From 368f0c38629930e99ca1cff4ae9e4a20c79325aa Mon Sep 17 00:00:00 2001
From: Florian TIAR <contact@tiar-florian.fr>
Date: Tue, 27 Sep 2016 18:38:07 +0200
Subject: [PATCH] Add first username and link to all username of a site in wp
admin list sites (multisite)
---
wp-admin/includes/class-wp-ms-sites-list-table.php | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/wp-admin/includes/class-wp-ms-sites-list-table.php b/wp-admin/includes/class-wp-ms-sites-list-table.php
index 9ce3ffe..9d61008 100644
a
|
b
|
class WP_MS_Sites_List_Table extends WP_List_Table { |
388 | 388 | * Handles the users column output. |
389 | 389 | * |
390 | 390 | * @since 4.3.0 |
| 391 | * @since 4.7.0 Display First user of the site, and number of users in the site |
391 | 392 | * @access public |
392 | 393 | * |
393 | 394 | * @param array $blog Current site. |
394 | 395 | */ |
395 | 396 | public function column_users( $blog ) { |
| 397 | $blog_users = get_users( array( 'blog_id' => $blog['blog_id'] ) ); |
396 | 398 | $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' ); |
397 | 399 | if ( ! $user_count ) { |
398 | | $blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) ); |
399 | 400 | $user_count = count( $blog_users ); |
400 | | unset( $blog_users ); |
401 | 401 | wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS ); |
402 | 402 | } |
403 | 403 | |
404 | 404 | printf( |
405 | 405 | '<a href="%s">%s</a>', |
406 | | esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ), |
407 | | number_format_i18n( $user_count ) |
| 406 | esc_url( network_admin_url( 'user-edit.php?user_id=' . $blog_users[0]->ID ) ), |
| 407 | $blog_users[0]->user_login |
408 | 408 | ); |
| 409 | |
| 410 | if ( $user_count > 1 ) { |
| 411 | printf( '<a href="%s">%s</a>', |
| 412 | esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ), |
| 413 | sprintf( |
| 414 | _x( '+ %s more users', 'Number of users of a site of a network (in admin page : wp-admin/network/sites.php)' ), |
| 415 | number_format_i18n( $user_count ) |
| 416 | ) |
| 417 | ); |
| 418 | } |
| 419 | |
| 420 | unset( $blog_users ); |
409 | 421 | } |
410 | 422 | |
411 | 423 | /** |