block_core_page_list_render_nested_page_list( string $submenu_visibility, boolean $show_submenu_icons, boolean $is_navigation_child, array $nested_pages, boolean $is_nested, array $active_page_ancestor_ids = array(), array $colors = array(), integer $depth = 0 ): string
- Since
- 5.8.0
- Source
wp-includes/blocks/page-list.php:142
Compatibility
- WordPress
- since 5.8.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$nested_pagesarray- The array of nested pages.
$is_nestedboolean- Whether the submenu is nested or not.
$active_page_ancestor_idsarrayoptional- An array of ancestor ids for active page.Default:
array() $colorsarrayoptional- Color information for overlay styles.Default:
array() $depthintegeroptional- The nesting depth.Default:
0
Return value
string- List markup.
Performance profile
How much work a call to block_core_page_list_render_nested_page_list() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Scales with input
- Instructions
- 22–23
- Plugin surface
- None
- Called by
- 2
Reads stored settings via get_option(), cached per request but not free on a cold cache.
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 194.
Nothing here hands control to plugin code.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()one call below block_core_page_list_render_nested_page_list() - cacheobject cache
wp_cache_get()one call below block_core_page_list_render_nested_page_list() - serializeserialisation
maybe_unserialize()one call below block_core_page_list_render_nested_page_list()
Further down the call graph this can also reach query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost block_core_page_list_render_nested_page_list() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!empty($nested_pages) | 22–23 | get_option() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 193 | 22–23 | 28 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 194 | 22–23 | 28 | |
| 8.4 | 194 | 22–23 | 28 | 9 fewer instructions than PHP 8.3 |
| 8.3 | 203 | 22–23 | 28 | |
| 8.2 | 203 | 22–23 | 28 | |
| 8.1 | 203 | 22–23 | 28 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 204 | 22–23 | 28 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 7
- get_option()Retrieves an option value based on an option name.
- esc_attr()Escaping for HTML attributes.
- __()Retrieves the translation of $text.
- wp_strip_all_tags()Properly strips all HTML tags including 'script' and 'style'.
- wp_kses_post()Sanitizes content for allowed HTML tags for post content.
- esc_url()Checks and cleans a URL.
- block_core_page_list_render_nested_page_list()Outputs Page list markup from an array of pages with nested children.
Used by · 2
- block_core_page_list_render_nested_page_list()Outputs Page list markup from an array of pages with nested children.
- render_block_core_page_list()Renders the `core/page-list` block on server.
Source code
function block_core_page_list_render_nested_page_list( $submenu_visibility, $show_submenu_icons, $is_navigation_child, $nested_pages, $is_nested, $active_page_ancestor_ids = array(), $colors = array(), $depth = 0 ) { if ( empty( $nested_pages ) ) { return; } $front_page_id = (int) get_option( 'page_on_front' ); $markup = ''; // Compute visibility mode flags once $open_on_click = 'click' === $submenu_visibility; $open_on_hover = 'hover' === $submenu_visibility; $open_always = 'always' === $submenu_visibility; foreach ( (array) $nested_pages as $page ) { $css_class = $page['is_active'] ? ' current-menu-item' : ''; $aria_current = $page['is_active'] ? ' aria-current="page"' : ''; $style_attribute = ''; $css_class .= in_array( $page['page_id'], $active_page_ancestor_ids, true ) ? ' current-menu-ancestor' : ''; if ( isset( $page['children'] ) ) { $css_class .= ' has-child'; } if ( $is_navigation_child ) { $css_class .= ' wp-block-navigation-item'; // Class assignment logic matches JS editor rendering in page-list-item/edit.js // Note: elseif ensures open-on-hover-click is mutually exclusive with open-on-click if ( $open_on_click ) { $css_class .= ' open-on-click'; } elseif ( $open_on_hover && $show_submenu_icons ) { $css_class .= ' open-on-hover-click'; } elseif ( $open_always ) { $css_class .= ' open-always'; } } $navigation_child_content_class = $is_navigation_child ? ' wp-block-navigation-item__content' : ''; // If this is the first level of submenus, include the overlay colors. if ( ( ( 0 < $depth && ! $is_nested ) || $is_nested ) && isset( $colors['overlay_css_classes'], $colors['overlay_inline_styles'] ) ) { $css_class .= ' ' . trim( implode( ' ', $colors['overlay_css_classes'] ) ); if ( '' !== $colors['overlay_inline_styles'] ) { $style_attribute = sprintf( ' style="%s"', esc_attr( $colors['overlay_inline_styles'] ) ); } } if ( (int) $page['page_id'] === $front_page_id ) { $css_class .= ' menu-item-home'; } $title = $page['title'] ? $page['title'] : __( '(no title)' ); $aria_label = sprintf( /* translators: Accessibility text. %s: Parent page title. */ __( '%s submenu' ), wp_strip_all_tags( $title ) ); $markup .= '<li class="wp-block-pages-list__item' . esc_attr( $css_class ) . '"' . $style_attribute . '>'; if ( isset( $page['children'] ) && $is_navigation_child && $open_on_click ) { $markup .= '<button aria-label="' . esc_attr( $aria_label ) . '" class="' . esc_attr( $navigation_child_content_class ) . ' wp-block-navigation-submenu__toggle" aria-expanded="false">' . wp_kses_post( $title ) . '</button><span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg></span>'; } else { $markup .= '<a class="wp-block-pages-list__item__link' . esc_attr( $navigation_child_content_class ) . '" href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' . wp_kses_post( $title ) . '</a>'; } if ( isset( $page['children'] ) ) { if ( $is_navigation_child && $show_submenu_icons && ! $open_on_click ) { $markup .= '<button aria-label="' . esc_attr( $aria_label ) . '" class="wp-block-navigation__submenu-icon wp-block-navigation-submenu__toggle" aria-expanded="false">'; $markup .= '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg>'; $markup .= '</button>'; } $markup .= '<ul class="wp-block-navigation__submenu-container">'; $markup .= block_core_page_list_render_nested_page_list( $submenu_visibility, $show_submenu_icons, $is_navigation_child, $page['children'], $is_nested, $active_page_ancestor_ids, $colors, $depth + 1 ); $markup .= '</ul>'; } $markup .= '</li>'; } return $markup;Changelog
Introduced in 5.8.0. 3 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$submenu_visibility retyped from untyped to string.verified against source$submenu_visibility added.verified against source$open_submenus_on_click removed.verified against sourceAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/blocks/page-list.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.