diff --git src/wp-includes/post.php src/wp-includes/post.php
index bedf2bf..f124b41 100644
|
|
function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) |
4311 | 4311 | * children for the same to retrieve all children of a page. Does not make any |
4312 | 4312 | * SQL queries to get the children. |
4313 | 4313 | * |
| 4314 | * It uses auxiliary structure to hold parent-children relationships and |
| 4315 | * runs in O(N) complexity |
| 4316 | * |
4314 | 4317 | * @since 1.5.1 |
4315 | 4318 | * |
4316 | 4319 | * @param int $page_id Page ID. |
… |
… |
function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) |
4318 | 4321 | * @return array List of page children. |
4319 | 4322 | */ |
4320 | 4323 | function get_page_children( $page_id, $pages ) { |
4321 | | $page_list = array(); |
4322 | | 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 ); |
| 4324 | // build a hash of ID -> children |
| 4325 | $children = array(); |
| 4326 | foreach ( (array) $pages as $p ) { |
| 4327 | $children[ intval( $p->post_parent ) ][] = $p; |
| 4328 | } |
| 4329 | |
| 4330 | $post_list = array(); |
| 4331 | if( array_key_exists( $page_id, $children ) ) { |
| 4332 | $to_look = array_reverse( $children[ $page_id ] ); |
| 4333 | // while we still have posts to_look add them to the list |
| 4334 | while ( $to_look ) { |
| 4335 | $p = array_pop( $to_look ); |
| 4336 | $post_list[] = $p; |
| 4337 | if ( array_key_exists( $p->ID, $children ) ) { |
| 4338 | foreach ( array_reverse( $children[ $p->ID ] ) as $child ) { |
| 4339 | $to_look[] = $child; |
| 4340 | } |
4327 | 4341 | } |
4328 | 4342 | } |
4329 | 4343 | } |
4330 | 4344 | |
4331 | | return $page_list; |
| 4345 | return $post_list; |
4332 | 4346 | } |
4333 | 4347 | |
4334 | 4348 | /** |