Skip to content

Commit

Permalink
Implement an aria-describedby attribute for login screen errors, an…
Browse files Browse the repository at this point in the history
…d improve the "Forgot password?" anchor text.

Props aferica, rianrietveld
Fixes #31143

Built from https://develop.svn.wordpress.org/trunk@31871


git-svn-id: http://core.svn.wordpress.org/trunk@31850 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
johnbillion committed Mar 24, 2015
1 parent 46b5808 commit 7c5fc2d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions wp-includes/user.php
Expand Up @@ -134,7 +134,7 @@ function wp_authenticate_username_password($user, $username, $password) {
$user = get_user_by('login', $username);

if ( !$user )
return new WP_Error( 'invalid_username', sprintf( __( '<strong>ERROR</strong>: Invalid username. <a href="%s">Lost your password</a>?' ), wp_lostpassword_url() ) );
return new WP_Error( 'invalid_username', sprintf( __( '<strong>ERROR</strong>: Invalid username. <a href="%s">Lost your password?</a>' ), wp_lostpassword_url() ) );

/**
* Filter whether the given user can be authenticated with the provided $password.
Expand All @@ -150,7 +150,7 @@ function wp_authenticate_username_password($user, $username, $password) {
return $user;

if ( !wp_check_password($password, $user->user_pass, $user->ID) )
return new WP_Error( 'incorrect_password', sprintf( __( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s">Lost your password</a>?' ),
return new WP_Error( 'incorrect_password', sprintf( __( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s">Lost your password?</a>' ),
$username, wp_lostpassword_url() ) );

return $user;
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-beta2-31870';
$wp_version = '4.2-beta2-31871';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down
10 changes: 8 additions & 2 deletions wp-login.php
Expand Up @@ -889,16 +889,22 @@ function retrieve_password() {
if ( isset($_POST['log']) )
$user_login = ( 'incorrect_password' == $errors->get_error_code() || 'empty_password' == $errors->get_error_code() ) ? esc_attr(wp_unslash($_POST['log'])) : '';
$rememberme = ! empty( $_POST['rememberme'] );

if ( ! empty( $errors->errors ) ) {
$aria_describedby_error = ' aria-describedby="login_error"';
} else {
$aria_describedby_error = '';
}
?>

<form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
<p>
<label for="user_login"><?php _e('Username') ?><br />
<input type="text" name="log" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label>
<input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" /></label>
</p>
<p>
<label for="user_pass"><?php _e('Password') ?><br />
<input type="password" name="pwd" id="user_pass" class="input" value="" size="20" /></label>
<input type="password" name="pwd" id="user_pass"<?php echo $aria_describedby_error; ?> class="input" value="" size="20" /></label>
</p>
<?php
/**
Expand Down

0 comments on commit 7c5fc2d

Please sign in to comment.