diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c163c8..179a501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ # Change Log All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## 2.7.2 2024-05-07 +- Fix: Updated depreciated PHP function to make it compatible with the latest PHP version. +- Added: Login designer compatibility banner. +- Improvement: Implement few UI tweaks. + +## 2.7.1 2024-03-27 +- Fixed - Disabled activity report by default. + +## 2.7 - 2024-03-26 +- New: Added Password Activity Report to provide weekly insights on access attempts to your protected sites. +- New: Added Categoric Tabs and Sub-Tabs User Interface for easy navigation and better user experience. ## 2.6.5.1 - 2023-11-20 - Ensured seamless compatibility with the latest WordPress version diff --git a/README.md b/README.md index 47f0790..c76c031 100644 --- a/README.md +++ b/README.md @@ -1,413 +1,163 @@ -=== Password Protected - Ultimate Plugin to Password Protect Your WordPress Content with Ease === -Contributors: wpexpertsio -Tags: password, maintenance mode, coming soon page, password protect, login -Requires at least: 4.6 -Tested up to: 6.4.1 -Requires PHP: 5.6 -Stable tag: 2.6.5.1 -License: GPLv2 or later +Password Protected +================== -The ultimate password protection plugin that protects your WordPress site with a single password. +A very simple way to quickly password protect your WordPress site with a single password. -== Description == +This plugin only protects your WordPress generated content. It **does not protect images or uploaded files** so if you enter and exact URL to in image file it will still be accessible. -[Live Demo](https://tastewp.com/new/?pre-installed-plugin-slug=password-protected) +Features include: -Password Protected for WordPress allows you to secure your website with a single password. The ultimate password protection plugin protects your WordPress categories, posts, products, and more with the simplest of ease. - -Password Protected does not protect images or uploaded files, so if you enter an exact URL of an image file, it will still be accessible. - -= Password Protected Features = - -* Easy to set up - Password protect your WordPress site with a single password. -* Set a description - Display text (description or instructions) above or below the password field. -* reCaptcha v2/v3 - You can enable Google reCAPTCHA v2 or V3 to increase bot security measures. -* Allow administrators - Option to allow administrators access without entering the password. -* Allow logged-in users - Option to give logged-in users access to the website. -* Allow RSS Feeds - Option to allow access to feeds. -* Allow Rest API Access - Allow admin to access pages and posts. -* Customization – Customize the password-protected screen, including the background, font, logo, and colors (using [Login Designer](https://wp.org/plugins/login-designer)) +- Password protect your WordPress site with a single password. +- Option to allow access to feeds. +- Option to allow administrators access without entering password. +- *New* 👉 Now you can customize the whole password protected screen including the background, font, logo, color e.t.c. > 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. -= Password Protected Pro = - -[Password Protected Pro](https://passwordwp.com/pricing/?utm_source=wp_org&utm_medium=readme) is a [Kinsta recommended plugin](https://kinsta.com/blog/password-protect-wordpress-site/) that offers powerful features that will take your WordPress website password protected to the next level. - -* Exclude page posts & post types - Option to exclude specific pages and post types from password protection. -* Limit login attempts - Limit the user’s attempts to enter a password for a specified interval. -* Lockdown time - Set a time (in minutes) during which users can not enter the password after their login attempts are limited. -* Usage limits - Set a usage limit after which a password can not be used. -* Status control - You can change the status of the password (Active, Deactivated, Expired). -* Manage multiple passwords - Edit, activate, deactivate, or delete passwords (individual or bulk action). -* Set Expiry Dates - Options to select the expiry date for specific passwords -* Activity Log Reports - View the Activity Logs of each user, including their IP address, browser, status, date, and time of password attempts. -* Priority Support - Our team of support professionals will make sure to handle your queries on high priority. - -= Detect hackers and bots from abusing password protection with reCAPTCHA = -Google reCAPTCHA v2 or v3 empowers your WordPress website to prevent password abuse against automated software, bots, hackers, etc. This anti-spam tool will allow any real user to access your website easily. - -= Password protect any post type = -You can include or exclude any post type from password protection. All of this can be done from the back end using a single password. - -= Password protect your WordPress site with a single password = -Password Protected has the ability to secure your entire website with a single password. Everything from pages to posts will also be protected. - -= Display password protected content in RSS feeds = -You can allow RSS feeds to show a login page after which user accessing the feed can view the password protected content. Disabling the option will restrict any user's access to the website even if the RSS feed is public. - -= Password usage limits and complexities = -Limits users from entering the password using Password Protected’s Usage Limit counter. Password greater than that limit can not be applicable on the login page. - -Usage limits can also be restricted by setting a password expiry from the calendar settings. This prevents users from re-using any given password. Regular password changes mitigate the risk of any security breach. - -Limiting password attempts prevents security issues like the Brute Force attack, where hackers keep trying to guess your password until they get it right. A complimentary solution to this feature is the Lockdown Timer, which resets the user’s right to log in after exceeding their login attempt limit. - -= Monitor and review activity logs for Password Protected = -Password Protected’s Activity Log is similar to an audit log that gives you a record of the events that have taken place on your website. To provide you with a better understanding, here is a list of the details you will find in the activity log: - -* Filter options for passwords used in a specific range (All-time, Today, Yesterday, This Week, This Month) -* IP addresses of the system from where the passwords were attempted. -* Country names from where the passwords were attempted. -* Browser names where the password was attempted. -* Status of the password attempts (successful or failed) - -The admin can also perform the search operation on the activity log. You can search by IP, Country, Browser, and Status. For e.g., searching Success will search all the passwords with successful attempts, and searching Failure will search all the orders with failed attempts. +Translations +------------ -= Documentation and support = -* Password Protected [Technical Documentation](https://passwordwp.com/documentation/?utm_source=wp_org&utm_medium=readme) -* You can open a support ticket [here](https://objectsws.atlassian.net/servicedesk/customer/portal/18) +If you would like to translate this plugin you can easily contribute at the [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/password-protected/) page. The stable plugin needs to be 95% translated for a language file to be available to download/update via WordPress. -= Translations = -If you would like to translate this plugin, you can easily contribute to the [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/password-protected/) page. The stable plugin needs to be 95% translated for a language file to be available to download/update via WordPress. - -== Installation == +Installation +------------ To install and configure this plugin... 1. Upload or install the plugin through your WordPress admin. -2. Activate the plugin via the 'Plugins' admin menu. -3. Configure the password options in the Password Protected settings. +1. Activate the plugin via the 'Plugins' admin menu. +1. Configure the password options in the Password Protected settings. -= Upgrading = +Upgrading +--------- If you are upgrading manually via FTP rather that through the WordPress automatic upgrade link, please de-activate and re-activate the plugin to ensure the plugin upgrades correctly. -== Frequently Asked Questions == +Frequently Asked Questions +-------------------------- -= How can I change the WordPress logo to a different image? = +__How can I change the WordPress logo to a different image?__ Install and configure the [Login Logo](https://wordpress.org/plugins/login-logo/) plugin by Mark Jaquith or the [Uber Login Logo](https://wordpress.org/plugins/uber-login-logo/) plugin. This will change the logo on your password entry page AND also your admin login page. -= How can I enable feeds while the site is password protected? = +__How can I enable feeds while the site is password protected?__ In the settings, check the 'Allow Feeds' checkbox. -= Can I prevent administrators having to enter password? = +__Can I prevent administrators having to enter password?__ In the settings, check the 'Allow Administrators' checkbox. -= I cannot preview my changes in the Theme Customizer = +__I cannot preview my changes in the Theme Customizer__ You must be an administrator (have the manage_options capability) and in the Password Protected settings, check the 'Allow Administrators' checkbox. -= How can I log out? = +__How can I log out?__ Just add a "password-protected=logout" query to your URL. eg. http://www.example.com/?password-protected=logout -= I have forgotten the password. How can I disable the plugin? = +__I have forgotten the password. How can I disable the plugin?__ If you go to your WordPress admin login page `/wp-login.php` and it shows the admin login fields, you should still be able to login and disable the plugin. If the admin login screen insteads shows the Password Protected field, you will need to access your site via SFTP/SSH and delete the Password Protected plugin folder in the plugins folder `wp-content/plugins/password-protected`. -= How can I redirect to a different domain name when logging out? = +__How can I redirect to a different domain name when logging out?__ If passing a redirect URL using 'redirect_to' when logging out you need you may need to use the [allowed domain names](https://codex.wordpress.org/Plugin_API/Filter_Reference/allowed_redirect_hosts) filter to allow redirecting to an external domain. -= Where can I report bugs and issues? = +__Where can I report bugs and issues?__ Please log issues and bugs on the plugin's [GitHub page](https://github.com/benhuson/password-protected/issues). You can also submit suggested enhancements if you like. -= How can I contribute? = +__How can I contribute?__ 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. -= How can I translate this plugin? = -If you would like to translate this plugin you can easily contribute at the [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/password-protected/) page. The stable plugin needs to be 90% translated for a language file to be available to download/update via WordPress. - -== Screenshots == - -1. Login page perfectly mimicks the WordPress login. -2. Login page with reCaptcha v3 -3. Login page with reCaptcha v2 -4. Password Protected general settings page. -4. Password Protected advanced settings page. - -== Changelog == -= 2.6.5.1 = -- Ensured seamless compatibility with the latest WordPress version - -= 2.6.5 = -- Fixed - [Login Designer](https://wp.org/plugins/login-designer) compatibility issues. - -= 2.6.4 = -- Fixed - Added compatibility for PHP version 8.2 - -= 2.6.3.2 = -- Update - Feedback library updated - -= 2.6.3.1 = -- Fix - Parse error related to PHP version 7.2 +__How can I translate this plugin?__ +If you would like to translate this plugin you can easily contribute at the [Translating WordPress](https://translate.wordpress.org/projects/wp-plugins/password-protected/) page. The stable plugin needs to be 95% translated for a language file to be available to download/update via WordPress. -= 2.6.3 = -- New - Added Freemius SDK integration. -- New - Added functionality to login with transient if the cookies are blocked. -- Fix – Fixed Redirect Issue from excluded page to password protected page. - -= 2.6.2 = -- Fix – Parse error related to PHP version 7.2 - -= 2.6.1 = -- Fix – Parse error related to PHP version 7.2 -- Update - Link to official Google Re-captcha documentation - -= 2.6.0 = -- Improved admin settings interface and introduced NEW tabs structure. -- NEW: Added Google Recaptcha v2 and v3 to make it more secure. -- NEW: Added Password Protected top-level admin menu for ease. -- NEW: Added option to add text above password Field. -- NEW: Added option to add text below password Field. - -= 2.5.3 = +Upgrade Notice +-------------- +### 2.5.3 - Improved Settings HTML structure - Added Note regarding compatibility with login designer within dashboard -= 2.5.2 = -- Made compatibility with [Login Designer](https://wp.org/plugins/login-designer); Now you can customize the password-protected screen with the customizer using login designer plugin. - -= 2.5.1 = -- Fix - Author name conflict resolved - -= 2.5 = -- Deprecate `wp_no_robots` and replace with `wp_robots_no_robots` for WordPress 5.7+ - -= 2.4 = -- Add a Nocache header to the login page redirect to prevent the browser from caching the redirect page. Props [De'Yonte W.](https://github.com/rxnlabs) -- Remove ‘password-protected’ query from redirects on successful login or logout. -- Check "redirect_to" query var is set in hidden form field. Props [Matthias Kittsteiner](https://wordpress.org/support/users/kittmedia/). -- Add favicon to password protected login page. - -= 2.3 = -- Adds `password_protected_cookie_name` filter for the cookie name. Props [Jose Castaneda](https://github.com/jocastaneda). -- Let developers override the capability needed to see the options page via a `password_protected_options_page_capability` filter. Props [Nicola Peluchetti](https://github.com/nicoladj77). -- Don't use a "testcookie" POST query as it is blocked by Namecheap (and possibly other hosts). -- Fix warnings in W3 validator - script and style “type” attribute not required. Props [@dianamurcia](https://github.com/dianamurcia). -- Translations now via [translate.wordpress.org](https://translate.wordpress.org/projects/wp-plugins/password-protected/). -- Updated URL references. Props [Garrett Hyder](https://github.com/garretthyder). - -= 2.2.5 = -- Added `password_protected_login_password_title` filter to allow customizing the "Password" label on the login form. Props [Jeremy Herve](https://github.com/jeherve). -- Fix stray "and" in readme. Props [Viktor Szépe](https://github.com/szepeviktor). -- Update Portuguese translation. Props [Jonathan Hult](https://github.com/jhult). -- Update Russian translation. Props [Alexey Chumakov](https://github.com/achumakov). - -= 2.2.4 = -- Check that `$_SERVER['REMOTE_ADDR']` is set. - -= 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. - -= 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. -* Option to show "Remember me" checkbox. Props [Christian Güdel](https://github.com/cguedel). -* REST API access disabled if password not entered. -* Admin option to allow REST API access. -* More robust checking of password hashes. - -= 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. -* Add CHANGELOG.md and README.md - -= 2.0.2 = -* Check allowed IP addresses are valid when saving. -* Only redirect to [allowed domain names](https://codex.wordpress.org/Plugin_API/Filter_Reference/allowed_redirect_hosts) when logging out. - -= 2.0.1 = -* Split logout functionality into separate function. -* Security fix: Use a more complex password hash for cookie key. Props Marcin Bury, [Securitum](http://securitum.pl). - -= 2.0 = -* Added [password_protected_logout_link](https://github.com/benhuson/password-protected/wiki/password_protected_logout_link-Shortcode) shortcode. -* Load 'password-protected-login.css' in theme folder if it exists. -* Added [password_protected_stylesheet_file](https://github.com/benhuson/password-protected/wiki/password_protected_stylesheet_file) filter to specify alternate stylesheet location. -* Added is_user_logged_in(), login_url(), logout_url() and logout_link() methods. -* Added Basque, Czech, Greek, Lithuanian and Norwegian translations. -* Better handling of login/out redirects when protection is not active on home page. - -= 1.9 = -* Fixed "Allow Users" functionality with is_user_logged_in(). Props PatRaven. -* Added option for allowed IP addresses which can bypass the password protection. -* Added 'password_protected_is_active' filter. - -= 1.8 = -* Support for adding "password-protected-login.php" in theme directory. -* Allow filtering of the 'redirect to' URL via the 'password_protected_login_redirect_url' filter. -* Added 'password_protected_login_messages' action to output errors and messages in template. -* Updated translations. -* Use current_time( 'timestamp' ) instead of time() to take into account site timezone. -* Check login earlier in the template_redirect action. - -= 1.7.2 = -* Fix always allow access to robots.txt. -* Added 'password_protected_login_redirect' filter. -* Updated translations. - -= 1.7.1 = -* Fix login template compatibility for WordPress 3.9 - -= 1.7 = -* Remove JavaScript that disables admin RSS checkbox. -* Added 'password_protected_theme_file' filter to allow custom login templates. -* Add option to allow logged in users. - -= 1.6.2 = -* Set login page not to index if privacy setting is on. -* Allow redirection to a different URL when logging out using 'redirect_to' query and full URL. - -= 1.6.1 = -* Language updates by wp-translations.org (Arabic, Dutch, French, Persian, Russian). - -= 1.6 = -* Robots.txt is now always accessible. -* Added support for Uber Login Logo plugin. - -= 1.5 = -* Added note about WP Engine compatibility to readme.txt -* Requires WordPress 3.1+ -* Settings now have their own page. -* Fixed an open redirect vulnerability. Props Chris Campbell. - -= 1.4 = -* Add option to allow administrators to use the site without logging in. -* Use DONOTCACHEPAGE to try to prevent some caching issues. -* Added a contextual help tab for WordPress 3.3+. -* Updated login screen styling for WordPress 3.5 compatibility. -* Options are now on the 'Reading' settings page in WordPress 3.5 - -= 1.3 = -* Added checkbox to allow access to feeds when protection is enabled. -* Prepare for WordPress 3.5 Settings API changes. -* Added 'password_protected_before_login_form' and 'password_protected_after_login_form' actions. -* Added 'password_protected_process_login' filter to make it possible to extend login functionality. -* Now possible to use 'pre_update_option_password_protected_password' filter to use password before it is encrypted and saved. -* Ready for [translations](http://codex.wordpress.org/I18n_for_WordPress_Developers). - -= 1.2.2 = -* Show login error messages. -* Escape 'redirect_to' attribute. Props A. Alagha. - -= 1.2.1 = -* Added a "How to log out?" FAQ. -* Only disable feeds when protection is active. - -= 1.2 = -* Use cookies instead of sessions. - -= 1.1 = -* Encrypt passwords in database. - -= 1.0 = -* First Release. If you spot any bugs or issues please [log them here](https://github.com/benhuson/password-protected/issues). - -== Upgrade Notice == - -= 2.5.1 = -Author name conflict resolved - -= 2.5 = +### 2.5.2 +Made compatibility with [login designer](https://wp.org/plugins/login-designer); Now you can customize the password-protected screen with the customizer using login designer plugin. + +### 2.5 Fixes robots tag for WordPress 5.7+ -= 2.4 = +### 2.4 Fixes to help with caching issues and favicon on login page. -= 2.3 = +### 2.3 Fixed an issue with "testcookie" on some hosts. Added `password_protected_cookie_name` and `password_protected_options_page_capability` filters. -= 2.2.5 = +### 2.2.5 Added `password_protected_login_password_title` filter to allow customizing the "Password" label on the login form. -= 2.2.4 = +### 2.2.4 Check that `$_SERVER['REMOTE_ADDR']` is set. -= 2.2.3 = +### 2.2.3 Restrict REST-API-access only if password protection is active. Added viewport meta tag to login page. -= 2.2.2 = +### 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 = +### 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). +### 2.2 +Added admin bar icon to indicate wether password protection is enabled/disabled. Options to enable REST API access and show "Remember me" checkbox. -= 2.1 = +### 2.1 Update caching notes for WP Engine and W3 Total Cache plugin. -= 2.0.3 = +### 2.0.3 Show user's IP address beside "Allow IP Addresses" admin setting. Declare methods as public or private and use PHP5 constructors. -= 2.0.2 = +### 2.0.2 Only redirect to [allowed domain names](https://codex.wordpress.org/Plugin_API/Filter_Reference/allowed_redirect_hosts) when logging out. -= 2.0.1 = +### 2.0.1 Security fix: Use a more complex password hash for cookie key. -= 2.0 = +### 2.0 Added 'password_protected_logout_link' shortcode and use 'password-protected-login.css' in theme folder if it exists. -= 1.9 = +### 1.9 Fixed "Allow Users" functionality and added option to allowed IP addresses which can bypass the password protection. -= 1.8 = +### 1.8 Support for adding "password-protected-login.php" in theme directory and allow filtering of the 'redirect to' URL via the 'password_protected_login_redirect_url' filter. -= 1.7.2 = +### 1.7.2 Added 'password_protected_login_redirect' filter. -= 1.7.1 = +### 1.7.1 Fix login template compatibility for WordPress 3.9 -= 1.7 = +### 1.7 Added 'password_protected_theme_file' filter and option to allow logged in users. -= 1.6.2 = +### 1.6.2 Allow redirection to a different URL when logging out. -= 1.6 = +### 1.6 Added support for Uber Login Logo plugin. -= 1.5 = +### 1.5 Fixes an open redirect vulnerability. Settings now have own page. -= 1.4 = +### 1.4 Administrators can use the site without logging in. WordPress 3.5 compatible. -= 1.3 = +### 1.3 Allow access to feeds. Ready for translation. -= 1.2 = +### 1.2 Use cookies instead of sessions. -= 1.1 = +### 1.1 Passwords saved encrypted. + +Changelog +--------- + +View a list of all plugin changes in [CHANGELOG.md](https://github.com/wpexpertsio/password-protected/blob/master/CHANGELOG.md). diff --git a/admin/admin-bar.php b/admin/admin-bar.php index 163d40d..b8170e6 100644 --- a/admin/admin-bar.php +++ b/admin/admin-bar.php @@ -22,9 +22,9 @@ class Admin_Bar { */ public static function load() { - add_action( 'wp_head', array( get_class(), 'styles' ) ); - add_action( 'admin_head', array( get_class(), 'styles' ) ); - add_action( 'wp_before_admin_bar_render', array( get_class(), 'toolbar_item' ) ); + add_action( 'wp_head', array( self::class, 'styles' ) ); + add_action( 'admin_head', array( self::class, 'styles' ) ); + add_action( 'wp_before_admin_bar_render', array( self::class, 'toolbar_item' ) ); } diff --git a/admin/admin-caching.php b/admin/admin-caching.php index f230480..cb8f6d3 100644 --- a/admin/admin-caching.php +++ b/admin/admin-caching.php @@ -60,6 +60,14 @@ public function cache_settings_info() { 'password_protected_compat_caching' ); + add_settings_field( + 'password_protected_documentation', + __( 'Documentation', 'password-protected' ), + array( $this, 'documentation' ), + 'password-protected-compat', + 'password_protected_compat_caching' + ); + // WP Engine Hosting if ( $this->test_wp_engine() ) { @@ -112,6 +120,10 @@ public function field_cookies() { } + public function documentation() { + echo 'Documentation'; + } + /** * WP Engine Hosting * diff --git a/admin/admin.php b/admin/admin.php index 855c108..1453801 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -12,9 +12,10 @@ class Password_Protected_Admin { public function __construct() { global $wp_version; add_action( 'admin_init', array( $this, 'password_protected_register_setting_tabs' ) ); - add_action( 'admin_init', array( $this, 'password_protected_settings' ), 5 ); + add_action( 'admin_init', array( $this, 'password_protected_settings' ), 15 ); add_action( 'admin_init', array( $this, 'add_privacy_policy' ) ); add_action( 'admin_menu', array( $this, 'admin_menu' ) ); + add_action( 'password_protected_subtab_password-protected-page-description_content', array( $this, 'password_protected_page_description_tab' ) ); add_action( 'password_protected_help_tabs', array( $this, 'help_tabs' ), 5 ); add_action( 'admin_notices', array( $this, 'password_protected_admin_notices' ) ); add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 4 ); @@ -30,15 +31,118 @@ public function __construct() { */ public function password_protected_register_setting_tabs() { $this->setting_tabs = array( - 'general' => 'General', - 'advanced' => 'Advanced', - 'help' => 'Help', - 'getpro' => 'Get Pro' - ); - if( $this->password_protected_pro_is_installed_and_activated() ) - unset( $this->setting_tabs['getpro'] ); + 'general' => array( + 'title' => __( 'General', 'password-protected' ), + 'slug' => 'general', + 'icon' => 'dashicons-migrate', + ), + + 'advanced' => array( + 'title' => __( 'Advanced', 'password-protected' ), + 'slug' => 'advanced', + 'icon' => 'dashicons-admin-settings', + 'sub-tabs' => array( + 'exclude-from-protection' => array( + 'title' => __( 'Exclude From Protection', 'password-protected' ), + 'slug' => 'exclude-from-protection', + ), + + 'password-protected-page-description' => array( + 'title' => __( 'Protected Page Content', 'password-protected' ), + 'slug' => 'password-protected-page-description', + ), + + 'bypass-url' => array( + 'title' => __( 'Bypass URL', 'password-protected' ), + 'slug' => 'bypass-url', + ), + ), + ), + + 'manage_passwords' => array( + 'title' => __( 'Multiple Passwords', 'password-protected' ), + 'slug' => 'manage_passwords', + 'icon' => 'dashicons-shield', + ), + + 'content-protection' => array( + 'title' => __( 'Content Protection', 'password-protected' ), + 'slug' => 'content-protection', + 'icon' => 'dashicons-superhero', + 'sub-tabs' => array( + 'post-type-protection' => array( + 'title' => __( 'Post Type Protection', 'password-protected' ), + 'slug' => 'post-type-protection', + ), + + 'taxonomy-protection' => array( + 'title' => __( 'Taxonomy Protection', 'password-protected' ), + 'slug' => 'taxonomy-protection', + ), + ), + ), + + 'security' => array( + 'title' => __( 'Security', 'password-protected' ), + 'slug' => 'security', + 'icon' => 'dashicons-shield-alt', + 'sub-tabs' => array( + 'whitelist-user-role' => array( + 'title' => __( 'Whitelist User Role', 'password-protected' ), + 'slug' => 'whitelist-user-role', + ), + + 'google-recaptcha' => array( + 'title' => __( 'Google ReCaptcha', 'password-protected' ), + 'slug' => 'google-recaptcha', + ), + + 'wp-admin-protection' => array( + 'title' => __( 'WP-Admin Protection', 'password-protected' ), + 'slug' => 'wp-admin-protection', + ), + + 'attempt-limitation' => array( + 'title' => __( 'Attempt Limitation', 'password-protected' ), + 'slug' => 'attempt-limitation', + ), + ), + ), + + 'logs' => array( + 'title' => __( 'Logs', 'password-protected' ), + 'slug' => 'logs', + 'icon' => 'dashicons-media-text', + 'sub-tabs' => array( + 'activity_logs' => array( + 'title' => __( 'Activity Logs', 'password-protected' ), + 'slug' => 'activity_logs', + ), + + 'activity-report' => array( + 'title' => __( 'Activity Report', 'password-protected' ), + 'slug' => 'activity-report', + ), + ), + ), + ); + + $this->setting_tabs = apply_filters( 'password_protected_setting_tabs', $this->setting_tabs ); - $this->setting_tabs = apply_filters( 'password_protected_setting_tabs', $this->setting_tabs ); + $this->setting_tabs['help'] = array( + 'title' => __( 'Help', 'password-protected' ), + 'slug' => 'help', + 'icon' => 'dashicons-editor-help', + ); + $this->setting_tabs['getpro'] = array( + 'title' => __( 'Get Pro', 'password-protected' ), + 'slug' => 'getpro', + 'icon' => 'dashicons-superhero-alt', + ); + + if ( class_exists( 'Password_Protected_Pro' ) ) { + unset( $this->setting_tabs['getpro'] ); + } } /** @@ -49,14 +153,44 @@ public function password_protected_register_setting_tabs() { public function admin_enqueue_scripts( $hooks ) { if ( 'settings_page_password-protected' === $hooks || 'toplevel_page_password-protected' === $hooks ) { - wp_enqueue_style( 'password-protected-page-script', PASSWORD_PROTECTED_URL . 'assets/css/admin.css', array(), '2.6.2' ); - wp_enqueue_script( 'password-protected-admin-script', PASSWORD_PROTECTED_URL . 'assets/js/admin.js', array('jquery'), '2.6.2' ); + global $Password_Protected; + wp_enqueue_style( 'password-protected-page-script', PASSWORD_PROTECTED_URL . 'assets/css/admin.css', array(), $Password_Protected->version ); + wp_enqueue_script( 'password-protected-admin-script', PASSWORD_PROTECTED_URL . 'assets/js/admin.js', array('jquery'), $Password_Protected->version ); + wp_localize_script( + 'password-protected-admin-script', + 'passwordProtectedAdminObject', + array( + 'imageURL' => PASSWORD_PROTECTED_URL . 'assets/images/', + 'description' => __( 'Unlock unmatched website protection with
advanced security features', 'password-protected' ), + 'buttonText' => __( 'Get Password Protected Pro', 'password-protected' ), + 'buttonRedirect' => add_query_arg( + array( + 'page' => 'password-protected', + 'tab' => 'getpro', + ), + admin_url( 'admin.php' ) + ), + ) + ); } } public function init() { + + if ( ! class_exists( 'Password_Protected_Pro' ) ) { + add_action( 'password_protected_subtab_exclude-from-protection_content', array( $this, 'dummy_content' ) ); + add_action( 'password_protected_subtab_attempt-limitation_content', array( $this, 'dummy_content' ) ); + add_action( 'password_protected_subtab_bypass-url_content', array( $this, 'dummy_content' ) ); + add_action( 'password_protected_tab_manage_passwords_content', array( $this, 'dummy_content' ) ); + add_action( 'password_protected_subtab_post-type-protection_content', array( $this, 'dummy_content' ) ); + add_action( 'password_protected_subtab_taxonomy-protection_content', array( $this, 'dummy_content' ) ); + add_action( 'password_protected_subtab_whitelist-user-role_content', array( $this, 'dummy_content' ) ); + add_action( 'password_protected_subtab_wp-admin-protection_content', array( $this, 'dummy_content' ) ); + add_action( 'password_protected_subtab_activity_logs_content', array( $this, 'dummy_content' ) ); + } + if ( isset( $_GET['page'] ) && 'password-protected-get-pro' === $_GET['page'] ) { - wp_redirect( 'https://passwordwp.com/pricing/?utm_source=Plugin&utm_medium=Sidebar' ); + wp_redirect( 'https://passwordprotectedwp.com/pricing/?utm_source=Plugin&utm_medium=Submenu' ); exit; } } @@ -80,12 +214,18 @@ public function add_privacy_policy() { * Admin Menu */ public function admin_menu() { - - $capability = apply_filters( 'password_protected_options_page_capability', 'manage_options' ); - $this->settings_page_id = add_options_page( __( 'Password Protected', 'password-protected' ), __( 'Password Protected', 'password-protected' ), $capability, 'password-protected', array( - $this, - 'settings_page' - ) ); + + $capability = apply_filters( 'password_protected_options_page_capability', 'manage_options' ); + $this->settings_page_id = add_options_page( + __( 'Password Protected', 'password-protected' ), + __( 'Password Protected', 'password-protected' ), + $capability, + 'password-protected', + array( + $this, + 'settings_page' + ) + ); add_menu_page( 'Password Protected', 'Password Protected', @@ -140,29 +280,83 @@ public function settings_page() { * Admin Menu Settings Page */ public function pp_admin_menu_page_callback() { - $tab = ( isset( $_GET['tab'] ) AND sanitize_text_field( $_GET['page'] ) == 'password-protected' ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; + $tab = ( isset( $_GET['tab'] ) && sanitize_text_field( $_GET['page'] ) == 'password-protected' ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; + $subtab = ( isset( $_GET['sub-tab'] ) && sanitize_text_field( $_GET['page'] ) == 'password-protected' ) ? sanitize_text_field( $_GET['sub-tab'] ) : ''; + + // for backward compatibility. + $this->setting_tabs = array_filter( + $this->setting_tabs, + function( $tab ) { + return isset( $tab['title'] ) && isset( $tab['slug'] ) && isset( $tab['icon'] ); + } + ); + if ( isset( $this->setting_tabs[ $tab ]['sub-tabs'] ) && ! empty( $this->setting_tabs[ $tab ]['sub-tabs'] ) ) { + $this->setting_tabs[ $tab ]['sub-tabs'] = array_filter( + $this->setting_tabs[ $tab ]['sub-tabs'], + function ( $subtab ) { + return isset( $subtab['title'] ) && isset( $subtab['slug'] ); + } + ); + } ?>
- - - - password_protected_render_tab_content( $tab ); ?> + + +
+ +
+ setting_tabs as $index => $setting_tab ) : ?> + + +
+ +
+ setting_tabs[ $tab ] ) && isset( $this->setting_tabs[ $tab ]['sub-tabs'] ) && ! empty( $this->setting_tabs[ $tab ]['sub-tabs'] ) ) : ?> +
+ +
+ + +
+ password_protected_render_tab_content( $tab, $subtab ); ?> +
+
+
-
@@ -170,49 +364,54 @@ public function pp_admin_menu_page_callback() { '; + settings_fields( 'password-protected-advanced' ); + do_settings_sections( 'password-protected&tab=advanced&sub-tab=password-protected-page-description' ); + + submit_button(); + echo ''; + } + /** * password protected render settings page in menu */ - public function password_protected_render_tab_content( $tab ) { - switch( $tab ) { - case 'general': - do_settings_sections( 'password-protected-help' ); - echo '
'; - settings_fields( 'password-protected' ); - do_settings_sections( 'password-protected' ); - submit_button(); - echo '
'; - break; - - case 'advanced': - echo '
'; - settings_fields( 'password-protected-advanced' ); - do_action( 'password_protected_advanced_tab_content' ); - do_settings_fields( 'password-protected&tab=advanced', 'password-protected-advanced' ); - do_settings_sections( 'password-protected-advanced-tab' ); - Password_Protected_reCAPTCHA::recpatcha_screen(); - echo '
'; - break; + public function password_protected_render_tab_content( $tab, $sub_tab ) { + switch ( $tab ) { + case 'general': + do_settings_sections( 'password-protected-help' ); + echo '
'; + settings_fields( 'password-protected' ); + do_settings_sections( 'password-protected' ); + submit_button(); + echo '
'; + break; case 'help': ?> -
- -
+
+ +
password_protected_get_pro_features(); - break; - - case $tab; - do_action( 'password_protected_tab_'.$tab.'_content' ); - break; - - default: - echo "Something went wrong! Please contact support."; - break; + break; + + case 'getpro': + $this->password_protected_get_pro_features(); + break; + + case $tab: + if ( ! empty( $sub_tab ) ) { + do_action( + 'password_protected_subtab_' . $sub_tab . '_content', + $this->setting_tabs[ $tab ]['sub-tabs'][ $sub_tab ] + ); + } else { + do_action( + 'password_protected_tab_' . $tab . '_content', + $this->setting_tabs[ $tab ] + ); + } + break; } } @@ -255,7 +454,7 @@ public function password_protected_settings() { // general tab add_settings_section( 'password_protected', - '', + __( 'Password Protected Configuration', 'password-protected' ), array( $this, 'password_protected_settings_section' ), $this->options_group ); @@ -313,14 +512,14 @@ public function password_protected_settings() { 'password-protected-advanced-tab', 'Password Protected Page description', array( $this, 'password_protected_page_description' ), - 'password-protected&tab=advanced' + 'password-protected&tab=advanced&sub-tab=password-protected-page-description' ); add_settings_field( 'text-above-password', __( 'Text Above Password Field', 'password-protected' ), array( $this, 'password_protected_text_above_password' ), - 'password-protected&tab=advanced', + 'password-protected&tab=advanced&sub-tab=password-protected-page-description', 'password-protected-advanced-tab' ); @@ -328,11 +527,11 @@ public function password_protected_settings() { 'text-below-password', __( 'Text Below Password Field ', 'password-protected' ), array( $this, 'password_protected_text_below_password' ), - 'password-protected&tab=advanced', + 'password-protected&tab=advanced&sub-tab=password-protected-page-description', 'password-protected-advanced-tab' ); - add_settings_field( + /*add_settings_field( 'password-protected-use-transient', __( 'Use Transients', 'password-protected' ), array( $this, 'password_protected_use_transient' ), @@ -341,7 +540,7 @@ public function password_protected_settings() { array( 'label_for' => 'password-protected-use-transient', ) - ); + );*/ // password protected help tab add_settings_section( @@ -350,17 +549,6 @@ public function password_protected_settings() { array( $this, 'password_protected_help_tab' ), 'password-protected-help' ); - - - // sidebar login designer compatibity - if( !$this->login_designer_is_installed_and_activated() ) { - add_settings_section( - 'password-protected-login-designer', - '', - array( $this, 'login_designer_message' ), - 'password-protected-login-designer' - ); - } if( !$this->password_protected_pro_is_installed_and_activated() ) { add_settings_section( @@ -371,6 +559,15 @@ public function password_protected_settings() { ); } + if ( ! $this->login_designer_is_installed_and_activated() ) { + add_settings_section( + 'password-protected-login-designer', + '', + array( $this, 'password_protected_login_designer' ), + 'password-protected-login-designer' + ); + } + // registering settings register_setting( $this->options_group, 'password_protected_status', 'intval' ); register_setting( $this->options_group, 'password_protected_feeds', 'intval' ); @@ -381,25 +578,9 @@ public function password_protected_settings() { register_setting( $this->options_group, 'password_protected_allowed_ip_addresses', array( $this, 'sanitize_ip_addresses' ) ); register_setting( $this->options_group, 'password_protected_remember_me', 'boolval' ); register_setting( $this->options_group, 'password_protected_remember_me_lifetime', 'intval' ); - register_setting( $this->options_group . '-advanced', 'password_protected_use_transient' ); + register_setting( $this->options_group.'-advanced', 'password_protected_text_above_password', array( 'type' => 'string' ) ); register_setting( $this->options_group.'-advanced', 'password_protected_text_below_password', array( 'type' => 'string' ) ); - - } - - /** - * Login Designer Message - */ - public function login_designer_message(){ - $image = plugin_dir_url( __DIR__ ) . "assets/images/login-designer-demo.gif"; - echo '
-

- 🎨' . esc_attr__( 'Now you can customize your Password Protected screen with the', 'password-protected' ) . ' Login Designer plugin🌈 -

- -

' . esc_attr__( '👉 Try it now! It\'s Free.', 'password-protected' ) . '

