Eliminate use of `extract()` in `wp_dropdown_categories()`.

See #22400.


git-svn-id: https://develop.svn.wordpress.org/trunk@28432 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-05-15 15:47:43 +00:00
parent 4aa28e9cdc
commit 29efc53b6a
1 changed files with 24 additions and 24 deletions

View File

@ -344,27 +344,27 @@ function wp_dropdown_categories( $args = '' ) {
$r = wp_parse_args( $args, $defaults ); $r = wp_parse_args( $args, $defaults );
if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) { if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
$r['pad_counts'] = true; $r['pad_counts'] = true;
} }
extract( $r ); $tab_index = $r['tab_index'];
$tab_index_attribute = ''; $tab_index_attribute = '';
if ( (int) $tab_index > 0 ) if ( (int) $tab_index > 0 ) {
$tab_index_attribute = " tabindex=\"$tab_index\""; $tab_index_attribute = " tabindex=\"$tab_index\"";
}
$categories = get_terms( $r['taxonomy'], $r );
$name = esc_attr( $r['name'] );
$class = esc_attr( $r['class'] );
$id = $r['id'] ? esc_attr( $r['id'] ) : $name;
$categories = get_terms( $taxonomy, $r ); if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) {
$name = esc_attr( $name );
$class = esc_attr( $class );
$id = $id ? esc_attr( $id ) : $name;
if ( ! $r['hide_if_empty'] || ! empty($categories) )
$output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n"; $output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n";
else } else {
$output = ''; $output = '';
}
if ( empty($categories) && ! $r['hide_if_empty'] && !empty($show_option_none) ) { if ( empty( $categories ) && ! $r['hide_if_empty'] && ! empty( $r['show_option_none'] ) ) {
/** /**
* Filter a taxonomy drop-down display element. * Filter a taxonomy drop-down display element.
@ -380,39 +380,39 @@ function wp_dropdown_categories( $args = '' ) {
* *
* @param string $element Taxonomy element to list. * @param string $element Taxonomy element to list.
*/ */
$show_option_none = apply_filters( 'list_cats', $show_option_none ); $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
$output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n"; $output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n";
} }
if ( ! empty( $categories ) ) { if ( ! empty( $categories ) ) {
if ( $show_option_all ) { if ( $r['show_option_all'] ) {
/** This filter is documented in wp-includes/category-template.php */ /** This filter is documented in wp-includes/category-template.php */
$show_option_all = apply_filters( 'list_cats', $show_option_all ); $show_option_all = apply_filters( 'list_cats', $r['show_option_all'] );
$selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : ''; $selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
$output .= "\t<option value='0'$selected>$show_option_all</option>\n"; $output .= "\t<option value='0'$selected>$show_option_all</option>\n";
} }
if ( $show_option_none ) { if ( $r['show_option_none'] ) {
/** This filter is documented in wp-includes/category-template.php */ /** This filter is documented in wp-includes/category-template.php */
$show_option_none = apply_filters( 'list_cats', $show_option_none ); $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
$selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : ''; $selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : '';
$output .= "\t<option value='-1'$selected>$show_option_none</option>\n"; $output .= "\t<option value='-1'$selected>$show_option_none</option>\n";
} }
if ( $hierarchical ) if ( $r['hierarchical'] ) {
$depth = $r['depth']; // Walk the full depth. $depth = $r['depth']; // Walk the full depth.
else } else {
$depth = -1; // Flat. $depth = -1; // Flat.
}
$output .= walk_category_dropdown_tree( $categories, $depth, $r ); $output .= walk_category_dropdown_tree( $categories, $depth, $r );
} }
if ( ! $r['hide_if_empty'] || ! empty($categories) ) if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) {
$output .= "</select>\n"; $output .= "</select>\n";
}
/** /**
* Filter the taxonomy drop-down output. * Filter the taxonomy drop-down output.
* *
@ -423,9 +423,9 @@ function wp_dropdown_categories( $args = '' ) {
*/ */
$output = apply_filters( 'wp_dropdown_cats', $output, $r ); $output = apply_filters( 'wp_dropdown_cats', $output, $r );
if ( $echo ) if ( $r['echo'] ) {
echo $output; echo $output;
}
return $output; return $output;
} }