Skip to content

Commit

Permalink
Rename backup codes to 'Recovery Codes', to dissuade their regular use.
Browse files Browse the repository at this point in the history
  • Loading branch information
dd32 committed Apr 13, 2023
1 parent 62af05b commit b18f97c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions providers/class-two-factor-backup-codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function admin_notices() {
echo wp_kses(
sprintf(
/* translators: %s: URL for code regeneration */
__( 'Two-Factor: You are out of backup codes and need to <a href="%s">regenerate!</a>', 'two-factor' ),
__( 'Two-Factor: You are out of recovery codes and need to <a href="%s">regenerate!</a>', 'two-factor' ),
esc_url( get_edit_user_link( $user->ID ) . '#two-factor-backup-codes' )
),
array( 'a' => array( 'href' => true ) )
Expand All @@ -132,7 +132,7 @@ public function admin_notices() {
* @since 0.1-dev
*/
public function get_label() {
return _x( 'Backup Codes', 'Provider Label', 'two-factor' );
return _x( 'Recovery Codes', 'Provider Label', 'two-factor' );
}

/**
Expand All @@ -141,7 +141,7 @@ public function get_label() {
* @since 0.9.0
*/
public function get_alternative_provider_label() {
return __( 'Use a backup code', 'two-factor' );
return __( 'Use a recovery code', 'two-factor' );
}

/**
Expand Down Expand Up @@ -176,15 +176,15 @@ public function user_options( $user ) {
echo esc_html(
sprintf(
/* translators: %s: count */
_n( '%s unused code remaining, each backup code can only be used once.', '%s unused codes remaining, each backup code can only be used once.', $count, 'two-factor' ),
_n( '%s unused code remaining, each recovery code can only be used once.', '%s unused codes remaining, each recovery code can only be used once.', $count, 'two-factor' ),
$count
)
);
?>
</p>
<p>
<button type="button" class="button button-two-factor-backup-codes-generate button-secondary hide-if-no-js">
<?php esc_html_e( 'Generate new verification codes', 'two-factor' ); ?>
<?php esc_html_e( 'Generate new recovery codes', 'two-factor' ); ?>
</button>
</p>
</p>
Expand Down Expand Up @@ -283,7 +283,7 @@ public function rest_generate_codes( $request ) {
$count = self::codes_remaining_for_user( $user );
$title = sprintf(
/* translators: %s: the site's domain */
__( 'Two-Factor Backup Codes for %s', 'two-factor' ),
__( 'Two-Factor Recovery Codes for %s', 'two-factor' ),
home_url( '/' )
);

Expand All @@ -299,11 +299,11 @@ public function rest_generate_codes( $request ) {

$i18n = array(
/* translators: %s: count */
'count' => esc_html( sprintf( _n( '%s unused code remaining, each backup code can only be used once.', '%s unused codes remaining, each backup code can only be used once.', $count, 'two-factor' ), $count ) ),
'count' => esc_html( sprintf( _n( '%s unused code remaining, each recovery code can only be used once.', '%s unused codes remaining, each recovery code can only be used once.', $count, 'two-factor' ), $count ) ),
);

if ( $request->get_param( 'enable_provider' ) && ! Two_Factor_Core::enable_provider_for_user( $user_id, 'Two_Factor_Backup_Codes' ) ) {
return new WP_Error( 'db_error', __( 'Unable to enable Backup Codes provider for this user.', 'two-factor' ), array( 'status' => 500 ) );
return new WP_Error( 'db_error', __( 'Unable to enable recovery codes for this user.', 'two-factor' ), array( 'status' => 500 ) );
}

return array(
Expand Down Expand Up @@ -338,9 +338,9 @@ public static function codes_remaining_for_user( $user ) {
public function authentication_page( $user ) {
require_once ABSPATH . '/wp-admin/includes/template.php';
?>
<p class="two-factor-prompt"><?php esc_html_e( 'Enter a backup code.', 'two-factor' ); ?></p><br/>
<p class="two-factor-prompt"><?php esc_html_e( 'Enter a recovery code.', 'two-factor' ); ?></p><br/>
<p>
<label for="authcode"><?php esc_html_e( 'Backup Code:', 'two-factor' ); ?></label>
<label for="authcode"><?php esc_html_e( 'Recovery Code:', 'two-factor' ); ?></label>
<input type="text" inputmode="numeric" name="two-factor-backup-code" id="authcode" class="input authcode" value="" size="20" pattern="[0-9 ]*" placeholder="1234 5678" data-digits="8" />
</p>
<?php
Expand Down
4 changes: 2 additions & 2 deletions tests/providers/class-two-factor-backup-codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function test_get_instance() {
* @covers Two_Factor_Backup_Codes::get_label
*/
public function test_get_label() {
$this->assertStringContainsString( 'Backup Codes', $this->provider->get_label() );
$this->assertStringContainsString( 'Recovery Codes', $this->provider->get_label() );
}

/**
Expand All @@ -60,7 +60,7 @@ public function test_authentication_page() {
$this->provider->authentication_page( false );
$contents = ob_get_clean();

$this->assertStringContainsString( 'Enter a backup code.', $contents );
$this->assertStringContainsString( 'Enter a recovery code.', $contents );
}

/**
Expand Down

0 comments on commit b18f97c

Please sign in to comment.