From ab20f9785a87ff1c49f2233fbb1da7fc629eb4b4 Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Tue, 29 May 2018 20:26:53 +0100 Subject: [PATCH 1/5] Change locked padlock icon to green. Signed-off-by: Ben Huson --- admin/admin-bar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/admin-bar.php b/admin/admin-bar.php index be33f38..d4e2fe1 100644 --- a/admin/admin-bar.php +++ b/admin/admin-bar.php @@ -93,7 +93,7 @@ public static function styles() { if ( self::is_enabled() ) { $icon = '\f160'; // Locked - $background = '#C00'; + $background = '#46b450'; } else { $icon = '\f528'; // Unlocked $background = 'transparent'; From 8219da8d090c00827685ec977f4c424811a33cb2 Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Tue, 29 May 2018 20:41:16 +0100 Subject: [PATCH 2/5] Remove die() ! Signed-off-by: Ben Huson --- password-protected.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/password-protected.php b/password-protected.php index 8c86477..99db07e 100644 --- a/password-protected.php +++ b/password-protected.php @@ -799,7 +799,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() && ! (bool) get_option( 'password_protected_rest' ) ) {die(); + if ( ! $this->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() ) ); } From 1c142e9e4247a346e1ff1792ad3eef2ae7073b6e Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Tue, 29 May 2018 20:53:39 +0100 Subject: [PATCH 3/5] Always allow logged in users to use REST for Gutenberg and plugin compatibility. Signed-off-by: Ben Huson --- password-protected.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/password-protected.php b/password-protected.php index 99db07e..bbad4fa 100644 --- a/password-protected.php +++ b/password-protected.php @@ -799,7 +799,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() && ! (bool) get_option( 'password_protected_rest' ) ) { + if ( ! $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() ) ); } From 5a0f6ee5c013e2927361b9d4725f0e5ed93a8521 Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Tue, 29 May 2018 20:54:39 +0100 Subject: [PATCH 4/5] Document REST API changes. Signed-off-by: Ben Huson --- password-protected.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/password-protected.php b/password-protected.php index bbad4fa..b04d9fb 100644 --- a/password-protected.php +++ b/password-protected.php @@ -793,6 +793,9 @@ static function is_plugin_supported() { /** * Check whether a given request has permissions * + * Always allow logged in users who require REST API for Gutenberg + * and other admin/plugin compatibility. + * * @param WP_REST_Request $access Full details about the request. * @return WP_Error|boolean */ From c15db0da02c7d757830c9712e4960a100f822992 Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Tue, 5 Jun 2018 21:40:27 +0100 Subject: [PATCH 5/5] 2.2.2 Signed-off-by: Ben Huson --- CHANGELOG.md | 11 ++++++++++- README.md | 3 +++ password-protected.php | 4 ++-- readme.txt | 12 +++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8db249..ac27d73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [2.2.2] - 2018-05-29 + +### Changed +- Change locked admin bar icon to green. + +### Fixed +- Fix REST option and always allow access to REST API for logged in users. + ## [2.2.1] - 2018-05-27 ### Fixed @@ -191,7 +199,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.1...HEAD +[Unreleased]: https://github.com/benhuson/password-protected/compare/2.2.2...HEAD +[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 [2.1]: https://github.com/benhuson/password-protected/compare/2.0.3...2.1 diff --git a/README.md b/README.md index f95fdb3..253c3d5 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.2 +Fix REST option and always allow access to REST API for logged in users. Change locked admin bar icon to green. + ### 2.2.1 Fixed PHP error when calculating cookie expiration date. diff --git a/password-protected.php b/password-protected.php index b04d9fb..63e4a17 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.1 +Version: 2.2.2 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.1'; + var $version = '2.2.2'; var $admin = null; var $errors = null; diff --git a/readme.txt b/readme.txt index b2cc09e..05206c6 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.1 +Stable tag: 2.2.2 License: GPLv2 or later A very simple way to quickly password protect your WordPress site with a single password. @@ -82,6 +82,10 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o == Changelog == += 2.2.2 = +- Change locked admin bar icon to green. +- Fix REST option and always allow access to REST API for logged in users. + = 2.2.1 = * Fixed PHP error when calculating cookie expiration date. @@ -195,6 +199,12 @@ More instructions can be found at [wp-translations.org](http://wp-translations.o == Upgrade Notice == += 2.2.2 = +Fix REST option and always allow access to REST API for logged in users. Change locked admin bar icon to green. + += 2.2.1 = +Fixed PHP error when calculating cookie expiration date. + = 2.2 = Added admin bar icon to indicate wether password protection is enabled/disabled and disable REST API access (admin option to allow).