WordPress.org

Make WordPress Core

Ticket #23498: 23498.5.diff

File 23498.5.diff, 2.5 KB (added by SergeyBiryukov, 8 months ago)
  • src/wp-includes/author-template.php

     
    379379 * @link https://developer.wordpress.org/reference/functions/wp_list_authors/
    380380 *
    381381 * @since 1.2.0
     382 * @since 5.3.0 The `$exclude_admin` parameter was updated to exclude all administrators.
    382383 *
    383384 * @global wpdb $wpdb WordPress database abstraction object.
    384385 *
     
    391392 *     @type string       $order         Sorting direction for $orderby. Accepts 'ASC', 'DESC'. Default 'ASC'.
    392393 *     @type int          $number        Maximum authors to return or display. Default empty (all authors).
    393394 *     @type bool         $optioncount   Show the count in parenthesis next to the author's name. Default false.
    394  *     @type bool         $exclude_admin Whether to exclude the 'admin' account, if it exists. Default true.
     395 *     @type bool         $exclude_admin Whether to exclude administrator accounts. Default true.
    395396 *     @type bool         $show_fullname Whether to show the author's full name. Default false.
    396397 *     @type bool         $hide_empty    Whether to hide any authors with no posts. Default true.
    397398 *     @type string       $feed          If not empty, show a link to the author's feed and use this text as the alt
     
    434435
    435436        $return = '';
    436437
    437         $query_args           = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );
    438         $query_args['fields'] = 'ids';
    439         $authors              = get_users( $query_args );
     438        $query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );
    440439
     440        $query_args['fields'] = 'ID';
     441
     442        if ( $args['exclude_admin'] ) {
     443                $query_args['exclude'] = get_users( array(
     444                        'role'   => 'administrator',
     445                        'fields' => 'ID',
     446                ) );
     447        }
     448
     449        $authors = get_users( $query_args );
     450
    441451        $author_count = array();
    442452        foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . ' GROUP BY post_author' ) as $row ) {
    443453                $author_count[ $row->post_author ] = $row->count;
     
    451461
    452462                $author = get_userdata( $author_id );
    453463
    454                 if ( $args['exclude_admin'] && 'admin' === $author->display_name ) {
    455                         continue;
    456                 }
    457 
    458464                if ( $args['show_fullname'] && $author->first_name && $author->last_name ) {
    459465                        $name = "$author->first_name $author->last_name";
    460466                } else {