Making WordPress.org

Changeset 10850


Ignore:
Timestamp:
03/26/2021 03:05:08 AM (4 years ago)
Author:
dd32
Message:

Login: Change the username unknown message to be more explicit.

See #5590.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php

    r10845 r10850  
    460460
    461461// This is the login messages, which is displayed on wp-login.php, which does not use wp_login_form() or it's actions.
    462 function wporg_login_message( $errors, $redirect_to ) {
     462function wp_login_errors_message( $errors, $redirect_to ) {
    463463    $errors->add(
    464464        'pre_login_message',
     
    470470    return $errors;
    471471}
    472 add_filter( 'wp_login_errors', 'wporg_login_message', 10, 2 );
     472add_filter( 'wp_login_errors', 'wp_login_errors_message', 10, 2 );
     473
     474/**
     475 * Replace some login related error messages with nicer forms.
     476 *
     477 * See https://core.trac.wordpress.org/ticket/52915
     478 */
     479function wp_login_errors_nicify( $errors, $redirect_to ) {
     480
     481    $replace_errors = [
     482        'invalid_username' => sprintf(
     483            /* translators: %s: <strong>UserLogin</strong> */
     484            __( "<strong>Error:</strong> The username %s is not registered on WordPress.org. If you're unsure of your username, you can attempt to login using your email address instead.", 'wporg' ),
     485            '<strong>' . esc_html( wp_unslash( $_POST['log'] ?? '' ) ) . '</strong>'
     486        ),
     487
     488    ];
     489
     490    foreach ( $replace_errors as $error_code => $error_message ) {
     491        if ( $errors->get_error_message( $error_code ) ) {
     492            // Remove the existing one.
     493            $errors->remove( $error_code );
     494            // Replace it.
     495            $errors->add( $error_code, $error_message );
     496        }
     497    }
     498
     499    return $errors;
     500}
     501add_filter( 'wp_login_errors', 'wp_login_errors_nicify', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.