From d6b90486d1998b3ac01a6f14af5d9f10d71ee089 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 24 Mar 2015 16:28:56 +0000 Subject: [PATCH] Implement an `aria-describedby` attribute for login screen errors, and improve the "Forgot password?" anchor text. Props aferica, rianrietveld Fixes #31143 git-svn-id: https://develop.svn.wordpress.org/trunk@31871 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/user.php | 4 ++-- src/wp-login.php | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index d07d54108c..6b6f43599f 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -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( __( 'ERROR: Invalid username. Lost your password?' ), wp_lostpassword_url() ) ); + return new WP_Error( 'invalid_username', sprintf( __( 'ERROR: Invalid username. Lost your password?' ), wp_lostpassword_url() ) ); /** * Filter whether the given user can be authenticated with the provided $password. @@ -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( __( 'ERROR: The password you entered for the username %1$s is incorrect. Lost your password?' ), + return new WP_Error( 'incorrect_password', sprintf( __( 'ERROR: The password you entered for the username %1$s is incorrect. Lost your password?' ), $username, wp_lostpassword_url() ) ); return $user; diff --git a/src/wp-login.php b/src/wp-login.php index 62b182d4e0..9eac5ae01d 100644 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -889,16 +889,22 @@ default: 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 = ''; + } ?>

+ class="input" value="" size="20" />

+ class="input" value="" size="20" />