- -
'; } /** @@ -479,7 +660,17 @@ public function password_protected_settings_section() { */ public function password_protected_status_field() { - echo ''; + echo ' +
+ + +
+

+ +

+ '; } @@ -488,10 +679,30 @@ public function password_protected_status_field() { */ public function password_protected_permissions_field() { - echo '

'; - echo '

'; - echo '

'; - echo '

'; + echo '

+ +

+

+ +

+

+ +

+

+ +

'; } @@ -524,7 +735,15 @@ public function password_protected_allowed_ip_addresses_field() { */ public function password_protected_remember_me_field() { - echo ''; + echo '
+ + +
+

+ +

'; } @@ -568,34 +787,103 @@ public function password_protected_use_transient() { * Help Tab text field */ public function password_protected_help_tab() { - echo '

' . __( 'Password protect your web site. Users will be asked to enter a password to view the site.', 'password-protected' ) . '
- ' . __( 'For more information about Password Protected settings, view the "Help" tab at the top of this page.', 'password-protected' ) . '

'; + echo '
+

' + . __( 'Password protect your web site. Users will be asked to enter a password to view the site.', 'password-protected' ) + . '
' + . __( 'For more information about Password Protected settings, view the "Help" tab at the top of this page.', 'password-protected' ) + . '

+
'; } /** * Try pro sideabr */ public function password_protected_try_pro() { - $pro_url = 'https://passwordwp.com/pricing/?utm_source=Plugin&utm_medium=ProWidget'; - echo ' -
-

