Ticket #36196: 36196.2.diff
| File 36196.2.diff, 3.3 KB (added by , 10 years ago) |
|---|
-
src/wp-admin/includes/class-wp-users-list-table.php
98 98 $args = array( 99 99 'number' => $users_per_page, 100 100 'offset' => ( $paged-1 ) * $users_per_page, 101 'include' => wp_get_users_with_no_role( ),101 'include' => wp_get_users_with_no_role( $this->site_id ), 102 102 'search' => $usersearch, 103 103 'fields' => 'all_with_meta' 104 104 ); … … 177 177 if ( $this->is_site_users ) { 178 178 $url = 'site-users.php?id=' . $this->site_id; 179 179 switch_to_blog( $this->site_id ); 180 $users_of_blog = count_users( );180 $users_of_blog = count_users( 'time', $this->site_id ); 181 181 restore_current_blog(); 182 182 } else { 183 183 $url = 'users.php'; … … 354 354 $post_counts = count_many_users_posts( array_keys( $this->items ) ); 355 355 356 356 foreach ( $this->items as $userid => $user_object ) { 357 if ( is_multisite() && empty( $user_object->allcaps ) )358 continue;359 360 357 echo "\n\t" . $this->single_row( $user_object, '', '', isset( $post_counts ) ? $post_counts[ $userid ] : 0 ); 361 358 } 362 359 } -
src/wp-includes/user.php
826 826 * 827 827 * @since 3.0.0 828 828 * @since 4.4.0 The number of users with no role is now included in the `none` element. 829 * @since 4.6.0 The `$site_id` parameter was added to support multisite. 829 830 * 830 831 * @global wpdb $wpdb WordPress database abstraction object. 831 832 * 832 * @param string $strategy 'time' or 'memory' 833 * @param string $strategy 'time' or 'memory' 834 * @param int|null $site_id Optional. The site ID to count users for. Defaults to the current site. 835 * 833 836 * @return array Includes a grand total and an array of counts indexed by role strings. 834 837 */ 835 function count_users( $strategy = 'time') {838 function count_users( $strategy = 'time', $site_id = null ) { 836 839 global $wpdb; 837 840 838 841 // Initialize 839 $id = get_current_blog_id(); 840 $blog_prefix = $wpdb->get_blog_prefix($id); 842 if ( ! $site_id ) { 843 $site_id = get_current_blog_id(); 844 } 845 $blog_prefix = $wpdb->get_blog_prefix( $site_id ); 841 846 $result = array(); 842 847 843 848 if ( 'time' == $strategy ) { … … 898 903 $result['avail_roles'] =& $avail_roles; 899 904 } 900 905 901 if ( is_multisite() ) {902 $result['avail_roles']['none'] = 0;903 }904 905 906 return $result; 906 907 } 907 908 … … 2406 2407 /** 2407 2408 * Get the user IDs of all users with no role on this site. 2408 2409 * 2409 * This function returns an empty array when used on Multisite.2410 *2411 2410 * @since 4.4.0 2411 * @since 4.6.0 The `$site_id` parameter was added to support multisite. 2412 2412 * 2413 * @param int|null $site_id Optional. The site ID to get users with no role for. Defaults to the current site. 2414 * 2413 2415 * @return array Array of user IDs. 2414 2416 */ 2415 function wp_get_users_with_no_role( ) {2417 function wp_get_users_with_no_role( $site_id = null ) { 2416 2418 global $wpdb; 2417 2419 2418 if ( is_multisite()) {2419 return array();2420 if ( ! $site_id ) { 2421 $site_id = get_current_blog_id(); 2420 2422 } 2421 2423 2422 $prefix = $wpdb->get_blog_prefix( );2424 $prefix = $wpdb->get_blog_prefix( $site_id ); 2423 2425 $regex = implode( '|', wp_roles()->get_names() ); 2424 2426 $regex = preg_replace( '/[^a-zA-Z_\|-]/', '', $regex ); 2425 2427 $users = $wpdb->get_col( $wpdb->prepare( "