Changeset 61430 for trunk/src/wp-includes/block-supports/layout.php
- Timestamp:
- 01/05/2026 04:50:51 AM (6 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/block-supports/layout.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/layout.php
r60968 r61430 239 239 */ 240 240 function 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'; 242 242 $layout_styles = array(); 243 243 … … 245 245 if ( $has_block_gap_support ) { 246 246 if ( is_array( $gap_value ) ) { 247 $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] :null;247 $gap_value = $gap_value['top'] ?? null; 248 248 } 249 249 if ( null !== $gap_value && ! $should_skip_gap_serialization ) { … … 275 275 } 276 276 } 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'; 280 280 281 281 $all_max_width_value = $content_size ? $content_size : $wide_size; … … 362 362 if ( $has_block_gap_support ) { 363 363 if ( is_array( $gap_value ) ) { 364 $gap_value = isset( $gap_value['top'] ) ? $gap_value['top'] :null;364 $gap_value = $gap_value['top'] ?? null; 365 365 } 366 366 if ( null !== $gap_value && ! $should_skip_gap_serialization ) { … … 392 392 } 393 393 } elseif ( 'flex' === $layout_type ) { 394 $layout_orientation = isset( $layout['orientation'] ) ? $layout['orientation'] :'horizontal';394 $layout_orientation = $layout['orientation'] ?? 'horizontal'; 395 395 396 396 $justify_content_options = array( … … 428 428 $process_value = $gap_value; 429 429 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; 431 431 } 432 432 // Get spacing CSS variable from preset value if provided. … … 515 515 $process_value = $gap_value; 516 516 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; 518 518 } 519 519 // Get spacing CSS variable from preset value if provided. … … 571 571 $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); 572 572 $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; 574 574 575 575 if ( ! $block_supports_layout && ! $child_layout ) { … … 611 611 $child_layout_styles = array(); 612 612 613 $self_stretch = isset( $child_layout['selfStretch'] ) ? $child_layout['selfStretch'] :null;613 $self_stretch = $child_layout['selfStretch'] ?? null; 614 614 615 615 if ( 'fixed' === $self_stretch && isset( $child_layout['flexSize'] ) ) { … … 641 641 if ( isset( $child_layout['columnSpan'] ) && ( isset( $block['parentLayout']['minimumColumnWidth'] ) || ! isset( $block['parentLayout']['columnCount'] ) ) ) { 642 642 $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'; 644 644 $parent_column_value = floatval( $parent_column_width ); 645 645 $parent_column_unit = explode( $parent_column_value, $parent_column_width ); … … 720 720 721 721 $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(); 725 723 if ( empty( $fallback_layout ) ) { 726 $fallback_layout = isset( $block_type->supports['__experimentalLayout']['default'] ) 727 ? $block_type->supports['__experimentalLayout']['default'] 728 : array(); 729 } 730 $used_layout = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $fallback_layout; 724 $fallback_layout = $block_type->supports['__experimentalLayout']['default'] ?? array(); 725 } 726 $used_layout = $block['attrs']['layout'] ?? $fallback_layout; 731 727 732 728 $class_names = array(); … … 738 734 } 739 735 740 $root_padding_aware_alignments = isset( $global_settings['useRootPaddingAwareAlignments'] ) 741 ? $global_settings['useRootPaddingAwareAlignments'] 742 : false; 736 $root_padding_aware_alignments = $global_settings['useRootPaddingAwareAlignments'] ?? false; 743 737 744 738 if ( … … 770 764 // Get classname for layout type. 771 765 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'] ?? ''; 775 767 } else { 776 $layout_classname = isset( $layout_definitions['default']['className'] ) 777 ? $layout_definitions['default']['className'] 778 : ''; 768 $layout_classname = $layout_definitions['default']['className'] ?? ''; 779 769 } 780 770 … … 789 779 if ( ! current_theme_supports( 'disable-layout-styles' ) ) { 790 780 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; 794 782 /* 795 783 * Skip if gap value contains unsupported characters. … … 805 793 } 806 794 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; 813 797 814 798 /* … … 818 802 $should_skip_gap_serialization = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'blockGap' ); 819 803 820 $block_gap = isset( $global_settings['spacing']['blockGap'] ) 821 ? $global_settings['spacing']['blockGap'] 822 : null; 804 $block_gap = $global_settings['spacing']['blockGap'] ?? null; 823 805 $has_block_gap_support = isset( $block_gap ); 824 806 … … 918 900 */ 919 901 $inner_block_wrapper_classes = null; 920 $first_chunk = isset( $block['innerContent'][0] ) ? $block['innerContent'][0] :null;902 $first_chunk = $block['innerContent'][0] ?? null; 921 903 if ( is_string( $first_chunk ) && count( $block['innerContent'] ) > 1 ) { 922 904 $first_chunk_processor = new WP_HTML_Tag_Processor( $first_chunk ); … … 1004 986 */ 1005 987 function 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'; 1007 989 $group_with_inner_container_regex = sprintf( 1008 990 '/(^\s*<%1$s\b[^>]*wp-block-group(\s|")[^>]*>)(\s*<div\b[^>]*wp-block-group__inner-container(\s|")[^>]*>)((.|\S|\s)*)/U',
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)