- ' . esc_attr__( 'Looking for more options?', 'password-protected' ) . ' -

-
    -
  1. ⚡ Get the option to exclude specific pages and posts.
  2. -
  3. ⚡ You can exclude specific post types.
  4. -
  5. 🔐 Feature to limit password attempts for a certain interval.
  6. -
  7. ⚡ You get the capability of managing multiple passwords with the following options.: -
  8. -
  9. 📃 Display activity log for each password attempt.
  10. -
  11. 🔗 Get Bypass URL - You can access without a password using a unique link.
  12. -
- -

' . esc_attr__( '👉 Try Pro', 'password-protected' ) . '

- -
'; + $image_url = PASSWORD_PROTECTED_URL . 'assets/images/'; + echo '
+
+ +
+

Level up your WordPress protection with

+

Password Protected Pro

+
+ +
+
    +
  • + Protect Specific Post Types +
  • +
  • + Whitelist Specific User Role +
  • +
  • + Password Protect WP-Admin +
  • +
  • + Password Attempt Activity Report +
  • +
  • + Specific Post/Page Protection +
  • +
  • + Certain Page/Posts Exclusions +
  • +
  • + Password Attempts Restriction +
  • +
  • + Password Expiration and Usage Limit +
  • +
  • + Bypass URL (Post, Page, Category, etc.) +
  • +
  • + Activity Log For Each Password Attempt +
  • +
  • + Multiple Password Management +
  • +
