Improve information displayed in a network's sites list table
* Better support for arbitrary domain/path combinations by displaying the URL in the primary column rather than Path or Domain. * Show a cached count of total users per site as a more useful data point rather than the first 5 users. * Clear that cached count of users for a site when a user is added to the site via `add_user_to_blog()`. Props @ocean90. Fixes #32434. Built from https://develop.svn.wordpress.org/trunk@32718 git-svn-id: http://core.svn.wordpress.org/trunk@32688 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
005d937ce2
commit
93ff65e677
|
@ -259,7 +259,7 @@ table.fixed {
|
|||
}
|
||||
|
||||
.fixed .column-posts {
|
||||
width: 74px;
|
||||
width: 74px;
|
||||
}
|
||||
|
||||
.fixed .column-comment .comment-author {
|
||||
|
@ -1510,6 +1510,15 @@ div.action-links,
|
|||
background: #fecac2;
|
||||
}
|
||||
|
||||
.sites.fixed .column-lastupdated,
|
||||
.sites.fixed .column-registered {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.sites.fixed .column-users {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
/* =Media Queries
|
||||
-------------------------------------------------------------- */
|
||||
|
||||
|
|
|
@ -259,7 +259,7 @@ table.fixed {
|
|||
}
|
||||
|
||||
.fixed .column-posts {
|
||||
width: 74px;
|
||||
width: 74px;
|
||||
}
|
||||
|
||||
.fixed .column-comment .comment-author {
|
||||
|
@ -1510,6 +1510,15 @@ div.action-links,
|
|||
background: #fecac2;
|
||||
}
|
||||
|
||||
.sites.fixed .column-lastupdated,
|
||||
.sites.fixed .column-registered {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.sites.fixed .column-users {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
/* =Media Queries
|
||||
-------------------------------------------------------------- */
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -111,10 +111,11 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
} elseif ( $order_by == 'lastupdated' ) {
|
||||
$query .= ' ORDER BY last_updated ';
|
||||
} elseif ( $order_by == 'blogname' ) {
|
||||
if ( is_subdomain_install() )
|
||||
if ( is_subdomain_install() ) {
|
||||
$query .= ' ORDER BY domain ';
|
||||
else
|
||||
} else {
|
||||
$query .= ' ORDER BY path ';
|
||||
}
|
||||
} elseif ( $order_by == 'blog_id' ) {
|
||||
$query .= ' ORDER BY blog_id ';
|
||||
} else {
|
||||
|
@ -182,17 +183,17 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
* @return array
|
||||
*/
|
||||
public function get_columns() {
|
||||
$blogname_columns = ( is_subdomain_install() ) ? __( 'Domain' ) : __( 'Path' );
|
||||
$sites_columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'blogname' => $blogname_columns,
|
||||
'blogname' => __( 'URL' ),
|
||||
'lastupdated' => __( 'Last Updated' ),
|
||||
'registered' => _x( 'Registered', 'site' ),
|
||||
'users' => __( 'Users' )
|
||||
'users' => __( 'Users' ),
|
||||
);
|
||||
|
||||
if ( has_filter( 'wpmublogsaction' ) )
|
||||
if ( has_filter( 'wpmublogsaction' ) ) {
|
||||
$sites_columns['plugins'] = __( 'Actions' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the displayed site columns in Sites list table.
|
||||
|
@ -261,7 +262,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
}
|
||||
echo "<tr{$class}>";
|
||||
|
||||
$blogname = ( is_subdomain_install() ) ? str_replace( '.' . get_current_site()->domain, '', $blog['domain'] ) : $blog['path'];
|
||||
$blogname = $blog['domain'] . $blog['path'];
|
||||
|
||||
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
|
||||
|
||||
|
@ -322,22 +323,18 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
break;
|
||||
|
||||
case 'users':
|
||||
$blogusers = get_users( array( 'blog_id' => $blog['blog_id'], 'number' => 6) );
|
||||
if ( is_array( $blogusers ) ) {
|
||||
$blogusers_warning = '';
|
||||
if ( count( $blogusers ) > 5 ) {
|
||||
$blogusers = array_slice( $blogusers, 0, 5 );
|
||||
$blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'More' ) . '</a>';
|
||||
}
|
||||
foreach ( $blogusers as $user_object ) {
|
||||
echo '<a href="' . esc_url( network_admin_url( 'user-edit.php?user_id=' . $user_object->ID ) ) . '">' . esc_html( $user_object->user_login ) . '</a> ';
|
||||
if ( 'list' != $mode )
|
||||
echo '( ' . $user_object->user_email . ' )';
|
||||
echo '<br />';
|
||||
}
|
||||
if ( $blogusers_warning != '' )
|
||||
echo '<strong>' . $blogusers_warning . '</strong><br />';
|
||||
if ( ! $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' ) ) {
|
||||
$blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) );
|
||||
$user_count = count( $blog_users );
|
||||
unset( $blog_users );
|
||||
wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
|
||||
}
|
||||
|
||||
printf(
|
||||
'<a href="%s">%s</a>',
|
||||
esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
|
||||
number_format_i18n( $user_count )
|
||||
);
|
||||
break;
|
||||
|
||||
case 'plugins':
|
||||
|
|
|
@ -204,6 +204,7 @@ function add_user_to_blog( $blog_id, $user_id, $role ) {
|
|||
*/
|
||||
do_action( 'add_user_to_blog', $user_id, $role, $blog_id );
|
||||
wp_cache_delete( $user_id, 'users' );
|
||||
wp_cache_delete( $blog_id . '_user_count', 'blog-details' );
|
||||
restore_current_blog();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.3-alpha-32717';
|
||||
$wp_version = '4.3-alpha-32718';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue