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:955
Compatibility
- WordPress
- since 6.6.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
$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
- 163–276
- 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 627.
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, 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 · 17 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() && !$global_settings && !$style_attr && !$block && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && !$class_attribute | 163–172 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && !$class_attribute | 167–176 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && $class_attribute && is_string($class_attribute) | 171–180 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), ->get_attribute(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && $class_attribute | 172–183 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), ->get_attribute(), ->next_tag(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && $class_attribute && is_string($class_attribute) | 175–184 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), ->get_attribute(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && $class_attribute | 176–187 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), ->get_attribute(), ->next_tag(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && is_string($first_chunk) && !$class_attribute | 182–193 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), wp_get_layout_style(), ->next_tag(), array_reverse(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && is_string($first_chunk) && !$class_attribute | 186–197 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), wp_get_layout_style(), ->next_tag(), array_reverse(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && is_string($first_chunk) && $class_attribute && is_string($class_attribute) | 190–201 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), wp_get_layout_style(), ->next_tag(), array_reverse(), ->get_attribute(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && is_string($first_chunk) && $class_attribute | 191–204 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), wp_get_layout_style(), ->next_tag(), array_reverse(), ->get_attribute(), ->next_tag(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && is_string($first_chunk) && $class_attribute && is_string($class_attribute) | 194–205 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), wp_get_layout_style(), ->next_tag(), array_reverse(), ->get_attribute(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && current_theme_supports() && is_string($first_chunk) && $class_attribute | 195–208 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), explode(), end(), wp_get_layout_style(), ->next_tag(), array_reverse(), ->get_attribute(), ->next_tag(), ->get_updated_html() |
5 further outcomes, up to 276 instructions
block_has_support() && !$global_settings && !$style_attr && !$block && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && empty($value) && !current_theme_supports() && $global_styles !== null && $global_block_gap_value === null && array_keys() && empty($style) && empty($outer_class_names) && !$class_attribute | 247–252 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), wp_sanitize_block_gap_value(), wp_should_skip_block_supports_serialization(), array_keys(), sanitize_title(), wp_unique_id_from_values(), wp_get_layout_style(), explode(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && ->next_tag() && !empty($fallback_layout) && !isset($used_layout) && empty($value) && !current_theme_supports() && $global_styles !== null && $global_block_gap_value === null && array_keys() && empty($style) && empty($outer_class_names) && $class_attribute && is_string($class_attribute) | 255–260 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), wp_sanitize_block_gap_value(), wp_should_skip_block_supports_serialization(), array_keys(), sanitize_title(), wp_unique_id_from_values(), wp_get_layout_style(), explode(), ->get_attribute(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && !current_theme_supports() && $global_styles !== null && $global_block_gap_value === null && array_keys() && empty($style) && empty($outer_class_names) && $class_attribute | 256–263 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), wp_sanitize_block_gap_value(), wp_should_skip_block_supports_serialization(), array_keys(), sanitize_title(), wp_unique_id_from_values(), wp_get_layout_style(), explode(), ->get_attribute(), ->next_tag(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && !current_theme_supports() && $global_styles !== null && $global_block_gap_value === null && array_keys() && empty($style) && empty($outer_class_names) && is_string($first_chunk) && array_reverse() && !$class_attribute | 266–267 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), wp_sanitize_block_gap_value(), wp_should_skip_block_supports_serialization(), array_keys(), sanitize_title(), wp_unique_id_from_values(), wp_get_layout_style(), explode(), wp_get_layout_style(), ->next_tag(), array_reverse(), ->get_updated_html() |
block_has_support() && !$global_settings && !$style_attr && !$block && !empty($fallback_layout) && !isset($used_layout) && empty($value) && !current_theme_supports() && $global_styles !== null && $global_block_gap_value === null && array_keys() && empty($style) && empty($outer_class_names) && is_string($first_chunk) && array_reverse() && $class_attribute && !is_string($class_attribute) | 275–276 | ::WP_Block_Type_Registry(), ->get_registered(), block_has_support(), wp_get_global_settings(), ::WP_Theme_JSON(), wp_get_layout_child_values(), array_intersect_key(), wp_unique_id_from_values(), wp_get_child_layout_style_rules(), wp_style_engine_get_stylesheet_from_css_rules(), layout(), ->next_tag(), wp_get_layout_definitions(), current_theme_supports(), wp_sanitize_block_gap_value(), wp_should_skip_block_supports_serialization(), array_keys(), sanitize_title(), wp_unique_id_from_values(), wp_get_layout_style(), explode(), wp_get_layout_style(), ->next_tag(), array_reverse(), ->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 | 624 | 163–276 | 109 | 3 fewer instructions than PHP 8.5 |
| 8.5 | 627 | 163–276 | 109 | |
| 8.4 | 627 | 163–276 | 109 | 13 fewer instructions than PHP 8.3 |
| 8.3 | 640 | 167–280 | 109 | |
| 8.2 | 640 | 167–280 | 109 | 1 more instruction than PHP 8.1 |
| 8.1 | 639 | 167–280 | 109 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 640 | 167–280 | 109 |
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 · 22
- block_has_support()Checks whether the current block type supports the feature requested.
- wp_get_global_settings()Gets the settings resulting of merging core, theme, and user data.
- wp_get_layout_child_values()Returns the child-layout-only subset of a layout object.
- wp_unique_id_from_values()Generates a unique ID based on the structure and values of a given array.
- wp_get_child_layout_style_rules()Returns child layout styles for a block affected by its parent's layout.
- wp_style_engine_get_stylesheet_from_css_rules()Returns compiled CSS from a collection of selectors and declarations.
- 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_sanitize_block_gap_value()Sanitizes a block gap value before layout style generation.
- wp_should_skip_block_supports_serialization()Checks whether serialization of the current block's supported properties should occur.
- wp_get_global_styles()Gets the styles resulting of merging core, theme, and user data.
Show all 22
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- wp_get_block_style_variation_name_from_registered_style()Gets the first style variation name from a className string that matches a registered style.
- wp_get_layout_container_values()Returns the container-layout subset of a layout object.
- wp_get_layout_style()Generates the CSS corresponding to the provided layout.
- WP_Block_Type_Registry::get_instance()::get_registered()
- WP_Block_Type_Registry::get_instance()Utility method to retrieve the main instance of the class.
- WP_Theme_JSON::get_viewport_media_queries()Returns CSS media queries for responsive viewport style states.
- WP_HTML_Tag_Processor::__construct()Constructor.
- WP_Block_Styles_Registry::get_instance()Utility method to retrieve the main instance of the class.
- WP_HTML_Processor::is_void()Returns whether a given element is an HTML Void Element
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 ); $style_attr = $block['attrs']['style'] ?? array(); /* * A block with no layout support and no style attribute at all cannot * produce layout output, so return before resolving global settings. * * Resolving settings is not read-only: on a cold cache it queries the * user's `wp_global_styles` post, which fires `the_posts`. A callback on * that hook that renders blocks re-enters this filter, and the content it * renders at that point is the global styles post itself, which parses to a * single block with no name and no attributes. Without this return that * block resolves settings again and the recursion has no base case. */ if ( ! $block_supports_layout && empty( $style_attr ) ) { return $block_content; } $global_settings = wp_get_global_settings(); $viewport_settings = $global_settings['viewport'] ?? null; $responsive_media_queries = WP_Theme_JSON::get_viewport_media_queries( $viewport_settings ); $child_layout = $style_attr['layout'] ?? null; /* * Collect responsive viewport child layout overrides so that a block with * only responsive child layout (no base child layout) is still processed. */ $viewport_child_layouts = array(); foreach ( $responsive_media_queries as $breakpoint => $media_query ) { $viewport_child = wp_get_layout_child_values( $style_attr[ $breakpoint ]['layout'] ?? null ); if ( ! empty( $viewport_child ) ) { $viewport_child_layouts[ $breakpoint ] = array( 'media_query' => $media_query, 'child_layout' => $viewport_child, ); } } if ( ! $block_supports_layout && ! $child_layout && empty( $viewport_child_layouts ) ) { return $block_content; } $outer_class_names = array(); // Child layout specific logic. if ( $child_layout || ! empty( $viewport_child_layouts ) ) { $base_child_layout = wp_get_layout_child_values( $child_layout ); $parent_layout = $block['parentLayout'] ?? array(); /* * 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']`, viewport overrides in * `$block['attrs']['style'][$breakpoint]['layout']`, and `$block['parentLayout']`. * * As long as these properties coincide, the generated class will be the same. */ $container_content_hash_input = array( 'layout' => $base_child_layout, 'parentLayout' => array_intersect_key( $parent_layout, array_flip( array( 'minimumColumnWidth', 'columnCount' ) ) ), ); foreach ( $viewport_child_layouts as $breakpoint => $viewport_data ) { $container_content_hash_input[ $breakpoint ] = $viewport_data['child_layout']; } $container_content_class = wp_unique_id_from_values( $container_content_hash_input, 'wp-container-content-' ); $child_layout_styles = wp_get_child_layout_style_rules( ".$container_content_class", $base_child_layout, $parent_layout );Changelog
Introduced in 5.8.0. Unchanged from 6.7.7 through 7.1.0.
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 7.1.0 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.