Make WordPress Core

Ticket #58407: 58407-with-error-handling-2.diff

File 58407-with-error-handling-2.diff, 1.4 KB (added by prashantbhivsane, 2 years ago)
  • src/wp-admin/users.php

    diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php
    index 8e5312c..ea38365 100644
    a b switch ( $wp_list_table->current_action() ) { 
    250250
    251251                        // Send the password reset link.
    252252                        $user = get_userdata( $id );
    253                         if ( retrieve_password( $user->user_login ) ) {
     253                        if ( ! is_wp_error( retrieve_password( $user->user_login ) ) ) {
    254254                                ++$reset_count;
    255255                        }
    256256                }
    switch ( $wp_list_table->current_action() ) { 
    565565                                        break;
    566566                                case 'resetpassword':
    567567                                        $reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0;
     568                                        $notice_type = $reset_count >= 1 ? 'updated' : 'error';
    568569                                        if ( 1 === $reset_count ) {
    569570                                                $message = __( 'Password reset link sent.' );
    570571                                        } else {
    571572                                                /* translators: %s: Number of users. */
    572573                                                $message = _n( 'Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count );
    573574                                        }
    574                                         $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $reset_count ) ) . '</p></div>';
     575                                        $messages[] = '<div id="message" class="notice is-dismissible ' . esc_attr( $notice_type ) . '"><p>' . sprintf( $message, number_format_i18n( $reset_count ) ) . '</p></div>';
    575576                                        break;
    576577                                case 'promote':
    577578                                        $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Changed roles.' ) . '</p></div>';