WP_Navigation_Block_Renderer::get_inner_blocks( array $attributes, WP_Block $block ): WP_Block_List
- Since
- 6.5.0
- Source
wp-includes/blocks/navigation.php:518
Compatibility
- WordPress
- since 6.5.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
$attributesarray- The block attributes.
$blockWP_Block- The parsed block.
Return value
WP_Block_List- Returns the inner blocks for the navigation block.
Performance profile
How much work a call to WP_Navigation_Block_Renderer::get_inner_blocks() 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
- Trivial
- Scaling
- Constant
- Instructions
- 22–54
- Plugin surface
- 1 hook
- Called by
- 0
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 54.
Third-party callbacks on 'block_core_navigation_render_inner_blocks' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach query, option, cache, serialize 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 · 24 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Navigation_Block_Renderer::get_inner_blocks() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!$attributes && !empty($inner_blocks) | 22–31 | apply_filters(), block_core_navigation_get_post_ids() |
!$attributes && empty($inner_blocks) | 26–35 | ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids() |
$attributes && !empty($inner_blocks) | 26–35 | ::get_inner_blocks_from_navigation_post(), apply_filters(), block_core_navigation_get_post_ids() |
!$attributes && !empty($inner_blocks) | 27–36 | apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
$attributes && empty($inner_blocks) | 30–39 | ::get_inner_blocks_from_navigation_post(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids() |
!$attributes && empty($inner_blocks) | 31–40 | ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
$attributes && !empty($inner_blocks) | 31–40 | ::get_inner_blocks_from_navigation_post(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
defined('IS_GUTENBERG_PLUGIN') && !block_core_navigation_get_menu_items_at_location() && !empty($inner_blocks) | 34–37 | block_core_navigation_get_menu_items_at_location(), apply_filters(), block_core_navigation_get_post_ids() |
$attributes && empty($inner_blocks) | 35–44 | ::get_inner_blocks_from_navigation_post(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
defined('IS_GUTENBERG_PLUGIN') && !block_core_navigation_get_menu_items_at_location() && empty($inner_blocks) | 38–41 | block_core_navigation_get_menu_items_at_location(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids() |
defined('IS_GUTENBERG_PLUGIN') && !block_core_navigation_get_menu_items_at_location() && !empty($inner_blocks) | 38–41 | block_core_navigation_get_menu_items_at_location(), ::get_inner_blocks_from_navigation_post(), apply_filters(), block_core_navigation_get_post_ids() |
defined('IS_GUTENBERG_PLUGIN') && block_core_navigation_get_menu_items_at_location() && !empty($inner_blocks) | 38–41 | block_core_navigation_get_menu_items_at_location(), block_core_navigation_get_inner_blocks_from_unstable_location(), apply_filters(), block_core_navigation_get_post_ids() |
12 further outcomes, up to 54 instructions
defined('IS_GUTENBERG_PLUGIN') && !block_core_navigation_get_menu_items_at_location() && !empty($inner_blocks) | 39–42 | block_core_navigation_get_menu_items_at_location(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
defined('IS_GUTENBERG_PLUGIN') && !block_core_navigation_get_menu_items_at_location() && empty($inner_blocks) | 42–45 | block_core_navigation_get_menu_items_at_location(), ::get_inner_blocks_from_navigation_post(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids() |
defined('IS_GUTENBERG_PLUGIN') && block_core_navigation_get_menu_items_at_location() && empty($inner_blocks) | 42–45 | block_core_navigation_get_menu_items_at_location(), block_core_navigation_get_inner_blocks_from_unstable_location(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids() |
defined('IS_GUTENBERG_PLUGIN') && block_core_navigation_get_menu_items_at_location() && !empty($inner_blocks) | 42–45 | block_core_navigation_get_menu_items_at_location(), block_core_navigation_get_inner_blocks_from_unstable_location(), ::get_inner_blocks_from_navigation_post(), apply_filters(), block_core_navigation_get_post_ids() |
defined('IS_GUTENBERG_PLUGIN') && !block_core_navigation_get_menu_items_at_location() && empty($inner_blocks) | 43–46 | block_core_navigation_get_menu_items_at_location(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
defined('IS_GUTENBERG_PLUGIN') && !block_core_navigation_get_menu_items_at_location() && !empty($inner_blocks) | 43–46 | block_core_navigation_get_menu_items_at_location(), ::get_inner_blocks_from_navigation_post(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
defined('IS_GUTENBERG_PLUGIN') && block_core_navigation_get_menu_items_at_location() && !empty($inner_blocks) | 43–46 | block_core_navigation_get_menu_items_at_location(), block_core_navigation_get_inner_blocks_from_unstable_location(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
defined('IS_GUTENBERG_PLUGIN') && block_core_navigation_get_menu_items_at_location() && empty($inner_blocks) | 46–49 | block_core_navigation_get_menu_items_at_location(), block_core_navigation_get_inner_blocks_from_unstable_location(), ::get_inner_blocks_from_navigation_post(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids() |
defined('IS_GUTENBERG_PLUGIN') && !block_core_navigation_get_menu_items_at_location() && empty($inner_blocks) | 47–50 | block_core_navigation_get_menu_items_at_location(), ::get_inner_blocks_from_navigation_post(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
defined('IS_GUTENBERG_PLUGIN') && block_core_navigation_get_menu_items_at_location() && empty($inner_blocks) | 47–50 | block_core_navigation_get_menu_items_at_location(), block_core_navigation_get_inner_blocks_from_unstable_location(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
defined('IS_GUTENBERG_PLUGIN') && block_core_navigation_get_menu_items_at_location() && !empty($inner_blocks) | 47–50 | block_core_navigation_get_menu_items_at_location(), block_core_navigation_get_inner_blocks_from_unstable_location(), ::get_inner_blocks_from_navigation_post(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
defined('IS_GUTENBERG_PLUGIN') && block_core_navigation_get_menu_items_at_location() && empty($inner_blocks) | 51–54 | block_core_navigation_get_menu_items_at_location(), block_core_navigation_get_inner_blocks_from_unstable_location(), ::get_inner_blocks_from_navigation_post(), ::get_inner_blocks_from_fallback(), apply_filters(), block_core_navigation_get_post_ids(), _prime_post_caches() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 54 instructions, 22–54 executed per call, 9 branches. The work does not change between versions.
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.
Hooks and filters fired · 1
One hook fires while WP_Navigation_Block_Renderer::get_inner_blocks() runs, in this order:
- apply_filters( block_core_navigation_render_inner_blocks )filterline 559 (+41 into the body)
Filter navigation block $inner_blocks.
Uses · 7
- block_core_navigation_get_menu_items_at_location()Returns the menu items for a WordPress menu location.
- block_core_navigation_get_inner_blocks_from_unstable_location()Gets the inner blocks for the navigation block from the unstable location attribute.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- block_core_navigation_get_post_ids()Iterate through all inner blocks recursively and get navigation link block's post IDs.
- _prime_post_caches()Adds any posts from the given IDs to the cache that do not already exist in cache.
- static::get_inner_blocks_from_navigation_post()
- static::get_inner_blocks_from_fallback()
Source code
private static function get_inner_blocks( $attributes, $block ) { $inner_blocks = $block->inner_blocks; // Ensure that blocks saved with the legacy ref attribute name (navigationMenuId) continue to render. if ( array_key_exists( 'navigationMenuId', $attributes ) ) { $attributes['ref'] = $attributes['navigationMenuId']; } // If: // - the gutenberg plugin is active // - `__unstableLocation` is defined // - we have menu items at the defined location // - we don't have a relationship to a `wp_navigation` Post (via `ref`). // ...then create inner blocks from the classic menu assigned to that location. if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && array_key_exists( '__unstableLocation', $attributes ) && ! array_key_exists( 'ref', $attributes ) && ! empty( block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] ) ) ) { $inner_blocks = block_core_navigation_get_inner_blocks_from_unstable_location( $attributes ); } // Load inner blocks from the navigation post. if ( array_key_exists( 'ref', $attributes ) ) { $inner_blocks = static::get_inner_blocks_from_navigation_post( $attributes ); } // If there are no inner blocks then fallback to rendering an appropriate fallback. if ( empty( $inner_blocks ) ) { $inner_blocks = static::get_inner_blocks_from_fallback( $attributes ); } /** * Filter navigation block $inner_blocks. * Allows modification of a navigation block menu items. * * @since 6.1.0 * * @param \WP_Block_List $inner_blocks */ $inner_blocks = apply_filters( 'block_core_navigation_render_inner_blocks', $inner_blocks ); $post_ids = block_core_navigation_get_post_ids( $inner_blocks ); if ( $post_ids ) { _prime_post_caches( $post_ids, false, false ); } return $inner_blocks; }Changelog
Introduced in 6.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/blocks/navigation.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.