Version Description
- Add option to allow administrators to use the site without logging in.
- Use DONOTCACHEPAGE to try to prevent some caching issues.
- Updated login screen styling for WordPress 3.5 compatibility.
- Options are now on the 'Reading' settings page in WordPress 3.5
- Added a contextual help tab for WordPress 3.3+.
Download this release
Release Info
Developer | husobj |
Plugin | Password Protected |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.3 to 1.4
- admin/admin.php +26 -3
- password-protected.php +16 -3
- readme.txt +26 -18
- theme/login.php +2 -2
admin/admin.php
CHANGED
@@ -10,6 +10,7 @@ class Password_Protected_Admin {
|
|
10 |
function Password_Protected_Admin() {
|
11 |
global $wp_version;
|
12 |
add_action( 'admin_init', array( $this, 'privacy_settings' ) );
|
|
|
13 |
add_action( 'admin_notices', array( $this, 'password_protected_admin_notices' ) );
|
14 |
add_filter( 'pre_update_option_password_protected_password', array( $this, 'pre_update_option_password_protected_password' ), 10, 2 );
|
15 |
add_filter( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
@@ -20,6 +21,23 @@ class Password_Protected_Admin {
|
|
20 |
}
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
/**
|
24 |
* Admin Enqueue Scripts
|
25 |
*/
|
@@ -55,9 +73,10 @@ class Password_Protected_Admin {
|
|
55 |
'password_protected'
|
56 |
);
|
57 |
register_setting( $this->options_group, 'password_protected_status', 'intval' );
|
58 |
-
register_setting( $this->options_group, 'password_protected_password', array( $this, 'sanitize_password_protected_password' ) );
|
59 |
register_setting( $this->options_group, 'password_protected_feeds', 'intval' );
|
60 |
-
|
|
|
|
|
61 |
|
62 |
/**
|
63 |
* Sanitize Password Field Input
|
@@ -94,7 +113,8 @@ class Password_Protected_Admin {
|
|
94 |
*/
|
95 |
function password_protected_status_field() {
|
96 |
echo '<input name="password_protected_status" id="password_protected_status" type="checkbox" value="1" ' . checked( 1, get_option( 'password_protected_status' ), false ) . ' /> ' . __( 'Enabled', 'password-protected' );
|
97 |
-
echo '<input name="password_protected_feeds" id="password_protected_feeds" type="checkbox" value="1" ' . checked( 1, get_option( 'password_protected_feeds' ), false ) . ' style="margin-left: 20px;" /> ' . __( 'Allow Feeds', 'password-protected' );
|
|
|
98 |
}
|
99 |
|
100 |
/**
|
@@ -135,6 +155,9 @@ class Password_Protected_Admin {
|
|
135 |
if ( (bool) $status && empty( $pwd ) ) {
|
136 |
echo '<div class="error"><p>' . __( 'You have enabled password protection but not yet set a password. Please set one below.', 'password-protected' ) . '</p></div>';
|
137 |
}
|
|
|
|
|
|
|
138 |
}
|
139 |
}
|
140 |
|
10 |
function Password_Protected_Admin() {
|
11 |
global $wp_version;
|
12 |
add_action( 'admin_init', array( $this, 'privacy_settings' ) );
|
13 |
+
add_action( 'load-options-reading.php', array( $this, 'add_reading_help_tabs' ), 20 );
|
14 |
add_action( 'admin_notices', array( $this, 'password_protected_admin_notices' ) );
|
15 |
add_filter( 'pre_update_option_password_protected_password', array( $this, 'pre_update_option_password_protected_password' ), 10, 2 );
|
16 |
add_filter( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
21 |
}
|
22 |
}
|
23 |
|
24 |
+
/**
|
25 |
+
* Add Reading Help Tabs
|
26 |
+
*/
|
27 |
+
function add_reading_help_tabs() {
|
28 |
+
global $wp_version;
|
29 |
+
if ( version_compare( $wp_version, '3.3', '<' ) )
|
30 |
+
return;
|
31 |
+
get_current_screen()->add_help_tab( array(
|
32 |
+
'id' => 'PASSWORD_PROTECTED_READING',
|
33 |
+
'title' => __( 'Password Protected', 'password-protected' ),
|
34 |
+
'content' => __( '<p><strong>Enabled Checkbox</strong><br />Turn on/off password protection.</p>', 'password-protected' )
|
35 |
+
. __( '<p><strong>Allow RSS Feeds Checkbox</strong><br />RSS Feeds will be able to accessed even when the site is password proteced.</p>', 'password-protected' )
|
36 |
+
. __( '<p><strong>Allow Administrators Checkbox</strong><br />Administrators will not need to enter a password to view the site (providing they are logged in of course). You will also need to enable this option if you want administrators to be able to preview the site in the Theme Customizer.</p>', 'password-protected' )
|
37 |
+
. __( '<p><strong>Password Fields</strong><br />To set a new password, enter it into both fields. You cannot set an `empty` password. To disable password protection uncheck the Enabled checkbox.</p>', 'password-protected' )
|
38 |
+
) );
|
39 |
+
}
|
40 |
+
|
41 |
/**
|
42 |
* Admin Enqueue Scripts
|
43 |
*/
|
73 |
'password_protected'
|
74 |
);
|
75 |
register_setting( $this->options_group, 'password_protected_status', 'intval' );
|
|
|
76 |
register_setting( $this->options_group, 'password_protected_feeds', 'intval' );
|
77 |
+
register_setting( $this->options_group, 'password_protected_administrators', 'intval' );
|
78 |
+
register_setting( $this->options_group, 'password_protected_password', array( $this, 'sanitize_password_protected_password' ) );
|
79 |
+
}
|
80 |
|
81 |
/**
|
82 |
* Sanitize Password Field Input
|
113 |
*/
|
114 |
function password_protected_status_field() {
|
115 |
echo '<input name="password_protected_status" id="password_protected_status" type="checkbox" value="1" ' . checked( 1, get_option( 'password_protected_status' ), false ) . ' /> ' . __( 'Enabled', 'password-protected' );
|
116 |
+
echo '<input name="password_protected_feeds" id="password_protected_feeds" type="checkbox" value="1" ' . checked( 1, get_option( 'password_protected_feeds' ), false ) . ' style="margin-left: 20px;" /> ' . __( 'Allow RSS Feeds', 'password-protected' );
|
117 |
+
echo '<input name="password_protected_administrators" id="password_protected_administrators" type="checkbox" value="1" ' . checked( 1, get_option( 'password_protected_administrators' ), false ) . ' style="margin-left: 20px;" /> ' . __( 'Allow Administrators', 'password-protected' );
|
118 |
}
|
119 |
|
120 |
/**
|
155 |
if ( (bool) $status && empty( $pwd ) ) {
|
156 |
echo '<div class="error"><p>' . __( 'You have enabled password protection but not yet set a password. Please set one below.', 'password-protected' ) . '</p></div>';
|
157 |
}
|
158 |
+
if ( current_user_can( 'manage_options' ) && (bool) get_option( 'password_protected_administrators' ) ) {
|
159 |
+
echo '<div class="error"><p>' . __( 'You have enabled password protection and allowed administrators - other users will still need to login to view the site.', 'password-protected' ) . '</p></div>';
|
160 |
+
}
|
161 |
}
|
162 |
}
|
163 |
|
password-protected.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
Plugin Name: Password Protected
|
5 |
Plugin URI: http://www.benhuson.co.uk/
|
6 |
Description: A very simple way to quickly password protect your WordPress site with a single password. Integrates seamlessly into your WordPress privacy settings.
|
7 |
-
Version: 1.
|
8 |
Author: Ben Huson
|
9 |
Author URI: http://www.benhuson.co.uk/
|
10 |
License: GPLv2
|
@@ -40,7 +40,7 @@ $Password_Protected = new Password_Protected();
|
|
40 |
|
41 |
class Password_Protected {
|
42 |
|
43 |
-
var $version = '1.
|
44 |
var $admin = null;
|
45 |
var $errors = null;
|
46 |
|
@@ -55,6 +55,7 @@ class Password_Protected {
|
|
55 |
add_action( 'wp', array( $this, 'disable_feeds' ) );
|
56 |
add_action( 'template_redirect', array( $this, 'maybe_show_login' ), 1 );
|
57 |
add_filter( 'pre_option_password_protected_status', array( $this, 'allow_feeds' ) );
|
|
|
58 |
if ( is_admin() ) {
|
59 |
include_once( dirname( __FILE__ ) . '/admin/admin.php' );
|
60 |
$this->admin = new Password_Protected_Admin();
|
@@ -72,8 +73,11 @@ class Password_Protected {
|
|
72 |
* Is Active?
|
73 |
*/
|
74 |
function is_active() {
|
75 |
-
if ( (bool) get_option( 'password_protected_status' ) )
|
|
|
|
|
76 |
return true;
|
|
|
77 |
return false;
|
78 |
}
|
79 |
|
@@ -109,6 +113,15 @@ class Password_Protected {
|
|
109 |
return $bool;
|
110 |
}
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
/**
|
113 |
* Maybe Process Login
|
114 |
*/
|
4 |
Plugin Name: Password Protected
|
5 |
Plugin URI: http://www.benhuson.co.uk/
|
6 |
Description: A very simple way to quickly password protect your WordPress site with a single password. Integrates seamlessly into your WordPress privacy settings.
|
7 |
+
Version: 1.4
|
8 |
Author: Ben Huson
|
9 |
Author URI: http://www.benhuson.co.uk/
|
10 |
License: GPLv2
|
40 |
|
41 |
class Password_Protected {
|
42 |
|
43 |
+
var $version = '1.4';
|
44 |
var $admin = null;
|
45 |
var $errors = null;
|
46 |
|
55 |
add_action( 'wp', array( $this, 'disable_feeds' ) );
|
56 |
add_action( 'template_redirect', array( $this, 'maybe_show_login' ), 1 );
|
57 |
add_filter( 'pre_option_password_protected_status', array( $this, 'allow_feeds' ) );
|
58 |
+
add_filter( 'pre_option_password_protected_status', array( $this, 'allow_administrators' ) );
|
59 |
if ( is_admin() ) {
|
60 |
include_once( dirname( __FILE__ ) . '/admin/admin.php' );
|
61 |
$this->admin = new Password_Protected_Admin();
|
73 |
* Is Active?
|
74 |
*/
|
75 |
function is_active() {
|
76 |
+
if ( (bool) get_option( 'password_protected_status' ) ) {
|
77 |
+
if ( ! defined( 'DONOTCACHEPAGE' ) )
|
78 |
+
define( 'DONOTCACHEPAGE', true );
|
79 |
return true;
|
80 |
+
}
|
81 |
return false;
|
82 |
}
|
83 |
|
113 |
return $bool;
|
114 |
}
|
115 |
|
116 |
+
/**
|
117 |
+
* Allow Administrators
|
118 |
+
*/
|
119 |
+
function allow_administrators( $bool ) {
|
120 |
+
if ( ! is_admin() && current_user_can( 'manage_options' ) && (bool) get_option( 'password_protected_administrators' ) )
|
121 |
+
return 0;
|
122 |
+
return $bool;
|
123 |
+
}
|
124 |
+
|
125 |
/**
|
126 |
* Maybe Process Login
|
127 |
*/
|
readme.txt
CHANGED
@@ -3,20 +3,22 @@ Contributors: husobj
|
|
3 |
Donate link: http://www.benhuson.co.uk/donate/
|
4 |
Tags: password, protect, password protect, login
|
5 |
Requires at least: 3.0
|
6 |
-
Tested up to: 3.
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
-
A very simple way to quickly password protect your WordPress site with a single password. Integrates seamlessly into your WordPress
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
A very simple way to quickly password protect your WordPress site with a single password. Integrates seamlessly into your WordPress
|
15 |
|
16 |
Features include:
|
17 |
|
18 |
* Password protect your WordPress site with a single password.
|
19 |
-
*
|
|
|
|
|
20 |
* Works with Mark Jaquith's [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin.
|
21 |
|
22 |
== Installation ==
|
@@ -25,7 +27,7 @@ To install and configure this plugin...
|
|
25 |
|
26 |
1. Upload or install the plugin through your WordPress admin.
|
27 |
2. Activate the plugin via the 'Plugins' admin menu.
|
28 |
-
3. Configuration the password in your WordPress
|
29 |
|
30 |
= Upgrading =
|
31 |
|
@@ -34,36 +36,44 @@ If you are upgrading manually via FTP rather that through the WordPress automati
|
|
34 |
== Frequently Asked Questions ==
|
35 |
|
36 |
= How can I change the Wordpress logo to a different image? =
|
37 |
-
|
38 |
Install and configure the [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin by Mark Jaquith. This will change the logo on your password entry page AND also your admin login page.
|
39 |
|
40 |
= How can I enable feeds while the site is password protected? =
|
41 |
-
|
42 |
In the settings, check the 'Allow Feeds' checkbox.
|
43 |
|
44 |
-
=
|
|
|
|
|
|
|
|
|
45 |
|
|
|
46 |
Just add a "password-protected=logout" query to your URL.
|
47 |
eg. http://www.example.com/?password-protected=logout
|
48 |
|
49 |
= Where can I report bugs and issues? =
|
50 |
-
|
51 |
Please log issues and bugs on the plugin's [GitHub page](https://github.com/benhuson/password-protected/issues).
|
52 |
You can also submit suggested enhancements if you like.
|
53 |
|
54 |
= How can I contribute? =
|
55 |
-
|
56 |
If you can, please [fork the code](https://github.com/benhuson/password-protected) and submit a pull request via GitHub. If you're not comfortable using Git, then please just submit it to the issues link above.
|
57 |
|
58 |
== Screenshots ==
|
59 |
|
60 |
1. Login page perfectly mimicks the WordPress login.
|
61 |
-
2. Integrates seamlessly into your WordPress
|
|
|
62 |
|
63 |
== Changelog ==
|
64 |
|
65 |
-
= 1.
|
|
|
|
|
|
|
|
|
|
|
66 |
|
|
|
67 |
* Added checkbox to allow access to feeds when protection is enabled.
|
68 |
* Prepare for WordPress 3.5 Settings API changes.
|
69 |
* Added 'password_protected_before_login_form' and 'password_protected_after_login_form' actions.
|
@@ -72,29 +82,27 @@ If you can, please [fork the code](https://github.com/benhuson/password-protecte
|
|
72 |
* Ready for [translations](http://codex.wordpress.org/I18n_for_WordPress_Developers).
|
73 |
|
74 |
= 1.2.2 =
|
75 |
-
|
76 |
* Escape 'redirect_to' attribute. Props A. Alagha.
|
77 |
* Show login error messages.
|
78 |
|
79 |
= 1.2.1 =
|
80 |
-
|
81 |
* Only disable feeds when protection is active.
|
82 |
* Added a "How to log out?" FAQ.
|
83 |
|
84 |
= 1.2 =
|
85 |
-
|
86 |
* Use cookies instead of sessions.
|
87 |
-
|
88 |
= 1.1 =
|
89 |
|
90 |
* Encrypt passwords in database.
|
91 |
-
|
92 |
= 1.0 =
|
93 |
|
94 |
* First Release. If you spot any bugs or issues please [log them here](https://github.com/benhuson/password-protected/issues).
|
95 |
|
96 |
== Upgrade Notice ==
|
97 |
|
|
|
|
|
|
|
98 |
= 1.3 =
|
99 |
Allow access to feeds. Ready for translation.
|
100 |
|
3 |
Donate link: http://www.benhuson.co.uk/donate/
|
4 |
Tags: password, protect, password protect, login
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 3.5
|
7 |
+
Stable tag: 1.4
|
8 |
License: GPLv2 or later
|
9 |
|
10 |
+
A very simple way to quickly password protect your WordPress site with a single password. Integrates seamlessly into your WordPress settings.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
A very simple way to quickly password protect your WordPress site with a single password. Integrates seamlessly into your WordPress settings.
|
15 |
|
16 |
Features include:
|
17 |
|
18 |
* Password protect your WordPress site with a single password.
|
19 |
+
* Option to allow access to feeds.
|
20 |
+
* Option to allow administrators access without entering password.
|
21 |
+
* Integrates seamlessly into your WordPress reading settings (or privacy settings prior to WordPress 3.5).
|
22 |
* Works with Mark Jaquith's [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin.
|
23 |
|
24 |
== Installation ==
|
27 |
|
28 |
1. Upload or install the plugin through your WordPress admin.
|
29 |
2. Activate the plugin via the 'Plugins' admin menu.
|
30 |
+
3. Configuration the password in your WordPress reading settings (or privacy settings prior to WordPress 3.5).
|
31 |
|
32 |
= Upgrading =
|
33 |
|
36 |
== Frequently Asked Questions ==
|
37 |
|
38 |
= How can I change the Wordpress logo to a different image? =
|
|
|
39 |
Install and configure the [Login Logo](http://wordpress.org/extend/plugins/login-logo/) plugin by Mark Jaquith. This will change the logo on your password entry page AND also your admin login page.
|
40 |
|
41 |
= How can I enable feeds while the site is password protected? =
|
|
|
42 |
In the settings, check the 'Allow Feeds' checkbox.
|
43 |
|
44 |
+
= Can I prevent administrators having to enter password? =
|
45 |
+
In the settings, check the 'Allow Administrators' checkbox.
|
46 |
+
|
47 |
+
= I cannot preview my changes in the Theme Customizer =
|
48 |
+
You must be an administrator (have the manage_options capability) and in the Password Protected settings, check the 'Allow Administrators' checkbox.
|
49 |
|
50 |
+
= How can I log out? =
|
51 |
Just add a "password-protected=logout" query to your URL.
|
52 |
eg. http://www.example.com/?password-protected=logout
|
53 |
|
54 |
= Where can I report bugs and issues? =
|
|
|
55 |
Please log issues and bugs on the plugin's [GitHub page](https://github.com/benhuson/password-protected/issues).
|
56 |
You can also submit suggested enhancements if you like.
|
57 |
|
58 |
= How can I contribute? =
|
|
|
59 |
If you can, please [fork the code](https://github.com/benhuson/password-protected) and submit a pull request via GitHub. If you're not comfortable using Git, then please just submit it to the issues link above.
|
60 |
|
61 |
== Screenshots ==
|
62 |
|
63 |
1. Login page perfectly mimicks the WordPress login.
|
64 |
+
2. Integrates seamlessly into your WordPress reading settings in WordPress 3.5+.
|
65 |
+
3. Integrates into your WordPress privacy settings in earlier versions of WordPress.
|
66 |
|
67 |
== Changelog ==
|
68 |
|
69 |
+
= 1.4 =
|
70 |
+
* Add option to allow administrators to use the site without logging in.
|
71 |
+
* Use DONOTCACHEPAGE to try to prevent some caching issues.
|
72 |
+
* Updated login screen styling for WordPress 3.5 compatibility.
|
73 |
+
* Options are now on the 'Reading' settings page in WordPress 3.5
|
74 |
+
* Added a contextual help tab for WordPress 3.3+.
|
75 |
|
76 |
+
= 1.3 =
|
77 |
* Added checkbox to allow access to feeds when protection is enabled.
|
78 |
* Prepare for WordPress 3.5 Settings API changes.
|
79 |
* Added 'password_protected_before_login_form' and 'password_protected_after_login_form' actions.
|
82 |
* Ready for [translations](http://codex.wordpress.org/I18n_for_WordPress_Developers).
|
83 |
|
84 |
= 1.2.2 =
|
|
|
85 |
* Escape 'redirect_to' attribute. Props A. Alagha.
|
86 |
* Show login error messages.
|
87 |
|
88 |
= 1.2.1 =
|
|
|
89 |
* Only disable feeds when protection is active.
|
90 |
* Added a "How to log out?" FAQ.
|
91 |
|
92 |
= 1.2 =
|
|
|
93 |
* Use cookies instead of sessions.
|
|
|
94 |
= 1.1 =
|
95 |
|
96 |
* Encrypt passwords in database.
|
|
|
97 |
= 1.0 =
|
98 |
|
99 |
* First Release. If you spot any bugs or issues please [log them here](https://github.com/benhuson/password-protected/issues).
|
100 |
|
101 |
== Upgrade Notice ==
|
102 |
|
103 |
+
= 1.4 =
|
104 |
+
Administrators can use the site without logging in. WordPress 3.5 compatible.
|
105 |
+
|
106 |
= 1.3 =
|
107 |
Allow access to feeds. Ready for translation.
|
108 |
|
theme/login.php
CHANGED
@@ -78,7 +78,7 @@ do_action( 'password_protected_login_head' );
|
|
78 |
?>
|
79 |
|
80 |
</head>
|
81 |
-
<body class="login login-password-protected">
|
82 |
|
83 |
<div id="login">
|
84 |
<h1><a href="<?php echo esc_url( apply_filters( 'password_proteced_login_headerurl', home_url( '/' ) ) ); ?>" title="<?php echo esc_attr( apply_filters( 'password_protected_login_headertitle', get_bloginfo( 'name' ) ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
|
@@ -118,7 +118,7 @@ do_action( 'password_protected_login_head' );
|
|
118 |
<p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90"<?php checked( ! empty( $_POST['rememberme'] ) ); ?> /> <?php esc_attr_e( 'Remember Me', 'password-protected' ); ?></label></p>
|
119 |
-->
|
120 |
<p class="submit">
|
121 |
-
<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="<?php esc_attr_e( 'Log In', 'password-protected' ); ?>" tabindex="100" />
|
122 |
<input type="hidden" name="testcookie" value="1" />
|
123 |
<input type="hidden" name="password-protected" value="login" />
|
124 |
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $_REQUEST['redirect_to'] ); ?>" />
|
78 |
?>
|
79 |
|
80 |
</head>
|
81 |
+
<body class="login login-password-protected login-action-password-protected-login wp-core-ui">
|
82 |
|
83 |
<div id="login">
|
84 |
<h1><a href="<?php echo esc_url( apply_filters( 'password_proteced_login_headerurl', home_url( '/' ) ) ); ?>" title="<?php echo esc_attr( apply_filters( 'password_protected_login_headertitle', get_bloginfo( 'name' ) ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1>
|
118 |
<p class="forgetmenot"><label for="rememberme"><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="90"<?php checked( ! empty( $_POST['rememberme'] ) ); ?> /> <?php esc_attr_e( 'Remember Me', 'password-protected' ); ?></label></p>
|
119 |
-->
|
120 |
<p class="submit">
|
121 |
+
<input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e( 'Log In', 'password-protected' ); ?>" tabindex="100" />
|
122 |
<input type="hidden" name="testcookie" value="1" />
|
123 |
<input type="hidden" name="password-protected" value="login" />
|
124 |
<input type="hidden" name="redirect_to" value="<?php echo esc_attr( $_REQUEST['redirect_to'] ); ?>" />
|