PluginProbe
Patchstack – WordPress & Plugins Security / 2.2.11
Patchstack – WordPress & Plugins Security v2.2.11
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
← All changes | includes/admin/options.php +171 -201 2.1.62.2.11 View file →
@@ -18,9 +18,9 @@
18 18 * @return void
19 19 */
20 20 public function __construct( $core ) {
21 21 parent::__construct( $core );
22 - add_action( 'admin_init', array( $this, 'settings_init' ) );
22 + add_action( 'admin_init', [ $this, 'settings_init' ] );
23 23 }
24 24
25 25 /**
26 26 * All options and their default values.
@@ -26,9 +26,9 @@
26 26 * All options and their default values.
27 27 *
28 28 * @var array
29 29 */
30 - public $options = array(
30 + public $options = [
31 31 // Hardening options.
32 32 'patchstack_pluginedit' => 1,
33 33 'patchstack_userenum' => 1,
34 34 'patchstack_basicscanblock' => 1,
@@ -37,8 +37,10 @@
37 37 'patchstack_rm_readme' => 1,
38 38 'patchstack_activity_log_is_enabled' => 1,
39 39 'patchstack_activity_log_failed_logins' => 1,
40 40 'patchstack_activity_log_failed_logins_db' => 0,
41 + 'patchstack_activity_log_posts' => 0,
42 + 'patchstack_activity_log_comments' => 0,
41 43 'patchstack_xmlrpc_is_disabled' => 1,
42 44 'patchstack_captcha_type' => 'v2',
43 45 'patchstack_captcha_public_key_v3' => '',
44 46 'patchstack_captcha_private_key_v3' => '',
@@ -52,21 +54,23 @@
52 54 'patchstack_captcha_on_comments' => 0,
53 55 'patchstack_prevent_default_file_access' => 1,
54 56 'patchstack_register_email_blacklist' => '',
55 57 'patchstack_json_is_disabled' => 0,
56 - 'patchstack_auto_update' => array(),
58 + 'patchstack_auto_update' => [],
57 59 'patchstack_application_passwords_disabled' => 1,
58 60
59 61 // The firewall and whitelist rules.
60 62 'patchstack_firewall_rules' => '',
63 + 'patchstack_firewall_rules_v3' => '[]',
61 64 'patchstack_whitelist_rules' => '',
62 - 'patchstack_custom_whitelist_rules' => '',
65 + 'patchstack_whitelist_rules_v3' => '[]',
63 66 'patchstack_whitelist_keys_rules' => '',
64 67
65 68 // Firewall options.
66 69 'patchstack_basic_firewall' => 1,
67 - 'patchstack_basic_firewall_roles' => array( 'administrator', 'editor', 'author', 'contributor' ),
70 + 'patchstack_basic_firewall_roles' => [ 'administrator', 'editor', 'author', 'contributor' ],
68 71 'patchstack_firewall_ip_header' => '',
72 + 'patchstack_ip_header_computed' => 0,
69 73 'patchstack_disable_htaccess' => 0,
70 74 'patchstack_known_blacklist' => 0,
71 75 'patchstack_block_debug_log_access' => 1,
72 76 'patchstack_block_fake_bots' => 1,
@@ -83,22 +87,10 @@
83 87 'patchstack_blocked_attacks' => 0,
84 88 'patchstack_ip_block_list' => '',
85 89 'patchstack_geo_block_enabled' => 0,
86 90 'patchstack_geo_block_inverse' => 0,
87 - 'patchstack_geo_block_countries' => array(),
91 + 'patchstack_geo_block_countries' => [],
88 92
89 - // Cookie notice options.
90 - 'patchstack_cookie_notice_message' => 'We use cookies for various purposes including analytics and personalized marketing. By continuing to use the service, you agree to our use of cookies.',
91 - 'patchstack_cookie_notice_backgroundcolor' => '#222222',
92 - 'patchstack_cookie_notice_textcolor' => '#ffffff',
93 - 'patchstack_cookie_notice_privacypolicy_enable' => 0,
94 - 'patchstack_cookie_notice_privacypolicy_text' => 'Cookie Policy',
95 - 'patchstack_cookie_notice_privacypolicy_link' => '#',
96 - 'patchstack_cookie_notice_cookie_expiration' => 'after_exit',
97 - 'patchstack_cookie_notice_opacity' => '100',
98 - 'patchstack_cookie_notice_accept_text' => 'I agree',
99 - 'patchstack_cookie_notice_credits' => 1,
100 -
101 93 // Login and firewall brute force options.
102 94 'patchstack_block_bruteforce_ips' => 0,
103 95 'patchstack_anti_bruteforce_attempts' => 10,
104 96 'patchstack_anti_bruteforce_minutes' => 5,
@@ -114,17 +106,37 @@
114 106
115 107 // General options.
116 108 'patchstack_blackhole_log' => '',
117 109 'patchstack_software_data_hash' => '',
110 + 'patchstack_software_upload_attempted' => false,
118 111 'patchstack_firewall_htaccess_hash' => '',
112 + 'patchstack_license_expiry' => '',
119 113 'patchstack_clientid' => false,
120 114 'patchstack_secretkey' => false,
115 + 'patchstack_secretkey_nonce' => '',
121 116 'patchstack_license_free' => 0,
122 117 'patchstack_api_token' => '',
118 + 'patchstack_subscription_class' => '',
119 + 'patchstack_last_license_check' => 0,
123 120 'patchstack_whitelist' => '',
124 - 'patchstack_show_settings' => 0
125 - );
121 + 'patchstack_show_settings' => 0,
122 + 'patchstack_firewall_log_lastid' => 0,
123 + 'patchstack_eventlog_lastid' => 0,
124 + 'patchstack_ott_action' => '',
125 + 'patchstack_enc_nonce' => '',
126 + 'patchstack_managed' => false,
127 + 'patchstack_managed_text' => '',
128 + 'patchstack_latest_vulnerable' => [],
129 + 'patchstack_site_id' => 0,
130 + 'patchstack_activation_secret' => '',
131 + 'patchstack_activation_time' => '',
126 132
133 + // Admin page rename options.
134 + 'patchstack_mv_wp_login' => 0,
135 + 'patchstack_rename_wp_login' => 'swlogin',
136 + 'patchstack_rename_wp_login_whitelist' => []
137 + ];
138 +
127 139 /**
128 140 * Register all the options, if not set already.
129 141 *
130 142 * @return void
@@ -143,96 +155,99 @@
143 155
144 156 // Multisite options
145 157 add_network_option( null, 'patchstack_multisite_installed', 0 );
146 158
159 + // Get the class value and convert.
160 + $class = get_option( 'patchstack_subscription_class', '' );
161 + $is_community = $class != '' && (int) $class === 0;
162 +
147 163 // All (sub)sections that show up.
148 - add_settings_section( 'patchstack_settings_section_hardening', __( 'Security Configurations', 'patchstack' ), false, 'patchstack_hardening_settings' );
149 - add_settings_section( 'patchstack_settings_section_hardening_captcha', __( '<hr style="height:1px;border:none;background-color: rgba(170, 189, 215, 0.1);"><br /> reCAPTCHA<br /><span style="font-size: 13px; color: #d0d0d0;">It should be noted that the reCAPTCHA feature only applies to WordPress its core features at this time. Not custom forms or of third party plugins.</span>', 'patchstack' ), false, 'patchstack_hardening_settings' );
150 - add_settings_section( 'patchstack_settings_section_firewall', __( 'Firewall settings', 'patchstack' ), false, 'patchstack_firewall_settings' );
151 - if ( ! is_multisite() || ( isset( $_GET['page'] ) && $_GET['page'] == 'patchstack-multisite-settings' ) ) {
152 - add_settings_section( 'patchstack_settings_section_firewall_htaccess', __( '.htaccess Features', 'patchstack' ), false, 'patchstack_firewall_settings' );
164 + add_settings_section( 'patchstack_settings_section_hardening', esc_attr__( 'Security Configurations', 'patchstack' ), false, 'patchstack_hardening_settings' );
165 + add_settings_section( 'patchstack_settings_section_hardening_captcha', esc_attr__( 'reCAPTCHA', 'patchstack' ), false, 'patchstack_hardening_settings' );
166 + add_settings_section( 'patchstack_settings_section_firewall', esc_attr__( 'Firewall settings', 'patchstack' ), false, 'patchstack_firewall_settings' );
167 + if ( ( ! is_multisite() || ( isset( $_GET['page'] ) && $_GET['page'] == 'patchstack-multisite-settings' ) ) && ! $is_community ) {
168 + add_settings_section( 'patchstack_settings_section_firewall_htaccess', esc_attr__( '.htaccess Features', 'patchstack' ), false, 'patchstack_firewall_settings' );
153 169 }
154 - add_settings_section( 'patchstack_settings_section_firewall_geo', __( 'Country Blocking', 'patchstack' ), false, 'patchstack_firewall_settings' );
155 - add_settings_section( 'patchstack_settings_section_firewall_wlbl', __( 'IP Whitelist &amp; Blacklist', 'patchstack' ), false, 'patchstack_firewall_settings' );
156 - add_settings_section( 'patchstack_settings_section_cookienotice', __( 'Cookie Notice Settings', 'patchstack' ), false, 'patchstack_cookienotice_settings' );
157 - add_settings_section( 'patchstack_settings_section_login', __( 'Login Protection', 'patchstack' ), false, 'patchstack_login_settings' );
158 - add_settings_section( 'patchstack_settings_section_login_2fa', __( '<hr style="height:1px;border:none;background-color: rgba(170, 189, 215, 0.1);"><br /> Two Factor Authentication', 'patchstack' ), false, 'patchstack_login_settings' );
159 - add_settings_section( 'patchstack_settings_section_login_blocked', __( '<hr style="height:1px;border:none;background-color: rgba(170, 189, 215, 0.1);"><br /> Currently Blocked IP Addresses', 'patchstack' ), false, 'patchstack_login_settings' );
160 - add_settings_section( 'patchstack_settings_section_login_whitelist', __( '<hr style="height:1px;border:none;background-color: rgba(170, 189, 215, 0.1);"><br /> Whitelisted IP Addresses', 'patchstack' ), false, 'patchstack_login_settings' );
161 170
171 + if (! $is_community ) {
172 + add_settings_section( 'patchstack_settings_section_firewall_geo', esc_attr__( 'Country Blocking', 'patchstack' ), false, 'patchstack_firewall_settings' );
173 + }
174 +
175 + add_settings_section( 'patchstack_settings_section_firewall_wlbl', esc_attr__( 'IP Whitelist &amp; Blacklist', 'patchstack' ), false, 'patchstack_firewall_settings' );
176 + add_settings_section( 'patchstack_settings_section_login', esc_attr__( 'Login Protection', 'patchstack' ), false, 'patchstack_login_settings' );
177 + add_settings_section( 'patchstack_settings_section_login_2fa', esc_attr__( 'Two Factor Authentication', 'patchstack' ), false, 'patchstack_login_settings' );
178 + add_settings_section( 'patchstack_settings_section_login_blocked', esc_attr__( 'Currently Blocked IP Addresses', 'patchstack' ), false, 'patchstack_login_settings' );
179 + add_settings_section( 'patchstack_settings_section_login_whitelist', esc_attr__( 'Whitelisted IP Addresses', 'patchstack' ), false, 'patchstack_login_settings' );
180 +
162 181 // Hardening.
163 182 if ( ! is_multisite() || ( isset( $_GET['page'] ) && $_GET['page'] == 'patchstack-multisite-settings' ) ) {
164 - add_settings_field( 'patchstack_rm_readme', __( 'Remove readme.html', 'patchstack' ), array( $this, 'patchstack_rm_readme_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
165 - add_settings_field( 'patchstack_auto_update', __( 'Auto Update Software', 'patchstack' ), array( $this, 'patchstack_auto_update_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
183 + add_settings_field( 'patchstack_rm_readme', esc_attr__( 'Remove readme.html', 'patchstack' ), [ $this, 'patchstack_rm_readme_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
184 + add_settings_field( 'patchstack_auto_update', esc_attr__( 'Auto Update Software', 'patchstack' ), [ $this, 'patchstack_auto_update_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
166 185 }
167 - add_settings_field( 'patchstack_basicscanblock', __( 'Stop readme.txt Scans', 'patchstack' ), array( $this, 'patchstack_basicscanblock_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
168 - add_settings_field( 'patchstack_userenum', __( 'Disable user enumeration', 'patchstack' ), array( $this, 'patchstack_userenum_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
169 - add_settings_field( 'patchstack_hidewpversion', __( 'Hide WordPress version', 'patchstack' ), array( $this, 'patchstack_hidewpversion_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
170 - add_settings_field( 'patchstack_activity_log_is_enabled', __( 'Enable activity log', 'patchstack' ), array( $this, 'patchstack_activity_log_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
171 - add_settings_field( 'patchstack_activity_log_failed_logins', __( 'Log failed logins', 'patchstack' ), array( $this, 'patchstack_activity_log_failed_logins_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
172 - add_settings_field( 'patchstack_activity_log_failed_logins_db', __( 'Upload failed logins to Patchstack', 'patchstack' ), array( $this, 'patchstack_activity_log_failed_logins_db_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
173 - add_settings_field( 'patchstack_application_passwords_disabled', __( 'Block Application Passwords', 'patchstack' ), array( $this, 'patchstack_application_passwords_disabled_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
174 - add_settings_field( 'patchstack_xmlrpc_is_disabled', __( 'Restrict XML-RPC Access', 'patchstack' ), array( $this, 'patchstack_xmlrpc_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
175 - add_settings_field( 'patchstack_json_is_disabled', __( 'Restrict WP REST API Access', 'patchstack' ), array( $this, 'patchstack_json_is_disabled_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
176 - add_settings_field( 'patchstack_register_email_blacklist', __( 'Registration Email Blacklist', 'patchstack' ), array( $this, 'patchstack_register_email_blacklist_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
186 + add_settings_field( 'patchstack_basicscanblock', esc_attr__( 'Stop readme.txt Scans', 'patchstack' ), [ $this, 'patchstack_basicscanblock_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
187 + add_settings_field( 'patchstack_pluginedit', esc_attr__( 'Disable theme editor', 'patchstack' ), [ $this, 'patchstack_pluginedit_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
188 + add_settings_field( 'patchstack_userenum', esc_attr__( 'Disable user enumeration', 'patchstack' ), [ $this, 'patchstack_userenum_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
189 + add_settings_field( 'patchstack_hidewpversion', esc_attr__( 'Hide WordPress version', 'patchstack' ), [ $this, 'patchstack_hidewpversion_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
190 + add_settings_field( 'patchstack_activity_log_is_enabled', esc_attr__( 'Enable activity log', 'patchstack' ), [ $this, 'patchstack_activity_log_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
191 + add_settings_field( 'patchstack_activity_log_failed_logins', esc_attr__( 'Log failed logins', 'patchstack' ), [ $this, 'patchstack_activity_log_failed_logins_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
192 + add_settings_field( 'patchstack_activity_log_failed_logins_db', esc_attr__( 'Upload failed logins to Patchstack', 'patchstack' ), [ $this, 'patchstack_activity_log_failed_logins_db_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
193 + add_settings_field( 'patchstack_application_passwords_disabled', esc_attr__( 'Block Application Passwords', 'patchstack' ), [ $this, 'patchstack_application_passwords_disabled_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
194 + add_settings_field( 'patchstack_xmlrpc_is_disabled', esc_attr__( 'Restrict XML-RPC Access', 'patchstack' ), [ $this, 'patchstack_xmlrpc_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
195 + add_settings_field( 'patchstack_json_is_disabled', esc_attr__( 'Restrict WP REST API Access', 'patchstack' ), [ $this, 'patchstack_json_is_disabled_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
196 + add_settings_field( 'patchstack_register_email_blacklist', esc_attr__( 'Registration Email Blacklist', 'patchstack' ), [ $this, 'patchstack_register_email_blacklist_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening' );
177 197
178 198 // reCAPTCHA.
179 - add_settings_field( 'patchstack_captcha_on_comments', __( 'Post comments form', 'patchstack' ), array( $this, 'patchstack_captcha_on_comments_callback' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
180 - add_settings_field( 'patchstack_captcha_login_form', __( 'Login form', 'patchstack' ), array( $this, 'patchstack_captcha_login_form_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
181 - add_settings_field( 'patchstack_captcha_registration_form', __( 'Registration form', 'patchstack' ), array( $this, 'patchstack_captcha_registration_form_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
182 - add_settings_field( 'patchstack_captcha_reset_pwd_form', __( 'Password reset form', 'patchstack' ), array( $this, 'patchstack_captcha_reset_pwd_form_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
183 - add_settings_field( 'patchstack_captcha_type', __( 'reCAPTCHA version (invisible/normal)' ), array( $this, 'patchstack_captcha_type_callback' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
184 - add_settings_field( 'patchstack_captcha_public_key', __( 'Site Key ', 'patchstack' ), array( $this, 'patchstack_captcha_public_key_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
185 - add_settings_field( 'patchstack_captcha_private_key', __( 'Secret Key', 'patchstack' ), array( $this, 'patchstack_captcha_private_key_input' ), 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
199 + add_settings_field( 'patchstack_captcha_on_comments', esc_attr__( 'Post comments form', 'patchstack' ), [ $this, 'patchstack_captcha_on_comments_callback' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
200 + add_settings_field( 'patchstack_captcha_login_form', esc_attr__( 'Login form', 'patchstack' ), [ $this, 'patchstack_captcha_login_form_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
201 + add_settings_field( 'patchstack_captcha_registration_form', esc_attr__( 'Registration form', 'patchstack' ), [ $this, 'patchstack_captcha_registration_form_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
202 + add_settings_field( 'patchstack_captcha_reset_pwd_form', esc_attr__( 'Password reset form', 'patchstack' ), [ $this, 'patchstack_captcha_reset_pwd_form_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
203 + add_settings_field( 'patchstack_captcha_type', esc_attr__( 'reCAPTCHA version (invisible/normal)' ), [ $this, 'patchstack_captcha_type_callback' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
204 + add_settings_field( 'patchstack_captcha_public_key', esc_attr__( 'Site Key ', 'patchstack' ), [ $this, 'patchstack_captcha_public_key_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
205 + add_settings_field( 'patchstack_captcha_private_key', esc_attr__( 'Secret Key', 'patchstack' ), [ $this, 'patchstack_captcha_private_key_input' ], 'patchstack_hardening_settings', 'patchstack_settings_section_hardening_captcha' );
186 206
187 207 // Firewall.
188 - add_settings_field( 'patchstack_basic_firewall', __( 'Enable firewall', 'patchstack' ), array( $this, 'patchstack_basic_firewall_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall' );
189 - add_settings_field( 'patchstack_basic_firewall_roles', __( 'Firewall user role whitelist', 'patchstack' ), array( $this, 'patchstack_basic_firewall_roles_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall' );
190 - add_settings_field( 'patchstack_basic_firewall_geo_enabled', __( 'Country Blocking Enabled', 'patchstack' ), array( $this, 'patchstack_basic_firewall_geo_enabled_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_geo' );
191 - add_settings_field( 'patchstack_basic_firewall_geo_inverse', __( 'Inversed Check', 'patchstack' ), array( $this, 'patchstack_basic_firewall_geo_inverse_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_geo' );
192 - add_settings_field( 'patchstack_basic_firewall_geo_countries', __( 'Countries To Block', 'patchstack' ), array( $this, 'patchstack_basic_firewall_geo_countries_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_geo' );
193 - if ( ! is_multisite() || ( isset( $_GET['page'] ) && $_GET['page'] == 'patchstack-multisite-settings' ) ) {
194 - add_settings_field( 'patchstack_firewall_ip_header', __( 'IP Address Header Override', 'patchstack' ), array( $this, 'patchstack_firewall_ip_header_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall' );
195 - add_settings_field( 'patchstack_disable_htaccess', __( 'Disable .htaccess features', 'patchstack' ), array( $this, 'patchstack_disable_htaccess_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
196 - add_settings_field( 'patchstack_add_security_headers', __( 'Add security headers', 'patchstack' ), array( $this, 'patchstack_add_security_headers_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
197 - add_settings_field( 'patchstack_prevent_default_file_access', __( 'Prevent default WordPress file access', 'patchstack' ), array( $this, 'patchstack_prevent_default_file_access_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
198 - add_settings_field( 'patchstack_block_debug_log_access', __( 'Block access to debug.log file', 'patchstack' ), array( $this, 'patchstack_block_debug_log_access_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
199 - add_settings_field( 'patchstack_index_views', __( 'Disable index views', 'patchstack' ), array( $this, 'patchstack_index_views_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
200 - add_settings_field( 'patchstack_proxy_comment_posting', __( 'Forbid proxy comment posting', 'patchstack' ), array( $this, 'patchstack_proxy_comment_posting_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
201 - add_settings_field( 'patchstack_image_hotlinking', __( 'Prevent image hotlinking', 'patchstack' ), array( $this, 'patchstack_image_hotlinking_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
202 - add_settings_field( 'patchstack_firewall_custom_rules', __( 'Add custom .htaccess rules here', 'patchstack' ), array( $this, 'patchstack_firewall_custom_rules_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
203 - add_settings_field( 'patchstack_firewall_custom_rules_loc', __( 'Custom .htaccess rules location', 'patchstack' ), array( $this, 'patchstack_firewall_custom_rules_loc_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
208 + add_settings_field( 'patchstack_basic_firewall', esc_attr__( 'Enable firewall', 'patchstack' ), [ $this, 'patchstack_basic_firewall_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall' );
209 + add_settings_field( 'patchstack_basic_firewall_roles', esc_attr__( 'Firewall user role whitelist', 'patchstack' ), [ $this, 'patchstack_basic_firewall_roles_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall' );
210 +
211 + if ( ! $is_community ) {
212 + add_settings_field( 'patchstack_basic_firewall_geo_enabled', esc_attr__( 'Country Blocking Enabled', 'patchstack' ), [ $this, 'patchstack_basic_firewall_geo_enabled_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_geo' );
213 + add_settings_field( 'patchstack_basic_firewall_geo_inverse', esc_attr__( 'Inversed Check', 'patchstack' ), [ $this, 'patchstack_basic_firewall_geo_inverse_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_geo' );
214 + add_settings_field( 'patchstack_basic_firewall_geo_countries', esc_attr__( 'Countries To Block', 'patchstack' ), [ $this, 'patchstack_basic_firewall_geo_countries_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_geo' );
204 215 }
205 - add_settings_field( 'patchstack_blackhole_log', __( 'Block IP List', 'patchstack' ), array( $this, 'patchstack_blackhole_log_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_wlbl' );
206 - add_settings_field( 'patchstack_whitelist', __( 'Whitelist', 'patchstack' ), array( $this, 'patchstack_whitelist_input' ), 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_wlbl' );
207 216
217 + add_settings_field( 'patchstack_firewall_ip_header', esc_attr__( 'IP Address Header Override', 'patchstack' ), [ $this, 'patchstack_firewall_ip_header_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall' );
218 +
219 + if ( ( ! is_multisite() || ( isset( $_GET['page'] ) && $_GET['page'] == 'patchstack-multisite-settings' ) ) && ! $is_community ) {
220 + add_settings_field( 'patchstack_disable_htaccess', esc_attr__( 'Disable .htaccess features', 'patchstack' ), [ $this, 'patchstack_disable_htaccess_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
221 + add_settings_field( 'patchstack_add_security_headers', esc_attr__( 'Add security headers', 'patchstack' ), [ $this, 'patchstack_add_security_headers_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
222 + add_settings_field( 'patchstack_prevent_default_file_access', esc_attr__( 'Prevent default WordPress file access', 'patchstack' ), [ $this, 'patchstack_prevent_default_file_access_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
223 + add_settings_field( 'patchstack_block_debug_log_access', esc_attr__( 'Block access to debug.log file', 'patchstack' ), [ $this, 'patchstack_block_debug_log_access_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
224 + add_settings_field( 'patchstack_index_views', esc_attr__( 'Disable index views', 'patchstack' ), [ $this, 'patchstack_index_views_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
225 + add_settings_field( 'patchstack_proxy_comment_posting', esc_attr__( 'Forbid proxy comment posting', 'patchstack' ), [ $this, 'patchstack_proxy_comment_posting_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
226 + add_settings_field( 'patchstack_image_hotlinking', esc_attr__( 'Prevent image hotlinking', 'patchstack' ), [ $this, 'patchstack_image_hotlinking_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
227 + add_settings_field( 'patchstack_firewall_custom_rules', esc_attr__( 'Add custom .htaccess rules here', 'patchstack' ), [ $this, 'patchstack_firewall_custom_rules_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
228 + add_settings_field( 'patchstack_firewall_custom_rules_loc', esc_attr__( 'Custom .htaccess rules location', 'patchstack' ), [ $this, 'patchstack_firewall_custom_rules_loc_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_htaccess' );
229 + }
230 + add_settings_field( 'patchstack_blackhole_log', esc_attr__( 'Block IP List', 'patchstack' ), [ $this, 'patchstack_blackhole_log_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_wlbl' );
231 + add_settings_field( 'patchstack_whitelist', esc_attr__( 'Whitelist', 'patchstack' ), [ $this, 'patchstack_whitelist_input' ], 'patchstack_firewall_settings', 'patchstack_settings_section_firewall_wlbl' );
232 +
208 233 // Login protection.
209 - add_settings_field( 'patchstack_block_bruteforce_ips', __( 'Automatic brute-force IP ban', 'patchstack' ), array( $this, 'patchstack_block_bruteforce_ips_input' ), 'patchstack_login_settings', 'patchstack_settings_section_login' );
210 - add_settings_field( 'patchstack_login_time_block', __( 'Logon hours', 'patchstack' ), array( $this, 'patchstack_login_time_block_input' ), 'patchstack_login_settings', 'patchstack_settings_section_login' );
211 - add_settings_field( 'patchstack_login_2fa', __( 'Two Factor Authentication', 'patchstack' ), array( $this, 'patchstack_login_2fa_input' ), 'patchstack_login_settings', 'patchstack_settings_section_login_2fa' );
212 - add_settings_field( 'patchstack_login_blocked', __( 'Blocked', 'patchstack' ), array( $this, 'patchstack_login_blocked_input' ), 'patchstack_login_settings', 'patchstack_settings_section_login_blocked' );
213 - add_settings_field( 'patchstack_login_whitelist', __( 'Whitelist', 'patchstack' ), array( $this, 'patchstack_login_whitelist_input' ), 'patchstack_login_settings', 'patchstack_settings_section_login_whitelist' );
234 + if ( ( ! is_multisite() || ( isset( $_GET['page'] ) && $_GET['page'] == 'patchstack-multisite-settings' ) ) && floatval( substr( phpversion(), 0, 5 ) ) > 5.5 ) {
235 + add_settings_field( 'patchstack_mv_wp_login', esc_attr__( 'Block access to wp-login.php', 'patchstack' ), [ $this, 'patchstack_hidewplogin_input' ], 'patchstack_login_settings', 'patchstack_settings_section_login' );
236 + add_settings_field( 'patchstack_rename_wp_login', '', [ $this, 'patchstack_hidewplogin_rename_input' ], 'patchstack_login_settings', 'patchstack_settings_section_login' );
237 + }
238 + add_settings_field( 'patchstack_block_bruteforce_ips', esc_attr__( 'Automatic brute-force IP ban', 'patchstack' ), [ $this, 'patchstack_block_bruteforce_ips_input' ], 'patchstack_login_settings', 'patchstack_settings_section_login' );
239 + add_settings_field( 'patchstack_login_time_block', esc_attr__( 'Logon hours', 'patchstack' ), [ $this, 'patchstack_login_time_block_input' ], 'patchstack_login_settings', 'patchstack_settings_section_login' );
240 + add_settings_field( 'patchstack_login_2fa', esc_attr__( 'Two Factor Authentication', 'patchstack' ), [ $this, 'patchstack_login_2fa_input' ], 'patchstack_login_settings', 'patchstack_settings_section_login_2fa' );
241 + add_settings_field( 'patchstack_login_blocked', esc_attr__( 'Blocked', 'patchstack' ), [ $this, 'patchstack_login_blocked_input' ], 'patchstack_login_settings', 'patchstack_settings_section_login_blocked' );
242 + add_settings_field( 'patchstack_login_whitelist', esc_attr__( 'Whitelist', 'patchstack' ), [ $this, 'patchstack_login_whitelist_input' ], 'patchstack_login_settings', 'patchstack_settings_section_login_whitelist' );
214 243
215 - // Cookie notice.
216 - add_settings_field( 'patchstack_enable_cookie_notice_message', 'Enable Cookie Notice', array( $this, 'patchstack_enable_cookie_notice_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
217 - add_settings_field( 'patchstack_cookie_notice_message', 'Enter message for displaying', array( $this, 'patchstack_cookie_notice_message_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
218 - add_settings_field( 'patchstack_cookie_notice_accept_text', 'Cookie acceptance button text', array( $this, 'patchstack_cookie_notice_accept_text_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
219 - add_settings_field( 'patchstack_cookie_notice_backgroundcolor', 'Background color (HEX)', array( $this, 'patchstack_cookie_notice_backgroundcolor_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
220 - add_settings_field( 'patchstack_cookie_notice_textcolor', 'Text color (HEX)', array( $this, 'patchstack_cookie_notice_textcolor_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
221 - add_settings_field( 'patchstack_cookie_notice_privacypolicy_enable', 'Enable Policy Link', array( $this, 'patchstack_cookie_notice_privacypolicy_enable_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
222 - add_settings_field( 'patchstack_cookie_notice_privacypolicy_text', 'Enter Policy Text', array( $this, 'patchstack_cookie_notice_privacypolicy_text_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
223 - add_settings_field( 'patchstack_cookie_notice_privacypolicy_link', 'Enter Policy Link', array( $this, 'patchstack_cookie_notice_privacypolicy_link_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
224 - add_settings_field( 'patchstack_cookie_notice_cookie_expiration', 'When to ask user permission again', array( $this, 'patchstack_cookie_notice_cookie_expiration_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
225 - add_settings_field( 'patchstack_cookie_notice_opacity', 'Background opacity (in percentage)', array( $this, 'patchstack_cookie_notice_opacity_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
226 - add_settings_field( 'patchstack_cookie_notice_credits', 'Display Patchstack credits', array( $this, 'patchstack_cookie_notice_credits_callback' ), 'patchstack_cookienotice_settings', 'patchstack_settings_section_cookienotice' );
227 -
228 244 // Register the group settings.
229 - $settings = array(
230 - 'hardening' => array( 'patchstack_auto_update', 'patchstack_json_is_disabled', 'patchstack_register_email_blacklist', 'patchstack_pluginedit', 'patchstack_basicscanblock', 'patchstack_userenum', 'patchstack_rm_readme', 'patchstack_hidewpcontent', 'patchstack_hidewpversion', 'patchstack_activity_log_is_enabled', 'patchstack_activity_log_failed_logins', 'patchstack_activity_log_failed_logins_db', 'patchstack_movewpconfig', 'patchstack_captcha_on_comments', 'patchstack_captcha_login_form', 'patchstack_captcha_registration_form', 'patchstack_captcha_reset_pwd_form', 'patchstack_captcha_public_key', 'patchstack_captcha_private_key', 'patchstack_captcha_type', 'patchstack_captcha_public_key_v3', 'patchstack_captcha_private_key_v3', 'patchstack_captcha_public_key_v3_new', 'patchstack_captcha_private_key_v3_new', 'patchstack_xmlrpc_is_disabled', 'patchstack_application_passwords_disabled' ),
231 - 'firewall' => array( 'patchstack_geo_block_enabled', 'patchstack_geo_block_inverse', 'patchstack_basic_firewall_geo_countries', 'patchstack_ip_block_list', 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_firewall_ip_header', 'patchstack_basic_firewall_roles', 'patchstack_disable_htaccess', 'patchstack_add_security_headers', 'patchstack_known_blacklist', 'patchstack_block_debug_log_access', 'patchstack_block_fake_bots', 'patchstack_index_views', 'patchstack_proxy_comment_posting', 'patchstack_bad_query_strings', 'patchstack_advanced_character_string_filter', 'patchstack_advanced_blacklist_firewall', 'patchstack_forbid_rfi', 'patchstack_image_hotlinking', 'patchstack_firewall_custom_rules', 'patchstack_firewall_custom_rules_loc', 'patchstack_blackhole_log', 'patchstack_whitelist', 'patchstack_autoblock_blocktime', 'patchstack_autoblock_attempts', 'patchstack_autoblock_minutes' ),
232 - 'cookienotice' => array( 'patchstack_enable_cookie_notice_message', 'patchstack_cookie_notice_message', 'patchstack_cookie_notice_backgroundcolor', 'patchstack_cookie_notice_textcolor', 'patchstack_cookie_notice_privacypolicy_enable', 'patchstack_cookie_notice_privacypolicy_text', 'patchstack_cookie_notice_privacypolicy_link', 'patchstack_cookie_notice_cookie_expiration', 'patchstack_cookie_notice_opacity', 'patchstack_cookie_notice_accept_text', 'patchstack_cookie_notice_credits' ),
233 - 'login' => array( 'patchstack_block_bruteforce_ips', 'patchstack_anti_bruteforce_attempts', 'patchstack_anti_bruteforce_minutes', 'patchstack_anti_bruteforce_blocktime', 'patchstack_login_time_block', 'patchstack_login_time_start', 'patchstack_login_time_end', 'patchstack_login_2fa', 'patchstack_login_blocked', 'patchstack_login_whitelist' ),
234 - );
245 + $settings = [
246 + 'hardening' => [ 'patchstack_auto_update', 'patchstack_json_is_disabled', 'patchstack_register_email_blacklist', 'patchstack_pluginedit', 'patchstack_basicscanblock', 'patchstack_userenum', 'patchstack_rm_readme', 'patchstack_hidewpcontent', 'patchstack_hidewpversion', 'patchstack_activity_log_is_enabled', 'patchstack_activity_log_failed_logins', 'patchstack_activity_log_failed_logins_db', 'patchstack_movewpconfig', 'patchstack_captcha_on_comments', 'patchstack_captcha_login_form', 'patchstack_captcha_registration_form', 'patchstack_captcha_reset_pwd_form', 'patchstack_captcha_public_key', 'patchstack_captcha_private_key', 'patchstack_captcha_type', 'patchstack_captcha_public_key_v3', 'patchstack_captcha_private_key_v3', 'patchstack_captcha_public_key_v3_new', 'patchstack_captcha_private_key_v3_new', 'patchstack_xmlrpc_is_disabled', 'patchstack_application_passwords_disabled' ],
247 + 'firewall' => [ 'patchstack_geo_block_enabled', 'patchstack_geo_block_inverse', 'patchstack_basic_firewall_geo_countries', 'patchstack_ip_block_list', 'patchstack_prevent_default_file_access', 'patchstack_basic_firewall', 'patchstack_firewall_ip_header', 'patchstack_basic_firewall_roles', 'patchstack_disable_htaccess', 'patchstack_add_security_headers', 'patchstack_known_blacklist', 'patchstack_block_debug_log_access', 'patchstack_block_fake_bots', 'patchstack_index_views', 'patchstack_proxy_comment_posting', 'patchstack_bad_query_strings', 'patchstack_advanced_character_string_filter', 'patchstack_advanced_blacklist_firewall', 'patchstack_forbid_rfi', 'patchstack_image_hotlinking', 'patchstack_firewall_custom_rules', 'patchstack_firewall_custom_rules_loc', 'patchstack_blackhole_log', 'patchstack_whitelist', 'patchstack_autoblock_blocktime', 'patchstack_autoblock_attempts', 'patchstack_autoblock_minutes' ],
248 + 'login' => [ 'patchstack_mv_wp_login', 'patchstack_rename_wp_login', 'patchstack_block_bruteforce_ips', 'patchstack_anti_bruteforce_attempts', 'patchstack_anti_bruteforce_minutes', 'patchstack_anti_bruteforce_blocktime', 'patchstack_login_time_block', 'patchstack_login_time_start', 'patchstack_login_time_end', 'patchstack_login_2fa', 'patchstack_login_blocked', 'patchstack_login_whitelist' ],
249 + ];
235 250
236 251 foreach ( $settings as $key => $setting ) {
237 252 foreach ( $setting as $option ) {
238 253 register_setting( 'patchstack_' . $key . '_settings_group', $option );
@@ -245,16 +260,16 @@
245 260 echo wp_kses( '<p style="color: red;">The auto update feature cannot be enabled because a plugin or code change forces automatic updates to be disabled. (AUTOMATIC_UPDATER_DISABLED)</p>', $this->allowed_html );
246 261 return;
247 262 }
248 263
249 - $selected = get_site_option( 'patchstack_auto_update', array() );
250 - $selected = ! is_array( $selected ) ? array() : $selected;
251 - $options = array(
264 + $selected = get_site_option( 'patchstack_auto_update', [] );
265 + $selected = ! is_array( $selected ) ? [] : $selected;
266 + $options = [
252 267 'core' => 'WordPress Core',
253 268 'plugin' => 'Plugins',
254 269 'theme' => 'Themes',
255 270 'vulnerable' => 'Vulnerable Plugins',
256 - );
271 + ];
257 272 $out = '';
258 273 foreach ( $options as $option => $text ) {
259 274 $out .= '<input type="checkbox" id="patchstack_auto_update_' . $option . '" name="patchstack_auto_update[]" value="' . $option . '" ' . checked( 1, in_array( $option, $selected ), false ) . '/>'
260 275 . '<label for="patchstack_auto_update_' . $option . '"><i>' . $text . '</i></label><br>';
@@ -259,25 +274,25 @@
259 274 $out .= '<input type="checkbox" id="patchstack_auto_update_' . $option . '" name="patchstack_auto_update[]" value="' . $option . '" ' . checked( 1, in_array( $option, $selected ), false ) . '/>'
260 275 . '<label for="patchstack_auto_update_' . $option . '"><i>' . $text . '</i></label><br>';
261 276 }
262 277
263 - $string1 = __( 'Select what needs to be automatically updated each time WordPress looks for updates in the background.<br />Keep in mind that if a plugin update contains a bug or a fatal error, it could break your site.', 'patchstack' );
278 + $string1 = esc_attr__( 'Select what needs to be automatically updated each time WordPress looks for updates in the background.<br />Keep in mind that if a plugin update contains a bug or a fatal error, it could break your site.', 'patchstack' );
264 279 echo wp_kses( ( '<label for="patchstack_auto_update"><i>' . $string1 . '</i></label><br /><br />' . $out ), $this->allowed_html );
265 280 }
266 281
267 282 public function patchstack_basic_firewall_geo_enabled_input() {
268 - $string1 = __( 'If enabled and valid countries are specified to be blocked, will block these countries.', 'patchstack' );
283 + $string1 = esc_attr__( 'If enabled and valid countries are specified to be blocked, will block these countries.', 'patchstack' );
269 284 echo wp_kses( '<input type="checkbox" name="patchstack_geo_block_enabled" id="patchstack_geo_block_enabled" value="1" ' . checked( 1, $this->get_option( 'patchstack_geo_block_enabled' ), false ) . '/><label for="patchstack_geo_block_enabled"><i>' . $string1 . '</i></label>' , $this->allowed_html );
270 285 }
271 286
272 287 public function patchstack_basic_firewall_geo_inverse_input() {
273 - $string1 = __( 'If enabled, instead of checking if the country of the visitor is in the list, check if it is not in the list instead.', 'patchstack' );
288 + $string1 = esc_attr__( 'If enabled, instead of checking if the country of the visitor is in the list, check if it is not in the list instead.', 'patchstack' );
274 289 echo wp_kses( '<input type="checkbox" name="patchstack_geo_block_inverse" id="patchstack_geo_block_inverse" value="1" ' . checked( 1, $this->get_option( 'patchstack_geo_block_inverse' ), false ) . '/><label for="patchstack_geo_block_inverse"><i>' . $string1 . '</i></label>' , $this->allowed_html );
275 290 }
276 291
277 292 public function patchstack_basic_firewall_geo_countries_input() {
278 293 $string1 = __( 'Specify which countries should be blocked.<br />Note that this will also block any type of (legitimate) bot traffic coming from this country. IP to country resolution might also not be 100% accurate.', 'patchstack' );
279 - $countries = $this->get_option( 'patchstack_geo_block_countries', array() );
294 + $countries = $this->get_option( 'patchstack_geo_block_countries', [] );
280 295 $country_list = '';
281 296 if ( ! empty( $countries ) ) {
282 297 foreach ( $countries as $country ) {
283 298 $country_list .= esc_attr( $country ) . ",";
@@ -287,19 +302,19 @@
287 302 echo wp_kses( '<label for="patchstack_geo_block_enabled"><i>' . $string1 . '</i></label>' , $this->allowed_html );
288 303 }
289 304
290 305 public function patchstack_xmlrpc_input() {
291 - $string1 = __( 'Restrict access to xmlrpc.php by only allowing authenticated users to access it.', 'patchstack' );
306 + $string1 = esc_attr__( 'Restrict access to xmlrpc.php by only allowing authenticated users to access it.', 'patchstack' );
292 307 echo wp_kses( '<input type="checkbox" name="patchstack_xmlrpc_is_disabled" id="patchstack_xmlrpc_is_disabled" value="1" ' . checked( 1, $this->get_option( 'patchstack_xmlrpc_is_disabled' ), false ) . '/><label for="patchstack_xmlrpc_is_disabled"><i>' . $string1 . '</i></label>' , $this->allowed_html );
293 308 }
294 309
295 310 public function patchstack_application_passwords_disabled_input() {
296 - $string1 = __( 'Disables the application passwords feature introduced in WordPress 5.6.', 'patchstack' );
311 + $string1 = esc_attr__( 'Disables the application passwords feature introduced in WordPress 5.6.', 'patchstack' );
297 312 echo wp_kses( '<input type="checkbox" name="patchstack_application_passwords_disabled" id="patchstack_application_passwords_disabled" value="1" ' . checked( 1, $this->get_option( 'patchstack_application_passwords_disabled' ), false ) . '/><label for="patchstack_application_passwords_disabled"><i>' . $string1 . '</i></label>' , $this->allowed_html );
298 313 }
299 314
300 315 public function patchstack_json_is_disabled_input() {
301 - $string1 = __( 'Restrict access to the WP Rest API by only allowing authenticated users to access it.', 'patchstack' );
316 + $string1 = esc_attr__( 'Restrict access to the WP Rest API by only allowing authenticated users to access it.', 'patchstack' );
302 317 echo wp_kses( '<input type="checkbox" name="patchstack_json_is_disabled" id="patchstack_json_is_disabled" value="1" ' . checked( 1, $this->get_option( 'patchstack_json_is_disabled' ), false ) . '/><label for="patchstack_json_is_disabled"><i>' . $string1 . '</i></label>' , $this->allowed_html );
303 318 }
304 319
305 320 public function patchstack_register_email_blacklist_input() {
@@ -307,132 +322,87 @@
307 322 echo wp_kses( '<input type="text" name="patchstack_register_email_blacklist" id="patchstack_register_email_blacklist" value="' . esc_attr( $this->get_option( 'patchstack_register_email_blacklist', '' ) ) . '"/><label for="patchstack_register_email_blacklist"><i>' . $string1 . '</i></label>' , $this->allowed_html );
308 323 }
309 324
310 325 public function patchstack_activity_log_input() {
311 - $string1 = __( 'If enabled, every user action will be recorded and put to activity logs', 'patchstack' );
326 + $string1 = esc_attr__( 'If enabled, a large number of user related activities will be logged.', 'patchstack' );
312 327 echo wp_kses( '<input type="checkbox" name="patchstack_activity_log_is_enabled" id="patchstack_activity_log_is_enabled" value="1" ' . checked( 1, $this->get_option( 'patchstack_activity_log_is_enabled' ), false ) . '/><label for="patchstack_activity_log_is_enabled"><i>' . $string1 . '</i></label>' , $this->allowed_html );
313 328 }
314 329
315 330 public function patchstack_activity_log_failed_logins_input() {
316 - $string1 = __( 'If this is checked along with the activity logs, we will also log failed login attempts.', 'patchstack' );
331 + $string1 = esc_attr__( 'If this is checked along with the activity logs, we will also log failed login attempts.', 'patchstack' );
317 332 echo wp_kses( '<input type="checkbox" name="patchstack_activity_log_failed_logins" id="patchstack_activity_log_failed_logins" value="1" ' . checked( 1, $this->get_option( 'patchstack_activity_log_failed_logins' ), false ) . '/><label for="patchstack_activity_log_failed_logins"><i>' . $string1 . '</i></label>' , $this->allowed_html );
318 333 }
319 334
320 335 public function patchstack_activity_log_failed_logins_db_input() {
321 - $string1 = __( 'If this is checked along with the failed login logger, we will also upload the failed login logs to Patchstack.', 'patchstack' );
336 + $string1 = esc_attr__( 'If this is checked along with the failed login logger, we will also upload the failed login logs to Patchstack.', 'patchstack' );
322 337 echo wp_kses( '<input type="checkbox" name="patchstack_activity_log_failed_logins_db" id="patchstack_activity_log_failed_logins_db" value="1" ' . checked( 1, $this->get_option( 'patchstack_activity_log_failed_logins_db' ), false ) . '/><label for="patchstack_activity_log_failed_logins_db"><i>' . $string1 . '</i></label>' , $this->allowed_html );
323 338 }
324 339
325 340 public function patchstack_captcha_on_comments_callback() {
326 - $string1 = __( 'Check this if you want to enable reCAPTCHA on post comments.', 'patchstack' );
341 + $string1 = esc_attr__( 'Check this if you want to enable reCAPTCHA on post comments.', 'patchstack' );
327 342 echo wp_kses( '<input type="checkbox" name="patchstack_captcha_on_comments" id="patchstack_captcha_on_comments" value="1" ' . checked( 1, $this->get_option( 'patchstack_captcha_on_comments' ), false ) . '/><label for="patchstack_captcha_on_comments"><i>' . $string1 . '</i></label>' , $this->allowed_html );
328 343 }
329 344
330 - public function patchstack_cookie_notice_credits_callback() {
331 - $string1 = __( 'Check this if you want to display "Powered by Patchstack"', 'patchstack' );
332 - echo wp_kses( '<input type="checkbox" name="patchstack_cookie_notice_credits" id="patchstack_cookie_notice_credits" value="1" ' . checked( 1, $this->get_option( 'patchstack_cookie_notice_credits' ), false ) . '/><label for="patchstack_cookie_notice_credits"><i>' . $string1 . '</i></label>' , $this->allowed_html );
345 + public function patchstack_hidewplogin_input() {
346 + $string1 = esc_attr__( 'Block access to the default wp-login.php page. This will require you to visit the URL below which will whitelist your IP address for 10 minutes to login.', 'patchstack' );
347 + echo wp_kses( '<input type="checkbox" name="patchstack_mv_wp_login" id="patchstack_mv_wp_login" value="1" ' . checked( 1, $this->get_option( 'patchstack_mv_wp_login' ), false ) . '/><label for="patchstack_mv_wp_login"><i>' . $string1 . '</i></label>' , $this->allowed_html );
333 348 }
334 349
335 - public function patchstack_enable_cookie_notice_callback() {
336 - $string1 = __( 'Check this if you want to enable cookie notice message.', 'patchstack' );
337 - echo wp_kses( '<input type="checkbox" name="patchstack_enable_cookie_notice_message" id="patchstack_enable_cookie_notice_message" value="1" ' . checked( 1, $this->get_option( 'patchstack_enable_cookie_notice_message' ), false ) . '/><label for="patchstack_index_views"><i>' . $string1 . '</i></label>' , $this->allowed_html );
338 - }
350 + public function patchstack_hidewplogin_rename_input() {
351 + if ( $this->get_option( 'patchstack_mv_wp_login' ) == 0 && $this->get_option( 'patchstack_rename_wp_login' ) == 'swlogin' ) {
352 + update_site_option( 'patchstack_rename_wp_login', md5( wp_generate_password( 32, true, true ) ) );
353 + }
339 354
340 - public function patchstack_cookie_notice_message_callback() {
341 - echo wp_kses( '<textarea name="patchstack_cookie_notice_message" id="patchstack_cookie_notice_message" rows="20" cols="50">' . esc_textarea( $this->get_option( 'patchstack_cookie_notice_message' ) ) . '</textarea>', $this->allowed_html );
355 + echo wp_kses( '<label><i style="color:red;">This feature should not be used if you have renamed your login page already or when you make use of a system that allows regular users to login.</i></label><br /><br /><label style="font-weight: 300; color: #d0d0d0;"> ' . get_site_url() . '/ </label><input type="text" style="width: 350px;" name="patchstack_rename_wp_login" id="patchstack_rename_wp_login" value="' . esc_attr( $this->get_option( 'patchstack_rename_wp_login' ) ) . '" />' , $this->allowed_html );
356 + if ( $this->get_option( 'patchstack_mv_wp_login' ) && $this->get_option( 'patchstack_rename_wp_login' ) ) {
357 + echo wp_kses( '<br /><br /><div style="font-weight: 300; color: #d0d0d0;">Your login access page is here: <a href="' . get_site_url() . '/' . esc_attr( $this->get_option( 'patchstack_rename_wp_login' ) ) . '">' . get_site_url() . '/' . esc_attr( $this->get_option( 'patchstack_rename_wp_login' ) ) . '</div></a>', $this->allowed_html );
358 + echo wp_kses( '<br /><input type="submit" id="patchstack_send_mail_url" name="patchstack_send_mail_url" value="Send the link to your admin email." class="button-primary" />', $this->allowed_html );
359 + }
342 360 }
343 361
344 - public function patchstack_cookie_notice_accept_text_callback() {
345 - echo wp_kses( "<input type='text' name='patchstack_cookie_notice_accept_text' id='patchstack_cookie_notice_accept_text' value='" . esc_attr( $this->get_option( 'patchstack_cookie_notice_accept_text' ) ) . "'>", $this->allowed_html );
346 - }
347 -
348 - public function patchstack_cookie_notice_backgroundcolor_callback() {
349 - echo wp_kses( "<input type='text' class='jscolor' name='patchstack_cookie_notice_backgroundcolor' id='patchstack_cookie_notice_backgroundcolor' value='" . esc_attr( $this->get_option( 'patchstack_cookie_notice_backgroundcolor' ) ) . "'>", $this->allowed_html );
350 - }
351 -
352 - public function patchstack_cookie_notice_textcolor_callback() {
353 - echo wp_kses( "<input type='text' class='jscolor' name='patchstack_cookie_notice_textcolor' id='patchstack_cookie_notice_textcolor' value='" . esc_attr( $this->get_option( 'patchstack_cookie_notice_textcolor' ) ) . "'>", $this->allowed_html );
354 - }
355 -
356 - public function patchstack_cookie_notice_privacypolicy_enable_callback() {
357 - $string1 = __( 'Check this if you want to enable policy link.', 'patchstack' );
358 - echo wp_kses( '<input type="checkbox" name="patchstack_cookie_notice_privacypolicy_enable" id="patchstack_cookie_notice_privacypolicy_enable" value="1" ' . checked( 1, $this->get_option( 'patchstack_cookie_notice_privacypolicy_enable' ), false ) . '/><label for="patchstack_index_views"><i>' . $string1 . '</i></label>' , $this->allowed_html );
359 - }
360 -
361 - public function patchstack_cookie_notice_privacypolicy_text_callback() {
362 - echo wp_kses( "<input type='text' name='patchstack_cookie_notice_privacypolicy_text' id='patchstack_cookie_notice_privacypolicy_text' value='" . esc_attr( $this->get_option( 'patchstack_cookie_notice_privacypolicy_text' ) ) . "'>", $this->allowed_html );
363 - }
364 -
365 - public function patchstack_cookie_notice_privacypolicy_link_callback() {
366 - echo wp_kses( "<input type='text' name='patchstack_cookie_notice_privacypolicy_link' id='patchstack_cookie_notice_privacypolicy_link' value='" . esc_attr( $this->get_option( 'patchstack_cookie_notice_privacypolicy_link' ) ) . "'>" , $this->allowed_html );
367 - echo wp_kses( '<br /><label for="patchstack_cookie_notice_privacypolicy_link"><i>Starting with http(s)://</i></label>', $this->allowed_html );
368 - }
369 -
370 - public function patchstack_cookie_notice_cookie_expiration_callback() {
371 - echo wp_kses ( '
372 - <select name="patchstack_cookie_notice_cookie_expiration" id="patchstack_cookie_notice_cookie_expiration">
373 - <option ' . ( $this->get_option( 'patchstack_cookie_notice_cookie_expiration' ) == 'after_exit' ? 'selected="selected"' : '' ) . ' value="after_exit">After user re-open browser</option>
374 - <option ' . ( $this->get_option( 'patchstack_cookie_notice_cookie_expiration' ) == '1week' ? 'selected="selected"' : '' ) . ' value="1week">After 1 week</option>
375 - <option ' . ( $this->get_option( 'patchstack_cookie_notice_cookie_expiration' ) == '1month' ? 'selected="selected"' : '' ) . ' value="1month">After 1 month</option>
376 - <option ' . ( $this->get_option( 'patchstack_cookie_notice_cookie_expiration' ) == '1year' ? 'selected="selected"' : '' ) . ' value="1year">After 1 year</option>
377 - </select>
378 - ', $this->allowed_html );
379 - }
380 -
381 - public function patchstack_cookie_notice_opacity_callback() {
382 - echo wp_kses( "<input min=1 max=100 type='number' name='patchstack_cookie_notice_opacity' id='patchstack_cookie_notice_opacity' value='" . esc_attr( $this->get_option( 'patchstack_cookie_notice_opacity' ) ) . "'>", $this->allowed_html );
383 - echo wp_kses( '<br /><label for="patchstack_cookie_notice_opacity"><i>min: 1 - max: 99 - no opacity: 100</i></label>', $this->allowed_html );
384 - }
385 -
386 362 public function patchstack_pluginedit_input() {
387 - $string1 = __( 'Disable direct editing of themes or plugins code from WordPress admin view.', 'patchstack' );
363 + $string1 = esc_attr__( 'Disable the theme editor. This could protect you from potential automated attacks that involve the theme editor.', 'patchstack' );
388 364 echo wp_kses( '<input type="checkbox" name="patchstack_pluginedit" id="patchstack_pluginedit" value="1" ' . checked( 1, $this->get_option( 'patchstack_pluginedit' ), false ) . '/><label for="patchstack_pluginedit"><i>' . $string1 . '</i></label>' , $this->allowed_html );
389 365 }
390 366
391 367 public function patchstack_add_security_headers_input() {
392 - $string1 = __( 'Add security headers to the response by your webserver.', 'patchstack' );
368 + $string1 = esc_attr__( 'Add security headers to the response by your webserver.', 'patchstack' );
393 369 echo wp_kses( '<input type="checkbox" name="patchstack_add_security_headers" id="patchstack_add_security_headers" value="1" ' . checked( 1, $this->get_option( 'patchstack_add_security_headers' ), false ) . '/><label for="patchstack_add_security_headers"><i>' . $string1 . '</i></label>' , $this->allowed_html );
394 370 }
395 371
396 372 public function patchstack_basicscanblock_input() {
397 - $string1 = __( 'This will attempt to stop basic readme.txt scans. These scans are generally used to determine the version of the installed software on the site.', 'patchstack' );
373 + $string1 = esc_attr__( 'This will attempt to stop basic readme.txt scans. These scans are generally used to determine the version of installed plugins on the site.', 'patchstack' );
398 374 echo wp_kses( '<input type="checkbox" name="patchstack_basicscanblock" id="patchstack_basicscanblock" value="1" ' . checked( 1, $this->get_option( 'patchstack_basicscanblock' ), false ) . '/><label for="patchstack_basicscanblock"><i>' . $string1 . '</i></label>' , $this->allowed_html );
399 375 }
400 376
401 377 public function patchstack_userenum_input() {
402 - $string1 = __( 'Disable user enumeration to block hackers from getting your usernames.', 'patchstack' );
378 + $string1 = esc_attr__( 'Make it harder for malicious people to find your WordPress username.', 'patchstack' );
403 379 echo wp_kses( '<input type="checkbox" name="patchstack_userenum" id="patchstack_userenum" value="1" ' . checked( 1, $this->get_option( 'patchstack_userenum' ), false ) . '/><label for="patchstack_userenum"><i>' . $string1 . '</i></label>' , $this->allowed_html );
404 380 }
405 381
406 - public function patchstack_hidewpcontent_input() {
407 - $string1 = __( 'Move wp-content folder into facebook.com folder and link to it in wp-config.php. saving settings after ticking this will take more time than usual. Just let it reload the page on its own and be patient.', 'patchstack' );
408 - $string2 = __( 'If this setting brakes your website then go to your server files through FTP, rename facebook.com folder to wp-content and erase Patchstack section from the top of wp-config.php file.', 'patchstack' );
409 - echo wp_kses( '<input type="checkbox" name="patchstack_hidewpcontent" id="patchstack_hidewpcontent" value="1" ' . checked( 1, $this->get_option( 'patchstack_hidewpcontent' ), false ) . '/><label for="patchstack_hidewpcontent"><i>' . $string1 . '</i></br><span style="color: red; font-weight: bold">' . $string2 . '</span></label>' , $this->allowed_html );
410 - }
411 -
412 382 public function patchstack_hidewpversion_input() {
413 - $string1 = __( 'Removes the WordPress version in the <meta> tag in the HTML output.', 'patchstack' );
383 + $string1 = esc_attr__( 'Removes the WordPress version in the meta tag in the HTML output.', 'patchstack' );
414 384 echo wp_kses( '<input type="checkbox" name="patchstack_hidewpversion" id="patchstack_hidewpversion" value="1" ' . checked( 1, $this->get_option( 'patchstack_hidewpversion' ), false ) . '/><label for="patchstack_hidewpversion"><i>' . $string1 . '</i></label>' , $this->allowed_html );
415 385 }
416 386
417 387 public function patchstack_rm_readme_input() {
418 - $string1 = __( 'Removes the readme.html file from the WordPress root folder.', 'patchstack' );
388 + $string1 = esc_attr__( 'Removes the readme.html file from the WordPress root folder.', 'patchstack' );
419 389 echo wp_kses( '<input type="checkbox" name="patchstack_rm_readme" id="patchstack_rm_readme" value="1" ' . checked( 1, $this->get_option( 'patchstack_rm_readme' ), false ) . '/><label for="patchstack_rm_readme"><i>' . $string1 . '</i></label>' , $this->allowed_html );
420 390 }
421 391
422 392 public function patchstack_prevent_default_file_access_input() {
423 - $string1 = __( 'Prevent access to such files as license.txt, readme.html and wp-config-sample.php', 'patchstack' );
393 + $string1 = esc_attr__( 'Prevent direct access to files such as license.txt, readme.html and wp-config.php', 'patchstack' );
424 394 echo wp_kses( '<input type="checkbox" name="patchstack_prevent_default_file_access" id="patchstack_prevent_default_file_access" value="1" ' . checked( 1, $this->get_option( 'patchstack_prevent_default_file_access' ), false ) . '/><label for="patchstack_prevent_default_file_access"><i>' . $string1 . '</i></label>' , $this->allowed_html );
425 395 }
426 396
427 397 public function patchstack_basic_firewall_input() {
428 - $string1 = __( 'Check this if you want to turn on the advanced firewall protection on your site.', 'patchstack' );
398 + $string1 = esc_attr__( 'Check this if you want to turn on the advanced firewall protection on your site.', 'patchstack' );
429 399 echo wp_kses( '<input type="checkbox" name="patchstack_basic_firewall" id="patchstack_basic_firewall" value="1" ' . checked( 1, $this->get_option( 'patchstack_basic_firewall' ), false ) . '/><label for="patchstack_basic_firewall"><i>' . $string1 . '</i></label><br /><br /><i style="color:#d0d0d0">Block IP for <input style="width: 50px;" type="number" name="patchstack_autoblock_blocktime" value="' . esc_attr( $this->get_option( 'patchstack_autoblock_blocktime', 60 ) ) . '" id="patchstack_autoblock_blocktime"> minutes after <input style="width: 50px;" type="number" name="patchstack_autoblock_attempts" value="' . esc_attr( $this->get_option( 'patchstack_autoblock_attempts', 10 ) ) . '" id="patchstack_autoblock_attempts"> blocked requests over a period of <input style="width: 50px;" type="number" name="patchstack_autoblock_minutes" value="' . esc_attr( $this->get_option( 'patchstack_autoblock_minutes', 30 ) ) . '" id="patchstack_autoblock_minutes"> minutes</i>', $this->allowed_html);
430 400 }
431 401
432 402 public function patchstack_basic_firewall_roles_input() {
433 - $selected = $this->get_option( 'patchstack_basic_firewall_roles', array( 'administrator', 'editor', 'author' ) );
434 - $selected = ! is_array( $selected ) ? array() : $selected;
403 + $selected = $this->get_option( 'patchstack_basic_firewall_roles', [ 'administrator', 'editor', 'author' ] );
404 + $selected = ! is_array( $selected ) ? [] : $selected;
435 405 $roles = wp_roles();
436 406 $roles = $roles->get_names();
437 407 $text = '';
438 408 foreach ( $roles as $key => $val ) {
@@ -438,54 +408,54 @@
438 408 foreach ( $roles as $key => $val ) {
439 409 $text .= '<input type="checkbox" id="patchstack_basic_firewall_roles-' . esc_attr( $key ) . '" name="patchstack_basic_firewall_roles[]" value="' . esc_attr( $key ) . '" ' . checked( 1, in_array( $key, $selected ), false ) . '/><label for="patchstack_basic_firewall_roles-' . esc_attr( $key ) . '"><i>' . esc_html( $val ) . '</i></label><br>';
440 410 }
441 411
442 - $string1 = __( 'Against which user roles should the firewall not run against?<br />The firewall will always run against guests.<br />', 'patchstack' );
412 + $string1 = esc_attr__( 'Against which user roles should the firewall not run against? The firewall will always run against guests.', 'patchstack' );
443 413 echo wp_kses( ( '<label for="patchstack_basic_firewall_roles"><i>' . $string1 . '</i></label><br />' . $text ), $this->allowed_html );
444 414 }
445 415
446 416 public function patchstack_known_blacklist_input() {
447 - $string1 = __( 'Check this if you want to block known malicious connections.', 'patchstack' );
417 + $string1 = esc_attr__( 'Check this if you want to block known malicious connections.', 'patchstack' );
448 418 echo wp_kses( '<input type="checkbox" name="patchstack_known_blacklist" id="patchstack_known_blacklist" value="1" ' . checked( 1, $this->get_option( 'patchstack_known_blacklist' ), false ) . '/><label for="patchstack_known_blacklist"><i>' . $string1 . '</i></label>' , $this->allowed_html );
449 419 }
450 420
451 421 public function patchstack_firewall_ip_header_input() {
452 - $string1 = __( 'If you would like to override the IP address header that we use to grab the IP address of the visitor, enter the value here. This must be a valid value in the $_SERVER array, for example HTTP_X_FORWARDED_FOR. If the $_SERVER value you enter does not exist, it will fallback to the Patchstack IP grab function so ask your hosting company if you are unsure. Leave this empty to use the Patchstack IP address grabbing function.', 'patchstack' );
422 + $string1 = esc_attr__( 'If you would like to override the IP address header that we use to grab the IP address of the visitor, enter the value here. This must be a valid value in the $_SERVER array, for example HTTP_X_FORWARDED_FOR. If the $_SERVER value you enter does not exist, it will fallback to the Patchstack IP grab function so ask your hosting company if you are unsure. Leave this empty to use the Patchstack IP address grabbing function.', 'patchstack' );
453 423 echo wp_kses( '<input type="text" name="patchstack_firewall_ip_header" id="patchstack_firewall_ip_header" value="' . esc_attr( $this->get_option( 'patchstack_firewall_ip_header' ) ) . '"/><br /><br /><label for="patchstack_firewall_ip_header"><i>' . $string1 . '</i></label>' , $this->allowed_html );
454 424 }
455 425
456 426 public function patchstack_disable_htaccess_input() {
457 - $string1 = __( 'Check this if you want to stop us from writing to your .htaccess file. Note that the current changes to the .htaccess file will remain.', 'patchstack' );
427 + $string1 = esc_attr__( 'Check this if you want to stop us from writing to your .htaccess file. Note that the current changes to the .htaccess file will remain.', 'patchstack' );
458 428 echo wp_kses( '<input type="checkbox" name="patchstack_disable_htaccess" id="patchstack_disable_htaccess" value="1" ' . checked( 1, $this->get_option( 'patchstack_disable_htaccess' ), false ) . '/><label for="patchstack_disable_htaccess"><i>' . $string1 . '</i></label>' , $this->allowed_html );
459 429 }
460 430
461 431 public function patchstack_block_debug_log_access_input() {
462 - $string1 = __( 'Check this if you want to block access to the debug.log file that WordPress creates when debug logging is enabled.', 'patchstack' );
432 + $string1 = esc_attr__( 'Check this if you want to block access to the debug.log file that WordPress creates when debug logging is enabled.', 'patchstack' );
463 433 echo wp_kses( '<input type="checkbox" name="patchstack_block_debug_log_access" id="patchstack_block_debug_log_access" value="1" ' . checked( 1, $this->get_option( 'patchstack_block_debug_log_access' ), false ) . '/><label for="patchstack_block_debug_log_access"><i>' . $string1 . '</i></label>' , $this->allowed_html );
464 434 }
465 435
466 436 public function patchstack_index_views_input() {
467 - $string1 = __( 'Check this if you want to disable directory and file listing.', 'patchstack' );
437 + $string1 = esc_attr__( 'Check this if you want to disable directory and file listing.', 'patchstack' );
468 438 echo wp_kses( '<input type="checkbox" name="patchstack_index_views" id="patchstack_index_views" value="1" ' . checked( 1, $this->get_option( 'patchstack_index_views' ), false ) . '/><label for="patchstack_index_views"><i>' . $string1 . '</i></label>' , $this->allowed_html );
469 439 }
470 440
471 441 public function patchstack_proxy_comment_posting_input() {
472 - $string1 = __( 'Check this if you want to forbid proxy comment posting.', 'patchstack' );
442 + $string1 = esc_attr__( 'Check this if you want to forbid proxy comment posting.', 'patchstack' );
473 443 echo wp_kses( '<input type="checkbox" name="patchstack_proxy_comment_posting" id="patchstack_proxy_comment_posting" value="1" ' . checked( 1, $this->get_option( 'patchstack_proxy_comment_posting' ), false ) . '/><label for="patchstack_proxy_comment_posting"><i>' . $string1 . '</i></label>' , $this->allowed_html );
474 444 }
475 445
476 446 public function patchstack_block_bruteforce_ips_input() {
477 - $string1 = __( 'Check this if you want to automatically ban IP addresses that fail to login multiple times in a short span of time.<br />For this feature to work, make sure that "Log failed logins" is turned on at the hardening settings page.', 'patchstack' );
447 + $string1 = esc_attr__( 'Check this if you want to automatically ban IP addresses that fail to login multiple times in a short span of time.<br />For this feature to work, make sure that "Log failed logins" is turned on at the hardening settings page.', 'patchstack' );
478 448 echo wp_kses( '<input type="checkbox" name="patchstack_block_bruteforce_ips" id="patchstack_block_bruteforce_ips" value="1" ' . checked( 1, $this->get_option( 'patchstack_block_bruteforce_ips' ), false ) . '/><label for="patchstack_block_bruteforce_ips"><i>' . $string1 . '</i></label><br /><br /><i style="color:#d0d0d0">Block IP for <input style="width: 50px;" type="number" name="patchstack_anti_bruteforce_blocktime" value="' . esc_attr( $this->get_option( 'patchstack_anti_bruteforce_blocktime', 60 ) ) . '" id="patchstack_anti_bruteforce_blocktime"> minutes after <input style="width: 50px;" type="number" name="patchstack_anti_bruteforce_attempts" value="' . esc_attr( $this->get_option( 'patchstack_anti_bruteforce_attempts', 10 ) ) . '" id="patchstack_anti_bruteforce_attempts"> failed login attempts over a period of <input style="width: 50px;" type="number" name="patchstack_anti_bruteforce_minutes" value="' . esc_attr( $this->get_option( 'patchstack_anti_bruteforce_minutes', 5 ) ) . '" id="patchstack_anti_bruteforce_minutes"> minutes</i>' , $this->allowed_html );
479 449 }
480 450
481 451 public function patchstack_login_time_block_input() {
482 - $string1 = __( 'Check this if you want to enforce specific logon hours.', 'patchstack' );
452 + $string1 = esc_attr__( 'Check this if you want to enforce specific logon hours.', 'patchstack' );
483 453 echo wp_kses( '<input type="checkbox" name="patchstack_login_time_block" id="patchstack_login_time_block" value="1" ' . checked( 1, $this->get_option( 'patchstack_login_time_block' ), false ) . '/><label for="patchstack_login_time_block"><i>' . $string1 . '</i></label><br /><br /><i style="color:#d0d0d0">Allow login between <input style="width: 70px;" type="text" name="patchstack_login_time_start" value="' . esc_attr( $this->get_option( 'patchstack_login_time_start', '00:00' ) ) . '" id="patchstack_login_time_start" autocomplete="off"> and <input style="width: 70px;" type="text" name="patchstack_login_time_end" value="' . esc_attr( $this->get_option( 'patchstack_login_time_end', '23:59' ) ) . '" id="patchstack_login_time_end" autocomplete="off"><br />Times must be in the 24 hour clock format.<br />The logon hours are also based on the current time of your site: ' . current_time( 'H:i:s' ) . '</i>', $this->allowed_html );
484 454 }
485 455
486 456 public function patchstack_login_2fa_input() {
487 - $string1 = __( 'Check this if you want to make it possible for users to enable two factor authentication (2FA) on their account.', 'patchstack' );
457 + $string1 = esc_attr__( 'Check this if you want to make it possible for users to enable two factor authentication (2FA) on their account.', 'patchstack' );
488 458 echo wp_kses( '<input type="checkbox" name="patchstack_login_2fa" id="patchstack_login_2fa" value="1" ' . checked( 1, $this->get_option( 'patchstack_login_2fa' ), false ) . '/><label for="patchstack_login_2fa"><i>' . $string1 . '<br />Once enabled, users can configure 2FA on the "Edit My Profile" page which is located <a href="' . admin_url( 'profile.php' ) . '">here</a>.</i></label><br />' , $this->allowed_html );
489 459 }
490 460
491 461 public function patchstack_login_blocked_input() {
@@ -500,9 +470,9 @@
500 470
501 471 // Check if X failed login attempts were made.
502 472 global $wpdb;
503 473 $results = $wpdb->get_results(
504 - $wpdb->prepare( 'SELECT id, ip, date FROM ' . $wpdb->prefix . "patchstack_event_log WHERE action = 'failed login' AND date >= ('" . current_time( 'mysql' ) . "' - INTERVAL %d MINUTE) GROUP BY ip HAVING COUNT(ip) >= %d ORDER BY date DESC", array( $time, $this->get_option( 'patchstack_anti_bruteforce_attempts', 10 ) ) ),
474 + $wpdb->prepare( 'SELECT id, ip, date FROM ' . $wpdb->prefix . "patchstack_event_log WHERE action = 'failed login' AND date >= ('" . current_time( 'mysql' ) . "' - INTERVAL %d MINUTE) GROUP BY ip HAVING COUNT(ip) >= %d ORDER BY date DESC", [ $time, $this->get_option( 'patchstack_anti_bruteforce_attempts', 10 ) ] ),
505 475 OBJECT
506 476 );
507 477
508 478 // Render the rows.
@@ -511,25 +481,25 @@
511 481 $rows = '<tr><td>No blocked IP addresses.</td><td></td><td></td><td></td></tr>';
512 482 } else {
513 483 $nonce = wp_create_nonce( 'patchstack-nonce-alter-ips' );
514 484 foreach ( $results as $result ) {
515 - $rows .= '<tr><td>' . esc_html( $result->ip ) . '</td><td>' . ( isset( $result->log_date ) ? $result->log_date : $result->date ) . '</td><td><a href="' . add_query_arg(
516 - array(
485 + $rows .= '<tr><td>' . esc_html( $result->ip ) . '</td><td>' . ( isset( $result->log_date ) ? $result->log_date : $result->date ) . '</td><td><a href="' . esc_url( add_query_arg(
486 + [
517 487 'PatchstackNonce' => $nonce,
518 488 'action' => 'patchstack_unblock',
519 489 'id' => $result->id,
520 - )
521 - ) . '">Unblock</a></td><td><a href="' . add_query_arg(
522 - array(
490 + ]
491 + ) ) . '">Unblock</a></td><td><a href="' . esc_url( add_query_arg(
492 + [
523 493 'PatchstackNonce' => $nonce,
524 494 'action' => 'patchstack_unblock_whitelist',
525 495 'id' => $result->id,
526 - )
527 - ) . '">Unblock &amp; Whitelist</a></td></tr>';
496 + ]
497 + ) ) . '">Unblock &amp; Whitelist</a></td></tr>';
528 498 }
529 499 }
530 500
531 - $string1 = __( 'These are the IP addresses that are currently blocked because of too many failed login attempts.<br />These are not the IP addresses banned by the firewall itself.<br /><br />', 'patchstack' );
501 + $string1 = esc_attr__( 'These are the IP addresses that are currently blocked because of too many failed login attempts.<br />These are not the IP addresses banned by the firewall itself.<br /><br />', 'patchstack' );
532 502 echo wp_kses( '<label><i>' . $string1 . '</i></label>', $this->allowed_html );
533 503 echo wp_kses( '<div class="patchstack-content-inner-table"><table class="table dataTable patchstack-bi" style="margin: 0 !important;"><thead><tr><th>IP Address</th><th style="padding-left: 0 !important;">Last Attempt</th><th style="padding-left: 0 !important;">Unblock</th><th style="padding-left: 0 !important;">Unbock &amp; Whitelist</th></tr></thead><tbody>' . $rows . '</table></div>', $this->allowed_html );
534 504 }
535 505
@@ -538,14 +508,14 @@
538 508 echo wp_kses( '<label><i>These IP addresses will never be blocked from logging in, no matter the amount of failed logins.</i></label><br /><br /><p><textarea rows="5" id="patchstack_login_whitelist" name="patchstack_login_whitelist">' . $ip_list . '</textarea>Each entry must be on its own line.<br />Your current IP address is: ' . esc_html( $this->get_ip() ) . '<br /><br /><strong>Following formats are accepted:</strong><p>127.0.0.1</p><p>127.0.0.*</p><p>127.0.0.0/24</p><p>127.0.0.0-127.0.0.255</p></p>', $this->allowed_html );
539 509 }
540 510
541 511 public function patchstack_image_hotlinking_input() {
542 - $string1 = __( 'Check this if you want to prevent hotlinking to images on your site.', 'patchstack' );
512 + $string1 = esc_attr__( 'Check this if you want to prevent hotlinking to images on your site.', 'patchstack' );
543 513 echo wp_kses( '<input type="checkbox" name="patchstack_image_hotlinking" id="patchstack_image_hotlinking" value="1" ' . checked( 1, $this->get_option( 'patchstack_image_hotlinking' ), false ) . '/><label for="patchstack_image_hotlinking"><i>' . $string1 . '</i></label>' , $this->allowed_html );
544 514 }
545 515
546 516 public function patchstack_firewall_custom_rules_input() {
547 - $string1 = __( 'Add custom .htaccess rules here if you know what you are doing, otherwise you may break your site. So be careful.', 'patchstack' );
517 + $string1 = esc_attr__( 'Add custom .htaccess rules here if you know what you are doing, otherwise you may break your site. So be careful.', 'patchstack' );
548 518 echo wp_kses( '<textarea name="patchstack_firewall_custom_rules" id="patchstack_firewall_custom_rules" rows="20" cols="50" placeholder="' . $string1 . '">', $this->allowed_html );
549 519 $rules = $this->get_option( 'patchstack_firewall_custom_rules' );
550 520 if ( isset( $rules ) ) {
551 521 if ( is_array( $rules ) ) {
@@ -564,19 +534,19 @@
564 534 echo wp_kses( '<select name="patchstack_firewall_custom_rules_loc" id="patchstack_firewall_custom_rules_loc"><option ' . ( $this->get_option( 'patchstack_firewall_custom_rules_loc' ) == 'top' ? 'selected="selected"' : '' ) . ' value="top">Top - above Patchstack rules</option><option ' . ( $this->get_option( 'patchstack_firewall_custom_rules_loc' ) == 'bottom' ? 'selected="selected"' : '' ) . ' value="bottom">Bottom - under Patchstack rules</option></select>', $this->allowed_html );
565 535 }
566 536
567 537 public function patchstack_captcha_login_form_input() {
568 - $string1 = __( 'Check this if you want to enable reCAPTCHA on user login.', 'patchstack' );
538 + $string1 = esc_attr__( 'Check this if you want to enable reCAPTCHA on user login.', 'patchstack' );
569 539 echo wp_kses( '<input type="checkbox" name="patchstack_captcha_login_form" id="patchstack_captcha_login_form" value="1" ' . checked( 1, $this->get_option( 'patchstack_captcha_login_form' ), false ) . '/><label for="patchstack_captcha_login_form"><i>' . $string1 . '</i></label>' , $this->allowed_html );
570 540 }
571 541
572 542 public function patchstack_captcha_registration_form_input() {
573 - $string1 = __( 'Check this if you want to enable reCAPTCHA on registration.', 'patchstack' );
543 + $string1 = esc_attr__( 'Check this if you want to enable reCAPTCHA on registration.', 'patchstack' );
574 544 echo wp_kses( '<input type="checkbox" name="patchstack_captcha_registration_form" id="patchstack_captcha_registration_form" value="1" ' . checked( 1, $this->get_option( 'patchstack_captcha_registration_form' ), false ) . '/><label for="patchstack_captcha_registration_form"><i>' . $string1 . '</i></label>' , $this->allowed_html );
575 545 }
576 546
577 547 public function patchstack_captcha_reset_pwd_form_input() {
578 - $string1 = __( 'Check this if you want to enable reCAPTCHA on password reset.', 'patchstack' );
548 + $string1 = esc_attr__( 'Check this if you want to enable reCAPTCHA on password reset.', 'patchstack' );
579 549 echo wp_kses( '<input type="checkbox" name="patchstack_captcha_reset_pwd_form" id="patchstack_captcha_reset_pwd_form" value="1" ' . checked( 1, $this->get_option( 'patchstack_captcha_reset_pwd_form' ), false ) . '/><label for="patchstack_captcha_reset_pwd_form"><i>' . $string1 . '</i></label>' , $this->allowed_html );
580 550 }
581 551
582 552 public function patchstack_captcha_type_callback() {
@@ -588,14 +558,14 @@
588 558 </select>', $this->allowed_html );
589 559 }
590 560
591 561 public function patchstack_captcha_public_key_input() {
592 - $string1 = __( '<br /><br />Enter the reCAPTCHA site key here.<br />Click <a href="https://docs.patchstack.com/technical-support-and-troubleshooting/plugin/how-to-get-the-site-and-secret-key-for-the-recaptcha-feature" target="_blank">here</a> for a guide on how to get the site / secret key.', 'patchstack' );
562 + $string1 = __( '<br /><br />Enter the reCAPTCHA site key here.<br />Click <a href="https://docs.patchstack.com/discuss/62e286cf7040390013b73bf7" target="_blank">here</a> for a guide on how to get the site / secret key.', 'patchstack' );
593 563 echo wp_kses( '<input style="display:none;" type="text" name="patchstack_captcha_public_key" id="patchstack_captcha_public_key" value="' . esc_attr( $this->get_option( 'patchstack_captcha_public_key', '' ) ) . '"/><input style="display:none;" type="text" name="patchstack_captcha_public_key_v3" id="patchstack_captcha_public_key_v3" value="' . esc_attr( $this->get_option( 'patchstack_captcha_public_key_v3', '' ) ) . '"/><input style="display:none;" type="text" name="patchstack_captcha_public_key_v3_new" id="patchstack_captcha_public_key_v3_new" value="' . esc_attr( $this->get_option( 'patchstack_captcha_public_key_v3_new', '' ) ) . '"/><label for="patchstack_captcha_public_key"><i>' . $string1 . '</i></label>' , $this->allowed_html );
594 564 }
595 565
596 566 public function patchstack_captcha_private_key_input() {
597 - $string1 = __( '<br /><br />Enter the reCAPTCHA secret key here.<br />Click <a href="https://docs.patchstack.com/technical-support-and-troubleshooting/plugin/how-to-get-the-site-and-secret-key-for-the-recaptcha-feature" target="_blank">here</a> for a guide on how to get the site / secret key.', 'patchstack' );
567 + $string1 = __( '<br /><br />Enter the reCAPTCHA secret key here.<br />Click <a href="https://docs.patchstack.com/discuss/62e286cf7040390013b73bf7" target="_blank">here</a> for a guide on how to get the site / secret key.', 'patchstack' );
598 568 echo wp_kses( '<input style="display:none;" type="text" name="patchstack_captcha_private_key" id="patchstack_captcha_private_key" value="' . esc_attr( $this->get_option( 'patchstack_captcha_private_key', '' ) ) . '"/><input style="display:none;" type="text" name="patchstack_captcha_private_key_v3" id="patchstack_captcha_private_key_v3" value="' . esc_attr( $this->get_option( 'patchstack_captcha_private_key_v3', '' ) ) . '"/><input style="display:none;" type="text" name="patchstack_captcha_private_key_v3_new" id="patchstack_captcha_private_key_v3_new" value="' . esc_attr( $this->get_option( 'patchstack_captcha_private_key_v3_new', '' ) ) . '"/><label for="patchstack_captcha_private_key"><i>' . $string1 . '</i></label>' , $this->allowed_html );
599 569 }
600 570
601 571 public function patchstack_blackhole_log_input() {