Make WordPress Core

Changeset 28401


Ignore:
Timestamp:
05/15/2014 01:21:20 AM (12 years ago)
Author:
wonderboymusic
Message:

Eliminate use of extract() in wp_list_pages() which, surprisingly, didn't even use any of the extracted variables.

See #22400.

File:
1 edited

Legend:

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

    r28399 r28401  
    10021002        $defaults = array(
    10031003                'depth' => 0, 'show_date' => '',
    1004                 'date_format' => get_option('date_format'),
     1004                'date_format' => get_option( 'date_format' ),
    10051005                'child_of' => 0, 'exclude' => '',
    1006                 'title_li' => __('Pages'), 'echo' => 1,
     1006                'title_li' => __( 'Pages' ), 'echo' => 1,
    10071007                'authors' => '', 'sort_column' => 'menu_order, post_title',
    10081008                'link_before' => '', 'link_after' => '', 'walker' => '',
    … …  
    10101010
    10111011        $r = wp_parse_args( $args, $defaults );
    1012         extract( $r, EXTR_SKIP );
    10131012
    10141013        $output = '';
    … …  
    10161015
    10171016        // sanitize, mostly to keep spaces out
    1018         $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
     1017        $r['exclude'] = preg_replace( '/[^0-9,]/', '', $r['exclude'] );
    10191018
    10201019        // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    1021         $exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();
     1020        $exclude_array = ( $r['exclude'] ) ? explode( ',', $r['exclude'] ) : array();
    10221021
    10231022        /**
    … …  
    10321031        // Query pages.
    10331032        $r['hierarchical'] = 0;
    1034         $pages = get_pages($r);
    1035 
    1036         if ( !empty($pages) ) {
    1037                 if ( $r['title_li'] )
     1033        $pages = get_pages( $r );
     1034
     1035        if ( ! empty( $pages ) ) {
     1036                if ( $r['title_li'] ) {
    10381037                        $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
    1039 
     1038                }
    10401039                global $wp_query;
    10411040                if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
    … …  
    10481047                }
    10491048
    1050                 $output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
    1051 
    1052                 if ( $r['title_li'] )
     1049                $output .= walk_page_tree( $pages, $r['depth'], $current_page, $r );
     1050
     1051                if ( $r['title_li'] ) {
    10531052                        $output .= '</ul></li>';
     1053                }
    10541054        }
    10551055
    … …  
    10611061         * @see wp_list_pages()
    10621062         *
    1063          * @param string $output HTML output of the pages list.
     1063         * @param string $html HTML output of the pages list.
    10641064         * @param array  $r      An array of page-listing arguments.
    10651065         */
    1066         $output = apply_filters( 'wp_list_pages', $output, $r );
    1067 
    1068         if ( $r['echo'] )
    1069                 echo $output;
    1070         else
    1071                 return $output;
     1066        $html = apply_filters( 'wp_list_pages', $output, $r );
     1067
     1068        if ( $r['echo'] ) {
     1069                echo $html;
     1070        } else {
     1071                return $html;
     1072        }
    10721073}
    10731074
Note: See TracChangeset for help on using the changeset viewer.