Make WordPress Core

Ticket #4323: wp_list_authors.diff

File wp_list_authors.diff, 1.4 KB (added by markjaquith, 16 years ago)

patch for trunk

  • wp-includes/author-template.php

     
    178178        $defaults = array(
    179179                'optioncount' => false, 'exclude_admin' => true,
    180180                'show_fullname' => false, 'hide_empty' => true,
    181                 'feed' => '', 'feed_image' => ''
     181                'feed' => '', 'feed_image' => '', 'echo' => true
    182182        );
    183        
     183
    184184        $r = wp_parse_args( $args, $defaults );
    185185        extract($r);
    186        
     186
     187        $return = '';
     188
    187189        // TODO:  Move select to get_authors().
    188190        $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
    189        
     191
    190192        $author_count = array();
    191193        foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_status = 'publish' GROUP BY post_author") as $row) {
    192194                $author_count[$row->post_author] = $row->count;
     
    201203                        $name = "$author->first_name $author->last_name";
    202204
    203205                if ( !($posts == 0 && $hide_empty) )
    204                         echo "<li>";
     206                        $return .= '<li>';
    205207                if ( $posts == 0 ) {
    206208                        if ( !$hide_empty )
    207209                                $link = $name;
     
    240242                }
    241243
    242244                if ( !($posts == 0 && $hide_empty) )
    243                         echo "$link</li>";
     245                        $return .= $link . '</li>';
    244246        }
     247        if ( !$echo )
     248                return $return;
     249        echo $return;
    245250}
    246251
    247252?>
     253 No newline at end of file