Ticket #19765: 19765.patch
File 19765.patch, 2.8 KB (added by , 11 years ago) |
---|
-
class-wp-users-list-table.php
33 33 } 34 34 35 35 function prepare_items() { 36 global $role, $ usersearch;36 global $role, $wp_roles, $usersearch; 37 37 38 38 $usersearch = isset( $_REQUEST['s'] ) ? trim( $_REQUEST['s'] ) : ''; 39 39 … … 64 64 if ( isset( $_REQUEST['order'] ) ) 65 65 $args['order'] = $_REQUEST['order']; 66 66 67 if ( $this->is_site_users ) 68 switch_to_blog( $this->site_id ); 69 67 70 // Query the user IDs for this page 68 71 $wp_user_search = new WP_User_Query( $args ); 69 72 70 73 $this->items = $wp_user_search->get_results(); 74 $this->users_of_blog = count_users(); 75 $this->role_names = $wp_roles->get_names(); 71 76 77 if ( $this->is_site_users ) 78 restore_current_blog(); 79 72 80 $this->set_pagination_args( array( 73 81 'total_items' => $wp_user_search->get_total(), 74 82 'per_page' => $users_per_page, … … 80 88 } 81 89 82 90 function get_views() { 83 global $ wp_roles, $role;91 global $role; 84 92 85 93 if ( $this->is_site_users ) { 86 94 $url = 'site-users.php?id=' . $this->site_id; 87 switch_to_blog( $this->site_id );88 $users_of_blog = count_users();89 restore_current_blog();90 95 } else { 91 96 $url = 'users.php'; 92 $users_of_blog = count_users();93 97 } 94 $total_users = $ users_of_blog['total_users'];95 $avail_roles =& $ users_of_blog['avail_roles'];96 unset( $users_of_blog);98 $total_users = $this->users_of_blog[ 'total_users' ]; 99 $avail_roles =& $this->users_of_blog[ 'avail_roles' ]; 100 unset( $this->users_of_blog ); 97 101 98 102 $current_role = false; 99 103 $class = empty($role) ? ' class="current"' : ''; 100 104 $role_links = array(); 101 105 $role_links['all'] = "<a href='$url'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>'; 102 foreach ( $ wp_roles->get_names()as $this_role => $name ) {106 foreach ( $this->role_names as $this_role => $name ) { 103 107 if ( !isset($avail_roles[$this_role]) ) 104 108 continue; 105 109 … … 225 229 * @return string 226 230 */ 227 231 function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) { 228 global $wp_roles;229 232 230 233 if ( !( is_object( $user_object ) && is_a( $user_object, 'WP_User' ) ) ) 231 234 $user_object = get_userdata( (int) $user_object ); … … 267 270 } else { 268 271 $edit = '<strong>' . $user_object->user_login . '</strong>'; 269 272 } 270 $role_name = isset( $ wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' );273 $role_name = isset( $this->role_names[$role] ) ? translate_user_role( $this->role_names[$role] ) : __( 'None' ); 271 274 $avatar = get_avatar( $user_object->ID, 32 ); 272 275 273 276 $r = "<tr id='user-$user_object->ID'$style>";