+
+ +
+
'; } + + public function password_protected_login_designer() { + $search_login_designer = add_query_arg( + array( + 's' => 'login designer', + 'tab' => 'search', + 'type' => 'term', + ), + admin_url( 'plugin-install.php' ) + ); + echo '
+
+

' . + sprintf( + __( '%1$s Now you can customize your Password Protected screen with the %3$s %2$s', 'password-protected' ), + '🎨', + '🌈', + '' . __( 'Login Designer Plugin', 'password-protected' ) . '' + ) + . '

+ + Login Designer Demo GIF + +

+ + 👉 ' . __( 'Try it now! It\'s Free', 'password-protected' ) . ' + +

+
+
'; + } + /** * Pre-update 'password_protected_password' Option * @@ -690,9 +978,13 @@ public function password_protected_admin_notices() { if ( (bool) get_option( 'password_protected_administrators' ) && (bool) get_option( 'password_protected_users' ) ) { echo $this->admin_error_display( __( 'You have enabled password protection and allowed administrators and logged in users - other users will still need to enter a password to view the site.', 'password-protected' ) ); } elseif ( (bool) get_option( 'password_protected_administrators' ) ) { - echo $this->admin_error_display( __( 'You have enabled password protection and allowed administrators - other users will still need to enter a password to view the site.', 'password-protected' ) ); + if ( (bool) get_option( 'password_protected_status' ) ) { + echo $this->admin_error_display( __( 'You have enabled password protection and allowed administrators - other users will still need to enter a password to view the site.', 'password-protected' ) ); + } } elseif ( (bool) get_option( 'password_protected_users' ) ) { - echo $this->admin_error_display( __( 'You have enabled password protection and allowed logged in users - other users will still need to enter a password to view the site.', 'password-protected' ) ); + if ( (bool) get_option( 'password_protected_status' ) ) { + echo $this->admin_error_display( __( 'You have enabled password protection and allowed logged in users - other users will still need to enter a password to view the site.', 'password-protected' ) ); + } } } @@ -760,14 +1052,6 @@ public function plugin_screen_ids( $screen_id = '' ) { } - /** - * @return bool - * true if login designer is installed and activated otherwise false - */ - public function login_designer_is_installed_and_activated(): bool { - return class_exists( 'Login_Designer' ); - } - /** * @return bool * true if password protected pro is installed and activated otherwise false @@ -776,40 +1060,512 @@ public function password_protected_pro_is_installed_and_activated(): bool { return class_exists( 'Password_Protected_Pro' ); } + public function login_designer_is_installed_and_activated() { + return class_exists( 'Login_designer' ); + } + /** * @return void * Display Pro Features */ public function password_protected_get_pro_features() { - ?> -
-
-
-
-

