WP_Navigation_Block_Renderer::get_responsive_container_markup( array $attributes, WP_Block_List $inner_blocks, string $inner_blocks_html ): string
- Since
- 6.5.0
- Source
wp-includes/blocks/navigation.php:730
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.
$inner_blocksWP_Block_List- The list of inner blocks.
$inner_blocks_htmlstring- The markup for the inner blocks.
Return value
string- Returns the container markup.
Performance profile
How much work a call to WP_Navigation_Block_Renderer::get_responsive_container_markup() 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
- 104–159
- Plugin surface
- None
- 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 181.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below WP_Navigation_Block_Renderer::get_responsive_container_markup()
Further down the call graph this can also reach option, cache, serialize, 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 · 20 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_responsive_container_markup() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($attributes) && empty($attributes) | 104–121 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && empty($attributes) | 106–126 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), __(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && empty($attributes) | 108–131 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), __(), __(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && empty($attributes) | 111–128 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && empty($attributes) | 113–133 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), __(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && empty($attributes) | 113–133 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), __(), __(), __(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && empty($attributes) | 115–138 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), __(), __(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && empty($attributes) | 118–135 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), __(), __(), __(), __(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && empty($attributes) | 120–140 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), __(), __(), __(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && !empty($attributes) | 124–138 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && empty($attributes) | 125–142 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_responsive_container_classes(), __(), __(), __(), __(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && !empty($attributes) | 126–143 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), __(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
8 further outcomes, up to 159 instructions
!isset($attributes) && !empty($attributes) | 128–148 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), __(), __(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && !empty($attributes) | 131–145 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && !empty($attributes) | 133–150 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), __(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && !empty($attributes) | 133–150 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), __(), __(), __(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && !empty($attributes) | 135–155 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), __(), __(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && !empty($attributes) | 138–152 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), __(), __(), __(), __(), ::get_overlay_inline_styles(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && !empty($attributes) | 140–157 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), __(), __(), __(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
!isset($attributes) && !empty($attributes) | 145–159 | ::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), ::get_overlay_blocks_from_template_part(), ::get_template_part_blocks_html(), block_core_navigation_overlay_html_has_close_block(), block_core_navigation_set_overlay_image_fetch_priority(), ::get_responsive_container_classes(), __(), __(), __(), __(), ::get_overlay_inline_styles(), sprintf(), esc_attr(), esc_attr(), esc_attr(), sprintf() |
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 | 179 | 104–157 | 16 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 181 | 104–159 | 16 | |
| 8.4 | 181 | 104–159 | 16 | 11 fewer instructions than PHP 8.3 |
| 8.3 | 192 | 114–170 | 16 | |
| 8.2 | 192 | 114–170 | 16 | |
| 8.1 | 192 | 114–170 | 16 | 2 fewer instructions than PHP 7.4 |
| 7.4 | 194 | 114–172 | 16 |
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 · 13
- block_core_navigation_build_css_colors()Build an array with CSS classes and inline styles defining the colors which will be applied to the navigation markup in the front-end.
- wp_unique_id()Gets unique ID.
- block_core_navigation_overlay_html_has_close_block()Checks if the overlay HTML contains a navigation-overlay-close block.
- block_core_navigation_add_directives_to_overlay_close()Add Interactivity API directives to the navigation-overlay-close block markup using the Tag Processor.
- block_core_navigation_set_overlay_image_fetch_priority()Sets fetchpriority="low" on all IMG tags within the navigation overlay.
- __()Retrieves the translation of $text.
- esc_attr()Escaping for HTML attributes.
- static::is_interactive()
- static::get_overlay_blocks_from_template_part()
- static::get_template_part_blocks_html()
- WP_HTML_Tag_Processor::__construct()Constructor.
- static::get_responsive_container_classes()
Show all 13
- static::get_overlay_inline_styles()
Source code
<?php private static function get_responsive_container_markup( $attributes, $inner_blocks, $inner_blocks_html ) { $is_interactive = static::is_interactive( $attributes, $inner_blocks ); $colors = block_core_navigation_build_css_colors( $attributes ); $modal_unique_id = wp_unique_id( 'modal-' ); $is_hidden_by_default = isset( $attributes['overlayMenu'] ) && 'always' === $attributes['overlayMenu']; // Set-up variables for custom overlays. $has_custom_overlay = false; $close_button_markup = ''; $has_custom_overlay_close_block = false; $overlay_blocks_html = ''; $custom_overlay_markup = ''; // Check if an overlay template part is selected and render it. // This needs to happen before building classes so we know if overlay blocks actually exist. if ( ! empty( $attributes['overlay'] ) ) { // Get blocks from the overlay template part. $overlay_blocks = static::get_overlay_blocks_from_template_part( $attributes['overlay'], $attributes ); // Render template part blocks directly without navigation container wrapper. $overlay_blocks_html = static::get_template_part_blocks_html( $overlay_blocks ); // Check if overlay contains a navigation-overlay-close block (detect in rendered HTML so it works with patterns). $has_custom_overlay_close_block = block_core_navigation_overlay_html_has_close_block( $overlay_blocks_html ); // Add Interactivity API directives to the overlay close block if present. if ( $has_custom_overlay_close_block && $is_interactive ) { $tags = new WP_HTML_Tag_Processor( $overlay_blocks_html ); $overlay_blocks_html = block_core_navigation_add_directives_to_overlay_close( $tags ); } // Images in the overlay are hidden until the menu is opened. Pre-set // fetchpriority="low" so that when wp_filter_content_tags() processes the // parent template part, it sees the attribute already present and calls // wp_get_loading_optimization_attributes() with fetchpriority="low", which both prevents // fetchpriority="high" from being added and stops the LCP counter from being incremented. $overlay_blocks_html = block_core_navigation_set_overlay_image_fetch_priority( $overlay_blocks_html ); } $has_custom_overlay = ! empty( $overlay_blocks_html ); $responsive_container_classes = static::get_responsive_container_classes( $is_hidden_by_default, $has_custom_overlay, $colors ); $open_button_classes = array( 'wp-block-navigation__responsive-container-open', $is_hidden_by_default ? 'always-shown' : '', ); $should_display_icon_label = isset( $attributes['hasIcon'] ) && true === $attributes['hasIcon']; $toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 7.5h16v1.5H4z"></path><path d="M4 15h16v1.5H4z"></path></svg>'; if ( isset( $attributes['icon'] ) ) { if ( 'menu' === $attributes['icon'] ) { $toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 5v1.5h14V5H5z"></path><path d="M5 12.8h14v-1.5H5v1.5z"></path><path d="M5 19h14v-1.5H5V19z"></path></svg>'; } } $toggle_button_content = $should_display_icon_label ? $toggle_button_icon : __( 'Menu' ); $toggle_close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"></path></svg>'; $toggle_close_button_content = $should_display_icon_label ? $toggle_close_button_icon : __( 'Close' ); $toggle_aria_label_open = $should_display_icon_label ? 'aria-label="' . __( 'Open menu' ) . '"' : ''; // Open button label. $toggle_aria_label_close = $should_display_icon_label ? 'aria-label="' . __( 'Close menu' ) . '"' : ''; // Close button label. // Add Interactivity API directives to the markup if needed. $open_button_directives = ''; $responsive_container_directives = ''; $responsive_dialog_directives = ''; $close_button_directives = ''; if ( $is_interactive ) { $open_button_directives = ' data-wp-on--click="actions.openMenuOnClick" data-wp-on--keydown="actions.handleMenuKeydown" '; $responsive_container_directives = ' data-wp-class--has-modal-open="state.isMenuOpen" data-wp-class--is-menu-open="state.isMenuOpen" data-wp-watch="callbacks.initMenu" data-wp-on--keydown="actions.handleMenuKeydown" data-wp-on--focusout="actions.handleMenuFocusout" tabindex="-1" '; $responsive_dialog_directives = ' data-wp-bind--aria-modal="state.ariaModal" data-wp-bind--aria-label="state.ariaLabel" data-wp-bind--role="state.roleAttribute"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.