| 1 |
<?php |
| 2 |
declare( strict_types = 1 ); |
| 3 |
|
| 4 |
wp_nonce_field( 'wpdef_2fa_user_options', '_wpdef_2fa_nonce_user_options', false ); |
| 5 |
?> |
| 6 |
<input type="hidden" name="<?php echo esc_attr( $enabled_providers_key ); ?>[]" value=""/> |
| 7 |
<h2><?php _e( 'Security', 'wpdef' ); ?></h2> |
| 8 |
<table class="form-table" id="defender-security"> |
| 9 |
<tr class="user-sessions-wrap hide-if-no-js"> |
| 10 |
<th> |
| 11 |
<?php _e( 'Two-Factor Authentication', 'wpdef' ); ?> |
| 12 |
</th> |
| 13 |
<td> |
| 14 |
<?php if ( $is_force_auth ) : ?> |
| 15 |
<div class="def-notification" style="margin-right: 0;margin-top: 0;"> |
| 16 |
<i class="dashicons dashicons-warning" aria-hidden="true"></i> |
| 17 |
<?php echo ( ! empty( $force_auth_message ) ) ? $force_auth_message : $default_message; ?> |
| 18 |
</div> |
| 19 |
<?php endif; ?> |
| 20 |
<table class="auth-methods-table"> |
| 21 |
<thead> |
| 22 |
<tr> |
| 23 |
<th class="col-enabled" scope="col"><?php esc_html_e( 'Default', 'two-factor' ); ?></th> |
| 24 |
<th class="col-primary" scope="col" colspan="2"> |
| 25 |
<?php esc_html_e( '2FA Method', 'two-factor' ); ?> |
| 26 |
</th> |
| 27 |
</tr> |
| 28 |
</thead> |
| 29 |
<tbody> |
| 30 |
<?php |
| 31 |
foreach ( $all_providers as $slug => $object ) : |
| 32 |
/** |
| 33 |
* Fires before user options are shown. |
| 34 |
* |
| 35 |
* @since 2.8.0 |
| 36 |
* @param WP_User $user The user. |
| 37 |
*/ |
| 38 |
do_action( 'wd_2fa_init_provider_' . $slug, $user ); |
| 39 |
?> |
| 40 |
<tr id="row-<?php echo esc_attr( $slug ); ?>"> |
| 41 |
<th scope="row" class="radio-button"> |
| 42 |
<input type="radio" name="<?php echo esc_attr( $default_provider_key ); ?>" |
| 43 |
value="<?php echo esc_attr( $slug ); ?>" <?php checked( $slug, $checked_def_provider_slug ); ?> |
| 44 |
<?php echo $webauthn_slug === $slug && ! $webauthn_requirements ? 'disabled="disabled" class="disabled"' : ''; ?> /> |
| 45 |
</th> |
| 46 |
<th scope="row" class="toggles"> |
| 47 |
<input type="checkbox" |
| 48 |
class="wpdef-ui-toggle<?php echo $webauthn_slug === $slug && ! $webauthn_requirements ? ' disabled' : ''; ?>" |
| 49 |
id="field-<?php echo esc_attr( $slug ); ?>" |
| 50 |
name="<?php echo esc_attr( $enabled_providers_key ); ?>[]" |
| 51 |
value="<?php echo esc_attr( $slug ); ?>" |
| 52 |
<?php checked( in_array( $slug, $checked_provider_slugs, true ) ); ?> |
| 53 |
<?php echo $webauthn_slug === $slug && ! $webauthn_requirements ? 'disabled="disabled"' : ''; ?> /> |
| 54 |
</th> |
| 55 |
<td> |
| 56 |
<strong> |
| 57 |
<?php |
| 58 |
// No use esc_html() because there might be links. |
| 59 |
echo $object->get_label(); |
| 60 |
?> |
| 61 |
</strong> |
| 62 |
<p class="<?php echo esc_attr( $slug ); ?>-provider-text"> |
| 63 |
<?php echo esc_html( $object->get_description() ); ?> |
| 64 |
</p> |
| 65 |
<?php |
| 66 |
/** |
| 67 |
* Fires after user options are shown. |
| 68 |
* |
| 69 |
* @since 2.8.0 |
| 70 |
* @param WP_User $user The user. |
| 71 |
*/ |
| 72 |
do_action( 'wd_2fa_user_options_' . $slug, $user ); |
| 73 |
?> |
| 74 |
</td> |
| 75 |
</tr> |
| 76 |
<?php endforeach; ?> |
| 77 |
</tbody> |
| 78 |
</table> |
| 79 |
</td> |
| 80 |
</tr> |
| 81 |
</table> |
| 82 |
<div class="defender-biometric-wrap" <?php echo true !== $webauthn_enabled ? 'style="display:none;"' : ''; ?>> |
| 83 |
<h3><?php esc_html_e( 'Registered Device', 'wpdef' ); ?></h3> |
| 84 |
<table class="form-table" id="defender-biometric-tbl"> |
| 85 |
<thead> |
| 86 |
<tr> |
| 87 |
<th><?php esc_html_e( 'Identifier', 'wpdef' ); ?></th> |
| 88 |
<th><?php esc_html_e( 'Type', 'wpdef' ); ?></th> |
| 89 |
<th><?php esc_html_e( 'Date registered', 'wpdef' ); ?></th> |
| 90 |
<th><?php esc_html_e( 'Action', 'wpdef' ); ?></th> |
| 91 |
</tr> |
| 92 |
</thead> |
| 93 |
<tbody class="records" style="display:none;"></tbody> |
| 94 |
<tbody class="no-record" style="display:none;"> |
| 95 |
<tr> |
| 96 |
<td colspan="4"><?php esc_html_e( 'No registered authenticator', 'wpdef' ); ?></td> |
| 97 |
</tr> |
| 98 |
</tbody> |
| 99 |
<tfoot> |
| 100 |
<tr> |
| 101 |
<td><?php esc_html_e( 'Identifier', 'wpdef' ); ?></td> |
| 102 |
<td><?php esc_html_e( 'Type', 'wpdef' ); ?></td> |
| 103 |
<td><?php esc_html_e( 'Date registered', 'wpdef' ); ?></td> |
| 104 |
<td><?php esc_html_e( 'Action', 'wpdef' ); ?></td> |
| 105 |
</tr> |
| 106 |
</tfoot> |
| 107 |
</table> |
| 108 |
<div class="wpdef-control"> |
| 109 |
<button type="button" class="button wpdef-new-btn wpdef-device-btn"><?php esc_html_e( 'Register Device', 'wpdef' ); ?></button> |
| 110 |
<button type="button" class="button wpdef-verify-btn wpdef-device-btn"><?php esc_html_e( 'Authenticate Device', 'wpdef' ); ?></button> |
| 111 |
</div> |
| 112 |
<div class="process-auth-desc"></div> |
| 113 |
<div class="register-authenticator-box" style="display:none;"> |
| 114 |
<h2><?php esc_html_e( 'Register New Authenticator', 'wpdef' ); ?></h2> |
| 115 |
<div class="desc"> |
| 116 |
<?php esc_html_e( 'Register new authenticator for current user account. Multiple authenticators can be registered for an account.', 'wpdef' ); ?> |
| 117 |
</div> |
| 118 |
<table class="form-table"> |
| 119 |
<tr> |
| 120 |
<th> |
| 121 |
<?php esc_html_e( 'Authenticator Identifier', 'wpdef' ); ?> |
| 122 |
<span class="required">*</span> |
| 123 |
</th> |
| 124 |
<td> |
| 125 |
<input type="text" class="regular-text" id="authenticator-identifier" /> |
| 126 |
<div class="field-error" style="display:none;"> |
| 127 |
<?php esc_html_e( 'Add an authenticator identifier.', 'wpdef' ); ?> |
| 128 |
</div> |
| 129 |
<div class="field-desc"> |
| 130 |
<?php esc_html_e( 'Provide name to identify authenticator easily.', 'wpdef' ); ?> |
| 131 |
</div> |
| 132 |
</td> |
| 133 |
</tr> |
| 134 |
</table> |
| 135 |
<button type="button" id="wpdef-register-authenticator-btn" class="button"><?php esc_html_e( 'Start Registration', 'wpdef' ); ?></button> |
| 136 |
<button type="button" id="wpdef-register-authenticator-close-btn" class="button"><?php esc_html_e( 'Cancel', 'wpdef' ); ?></button> |
| 137 |
<div class="process-desc"></div> |
| 138 |
</div> |
| 139 |
</div> |
| 140 |
<script type="text/javascript"> |
| 141 |
jQuery(function ($) { |
| 142 |
<?php if ( $is_force_auth ) { ?> |
| 143 |
$('html, body').animate({scrollTop: $(".auth-methods-table").offset().top}, 1000); |
| 144 |
<?php } ?> |
| 145 |
|
| 146 |
$( 'body' ).on( 'click', '#defender-security #field-<?php echo $webauthn_slug; ?>', function( e ) { |
| 147 |
if ( $( this ).is( ':checked' ) ) { |
| 148 |
$( '.defender-biometric-wrap' ).show(); |
| 149 |
} else { |
| 150 |
$( '.defender-biometric-wrap' ).hide(); |
| 151 |
} |
| 152 |
}); |
| 153 |
}) |
| 154 |
</script> |
| 155 |
|