Pro Features

-
    -
  1. ⚡ Get the option to exclude specific pages and posts.
  2. -
  3. ⚡ You can exclude specific post types.
  4. -
  5. 🔐 Feature to limit password attempts for a certain interval.
  6. -
  7. ⚡ You get the capability of managing multiple passwords with the following options.: -
      -
    1. 👉 Option to activate and deactivate manually.
    2. -
    3. 👉 Set the expiry date for each Password.
    4. -
    5. 👉 Set the usage limit for each Password.
    6. -
    -
  8. -
  9. 📃 Display activity log for each password attempt.
  10. -
  11. 🔗 Get Bypass URL - You can access without a password using a unique link.
  12. -
- - Get Pro Now -
-
-
-
- +
+
+

Level up your WordPress protection with

+

Password Protected + + Pro +

+
+ +
+
+
+ + Protect Specific Post Types + + Docs + +
+ +
+ + Whitelist Specific User Role + + Docs + +
+ +
+ + Password Protect WP-Admin + + Docs + +
+ +
+ + Password Attempt Activity Report + + Docs + +
+ +
+ + Specific Post/Page Protection + + Docs + +
+ +
+ + Certain Page/Posts Exclusions + + Docs + +
+ +
+
+
+ + Password Attempts Restriction + + Docs + +
+ +
+ + Password Expiration and Usage Limit + + Docs + +
+ +
+ + Bypass URL (Post, Page, Category, etc.) + + Docs + +
+ +
+ + Activity Log For Each Password Attempt + + Docs + +
+ +
+ + Multiple Password Management + + Docs + +
+ +
+ +
+
+ + +
+
'; } + public function dummy_content( $k ) { + echo '
+
+
'; + + switch ( $k['slug'] ) { + case 'exclude-from-protection': + $url = add_query_arg( + array( + 'utm_source' => 'plugin', + 'utm_medium' => 'pop_up', + 'utm_campaign' => 'plugin', + 'utm_content' => 'exclude_protection' + ), + 'https://passwordprotectedwp.com/pricing/' + ); + echo '
+

