diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php index 1176302b01..6edc5e91d6 100644 --- a/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/wp-admin/includes/class-wp-ms-users-list-table.php @@ -23,12 +23,14 @@ class WP_MS_Users_List_Table extends WP_List_Table { } function prepare_items() { - global $usersearch; + global $usersearch, $role, $wpdb; $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; $users_per_page = $this->get_items_per_page( 'users_network_per_page' ); + $role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : ''; + $paged = $this->get_pagenum(); $args = array( @@ -38,6 +40,11 @@ class WP_MS_Users_List_Table extends WP_List_Table { 'blog_id' => 0 ); + if ( $role == 'super' ) { + $logins = implode( "', '", get_super_admins() ); + $args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" ); + } + // If the network is large and a search is not being performed, show only the latest users with no paging in order // to avoid expensive count queries. if ( !$usersearch && ( get_blog_count() >= 10000 ) ) { @@ -78,6 +85,25 @@ class WP_MS_Users_List_Table extends WP_List_Table { _e( 'No users found.' ); } + function get_views() { + global $wp_roles, $role; + + $users_of_blog = count_users(); + $total_users = $users_of_blog['total_users']; + $super_admins = get_super_admins(); + $total_admins = count( $super_admins ); + unset($users_of_blog); + + $current_role = false; + $class = $role != 'super' ? ' class="current"' : ''; + $role_links = array(); + $role_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; + $class = $role == 'super' ? ' class="current"' : ''; + $role_links['super'] = "" . sprintf( _n( 'Super Admin (%s)', 'Super Admins (%s)', $total_admins ), number_format_i18n( $total_admins ) ) . ''; + + return $role_links; + } + function pagination( $which ) { global $mode; @@ -155,7 +181,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {