diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/class-wp-users-list-table.php --- a/wp/wp-admin/includes/class-wp-users-list-table.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/class-wp-users-list-table.php Tue Dec 15 13:49:49 2020 +0100 @@ -137,7 +137,7 @@ */ $args = apply_filters( 'users_list_table_query_args', $args ); - // Query the user IDs for this page + // Query the user IDs for this page. $wp_user_search = new WP_User_Query( $args ); $this->items = $wp_user_search->get_results(); @@ -166,11 +166,11 @@ * Provides a list of roles and user count for that role for easy * Filtersing of the user table. * - * @since 3.1.0 + * @since 3.1.0 * * @global string $role * - * @return array An array of HTML links, one for each view. + * @return string[] An array of HTML links keyed by their view. */ protected function get_views() { global $role; @@ -194,7 +194,22 @@ $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : ''; $role_links = array(); - $role_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; + $role_links['all'] = sprintf( + '%s', + $url, + $current_link_attributes, + sprintf( + /* translators: %s: Number of users. */ + _nx( + 'All (%s)', + 'All (%s)', + $total_users, + 'users' + ), + number_format_i18n( $total_users ) + ) + ); + foreach ( $wp_roles->get_names() as $this_role => $name ) { if ( ! isset( $avail_roles[ $this_role ] ) ) { continue; @@ -207,8 +222,13 @@ } $name = translate_user_role( $name ); - /* translators: User role name with count */ - $name = sprintf( __( '%1$s (%2$s)' ), $name, number_format_i18n( $avail_roles[ $this_role ] ) ); + $name = sprintf( + /* translators: 1: User role name, 2: Number of users. */ + __( '%1$s (%2$s)' ), + $name, + number_format_i18n( $avail_roles[ $this_role ] ) + ); + $role_links[ $this_role ] = "$name"; } @@ -221,10 +241,14 @@ } $name = __( 'No role' ); - /* translators: User role name with count */ - $name = sprintf( __( '%1$s (%2$s)' ), $name, number_format_i18n( $avail_roles['none'] ) ); + $name = sprintf( + /* translators: 1: User role name, 2: Number of users. */ + __( '%1$s (%2$s)' ), + $name, + number_format_i18n( $avail_roles['none'] ) + ); + $role_links['none'] = "$name"; - } return $role_links; @@ -233,9 +257,9 @@ /** * Retrieve an associative array of bulk actions available on this table. * - * @since 3.1.0 + * @since 3.1.0 * - * @return array Array of bulk actions. + * @return string[] Array of bulk action labels keyed by their action. */ protected function get_bulk_actions() { $actions = array(); @@ -306,7 +330,7 @@ * Overridden from the base class implementation to capture * the role change drop-down. * - * @since 3.1.0 + * @since 3.1.0 * * @return string The bulk action required. */ @@ -322,10 +346,9 @@ /** * Get a list of columns for the list table. * - * @since 3.1.0 + * @since 3.1.0 * - * @return array Array in which the key is the ID of the column, - * and the value is the description. + * @return string[] Array of column titles keyed by their column name. */ public function get_columns() { $c = array( @@ -366,7 +389,7 @@ * @since 3.1.0 */ public function display_rows() { - // Query the post counts for this page + // Query the post counts for this page. if ( ! $this->is_site_users ) { $post_counts = count_many_users_posts( array_keys( $this->items ) ); } @@ -405,7 +428,7 @@ $user_roles = $this->get_role_list( $user_object ); - // Set up the hover actions for this user + // Set up the hover actions for this user. $actions = array(); $checkbox = ''; $super_admin = ''; @@ -416,9 +439,9 @@ } } - // Check if the user for this row is editable + // Check if the user for this row is editable. if ( current_user_can( 'list_users' ) ) { - // Set up the user editing link + // Set up the user editing link. $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) ); if ( current_user_can( 'edit_user', $user_object->ID ) ) { @@ -431,7 +454,7 @@ if ( ! is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) { $actions['delete'] = "" . __( 'Delete' ) . ''; } - if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) { + if ( is_multisite() && current_user_can( 'remove_user', $user_object->ID ) ) { $actions['remove'] = "" . __( 'Remove' ) . ''; } @@ -441,7 +464,7 @@ $actions['view'] = sprintf( '%s', esc_url( $author_posts_url ), - /* translators: %s: author's display name */ + /* translators: %s: Author's display name. */ esc_attr( sprintf( __( 'View posts by %s' ), $user_object->display_name ) ), __( 'View' ) ); @@ -462,13 +485,20 @@ // Role classes. $role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) ); - // Set up the checkbox ( because the user is editable, otherwise it's empty ) - $checkbox = '' - . ""; + // 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 + ); } else { $edit = "{$user_object->user_login}{$super_admin}"; } + $avatar = get_avatar( $user_object->ID, 32 ); // Comma-separated list of user roles. @@ -484,10 +514,10 @@ $classes .= ' has-row-actions column-primary'; } if ( 'posts' === $column_name ) { - $classes .= ' num'; // Special case for that column + $classes .= ' num'; // Special case for that column. } - if ( in_array( $column_name, $hidden ) ) { + if ( in_array( $column_name, $hidden, true ) ) { $classes .= ' hidden'; } @@ -511,7 +541,10 @@ } elseif ( $user_object->last_name ) { $r .= $user_object->last_name; } else { - $r .= '' . _x( 'Unknown', 'name' ) . ''; + $r .= sprintf( + '%s', + _x( 'Unknown', 'name' ) + ); } break; case 'email': @@ -522,10 +555,16 @@ break; case 'posts': if ( $numposts > 0 ) { - $r .= ""; - $r .= ''; - $r .= '' . sprintf( _n( '%s post by this author', '%s posts by this author', $numposts ), number_format_i18n( $numposts ) ) . ''; - $r .= ''; + $r .= sprintf( + '%s', + "edit.php?author={$user_object->ID}", + $numposts, + sprintf( + /* translators: %s: Number of posts. */ + _n( '%s post by this author', '%s posts by this author', $numposts ), + number_format_i18n( $numposts ) + ) + ); } else { $r .= 0; }