Exclude From Password Protection PRO

+ + + + + + + + + + + + + + + +
+ +
+ +
+ +
+
'; + break; + case 'attempt-limitation': + $url = add_query_arg( + array( + 'utm_source' => 'plugin', + 'utm_medium' => 'pop_up', + 'utm_campaign' => 'plugin', + 'utm_content' => 'attempt_limitation' + ), + 'https://passwordprotectedwp.com/pricing/' + ); + echo '
+

Limit Password Attempts PRO

+ + + + + + + + + + +
+ +
+ +
+
'; + break; + case 'bypass-url': + $url = add_query_arg( + array( + 'utm_source' => 'plugin', + 'utm_medium' => 'pop_up', + 'utm_campaign' => 'plugin', + 'utm_content' => 'bypass_url' + ), + 'https://passwordprotectedwp.com/pricing/' + ); + echo '
+

Bypass URL PRO

+ + + + + + + + + + + + + + + +
+ + +
+ + +
+
+ + + +
+ + + +
+
'; + break; + case 'manage_passwords': + $url = add_query_arg( + array( + 'utm_source' => 'plugin', + 'utm_medium' => 'pop_up', + 'utm_campaign' => 'plugin', + 'utm_content' => 'multiple_passwords' + ), + 'https://passwordprotectedwp.com/pricing/' + ); + echo '
+

