wppaste
WordPress

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:459
Get the responsive container markup

Compatibility

WordPress
since 6.5.0
PHP
7.4–8.6-dev
  • 6.7.10
  • 6.8.11
  • 6.9.10
  • 7.0.7
  • 7.1.3

Present in every tracked release (6.7.10 to 7.1.3), 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

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
98–130

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 139.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_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 · 5 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.

WhenInstructionsCalls it makes
always98–116::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), safecss_filter_attr(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), sprintf()
always100–121::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), __(), safecss_filter_attr(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), sprintf()
always102–126::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), __(), __(), safecss_filter_attr(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), sprintf()
always107–128::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), __(), __(), __(), safecss_filter_attr(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), sprintf()
always112–130::is_interactive(), block_core_navigation_build_css_colors(), wp_unique_id(), __(), __(), __(), __(), safecss_filter_attr(), esc_attr(), esc_attr(), esc_attr(), esc_attr(), sprintf()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev13798–128122 fewer instructions than PHP 8.5
8.513998–13012
8.413998–130129 fewer instructions than PHP 8.3
8.3148107–13912
8.2148107–13912
8.1148107–139123 fewer instructions than PHP 7.4
7.4151107–14212

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 · 6

Source code

	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']; 		$responsive_container_classes = array(			'wp-block-navigation__responsive-container',			$is_hidden_by_default ? 'hidden-by-default' : '',			implode( ' ', $colors['overlay_css_classes'] ),		);		$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"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></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.5h14V5H5zm0 7.8h14v-1.5H5v1.5zM5 19h14v-1.5H5V19z" /></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-async--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-async--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"			';			$close_button_directives                 = '				data-wp-on-async--click="actions.closeMenuOnClick"			';			$responsive_container_content_directives = '				data-wp-watch="callbacks.focusFirstElement"			';		} 		$overlay_inline_styles = esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ); 		return sprintf(			'<button aria-haspopup="dialog" %3$s class="%6$s" %10$s>%8$s</button>				<div class="%5$s" %7$s id="%1$s" %11$s>					<div class="wp-block-navigation__responsive-close" tabindex="-1">						<div class="wp-block-navigation__responsive-dialog" %12$s>							<button %4$s class="wp-block-navigation__responsive-container-close" %13$s>%9$s</button>							<div class="wp-block-navigation__responsive-container-content" %14$s id="%1$s-content">								%2$s							</div>						</div>					</div>				</div>',			esc_attr( $modal_unique_id ),			$inner_blocks_html,			$toggle_aria_label_open,			$toggle_aria_label_close,			esc_attr( implode( ' ', $responsive_container_classes ) ),

Changelog

Introduced in 6.5.0. Unchanged from 6.7.10 through 7.1.3.

  1. 6.7.10
  2. 6.8.11
  3. 6.9.10
  4. 7.0.7
  5. 7.1.3

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.10 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.