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: http://svn.automattic.com/wordpress/trunk@15876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
669a403b55
commit
c7811f19b3
|
@ -2958,7 +2958,7 @@ class WP_Sites_Table extends WP_List_Table {
|
|||
case 'users': ?>
|
||||
<td valign="top">
|
||||
<?php
|
||||
$blogusers = get_users_of_blog( $blog['blog_id'] );
|
||||
$blogusers = get_users_of_blog( $blog['blog_id'], array('number' => 6) );
|
||||
if ( is_array( $blogusers ) ) {
|
||||
$blogusers_warning = '';
|
||||
if ( count( $blogusers ) > 5 ) {
|
||||
|
|
|
@ -257,13 +257,14 @@ switch ( $action ) {
|
|||
<?php }
|
||||
|
||||
// Site users
|
||||
$blogusers = get_users_of_blog( $id );
|
||||
|
||||
$blogusers = get_users_of_blog( $id, array('number' => 20) );
|
||||
if ( is_array( $blogusers ) ) {
|
||||
echo '<div id="blogedit_blogusers" class="postbox"><h3 class="hndle"><span>' . __( 'Site Users' ) . '</span></h3><div class="inside">';
|
||||
echo '<table class="form-table">';
|
||||
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 ) {
|
||||
$user_count++;
|
||||
$existing_role = reset( $user_object->roles );
|
||||
|
||||
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 '<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>";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
function get_users_of_blog( $id = '' ) {
|
||||
function get_users_of_blog( $id = '', $args = array() ) {
|
||||
global $blog_id;
|
||||
|
||||
if ( empty($id) )
|
||||
$id = (int) $blog_id;
|
||||
|
||||
return get_users( array( 'blog_id' => $id ) );
|
||||
$args['blog_id'] = $id;
|
||||
return get_users( $args );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue