Eliminate use of extract() in wp_list_authors().

See #22400.

Built from https://develop.svn.wordpress.org/trunk@28392


git-svn-id: http://core.svn.wordpress.org/trunk@28220 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-05-13 06:02:14 +00:00
parent fd9abeb0f9
commit e866b5fb82

View File

@ -329,7 +329,7 @@ function get_author_posts_url($author_id, $author_nicename = '') {
* @param array $args The argument array. * @param array $args The argument array.
* @return null|string The output, if echo is set to false. * @return null|string The output, if echo is set to false.
*/ */
function wp_list_authors($args = '') { function wp_list_authors( $args = '' ) {
global $wpdb; global $wpdb;
$defaults = array( $defaults = array(
@ -341,7 +341,6 @@ function wp_list_authors($args = '') {
); );
$args = wp_parse_args( $args, $defaults ); $args = wp_parse_args( $args, $defaults );
extract( $args, EXTR_SKIP );
$return = ''; $return = '';
@ -350,76 +349,82 @@ function wp_list_authors($args = '') {
$authors = get_users( $query_args ); $authors = get_users( $query_args );
$author_count = array(); $author_count = array();
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 ) 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 ) {
$author_count[$row->post_author] = $row->count; $author_count[$row->post_author] = $row->count;
}
foreach ( $authors as $author_id ) { foreach ( $authors as $author_id ) {
$author = get_userdata( $author_id ); $author = get_userdata( $author_id );
if ( $exclude_admin && 'admin' == $author->display_name ) if ( $args['exclude_admin'] && 'admin' == $author->display_name ) {
continue; continue;
}
$posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0; $posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0;
if ( !$posts && $hide_empty ) if ( ! $posts && $args['hide_empty'] ) {
continue; continue;
}
if ( $show_fullname && $author->first_name && $author->last_name ) if ( $args['show_fullname'] && $author->first_name && $author->last_name ) {
$name = "$author->first_name $author->last_name"; $name = "$author->first_name $author->last_name";
else } else {
$name = $author->display_name; $name = $author->display_name;
}
if ( !$html ) { if ( ! $args['html'] ) {
$return .= $name . ', '; $return .= $name . ', ';
continue; // No need to go further to process HTML. continue; // No need to go further to process HTML.
} }
if ( 'list' == $style ) { if ( 'list' == $args['style'] ) {
$return .= '<li>'; $return .= '<li>';
} }
$link = '<a href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>'; $link = '<a href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>';
if ( !empty( $feed_image ) || !empty( $feed ) ) { if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) {
$link .= ' '; $link .= ' ';
if ( empty( $feed_image ) ) { if ( empty( $args['feed_image'] ) ) {
$link .= '('; $link .= '(';
} }
$link .= '<a href="' . get_author_feed_link( $author->ID, $feed_type ) . '"'; $link .= '<a href="' . get_author_feed_link( $author->ID, $args['feed_type'] ) . '"';
$alt = ''; $alt = '';
if ( !empty( $feed ) ) { if ( ! empty( $args['feed'] ) ) {
$alt = ' alt="' . esc_attr( $feed ) . '"'; $alt = ' alt="' . esc_attr( $args['feed'] ) . '"';
$name = $feed; $name = $args['feed'];
} }
$link .= '>'; $link .= '>';
if ( !empty( $feed_image ) ) if ( ! empty( $args['feed_image'] ) ) {
$link .= '<img src="' . esc_url( $feed_image ) . '" style="border: none;"' . $alt . ' />'; $link .= '<img src="' . esc_url( $args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';
else } else {
$link .= $name; $link .= $name;
}
$link .= '</a>'; $link .= '</a>';
if ( empty( $feed_image ) ) if ( empty( $args['feed_image'] ) ) {
$link .= ')'; $link .= ')';
}
} }
if ( $optioncount ) if ( $args['optioncount'] ) {
$link .= ' ('. $posts . ')'; $link .= ' ('. $posts . ')';
}
$return .= $link; $return .= $link;
$return .= ( 'list' == $style ) ? '</li>' : ', '; $return .= ( 'list' == $args['style'] ) ? '</li>' : ', ';
} }
$return = rtrim($return, ', '); $return = rtrim( $return, ', ' );
if ( !$echo ) if ( ! $args['echo'] ) {
return $return; return $return;
}
echo $return; echo $return;
} }