From ee90a8c17c1178057700626672080df72a5567cf Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 15 May 2014 05:18:15 +0000 Subject: [PATCH] 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 --- wp-includes/user.php | 52 ++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index 5a9dc466ac..4fbd85a40d 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -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 = "\n"; - - if ( $show_option_all ) + if ( $show_option_all ) { $output .= "\t\n"; + } if ( $show_option_none ) { - $_selected = selected( -1, $selected, false ); + $_selected = selected( -1, $r['selected'], false ); $output .= "\t\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\n"; + } + $display = ! empty( $user->$show ) ? $user->$show : '('. $user->user_login . ')'; + $output .= "\t\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\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\n"; } $output .= ""; @@ -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; } /**