FirstTimeWizardSteps.php
501 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP2FA\Admin\Views; |
| 4 | |
| 5 | use WP2FA\WP2FA; |
| 6 | |
| 7 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly |
| 8 | |
| 9 | /** |
| 10 | * WP2FA First Wizard Settings view controller |
| 11 | * |
| 12 | * @since 1.7 |
| 13 | */ |
| 14 | class FirstTimeWizardSteps { |
| 15 | |
| 16 | /** |
| 17 | * Select method step |
| 18 | * |
| 19 | * @since 1.7.0 |
| 20 | * |
| 21 | * @param boolean $setupWizard |
| 22 | * |
| 23 | * @return void |
| 24 | */ |
| 25 | public static function selectMethod( $setupWizard = false ) { |
| 26 | ?> |
| 27 | <h3><?php esc_html_e( 'Which two-factor authentication methods can your users use?', 'wp-2fa' ); ?></h3> |
| 28 | <p class="description"> |
| 29 | <?php esc_html_e( 'When you disable one of the below 2FA methods none of your users can use it.', 'wp-2fa' ); ?> |
| 30 | </p> |
| 31 | <?php |
| 32 | if ( ! $setupWizard ) { |
| 33 | ?> |
| 34 | <table class="form-table"> |
| 35 | <tbody> |
| 36 | <tr> |
| 37 | <th><label for="2fa-method"><?php esc_html_e( 'Select the methods', 'wp-2fa' ); ?></label></th> |
| 38 | <td> |
| 39 | <?php } ?> |
| 40 | <fieldset id="2fa-method-select"> |
| 41 | <div><em><?php esc_html_e( 'Primary 2FA methods:', 'wp-2fa')?></em></div> |
| 42 | <br> |
| 43 | <label for="totp"> |
| 44 | <input type="checkbox" id="totp" name="wp_2fa_settings[enable_totp]" value="enable_totp" |
| 45 | <?php checked( 'enable_totp', WP2FA::get_wp2fa_setting( 'enable_totp' ), true ); ?> |
| 46 | > |
| 47 | <?php esc_html_e( 'One-time code via 2FA App (TOTP) - ', 'wp-2fa' ); ?><a href="https://www.wpwhitesecurity.com/support/kb/configuring-2fa-apps/?utm_source=plugin&utm_medium=referral&utm_campaign=WP2FA&utm_content=settings+pages" target="_blank" rel=noopener><?php esc_html_e( 'complete list of supported 2FA apps.', 'wp-2fa' ); ?></a> |
| 48 | </label> |
| 49 | <?php |
| 50 | if ( $setupWizard ) { |
| 51 | echo '<p class="description">'; |
| 52 | printf( |
| 53 | /* translators: link to the knowledge base website */ |
| 54 | esc_html__( 'Refer to the %s for more information on how to setup these apps and which apps are supported.', 'wp-2fa' ), |
| 55 | '<a href="https://www.wpwhitesecurity.com/support/kb/configuring-2fa-apps/" target="_blank">' . esc_html__( '2FA apps article on our knowledge base', 'wp-2fa' ) . '</a>' |
| 56 | ); |
| 57 | echo '</p>'; |
| 58 | } |
| 59 | ?> |
| 60 | <br/> |
| 61 | <label for="hotp"> |
| 62 | <input type="checkbox" id="hotp" name="wp_2fa_settings[enable_email]" value="enable_email" |
| 63 | <?php checked( WP2FA::get_wp2fa_setting( 'enable_email' ), 'enable_email' ); ?> |
| 64 | > |
| 65 | <?php esc_html_e( 'One-time code via email (HOTP)', 'wp-2fa' ); ?> |
| 66 | <?php |
| 67 | if ( $setupWizard ) { |
| 68 | echo '<p class="description">'; |
| 69 | } else { |
| 70 | echo ' - '; |
| 71 | } |
| 72 | printf( '%1$s <a href="https://wordpress.org/plugins/wp-mail-smtp/" target="_blank">%2$s</a>.', esc_html__( 'Email reliability and deliverability is important when using this method, otherwise you might have problems logging in. To ensure emails are always delivered we recommend using the free plugin', 'wp-2fa' ), esc_html__( 'WP Mail SMTP', 'wp-2fa' ) ); |
| 73 | if ( $setupWizard ) { |
| 74 | echo '</p>'; |
| 75 | } |
| 76 | ?> |
| 77 | </label> |
| 78 | <br /> |
| 79 | <?php |
| 80 | $class = ''; |
| 81 | |
| 82 | if ( false === WP2FA::get_wp2fa_setting( 'enable_totp' ) && false === WP2FA::get_wp2fa_setting( 'enable_email' ) ) { |
| 83 | $class = ' class="disabled"'; |
| 84 | } |
| 85 | ?> |
| 86 | <div><em><?php esc_html_e( 'Secondary 2FA methods:', 'wp-2fa')?></em></div> |
| 87 | <br> |
| 88 | <label for="backup-codes" <?php echo $class; ?>> |
| 89 | <input <?php echo $class; ?> type="checkbox" id="backup-codes" name="wp_2fa_settings[backup_codes_enabled]" value="yes" |
| 90 | <?php checked( WP2FA::get_wp2fa_setting( 'backup_codes_enabled' ), 'yes' ); ?> |
| 91 | > |
| 92 | <?php |
| 93 | esc_html_e( 'Backup codes', 'wp-2fa' ); |
| 94 | if ( $setupWizard ) { |
| 95 | echo '<p class="description">Note: '; |
| 96 | } else { |
| 97 | echo ' - '; |
| 98 | } |
| 99 | esc_html_e( 'Backup codes are a secondary method which you can use to log in to the website in case the primary 2FA method is unavailable. Therefore they can\'t be enabled and used as a primary method.', 'wp-2fa' ); |
| 100 | if ( $setupWizard ) { |
| 101 | echo '</p>'; |
| 102 | } |
| 103 | ?> |
| 104 | </label> |
| 105 | <br /> |
| 106 | </fieldset> |
| 107 | <?php |
| 108 | if ( ! $setupWizard ) { |
| 109 | ?> |
| 110 | </td> |
| 111 | </tr> |
| 112 | </tbody> |
| 113 | </table> |
| 114 | <?php } ?> |
| 115 | <?php |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Enforcement policy step |
| 120 | * |
| 121 | * @since 1.7.0 |
| 122 | * |
| 123 | * @param boolean $setupWizard |
| 124 | * |
| 125 | * @return void |
| 126 | */ |
| 127 | public static function enforcementPolicy( $setupWizard = false ) { |
| 128 | ?> |
| 129 | <h3><?php esc_html_e( 'Do you want to enforce 2FA for some, or all the users? ', 'wp-2fa' ); ?></h3> |
| 130 | <p class="description"> |
| 131 | <?php esc_html_e( 'When you enforce 2FA the users will be prompted to configure 2FA the next time they login. Users have a grace period for configuring 2FA. You can configure the grace period and also exclude user(s) or role(s) in this settings page. ', 'wp-2fa' ); ?> <a href="https://www.wpwhitesecurity.com/support/kb/configure-2fa-policies-enforce/?utm_source=plugin&utm_medium=referral&utm_campaign=WP2FA&utm_content=settings+pages" target="_blank" rel=noopener><?php esc_html_e( 'Learn more.', 'wp-2fa' ); ?></a> |
| 132 | </p> |
| 133 | <?php |
| 134 | if ( ! $setupWizard ) { |
| 135 | ?> |
| 136 | <table class="form-table"> |
| 137 | <tbody> |
| 138 | <tr> |
| 139 | <th><label for="enforcement-policy"><?php esc_html_e( 'Enforce 2FA on', 'wp-2fa' ); ?></label></th> |
| 140 | <td> |
| 141 | <?php } ?> |
| 142 | <fieldset class="contains-hidden-inputs"> |
| 143 | <label for="all-users"> |
| 144 | <input type="radio" name="wp_2fa_settings[enforcement-policy]" id="all-users" value="all-users" |
| 145 | <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'all-users' ); ?> |
| 146 | > |
| 147 | <span><?php esc_html_e( 'All users', 'wp-2fa' ); ?></span> |
| 148 | </label> |
| 149 | <br/> |
| 150 | |
| 151 | <?php if ( WP2FA::is_this_multisite() ) : ?> |
| 152 | <label for="superadmins-only"> |
| 153 | <input type="radio" name="wp_2fa_settings[enforcement-policy]" id="superadmins-only" value="superadmins-only" |
| 154 | <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'superadmins-only' ); ?> /> |
| 155 | <span><?php esc_html_e( 'Only super admins', 'wp-2fa' ); ?></span> |
| 156 | </label> |
| 157 | <br/> |
| 158 | <label for="superadmins-siteadmins-only"> |
| 159 | <input type="radio" name="wp_2fa_settings[enforcement-policy]" id="superadmins-siteadmins-only" value="superadmins-siteadmins-only" |
| 160 | <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'superadmins-siteadmins-only' ); ?> /> |
| 161 | <span><?php esc_html_e( 'Only super admins and site admins', 'wp-2fa' ); ?></span> |
| 162 | </label> |
| 163 | <br/> |
| 164 | <?php endif; ?> |
| 165 | |
| 166 | <label for="certain-roles-only"> |
| 167 | <?php $checked = in_array( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), [ 'certain-roles-only', 'certain-users-only' ] ); ?> |
| 168 | <input type="radio" name="wp_2fa_settings[enforcement-policy]" id="certain-roles-only" value="certain-roles-only" |
| 169 | <?php ( $setupWizard ) ? checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'certain-roles-only' ) : checked( $checked ); ?> |
| 170 | data-unhide-when-checked=".certain-roles-only-inputs, .certain-users-only-inputs"> |
| 171 | <span><?php esc_html_e( 'Only for specific users and roles', 'wp-2fa' ); ?></span> |
| 172 | </label> |
| 173 | <fieldset class="hidden certain-users-only-inputs"> |
| 174 | <div> |
| 175 | <p> |
| 176 | <label for="enforced_users-multi-select"><?php esc_html_e( 'Users :', 'wp-2fa' ); ?></label> <select multiple="multiple" id="enforced_users-multi-select" name="wp_2fa_settings[enforced_users][]" style=" display:none;width:<?php echo ( $setupWizard ) ? '100' : '50'; ?>%"> |
| 177 | <?php |
| 178 | $excludedUsers = WP2FA::get_wp2fa_setting( 'enforced_users' ); |
| 179 | foreach ( $excludedUsers as $user ) { |
| 180 | ?> |
| 181 | <option selected="selected" value="<?php echo $user; ?>"><?php echo $user; ?></option> |
| 182 | <?php |
| 183 | } |
| 184 | ?> |
| 185 | </select> |
| 186 | </p> |
| 187 | </div> |
| 188 | <br/> |
| 189 | </fieldset> |
| 190 | <fieldset class="hidden certain-roles-only-inputs"> |
| 191 | <div> |
| 192 | <p style="margin-top: 0;"> |
| 193 | <label for="enforced-roles-multi-select"><?php esc_html_e( 'Roles :', 'wp-2fa' ); ?></label> |
| 194 | <select multiple="multiple" id="enforced-roles-multi-select" name="wp_2fa_settings[enforced_roles][]" style=" display:none;width:<?php echo ( $setupWizard ) ? '100' : '50'; ?>%"> |
| 195 | <?php |
| 196 | $allRoles = \WP2FA\WP2FA::wp_2fa_get_roles(); |
| 197 | $enforcedRoles = WP2FA::get_wp2fa_setting( 'enforced_roles' ); |
| 198 | foreach ( $allRoles as $role => $roleName ) { |
| 199 | $selected = ''; |
| 200 | if ( in_array( $role, $enforcedRoles ) ) { |
| 201 | $selected = 'selected="selected"'; |
| 202 | } |
| 203 | ?> |
| 204 | <option <?php echo $selected; ?> value="<?php echo strtolower( $role ); ?>"><?php echo $roleName; ?></option> |
| 205 | <?php |
| 206 | } |
| 207 | ?> |
| 208 | </select> |
| 209 | </p> |
| 210 | </div> |
| 211 | <?php if ( WP2FA::is_this_multisite() ) { ?> |
| 212 | <div style="margin-left: 70px"> |
| 213 | <input type="checkbox" name="wp_2fa_settings[superadmins-role-add]" id="superadmins-role-add" value="yes" |
| 214 | <?php checked( WP2FA::get_wp2fa_setting( 'superadmins-role-add' ), 'yes' ); ?> /> |
| 215 | <label for="superadmins-role-add"><?php esc_html_e( 'Also enforce 2FA on network users with super admin privileges', 'wp-2fa' ); ?></label> |
| 216 | </div> |
| 217 | <?php } ?> |
| 218 | </fieldset> |
| 219 | <br/> |
| 220 | <?php if ( WP2FA::is_this_multisite() ) { ?> |
| 221 | <div> |
| 222 | <label for="enforce-on-multisite"> |
| 223 | <input type="radio" name="wp_2fa_settings[enforcement-policy]" id="enforce-on-multisite" value="enforce-on-multisite" |
| 224 | <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'enforce-on-multisite' ); ?> |
| 225 | data-unhide-when-checked=".all-sites"> |
| 226 | <span><?php esc_html_e( 'These sub-sites', 'wp-2fa' ); ?></span> |
| 227 | </label> |
| 228 | <fieldset class="hidden all-sites"> |
| 229 | <p> |
| 230 | <label for="slim-multi-select"><?php esc_html_e( 'Sites :', 'wp-2fa' ); ?></label> <select multiple="multiple" id="slim-multi-select" name="wp_2fa_settings[included_sites][]" style="display:none; width:<?php echo ( $setupWizard ) ? '100' : '50'; ?>%"> |
| 231 | <?php |
| 232 | $selectedSites = WP2FA::get_wp2fa_setting( 'included_sites' ); |
| 233 | foreach ( WP2FA::getMultiSites() as $site ) { |
| 234 | $args = [ |
| 235 | 'blog_id' => $site->blog_id, |
| 236 | ]; |
| 237 | |
| 238 | $currentBlogDetails = get_blog_details( $args ); |
| 239 | $selected = ''; |
| 240 | if ( in_array( $site->blog_id, $selectedSites ) ) { |
| 241 | $selected = 'selected="selected"'; |
| 242 | } |
| 243 | ?> |
| 244 | <option <?php echo $selected; ?> value="<?php echo $site->blog_id; ?>"><?php echo $currentBlogDetails->blogname; ?></option> |
| 245 | <?php |
| 246 | } |
| 247 | ?> |
| 248 | </select> |
| 249 | </p> |
| 250 | </fieldset> |
| 251 | </div> |
| 252 | <?php } ?> |
| 253 | <div> |
| 254 | <label for="do-not-enforce"> |
| 255 | <input type="radio" name="wp_2fa_settings[enforcement-policy]" id="do-not-enforce" value="do-not-enforce" |
| 256 | <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'do-not-enforce' ); ?> |
| 257 | > |
| 258 | <span><?php esc_html_e( 'Do not enforce on any users', 'wp-2fa' ); ?></span> |
| 259 | </label> |
| 260 | </div> |
| 261 | <br/> |
| 262 | </fieldset> |
| 263 | <?php |
| 264 | if ( ! $setupWizard ) { |
| 265 | ?> |
| 266 | </td> |
| 267 | </tr> |
| 268 | </tbody> |
| 269 | </table> |
| 270 | <?php |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Exclude users and groups |
| 276 | * |
| 277 | * @since 1.7.0 |
| 278 | * |
| 279 | * @param boolean $setupWizard |
| 280 | * |
| 281 | * @return void |
| 282 | */ |
| 283 | public static function excludeUsers( $setupWizard = false ) { |
| 284 | ?> |
| 285 | <h3><?php esc_html_e( 'Do you want to exclude any users or roles from 2FA? ', 'wp-2fa' ); ?></h3> |
| 286 | <p class="description"> |
| 287 | <?php esc_html_e( 'If you are enforcing 2FA on all users but for some reason you would like to exclude individual user(s) or users with a specific role, you can exclude them below', 'wp-2fa' ); ?> |
| 288 | </p> |
| 289 | <?php |
| 290 | if ( ! $setupWizard ) { |
| 291 | ?> |
| 292 | <table class="form-table"> |
| 293 | <tbody> |
| 294 | <tr> |
| 295 | <th><label for="enforcement-policy"><?php esc_html_e( 'Exclude the following users', 'wp-2fa' ); ?></label></th> |
| 296 | <td> |
| 297 | <?php } else { ?> |
| 298 | <label for="excluded-users-multi-select"><?php esc_html_e( 'Exclude the following users', 'wp-2fa' ); ?> |
| 299 | <?php } ?> |
| 300 | <fieldset> |
| 301 | <div> |
| 302 | <select multiple="multiple" id="excluded-users-multi-select" name="wp_2fa_settings[excluded_users][]" style=" display:none;width:<?php echo ( $setupWizard ) ? '100' : '50'; ?>%"> |
| 303 | <?php |
| 304 | $excludedUsers = WP2FA::get_wp2fa_setting( 'excluded_users' ); |
| 305 | foreach ( $excludedUsers as $user ) { |
| 306 | ?> |
| 307 | <option selected="selected" value="<?php echo $user; ?>"><?php echo $user; ?></option> |
| 308 | <?php |
| 309 | } |
| 310 | ?> |
| 311 | </select> |
| 312 | </div> |
| 313 | <?php |
| 314 | if ( ! $setupWizard ) { |
| 315 | ?> |
| 316 | |
| 317 | </td> |
| 318 | </tr> |
| 319 | <tr> |
| 320 | <th><label for="enforcement-policy"><?php esc_html_e( 'Exclude the following roles', 'wp-2fa' ); ?></label></th> |
| 321 | <td> |
| 322 | <p> |
| 323 | <?php } else { ?> |
| 324 | <br> |
| 325 | <label for="enforcement-policy"><?php esc_html_e( 'Exclude the following roles', 'wp-2fa' ); ?></label> |
| 326 | <?php } ?> |
| 327 | <select multiple="multiple" id="excluded-roles-multi-select" name="wp_2fa_settings[excluded_roles][]" style=" display:none;width:<?php echo ( $setupWizard ) ? '100' : '50'; ?>%"> |
| 328 | <?php |
| 329 | $allRoles = \WP2FA\WP2FA::wp_2fa_get_roles(); |
| 330 | $excludedRoles = WP2FA::get_wp2fa_setting( 'excluded_roles' ); |
| 331 | foreach ( $allRoles as $role => $roleName ) { |
| 332 | $selected = ''; |
| 333 | if ( in_array( strtolower( $role ), $excludedRoles ) ) { |
| 334 | $selected = 'selected="selected"'; |
| 335 | } |
| 336 | ?> |
| 337 | <option <?php echo $selected; ?> value="<?php echo strtolower( $role ); ?>"><?php echo $roleName; ?></option> |
| 338 | <?php |
| 339 | } |
| 340 | ?> |
| 341 | </select> |
| 342 | <br> |
| 343 | <?php if ( WP2FA::is_this_multisite() ) { ?> |
| 344 | <div style="margin-left: 70px"> |
| 345 | <input type="checkbox" name="wp_2fa_settings[superadmins-role-exclude]" id="superadmins-role-exclude" value="yes" |
| 346 | <?php checked( WP2FA::get_wp2fa_setting( 'superadmins-role-exclude' ), 'yes' ); ?> /> |
| 347 | <label for="superadmins-role-exclude"><?php esc_html_e( 'Also exclude users with super admin privilege', 'wp-2fa' ); ?></label> |
| 348 | </div> |
| 349 | <?php } ?> |
| 350 | </fieldset> |
| 351 | <?php |
| 352 | if ( ! $setupWizard ) { |
| 353 | ?> |
| 354 | </td> |
| 355 | </tr> |
| 356 | </tbody> |
| 357 | </table> |
| 358 | <?php } ?> |
| 359 | <?php |
| 360 | } |
| 361 | |
| 362 | /** |
| 363 | * Which network sites to exclude (for multisite instal) |
| 364 | * |
| 365 | * @since 1.7.0 |
| 366 | * |
| 367 | * @param boolean $setupWizard |
| 368 | * |
| 369 | * @return void |
| 370 | */ |
| 371 | public static function excludedNetworkSites( $setupWizard = false ) { |
| 372 | ?> |
| 373 | <h3><?php esc_html_e( 'Do you want to exclude all the users of a site from 2FA? ', 'wp-2fa' ); ?></h3> |
| 374 | <p class="description"> |
| 375 | <?php esc_html_e( 'If you are enforcing 2FA on all users but for some reason you do not want to enforce it on a specific sub site, specify the sub site name below:', 'wp-2fa' ); ?> |
| 376 | </p> |
| 377 | <?php |
| 378 | if ( ! $setupWizard ) { |
| 379 | ?> |
| 380 | <table class="form-table"> |
| 381 | <tbody> |
| 382 | <tr> |
| 383 | <th><label for="excluded-sites-multi-select"><?php esc_html_e( 'Exclude the following sites', 'wp-2fa' ); ?></label></th> |
| 384 | <td> |
| 385 | <?php } ?> |
| 386 | <fieldset> |
| 387 | <?php |
| 388 | if ( $setupWizard ) { |
| 389 | ?> |
| 390 | |
| 391 | <div class="option-pill"> |
| 392 | <label for="excluded_sites_search"><?php esc_html_e( 'Exclude the following sites', 'wp-2fa' ); ?> |
| 393 | <?php } ?> |
| 394 | <select multiple="multiple" id="excluded-sites-multi-select" name="wp_2fa_settings[excluded_sites][]" style=" display:none;width:<?php echo ( $setupWizard ) ? '100' : '50'; ?>%"> |
| 395 | <?php |
| 396 | $excludedSites = WP2FA::get_wp2fa_setting( 'excluded_sites' ); |
| 397 | if ( ! empty( $excludedSites ) ) { |
| 398 | foreach ( $excludedSites as $siteId ) { |
| 399 | $site = get_blog_details( $siteId )->blogname; |
| 400 | ?> |
| 401 | <option selected="selected" value="<?php echo esc_html( $siteId ); ?>"><?php echo $site; ?></option> |
| 402 | <?php |
| 403 | } |
| 404 | } |
| 405 | ?> |
| 406 | </select> |
| 407 | <?php |
| 408 | if ( $setupWizard ) { |
| 409 | ?> |
| 410 | </label> |
| 411 | </div> |
| 412 | <?php } ?> |
| 413 | </fieldset> |
| 414 | <?php |
| 415 | if ( ! $setupWizard ) { |
| 416 | ?> |
| 417 | </td> |
| 418 | </tr> |
| 419 | </tbody> |
| 420 | </table> |
| 421 | <?php } ?> |
| 422 | <?php |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * Set the grace period |
| 427 | * |
| 428 | * @since 1.7.0 |
| 429 | * |
| 430 | * @param boolean $setupWizard |
| 431 | * |
| 432 | * @return void |
| 433 | */ |
| 434 | public static function gracePeriod( $setupWizard = false ) { |
| 435 | $gracePeriod = (int) WP2FA::get_wp2fa_setting( 'grace-period' ); |
| 436 | $testing = apply_filters( 'wp_2fa_allow_grace_period_in_seconds', false ); |
| 437 | if ( $testing ) { |
| 438 | $graceMax = 600; |
| 439 | } else { |
| 440 | $graceMax = 10; |
| 441 | } get_terms() |
| 442 | ?> |
| 443 | <fieldset class="contains-hidden-inputs"> |
| 444 | <label for="no-grace-period"> |
| 445 | <input type="radio" name="wp_2fa_settings[grace-policy]" id="no-grace-period" value="no-grace-period" |
| 446 | <?php checked( WP2FA::get_wp2fa_setting( 'grace-policy' ), 'no-grace-period' ); ?> |
| 447 | > |
| 448 | <span><?php esc_html_e( 'Users have to configure 2FA straight away.', 'wp-2fa' ); ?></span> |
| 449 | </label> |
| 450 | |
| 451 | <br/> |
| 452 | <label for="use-grace-period"> |
| 453 | <input type="radio" name="wp_2fa_settings[grace-policy]" id="use-grace-period" value="use-grace-period" |
| 454 | <?php checked( WP2FA::get_wp2fa_setting( 'grace-policy' ), 'use-grace-period' ); ?> |
| 455 | data-unhide-when-checked=".grace-period-inputs"> |
| 456 | <span><?php esc_html_e( 'Give users a grace period to configure 2FA', 'wp-2fa' ); ?></span> |
| 457 | </label> |
| 458 | <fieldset class="hidden grace-period-inputs"> |
| 459 | <br/> |
| 460 | <input type="number" id="grace-period" name="wp_2fa_settings[grace-period]" value="<?php echo esc_attr( $gracePeriod ); ?>" min="1" max="<?php echo esc_attr( $graceMax ); ?>"> |
| 461 | <label class="radio-inline"> |
| 462 | <input class="js-nested" type="radio" name="wp_2fa_settings[grace-period-denominator]" value="hours" |
| 463 | <?php checked( WP2FA::get_wp2fa_setting( 'grace-period-denominator' ), 'hours' ); ?> |
| 464 | > |
| 465 | <?php esc_html_e( 'Hours', 'wp-2fa' ); ?> |
| 466 | </label> |
| 467 | <label class="radio-inline"> |
| 468 | <input class="js-nested" type="radio" name="wp_2fa_settings[grace-period-denominator]" value="days" |
| 469 | <?php checked( WP2FA::get_wp2fa_setting( 'grace-period-denominator' ), 'days' ); ?> |
| 470 | > |
| 471 | <?php esc_html_e( 'Days', 'wp-2fa' ); ?> |
| 472 | </label> |
| 473 | <?php |
| 474 | $testing = apply_filters( 'wp_2fa_allow_grace_period_in_seconds', false ); |
| 475 | if ( $testing ) { |
| 476 | ?> |
| 477 | <label class="radio-inline"> |
| 478 | <input class="js-nested" type="radio" name="wp_2fa_settings[grace-period-denominator]" value="seconds" |
| 479 | <?php checked( WP2FA::get_wp2fa_setting( 'grace-period-denominator' ), 'seconds' ); ?> |
| 480 | > |
| 481 | <?php esc_html_e( 'Seconds', 'wp-2fa' ); ?> |
| 482 | </label> |
| 483 | <?php |
| 484 | } |
| 485 | |
| 486 | if ( $setupWizard ) { |
| 487 | $user = wp_get_current_user(); |
| 488 | $lastUserToUpdateSettings = $user->ID; |
| 489 | |
| 490 | ?> |
| 491 | <input type="hidden" id="2fa_main_user" name="wp_2fa_settings[2fa_settings_last_updated_by]" value="<?php echo esc_attr( $lastUserToUpdateSettings ); ?>"> |
| 492 | <?php } else { ?> |
| 493 | <p><?php esc_html_e( 'Note: If users do not configure it within the configured stipulated time, their account will be locked and have to be unlocked manually.', 'wp-2fa' ); ?></p> |
| 494 | <?php } ?> |
| 495 | </fieldset> |
| 496 | <br/> |
| 497 | </fieldset> |
| 498 | <?php |
| 499 | } |
| 500 | } |
| 501 |