block_core_page_list_nest_pages() – Outputs nested array of pages

You appear to be a bot. Output may be restricted

Description

Outputs nested array of pages

Usage

$array = block_core_page_list_nest_pages( $current_level, $children );

Parameters

$current_level
( array ) required – The level being iterated through.
$children
( array ) required – The children grouped by parent post ID.

Returns

array The nested array of pages.

Source

File name: wordpress/wp-includes/blocks/page-list.php
Lines:

1 to 11 of 11
function block_core_page_list_nest_pages( $current_level, $children ) {
  if ( empty( $current_level ) ) {
    return;
  }
  foreach ( (array) $current_level as $key => $current ) {
    if ( isset( $children[ $key ] ) ) {
      $current_level[ $key ]['children'] = block_core_page_list_nest_pages( $children[ $key ], $children );
    }
  }
  return $current_level;
}
 

 View on GitHub View on Trac