mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 07:37:44 +02:00
Enhance wp_list_authors() to support more of the standard output options. Props jacobsantos see #4420.
git-svn-id: http://svn.automattic.com/wordpress/trunk@10570 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
90aeee2ce4
commit
5ed02dc0ed
@ -442,15 +442,23 @@ function get_author_name( $auth_id ) {
|
|||||||
/**
|
/**
|
||||||
* List all the authors of the blog, with several options available.
|
* List all the authors of the blog, with several options available.
|
||||||
*
|
*
|
||||||
* optioncount (boolean) (false): Show the count in parenthesis next to the
|
* <ul>
|
||||||
* author's name.
|
* <li>optioncount (boolean) (false): Show the count in parenthesis next to the
|
||||||
* exclude_admin (boolean) (true): Exclude the 'admin' user that is installed by
|
* author's name.</li>
|
||||||
* default.
|
* <li>exclude_admin (boolean) (true): Exclude the 'admin' user that is
|
||||||
* show_fullname (boolean) (false): Show their full names.
|
* installed bydefault.</li>
|
||||||
* hide_empty (boolean) (true): Don't show authors without any posts.
|
* <li>show_fullname (boolean) (false): Show their full names.</li>
|
||||||
* feed (string) (''): If isn't empty, show links to author's feeds.
|
* <li>hide_empty (boolean) (true): Don't show authors without any posts.</li>
|
||||||
* feed_image (string) (''): If isn't empty, use this image to link to feeds.
|
* <li>feed (string) (''): If isn't empty, show links to author's feeds.</li>
|
||||||
* echo (boolean) (true): Set to false to return the output, instead of echoing.
|
* <li>feed_image (string) (''): If isn't empty, use this image to link to
|
||||||
|
* feeds.</li>
|
||||||
|
* <li>echo (boolean) (true): Set to false to return the output, instead of
|
||||||
|
* echoing.</li>
|
||||||
|
* <li>style (string) ('list'): Whether to display list of authors in list form
|
||||||
|
* or as a string.</li>
|
||||||
|
* <li>html (bool) (true): Whether to list the items in html for or plaintext.
|
||||||
|
* </li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @link http://codex.wordpress.org/Template_Tags/wp_list_authors
|
* @link http://codex.wordpress.org/Template_Tags/wp_list_authors
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
@ -463,12 +471,12 @@ 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_type' => '', 'echo' => true
|
'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,
|
||||||
|
'style' => 'list', 'html' => true
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = wp_parse_args( $args, $defaults );
|
$r = wp_parse_args( $args, $defaults );
|
||||||
extract($r, EXTR_SKIP);
|
extract($r, EXTR_SKIP);
|
||||||
|
|
||||||
$return = '';
|
$return = '';
|
||||||
|
|
||||||
/** @todo Move select to get_authors(). */
|
/** @todo Move select to get_authors(). */
|
||||||
@ -487,10 +495,21 @@ function wp_list_authors($args = '') {
|
|||||||
if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
|
if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
|
||||||
$name = "$author->first_name $author->last_name";
|
$name = "$author->first_name $author->last_name";
|
||||||
|
|
||||||
if ( !($posts == 0 && $hide_empty) )
|
if( !$html ) {
|
||||||
|
if ( $posts == 0 ) {
|
||||||
|
if ( ! $hide_empty )
|
||||||
|
$return .= $name . ', ';
|
||||||
|
} else
|
||||||
|
$return .= $name . ', ';
|
||||||
|
|
||||||
|
// No need to go further to process HTML.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !($posts == 0 && $hide_empty) && 'list' == $style )
|
||||||
$return .= '<li>';
|
$return .= '<li>';
|
||||||
if ( $posts == 0 ) {
|
if ( $posts == 0 ) {
|
||||||
if ( !$hide_empty )
|
if ( ! $hide_empty )
|
||||||
$link = $name;
|
$link = $name;
|
||||||
} else {
|
} else {
|
||||||
$link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
|
$link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
|
||||||
@ -526,10 +545,15 @@ function wp_list_authors($args = '') {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !($posts == 0 && $hide_empty) )
|
if ( !($posts == 0 && $hide_empty) && 'list' == $style )
|
||||||
$return .= $link . '</li>';
|
$return .= $link . '</li>';
|
||||||
|
else
|
||||||
|
$return .= $link . ', ';
|
||||||
}
|
}
|
||||||
if ( !$echo )
|
|
||||||
|
$return = trim($return, ', ');
|
||||||
|
|
||||||
|
if ( ! $echo )
|
||||||
return $return;
|
return $return;
|
||||||
echo $return;
|
echo $return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user