diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php index 434f06c8b74f95..24c6f147d8a7cd 100644 --- a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php @@ -910,7 +910,16 @@ protected static function get_property_value( $styles, $path, $theme_json = null * @return string Layout styles for the block. */ protected function get_layout_styles( $block_metadata ) { - $block_rules = ''; + $block_rules = ''; + $block_type = null; + + if ( isset( $block_metadata['name'] ) ) { + $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_metadata['name'] ); + if ( ! block_has_support( $block_type, array( '__experimentalLayout' ), false ) ) { + return $block_rules; + } + } + $selector = isset( $block_metadata['selector'] ) ? $block_metadata['selector'] : ''; $has_block_gap_support = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null; $has_block_styles_support = current_theme_supports( 'wp-block-styles' ); @@ -926,8 +935,7 @@ protected function get_layout_styles( $block_metadata ) { // Use a fallback gap value if block gap support is not available. if ( ! $has_block_gap_support ) { $block_gap_value = '0.5em'; - if ( isset( $block_metadata['name'] ) ) { - $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_metadata['name'] ); + if ( ! empty( $block_type ) ) { $block_gap_value = _wp_array_get( $block_type->supports, array( 'spacing', 'blockGap', '__experimentalDefault' ), '0.5em' ); } } else {