PluginProbe ʕ •ᴥ•ʔ
WP 2FA – Two-factor authentication for WordPress / 2.0.0
WP 2FA – Two-factor authentication for WordPress v2.0.0
4.0.0 1.7.1 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.8.0 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0 3.0.1 3.1.0 3.1.1 3.1.1.2 trunk 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.7.0
wp-2fa / includes / classes / Admin / Views / FirstTimeWizardSteps.php
wp-2fa / includes / classes / Admin / Views Last commit date
FirstTimeWizardSteps.php 4 years ago WizardSteps.php 4 years ago class-settings-page-render.php 4 years ago
FirstTimeWizardSteps.php
577 lines
1 <?php
2
3 namespace WP2FA\Admin\Views;
4
5 use WP2FA\WP2FA;
6 use WP2FA\Admin\Controllers\Settings;
7
8 defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
9
10 /**
11 * WP2FA First Wizard Settings view controller
12 *
13 * @since 1.7
14 */
15 class FirstTimeWizardSteps {
16
17 /**
18 * Select method step
19 *
20 * @since 1.7.0
21 *
22 * @param boolean $setup_wizard - Boolean - is that first time wizard setup or settings page call.
23 *
24 * @return void
25 */
26 public static function select_method( $setup_wizard = false ) {
27
28 ob_start();
29 ?>
30 <h3><?php esc_html_e( 'Which two-factor authentication methods can your users use?', 'wp-2fa' ); ?></h3>
31 <p class="description">
32 <?php esc_html_e( 'When you disable one of the below 2FA methods none of your users can use it.', 'wp-2fa' ); ?>
33 </p>
34 <?php
35 $data_role = 'data-role="global"';
36 if ( ! $setup_wizard ) {
37 ?>
38 <table class="form-table">
39 <tbody>
40 <tr>
41 <th colspan="2"><?php esc_html_e( 'Which of the below 2FA methods can users use?', 'wp-2fa' ); ?></th>
42 </tr>
43 <tr>
44 <th><label for="2fa-method"><?php esc_html_e( 'Select the methods', 'wp-2fa' ); ?></label></th>
45 <td>
46 <?php } ?>
47 <fieldset id="2fa-method-select" class="2fa-method-select">
48 <div class="method-title"><em><?php esc_html_e( 'Primary 2FA methods:', 'wp-2fa' ); ?></em></div>
49 <br>
50 <label for="totp">
51 <input type="checkbox" id="totp" name="wp_2fa_policy[enable_totp]" value="enable_totp"
52 <?php echo $data_role; // @codingStandardsIgnoreLine - escaped in our code ?>
53 <?php checked( 'enable_totp', WP2FA::get_wp2fa_setting( 'enable_totp' ), true ); ?>
54 >
55 <?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>
56 </label>
57 <?php
58 if ( $setup_wizard ) {
59 echo '<p class="description">';
60 printf(
61 /* translators: link to the knowledge base website */
62 esc_html__( 'Refer to the %s for more information on how to setup these apps and which apps are supported.', 'wp-2fa' ),
63 '<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>'
64 );
65 echo '</p>';
66 }
67 ?>
68 <?php
69 \do_action( 'wp_2fa_after_totp_setup', $setup_wizard, $data_role, null );
70 ?>
71 <br/>
72 <label for="hotp">
73 <input type="checkbox" id="hotp" name="wp_2fa_policy[enable_email]" value="enable_email"
74 <?php echo $data_role; // @codingStandardsIgnoreLine - escaped in our code ?>
75 <?php checked( WP2FA::get_wp2fa_setting( 'enable_email' ), 'enable_email' ); ?>
76 >
77 <?php esc_html_e( 'One-time code via email (HOTP)', 'wp-2fa' ); ?>
78 <?php
79 if ( $setup_wizard ) {
80 echo '<p class="description">';
81 } else {
82 echo ' - ';
83 }
84 echo WP2FA::print_email_deliverability_message(); // @codingStandardsIgnoreLine
85 if ( $setup_wizard ) {
86 echo '</p>';
87 }
88 ?>
89 <?php
90 ?>
91 </label>
92 <?php if ( ! $setup_wizard ) { ?>
93 <div class="use-different-hotp-mail<?php echo \esc_attr( ( false === WP2FA::get_wp2fa_setting( 'enable_email' ) ? ' disabled' : '' ) ); ?>">
94 <p class="description" style="margin-bottom: 5px; font-style: normal;">
95 <?php esc_html_e( 'Allow user to specify the email address of choice', 'wp-2fa' ); ?>
96 </p>
97 <fieldset class="email-hotp-options">
98 <?php
99 $options = array(
100 'yes' => array(
101 'label' => esc_html__( 'Yes', 'wp-2fa' ),
102 'value' => 'specify-email_hotp',
103 ),
104 'no' => array(
105 'label' => esc_html__( 'No', 'wp-2fa' ),
106 'value' => '',
107 ),
108 );
109
110 foreach ( $options as $option_key => $option_settings ) {
111 ?>
112 <label for="specify-email_hotp-<?php echo $option_key; ?>">
113 <input type="radio" name="wp_2fa_policy[specify-email_hotp]" id="specify-email_hotp-<?php echo $option_key; ?>" value="<?php echo $option_settings['value']; ?>" class="js-nested"
114
115 <?php checked( Settings::get_role_or_default_setting( 'specify-email_hotp', null ), $option_settings['value'] ); ?>
116 >
117 <span><?php echo $option_settings['label']; // @codingStandardsIgnoreLine - already escaped ?></span>
118 </label>
119 <?php
120 }
121 ?>
122 </fieldset>
123 </div>
124 <?php } ?>
125 <br />
126 <?php
127 if ( ! $setup_wizard ) {
128 $class = '';
129
130 if ( '' === trim( Settings::get_role_or_default_setting( 'enable_totp', null, null, true ) ) && '' === trim( Settings::get_role_or_default_setting( 'enable_email', null, null, true ) ) && '' === trim( Settings::get_role_or_default_setting( 'enable_oob_email', null, null, true ) ) ) {
131 $class = ' class="disabled"';
132 }
133 ?>
134 <div class="method-title"><em><?php esc_html_e( 'Secondary 2FA methods:', 'wp-2fa' ); ?></em></div>
135 <br>
136 <label for="backup-codes" <?php echo $class; // @codingStandardsIgnoreLine - escaped in our code ?>>
137 <input <?php echo $class; // @codingStandardsIgnoreLine - escaped in our code ?> type="checkbox" id="backup-codes" name="wp_2fa_policy[backup_codes_enabled]"
138 <?php echo $data_role; // @codingStandardsIgnoreLine - escaped in our code ?>
139 value="yes"
140 <?php checked( WP2FA::get_wp2fa_setting( 'backup_codes_enabled' ), 'yes' ); ?>
141 >
142 <?php
143 esc_html_e( 'Backup codes', 'wp-2fa' );
144 if ( $setup_wizard ) {
145 echo '<p class="description">Note: ';
146 } else {
147 echo ' - ';
148 }
149 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' );
150 if ( $setup_wizard ) {
151 echo '</p>';
152 }
153 ?>
154 </label>
155 <?php
156 \do_action( 'wp_2fa_after_backup_methods_setup', $setup_wizard, $data_role, null );
157 } else {
158 ?>
159 <input type="hidden" name="wp_2fa_policy[backup_codes_enabled]" value="yes">
160 <input type="hidden" name="wp_2fa_policy[enable-email-backup]" value="enable-email-backup">
161 <div class="method-wrapper"></div>
162 <div class="method-title"><em><?php esc_html_e( 'Secondary 2FA methods and other settings', 'wp-2fa' ); ?></em></div>
163 <p class="description" style="margin-bottom: 5px;"><br>
164 <?php esc_html_e( 'You can configure other 2FA method settings and the 2FA backup methods from the plugin settings later on.', 'wp-2fa' ); ?>
165 </p>
166 <?php
167 }
168 ?>
169 </fieldset>
170 <?php
171 if ( ! $setup_wizard ) {
172 ?>
173 </td>
174 </tr>
175 </tbody>
176 </table>
177 <?php } ?>
178 <?php
179 $output = ob_get_clean();
180
181 /**
182 * At this point, none of the default providers is set / activated. This filter allows additional providers to change the behaviour. Checking the input array for specific values (methods), and based on that we can raise error that none of the allowed methods has bees selected by the user, or dismiss the error otherwise.
183 *
184 * @param string $output - Parsed HTML with the methods.
185 * @param bool $setup_wizard - The type of the wizard (first time wizard / settings).
186 *
187 * @since 2.0.0
188 */
189 $output = apply_filters( WP_2FA_PREFIX . 'select_methods', $output, $setup_wizard );
190
191 echo $output; // @codingStandardsIgnoreLine - not escaped warning
192 }
193
194 /**
195 * Enforcement policy step
196 *
197 * @since 1.7.0
198 *
199 * @param boolean $setup_wizard - Boolean - is that first time wizard setup or settings page call.
200 *
201 * @return void
202 */
203 public static function enforcementPolicy( $setup_wizard = false ) {
204 ?>
205 <h3 id="enforcement_settings"><?php esc_html_e( 'Do you want to enforce 2FA for some, or all the users? ', 'wp-2fa' ); ?></h3>
206 <p class="description">
207 <?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>
208 </p>
209 <?php
210 if ( ! $setup_wizard ) {
211 ?>
212 <table class="form-table js-enforcement-policy-section">
213 <tbody>
214 <tr>
215 <th><label for="enforcement-policy"><?php esc_html_e( 'Enforce 2FA on', 'wp-2fa' ); ?></label></th>
216 <td>
217 <?php } ?>
218 <fieldset class="contains-hidden-inputs">
219 <label for="all-users" style="margin-bottom: 10px !important; display: block;">
220 <input type="radio" name="wp_2fa_policy[enforcement-policy]" id="all-users" value="all-users"
221 <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'all-users' ); ?>
222 >
223 <span><?php esc_html_e( 'All users', 'wp-2fa' ); ?></span>
224 </label>
225
226 <?php if ( WP2FA::is_this_multisite() ) : ?>
227 <label for="superadmins-only" style="margin-bottom: 10px; display: block;">
228 <input type="radio" name="wp_2fa_policy[enforcement-policy]" id="superadmins-only" value="superadmins-only"
229 <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'superadmins-only' ); ?> />
230 <span><?php esc_html_e( 'Only super admins', 'wp-2fa' ); ?></span>
231 </label>
232 <br/>
233 <label for="superadmins-siteadmins-only" style="margin-bottom: 10px; display: block;">
234 <input type="radio" name="wp_2fa_policy[enforcement-policy]" id="superadmins-siteadmins-only" value="superadmins-siteadmins-only"
235 <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'superadmins-siteadmins-only' ); ?> />
236 <span><?php esc_html_e( 'Only super admins and site admins', 'wp-2fa' ); ?></span>
237 </label>
238 <br/>
239 <?php endif; ?>
240
241 <label for="certain-roles-only" style="margin-bottom: 10px; display: block;">
242 <?php $checked = in_array( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), [ 'certain-roles-only', 'certain-users-only' ] ); ?>
243 <input type="radio" name="wp_2fa_policy[enforcement-policy]" id="certain-roles-only" value="certain-roles-only"
244 <?php ( $setup_wizard ) ? checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'certain-roles-only' ) : checked( $checked ); ?>
245 data-unhide-when-checked=".certain-roles-only-inputs, .certain-users-only-inputs">
246 <span><?php esc_html_e( 'Only for specific users and roles', 'wp-2fa' ); ?></span>
247 </label>
248 <fieldset class="hidden certain-users-only-inputs">
249 <div>
250 <p>
251 <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_policy[enforced_users][]" style=" display:none;width:<?php echo ( $setup_wizard ) ? '100' : '50'; ?>%">
252 <?php
253 $excluded_users = WP2FA::get_wp2fa_setting( 'enforced_users' );
254 foreach ( $excluded_users as $user ) {
255 ?>
256 <option selected="selected" value="<?php echo $user; ?>"><?php echo $user; ?></option>
257 <?php
258 }
259 ?>
260 </select>
261 </p>
262 </div>
263 </fieldset>
264 <fieldset class="hidden certain-roles-only-inputs">
265 <div>
266 <p style="margin-top: 0;">
267 <label for="enforced-roles-multi-select"><?php esc_html_e( 'Roles :', 'wp-2fa' ); ?></label>
268 <select multiple="multiple" id="enforced-roles-multi-select" name="wp_2fa_policy[enforced_roles][]" style=" display:none;width:<?php echo ( $setup_wizard ) ? '100' : '50'; ?>%">
269 <?php
270 $allRoles = \WP2FA\WP2FA::wp_2fa_get_roles();
271 $enforcedRoles = WP2FA::get_wp2fa_setting( 'enforced_roles' );
272 foreach ( $allRoles as $role => $roleName ) {
273 $selected = '';
274 if ( in_array( $role, $enforcedRoles ) ) {
275 $selected = 'selected="selected"';
276 }
277 ?>
278 <option <?php echo $selected; ?> value="<?php echo strtolower( $role ); ?>"><?php echo $roleName; ?></option>
279 <?php
280 }
281 ?>
282 </select>
283 </p>
284 </div>
285 <?php if ( WP2FA::is_this_multisite() ) { ?>
286 <div style="margin-left: 70px">
287 <input type="checkbox" name="wp_2fa_policy[superadmins-role-add]" id="superadmins-role-add" value="yes"
288 <?php checked( WP2FA::get_wp2fa_setting( 'superadmins-role-add' ), 'yes' ); ?> />
289 <label for="superadmins-role-add"><?php esc_html_e( 'Also enforce 2FA on network users with super admin privileges', 'wp-2fa' ); ?></label>
290 </div>
291 <?php } ?>
292 </fieldset>
293 <?php if ( WP2FA::is_this_multisite() ) { ?>
294 <div>
295 <label for="enforce-on-multisite" style="margin-bottom: 10px; display: block;">
296 <input type="radio" name="wp_2fa_policy[enforcement-policy]" id="enforce-on-multisite" value="enforce-on-multisite"
297 <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'enforce-on-multisite' ); ?>
298 data-unhide-when-checked=".all-sites">
299 <span><?php esc_html_e( 'These sub-sites', 'wp-2fa' ); ?></span>
300 </label>
301 <fieldset class="hidden all-sites">
302 <p>
303 <label for="slim-multi-select"><?php esc_html_e( 'Sites :', 'wp-2fa' ); ?></label> <select multiple="multiple" id="slim-multi-select" name="wp_2fa_policy[included_sites][]" style="display:none; width:<?php echo ( $setup_wizard ) ? '100' : '50'; ?>%">
304 <?php
305 $selectedSites = WP2FA::get_wp2fa_setting( 'included_sites' );
306 foreach ( WP2FA::getMultiSites() as $site ) {
307 $args = [
308 'blog_id' => $site->blog_id,
309 ];
310
311 $currentBlogDetails = get_blog_details( $args );
312 $selected = '';
313 if ( in_array( $site->blog_id, $selectedSites ) ) {
314 $selected = 'selected="selected"';
315 }
316 ?>
317 <option <?php echo $selected; ?> value="<?php echo $site->blog_id; ?>"><?php echo $currentBlogDetails->blogname; ?></option>
318 <?php
319 }
320 ?>
321 </select>
322 </p>
323 </fieldset>
324 </div>
325 <?php } ?>
326 <div>
327 <label for="do-not-enforce">
328 <input type="radio" name="wp_2fa_policy[enforcement-policy]" id="do-not-enforce" value="do-not-enforce"
329 <?php checked( WP2FA::get_wp2fa_setting( 'enforcement-policy' ), 'do-not-enforce' ); ?>
330 >
331 <span><?php esc_html_e( 'Do not enforce on any users', 'wp-2fa' ); ?></span>
332 </label>
333 </div>
334 <br/>
335 </fieldset>
336 <?php
337 if ( ! $setup_wizard ) {
338 ?>
339 </td>
340 </tr>
341 </tbody>
342 </table>
343 <?php
344 }
345 }
346
347 /**
348 * Exclude users and groups
349 *
350 * @since 1.7.0
351 *
352 * @param boolean $setup_wizard - Boolean - is that first time wizard setup or settings page call.
353 *
354 * @return void
355 */
356 public static function excludeUsers( $setup_wizard = false ) {
357 ?>
358 <h3><?php esc_html_e( 'Do you want to exclude any users or roles from 2FA? ', 'wp-2fa' ); ?></h3>
359 <p class="description">
360 <?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' ); ?>
361 </p>
362 <?php
363 if ( ! $setup_wizard ) {
364 ?>
365 <table class="form-table js-enforcement-policy-section">
366 <tbody>
367 <tr>
368 <th><label for="enforcement-policy"><?php esc_html_e( 'Exclude the following users', 'wp-2fa' ); ?></label></th>
369 <td>
370 <?php } else { ?>
371 <label for="excluded-users-multi-select"><?php esc_html_e( 'Exclude the following users', 'wp-2fa' ); ?>
372 <?php } ?>
373 <fieldset>
374 <div>
375 <select multiple="multiple" id="excluded-users-multi-select" name="wp_2fa_policy[excluded_users][]" style=" display:none;width:<?php echo ( $setup_wizard ) ? '100' : '50'; ?>%">
376 <?php
377 $excluded_users = WP2FA::get_wp2fa_setting( 'excluded_users' );
378 foreach ( $excluded_users as $user ) {
379 ?>
380 <option selected="selected" value="<?php echo $user; ?>"><?php echo $user; ?></option>
381 <?php
382 }
383 ?>
384 </select>
385 </div>
386 <?php
387 if ( ! $setup_wizard ) {
388 ?>
389
390 </td>
391 </tr>
392 <tr>
393 <th><label for="enforcement-policy"><?php esc_html_e( 'Exclude the following roles', 'wp-2fa' ); ?></label></th>
394 <td>
395 <p>
396 <?php } else { ?>
397 <br>
398 <label for="enforcement-policy"><?php esc_html_e( 'Exclude the following roles', 'wp-2fa' ); ?></label>
399 <?php } ?>
400 <select multiple="multiple" id="excluded-roles-multi-select" name="wp_2fa_policy[excluded_roles][]" style=" display:none;width:<?php echo ( $setup_wizard ) ? '100' : '50'; ?>%">
401 <?php
402 $allRoles = \WP2FA\WP2FA::wp_2fa_get_roles();
403 $excludedRoles = WP2FA::get_wp2fa_setting( 'excluded_roles' );
404 foreach ( $allRoles as $role => $roleName ) {
405 $selected = '';
406 if ( in_array( strtolower( $role ), $excludedRoles ) ) {
407 $selected = 'selected="selected"';
408 }
409 ?>
410 <option <?php echo $selected; ?> value="<?php echo strtolower( $role ); ?>"><?php echo $roleName; ?></option>
411 <?php
412 }
413 ?>
414 </select>
415 <br>
416 <?php if ( WP2FA::is_this_multisite() ) { ?>
417 <div style="margin-top:10px;">
418 <input type="checkbox" name="wp_2fa_policy[superadmins-role-exclude]" id="superadmins-role-exclude" value="yes"
419 <?php checked( WP2FA::get_wp2fa_setting( 'superadmins-role-exclude' ), 'yes' ); ?> />
420 <label for="superadmins-role-exclude"><?php esc_html_e( 'Also exclude users with super admin privilege', 'wp-2fa' ); ?></label>
421 </div>
422 <?php } ?>
423 </fieldset>
424 <?php
425 if ( ! $setup_wizard ) {
426 ?>
427 </td>
428 </tr>
429 </tbody>
430 </table>
431 <?php } ?>
432 <?php
433 }
434
435 /**
436 * Which network sites to exclude (for multisite instal)
437 *
438 * @since 1.7.0
439 *
440 * @param boolean $setup_wizard - Boolean - is that first time wizard setup or settings page call.
441 *
442 * @return void
443 */
444 public static function excludedNetworkSites( $setup_wizard = false ) {
445 ?>
446 <h3><?php esc_html_e( 'Do you want to exclude all the users of a site from 2FA? ', 'wp-2fa' ); ?></h3>
447 <p class="description">
448 <?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' ); ?>
449 </p>
450 <?php
451 if ( ! $setup_wizard ) {
452 ?>
453 <table class="form-table js-enforcement-policy-section">
454 <tbody>
455 <tr>
456 <th><label for="excluded-sites-multi-select"><?php esc_html_e( 'Exclude the following sites', 'wp-2fa' ); ?></label></th>
457 <td>
458 <?php } ?>
459 <fieldset>
460 <?php
461 if ( $setup_wizard ) {
462 ?>
463
464 <div class="option-pill">
465 <label for="excluded_sites_search"><?php esc_html_e( 'Exclude the following sites', 'wp-2fa' ); ?>
466 <?php } ?>
467 <select multiple="multiple" id="excluded-sites-multi-select" name="wp_2fa_policy[excluded_sites][]" style=" display:none;width:<?php echo ( $setup_wizard ) ? '100' : '50'; ?>%">
468 <?php
469 $excludedSites = WP2FA::get_wp2fa_setting( 'excluded_sites' );
470 if ( ! empty( $excludedSites ) ) {
471 foreach ( $excludedSites as $siteId ) {
472 $site = get_blog_details( $siteId )->blogname;
473 ?>
474 <option selected="selected" value="<?php echo esc_html( $siteId ); ?>"><?php echo $site; ?></option>
475 <?php
476 }
477 }
478 ?>
479 </select>
480 <?php
481 if ( $setup_wizard ) {
482 ?>
483 </label>
484 </div>
485 <?php } ?>
486 </fieldset>
487 <?php
488 if ( ! $setup_wizard ) {
489 ?>
490 </td>
491 </tr>
492 </tbody>
493 </table>
494 <?php } ?>
495 <?php
496 }
497
498 /**
499 * Set the grace period
500 *
501 * @since 1.7.0
502 *
503 * @param boolean $setup_wizard - Boolean - is that first time wizard setup or settings page call.
504 *
505 * @return void
506 */
507 public static function gracePeriod( $setup_wizard = false ) {
508 $gracePeriod = (int) WP2FA::get_wp2fa_setting( 'grace-period', true );
509 $testing = apply_filters( 'wp_2fa_allow_grace_period_in_seconds', false );
510 if ( $testing ) {
511 $graceMax = 600;
512 } else {
513 $graceMax = 10;
514 }
515 ?>
516 <fieldset class="contains-hidden-inputs">
517 <label for="no-grace-period" style="margin-bottom: 10px; display: block;">
518 <input type="radio" name="wp_2fa_policy[grace-policy]" id="no-grace-period" value="no-grace-period"
519 <?php checked( WP2FA::get_wp2fa_setting( 'grace-policy' ), 'no-grace-period' ); ?>
520 >
521 <span><?php esc_html_e( 'Users have to configure 2FA straight away.', 'wp-2fa' ); ?></span>
522 </label>
523
524 <label for="use-grace-period">
525 <input type="radio" name="wp_2fa_policy[grace-policy]" id="use-grace-period" value="use-grace-period"
526 <?php checked( WP2FA::get_wp2fa_setting( 'grace-policy' ), 'use-grace-period' ); ?>
527 data-unhide-when-checked=".grace-period-inputs">
528 <span><?php esc_html_e( 'Give users a grace period to configure 2FA', 'wp-2fa' ); ?></span>
529 </label>
530 <fieldset class="hidden grace-period-inputs">
531 <br/>
532 <input type="number" id="grace-period" name="wp_2fa_policy[grace-period]" value="<?php echo esc_attr( $gracePeriod ); ?>" min="1" max="<?php echo esc_attr( $graceMax ); ?>">
533 <label class="radio-inline">
534 <input class="js-nested" type="radio" name="wp_2fa_policy[grace-period-denominator]" value="hours"
535 <?php checked( WP2FA::get_wp2fa_setting( 'grace-period-denominator' ), 'hours' ); ?>
536 >
537 <?php esc_html_e( 'hours', 'wp-2fa' ); ?>
538 </label>
539 <label class="radio-inline">
540 <input class="js-nested" type="radio" name="wp_2fa_policy[grace-period-denominator]" value="days"
541 <?php checked( WP2FA::get_wp2fa_setting( 'grace-period-denominator' ), 'days' ); ?>
542 >
543 <?php esc_html_e( 'days', 'wp-2fa' ); ?>
544 </label>
545 <?php
546 $after_grace_content = \apply_filters( 'wp_2fa_after_grace_period', '', '', 'wp_2fa_policy' );
547 echo $after_grace_content;
548 ?>
549 <?php
550 $testing = apply_filters( 'wp_2fa_allow_grace_period_in_seconds', false );
551 if ( $testing ) {
552 ?>
553 <label class="radio-inline">
554 <input class="js-nested" type="radio" name="wp_2fa_policy[grace-period-denominator]" value="seconds"
555 <?php checked( WP2FA::get_wp2fa_setting( 'grace-period-denominator' ), 'seconds' ); ?>
556 >
557 <?php esc_html_e( 'Seconds', 'wp-2fa' ); ?>
558 </label>
559 <?php
560 }
561
562 if ( $setup_wizard ) {
563 $user = wp_get_current_user();
564 $lastUserToUpdateSettings = $user->ID;
565
566 ?>
567 <input type="hidden" id="2fa_main_user" name="wp_2fa_policy[2fa_settings_last_updated_by]" value="<?php echo esc_attr( $lastUserToUpdateSettings ); ?>">
568 <?php } else { ?>
569 <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>
570 <?php } ?>
571 </fieldset>
572 <br/>
573 </fieldset>
574 <?php
575 }
576 }
577