@@ -238,13 +238,13 @@ function wp_register_layout_support( $block_type ) {
238238 * @return string CSS styles on success. Else, empty string.
239239 */
240240function wp_get_layout_style ( $ selector , $ layout , $ has_block_gap_support = false , $ gap_value = null , $ should_skip_gap_serialization = false , $ fallback_gap_value = '0.5em ' , $ block_spacing = null ) {
241- $ layout_type = isset ( $ layout ['type ' ] ) ? $ layout [ ' type ' ] : 'default ' ;
241+ $ layout_type = $ layout ['type ' ] ?? 'default ' ;
242242 $ layout_styles = array ();
243243
244244 if ( 'default ' === $ layout_type ) {
245245 if ( $ has_block_gap_support ) {
246246 if ( is_array ( $ gap_value ) ) {
247- $ gap_value = isset ( $ gap_value ['top ' ] ) ? $ gap_value [ ' top ' ] : null ;
247+ $ gap_value = $ gap_value ['top ' ] ?? null ;
248248 }
249249 if ( null !== $ gap_value && ! $ should_skip_gap_serialization ) {
250250 // Get spacing CSS variable from preset value if provided.
@@ -274,9 +274,9 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
274274 }
275275 }
276276 } elseif ( 'constrained ' === $ layout_type ) {
277- $ content_size = isset ( $ layout ['contentSize ' ] ) ? $ layout [ ' contentSize ' ] : '' ;
278- $ wide_size = isset ( $ layout ['wideSize ' ] ) ? $ layout [ ' wideSize ' ] : '' ;
279- $ justify_content = isset ( $ layout ['justifyContent ' ] ) ? $ layout [ ' justifyContent ' ] : 'center ' ;
277+ $ content_size = $ layout ['contentSize ' ] ?? '' ;
278+ $ wide_size = $ layout ['wideSize ' ] ?? '' ;
279+ $ justify_content = $ layout ['justifyContent ' ] ?? 'center ' ;
280280
281281 $ all_max_width_value = $ content_size ? $ content_size : $ wide_size ;
282282 $ wide_max_width_value = $ wide_size ? $ wide_size : $ content_size ;
@@ -361,7 +361,7 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
361361
362362 if ( $ has_block_gap_support ) {
363363 if ( is_array ( $ gap_value ) ) {
364- $ gap_value = isset ( $ gap_value ['top ' ] ) ? $ gap_value [ ' top ' ] : null ;
364+ $ gap_value = $ gap_value ['top ' ] ?? null ;
365365 }
366366 if ( null !== $ gap_value && ! $ should_skip_gap_serialization ) {
367367 // Get spacing CSS variable from preset value if provided.
@@ -391,7 +391,7 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
391391 }
392392 }
393393 } elseif ( 'flex ' === $ layout_type ) {
394- $ layout_orientation = isset ( $ layout ['orientation ' ] ) ? $ layout [ ' orientation ' ] : 'horizontal ' ;
394+ $ layout_orientation = $ layout ['orientation ' ] ?? 'horizontal ' ;
395395
396396 $ justify_content_options = array (
397397 'left ' => 'flex-start ' ,
@@ -427,7 +427,7 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
427427 foreach ( $ gap_sides as $ gap_side ) {
428428 $ process_value = $ gap_value ;
429429 if ( is_array ( $ gap_value ) ) {
430- $ process_value = isset ( $ gap_value [ $ gap_side ] ) ? $ gap_value [ $ gap_side ] : $ fallback_gap_value ;
430+ $ process_value = $ gap_value [ $ gap_side ] ?? $ fallback_gap_value ;
431431 }
432432 // Get spacing CSS variable from preset value if provided.
433433 if ( is_string ( $ process_value ) && str_contains ( $ process_value , 'var:preset|spacing| ' ) ) {
@@ -514,7 +514,7 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
514514 foreach ( $ gap_sides as $ gap_side ) {
515515 $ process_value = $ gap_value ;
516516 if ( is_array ( $ gap_value ) ) {
517- $ process_value = isset ( $ gap_value [ $ gap_side ] ) ? $ gap_value [ $ gap_side ] : $ fallback_gap_value ;
517+ $ process_value = $ gap_value [ $ gap_side ] ?? $ fallback_gap_value ;
518518 }
519519 // Get spacing CSS variable from preset value if provided.
520520 if ( is_string ( $ process_value ) && str_contains ( $ process_value , 'var:preset|spacing| ' ) ) {
@@ -570,7 +570,7 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
570570function wp_render_layout_support_flag ( $ block_content , $ block ) {
571571 $ block_type = WP_Block_Type_Registry::get_instance ()->get_registered ( $ block ['blockName ' ] );
572572 $ block_supports_layout = block_has_support ( $ block_type , 'layout ' , false ) || block_has_support ( $ block_type , '__experimentalLayout ' , false );
573- $ child_layout = isset ( $ block ['attrs ' ]['style ' ]['layout ' ] ) ? $ block [ ' attrs ' ][ ' style ' ][ ' layout ' ] : null ;
573+ $ child_layout = $ block ['attrs ' ]['style ' ]['layout ' ] ?? null ;
574574
575575 if ( ! $ block_supports_layout && ! $ child_layout ) {
576576 return $ block_content ;
@@ -610,7 +610,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
610610 $ child_layout_declarations = array ();
611611 $ child_layout_styles = array ();
612612
613- $ self_stretch = isset ( $ child_layout ['selfStretch ' ] ) ? $ child_layout [ ' selfStretch ' ] : null ;
613+ $ self_stretch = $ child_layout ['selfStretch ' ] ?? null ;
614614
615615 if ( 'fixed ' === $ self_stretch && isset ( $ child_layout ['flexSize ' ] ) ) {
616616 $ child_layout_declarations ['flex-basis ' ] = $ child_layout ['flexSize ' ];
@@ -640,7 +640,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
640640 */
641641 if ( isset ( $ child_layout ['columnSpan ' ] ) && ( isset ( $ block ['parentLayout ' ]['minimumColumnWidth ' ] ) || ! isset ( $ block ['parentLayout ' ]['columnCount ' ] ) ) ) {
642642 $ column_span_number = floatval ( $ child_layout ['columnSpan ' ] );
643- $ parent_column_width = isset ( $ block ['parentLayout ' ]['minimumColumnWidth ' ] ) ? $ block [ ' parentLayout ' ][ ' minimumColumnWidth ' ] : '12rem ' ;
643+ $ parent_column_width = $ block ['parentLayout ' ]['minimumColumnWidth ' ] ?? '12rem ' ;
644644 $ parent_column_value = floatval ( $ parent_column_width );
645645 $ parent_column_unit = explode ( $ parent_column_value , $ parent_column_width );
646646
@@ -719,15 +719,11 @@ function wp_render_layout_support_flag( $block_content, $block ) {
719719 }
720720
721721 $ global_settings = wp_get_global_settings ();
722- $ fallback_layout = isset ( $ block_type ->supports ['layout ' ]['default ' ] )
723- ? $ block_type ->supports ['layout ' ]['default ' ]
724- : array ();
722+ $ fallback_layout = $ block_type ->supports ['layout ' ]['default ' ] ?? array ();
725723 if ( empty ( $ fallback_layout ) ) {
726- $ fallback_layout = isset ( $ block_type ->supports ['__experimentalLayout ' ]['default ' ] )
727- ? $ block_type ->supports ['__experimentalLayout ' ]['default ' ]
728- : array ();
724+ $ fallback_layout = $ block_type ->supports ['__experimentalLayout ' ]['default ' ] ?? array ();
729725 }
730- $ used_layout = isset ( $ block ['attrs ' ]['layout ' ] ) ? $ block [ ' attrs ' ][ ' layout ' ] : $ fallback_layout ;
726+ $ used_layout = $ block ['attrs ' ]['layout ' ] ?? $ fallback_layout ;
731727
732728 $ class_names = array ();
733729 $ layout_definitions = wp_get_layout_definitions ();
@@ -737,9 +733,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
737733 $ used_layout ['type ' ] = 'constrained ' ;
738734 }
739735
740- $ root_padding_aware_alignments = isset ( $ global_settings ['useRootPaddingAwareAlignments ' ] )
741- ? $ global_settings ['useRootPaddingAwareAlignments ' ]
742- : false ;
736+ $ root_padding_aware_alignments = $ global_settings ['useRootPaddingAwareAlignments ' ] ?? false ;
743737
744738 if (
745739 $ root_padding_aware_alignments &&
@@ -769,13 +763,9 @@ function wp_render_layout_support_flag( $block_content, $block ) {
769763
770764 // Get classname for layout type.
771765 if ( isset ( $ used_layout ['type ' ] ) ) {
772- $ layout_classname = isset ( $ layout_definitions [ $ used_layout ['type ' ] ]['className ' ] )
773- ? $ layout_definitions [ $ used_layout ['type ' ] ]['className ' ]
774- : '' ;
766+ $ layout_classname = $ layout_definitions [ $ used_layout ['type ' ] ]['className ' ] ?? '' ;
775767 } else {
776- $ layout_classname = isset ( $ layout_definitions ['default ' ]['className ' ] )
777- ? $ layout_definitions ['default ' ]['className ' ]
778- : '' ;
768+ $ layout_classname = $ layout_definitions ['default ' ]['className ' ] ?? '' ;
779769 }
780770
781771 if ( $ layout_classname && is_string ( $ layout_classname ) ) {
@@ -788,9 +778,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
788778 */
789779 if ( ! current_theme_supports ( 'disable-layout-styles ' ) ) {
790780
791- $ gap_value = isset ( $ block ['attrs ' ]['style ' ]['spacing ' ]['blockGap ' ] )
792- ? $ block ['attrs ' ]['style ' ]['spacing ' ]['blockGap ' ]
793- : null ;
781+ $ gap_value = $ block ['attrs ' ]['style ' ]['spacing ' ]['blockGap ' ] ?? null ;
794782 /*
795783 * Skip if gap value contains unsupported characters.
796784 * Regex for CSS value borrowed from `safecss_filter_attr`, and used here
@@ -804,22 +792,16 @@ function wp_render_layout_support_flag( $block_content, $block ) {
804792 $ gap_value = $ gap_value && preg_match ( '%[ \\\(&=}]|/\*% ' , $ gap_value ) ? null : $ gap_value ;
805793 }
806794
807- $ fallback_gap_value = isset ( $ block_type ->supports ['spacing ' ]['blockGap ' ]['__experimentalDefault ' ] )
808- ? $ block_type ->supports ['spacing ' ]['blockGap ' ]['__experimentalDefault ' ]
809- : '0.5em ' ;
810- $ block_spacing = isset ( $ block ['attrs ' ]['style ' ]['spacing ' ] )
811- ? $ block ['attrs ' ]['style ' ]['spacing ' ]
812- : null ;
795+ $ fallback_gap_value = $ block_type ->supports ['spacing ' ]['blockGap ' ]['__experimentalDefault ' ] ?? '0.5em ' ;
796+ $ block_spacing = $ block ['attrs ' ]['style ' ]['spacing ' ] ?? null ;
813797
814798 /*
815799 * If a block's block.json skips serialization for spacing or spacing.blockGap,
816800 * don't apply the user-defined value to the styles.
817801 */
818802 $ should_skip_gap_serialization = wp_should_skip_block_supports_serialization ( $ block_type , 'spacing ' , 'blockGap ' );
819803
820- $ block_gap = isset ( $ global_settings ['spacing ' ]['blockGap ' ] )
821- ? $ global_settings ['spacing ' ]['blockGap ' ]
822- : null ;
804+ $ block_gap = $ global_settings ['spacing ' ]['blockGap ' ] ?? null ;
823805 $ has_block_gap_support = isset ( $ block_gap );
824806
825807 /*
@@ -917,7 +899,7 @@ function wp_render_layout_support_flag( $block_content, $block ) {
917899 * @var string|null
918900 */
919901 $ inner_block_wrapper_classes = null ;
920- $ first_chunk = isset ( $ block ['innerContent ' ][0 ] ) ? $ block [ ' innerContent ' ][ 0 ] : null ;
902+ $ first_chunk = $ block ['innerContent ' ][0 ] ?? null ;
921903 if ( is_string ( $ first_chunk ) && count ( $ block ['innerContent ' ] ) > 1 ) {
922904 $ first_chunk_processor = new WP_HTML_Tag_Processor ( $ first_chunk );
923905 while ( $ first_chunk_processor ->next_tag () ) {
@@ -1003,7 +985,7 @@ function wp_add_parent_layout_to_parsed_block( $parsed_block, $source_block, $pa
1003985 * @return string Filtered block content.
1004986 */
1005987function wp_restore_group_inner_container ( $ block_content , $ block ) {
1006- $ tag_name = isset ( $ block ['attrs ' ]['tagName ' ] ) ? $ block [ ' attrs ' ][ ' tagName ' ] : 'div ' ;
988+ $ tag_name = $ block ['attrs ' ]['tagName ' ] ?? 'div ' ;
1007989 $ group_with_inner_container_regex = sprintf (
1008990 '/(^\s*<%1$s\b[^>]*wp-block-group(\s|")[^>]*>)(\s*<div\b[^>]*wp-block-group__inner-container(\s|")[^>]*>)((.|\S|\s)*)/U ' ,
1009991 preg_quote ( $ tag_name , '/ ' )
0 commit comments