Make WordPress Core

Changeset 28392


Ignore:
Timestamp:
05/13/2014 06:01:33 AM (10 years ago)
Author:
wonderboymusic
Message:

Eliminate use of extract() in wp_list_authors().

See #22400.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/author-template.php

    r28362 r28392  
    330330 * @return null|string The output, if echo is set to false.
    331331 */
    332 function wp_list_authors($args = '') {
     332function wp_list_authors( $args = '' ) {
    333333    global $wpdb;
    334334
     
    342342
    343343    $args = wp_parse_args( $args, $defaults );
    344     extract( $args, EXTR_SKIP );
    345344
    346345    $return = '';
     
    351350
    352351    $author_count = array();
    353     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 )
     352    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 ) {
    354353        $author_count[$row->post_author] = $row->count;
    355 
     354    }
    356355    foreach ( $authors as $author_id ) {
    357356        $author = get_userdata( $author_id );
    358357
    359         if ( $exclude_admin && 'admin' == $author->display_name )
     358        if ( $args['exclude_admin'] && 'admin' == $author->display_name ) {
    360359            continue;
     360        }
    361361
    362362        $posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0;
    363363
    364         if ( !$posts && $hide_empty )
     364        if ( ! $posts && $args['hide_empty'] ) {
    365365            continue;
    366 
    367         if ( $show_fullname && $author->first_name && $author->last_name )
     366        }
     367
     368        if ( $args['show_fullname'] && $author->first_name && $author->last_name ) {
    368369            $name = "$author->first_name $author->last_name";
    369         else
     370        } else {
    370371            $name = $author->display_name;
    371 
    372         if ( !$html ) {
     372        }
     373
     374        if ( ! $args['html'] ) {
    373375            $return .= $name . ', ';
    374376
     
    376378        }
    377379
    378         if ( 'list' == $style ) {
     380        if ( 'list' == $args['style'] ) {
    379381            $return .= '<li>';
    380382        }
     
    382384        $link = '<a href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>';
    383385
    384         if ( !empty( $feed_image ) || !empty( $feed ) ) {
     386        if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) {
    385387            $link .= ' ';
    386             if ( empty( $feed_image ) ) {
     388            if ( empty( $args['feed_image'] ) ) {
    387389                $link .= '(';
    388390            }
    389391
    390             $link .= '<a href="' . get_author_feed_link( $author->ID, $feed_type ) . '"';
     392            $link .= '<a href="' . get_author_feed_link( $author->ID, $args['feed_type'] ) . '"';
    391393
    392394            $alt = '';
    393             if ( !empty( $feed ) ) {
    394                 $alt = ' alt="' . esc_attr( $feed ) . '"';
    395                 $name = $feed;
     395            if ( ! empty( $args['feed'] ) ) {
     396                $alt = ' alt="' . esc_attr( $args['feed'] ) . '"';
     397                $name = $args['feed'];
    396398            }
    397399
    398400            $link .= '>';
    399401
    400             if ( !empty( $feed_image ) )
    401                 $link .= '<img src="' . esc_url( $feed_image ) . '" style="border: none;"' . $alt . ' />';
    402             else
     402            if ( ! empty( $args['feed_image'] ) ) {
     403                $link .= '<img src="' . esc_url( $args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';
     404            } else {
    403405                $link .= $name;
     406            }
    404407
    405408            $link .= '</a>';
    406409
    407             if ( empty( $feed_image ) )
     410            if ( empty( $args['feed_image'] ) ) {
    408411                $link .= ')';
    409         }
    410 
    411         if ( $optioncount )
     412            }
     413        }
     414
     415        if ( $args['optioncount'] ) {
    412416            $link .= ' ('. $posts . ')';
     417        }
    413418
    414419        $return .= $link;
    415         $return .= ( 'list' == $style ) ? '</li>' : ', ';
    416     }
    417 
    418     $return = rtrim($return, ', ');
    419 
    420     if ( !$echo )
     420        $return .= ( 'list' == $args['style'] ) ? '</li>' : ', ';
     421    }
     422
     423    $return = rtrim( $return, ', ' );
     424
     425    if ( ! $args['echo'] ) {
    421426        return $return;
    422 
     427    }
    423428    echo $return;
    424429}
Note: See TracChangeset for help on using the changeset viewer.