Make WordPress Core

Ticket #17025: 17025.6.diff

File 17025.6.diff, 1.5 KB (added by DrewAPicture, 11 years ago)

refresh

  • src/wp-includes/author-template.php

     
    350350        $return = '';
    351351
    352352        $query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );
    353         $query_args['fields'] = 'ids';
    354         $authors = get_users( $query_args );
    355353
    356354        $author_count = array();
    357         foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author" ) as $row ) {
     355
     356        $rows = $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author" );
     357
     358        foreach ( $rows as $row ) {
    358359                $author_count[$row->post_author] = $row->count;
    359360        }
     361
     362        if ( $hide_empty ) {
     363                $query_args['include'] = wp_list_pluck( $rows, 'post_author' );
     364        } else {
     365                $query_args['fields'] = 'ids';
     366        }
     367
     368        /**
     369         * Filter the found list of authors.
     370         *
     371         * @since 4.0.0
     372         *
     373         * @param array $authors    Array of WP_User objects for found authors.
     374         * @param array $query_args User query arguments.
     375         */
     376        $authors = apply_filters( 'wp_list_authors', get_users( $query_args ), $query_args );
     377
    360378        foreach ( $authors as $author_id ) {
    361379                $author = get_userdata( $author_id );
    362380