mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 17:48:01 +01:00
Allow get_pages()
, with child_of
passed to it, to work with interrupted hierarchies.
Adds unit test. Fixes #18962. Built from https://develop.svn.wordpress.org/trunk@30159 git-svn-id: http://core.svn.wordpress.org/trunk@30159 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d5e4583475
commit
878d074e84
@ -4285,7 +4285,7 @@ function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' )
|
|||||||
function get_page_children($page_id, $pages) {
|
function get_page_children($page_id, $pages) {
|
||||||
$page_list = array();
|
$page_list = array();
|
||||||
foreach ( (array) $pages as $page ) {
|
foreach ( (array) $pages as $page ) {
|
||||||
if ( $page->post_parent == $page_id ) {
|
if ( $page->post_parent == $page_id || in_array( $page_id, $page->ancestors ) ) {
|
||||||
$page_list[] = $page;
|
$page_list[] = $page;
|
||||||
if ( $children = get_page_children($page->ID, $pages) )
|
if ( $children = get_page_children($page->ID, $pages) )
|
||||||
$page_list = array_merge($page_list, $children);
|
$page_list = array_merge($page_list, $children);
|
||||||
@ -4619,6 +4619,9 @@ function get_pages( $args = array() ) {
|
|||||||
// Update cache.
|
// Update cache.
|
||||||
update_post_cache( $pages );
|
update_post_cache( $pages );
|
||||||
|
|
||||||
|
// Convert to WP_Post instances
|
||||||
|
$pages = array_map( 'get_post', $pages );
|
||||||
|
|
||||||
if ( $child_of || $hierarchical ) {
|
if ( $child_of || $hierarchical ) {
|
||||||
$pages = get_page_children($child_of, $pages);
|
$pages = get_page_children($child_of, $pages);
|
||||||
}
|
}
|
||||||
@ -4647,9 +4650,6 @@ function get_pages( $args = array() ) {
|
|||||||
|
|
||||||
wp_cache_set( $cache_key, $page_structure, 'posts' );
|
wp_cache_set( $cache_key, $page_structure, 'posts' );
|
||||||
|
|
||||||
// Convert to WP_Post instances.
|
|
||||||
$pages = array_map( 'get_post', $pages );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the retrieved list of pages.
|
* Filter the retrieved list of pages.
|
||||||
*
|
*
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.1-alpha-30158';
|
$wp_version = '4.1-alpha-30159';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user