Allow wp_list_authors() to optionally return. fixes #4323. see #3567.

git-svn-id: http://svn.automattic.com/wordpress/trunk@5624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith 2007-06-01 05:43:24 +00:00
parent b8c26df7e0
commit 06e670d043
1 changed files with 11 additions and 6 deletions

View File

@ -178,15 +178,17 @@ function wp_list_authors($args = '') {
$defaults = array( $defaults = array(
'optioncount' => false, 'exclude_admin' => true, 'optioncount' => false, 'exclude_admin' => true,
'show_fullname' => false, 'hide_empty' => true, 'show_fullname' => false, 'hide_empty' => true,
'feed' => '', 'feed_image' => '' 'feed' => '', 'feed_image' => '', 'echo' => true
); );
$r = wp_parse_args( $args, $defaults ); $r = wp_parse_args( $args, $defaults );
extract($r); extract($r);
$return = '';
// TODO: Move select to get_authors(). // TODO: Move select to get_authors().
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name"); $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
$author_count = array(); $author_count = array();
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) { 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) {
$author_count[$row->post_author] = $row->count; $author_count[$row->post_author] = $row->count;
@ -201,7 +203,7 @@ function wp_list_authors($args = '') {
$name = "$author->first_name $author->last_name"; $name = "$author->first_name $author->last_name";
if ( !($posts == 0 && $hide_empty) ) if ( !($posts == 0 && $hide_empty) )
echo "<li>"; $return .= '<li>';
if ( $posts == 0 ) { if ( $posts == 0 ) {
if ( !$hide_empty ) if ( !$hide_empty )
$link = $name; $link = $name;
@ -240,8 +242,11 @@ function wp_list_authors($args = '') {
} }
if ( !($posts == 0 && $hide_empty) ) if ( !($posts == 0 && $hide_empty) )
echo "$link</li>"; $return .= $link . '</li>';
} }
if ( !$echo )
return $return;
echo $return;
} }
?> ?>