diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/class-wp-users-list-table.php --- a/wp/wp-admin/includes/class-wp-users-list-table.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/includes/class-wp-users-list-table.php Fri Sep 05 18:40:08 2025 +0200 @@ -11,7 +11,6 @@ * Core class used to implement displaying users in a list table. * * @since 3.1.0 - * @access private * * @see WP_List_Table */ @@ -59,7 +58,7 @@ } /** - * Check the current user's permissions. + * Checks the current user's permissions. * * @since 3.1.0 * @@ -74,7 +73,7 @@ } /** - * Prepare the users list for display. + * Prepares the users list for display. * * @since 3.1.0 * @@ -151,7 +150,7 @@ } /** - * Output 'no users' message. + * Outputs 'no users' message. * * @since 3.1.0 */ @@ -160,11 +159,11 @@ } /** - * Return an associative array listing all the views that can be used + * Returns an associative array listing all the views that can be used * with this table. * * Provides a list of roles and user count for that role for easy - * Filtersing of the user table. + * filtering of the user table. * * @since 3.1.0 * @@ -185,10 +184,9 @@ $url = 'users.php'; } - $role_links = array(); - $avail_roles = array(); - $all_text = __( 'All' ); - $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : ''; + $role_links = array(); + $avail_roles = array(); + $all_text = __( 'All' ); if ( $count_users ) { if ( $this->is_site_users ) { @@ -215,19 +213,17 @@ ); } - $role_links['all'] = sprintf( '%s', $url, $current_link_attributes, $all_text ); + $role_links['all'] = array( + 'url' => $url, + 'label' => $all_text, + 'current' => empty( $role ), + ); foreach ( $wp_roles->get_names() as $this_role => $name ) { if ( $count_users && ! isset( $avail_roles[ $this_role ] ) ) { continue; } - $current_link_attributes = ''; - - if ( $this_role === $role ) { - $current_link_attributes = ' class="current" aria-current="page"'; - } - $name = translate_user_role( $name ); if ( $count_users ) { $name = sprintf( @@ -238,17 +234,15 @@ ); } - $role_links[ $this_role ] = "$name"; + $role_links[ $this_role ] = array( + 'url' => esc_url( add_query_arg( 'role', $this_role, $url ) ), + 'label' => $name, + 'current' => $this_role === $role, + ); } if ( ! empty( $avail_roles['none'] ) ) { - $current_link_attributes = ''; - - if ( 'none' === $role ) { - $current_link_attributes = ' class="current" aria-current="page"'; - } - $name = __( 'No role' ); $name = sprintf( /* translators: 1: User role name, 2: Number of users. */ @@ -257,14 +251,18 @@ number_format_i18n( $avail_roles['none'] ) ); - $role_links['none'] = "$name"; + $role_links['none'] = array( + 'url' => esc_url( add_query_arg( 'role', 'none', $url ) ), + 'label' => $name, + 'current' => 'none' === $role, + ); } - return $role_links; + return $this->get_views_links( $role_links ); } /** - * Retrieve an associative array of bulk actions available on this table. + * Retrieves an associative array of bulk actions available on this table. * * @since 3.1.0 * @@ -292,7 +290,7 @@ } /** - * Output the controls to allow user roles to be changed in bulk. + * Outputs the controls to allow user roles to be changed in bulk. * * @since 3.1.0 * @@ -305,7 +303,12 @@ ?>
has_items() ) : ?> - + ', 'username' => __( 'Username' ), 'name' => __( 'Name' ), @@ -375,30 +378,30 @@ ); if ( $this->is_site_users ) { - unset( $c['posts'] ); + unset( $columns['posts'] ); } - return $c; + return $columns; } /** - * Get a list of sortable columns for the list table. + * Gets a list of sortable columns for the list table. * * @since 3.1.0 * * @return array Array of sortable columns. */ protected function get_sortable_columns() { - $c = array( - 'username' => 'login', - 'email' => 'email', + $columns = array( + 'username' => array( 'login', false, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ), + 'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ), ); - return $c; + return $columns; } /** - * Generate the list table rows. + * Generates the list table rows. * * @since 3.1.0 */ @@ -414,7 +417,7 @@ } /** - * Generate HTML for a single row on the users.php admin panel. + * Generates HTML for a single row on the users.php admin panel. * * @since 3.1.0 * @since 4.2.0 The `$style` parameter was deprecated. @@ -499,6 +502,7 @@ // Add a link to send the user a reset password link by email. if ( get_current_user_id() !== $user_object->ID && current_user_can( 'edit_user', $user_object->ID ) + && true === wp_is_password_reset_allowed_for_user( $user_object ) ) { $actions['resetpassword'] = "" . __( 'Send password reset' ) . ''; } @@ -520,12 +524,12 @@ // Set up the checkbox (because the user is editable, otherwise it's empty). $checkbox = sprintf( - '' . - '', + '' . + '', $user_object->ID, - /* translators: %s: User login. */ - sprintf( __( 'Select %s' ), $user_object->user_login ), - $role_classes + $role_classes, + /* translators: Hidden accessibility text. %s: User login. */ + sprintf( __( 'Select %s' ), $user_object->user_login ) ); } else { @@ -537,7 +541,7 @@ // Comma-separated list of user roles. $roles_list = implode( ', ', $user_roles ); - $r = ""; + $row = ""; list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); @@ -559,47 +563,53 @@ $attributes = "class='$classes' $data"; if ( 'cb' === $column_name ) { - $r .= "$checkbox"; + $row .= "$checkbox"; } else { - $r .= ""; + $row .= ""; switch ( $column_name ) { case 'username': - $r .= "$avatar $edit"; + $row .= "$avatar $edit"; break; case 'name': if ( $user_object->first_name && $user_object->last_name ) { - $r .= "$user_object->first_name $user_object->last_name"; + $row .= sprintf( + /* translators: 1: User's first name, 2: Last name. */ + _x( '%1$s %2$s', 'Display name based on first name and last name' ), + $user_object->first_name, + $user_object->last_name + ); } elseif ( $user_object->first_name ) { - $r .= $user_object->first_name; + $row .= $user_object->first_name; } elseif ( $user_object->last_name ) { - $r .= $user_object->last_name; + $row .= $user_object->last_name; } else { - $r .= sprintf( + $row .= sprintf( '%s', + /* translators: Hidden accessibility text. */ _x( 'Unknown', 'name' ) ); } break; case 'email': - $r .= "$email"; + $row .= "$email"; break; case 'role': - $r .= esc_html( $roles_list ); + $row .= esc_html( $roles_list ); break; case 'posts': if ( $numposts > 0 ) { - $r .= sprintf( + $row .= sprintf( '%s', "edit.php?author={$user_object->ID}", $numposts, sprintf( - /* translators: %s: Number of posts. */ + /* translators: Hidden accessibility text. %s: Number of posts. */ _n( '%s post by this author', '%s posts by this author', $numposts ), number_format_i18n( $numposts ) ) ); } else { - $r .= 0; + $row .= 0; } break; default: @@ -612,18 +622,18 @@ * @param string $column_name Column name. * @param int $user_id ID of the currently-listed user. */ - $r .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID ); + $row .= apply_filters( 'manage_users_custom_column', '', $column_name, $user_object->ID ); } if ( $primary === $column_name ) { - $r .= $this->row_actions( $actions ); + $row .= $this->row_actions( $actions ); } - $r .= ''; + $row .= ''; } } - $r .= ''; + $row .= ''; - return $r; + return $row; } /** @@ -670,5 +680,4 @@ */ return apply_filters( 'get_role_list', $role_list, $user_object ); } - }