WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/03/2010 07:08:30 PM (12 years ago)
Author:
ryan
Message:

Improve user listing performance. Props miqrogroove. see #11914

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/users.php

    r12916 r13576  
    209209    $role = isset($_GET['role']) ? $_GET['role'] : null;
    210210
    211     // Query the users
     211    // Query the user IDs for this page
    212212    $wp_user_search = new WP_User_Search($usersearch, $userspage, $role);
     213
     214    // Query the post counts for this page
     215    $post_counts = count_many_users_posts($wp_user_search->get_results());
     216
     217    // Query the users for this page
     218    cache_users($wp_user_search->get_results());
    213219
    214220    $messages = array();
     
    264270<ul class="subsubsub">
    265271<?php
    266 $role_links = array();
    267 $avail_roles = array();
    268 $users_of_blog = get_users_of_blog();
    269 $total_users = count( $users_of_blog );
    270 foreach ( (array) $users_of_blog as $b_user ) {
    271     $b_roles = unserialize($b_user->meta_value);
    272     foreach ( (array) $b_roles as $b_role => $val ) {
    273         if ( !isset($avail_roles[$b_role]) )
    274             $avail_roles[$b_role] = 0;
    275         $avail_roles[$b_role]++;
    276     }
    277 }
     272$users_of_blog = count_users();
     273$total_users = $users_of_blog['total_users'];
     274$avail_roles =& $users_of_blog['avail_roles'];
    278275unset($users_of_blog);
    279276
    280277$current_role = false;
    281278$class = empty($role) ? ' class="current"' : '';
     279$role_links = array();
    282280$role_links[] = "<li><a href='users.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
    283281foreach ( $wp_roles->get_names() as $this_role => $name ) {
     
    373371
    374372    $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
    375     echo "\n\t" . user_row($user_object, $style, $role);
     373    echo "\n\t", user_row($user_object, $style, $role, $post_counts[(string)$userid]);
    376374}
    377375?>
Note: See TracChangeset for help on using the changeset viewer.