admin-actions.php
5 days ago
backup-codes-dialog.php
5 days ago
card-backup.php
5 days ago
card-setup.php
5 days ago
confirm-dialogs.php
5 days ago
index.php
5 days ago
main.php
5 days ago
summary.php
5 days ago
totp-details.php
5 days ago
card-backup.php
67 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Profile section: Backup 2FA Method card. |
| 4 | * |
| 5 | * Contains buttons for generating backup codes and managing backup methods. |
| 6 | * |
| 7 | * @var array $data Template data from the renderer. |
| 8 | * |
| 9 | * @package wp2fa |
| 10 | * @since 4.0.0 |
| 11 | */ |
| 12 | |
| 13 | defined( 'ABSPATH' ) || exit; |
| 14 | $backup = $data['backup_card_data']; |
| 15 | ?> |
| 16 | <div class="wp2fa-profile__card" id="wp2fa-backup-card"> |
| 17 | <h4 class="wp2fa-profile__card-title"><?php \esc_html_e( 'Backup 2FA Method', 'wp-2fa' ); ?></h4> |
| 18 | <div class="wp2fa-profile__btn-group"> |
| 19 | <?php if ( $backup['show_generate_codes'] ) { ?> |
| 20 | <button type="button" |
| 21 | class="wp2fa-profile__btn wp2fa-profile__btn--primary" |
| 22 | data-wp2fa-generate-backup-codes |
| 23 | data-nonce="<?php echo \esc_attr( $backup['backup_codes_nonce'] ); ?>" |
| 24 | data-user-id="<?php echo \esc_attr( (string) $data['user_id'] ); ?>"> |
| 25 | <?php \esc_html_e( 'Generate list of backup codes', 'wp-2fa' ); ?> |
| 26 | </button> |
| 27 | <?php if ( $backup['codes_remaining'] > 0 ) { ?> |
| 28 | <p class="wp2fa-profile__status-text"> |
| 29 | <?php |
| 30 | printf( |
| 31 | /* translators: %d: number of remaining backup codes */ |
| 32 | \esc_html__( '%d unused backup codes remaining.', 'wp-2fa' ), |
| 33 | (int) $backup['codes_remaining'] |
| 34 | ); |
| 35 | ?> |
| 36 | </p> |
| 37 | <?php } elseif ( 0 === $backup['codes_remaining'] ) { ?> |
| 38 | <p class="wp2fa-profile__status-text"> |
| 39 | <?php echo \wp_kses_post( \WP2FA\WP2FA::get_wp2fa_white_label_setting( 'backup_codes_learn_more', true ) ); ?> |
| 40 | </p> |
| 41 | <?php } ?> |
| 42 | <?php } ?> |
| 43 | |
| 44 | <?php |
| 45 | /** |
| 46 | * Action: wp_2fa_profile_backup_card_buttons |
| 47 | * |
| 48 | * Allows extensions to add their own backup method buttons |
| 49 | * (e.g., "Remove backup email method"). |
| 50 | * |
| 51 | * @param array $backup Backup card data. |
| 52 | * @param \WP_User $user The target user object. |
| 53 | * |
| 54 | * @since 4.0.0 |
| 55 | */ |
| 56 | \do_action( WP_2FA_PREFIX . 'profile_backup_card_buttons', $backup, $data['user'] ); |
| 57 | ?> |
| 58 | |
| 59 | <?php |
| 60 | // Render any extra backup buttons from filter. |
| 61 | if ( ! empty( $backup['extra_buttons'] ) ) { |
| 62 | echo \wp_kses_post( $backup['extra_buttons'] ); |
| 63 | } |
| 64 | ?> |
| 65 | </div> |
| 66 | </div> |
| 67 |