Manage Passwords PRO

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
PasswordUses RemainingExpiryStatusActionsBypass URL
+ Manage passwords are only available in Password Protected Pro version. +
PasswordUses RemainingExpiryStatusActionsBypass URL
+
'; + break; + case 'activity_logs': + $url = add_query_arg( + array( + 'utm_source' => 'plugin', + 'utm_medium' => 'pop_up', + 'utm_campaign' => 'plugin', + 'utm_content' => 'activity_logs' + ), + 'https://passwordprotectedwp.com/pricing/' + ); + echo '
+

Activity Logs PRO

+ + + + + + + + + + + + + + + + + + + + + + + + +
IPBrowserStatusPasswordDate Time
+ Activity logs are only available in Password Protected Pro version. +
IPBrowserStatusPasswordDate Time
+
'; + break; + case 'post-type-protection': + $url = add_query_arg( + array( + 'utm_source' => 'plugin', + 'utm_medium' => 'pop_up', + 'utm_campaign' => 'plugin', + 'utm_content' => 'post_protection' + ), + 'https://passwordprotectedwp.com/pricing/' + ); + echo '
+

Post type protection PRO

+ + + + + + + + + + + + + + + + + +
Post TypeGlobalIndividual
Post
Page
+
'; + break; + case 'taxonomy-protection': + $url = add_query_arg( + array( + 'utm_source' => 'plugin', + 'utm_medium' => 'pop_up', + 'utm_campaign' => 'plugin', + 'utm_content' => 'taxonomy_protection' + ), + 'https://passwordprotectedwp.com/pricing/' + ); + echo '
+

Category/Taxonomy protection PRO

+ + + + + + + + + + +
Category
Post_tag
+
'; + break; + case 'whitelist-user-role': + $url = add_query_arg( + array( + 'utm_source' => 'plugin', + 'utm_medium' => 'pop_up', + 'utm_campaign' => 'plugin', + 'utm_content' => 'whitelist_user_role' + ), + 'https://passwordprotectedwp.com/pricing/' + ); + echo '
+

White List User Roles PRO

+ + + + + + + + + +
Enable Whitelist User Roles +
+ + +
+
Whitelist User Roles + +
+

WP Login Screen Redirect

