mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Eliminate use of extract()
in wp_list_pages()
which, surprisingly, didn't even use any of the extracted variables.
See #22400. Built from https://develop.svn.wordpress.org/trunk@28401 git-svn-id: http://core.svn.wordpress.org/trunk@28228 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
29d8832625
commit
7b8d797355
@ -1001,24 +1001,23 @@ function wp_dropdown_pages( $args = '' ) {
|
|||||||
function wp_list_pages( $args = '' ) {
|
function wp_list_pages( $args = '' ) {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'depth' => 0, 'show_date' => '',
|
'depth' => 0, 'show_date' => '',
|
||||||
'date_format' => get_option('date_format'),
|
'date_format' => get_option( 'date_format' ),
|
||||||
'child_of' => 0, 'exclude' => '',
|
'child_of' => 0, 'exclude' => '',
|
||||||
'title_li' => __('Pages'), 'echo' => 1,
|
'title_li' => __( 'Pages' ), 'echo' => 1,
|
||||||
'authors' => '', 'sort_column' => 'menu_order, post_title',
|
'authors' => '', 'sort_column' => 'menu_order, post_title',
|
||||||
'link_before' => '', 'link_after' => '', 'walker' => '',
|
'link_before' => '', 'link_after' => '', 'walker' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = wp_parse_args( $args, $defaults );
|
$r = wp_parse_args( $args, $defaults );
|
||||||
extract( $r, EXTR_SKIP );
|
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
$current_page = 0;
|
$current_page = 0;
|
||||||
|
|
||||||
// sanitize, mostly to keep spaces out
|
// sanitize, mostly to keep spaces out
|
||||||
$r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
|
$r['exclude'] = preg_replace( '/[^0-9,]/', '', $r['exclude'] );
|
||||||
|
|
||||||
// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
|
// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
|
||||||
$exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array();
|
$exclude_array = ( $r['exclude'] ) ? explode( ',', $r['exclude'] ) : array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the array of pages to exclude from the pages list.
|
* Filter the array of pages to exclude from the pages list.
|
||||||
@ -1031,12 +1030,12 @@ function wp_list_pages( $args = '' ) {
|
|||||||
|
|
||||||
// Query pages.
|
// Query pages.
|
||||||
$r['hierarchical'] = 0;
|
$r['hierarchical'] = 0;
|
||||||
$pages = get_pages($r);
|
$pages = get_pages( $r );
|
||||||
|
|
||||||
if ( !empty($pages) ) {
|
if ( ! empty( $pages ) ) {
|
||||||
if ( $r['title_li'] )
|
if ( $r['title_li'] ) {
|
||||||
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
|
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
|
||||||
|
}
|
||||||
global $wp_query;
|
global $wp_query;
|
||||||
if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
|
if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
|
||||||
$current_page = get_queried_object_id();
|
$current_page = get_queried_object_id();
|
||||||
@ -1047,10 +1046,11 @@ function wp_list_pages( $args = '' ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
|
$output .= walk_page_tree( $pages, $r['depth'], $current_page, $r );
|
||||||
|
|
||||||
if ( $r['title_li'] )
|
if ( $r['title_li'] ) {
|
||||||
$output .= '</ul></li>';
|
$output .= '</ul></li>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1060,15 +1060,16 @@ function wp_list_pages( $args = '' ) {
|
|||||||
*
|
*
|
||||||
* @see wp_list_pages()
|
* @see wp_list_pages()
|
||||||
*
|
*
|
||||||
* @param string $output HTML output of the pages list.
|
* @param string $html HTML output of the pages list.
|
||||||
* @param array $r An array of page-listing arguments.
|
* @param array $r An array of page-listing arguments.
|
||||||
*/
|
*/
|
||||||
$output = apply_filters( 'wp_list_pages', $output, $r );
|
$html = apply_filters( 'wp_list_pages', $output, $r );
|
||||||
|
|
||||||
if ( $r['echo'] )
|
if ( $r['echo'] ) {
|
||||||
echo $output;
|
echo $html;
|
||||||
else
|
} else {
|
||||||
return $output;
|
return $html;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user