/** * Display the security key section in a users profile. * * This executes during the `show_user_security_settings` action. * * @since 0.1-dev * * @access public * @static * * @param WP_User $user WP_User object of the logged-in user. */ public static function show_user_profile($user) { wp_nonce_field("user_security_keys-{$user->ID}", '_nonce_user_security_keys'); $new_key = false; $security_keys = Two_Factor_FIDO_U2F::get_security_keys($user->ID); if ($security_keys) { foreach ($security_keys as &$security_key) { if (property_exists($security_key, 'new')) { $new_key = true; unset($security_key->new); // If we've got a new one, update the db record to not save it there any longer. Two_Factor_FIDO_U2F::update_security_key($user->ID, $security_key); } } unset($security_key); } ?> <div class="security-keys" id="security-keys-section"> <h3><?php esc_html_e('Security Keys'); ?> </h3> <p><?php esc_html_e('FIDO U2F is only supported in Chrome 41+.'); ?> </p> <p><a href="https://support.google.com/accounts/answer/6103523"><?php esc_html_e('You can find FIDO U2F Security Key devices for sale from here.'); ?> </a></p> <div class="register-security-key"> <?php if (Two_Factor_FIDO_U2F::is_browser_support()) { ?> <input type="hidden" name="do_new_security_key" id="do_new_security_key" /> <input type="hidden" name="u2f_response" id="u2f_response" /> <button type="button" class="button button-secondary" id="register_security_key"><?php esc_html_e('Add New'); ?> </button> <?php } else { ?> <p><?php esc_html_e('Your browser doesn\'t support FIDO U2F.'); ?> </p> <?php } ?> </div> <?php if ($new_key) { ?> <p class="new-security-key"><?php esc_html_e('Your new security key registered.'); ?> </p> <?php } ?> <?php require TWO_FACTOR_DIR . 'providers/class.two-factor-fido-u2f-admin-list-table.php'; $u2f_list_table = new Two_Factor_FIDO_U2F_Admin_List_Table(); $u2f_list_table->items = $security_keys; $u2f_list_table->prepare_items(); $u2f_list_table->display(); $u2f_list_table->inline_edit(); ?> </div> <?php }