Make WordPress Core

Changeset 28420


Ignore:
Timestamp:
05/15/2014 05:17:12 AM (9 years ago)
Author:
wonderboymusic
Message:

Eliminate the use of extract() in wp_dropdown_users().

See #22400.

File:
1 edited

Legend:

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

    r28087 r28420  
    12351235
    12361236    $r = wp_parse_args( $args, $defaults );
    1237     extract( $r, EXTR_SKIP );
     1237    $show = $r['show'];
     1238    $show_option_all = $r['show_option_all'];
     1239    $show_option_none = $r['show_option_none'];
    12381240
    12391241    $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) );
     
    12421244
    12431245    $output = '';
    1244     if ( !empty($users) && ( empty($hide_if_only_one_author) || count($users) > 1 ) ) {
    1245         $name = esc_attr( $name );
    1246         if ( $multi && ! $id )
     1246    if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) {
     1247        $name = esc_attr( $r['name'] );
     1248        if ( $r['multi'] && ! $r['id'] ) {
    12471249            $id = '';
    1248         else
    1249             $id = $id ? " id='" . esc_attr( $id ) . "'" : " id='$name'";
    1250 
    1251         $output = "<select name='{$name}'{$id} class='$class'>\n";
    1252 
    1253         if ( $show_option_all )
     1250        } else {
     1251            $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'";
     1252        }
     1253        $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n";
     1254
     1255        if ( $show_option_all ) {
    12541256            $output .= "\t<option value='0'>$show_option_all</option>\n";
     1257        }
    12551258
    12561259        if ( $show_option_none ) {
    1257             $_selected = selected( -1, $selected, false );
     1260            $_selected = selected( -1, $r['selected'], false );
    12581261            $output .= "\t<option value='-1'$_selected>$show_option_none</option>\n";
    12591262        }
     
    12621265        foreach ( (array) $users as $user ) {
    12631266            $user->ID = (int) $user->ID;
    1264             $_selected = selected( $user->ID, $selected, false );
    1265             if ( $_selected )
     1267            $_selected = selected( $user->ID, $r['selected'], false );
     1268            if ( $_selected ) {
    12661269                $found_selected = true;
    1267             $display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
    1268             $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n";
    1269         }
    1270 
    1271         if ( $include_selected && ! $found_selected && ( $selected > 0 ) ) {
    1272             $user = get_userdata( $selected );
    1273             $_selected = selected( $user->ID, $selected, false );
    1274             $display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
    1275             $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n";
     1270            }
     1271            $display = ! empty( $user->$show ) ? $user->$show : '('. $user->user_login . ')';
     1272            $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n";
     1273        }
     1274
     1275        if ( $r['include_selected'] && ! $found_selected && ( $r['selected'] > 0 ) ) {
     1276            $user = get_userdata( $r['selected'] );
     1277            $_selected = selected( $user->ID, $r['selected'], false );
     1278            $display = ! empty( $user->$show ) ? $user->$show : '('. $user->user_login . ')';
     1279            $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n";
    12761280        }
    12771281
     
    12861290     * @param string $output HTML output generated by wp_dropdown_users().
    12871291     */
    1288     $output = apply_filters( 'wp_dropdown_users', $output );
    1289 
    1290     if ( $echo )
    1291         echo $output;
    1292 
    1293     return $output;
     1292    $html = apply_filters( 'wp_dropdown_users', $output );
     1293
     1294    if ( $r['echo'] ) {
     1295        echo $html;
     1296    }
     1297    return $html;
    12941298}
    12951299
Note: See TracChangeset for help on using the changeset viewer.