Make WordPress Core

Changeset 28432


Ignore:
Timestamp:
05/15/2014 03:47:43 PM (10 years ago)
Author:
wonderboymusic
Message:

Eliminate use of extract() in wp_dropdown_categories().

See #22400.

File:
1 edited

Legend:

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

    r28359 r28432  
    345345    $r = wp_parse_args( $args, $defaults );
    346346
    347     if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
     347    if ( ! isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
    348348        $r['pad_counts'] = true;
    349349    }
    350350
    351     extract( $r );
     351    $tab_index = $r['tab_index'];
    352352
    353353    $tab_index_attribute = '';
    354     if ( (int) $tab_index > 0 )
     354    if ( (int) $tab_index > 0 ) {
    355355        $tab_index_attribute = " tabindex=\"$tab_index\"";
    356 
    357     $categories = get_terms( $taxonomy, $r );
    358     $name = esc_attr( $name );
    359     $class = esc_attr( $class );
    360     $id = $id ? esc_attr( $id ) : $name;
    361 
    362     if ( ! $r['hide_if_empty'] || ! empty($categories) )
     356    }
     357    $categories = get_terms( $r['taxonomy'], $r );
     358    $name = esc_attr( $r['name'] );
     359    $class = esc_attr( $r['class'] );
     360    $id = $r['id'] ? esc_attr( $r['id'] ) : $name;
     361
     362    if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) {
    363363        $output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n";
    364     else
     364    } else {
    365365        $output = '';
    366 
    367     if ( empty($categories) && ! $r['hide_if_empty'] && !empty($show_option_none) ) {
     366    }
     367    if ( empty( $categories ) && ! $r['hide_if_empty'] && ! empty( $r['show_option_none'] ) ) {
    368368
    369369        /**
     
    381381         * @param string $element Taxonomy element to list.
    382382         */
    383         $show_option_none = apply_filters( 'list_cats', $show_option_none );
     383        $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
    384384        $output .= "\t<option value='-1' selected='selected'>$show_option_none</option>\n";
    385385    }
     
    387387    if ( ! empty( $categories ) ) {
    388388
    389         if ( $show_option_all ) {
     389        if ( $r['show_option_all'] ) {
    390390
    391391            /** This filter is documented in wp-includes/category-template.php */
    392             $show_option_all = apply_filters( 'list_cats', $show_option_all );
     392            $show_option_all = apply_filters( 'list_cats', $r['show_option_all'] );
    393393            $selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
    394394            $output .= "\t<option value='0'$selected>$show_option_all</option>\n";
    395395        }
    396396
    397         if ( $show_option_none ) {
     397        if ( $r['show_option_none'] ) {
    398398
    399399            /** This filter is documented in wp-includes/category-template.php */
    400             $show_option_none = apply_filters( 'list_cats', $show_option_none );
     400            $show_option_none = apply_filters( 'list_cats', $r['show_option_none'] );
    401401            $selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : '';
    402402            $output .= "\t<option value='-1'$selected>$show_option_none</option>\n";
    403403        }
    404404
    405         if ( $hierarchical )
     405        if ( $r['hierarchical'] ) {
    406406            $depth = $r['depth'];  // Walk the full depth.
    407         else
     407        } else {
    408408            $depth = -1; // Flat.
    409 
     409        }
    410410        $output .= walk_category_dropdown_tree( $categories, $depth, $r );
    411411    }
    412412
    413     if ( ! $r['hide_if_empty'] || ! empty($categories) )
     413    if ( ! $r['hide_if_empty'] || ! empty( $categories ) ) {
    414414        $output .= "</select>\n";
    415 
     415    }
    416416    /**
    417417     * Filter the taxonomy drop-down output.
     
    424424    $output = apply_filters( 'wp_dropdown_cats', $output, $r );
    425425
    426     if ( $echo )
     426    if ( $r['echo'] ) {
    427427        echo $output;
    428 
     428    }
    429429    return $output;
    430430}
Note: See TracChangeset for help on using the changeset viewer.