Password Protected - Version 2.1

Version Description

  • Update caching notes for WP Engine and W3 Total Cache plugin.
  • Tested up to WordPress 4.8
Download this release

Release Info

Developer husobj
Plugin Icon 128x128 Password Protected
Version 2.1
Comparing to
See all releases

Code changes from version 2.0.3 to 2.1

Files changed (6) hide show
  1. CHANGELOG.md +8 -1
  2. README.md +4 -1
  3. admin/admin-caching.php +165 -0
  4. admin/admin.php +1 -0
  5. password-protected.php +8 -8
  6. readme.txt +11 -3
CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
 
5
  ## [Unreleased]
6
 
 
 
 
 
 
 
7
  ## [2.0.3] - 2015-03-23
8
 
9
  ### Added
@@ -169,7 +175,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
169
  ### Added
170
  - First Release. If you spot any bugs or issues please [log them here](https://github.com/benhuson/password-protected/issues).
171
 
172
- [Unreleased]: https://github.com/benhuson/password-protected/compare/2.0.3...HEAD
 
173
  [2.0.3]: https://github.com/benhuson/password-protected/compare/2.0.2...2.0.3
174
  [2.0.2]: https://github.com/benhuson/password-protected/compare/2.0.1...2.0.2
175
  [2.0.1]: https://github.com/benhuson/password-protected/compare/2.0...2.0.1
4
 
5
  ## [Unreleased]
6
 
7
+ ## [2.1] - 2017-07-27
8
+
9
+ ### Added
10
+ - Update caching notes for WP Engine and W3 Total Cache plugin.
11
+ - Tested up to WordPress 4.8
12
+
13
  ## [2.0.3] - 2015-03-23
14
 
15
  ### Added
175
  ### Added
176
  - First Release. If you spot any bugs or issues please [log them here](https://github.com/benhuson/password-protected/issues).
177
 
178
+ [Unreleased]: https://github.com/benhuson/password-protected/compare/2.1...HEAD
179
+ [2.1]: https://github.com/benhuson/password-protected/compare/2.0.3...2.1
180
  [2.0.3]: https://github.com/benhuson/password-protected/compare/2.0.2...2.0.3
181
  [2.0.2]: https://github.com/benhuson/password-protected/compare/2.0.1...2.0.2
182
  [2.0.1]: https://github.com/benhuson/password-protected/compare/2.0...2.0.1
README.md CHANGED
@@ -13,7 +13,7 @@ Features include:
13
  - Works with Mark Jaquith's [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin.
14
  - Works with the [Uber Login Logo](http://wordpress.org/plugins/uber-login-logo/) plugin.
15
 
16
- > Please note, this plugin does not currently work with WP Engine hosting due to their page caching implementation.
17
 
18
  Translations
19
  ------------
@@ -71,6 +71,9 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o
71
  Upgrade Notice
72
  --------------
73
 
 
 
 
74
  ### 2.0.3
75
  Show user's IP address beside "Allow IP Addresses" admin setting. Declare methods as public or private and use PHP5 constructors.
76
 
13
  - Works with Mark Jaquith's [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin.
14
  - Works with the [Uber Login Logo](http://wordpress.org/plugins/uber-login-logo/) plugin.
15
 
16
+ > 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.
17
 
18
  Translations
19
  ------------
71
  Upgrade Notice
72
  --------------
73
 
74
+ ### 2.1
75
+ Update caching notes for WP Engine and W3 Total Cache plugin.
76
+
77
  ### 2.0.3
78
  Show user's IP address beside "Allow IP Addresses" admin setting. Declare methods as public or private and use PHP5 constructors.
79
 
admin/admin-caching.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Password Protected
5
+ * @subpackage Admin Caching
6
+ *
7
+ * @since 2.1
8
+ */
9
+
10
+ class Password_Protected_Admin_Caching {
11
+
12
+ /**
13
+ * Plugin
14
+ *
15
+ * @since 2.1
16
+ *
17
+ * @var Password_Protected|null
18
+ */
19
+ private $plugin = null;
20
+
21
+ /**
22
+ * Constructor
23
+ *
24
+ * @since 2.1
25
+ *
26
+ * @internal Private. This class should only be instantiated once by the plugin.
27
+ */
28
+ public function __construct( $plugin ) {
29
+
30
+ $this->plugin = $plugin;
31
+
32
+ add_action( 'admin_init', array( $this, 'cache_settings_info' ) );
33
+
34
+ }
35
+
36
+ /**
37
+ * Cache Settings Info
38
+ *
39
+ * Displays information on the settings page for helping
40
+ * to configure Password Protected to work with caching setups.
41
+ *
42
+ * @since 2.1
43
+ */
44
+ public function cache_settings_info() {
45
+
46
+ // Caching Section
47
+ add_settings_section(
48
+ 'password_protected_compat_caching',
49
+ __( 'Caching', 'password-protected' ),
50
+ array( $this, 'section_caching' ),
51
+ 'password-protected-compat'
52
+ );
53
+
54
+ // Cookies
55
+ add_settings_field(
56
+ 'password_protected_compat_caching_cookie',
57
+ __( 'Cookies', 'password-protected' ),
58
+ array( $this, 'field_cookies' ),
59
+ 'password-protected-compat',
60
+ 'password_protected_compat_caching'
61
+ );
62
+
63
+ // WP Engine Hosting
64
+ if ( $this->test_wp_engine() ) {
65
+
66
+ add_settings_field(
67
+ 'password_protected_compat_caching_wp_engine',
68
+ __( 'WP Engine Hosting', 'password-protected' ),
69
+ array( $this, 'field_wp_engine' ),
70
+ 'password-protected-compat',
71
+ 'password_protected_compat_caching'
72
+ );
73
+
74
+ }
75
+
76
+ // W3 Total Cache
77
+ if ( $this->test_w3_total_cache() ) {
78
+
79
+ add_settings_field(
80
+ 'password_protected_compat_caching_w3_total_cache',
81
+ __( 'W3 Total Cache', 'password-protected' ),
82
+ array( $this, 'field_w3_total_cache' ),
83
+ 'password-protected-compat',
84
+ 'password_protected_compat_caching'
85
+ );
86
+
87
+ }
88
+
89
+ }
90
+
91
+ /**
92
+ * Caching Section
93
+ *
94
+ * @since 2.1
95
+ */
96
+ public function section_caching() {
97
+
98
+ echo '<p>' . __( 'Password Protected does not always work well with sites that use caching.', 'password-protected' ) . '<br />
99
+ ' . __( '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>';
100
+
101
+ }
102
+
103
+ /**
104
+ * Password Protection Status Field
105
+ *
106
+ * @since 2.1
107
+ */
108
+ public function field_cookies() {
109
+
110
+ echo '<p><input type="text" value="' . esc_attr( $this->plugin->cookie_name() ) . '" class="regular-text code" /></p>';
111
+
112
+ }
113
+
114
+ /**
115
+ * WP Engine Hosting
116
+ *
117
+ * @since 2.1
118
+ */
119
+ public function field_wp_engine() {
120
+
121
+ echo '<p>' . __( 'We have detected your site may be running on WP Engine hosting.', 'password-protected' ) . '<br />
122
+ ' . __( '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>';
123
+
124
+ }
125
+
126
+ /**
127
+ * W3 Total Cache Plugin
128
+ *
129
+ * @since 2.1
130
+ */
131
+ public function field_w3_total_cache() {
132
+
133
+ echo '<p>' . __( 'It looks like you may be using the W3 Total Cache plugin?', 'password-protected' ) . '<br />
134
+ ' . __( 'In order for Password Protected to work with W3 Total Cache you must disable caching when the Password Protected cookie is set.', 'password-protected' ) . '
135
+ ' . 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>';
136
+
137
+ }
138
+
139
+ /**
140
+ * Test: WP Engine
141
+ *
142
+ * @since 2.1
143
+ *
144
+ * @return boolean
145
+ */
146
+ private function test_wp_engine() {
147
+
148
+ return ( function_exists( 'is_wpe' ) && is_wpe() ) || ( function_exists( 'is_wpe_snapshot' ) && is_wpe_snapshot() );
149
+
150
+ }
151
+
152
+ /**
153
+ * Test: W3 Total Cache
154
+ *
155
+ * @since 2.1
156
+ *
157
+ * @return boolean
158
+ */
159
+ private function test_w3_total_cache() {
160
+
161
+ return defined( 'W3TC' ) && W3TC;
162
+
163
+ }
164
+
165
+ }
admin/admin.php CHANGED
@@ -48,6 +48,7 @@ class Password_Protected_Admin {
48
  ?>
49
  <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( 'Save Changes' ) ?>"></p>
50
  </form>
 
51
  </div>
52
 
53
  <?php
48
  ?>
49
  <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e( 'Save Changes' ) ?>"></p>
50
  </form>
51
+ <?php do_settings_sections( 'password-protected-compat' ); ?>
52
  </div>
53
 
54
  <?php
password-protected.php CHANGED
@@ -3,8 +3,8 @@
3
  /*
4
  Plugin Name: Password Protected
5
  Plugin URI: https://wordpress.org/plugins/password-protected/
6
- 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.
7
- Version: 2.0.3
8
  Author: Ben Huson
9
  Text Domain: password-protected
10
  Author URI: http://github.com/benhuson/password-protected/
@@ -42,7 +42,7 @@ $Password_Protected = new Password_Protected();
42
 
43
  class Password_Protected {
44
 
45
- var $version = '2.0.3';
46
  var $admin = null;
47
  var $errors = null;
48
 
@@ -74,8 +74,13 @@ class Password_Protected {
74
  add_shortcode( 'password_protected_logout_link', array( $this, 'logout_link_shortcode' ) );
75
 
76
  if ( is_admin() ) {
 
 
77
  include_once( dirname( __FILE__ ) . '/admin/admin.php' );
 
 
78
  $this->admin = new Password_Protected_Admin();
 
79
  }
80
 
81
  }
@@ -755,11 +760,6 @@ class Password_Protected {
755
  */
756
  static function is_plugin_supported() {
757
 
758
- // WP Engine
759
- if ( class_exists( 'WPE_API', false ) ) {
760
- return new WP_Error( 'PASSWORD_PROTECTED_SUPPORT', __( 'The Password Protected plugin does not work with WP Engine hosting. Please disable it.', 'password-protected' ) );
761
- }
762
-
763
  return true;
764
 
765
  }
3
  /*
4
  Plugin Name: Password Protected
5
  Plugin URI: https://wordpress.org/plugins/password-protected/
6
+ 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.
7
+ Version: 2.1
8
  Author: Ben Huson
9
  Text Domain: password-protected
10
  Author URI: http://github.com/benhuson/password-protected/
42
 
43
  class Password_Protected {
44
 
45
+ var $version = '2.1';
46
  var $admin = null;
47
  var $errors = null;
48
 
74
  add_shortcode( 'password_protected_logout_link', array( $this, 'logout_link_shortcode' ) );
75
 
76
  if ( is_admin() ) {
77
+
78
+ include_once( dirname( __FILE__ ) . '/admin/admin-caching.php' );
79
  include_once( dirname( __FILE__ ) . '/admin/admin.php' );
80
+
81
+ $this->admin_caching = new Password_Protected_Admin_Caching( $this );
82
  $this->admin = new Password_Protected_Admin();
83
+
84
  }
85
 
86
  }
760
  */
761
  static function is_plugin_supported() {
762
 
 
 
 
 
 
763
  return true;
764
 
765
  }
readme.txt CHANGED
@@ -3,8 +3,9 @@ Contributors: husobj
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DXRJDNCMK9U3N
4
  Tags: password, protect, password protect, login
5
  Requires at least: 3.5
6
- Tested up to: 4.4.2
7
- Stable tag: 2.0.3
 
8
  License: GPLv2 or later
9
 
10
  A very simple way to quickly password protect your WordPress site with a single password.
@@ -23,7 +24,7 @@ Features include:
23
  * Works with Mark Jaquith's [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin.
24
  * Works with the [Uber Login Logo](http://wordpress.org/plugins/uber-login-logo/) plugin.
25
 
26
- > Please note, this plugin does not currently work with WP Engine hosting due to their page caching implementation.
27
 
28
  = Translations =
29
 
@@ -83,6 +84,10 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o
83
 
84
  = Unreleased =
85
 
 
 
 
 
86
  = 2.0.3 =
87
  * Declare methods as public or private and use PHP5 constructors.
88
  * Show user's IP address beside "Allow IP Addresses" admin setting.
@@ -182,6 +187,9 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o
182
 
183
  == Upgrade Notice ==
184
 
 
 
 
185
  = 2.0.3 =
186
  Show user's IP address beside "Allow IP Addresses" admin setting. Declare methods as public or private and use PHP5 constructors.
187
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DXRJDNCMK9U3N
4
  Tags: password, protect, password protect, login
5
  Requires at least: 3.5
6
+ Tested up to: 4.8
7
+ Requires PHP: 5.6
8
+ Stable tag: 2.1
9
  License: GPLv2 or later
10
 
11
  A very simple way to quickly password protect your WordPress site with a single password.
24
  * Works with Mark Jaquith's [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin.
25
  * Works with the [Uber Login Logo](http://wordpress.org/plugins/uber-login-logo/) plugin.
26
 
27
+ > 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.
28
 
29
  = Translations =
30
 
84
 
85
  = Unreleased =
86
 
87
+ = 2.1 =
88
+ * Update caching notes for WP Engine and W3 Total Cache plugin.
89
+ * Tested up to WordPress 4.8
90
+
91
  = 2.0.3 =
92
  * Declare methods as public or private and use PHP5 constructors.
93
  * Show user's IP address beside "Allow IP Addresses" admin setting.
187
 
188
  == Upgrade Notice ==
189
 
190
+ = 2.1 =
191
+ Update caching notes for WP Engine and W3 Total Cache plugin.
192
+
193
  = 2.0.3 =
194
  Show user's IP address beside "Allow IP Addresses" admin setting. Declare methods as public or private and use PHP5 constructors.
195