@@ -955,17 +955,20 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
955955function wp_render_layout_support_flag ( $ block_content , $ block ) {
956956 static $ global_styles = null ;
957957
958- $ block_type = WP_Block_Type_Registry::get_instance ()->get_registered ( $ block ['blockName ' ] );
959- $ block_supports_layout = block_has_support ( $ block_type , 'layout ' , false ) || block_has_support ( $ block_type , '__experimentalLayout ' , false );
960- $ style_attr = $ block ['attrs ' ]['style ' ] ?? array ();
961- $ child_layout = $ style_attr ['layout ' ] ?? null ;
958+ $ block_type = WP_Block_Type_Registry::get_instance ()->get_registered ( $ block ['blockName ' ] );
959+ $ block_supports_layout = block_has_support ( $ block_type , 'layout ' , false ) || block_has_support ( $ block_type , '__experimentalLayout ' , false );
960+ $ style_attr = $ block ['attrs ' ]['style ' ] ?? array ();
961+ $ global_settings = wp_get_global_settings ();
962+ $ viewport_settings = $ global_settings ['viewport ' ] ?? null ;
963+ $ responsive_media_queries = WP_Theme_JSON::get_viewport_media_queries ( $ viewport_settings );
964+ $ child_layout = $ style_attr ['layout ' ] ?? null ;
962965
963966 /*
964967 * Collect responsive viewport child layout overrides so that a block with
965968 * only responsive child layout (no base child layout) is still processed.
966969 */
967970 $ viewport_child_layouts = array ();
968- foreach ( WP_Theme_JSON:: RESPONSIVE_BREAKPOINTS as $ breakpoint => $ media_query ) {
971+ foreach ( $ responsive_media_queries as $ breakpoint => $ media_query ) {
969972 $ viewport_child = wp_get_layout_child_values ( $ style_attr [ $ breakpoint ]['layout ' ] ?? null );
970973
971974 if ( ! empty ( $ viewport_child ) ) {
@@ -1075,7 +1078,6 @@ function wp_render_layout_support_flag( $block_content, $block ) {
10751078 return $ block_content ;
10761079 }
10771080
1078- $ global_settings = wp_get_global_settings ();
10791081 $ fallback_layout = $ block_type ->supports ['layout ' ]['default ' ] ?? array ();
10801082 if ( empty ( $ fallback_layout ) ) {
10811083 $ fallback_layout = $ block_type ->supports ['__experimentalLayout ' ]['default ' ] ?? array ();
@@ -1183,7 +1185,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
11831185 $ block_spacing ,
11841186 );
11851187
1186- foreach ( array_keys ( WP_Theme_JSON:: RESPONSIVE_BREAKPOINTS ) as $ breakpoint ) {
1188+ foreach ( array_keys ( $ responsive_media_queries ) as $ breakpoint ) {
11871189 $ viewport_style = $ style_attr [ $ breakpoint ] ?? null ;
11881190 if ( ! is_array ( $ viewport_style ) ) {
11891191 continue ;
@@ -1231,7 +1233,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
12311233 * Emit responsive container layout styles using the same $container_class
12321234 * selector as the base layout so they target the inner block wrapper.
12331235 */
1234- foreach ( WP_Theme_JSON:: RESPONSIVE_BREAKPOINTS as $ breakpoint => $ media_query ) {
1236+ foreach ( $ responsive_media_queries as $ breakpoint => $ media_query ) {
12351237 $ viewport_style = $ style_attr [ $ breakpoint ] ?? null ;
12361238 if ( ! is_array ( $ viewport_style ) ) {
12371239 continue ;
0 commit comments