Add query args argument to get_users_of_blog(). Limit number of users fetched for user lists in sites table and edit blog form. see #15053

git-svn-id: https://develop.svn.wordpress.org/trunk@15876 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-10-20 20:43:32 +00:00
parent 4c3535a58d
commit 76b207939d
3 changed files with 10 additions and 5 deletions

View File

@ -2958,7 +2958,7 @@ class WP_Sites_Table extends WP_List_Table {
case 'users': ?> case 'users': ?>
<td valign="top"> <td valign="top">
<?php <?php
$blogusers = get_users_of_blog( $blog['blog_id'] ); $blogusers = get_users_of_blog( $blog['blog_id'], array('number' => 6) );
if ( is_array( $blogusers ) ) { if ( is_array( $blogusers ) ) {
$blogusers_warning = ''; $blogusers_warning = '';
if ( count( $blogusers ) > 5 ) { if ( count( $blogusers ) > 5 ) {

View File

@ -257,13 +257,14 @@ switch ( $action ) {
<?php } <?php }
// Site users // Site users
$blogusers = get_users_of_blog( $id ); $blogusers = get_users_of_blog( $id, array('number' => 20) );
if ( is_array( $blogusers ) ) { if ( is_array( $blogusers ) ) {
echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">'; echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">';
echo '<table class="form-table">'; echo '<table class="form-table">';
echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>"; echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>";
$user_count = 0;
foreach ( $blogusers as $user_id => $user_object ) { foreach ( $blogusers as $user_id => $user_object ) {
$user_count++;
$existing_role = reset( $user_object->roles ); $existing_role = reset( $user_object->roles );
echo '<tr><td><a href="user-edit.php?user_id=' . $user_id . '">' . $user_object->user_login . '</a></td>'; echo '<tr><td><a href="user-edit.php?user_id=' . $user_id . '">' . $user_object->user_login . '</a></td>';
@ -290,6 +291,8 @@ switch ( $action ) {
} }
echo "</table>"; echo "</table>";
echo '<p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="' . esc_attr__( 'Update Options' ) . '" /></p>'; echo '<p class="submit" style="text-align:center;"><input type="submit" name="Submit" value="' . esc_attr__( 'Update Options' ) . '" /></p>';
if ( 20 == $user_count )
echo '<p>' . sprintf( __('First 20 users shown. <a href="%s">Manage all users</a>.'), get_admin_url($id, 'users.php') ) . '</p>';
echo "</div></div>"; echo "</div></div>";
} }
?> ?>

View File

@ -563,15 +563,17 @@ function get_users( $args = array() ) {
* @uses $blog_id The Blog id of the blog for those that use more than one blog * @uses $blog_id The Blog id of the blog for those that use more than one blog
* *
* @param int $id Blog ID. * @param int $id Blog ID.
* @param array $args Optional query arguments passed to get_users()
* @return array List of users that are part of that Blog ID * @return array List of users that are part of that Blog ID
*/ */
function get_users_of_blog( $id = '' ) { function get_users_of_blog( $id = '', $args = array() ) {
global $blog_id; global $blog_id;
if ( empty($id) ) if ( empty($id) )
$id = (int) $blog_id; $id = (int) $blog_id;
return get_users( array( 'blog_id' => $id ) ); $args['blog_id'] = $id;
return get_users( $args );
} }
/** /**