Eliminate the use of `extract()` in `wp_dropdown_users()`.
See #22400. Built from https://develop.svn.wordpress.org/trunk@28420 git-svn-id: http://core.svn.wordpress.org/trunk@28247 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ae61a48489
commit
ee90a8c17c
|
@ -1234,45 +1234,49 @@ function wp_dropdown_users( $args = '' ) {
|
|||
$defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;
|
||||
|
||||
$r = wp_parse_args( $args, $defaults );
|
||||
extract( $r, EXTR_SKIP );
|
||||
$show = $r['show'];
|
||||
$show_option_all = $r['show_option_all'];
|
||||
$show_option_none = $r['show_option_none'];
|
||||
|
||||
$query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) );
|
||||
$query_args['fields'] = array( 'ID', 'user_login', $show );
|
||||
$users = get_users( $query_args );
|
||||
|
||||
$output = '';
|
||||
if ( !empty($users) && ( empty($hide_if_only_one_author) || count($users) > 1 ) ) {
|
||||
$name = esc_attr( $name );
|
||||
if ( $multi && ! $id )
|
||||
if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) {
|
||||
$name = esc_attr( $r['name'] );
|
||||
if ( $r['multi'] && ! $r['id'] ) {
|
||||
$id = '';
|
||||
else
|
||||
$id = $id ? " id='" . esc_attr( $id ) . "'" : " id='$name'";
|
||||
} else {
|
||||
$id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'";
|
||||
}
|
||||
$output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n";
|
||||
|
||||
$output = "<select name='{$name}'{$id} class='$class'>\n";
|
||||
|
||||
if ( $show_option_all )
|
||||
if ( $show_option_all ) {
|
||||
$output .= "\t<option value='0'>$show_option_all</option>\n";
|
||||
}
|
||||
|
||||
if ( $show_option_none ) {
|
||||
$_selected = selected( -1, $selected, false );
|
||||
$_selected = selected( -1, $r['selected'], false );
|
||||
$output .= "\t<option value='-1'$_selected>$show_option_none</option>\n";
|
||||
}
|
||||
|
||||
$found_selected = false;
|
||||
foreach ( (array) $users as $user ) {
|
||||
$user->ID = (int) $user->ID;
|
||||
$_selected = selected( $user->ID, $selected, false );
|
||||
if ( $_selected )
|
||||
$_selected = selected( $user->ID, $r['selected'], false );
|
||||
if ( $_selected ) {
|
||||
$found_selected = true;
|
||||
$display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
|
||||
$output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n";
|
||||
}
|
||||
$display = ! empty( $user->$show ) ? $user->$show : '('. $user->user_login . ')';
|
||||
$output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n";
|
||||
}
|
||||
|
||||
if ( $include_selected && ! $found_selected && ( $selected > 0 ) ) {
|
||||
$user = get_userdata( $selected );
|
||||
$_selected = selected( $user->ID, $selected, false );
|
||||
$display = !empty($user->$show) ? $user->$show : '('. $user->user_login . ')';
|
||||
$output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n";
|
||||
if ( $r['include_selected'] && ! $found_selected && ( $r['selected'] > 0 ) ) {
|
||||
$user = get_userdata( $r['selected'] );
|
||||
$_selected = selected( $user->ID, $r['selected'], false );
|
||||
$display = ! empty( $user->$show ) ? $user->$show : '('. $user->user_login . ')';
|
||||
$output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n";
|
||||
}
|
||||
|
||||
$output .= "</select>";
|
||||
|
@ -1285,12 +1289,12 @@ function wp_dropdown_users( $args = '' ) {
|
|||
*
|
||||
* @param string $output HTML output generated by wp_dropdown_users().
|
||||
*/
|
||||
$output = apply_filters( 'wp_dropdown_users', $output );
|
||||
$html = apply_filters( 'wp_dropdown_users', $output );
|
||||
|
||||
if ( $echo )
|
||||
echo $output;
|
||||
|
||||
return $output;
|
||||
if ( $r['echo'] ) {
|
||||
echo $html;
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue