setting_tabs = array(
'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',
),
'cache-issue' => array(
'title' => __( 'Cache Issue', 'password-protected' ),
'slug' => 'cache-issue',
),
'custom-error-message' => array(
'title' => __( 'Custom Error Message', 'password-protected' ),
'slug' => 'custom-error-message',
),
),
),
'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',
),
'partial-protection' => array(
'title' => __( 'Partial Content Protection', 'password-protected' ),
'slug' => 'partial-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',
),
'all-captchas' => array(
'title' => __( 'Captcha', 'password-protected' ),
'slug' => 'all-captchas',
),
'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',
),
),
),
'protected-screen' => array(
'title' => __( 'Customization', 'password-protected' ),
'slug' => 'protected-screen',
'icon' => 'dashicons-admin-customizer',
'sub-tabs' => array(
'logo-styles' => array(
'title' => __( 'Logo', 'password-protected' ),
'slug' => 'logo-styles',
),
'label-styles' => array(
'title' => __( 'Labels', 'password-protected' ),
'slug' => 'label-styles',
),
'field-styles' => array(
'title' => __( 'Fields', 'password-protected' ),
'slug' => 'field-styles',
),
'button-styles' => array(
'title' => __( 'Button', 'password-protected' ),
'slug' => 'button-styles',
),
'remember-me-styles' => array(
'title' => __( 'Remember Me', 'password-protected' ),
'slug' => 'remember-me-styles',
),
'form-background' => array(
'title' => __( 'Form Background', 'password-protected' ),
'slug' => 'form-background',
),
'body-background' => array(
'title' => __( 'Body Background', 'password-protected' ),
'slug' => 'body-background',
),
'below-form' => array(
'title' => __( 'Form Content', 'password-protected' ),
'slug' => 'below-form',
),
'below-page' => array(
'title' => __( 'Page Content', 'password-protected' ),
'slug' => 'below-page',
),
'custom-css' => array(
'title' => __( 'Custom CSS', 'password-protected' ),
'slug' => 'custom-css',
),
),
),
'request-password' => array(
'title' => __( 'Password Request', 'password-protected' ),
'slug' => 'request-password',
'icon' => 'dashicons-email-alt',
'sub-tabs' => array(
'password-request' => array(
'title' => __( 'Request Password', 'password-protected' ),
'slug' => 'password-request',
),
'requests' => array(
'title' => __( 'Requests', 'password-protected' ),
'slug' => 'requests',
),
'email-templates' => array(
'title' => __( 'Email Templates', 'password-protected' ),
'slug' => 'email-templates',
),
),
),
);
$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'] );
}
}
/**
* Admin enqueue scripts.
*
* @param string $hooks Page Hook.
*/
public function admin_enqueue_scripts( $hooks ) {
if ( 'settings_page_password-protected' === $hooks || 'toplevel_page_password-protected' === $hooks ) {
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_custom-error-message_content', array( $this, 'dummy_content' ) );
add_action( 'text_before_after_login_form', 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_partial-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' ) );
add_action( 'password_protected_subtab_logo-styles_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_label-styles_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_field-styles_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_button-styles_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_remember-me-styles_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_form-background_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_body-background_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_below-form_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_below-page_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_custom-css_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_password-request_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_requests_content', array( $this, 'dummy_content' ) );
add_action( 'password_protected_subtab_email-templates_content', array( $this, 'dummy_content' ) );
}
if ( isset( $_GET['page'] ) && 'password-protected-get-pro' === $_GET['page'] ) {
wp_redirect( 'https://passwordprotectedwp.com/pricing/?utm_source=Plugin&utm_medium=Submenu' );
exit;
}
}
/**
* Add Privacy Policy
*/
public function add_privacy_policy() {
if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
return 1;
}
$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
*/
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'
)
);
add_menu_page(
'Password Protected',
'Password Protected',
'manage_options',
'password-protected',
array( $this, 'pp_admin_menu_page_callback' ),
'dashicons-lock',
99
);
add_action( 'load-' . $this->settings_page_id, array( $this, 'add_help_tabs' ), 20 );
if ( ! class_exists( 'Password_Protected_Pro' ) ) {
add_submenu_page(
'password-protected',
__( 'Get Pro Now', 'password-protected' ),
__( '⭐ Get Pro Now', 'password-protected' ),
'manage_options',
'password-protected-get-pro',
array( $this, 'password_protected_get_pro_features' )
);
}
}
/**
* Settings Page
*/
public function settings_page() {
?>
Password Protected Status
Turn on/off password protection.
Protected Permissions
Allow access for logged in users and administrators without needing to enter a password. You will need to enable this option if you want administrators to be able to preview the site in the Theme Customizer. Also allow RSS Feeds to be accessed when the site is password protected.
Password Fields
To set a new password, enter it into both fields. You cannot set an `empty` password. To disable password protection uncheck the Enabled checkbox.
'; } /** * Password Protection Permissions Field */ public function password_protected_permissions_field() { echo '
'; } /** * Password Field */ public function password_protected_password_field() { echo '
' . __( 'If you would like to change the password, type a new one. Otherwise, leave this blank.', 'password-protected' ) . '
' . __( 'Type your new password again.', 'password-protected' ) . '
'; } /** * Allowed IP Addresses Field */ public function password_protected_allowed_ip_addresses_field() { echo '' . esc_html( get_option( 'password_protected_allowed_ip_addresses' ) ) . ''; echo '' . esc_html__( 'Enter one IP address per line.', 'password-protected' ); if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { echo ' ' . esc_html( sprintf( __( 'Your IP address is %s.', 'password-protected' ), $_SERVER['REMOTE_ADDR'] ) ); } echo '
'; } /** * Remember Me Field */ public function password_protected_remember_me_field() { echo ''; } /** * Remember Me lifetime field */ public function password_protected_remember_me_lifetime_field() { echo ''; } /** * Password Protected Page description */ public function password_protected_page_description() { return 1; } /** * Password Protected text above passsword */ public function password_protected_text_above_password() { echo ''; } /** * Password Protected below above passsword */ public function password_protected_text_below_password() { echo ''; } public function password_protected_use_transient() { $use_transient = get_option( 'password_protected_use_transient', 'default' ); $cache_issue = array( array( 'name' => 'default', 'title' => __( 'Use default settings', 'password-protected' ), ), array( 'name' => 'transient', 'title' => __( 'You can enable this option if you are having trouble with cookies due to cache or server restrictions.', 'password-protected' ), 'description' => __( 'Note: It uses transients, which are saved based on the user\'s IP address, unlike cookies that are tied to the specific browser. This means that once a user logs in using any browser, they can access the page from any other browser as long as they are on the same IP address.', 'password-protected' ), ), ); foreach ( $cache_issue as $issue ) : echo '
'; if ( isset( $issue['description'] ) ) : echo '
' . esc_attr( $issue['description'] ) . '
'; endif; endforeach; } /** * 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' )
. '
' . $string . '