Ticket #22993: 22993.3.diff
File 22993.3.diff, 3.4 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/class-wp-users-list-table.php
87 87 88 88 $paged = $this->get_pagenum(); 89 89 90 $args = array( 91 'number' => $users_per_page, 92 'offset' => ( $paged-1 ) * $users_per_page, 93 'role' => $role, 94 'search' => $usersearch, 95 'fields' => 'all_with_meta' 96 ); 90 if ( 'none' === $role ) { 91 $args = array( 92 'number' => $users_per_page, 93 'offset' => ( $paged-1 ) * $users_per_page, 94 'include' => wp_get_norole_users(), 95 'search' => $usersearch, 96 'fields' => 'all_with_meta' 97 ); 98 } else { 99 $args = array( 100 'number' => $users_per_page, 101 'offset' => ( $paged-1 ) * $users_per_page, 102 'role' => $role, 103 'search' => $usersearch, 104 'fields' => 'all_with_meta' 105 ); 106 } 97 107 98 108 if ( '' !== $args['search'] ) 99 109 $args['search'] = '*' . $args['search'] . '*'; … … 156 166 $url = 'users.php'; 157 167 $users_of_blog = count_users(); 158 168 } 169 159 170 $total_users = $users_of_blog['total_users']; 160 171 $avail_roles =& $users_of_blog['avail_roles']; 161 172 unset($users_of_blog); … … 179 190 $role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$class>$name</a>"; 180 191 } 181 192 193 if ( ! empty( $avail_roles['none' ] ) ) { 194 195 $class = ''; 196 197 if ( 'none' === $role ) { 198 $class = ' class="current"'; 199 } 200 201 $name = __( 'No role' ); 202 /* translators: User role name with count */ 203 $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) ); 204 $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$class>$name</a>"; 205 206 } 207 182 208 return $role_links; 183 209 } 184 210 -
src/wp-includes/user-functions.php
775 775 // Get the meta_value index from the end of the result set. 776 776 $total_users = (int) $row[$col]; 777 777 778 $role_counts['none'] = ( $total_users - array_sum( $role_counts ) ); 779 778 780 $result['total_users'] = $total_users; 779 781 $result['avail_roles'] =& $role_counts; 780 782 } else { … … 786 788 $b_roles = maybe_unserialize($caps_meta); 787 789 if ( ! is_array( $b_roles ) ) 788 790 continue; 791 if ( empty( $b_roles ) ) { 792 if ( isset( $avail_roles['none'] ) ) { 793 $avail_roles['none']++; 794 } else { 795 $avail_roles['none'] = 1; 796 } 797 } 789 798 foreach ( $b_roles as $b_role => $val ) { 790 799 if ( isset($avail_roles[$b_role]) ) { 791 800 $avail_roles[$b_role]++; … … 2143 2152 $manager = WP_Session_Tokens::get_instance( get_current_user_id() ); 2144 2153 $manager->destroy_all(); 2145 2154 } 2155 2156 /** 2157 * Get the user IDs of all users with no role on this site. 2158 * 2159 * @since 4.4.0 2160 * 2161 * @return array Array of user IDs. 2162 */ 2163 function wp_get_norole_users() { 2164 global $wpdb; 2165 $wp_roles = wp_roles(); 2166 $blog_prefix = $wpdb->get_blog_prefix(); 2167 $norole_regexp = implode( '|', array_keys( $wp_roles->get_names() ) ); 2168 $norole_users = $wpdb->get_col( $wpdb->prepare( " 2169 SELECT user_id 2170 FROM $wpdb->usermeta 2171 WHERE meta_key = '{$blog_prefix}capabilities' 2172 AND meta_value NOT REGEXP %s 2173 ", $norole_regexp ) ); 2174 return $norole_users; 2175 }