| @@ -1,31 +1,36 @@ | ||
| 1 | 1 | <?php |
| 2 | -declare( strict_types = 1 ); | |
| 2 | +/** | |
| 3 | + * This template is used to display 2FA user options. | |
| 4 | + * | |
| 5 | + * @package WP_Defender | |
| 6 | + */ | |
| 3 | 7 | |
| 8 | +$admin_class = $is_admin ? 'admin_area' : ''; | |
| 4 | 9 | wp_nonce_field( 'wpdef_2fa_user_options', '_wpdef_2fa_nonce_user_options', false ); |
| 5 | 10 | ?> |
| 6 | 11 | <input type="hidden" name="<?php echo esc_attr( $enabled_providers_key ); ?>[]" value=""/> |
| 7 | -<h2><?php _e( 'Security', 'wpdef' ); ?></h2> | |
| 12 | +<h2 class="defender-header"><?php esc_attr_e( 'Security', 'defender-security' ); ?></h2> | |
| 8 | 13 | <table class="form-table" id="defender-security"> |
| 9 | 14 | <tr class="user-sessions-wrap hide-if-no-js"> |
| 10 | 15 | <th> |
| 11 | - <?php _e( 'Two-Factor Authentication', 'wpdef' ); ?> | |
| 16 | + <?php esc_attr_e( 'Two-Factor Authentication', 'defender-security' ); ?> | |
| 12 | 17 | </th> |
| 13 | 18 | <td> |
| 14 | 19 | <?php if ( $is_force_auth ) : ?> |
| 15 | 20 | <div class="def-notification" style="margin-right: 0;margin-top: 0;"> |
| 16 | 21 | <i class="dashicons dashicons-warning" aria-hidden="true"></i> |
| 17 | - <?php echo ( ! empty( $force_auth_message ) ) ? $force_auth_message : $default_message; ?> | |
| 22 | + <?php echo wp_kses_post( ( '' !== trim( $force_auth_message ) ) ? $force_auth_message : $default_message ); ?> | |
| 18 | 23 | </div> |
| 19 | 24 | <?php endif; ?> |
| 20 | 25 | <table class="auth-methods-table"> |
| 21 | 26 | <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> | |
| 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> | |
| 28 | 33 | </thead> |
| 29 | 34 | <tbody> |
| 30 | 35 | <?php |
| 31 | 36 | foreach ( $all_providers as $slug => $object ) : |
| @@ -31,10 +36,11 @@ | ||
| 31 | 36 | foreach ( $all_providers as $slug => $object ) : |
| 32 | 37 | /** |
| 33 | 38 | * Fires before user options are shown. |
| 34 | 39 | * |
| 40 | + * @param WP_User $user The user. | |
| 41 | + * | |
| 35 | 42 | * @since 2.8.0 |
| 36 | - * @param WP_User $user The user. | |
| 37 | 43 | */ |
| 38 | 44 | do_action( 'wd_2fa_init_provider_' . $slug, $user ); |
| 39 | 45 | ?> |
| 40 | 46 | <tr id="row-<?php echo esc_attr( $slug ); ?>"> |
| @@ -39,17 +45,23 @@ | ||
| 39 | 45 | ?> |
| 40 | 46 | <tr id="row-<?php echo esc_attr( $slug ); ?>"> |
| 41 | 47 | <th scope="row" class="radio-button"> |
| 42 | 48 | <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 ); ?> | |
| 49 | + value="<?php echo esc_attr( $slug ); ?>" | |
| 50 | + <?php | |
| 51 | + checked( | |
| 52 | + $slug, | |
| 53 | + $checked_def_provider_slug | |
| 54 | + ); | |
| 55 | + ?> | |
| 44 | 56 | <?php echo $webauthn_slug === $slug && ! $webauthn_requirements ? 'disabled="disabled" class="disabled"' : ''; ?> /> |
| 45 | 57 | </th> |
| 46 | 58 | <th scope="row" class="toggles"> |
| 47 | 59 | <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 ); ?>" | |
| 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 ); ?>" | |
| 52 | 64 | <?php checked( in_array( $slug, $checked_provider_slugs, true ) ); ?> |
| 53 | 65 | <?php echo $webauthn_slug === $slug && ! $webauthn_requirements ? 'disabled="disabled"' : ''; ?> /> |
| 54 | 66 | </th> |
| 55 | 67 | <td> |
| @@ -54,10 +66,10 @@ | ||
| 54 | 66 | </th> |
| 55 | 67 | <td> |
| 56 | 68 | <strong> |
| 57 | 69 | <?php |
| 58 | - // No use esc_html() because there might be links. | |
| 59 | - echo $object->get_label(); | |
| 70 | + // It has button tag in src\component\two-factor\providers\class-totp.php. | |
| 71 | + echo wp_kses_post( $object->get_label() ); | |
| 60 | 72 | ?> |
| 61 | 73 | </strong> |
| 62 | 74 | <p class="<?php echo esc_attr( $slug ); ?>-provider-text"> |
| 63 | 75 | <?php echo esc_html( $object->get_description() ); ?> |
| @@ -65,10 +77,11 @@ | ||
| 65 | 77 | <?php |
| 66 | 78 | /** |
| 67 | 79 | * Fires after user options are shown. |
| 68 | 80 | * |
| 81 | + * @param WP_User $user The user. | |
| 82 | + * | |
| 69 | 83 | * @since 2.8.0 |
| 70 | - * @param WP_User $user The user. | |
| 71 | 84 | */ |
| 72 | 85 | do_action( 'wd_2fa_user_options_' . $slug, $user ); |
| 73 | 86 | ?> |
| 74 | 87 | </td> |
| @@ -79,76 +92,106 @@ | ||
| 79 | 92 | </td> |
| 80 | 93 | </tr> |
| 81 | 94 | </table> |
| 82 | 95 | <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> | |
| 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> | |
| 139 | 182 | </div> |
| 140 | 183 | <script type="text/javascript"> |
| 141 | 184 | jQuery(function ($) { |
| 142 | 185 | <?php if ( $is_force_auth ) { ?> |
| 143 | - $('html, body').animate({scrollTop: $(".auth-methods-table").offset().top}, 1000); | |
| 186 | + $('html, body').animate({scrollTop: $(".auth-methods-table").offset().top}, 1000); | |
| 144 | 187 | <?php } ?> |
| 145 | 188 | |
| 146 | - $( 'body' ).on( 'click', '#defender-security #field-<?php echo $webauthn_slug; ?>', function( e ) { | |
| 147 | - if ( $( this ).is( ':checked' ) ) { | |
| 148 | - $( '.defender-biometric-wrap' ).show(); | |
| 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(); | |
| 149 | 192 | } else { |
| 150 | - $( '.defender-biometric-wrap' ).hide(); | |
| 193 | + $('.defender-biometric-wrap').hide(); | |
| 151 | 194 | } |
| 152 | 195 | }); |
| 153 | 196 | }) |
| 154 | 197 | </script> |