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:570
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
- Scaling
- Scales with input
- Instructions
- 119–217
- Plugin surface
- None
- Called by
- 0
Only touches the object cache, via wp_cache_get().
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 506.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- cacheobject cache
wp_cache_get()one call below wp_render_layout_support_flag() - hookthird-party callbacks
apply_filters()one call below wp_render_layout_support_flag()
Further down the call graph this can also reach option, serialize, transient and query. 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.
| When | Instructions | Calls it makes |
|---|---|---|
block_has_support() && !isset($value) && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() | 119–129 | ::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() && !isset($value) && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() | 123–133 | ::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() && !isset($value) && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() && is_string($class_attribute) && $class_attribute | 127–137 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() | 128–140 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() && is_string($first_chunk) | 131–137 | ::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() && !isset($value) && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() && is_string($class_attribute) && $class_attribute | 131–141 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() | 132–144 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() && is_string($first_chunk) | 135–141 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() && is_string($first_chunk) && is_string($class_attribute) && $class_attribute | 139–145 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() && is_string($first_chunk) | 140–148 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() && is_string($first_chunk) && is_string($class_attribute) && $class_attribute | 143–149 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && current_theme_supports() && is_string($first_chunk) | 144–152 | ::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 217 instructions
block_has_support() && !isset($value) && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) | 187–197 | ::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() && !isset($value) && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) | 191–198 | ::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() && !isset($value) && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) && is_string($class_attribute) && $class_attribute | 195–205 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) | 196–208 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) && is_string($first_chunk) | 199–205 | ::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() && !isset($value) && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) && is_string($class_attribute) && $class_attribute | 199–206 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) | 200–209 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) && is_string($first_chunk) | 203–206 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) && is_string($first_chunk) && is_string($class_attribute) && $class_attribute | 207–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(), wp_unique_id_from_values(), ->next_tag(), ->get_attribute(), ->get_updated_html() |
block_has_support() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) && is_string($first_chunk) | 208–216 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) && empty($outer_class_names) && is_string($first_chunk) && is_string($class_attribute) && $class_attribute | 211–214 | ::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() && !isset($value) && !empty($fallback_layout) && !isset($used_layout) && !isset($global_settings) && empty($value) && !current_theme_supports() && !is_array($gap_value) && empty($style) && is_string($first_chunk) | 212–217 | ::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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 505 | 119–216 | 77 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 506 | 119–217 | 77 | |
| 8.4 | 506 | 119–217 | 77 | 13 fewer instructions than PHP 8.3 |
| 8.3 | 519 | 123–223 | 77 | |
| 8.2 | 519 | 123–223 | 77 | |
| 8.1 | 519 | 123–223 | 77 | 14 fewer instructions than PHP 7.4 |
| 7.4 | 533 | 123–224 | 77 |
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_has_support()Checks whether the current block type supports the feature requested.
- wp_unique_id_from_values()Generates a unique ID based on the structure and values of a given array.
- wp_style_engine_get_stylesheet_from_css_rules()Returns compiled CSS from a collection of selectors and declarations.
- wp_get_global_settings()Gets the settings resulting of merging core, theme, and user data.
- wp_get_layout_definitions()Returns layout definitions, keyed by layout type.
- sanitize_title()Sanitizes a string into a slug, which can be used in URLs or HTML attributes.
- current_theme_supports()Checks a theme's support for a given feature.
- wp_should_skip_block_supports_serialization()Checks whether serialization of the current block's supported properties should occur.
- wp_get_layout_style()Generates the CSS corresponding to the provided layout.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- WP_Block_Type_Registry::get_instance()::get_registered()
- WP_Block_Type_Registry::get_instance()Utility method to retrieve the main instance of the class.
Show all 13
- WP_HTML_Tag_Processor::__construct()Constructor.
Source code
function wp_render_layout_support_flag( $block_content, $block ) { $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 = isset( $block['attrs']['style']['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 = isset( $child_layout['selfStretch'] ) ? $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 = isset( $block['parentLayout']['minimumColumnWidth'] ) ? $block['parentLayout']['minimumColumnWidth'] : '12rem'; $parent_column_value = floatval( $parent_column_width ); $parent_column_unit = explode( $parent_column_value, $parent_column_width ); /* * If there is no unit, the width has somehow been mangled so we reset both unit and value * to defaults.Changelog
Introduced in 5.8.0. Unchanged from 6.7.10 through 7.1.3.
Signature, return type and hooks compared across 5 parsed releases.
layout key with fallback to __experimentalLayout.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 6.9.10 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.