mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 16:21:26 +01:00
Use wp_parse_id_list()
when parsing exclude_tree
in get_pages()
. Add unit tests to ensure a URL string, array with string as value, and array with array as value for exclude_tree
can be used to specify multiple IDs.
Props cgaffga, roothorick, hakre, tbrams for patches across the years. Fixes #9153. Built from https://develop.svn.wordpress.org/trunk@27767 git-svn-id: http://core.svn.wordpress.org/trunk@27604 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b2b6d416f3
commit
0a2e85d3f0
@ -3742,7 +3742,7 @@ function get_pages( $args = array() ) {
|
||||
'sort_column' => 'post_title', 'hierarchical' => 1,
|
||||
'exclude' => array(), 'include' => array(),
|
||||
'meta_key' => '', 'meta_value' => '',
|
||||
'authors' => '', 'parent' => -1, 'exclude_tree' => '',
|
||||
'authors' => '', 'parent' => -1, 'exclude_tree' => array(),
|
||||
'number' => '', 'offset' => 0,
|
||||
'post_type' => 'page', 'post_status' => 'publish',
|
||||
);
|
||||
@ -3925,18 +3925,21 @@ function get_pages( $args = array() ) {
|
||||
$pages = get_page_children($child_of, $pages);
|
||||
|
||||
if ( ! empty( $exclude_tree ) ) {
|
||||
$exclude = (int) $exclude_tree;
|
||||
$children = get_page_children($exclude, $pages);
|
||||
$excludes = array();
|
||||
foreach ( $children as $child )
|
||||
$excludes[] = $child->ID;
|
||||
$excludes[] = $exclude;
|
||||
$exclude = wp_parse_id_list( $exclude_tree );
|
||||
foreach( $exclude as $id ) {
|
||||
$children = get_page_children( $id, $pages );
|
||||
foreach ( $children as $child ) {
|
||||
$exclude[] = $child->ID;
|
||||
}
|
||||
}
|
||||
|
||||
$num_pages = count( $pages );
|
||||
for ( $i = 0; $i < $num_pages; $i++ ) {
|
||||
if ( in_array($pages[$i]->ID, $excludes) )
|
||||
if ( in_array( $pages[$i]->ID, $exclude ) ) {
|
||||
unset( $pages[$i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page_structure = array();
|
||||
foreach ( $pages as $page )
|
||||
|
Loading…
Reference in New Issue
Block a user