wppaste
WordPress

wp_render_layout_support_flag( string $block_content, array $block ): string

Since
5.8.0, 6.3.0, 6.3.0, 6.6.0
Source
wp-includes/block-supports/layout.php:648
Renders the layout config to the block wrapper.

Compatibility

WordPress
since 6.6.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

$block_contentstring
Rendered block content.
$blockarray
Block object.

Return value

string
Filtered block content.

Performance profile

How much work a call to wp_render_layout_support_flag() 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
Moderate

Only touches the object cache, via wp_cache_get().

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
114–222

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

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

  • cacheobject cachewp_cache_get()one call below wp_render_layout_support_flag()
  • hookthird-party callbacksapply_filters()one call below wp_render_layout_support_flag()

Further down the call graph this can also reach option, 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 · 24 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_render_layout_support_flag() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
block_has_support() && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports()114–123::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), ->get_updated_html()
block_has_support() && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports()118–127::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), ->get_updated_html()
block_has_support() && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports() && is_string($class_attribute) && $class_attribute122–131::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), ->get_attribute(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports()123–134::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), ->get_attribute(), ->next_tag(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports() && is_string($first_chunk)126–131::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), wp_unique_id_from_values(), ->next_tag(), ->get_updated_html()
block_has_support() && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports() && is_string($class_attribute) && $class_attribute126–135::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), ->get_attribute(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports()127–138::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), ->get_attribute(), ->next_tag(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports() && is_string($first_chunk)130–135::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), wp_unique_id_from_values(), ->next_tag(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports() && is_string($first_chunk) && is_string($class_attribute) && $class_attribute134–139::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), wp_unique_id_from_values(), ->next_tag(), ->get_attribute(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports() && is_string($first_chunk)135–142::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), wp_unique_id_from_values(), ->next_tag(), ->get_attribute(), ->next_tag(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports() && is_string($first_chunk) && is_string($class_attribute) && $class_attribute138–143::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), wp_unique_id_from_values(), ->next_tag(), ->get_attribute(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && current_theme_supports() && is_string($first_chunk)139–146::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), wp_unique_id_from_values(), ->next_tag(), ->get_attribute(), ->next_tag(), ->get_updated_html()
12 further outcomes, up to 222 instructions
block_has_support() && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style)193–202::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), ->get_updated_html()
block_has_support() && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style)197–204::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), end(), ->get_updated_html()
block_has_support() && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style) && is_string($class_attribute) && $class_attribute201–210::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), ->get_attribute(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style)202–213::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), ->get_attribute(), ->next_tag(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style) && is_string($first_chunk)205–210::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), wp_unique_id_from_values(), ->next_tag(), ->get_updated_html()
block_has_support() && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style) && is_string($class_attribute) && $class_attribute205–212::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), end(), ->get_attribute(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style)206–215::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), end(), ->get_attribute(), ->next_tag(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style) && is_string($first_chunk)209–212::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), end(), wp_unique_id_from_values(), ->next_tag(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style) && is_string($first_chunk) && is_string($class_attribute) && $class_attribute213–218::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), wp_unique_id_from_values(), ->next_tag(), ->get_attribute(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style) && is_string($first_chunk)214–221::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), wp_unique_id_from_values(), ->next_tag(), ->get_attribute(), ->next_tag(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style) && empty($outer_class_names) && is_string($first_chunk) && is_string($class_attribute) && $class_attribute217–219::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), end(), wp_unique_id_from_values(), ->next_tag(), ->get_attribute(), ->get_updated_html()
block_has_support() && !empty($fallback_layout) && !isset($used_layout) && !$global_settings && empty($value) && !current_theme_supports() && !is_array($gap_value) && !$block && $global_styles !== null && $global_block_gap_value === null && empty($style) && is_string($first_chunk)218–222::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), rules_group(), ->next_tag(), wp_get_global_settings(), wp_get_layout_definitions(), current_theme_supports(), wp_should_skip_block_supports_serialization(), sanitize_title(), wp_get_layout_style(), explode(), end(), wp_unique_id_from_values(), ->next_tag(), ->get_attribute(), ->next_tag(), ->get_updated_html()

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

