diff --git a/CHANGELOG.md b/CHANGELOG.md index ac27d73..6f2c359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [2.2.3] - 2019-01-10 + +### Fixed +- Restrict REST-API-access only if password protection is active. + +### Added +- Added viewport meta tag to login page. +- Added `password_protected_show_login` filter. + +### Changed +- Cookie name is not editable in the admin so display just for reference. +- Use default WordPress text domain for “Remember Me” and “Log In” buttons. + ## [2.2.2] - 2018-05-29 ### Changed @@ -199,7 +212,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.2.2...HEAD +[Unreleased]: https://github.com/benhuson/password-protected/compare/2.2.3...HEAD +[2.2.3]: https://github.com/benhuson/password-protected/compare/2.2.2...2.2.3 [2.2.2]: https://github.com/benhuson/password-protected/compare/2.2.1...2.2.2 [2.2.1]: https://github.com/benhuson/password-protected/compare/2.2...2.2.1 [2.2]: https://github.com/benhuson/password-protected/compare/2.1...2.2 diff --git a/README.md b/README.md index 253c3d5..083cd23 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,9 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o Upgrade Notice -------------- +### 2.2.3 +Restrict REST-API-access only if password protection is active. Added viewport meta tag to login page. + ### 2.2.2 Fix REST option and always allow access to REST API for logged in users. Change locked admin bar icon to green. diff --git a/admin/admin-caching.php b/admin/admin-caching.php index db34b88..ddcd450 100644 --- a/admin/admin-caching.php +++ b/admin/admin-caching.php @@ -54,7 +54,7 @@ public function cache_settings_info() { // Cookies add_settings_field( 'password_protected_compat_caching_cookie', - __( 'Cookies', 'password-protected' ), + __( 'Cookie Name', 'password-protected' ), array( $this, 'field_cookies' ), 'password-protected-compat', 'password_protected_compat_caching' @@ -96,7 +96,7 @@ public function cache_settings_info() { public function section_caching() { echo '

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

'; + ' . __( 'If your site uses a caching plugin or your web hosting uses server-side caching, you may need to configure your caching setup to disable caching for the Password Protected cookie:', 'password-protected' ) . '

'; } @@ -107,7 +107,7 @@ public function section_caching() { */ public function field_cookies() { - echo '

'; + echo '

' . esc_html( $this->plugin->cookie_name() ) . '

'; } diff --git a/admin/admin.php b/admin/admin.php index 93033ed..2b929e1 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -13,6 +13,7 @@ public function __construct() { global $wp_version; add_action( 'admin_init', array( $this, 'password_protected_settings' ), 5 ); + add_action( 'admin_init', array( $this, 'add_privacy_policy' ) ); add_action( 'admin_menu', array( $this, 'admin_menu' ) ); add_action( 'password_protected_help_tabs', array( $this, 'help_tabs' ), 5 ); add_action( 'admin_notices', array( $this, 'password_protected_admin_notices' ) ); @@ -22,6 +23,21 @@ public function __construct() { } + /** + * Add Privacy Policy + */ + public function add_privacy_policy() { + + if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { + return; + } + + $content = _x( 'The Password Protected plugin stores a cookie on successful password login containing a hashed version of the entered password. It does not store any information about the user. The cookie stored is named bid_n_password_protected_auth where n is the blog ID in a multisite network', 'privacy policy content', 'password-protected' ); + + wp_add_privacy_policy_content( __( 'Password Protected Plugin', 'password-protected' ), wp_kses_post( wpautop( $content, false ) ) ); + + } + /** * Admin Menu */ diff --git a/password-protected.php b/password-protected.php index 63e4a17..39af025 100644 --- a/password-protected.php +++ b/password-protected.php @@ -4,7 +4,7 @@ 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 with some caching setups. -Version: 2.2.2 +Version: 2.2.3 Author: Ben Huson Text Domain: password-protected Author URI: http://github.com/benhuson/password-protected/ @@ -42,7 +42,7 @@ class Password_Protected { - var $version = '2.2.2'; + var $version = '2.2.3'; var $admin = null; var $errors = null; @@ -345,13 +345,15 @@ public function is_user_logged_in() { */ public function maybe_show_login() { - // Don't show login if not enabled - if ( ! $this->is_active() ) { - return; - } + // Filter for adding exceptions. + $show_login = apply_filters( 'password_protected_show_login', $this->is_active() ); // Logged in - if ( $this->is_user_logged_in() ) { + if ( $this->is_user_logged_in() ) { + $show_login = false; + } + + if ( ! $show_login ) { return; } @@ -802,7 +804,7 @@ static function is_plugin_supported() { public function only_allow_logged_in_rest_access( $access ) { // If user is not logged in - if ( ! $this->is_user_logged_in() && ! is_user_logged_in() && ! (bool) get_option( 'password_protected_rest' ) ) { + if ( $this->is_active() && ! $this->is_user_logged_in() && ! is_user_logged_in() && ! (bool) get_option( 'password_protected_rest' ) ) { return new WP_Error( 'rest_cannot_access', __( 'Only authenticated users can access the REST API.', 'password-protected' ), array( 'status' => rest_authorization_required_code() ) ); } diff --git a/readme.txt b/readme.txt index 05206c6..f13c47e 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: password, protect, password protect, login Requires at least: 3.9 Tested up to: 4.9.6 Requires PHP: 5.6 -Stable tag: 2.2.2 +Stable tag: 2.2.3 License: GPLv2 or later A very simple way to quickly password protect your WordPress site with a single password. @@ -82,6 +82,13 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o == Changelog == += 2.2.3 = +- Restrict REST-API-access only if password protection is active. +- Added viewport meta tag to login page. +- Added `password_protected_show_login` filter. +- Cookie name is not editable in the admin so display just for reference. +- Use default WordPress text domain for “Remember Me” and “Log In” buttons. + = 2.2.2 = - Change locked admin bar icon to green. - Fix REST option and always allow access to REST API for logged in users. @@ -199,6 +206,9 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o == Upgrade Notice == += 2.2.3 = +Restrict REST-API-access only if password protection is active. Added viewport meta tag to login page. + = 2.2.2 = Fix REST option and always allow access to REST API for logged in users. Change locked admin bar icon to green. diff --git a/theme/password-protected-login.php b/theme/password-protected-login.php index 491ddf4..d2d2fd4 100644 --- a/theme/password-protected-login.php +++ b/theme/password-protected-login.php @@ -28,6 +28,17 @@ function shake(id,a,d){c=a.shift();s(id,c);if(a.length>0){setTimeout(function(){ } } +/** + * @since 3.7.0 + */ +if ( ! function_exists( 'wp_login_viewport_meta' ) ) { + function wp_login_viewport_meta() { + ?> + + 0){setTimeout(function(){ } // Obey privacy setting -add_action( 'password_protected_login_head', 'noindex' ); +add_action( 'password_protected_login_head', 'wp_no_robots' ); + +add_action( 'password_protected_login_head', 'wp_login_viewport_meta' ); ?> @@ -110,12 +123,12 @@ function shake(id,a,d){c=a.shift();s(id,c);if(a.length>0){setTimeout(function(){ allow_remember_me() ) : ?>

- +

- +