From eeb57f67c44df4f31bf7958d842c42681ff71e71 Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Sat, 16 Mar 2019 15:21:25 +0000 Subject: [PATCH] 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 --- src/wp-includes/user.php | 4 ---- src/wp-login.php | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index eb8f0a13aa..3414da0fbc 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -95,10 +95,6 @@ function wp_signon( $credentials = array(), $secure_cookie = '' ) { $user = wp_authenticate( $credentials['user_login'], $credentials['user_password'] ); if ( is_wp_error( $user ) ) { - if ( $user->get_error_codes() == array( 'empty_username', 'empty_password' ) ) { - $user = new WP_Error( '', '' ); - } - return $user; } diff --git a/src/wp-login.php b/src/wp-login.php index 72fcae266d..b02a2b9e70 100644 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -1007,6 +1007,10 @@ switch ( $action ) { $errors = new WP_Error(); } + if ( empty( $_POST ) && $errors->get_error_codes() === array( 'empty_username', 'empty_password' ) ) { + $errors = new WP_Error( '', '' ); + } + if ( $interim_login ) { if ( ! $errors->has_errors() ) { $errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' );