diff --git src/wp-includes/post.php src/wp-includes/post.php
index bedf2bf..1b1d62c 100644
|
|
function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) |
4318 | 4318 | * @return array List of page children. |
4319 | 4319 | */ |
4320 | 4320 | function get_page_children( $page_id, $pages ) { |
4321 | | $page_list = array(); |
| 4321 | $post_hash = array(); |
| 4322 | $children_hash = array(); |
| 4323 | |
| 4324 | // build a hash of ID -> children |
4322 | 4325 | foreach ( (array) $pages as $page ) { |
4323 | | if ( $page->post_parent == $page_id ) { |
4324 | | $page_list[] = $page; |
4325 | | if ( $children = get_page_children( $page->ID, $pages ) ) { |
4326 | | $page_list = array_merge( $page_list, $children ); |
4327 | | } |
| 4326 | $post_hash[$page->ID] = $page; |
| 4327 | if ( !array_key_exists( $page->post_parent, $children_hash ) ) { |
| 4328 | $children_hash[$page->post_parent] = [$page->ID]; |
| 4329 | } else { |
| 4330 | $children_hash[$page->post_parent][] = $page->ID; |
4328 | 4331 | } |
4329 | 4332 | } |
4330 | 4333 | |
4331 | | return $page_list; |
| 4334 | if( array_key_exists( $page_id, $children_hash ) ) { |
| 4335 | $post_list = array(); |
| 4336 | $to_look = array_reverse( $children_hash[$page_id] ); |
| 4337 | // while we still have posts to_look add them to the list |
| 4338 | while ( $to_look ) { |
| 4339 | $id = array_pop( $to_look ); |
| 4340 | $post_list[] = $post_hash[$id]; |
| 4341 | if ( array_key_exists( $id, $children_hash ) ) { |
| 4342 | foreach( array_reverse( $children_hash[$id] ) as $child ) { |
| 4343 | $to_look[] = $child; |
| 4344 | } |
| 4345 | } |
| 4346 | } |
| 4347 | return $post_list; |
| 4348 | } else { |
| 4349 | return array(); |
| 4350 | } |
4332 | 4351 | } |
4333 | 4352 | |
4334 | 4353 | /** |