Accessibility: Login: Display error messages when both the username and password fields are empty.
For accessibility and usability, if an input error is detected, the item that is in error needs to be identified and the error needs to be described to the user in text (WCAG Success Criterion 3.3.1). The login form displays an error when the username field is empty or when the password field is empty. It omits to do so when both fields are empty. This change restores the login form behavior to the one that used to work in WordPress 2.3 (!) and displays the related error messages also when both fields are empty. Props birgire, audrasjb. See #8938, #5405, #3708. Fixes #42985. git-svn-id: https://develop.svn.wordpress.org/trunk@44918 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
13bb9c5ef4
commit
eeb57f67c4
|
@ -95,10 +95,6 @@ function wp_signon( $credentials = array(), $secure_cookie = '' ) {
|
||||||
$user = wp_authenticate( $credentials['user_login'], $credentials['user_password'] );
|
$user = wp_authenticate( $credentials['user_login'], $credentials['user_password'] );
|
||||||
|
|
||||||
if ( is_wp_error( $user ) ) {
|
if ( is_wp_error( $user ) ) {
|
||||||
if ( $user->get_error_codes() == array( 'empty_username', 'empty_password' ) ) {
|
|
||||||
$user = new WP_Error( '', '' );
|
|
||||||
}
|
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1007,6 +1007,10 @@ switch ( $action ) {
|
||||||
$errors = new WP_Error();
|
$errors = new WP_Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( empty( $_POST ) && $errors->get_error_codes() === array( 'empty_username', 'empty_password' ) ) {
|
||||||
|
$errors = new WP_Error( '', '' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( $interim_login ) {
|
if ( $interim_login ) {
|
||||||
if ( ! $errors->has_errors() ) {
|
if ( ! $errors->has_errors() ) {
|
||||||
$errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' );
|
$errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' );
|
||||||
|
|
Loading…
Reference in New Issue