Make WordPress Core

Changeset 28434


Ignore:
Timestamp:
05/15/2014 05:27:18 PM (10 years ago)
Author:
wonderboymusic
Message:

Eliminate use of extract() in wp_list_categories().

See #22400.

File:
1 edited

Legend:

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

    r28432 r28434  
    486486    }
    487487
    488     if ( !isset( $r['class'] ) )
     488    if ( ! isset( $r['class'] ) )
    489489        $r['class'] = ( 'category' == $r['taxonomy'] ) ? 'categories' : $r['taxonomy'];
    490490
    491     extract( $r );
    492 
    493     if ( !taxonomy_exists($taxonomy) )
     491    if ( ! taxonomy_exists( $r['taxonomy'] ) ) {
    494492        return false;
     493    }
     494
     495    $show_option_all = $r['show_option_all'];
     496    $show_option_none = $r['show_option_none'];
    495497
    496498    $categories = get_categories( $r );
    497499
    498500    $output = '';
    499     if ( $title_li && 'list' == $style )
    500             $output = '<li class="' . esc_attr( $class ) . '">' . $title_li . '<ul>';
    501 
     501    if ( $r['title_li'] && 'list' == $r['style'] ) {
     502        $output = '<li class="' . esc_attr( $r['class'] ) . '">' . $r['title_li'] . '<ul>';
     503    }
    502504    if ( empty( $categories ) ) {
    503505        if ( ! empty( $show_option_none ) ) {
    504             if ( 'list' == $style )
     506            if ( 'list' == $r['style'] ) {
    505507                $output .= '<li class="cat-item-none">' . $show_option_none . '</li>';
    506             else
     508            } else {
    507509                $output .= $show_option_none;
     510            }
    508511        }
    509512    } else {
     
    511514            $posts_page = ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) ? get_permalink( get_option( 'page_for_posts' ) ) : home_url( '/' );
    512515            $posts_page = esc_url( $posts_page );
    513             if ( 'list' == $style )
     516            if ( 'list' == $r['style'] ) {
    514517                $output .= "<li class='cat-item-all'><a href='$posts_page'>$show_option_all</a></li>";
    515             else
     518            } else {
    516519                $output .= "<a href='$posts_page'>$show_option_all</a>";
     520            }
    517521        }
    518522
    519523        if ( empty( $r['current_category'] ) && ( is_category() || is_tax() || is_tag() ) ) {
    520524            $current_term_object = get_queried_object();
    521             if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy )
     525            if ( $current_term_object && $r['taxonomy'] === $current_term_object->taxonomy ) {
    522526                $r['current_category'] = get_queried_object_id();
    523         }
    524 
    525         if ( $hierarchical )
     527            }
     528        }
     529
     530        if ( $r['hierarchical'] ) {
    526531            $depth = $r['depth'];
    527         else
     532        } else {
    528533            $depth = -1; // Flat.
    529 
     534        }
    530535        $output .= walk_category_tree( $categories, $depth, $r );
    531536    }
    532537
    533     if ( $title_li && 'list' == $style )
     538    if ( $r['title_li'] && 'list' == $r['style'] )
    534539        $output .= '</ul></li>';
    535540
     
    542547     * @param array  $args   An array of taxonomy-listing arguments.
    543548     */
    544     $output = apply_filters( 'wp_list_categories', $output, $args );
    545 
    546     if ( $echo )
    547         echo $output;
    548     else
    549         return $output;
     549    $html = apply_filters( 'wp_list_categories', $output, $args );
     550
     551    if ( $r['echo'] ) {
     552        echo $html;
     553    } else {
     554        return $html;
     555    }
    550556}
    551557
Note: See TracChangeset for help on using the changeset viewer.