+ + + + + + + + + +
Enable WP Login Screen Redirection +
+ + +
+
Add Text for Redirection Link
+
'; + break; + case 'wp-admin-protection': + $url = add_query_arg( + array( + 'utm_source' => 'plugin', + 'utm_medium' => 'pop_up', + 'utm_campaign' => 'plugin', + 'utm_content' => 'wpadmin_protection' + ), + 'https://passwordprotectedwp.com/pricing/' + ); + echo '
+

Enable Admin Protection PRO

+ + + + + +
Enable
+ + +
+

Password

+ + + + + +
Password + +

+ +
+

Remember Me

+ + + + + + + + + +
Remember Me
+ + +
Remember Me Many Days + +
+

Forgot Password

+ + + + + +
Forgot Password
+ + +
+
'; + break; + } + echo '
+
'; + } + } diff --git a/admin/class-recaptcha.php b/admin/class-recaptcha.php index 905b17b..ef017b7 100644 --- a/admin/class-recaptcha.php +++ b/admin/class-recaptcha.php @@ -1,66 +1,83 @@ options_name ); - - if( empty($options) || !$options ) - $this->settings = $this->get_default_reCAPTCHA_settings(); - else - $this->settings = get_option( $this->options_name ); - + + $options = get_option( $this->options_name ); + + if ( empty( $options ) || ! $options ) { + $this->settings = $this->get_default_reCAPTCHA_settings(); + } else { + $this->settings = get_option( $this->options_name ); + } + add_action( 'admin_init', array( $this, 'register_reCAPTCHA_settings' ), 6 ); + add_action( 'password_protected_subtab_google-recaptcha_content', array( $this, 'google_recaptcha_settings' ) ); - add_action( 'password_protected_after_password_field', array( $this, 'add_recaptcha' ) ); + add_action( 'password_protected_after_password_field', array( $this, 'add_recaptcha' ) ); - add_filter( 'password_protected_verify_recaptcha', array( $this, 'verify_recaptcha' ) ); + add_filter( 'password_protected_verify_recaptcha', array( $this, 'verify_recaptcha' ) ); } - - /** + + /** * reCAPTCHA Default Settings * * @return array * @since 2.6 */ - private function get_default_reCAPTCHA_settings(): array { - return array( - 'enable' => 0, - 'version' => 'google_recaptcha_v2', - 'v2_site_key' => null, - 'v3_site_key' => null, - 'v2_secret_key' => null, - 'v3_secret_key' => null, - 'v3_score' => 0.3, - 'v3_badge' => 'bottomright', - 'v2_theme' => 'light' - ); + private function get_default_reCAPTCHA_settings(): array { + return array( + 'enable' => 0, + 'version' => 'google_recaptcha_v2', + 'v2_site_key' => null, + 'v3_site_key' => null, + 'v2_secret_key' => null, + 'v3_secret_key' => null, + 'v3_score' => 0.3, + 'v3_badge' => 'bottomright', + 'v2_theme' => 'light', + ); + } + + public function google_recaptcha_settings() { + ?> +
+

+
+ +
+
+ options_group, __( 'Google reCAPTCHA', 'password-protected' ), @@ -78,7 +94,7 @@ public function register_reCAPTCHA_settings() { $this->tab ); - // Enable reCAPTCHA + // Enable reCAPTCHA add_settings_field( 'password_protected_enable_recaptcha', __( 'Enable reCAPTCHA ', 'password-protected' ), @@ -87,8 +103,8 @@ public function register_reCAPTCHA_settings() { $this->options_group ); - // reCAPTCHA version v2/v3 - add_settings_field( + // reCAPTCHA version v2/v3 + add_settings_field( 'password_protected_recaptcha_settings', __( 'Captcha Settings', 'password-protected' ), array( $this, 'reCAPTCHA_setting' ), @@ -96,8 +112,8 @@ public function register_reCAPTCHA_settings() { $this->options_group ); - // reCAPTCHA v2/v3 sitekey - add_settings_field( + // reCAPTCHA v2/v3 sitekey + add_settings_field( 'password_protected_recaptcha_v2_site_key', __( 'Site Key', 'password-protected' ), array( $this, 'reCAPTCHA_site_key' ), @@ -105,17 +121,17 @@ public function register_reCAPTCHA_settings() { $this->options_group ); - // reCAPTCHA v2/v3 secretkey - add_settings_field( + // reCAPTCHA v2/v3 secretkey + add_settings_field( 'password_protected_recaptcha_v2_secret_key', __( 'Secret Key', 'password-protected' ), array( $this, 'reCAPTCHA_secret_key' ), $this->tab, $this->options_group ); - - // reCAPTCHA v3 score - add_settings_field( + + // reCAPTCHA v3 score + add_settings_field( 'password_protected_recaptcha_score', __( 'Score', 'password-protected' ), array( $this, 'reCAPTCHA_score' ), @@ -123,8 +139,8 @@ public function register_reCAPTCHA_settings() { $this->options_group ); - // reCAPTCHA v3 badgeposition - add_settings_field( + // reCAPTCHA v3 badgeposition + add_settings_field( 'password_protected_recaptcha_badge_position', __( 'Badge Position', 'password-protected' ), array( $this, 'reCAPTCHA_badge_position' ), @@ -132,8 +148,8 @@ public function register_reCAPTCHA_settings() { $this->options_group ); - // reCAPTCHA v2 theme - add_settings_field( + // reCAPTCHA v2 theme + add_settings_field( 'password_protected_recaptcha_theme', __( 'Theme', 'password-protected' ), array( $this, 'reCAPTCHA_theme' ), @@ -141,63 +157,69 @@ public function register_reCAPTCHA_settings() { $this->options_group ); - // register settings in an array group. - register_setting( 'password-protected-advanced', $this->options_name, array( 'type' => 'array') ); - } + // register settings in an array group. + register_setting( 'password-protected-advanced', $this->options_name, array( 'type' => 'array' ) ); + } - /** + /** * reCAPTCHA Screen * - *@since 2.6 - * + * @since 2.6 + * * @return void password protected reCAPTCHA settings */ - public static function recpatcha_screen() { - do_settings_sections( 'password-protected&tab=advanced' ); - submit_button(); - } + public static function recpatcha_screen() { + do_settings_sections( 'password-protected&tab=advanced' ); + submit_button(); + } - /** + /** * reCAPTCHA Section * * @return void password protected reCAPTCHA section */ - public function reCAPTCHA_section() { - return 1; - } + public function reCAPTCHA_section() { + return 1; + } - /** + /** * ENable reCAPTCHA * - * @since 2.6 - * + * @since 2.6 + * * @return void password protected reCAPTCHA status field */ - public function reCAPTCHA_enable() { - echo ''; - } + public function reCAPTCHA_enable() { + echo '
+ settings['enable'], false ) . ' + /> + +
+ '; + } - /** + /** * reCAPTCHA Version * - * @since 2.6 - * + * @since 2.6 + * * @return void password protected reCAPTCHA version field */ - public function reCAPTCHA_setting() { - echo '