| 1 |
<?php |
| 2 |
/** |
| 3 |
* This template is used to display 2FA user options. |
| 4 |
* |
| 5 |
* @package WP_Defender |
| 6 |
*/ |
| 7 |
|
| 8 |
$admin_class = $is_admin ? 'admin_area' : ''; |
| 9 |
wp_nonce_field( 'wpdef_2fa_user_options', '_wpdef_2fa_nonce_user_options', false ); |
| 10 |
?> |
| 11 |
<input type="hidden" name="<?php echo esc_attr( $enabled_providers_key ); ?>[]" value=""/> |
| 12 |
<h2 class="defender-header"><?php esc_attr_e( 'Security', 'defender-security' ); ?></h2> |
| 13 |
<table class="form-table" id="defender-security"> |
| 14 |
<tr class="user-sessions-wrap hide-if-no-js"> |
| 15 |
<th> |
| 16 |
<?php esc_attr_e( 'Two-Factor Authentication', 'defender-security' ); ?> |
| 17 |
</th> |
| 18 |
<td> |
| 19 |
<?php if ( $is_force_auth ) : ?> |
| 20 |
<div class="def-notification" style="margin-right: 0;margin-top: 0;"> |
| 21 |
<i class="dashicons dashicons-warning" aria-hidden="true"></i> |
| 22 |
<?php echo wp_kses_post( ( '' !== trim( $force_auth_message ) ) ? $force_auth_message : $default_message ); ?> |
| 23 |
</div> |
| 24 |
<?php endif; ?> |
| 25 |
<table class="auth-methods-table"> |
| 26 |
<thead> |
| 27 |
<tr> |
| 28 |
<th class="col-enabled" scope="col"><?php esc_html_e( 'Default', 'defender-security' ); ?></th> |
| 29 |
<th class="col-primary" scope="col" colspan="2"> |
| 30 |
<?php esc_html_e( '2FA Method', 'defender-security' ); ?> |
| 31 |
</th> |
| 32 |
</tr> |
| 33 |
</thead> |
| 34 |
<tbody> |
| 35 |
<?php |
| 36 |
foreach ( $all_providers as $slug => $object ) : |
| 37 |
/** |
| 38 |
* Fires before user options are shown. |
| 39 |
* |
| 40 |
* @param WP_User $user The user. |
| 41 |
* |
| 42 |
* @since 2.8.0 |
| 43 |
*/ |
| 44 |
do_action( 'wd_2fa_init_provider_' . $slug, $user ); |
| 45 |
?> |
| 46 |
<tr id="row-<?php echo esc_attr( $slug ); ?>"> |
| 47 |
<th scope="row" class="radio-button"> |
| 48 |
<input type="radio" name="<?php echo esc_attr( $default_provider_key ); ?>" |
| 49 |
value="<?php echo esc_attr( $slug ); ?>" |
| 50 |
<?php |
| 51 |
checked( |
| 52 |
$slug, |
| 53 |
$checked_def_provider_slug |
| 54 |
); |
| 55 |
?> |
| 56 |
<?php echo $webauthn_slug === $slug && ! $webauthn_requirements ? 'disabled="disabled" class="disabled"' : ''; ?> /> |
| 57 |
</th> |
| 58 |
<th scope="row" class="toggles"> |
| 59 |
<input type="checkbox" |
| 60 |
class="wpdef-ui-toggle<?php echo $webauthn_slug === $slug && ! $webauthn_requirements ? ' disabled' : ''; ?>" |
| 61 |
id="field-<?php echo esc_attr( $slug ); ?>" |
| 62 |
name="<?php echo esc_attr( $enabled_providers_key ); ?>[]" |
| 63 |
value="<?php echo esc_attr( $slug ); ?>" |
| 64 |
<?php checked( in_array( $slug, $checked_provider_slugs, true ) ); ?> |
| 65 |
<?php echo $webauthn_slug === $slug && ! $webauthn_requirements ? 'disabled="disabled"' : ''; ?> /> |
| 66 |
</th> |
| 67 |
<td> |
| 68 |
<strong> |
| 69 |
<?php |
| 70 |
// It has button tag in src\component\two-factor\providers\class-totp.php. |
| 71 |
echo wp_kses_post( $object->get_label() ); |
| 72 |
?> |
| 73 |
</strong> |
| 74 |
<p class="<?php echo esc_attr( $slug ); ?>-provider-text"> |
| 75 |
<?php echo esc_html( $object->get_description() ); ?> |
| 76 |
</p> |
| 77 |
<?php |
| 78 |
/** |
| 79 |
* Fires after user options are shown. |
| 80 |
* |
| 81 |
* @param WP_User $user The user. |
| 82 |
* |
| 83 |
* @since 2.8.0 |
| 84 |
*/ |
| 85 |
do_action( 'wd_2fa_user_options_' . $slug, $user ); |
| 86 |
?> |
| 87 |
</td> |
| 88 |
</tr> |
| 89 |
<?php endforeach; ?> |
| 90 |
</tbody> |
| 91 |
</table> |
| 92 |
</td> |
| 93 |
</tr> |
| 94 |
</table> |
| 95 |
<div class="defender-biometric-wrap" <?php echo true !== $webauthn_enabled ? 'style="display:none;"' : ''; ?>> |
| 96 |
<h3><?php esc_html_e( 'Registered Device', 'defender-security' ); ?></h3> |
| 97 |
<table class="form-table" id="defender-biometric-tbl"> |
| 98 |
<thead> |
| 99 |
<tr> |
| 100 |
<th><?php esc_html_e( 'Identifier', 'defender-security' ); ?></th> |
| 101 |
<th><?php esc_html_e( 'Type', 'defender-security' ); ?></th> |
| 102 |
<th><?php esc_html_e( 'Date registered', 'defender-security' ); ?></th> |
| 103 |
<th><?php esc_html_e( 'Action', 'defender-security' ); ?></th> |
| 104 |
</tr> |
| 105 |
</thead> |
| 106 |
<tbody class="records" style="display:none;"></tbody> |
| 107 |
<tbody class="no-record" style="display:none;"> |
| 108 |
<tr> |
| 109 |
<td colspan="4"><?php esc_html_e( 'No registered authenticator', 'defender-security' ); ?></td> |
| 110 |
</tr> |
| 111 |
</tbody> |
| 112 |
<tfoot> |
| 113 |
<tr> |
| 114 |
<td><?php esc_html_e( 'Identifier', 'defender-security' ); ?></td> |
| 115 |
<td><?php esc_html_e( 'Type', 'defender-security' ); ?></td> |
| 116 |
<td><?php esc_html_e( 'Date registered', 'defender-security' ); ?></td> |
| 117 |
<td><?php esc_html_e( 'Action', 'defender-security' ); ?></td> |
| 118 |
</tr> |
| 119 |
</tfoot> |
| 120 |
</table> |
| 121 |
<div class="wpdef-control"> |
| 122 |
<button type="button" class="button wpdef-new-btn wpdef-device-btn <?php echo esc_attr( $admin_class ); ?>"> |
| 123 |
<?php esc_html_e( 'Register Device', 'defender-security' ); ?> |
| 124 |
</button> |
| 125 |
<button type="button" class="button wpdef-verify-btn wpdef-device-btn <?php echo esc_attr( $admin_class ); ?>"> |
| 126 |
<?php esc_html_e( 'Authenticate Device', 'defender-security' ); ?> |
| 127 |
</button> |
| 128 |
</div> |
| 129 |
<div class="process-auth-desc"></div> |
| 130 |
<div class="register-authenticator-box" style="display:none;"> |
| 131 |
<h2><?php esc_html_e( 'Register New Authenticator', 'defender-security' ); ?></h2> |
| 132 |
<div class="desc"> |
| 133 |
<?php |
| 134 |
esc_html_e( |
| 135 |
'Register a new authenticator for the current user account. You can register multiple authenticators for an account.', |
| 136 |
'defender-security' |
| 137 |
); |
| 138 |
?> |
| 139 |
</div> |
| 140 |
<table class="form-table"> |
| 141 |
<tr id="row-auth-type"> |
| 142 |
<th> |
| 143 |
<?php esc_html_e( 'Select an Authenticator Type', 'defender-security' ); ?> |
| 144 |
<span class="required">*</span> |
| 145 |
</th> |
| 146 |
<td> |
| 147 |
<div class="field-group"> |
| 148 |
<input type="radio" name="authenticator-type" value="platform"/> |
| 149 |
<span><?php esc_html_e( 'Platform (Fingerprint and facial recognition)', 'defender-security' ); ?></span> |
| 150 |
</div> |
| 151 |
<div class="field-group"> |
| 152 |
<input type="radio" name="authenticator-type" value="cross-platform"/> |
| 153 |
<span><?php esc_html_e( 'Roaming (e.g. USB security keys)', 'defender-security' ); ?></span> |
| 154 |
</div> |
| 155 |
<div class="field-error" style="display:none;"> |
| 156 |
<?php esc_html_e( 'Choose an authenticator type.', 'defender-security' ); ?> |
| 157 |
</div> |
| 158 |
</td> |
| 159 |
</tr> |
| 160 |
<tr> |
| 161 |
<th> |
| 162 |
<?php esc_html_e( 'Authenticator Identifier', 'defender-security' ); ?> |
| 163 |
<span class="required">*</span> |
| 164 |
</th> |
| 165 |
<td> |
| 166 |
<input type="text" class="regular-text" id="authenticator-identifier"/> |
| 167 |
<div class="field-error" style="display:none;"> |
| 168 |
<?php esc_html_e( 'Add an authenticator identifier.', 'defender-security' ); ?> |
| 169 |
</div> |
| 170 |
<div class="field-desc"> |
| 171 |
<?php esc_html_e( 'Provide name to identify authenticator easily.', 'defender-security' ); ?> |
| 172 |
</div> |
| 173 |
</td> |
| 174 |
</tr> |
| 175 |
</table> |
| 176 |
<button type="button" id="wpdef-register-authenticator-btn" |
| 177 |
class="button"><?php esc_html_e( 'Start Registration', 'defender-security' ); ?></button> |
| 178 |
<button type="button" id="wpdef-register-authenticator-close-btn" |
| 179 |
class="button"><?php esc_html_e( 'Cancel', 'defender-security' ); ?></button> |
| 180 |
<div class="process-desc"></div> |
| 181 |
</div> |
| 182 |
</div> |
| 183 |
<script type="text/javascript"> |
| 184 |
jQuery(function ($) { |
| 185 |
<?php if ( $is_force_auth ) { ?> |
| 186 |
$('html, body').animate({scrollTop: $(".auth-methods-table").offset().top}, 1000); |
| 187 |
<?php } ?> |
| 188 |
|
| 189 |
$('body').on('click', '#defender-security #field-<?php echo esc_html( $webauthn_slug ); ?>', function (e) { |
| 190 |
if ($(this).is(':checked')) { |
| 191 |
$('.defender-biometric-wrap').show(); |
| 192 |
} else { |
| 193 |
$('.defender-biometric-wrap').hide(); |
| 194 |
} |
| 195 |
}); |
| 196 |
}) |
| 197 |
</script> |
| 198 |
|