PHPCompiledExecutedBranchesNotes
8.6-dev514114–221891 fewer instruction than PHP 8.5
8.5515114–22289
8.4515114–2228916 fewer instructions than PHP 8.3
8.3531118–22889
8.2531118–22889
8.1531118–22889
7.4531118–22889

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

Show all 16

Source code

function wp_render_layout_support_flag( $block_content, $block ) {	static $global_styles = null; 	$block_type            = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );	$block_supports_layout = block_has_support( $block_type, 'layout', false ) || block_has_support( $block_type, '__experimentalLayout', false );	$child_layout          = $block['attrs']['style']['layout'] ?? null; 	if ( ! $block_supports_layout && ! $child_layout ) {		return $block_content;	} 	$outer_class_names = array(); 	// Child layout specific logic.	if ( $child_layout ) {		/*		 * Generates a unique class for child block layout styles.		 *		 * To ensure consistent class generation across different page renders,		 * only properties that affect layout styling are used. These properties		 * come from `$block['attrs']['style']['layout']` and `$block['parentLayout']`.		 *		 * As long as these properties coincide, the generated class will be the same.		 */		$container_content_class = wp_unique_id_from_values(			array(				'layout'       => array_intersect_key(					$block['attrs']['style']['layout'] ?? array(),					array_flip(						array( 'selfStretch', 'flexSize', 'columnStart', 'columnSpan', 'rowStart', 'rowSpan' )					)				),				'parentLayout' => array_intersect_key(					$block['parentLayout'] ?? array(),					array_flip(						array( 'minimumColumnWidth', 'columnCount' )					)				),			),			'wp-container-content-'		); 		$child_layout_declarations = array();		$child_layout_styles       = array(); 		$self_stretch = $child_layout['selfStretch'] ?? null; 		if ( 'fixed' === $self_stretch && isset( $child_layout['flexSize'] ) ) {			$child_layout_declarations['flex-basis'] = $child_layout['flexSize'];			$child_layout_declarations['box-sizing'] = 'border-box';		} elseif ( 'fill' === $self_stretch ) {			$child_layout_declarations['flex-grow'] = '1';		} 		if ( isset( $child_layout['columnSpan'] ) ) {			$column_span                              = $child_layout['columnSpan'];			$child_layout_declarations['grid-column'] = "span $column_span";		}		if ( isset( $child_layout['rowSpan'] ) ) {			$row_span                              = $child_layout['rowSpan'];			$child_layout_declarations['grid-row'] = "span $row_span";		}		$child_layout_styles[] = array(			'selector'     => ".$container_content_class",			'declarations' => $child_layout_declarations,		); 		/*		 * If columnSpan is set, and the parent grid is responsive, i.e. if it has a minimumColumnWidth set,		 * the columnSpan should be removed on small grids. If there's a minimumColumnWidth, the grid is responsive.		 * But if the minimumColumnWidth value wasn't changed, it won't be set. In that case, if columnCount doesn't		 * exist, we can assume that the grid is responsive.		 */		if ( isset( $child_layout['columnSpan'] ) && ( isset( $block['parentLayout']['minimumColumnWidth'] ) || ! isset( $block['parentLayout']['columnCount'] ) ) ) {			$column_span_number  = floatval( $child_layout['columnSpan'] );			$parent_column_width = $block['parentLayout']['minimumColumnWidth'] ?? '12rem';			$parent_column_value = floatval( $parent_column_width );			$parent_column_unit  = explode( $parent_column_value, $parent_column_width ); 			/*

Changelog

Introduced in 5.8.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.

6.6.0
Removed duplicate container class from layout styles.from the docblock
6.3.0
Check for layout support via the layout key with fallback to __experimentalLayout.from the docblock
6.3.0
Adds compound class to layout wrapper for global spacing styles.from the docblock
5.8.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.0.7 tag, from src/wp-includes/block-supports/layout.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.