Make WordPress Core

Ticket #17025: 17025.5.diff

File 17025.5.diff, 1.5 KB (added by DrewAPicture, 10 years ago)

refresh

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

     
    342342        $return = '';
    343343
    344344        $query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );
    345         $query_args['fields'] = 'ids';
    346         $authors = get_users( $query_args );
    347345
    348346        $author_count = array();
    349         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 )
     347        $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" );
     348
     349        foreach ( (array) $rows as $row ) {
    350350                $author_count[$row->post_author] = $row->count;
     351        }
    351352
     353        if ( $hide_empty ) {
     354                $query_args['include'] = wp_list_pluck( $rows, 'post_author' );
     355        } else {
     356                $query_args['fields'] = 'ids';
     357        }
     358
     359        /**
     360         * Filter the list of found authors.
     361         *
     362         * @since 4.0.0
     363         *
     364         * @param array $authors    Array of WP_User objects for found authors.
     365         * @param array $query_args User query arguments.
     366         */
     367        $authors = apply_filters( 'wp_list_authors', get_users( $query_args ), $query_args );
     368
    352369        foreach ( $authors as $author_id ) {
    353370                $author = get_userdata( $author_id );
    354371