Make WordPress Core

Ticket #33967: 33967.1.patch

File 33967.1.patch, 4.2 KB (added by Mista-Flo, 8 years ago)

Display first username and link to all users of a site in sites admin page

  • wp-admin/includes/class-wp-ms-sites-list-table.php

    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 { 
    388388         * Handles the users column output.
    389389         *
    390390         * @since 4.3.0
     391         * @since 4.7.0 Display First user of the site, and number of users in the site
    391392         * @access public
    392393         *
    393394         * @param array $blog Current site.
    394395         */
    395396        public function column_users( $blog ) {
     397                $blog_users = get_users( array( 'blog_id' => $blog['blog_id'] ) );
    396398                $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
    397399                if ( ! $user_count ) {
    398                         $blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) );
    399400                        $user_count = count( $blog_users );
    400                         unset( $blog_users );
    401401                        wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
    402402                }
    403403
    404404                printf(
    405405                        '<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
    408408                );
     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 );
    409421        }
    410422
    411423        /**