about-us
1 day ago
partials
1 day ago
passkeys
1 day ago
policies
1 day ago
reports
1 day ago
support
1 day ago
customize-code-page.php
1 day ago
customize-setup-wizard.php
1 day ago
customize-user-profile.php
1 day ago
customize-user-prompts.php
1 day ago
email-settings.php
1 day ago
general-settings.php
1 day ago
generic-settings.php
1 day ago
import-export.php
1 day ago
index.php
1 day ago
plugins-integrations.php
1 day ago
providers-integrations.php
1 day ago
sidebar.php
1 day ago
white-labeling.php
1 day ago
generic-settings.php
368 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Settings Template |
| 4 | * |
| 5 | * @package wp-2fa |
| 6 | */ |
| 7 | |
| 8 | use WP2FA\WP2FA; |
| 9 | use WP2FA\Admin\Settings_Builder; |
| 10 | use WP2FA\Utils\Settings_Utils; |
| 11 | |
| 12 | ?> |
| 13 | <input type="hidden" id="use_new_interface" name="wp_2fa_settings[use_new_interface]" value="use_new_interface" <?php echo Settings_Utils::string_to_bool( WP2FA::get_wp2fa_general_setting( 'use_new_interface' ) ) ? 'checked' : ''; ?>> |
| 14 | <div class="settings-page" id="generic-settings-wrap"> |
| 15 | <?php |
| 16 | Settings_Builder::build_option( |
| 17 | array( |
| 18 | 'parent' => \esc_html__( 'Settings', 'wp-2fa' ), |
| 19 | 'type' => 'breadcrumb', |
| 20 | 'custom_class' => 'back-policies-settings-main-wrapper', |
| 21 | 'default' => \esc_html__( 'General settings', 'wp-2fa' ), |
| 22 | ) |
| 23 | ); |
| 24 | |
| 25 | Settings_Builder::build_option( |
| 26 | array( |
| 27 | 'title' => \esc_html__( 'General settings', 'wp-2fa' ), |
| 28 | 'id' => 'general-settings-tab', |
| 29 | 'type' => 'tab-title', |
| 30 | ) |
| 31 | ); |
| 32 | |
| 33 | Settings_Builder::build_option( |
| 34 | array( |
| 35 | 'text' => \wp_sprintf( |
| 36 | // translators: 1. Link to documentation, 2. Link to support. |
| 37 | \esc_html__( 'Use the settings below to configure several 2FA settings on your website. If you have any questions, %1$s or %2$s.', 'wp-2fa' ), |
| 38 | \wp_sprintf( '<a href="%s" target="_blank">%s</a>', 'https://melapress.com/support/?utm_source=plugin&utm_medium=wp2fa&utm_campaign=settings_page_doc', \esc_html__( 'visit documentation', 'wp-2fa' ) ), |
| 39 | \wp_sprintf( '<a href="%s" target="_blank">%s</a>', 'https://melapress.com/support/?utm_source=plugin&utm_medium=wp2fa&utm_campaign=settings_page_support', \esc_html__( 'contact support', 'wp-2fa' ) ) |
| 40 | ), |
| 41 | 'class' => 'description-settings-card', |
| 42 | 'id' => 'general-settings-tab', |
| 43 | 'type' => 'description', |
| 44 | ) |
| 45 | ); |
| 46 | ?> |
| 47 | <div class="settings-card"> |
| 48 | <?php |
| 49 | |
| 50 | Settings_Builder::build_option( |
| 51 | array( |
| 52 | 'title' => \esc_html__( 'Unavailable service', 'wp-2fa' ), |
| 53 | 'id' => 'general-settings-tab', |
| 54 | 'type' => 'section-title', |
| 55 | ) |
| 56 | ); |
| 57 | |
| 58 | Settings_Builder::build_option( |
| 59 | array( |
| 60 | 'text' => \wp_sprintf( |
| 61 | // translators: 1. Link to documentation, 2. Link to support. |
| 62 | \esc_html__( 'There may be cases in which the 2FA service is unavailable when a user is trying to log in. For example, the service is unreachable or there are no credits to complete the action. In this case you can configure the plugin to either block the login process, or allow the user to log in without 2FA authentication.', 'wp-2fa' ), |
| 63 | ), |
| 64 | 'class' => 'description-settings-card', |
| 65 | 'id' => 'general-settings-tab', |
| 66 | 'type' => 'description', |
| 67 | ) |
| 68 | ); |
| 69 | |
| 70 | ?> |
| 71 | <div class="form-group settings-row"> |
| 72 | <?php |
| 73 | |
| 74 | Settings_Builder::build_option( |
| 75 | array( |
| 76 | 'text' => \esc_html__( 'Enforce 2FA on', 'wp-2fa' ), |
| 77 | 'id' => 'general-settings-tab', |
| 78 | 'type' => 'settings-label', |
| 79 | ) |
| 80 | ); |
| 81 | |
| 82 | Settings_Builder::build_option( |
| 83 | array( |
| 84 | 'id' => 'method_invalid_setting', |
| 85 | 'type' => 'radio', |
| 86 | 'option_name' => 'wp_2fa_settings[method_invalid_setting]', |
| 87 | 'default' => WP2FA::get_wp2fa_general_setting( 'method_invalid_setting', true ), |
| 88 | 'options' => array( |
| 89 | 'login_block' => \esc_html__( 'Block the login', 'wp-2fa' ), |
| 90 | 'allow_login_without_method' => \esc_html__( 'Allow the login without 2FA', 'wp-2fa' ), |
| 91 | ), |
| 92 | ) |
| 93 | ); |
| 94 | ?> |
| 95 | </div> |
| 96 | </div> |
| 97 | |
| 98 | <div class="settings-card"> |
| 99 | <?php |
| 100 | |
| 101 | Settings_Builder::build_option( |
| 102 | array( |
| 103 | 'title' => \esc_html__( 'Disable 2FA code brute force protection', 'wp-2fa' ), |
| 104 | 'id' => 'general-settings-tab', |
| 105 | 'type' => 'section-title', |
| 106 | ) |
| 107 | ); |
| 108 | |
| 109 | Settings_Builder::build_option( |
| 110 | array( |
| 111 | 'text' => \wp_sprintf( |
| 112 | // translators: 1. Link to documentation, 2. Link to support. |
| 113 | \esc_html__( 'When using email or SMS 2FA, the plugin sends users a new one-time code each time they enter a wrong code at login. This acts as a form of brute-force protection. You can disable it using the setting below, although doing so is not recommended. %1$s', 'wp-2fa' ), |
| 114 | \wp_sprintf( '<a href="%s" target="_blank">%s</a>', 'https://melapress.com/support/kb/wp-2fa-plugin-getting-started/?#utm_source=plugin&utm_medium=wp2fa&utm_campaign=guide_getting_started_wp2fa', \esc_html__( 'Learn more', 'wp-2fa' ) ) |
| 115 | ), |
| 116 | 'class' => 'description-settings-card', |
| 117 | 'id' => 'general-settings-tab', |
| 118 | 'type' => 'description', |
| 119 | ) |
| 120 | ); |
| 121 | |
| 122 | ?> |
| 123 | |
| 124 | <div class="form-group settings-row"> |
| 125 | <?php |
| 126 | Settings_Builder::build_option( |
| 127 | array( |
| 128 | 'text' => \esc_html__( 'Disable brute force protection', 'wp-2fa' ), |
| 129 | 'id' => 'wp_2fa_settings[brute_force_disable]', |
| 130 | 'option_name' => 'wp_2fa_settings[brute_force_disable]', |
| 131 | 'type' => 'checkbox', |
| 132 | 'default' => WP2FA::get_wp2fa_general_setting( 'brute_force_disable', true ), |
| 133 | ) |
| 134 | ); |
| 135 | ?> |
| 136 | </div> |
| 137 | </div> |
| 138 | |
| 139 | <div class="settings-card"> |
| 140 | <?php |
| 141 | |
| 142 | Settings_Builder::build_option( |
| 143 | array( |
| 144 | 'title' => \esc_html__( 'Limit 2FA settings access', 'wp-2fa' ), |
| 145 | 'id' => 'general-settings-tab', |
| 146 | 'type' => 'section-title', |
| 147 | ) |
| 148 | ); |
| 149 | |
| 150 | Settings_Builder::build_option( |
| 151 | array( |
| 152 | 'text' => \wp_sprintf( |
| 153 | // translators: 1. Link to documentation, 2. Link to support. |
| 154 | \esc_html__( 'Use this setting to hide this plugin configuration area from all other admins.', 'wp-2fa' ), |
| 155 | ), |
| 156 | 'class' => 'description-settings-card', |
| 157 | 'id' => 'general-settings-tab', |
| 158 | 'type' => 'description', |
| 159 | ) |
| 160 | ); |
| 161 | |
| 162 | ?> |
| 163 | <div class="form-group settings-row"> |
| 164 | <?php |
| 165 | |
| 166 | // Settings_Builder::build_option( |
| 167 | // array( |
| 168 | // 'text' => \esc_html__( 'Limit access to 2FA settings', 'wp-2fa' ), |
| 169 | // 'id' => 'general-settings-tab', |
| 170 | // 'type' => 'settings-label', |
| 171 | // ) |
| 172 | // ); |
| 173 | |
| 174 | Settings_Builder::build_option( |
| 175 | array( |
| 176 | 'text' => \esc_html__( 'Hide settings from other administrators', 'wp-2fa' ), |
| 177 | 'id' => 'wp_2fa_settings[limit_access]', |
| 178 | 'option_name' => 'wp_2fa_settings[limit_access]', |
| 179 | 'type' => 'checkbox', |
| 180 | 'default' => WP2FA::get_wp2fa_general_setting( 'limit_access', true ), |
| 181 | ) |
| 182 | ); |
| 183 | |
| 184 | ?> |
| 185 | </div> |
| 186 | </div> |
| 187 | |
| 188 | <div class="settings-card"> |
| 189 | <?php |
| 190 | |
| 191 | Settings_Builder::build_option( |
| 192 | array( |
| 193 | 'title' => \esc_html__( 'Disable the REST API endpoints for 2FA', 'wp-2fa' ), |
| 194 | 'id' => 'general-settings-tab', |
| 195 | 'type' => 'section-title', |
| 196 | ) |
| 197 | ); |
| 198 | |
| 199 | Settings_Builder::build_option( |
| 200 | array( |
| 201 | 'text' => \esc_html__( 'The WP 2FA REST API endpoints are enabled by default. They are used for integrations and do not impact your website\'s performance, functionality, or security. If you prefer, you can disable these endpoints by using this setting.', 'wp-2fa' ), |
| 202 | 'class' => 'description-settings-card', |
| 203 | 'id' => 'general-settings-tab', |
| 204 | 'type' => 'description', |
| 205 | ) |
| 206 | ); |
| 207 | |
| 208 | ?> |
| 209 | <div class="form-group settings-row"> |
| 210 | <?php |
| 211 | |
| 212 | // Settings_Builder::build_option( |
| 213 | // array( |
| 214 | // 'text' => \esc_html__( 'Disable REST API endpoints', 'wp-2fa' ), |
| 215 | // 'id' => 'general-settings-tab', |
| 216 | // 'type' => 'settings-label', |
| 217 | // ) |
| 218 | // ); |
| 219 | |
| 220 | Settings_Builder::build_option( |
| 221 | array( |
| 222 | 'text' => \esc_html__( 'Disable the REST API endpoints', 'wp-2fa' ), |
| 223 | 'id' => 'disable_rest', |
| 224 | 'option_name' => 'wp_2fa_settings[disable_rest]', |
| 225 | 'type' => 'checkbox', |
| 226 | 'default' => Settings_Utils::string_to_bool( WP2FA::get_wp2fa_general_setting( 'disable_rest' ) ), |
| 227 | ) |
| 228 | ); |
| 229 | |
| 230 | ?> |
| 231 | </div> |
| 232 | </div> |
| 233 | |
| 234 | <div id="select_verification_method_wrap" class="settings-card<?php echo true === Settings_Utils::string_to_bool( WP2FA::get_wp2fa_general_setting( 'disable_rest' ) ) ? ' rest-section-disabled' : ''; ?>"> |
| 235 | <?php |
| 236 | |
| 237 | Settings_Builder::build_option( |
| 238 | array( |
| 239 | 'title' => \esc_html__( 'Select the 2FA verification mechanism', 'wp-2fa' ), |
| 240 | 'id' => 'general-settings-tab', |
| 241 | 'type' => 'section-title', |
| 242 | ) |
| 243 | ); |
| 244 | |
| 245 | Settings_Builder::build_option( |
| 246 | array( |
| 247 | 'text' => \esc_html__( 'Choose how WP 2FA verifies the 2FA by default. The native method works for most setups, but you can switch to REST API verification if needed. Only change this setting if you are experiencing issues with the default method.', 'wp-2fa' ), |
| 248 | 'class' => 'description-settings-card', |
| 249 | 'id' => 'general-settings-tab', |
| 250 | 'type' => 'description', |
| 251 | ) |
| 252 | ); |
| 253 | |
| 254 | ?> |
| 255 | <div class="form-group settings-row"> |
| 256 | <?php |
| 257 | |
| 258 | Settings_Builder::build_option( |
| 259 | array( |
| 260 | 'text' => \esc_html__( 'Default 2FA verification mechanism', 'wp-2fa' ), |
| 261 | 'id' => 'general-settings-tab', |
| 262 | 'type' => 'settings-label', |
| 263 | ) |
| 264 | ); |
| 265 | |
| 266 | Settings_Builder::build_option( |
| 267 | array( |
| 268 | 'id' => 'enable_rest', |
| 269 | 'type' => 'radio', |
| 270 | 'option_name' => 'wp_2fa_settings[enable_rest]', |
| 271 | // Bit complicated here - needs improvement, we need to keep the old value for backward compatibility, but we also need to convert it to a boolean for the checkbox above. For this to work, the value of the setting needs to be either 'enable_rest' or '', and not a boolean. This is because we are using the same setting for both the checkbox and the radio, and they need to have the same value. |
| 272 | 'default' => ( WP2FA::get_wp2fa_general_setting( 'enable_rest', true ) ? 'enable_rest' : '' ), |
| 273 | 'not_bool' => true, |
| 274 | 'options' => array( |
| 275 | '' => \esc_html__( 'Native', 'wp-2fa' ), |
| 276 | 'enable_rest' => \esc_html__( 'REST API', 'wp-2fa' ), |
| 277 | ), |
| 278 | ) |
| 279 | ); |
| 280 | |
| 281 | ?> |
| 282 | </div> |
| 283 | </div> |
| 284 | |
| 285 | <style> |
| 286 | #select_verification_method_wrap.rest-section-disabled { |
| 287 | opacity: 0.5; |
| 288 | pointer-events: none; |
| 289 | user-select: none; |
| 290 | } |
| 291 | .plugin-uninstall-card { |
| 292 | border: 2px dashed #e07b39 !important; |
| 293 | border-radius: 6px; |
| 294 | padding: 20px 24px; |
| 295 | margin-top: 24px; |
| 296 | background: #fff; |
| 297 | border-bottom: 2px dashed #e07b39 !important; |
| 298 | } |
| 299 | </style> |
| 300 | |
| 301 | <script> |
| 302 | document.addEventListener( 'DOMContentLoaded', function () { |
| 303 | var disableRestCheckbox = document.getElementById( 'disable_rest' ); |
| 304 | var verificationWrap = document.getElementById( 'select_verification_method_wrap' ); |
| 305 | |
| 306 | if ( ! disableRestCheckbox || ! verificationWrap ) { |
| 307 | return; |
| 308 | } |
| 309 | |
| 310 | function toggleVerificationSection() { |
| 311 | if ( disableRestCheckbox.checked ) { |
| 312 | verificationWrap.classList.add( 'rest-section-disabled' ); |
| 313 | } else { |
| 314 | verificationWrap.classList.remove( 'rest-section-disabled' ); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | disableRestCheckbox.addEventListener( 'change', toggleVerificationSection ); |
| 319 | } ); |
| 320 | </script> |
| 321 | |
| 322 | <div class="settings-card plugin-uninstall-card"> |
| 323 | <?php |
| 324 | |
| 325 | Settings_Builder::build_option( |
| 326 | array( |
| 327 | 'title' => \esc_html__( 'Plugin uninstall options', 'wp-2fa' ), |
| 328 | 'id' => 'general-settings-tab', |
| 329 | 'type' => 'section-title', |
| 330 | ) |
| 331 | ); |
| 332 | |
| 333 | Settings_Builder::build_option( |
| 334 | array( |
| 335 | 'text' => \esc_html__( 'The plugin saves its settings in the WordPress database. By default the plugin settings are kept in the database so if it is installed again, you do not have to reconfigure the plugin. Enable this setting to delete the plugin settings from the database upon uninstall.', 'wp-2fa' ), |
| 336 | 'class' => 'description-settings-card', |
| 337 | 'id' => 'general-settings-tab', |
| 338 | 'type' => 'description', |
| 339 | ) |
| 340 | ); |
| 341 | |
| 342 | ?> |
| 343 | <div class="form-group settings-row"> |
| 344 | <?php |
| 345 | |
| 346 | Settings_Builder::build_option( |
| 347 | array( |
| 348 | 'text' => \esc_html__( 'Delete data', 'wp-2fa' ), |
| 349 | 'id' => 'general-settings-tab', |
| 350 | 'type' => 'settings-label', |
| 351 | ) |
| 352 | ); |
| 353 | |
| 354 | Settings_Builder::build_option( |
| 355 | array( |
| 356 | 'text' => \esc_html__( 'Delete all plugin data upon uninstall', 'wp-2fa' ), |
| 357 | 'id' => 'delete_data_upon_uninstall', |
| 358 | 'option_name' => 'wp_2fa_settings[delete_data_upon_uninstall]', |
| 359 | 'type' => 'checkbox', |
| 360 | 'default' => WP2FA::get_wp2fa_general_setting( 'delete_data_upon_uninstall' ), |
| 361 | ) |
| 362 | ); |
| 363 | |
| 364 | ?> |
| 365 | </div> |
| 366 | </div> |
| 367 | </div> |
| 368 |