Skip to content

Commit

Permalink
Merge branch 'release/2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
benhuson committed Oct 17, 2017
2 parents 6f3ef58 + 909ced2 commit 6400e69
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 13 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [2.1] - 2017-07-27

### Added
- Update caching notes for WP Engine and W3 Total Cache plugin.
- Tested up to WordPress 4.8

## [2.0.3] - 2015-03-23

### Added
Expand Down Expand Up @@ -169,7 +175,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added
- First Release. If you spot any bugs or issues please [log them here](https://github.com/benhuson/password-protected/issues).

[Unreleased]: https://github.com/benhuson/password-protected/compare/2.0.3...HEAD
[Unreleased]: https://github.com/benhuson/password-protected/compare/2.1...HEAD
[2.0.3]: https://github.com/benhuson/password-protected/compare/2.0.3...2.1
[2.0.3]: https://github.com/benhuson/password-protected/compare/2.0.2...2.0.3
[2.0.2]: https://github.com/benhuson/password-protected/compare/2.0.1...2.0.2
[2.0.1]: https://github.com/benhuson/password-protected/compare/2.0...2.0.1
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Features include:
- Works with Mark Jaquith's [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin.
- Works with the [Uber Login Logo](http://wordpress.org/plugins/uber-login-logo/) plugin.

> Please note, this plugin does not currently work with WP Engine hosting due to their page caching implementation.
> Please note, this plugin works by setting a cookie to allow access to the site. If you are using a caching plugin or web hosting such as WP Engine that has in-built caching, you will need to configure the caching service to be disabled if the Password Protected cookie is set.
Translations
------------
Expand Down Expand Up @@ -71,6 +71,9 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o
Upgrade Notice
--------------

### 2.1
Update caching notes for WP Engine and W3 Total Cache plugin.

### 2.0.3
Show user's IP address beside "Allow IP Addresses" admin setting. Declare methods as public or private and use PHP5 constructors.

Expand Down
165 changes: 165 additions & 0 deletions admin/admin-caching.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?php

/**
* @package Password Protected
* @subpackage Admin Caching
*
* @since 2.1
*/

class Password_Protected_Admin_Caching {

/**
* Plugin
*
* @since 2.1
*
* @var Password_Protected|null
*/
private $plugin = null;

/**
* Constructor
*
* @since 2.1
*
* @internal Private. This class should only be instantiated once by the plugin.
*/
public function __construct( $plugin ) {

$this->plugin = $plugin;

add_action( 'admin_init', array( $this, 'cache_settings_info' ) );

}

/**
* Cache Settings Info
*
* Displays information on the settings page for helping
* to configure Password Protected to work with caching setups.
*
* @since 2.1
*/
public function cache_settings_info() {

// Caching Section
add_settings_section(
'password_protected_compat_caching',
__( 'Caching', 'password-protected' ),
array( $this, 'section_caching' ),
'password-protected-compat'
);

// Cookies
add_settings_field(
'password_protected_compat_caching_cookie',
__( 'Cookies', 'password-protected' ),
array( $this, 'field_cookies' ),
'password-protected-compat',
'password_protected_compat_caching'
);

// WP Engine Hosting
if ( $this->test_wp_engine() ) {

add_settings_field(
'password_protected_compat_caching_wp_engine',
__( 'WP Engine Hosting', 'password-protected' ),
array( $this, 'field_wp_engine' ),
'password-protected-compat',
'password_protected_compat_caching'
);

}

// W3 Total Cache
if ( $this->test_w3_total_cache() ) {

add_settings_field(
'password_protected_compat_caching_w3_total_cache',
__( 'W3 Total Cache', 'password-protected' ),
array( $this, 'field_w3_total_cache' ),
'password-protected-compat',
'password_protected_compat_caching'
);

}

}

/**
* Caching Section
*
* @since 2.1
*/
public function section_caching() {

echo '<p>' . __( 'Password Protected does not always work well with sites that use caching.', 'password-protected' ) . '<br />
' . __( 'If your site uses a caching plugin or yur web hosting uses server-side caching, you may need to configure your setup to disable caching for the Password Protected cookie:', 'password-protected' ) . '</p>';

}

/**
* Password Protection Status Field
*
* @since 2.1
*/
public function field_cookies() {

echo '<p><input type="text" value="' . esc_attr( $this->plugin->cookie_name() ) . '" class="regular-text code" /></p>';

}

/**
* WP Engine Hosting
*
* @since 2.1
*/
public function field_wp_engine() {

echo '<p>' . __( 'We have detected your site may be running on WP Engine hosting.', 'password-protected' ) . '<br />
' . __( 'In order for Password Protected to work with WP Engine\'s caching configuration you must ask them to disable caching for the Password Protected cookie.', 'password-protected' ) . '</p>';

}

/**
* W3 Total Cache Plugin
*
* @since 2.1
*/
public function field_w3_total_cache() {

echo '<p>' . __( 'It looks like you may be using the W3 Total Cache plugin?', 'password-protected' ) . '<br />
' . __( 'In order for Password Protected to work with W3 Total Cache you must disable caching when the Password Protected cookie is set.', 'password-protected' ) . '
' . sprintf( __( 'You can adjust the cookie settings for W3 Total Cache under <a href="%s">Performance > Page Cache > Advanced > Rejected Cookies</a>.', 'password-protected' ), admin_url( '/admin.php?page=w3tc_pgcache#advanced' ) ) . '</p>';

}

/**
* Test: WP Engine
*
* @since 2.1
*
* @return boolean
*/
private function test_wp_engine() {

return ( function_exists( 'is_wpe' ) && is_wpe() ) || ( function_exists( 'is_wpe_snapshot' ) && is_wpe_snapshot() );

}

/**
* Test: W3 Total Cache
*
* @since 2.1
*
* @return boolean
*/
private function test_w3_total_cache() {

return defined( 'W3TC' ) && W3TC;

}

}
1 change: 1 addition & 0 deletions admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function settings_page() {
?>
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( 'Save Changes' ) ?>"></p>
</form>
<?php do_settings_sections( 'password-protected-compat' ); ?>
</div>

<?php
Expand Down
16 changes: 8 additions & 8 deletions password-protected.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/*
Plugin Name: Password Protected
Plugin URI: https://wordpress.org/plugins/password-protected/
Description: A very simple way to quickly password protect your WordPress site with a single password. Please note: This plugin does not restrict access to uploaded files and images and does not work on WP Engine or with some caching setups.
Version: 2.0.3
Description: A very simple way to quickly password protect your WordPress site with a single password. Please note: This plugin does not restrict access to uploaded files and images and does not work with some caching setups.
Version: 2.1
Author: Ben Huson
Text Domain: password-protected
Author URI: http://github.com/benhuson/password-protected/
Expand Down Expand Up @@ -42,7 +42,7 @@

class Password_Protected {

var $version = '2.0.3';
var $version = '2.1';
var $admin = null;
var $errors = null;

Expand Down Expand Up @@ -74,8 +74,13 @@ public function __construct() {
add_shortcode( 'password_protected_logout_link', array( $this, 'logout_link_shortcode' ) );

if ( is_admin() ) {

include_once( dirname( __FILE__ ) . '/admin/admin-caching.php' );
include_once( dirname( __FILE__ ) . '/admin/admin.php' );

$this->admin_caching = new Password_Protected_Admin_Caching( $this );
$this->admin = new Password_Protected_Admin();

}

}
Expand Down Expand Up @@ -755,11 +760,6 @@ public function safe_redirect( $location, $status = 302 ) {
*/
static function is_plugin_supported() {

// WP Engine
if ( class_exists( 'WPE_API', false ) ) {
return new WP_Error( 'PASSWORD_PROTECTED_SUPPORT', __( 'The Password Protected plugin does not work with WP Engine hosting. Please disable it.', 'password-protected' ) );
}

return true;

}
Expand Down
13 changes: 10 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: husobj
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DXRJDNCMK9U3N
Tags: password, protect, password protect, login
Requires at least: 3.5
Tested up to: 4.4.2
Stable tag: 2.0.3
Tested up to: 4.8
Stable tag: 2.1
License: GPLv2 or later

A very simple way to quickly password protect your WordPress site with a single password.
Expand All @@ -23,7 +23,7 @@ Features include:
* Works with Mark Jaquith's [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin.
* Works with the [Uber Login Logo](http://wordpress.org/plugins/uber-login-logo/) plugin.

> Please note, this plugin does not currently work with WP Engine hosting due to their page caching implementation.
> Please note, this plugin works by setting a cookie to allow access to the site. If you are using a caching plugin or web hosting such as WP Engine that has in-built caching, you will need to configure the caching service to be disabled if the Password Protected cookie is set.

= Translations =

Expand Down Expand Up @@ -83,6 +83,10 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o

= Unreleased =

= 2.1 =
* Update caching notes for WP Engine and W3 Total Cache plugin.
* Tested up to WordPress 4.8

= 2.0.3 =
* Declare methods as public or private and use PHP5 constructors.
* Show user's IP address beside "Allow IP Addresses" admin setting.
Expand Down Expand Up @@ -182,6 +186,9 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o

== Upgrade Notice ==

= 2.1 =
Update caching notes for WP Engine and W3 Total Cache plugin.

= 2.0.3 =
Show user's IP address beside "Allow IP Addresses" admin setting. Declare methods as public or private and use PHP5 constructors.

Expand Down

0 comments on commit 6400e69

Please sign in to comment.