Skip to content

Commit

Permalink
Adds noindex to staging, updates documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanshoover committed Feb 9, 2019
1 parent 4ece493 commit a8c2354
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 35 deletions.
22 changes: 4 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
*.log
wp-config.php
wp-content/advanced-cache.php
wp-content/backup-db/
wp-content/backups/
wp-content/blogs.dir/
wp-content/cache/
wp-content/upgrade/
wp-content/uploads/
wp-content/mu-plugins/
wp-content/wp-cache-config.php
wp-content/plugins/hello.php

/.htaccess
/license.txt
/readme.html
/sitemap.xml
/sitemap.xml.gz
vendor
node_modules

*.log
.DS_Store
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Contributors: ryanshoover
* Tags: staging, woocommerce, email
* Requires at least: 4.7
* Tested up to: 5
* Tested up to: 5.0
* Requires PHP: 7.0
* License: GPL3
* License URI: www.gnu.org/licenses/gpl-3.0.en.html
Expand All @@ -12,7 +12,7 @@ Safely copy your WordPress, WooCommerce, and membership site between production

## Description

Simply define your production url in settings and copy your site to your staging instance without fear. The staging site won\'t send any emails and won\'t process any payments.
Simply define your production url in settings and copy your site to your staging instance without fear. The staging site won't send any emails and won't process any payments.

### Why should I use the plugin

Expand All @@ -22,6 +22,8 @@ Instead, install this plugin in production, set the production URL, and safely c

### Features on Staging

A "noindex" tag is added to all pages. Your staging site won't show up in Google.

WordPress emails are stopped. The site won't send any emails except for the password reset email. Please note, this feature may not be compatible with plugins that offload email to a 3rd party service.

The WooCommerce checkout page has a warning message notifying the visitor they are viewing the staging site.
Expand All @@ -32,6 +34,38 @@ WooCommerce Subscriptions is put into staging mode.

## Installation

1. Upload the plugin to wp-content/plugins/
2. Activate the plugin at wp-admin/plugins.php
3. Set the URL for your production site at /wp-admin/options-general.php?page=safe-staging
1. Upload the plugin to `/wp-content/plugins/`
2. Activate the plugin at `/wp-admin/plugins.php`
3. Set the URL for your production site at `/wp-admin/options-general.php?page=safe-staging`

## Hooks and Filters

```php
/**
* Change whether Safe Staging thinks the current site
* is the production site.
*
* @param bool $is_prod Is this the production site.
*/
apply_filters( 'safe_staging_is_production', $is_prod );
```

```php
/**
* Determine whether a particular email should be sent.
*
* @param bool $whitelisted Should the email actually send.
* @param object $this Instance of the Fake PHPMailer class.
*/
apply_filters( 'safe_staging_is_whitelist_email', $whitelisted, $this );
```

```php
/**
* Change the warning message that gets displayed on the checkout page
* of staging sites.
*
* @param string $notice HTML of the message to be shown.
*/
apply_filters( 'safe_staging_checkout_notice', $notice );
```
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
== Changelog ==

= 0.2 =
* Adds noindex tag to the staging site.
6 changes: 6 additions & 0 deletions inc/class-fake-phpmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ protected function is_whitelist_email() {
$whitelisted = true;
}

/**
* Determine whether the email should be sent.
*
* @param bool $whitelisted Should the email actually send.
* @param object $this Instance of the Fake PHPMailer class.
*/
return apply_filters( 'safe_staging_is_whitelist_email', $whitelisted, $this );
}

Expand Down
8 changes: 7 additions & 1 deletion inc/class-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public function do_checkout_notice() {
__( 'production site', 'safe-staging' )
);

wc_add_notice( $notice, 'error' );
/**
* Change the warning message that gets displayed on the checkout page
* of staging sites.
*
* @param string $notice HTML of the message to be shown.
*/
wc_add_notice( apply_filters( 'safe_staging_checkout_notice', $notice ), 'error' );
}
}
9 changes: 9 additions & 0 deletions inc/class-protection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public static function hooks() {
// Stop all emails.
$self->replace_mailer();

// Add a noindex tag to the header to stop indexing bots.
add_action( 'wp_head', 'wp_no_robots' );

// Remove all but most basic payment gateways.
add_filter( 'woocommerce_payment_gateways', [ $self, 'disable_payment_gateways' ], 999999 );

Expand Down Expand Up @@ -54,6 +57,12 @@ public static function is_production() {
$is_prod = true;
}

/**
* Change whether Safe Staging thinks the current site
* is the production site.
*
* @param bool $is_prod Is this the production site.
*/
return apply_filters( 'safe_staging_is_production', $is_prod );
}

Expand Down
52 changes: 41 additions & 11 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributors: ryanshoover
Tags: staging, woocommerce, email
Requires at least: 4.7
Tested up to: 5
Tested up to: 5.0
Requires PHP: 7.0
License: GPL3
License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
Expand All @@ -18,15 +18,45 @@ If you host your site on a managed host that provides a staging instance (WP Eng
Instead, install this plugin in production, set the production URL, and safely copy your site to and from staging. No other steps needed!

= Features on Staging =
WordPress emails are stopped. The site won't send any emails except for the password reset email. Please note, this feature may not be compatible with plugins that offload email to a 3rd party service.

The WooCommerce checkout page has a warning message notifying the visitor they are viewing the staging site.

WooCommerce payment gateways are suspended. Bank account transfer, Cash on Delivery and Check are left enabled. Stripe is automatically put into test mode.

WooCommerce Subscriptions is put into staging mode.
1. A "noindex" tag is added to all pages. Your staging site won't show up in Google.
2. WordPress emails are stopped. The site won't send any emails except for the password reset email. Please note, this feature may not be compatible with plugins that offload email to a 3rd party service.
3. The WooCommerce checkout page has a warning message notifying the visitor they are viewing the staging site.
4. WooCommerce payment gateways are suspended. Bank account transfer, Cash on Delivery and Check are left enabled. Stripe is automatically put into test mode.
5. WooCommerce Subscriptions is put into staging mode.

== Installation ==
1. Upload the plugin to wp-content/plugins/
2. Activate the plugin at wp-admin/plugins.php
3. Set the URL for your production site at /wp-admin/options-general.php?page=safe-staging
1. Upload the plugin to `/wp-content/plugins/`
2. Activate the plugin at `/wp-admin/plugins.php`
3. Set the URL for your production site at `/wp-admin/options-general.php?page=safe-staging`

== Hooks and Filters ==

```php
/**
* Change whether Safe Staging thinks the current site
* is the production site.
*
* @param bool $is_prod Is this the production site.
*/
apply_filters( 'safe_staging_is_production', $is_prod );
```

```php
/**
* Determine whether a particular email should be sent.
*
* @param bool $whitelisted Should the email actually send.
* @param object $this Instance of the Fake PHPMailer class.
*/
apply_filters( 'safe_staging_is_whitelist_email', $whitelisted, $this );
```

```php
/**
* Change the warning message that gets displayed on the checkout page
* of staging sites.
*
* @param string $notice HTML of the message to be shown.
*/
apply_filters( 'safe_staging_checkout_notice', $notice );
```

0 comments on commit a8c2354

Please sign in to comment.