Changeset 61619
- Timestamp:
- 02/12/2026 05:06:08 AM (5 days ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
src/wp-includes/block-supports/dimensions.php (modified) (2 diffs)
-
src/wp-includes/class-wp-theme-json.php (modified) (10 diffs)
-
src/wp-includes/style-engine/class-wp-style-engine.php (modified) (1 diff)
-
tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php (modified) (1 diff)
-
tests/phpunit/tests/theme/wpThemeJson.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/dimensions.php
r61430 r61619 52 52 */ 53 53 function wp_apply_dimensions_support( $block_type, $block_attributes ) { 54 $attributes = array(); 55 54 56 if ( wp_should_skip_block_supports_serialization( $block_type, 'dimensions' ) ) { 55 return array();57 return $attributes; 56 58 } 57 59 58 $attributes = array(); 59 60 // Width support to be added in near future. 61 62 $has_min_height_support = block_has_support( $block_type, array( 'dimensions', 'minHeight' ), false ); 63 $block_styles = $block_attributes['style'] ?? null; 60 $block_styles = $block_attributes['style'] ?? null; 64 61 65 62 if ( ! $block_styles ) { … … 67 64 } 68 65 69 $skip_min_height = wp_should_skip_block_supports_serialization( $block_type, 'dimensions', 'minHeight' ); 70 $dimensions_block_styles = array(); 71 $dimensions_block_styles['minHeight'] = null; 72 if ( $has_min_height_support && ! $skip_min_height ) { 73 $dimensions_block_styles['minHeight'] = $block_styles['dimensions']['minHeight'] ?? null; 66 $dimensions_block_styles = array(); 67 $supported_features = array( 'minHeight', 'width' ); 68 69 foreach ( $supported_features as $feature ) { 70 $has_support = block_has_support( $block_type, array( 'dimensions', $feature ), false ); 71 $skip_serialization = wp_should_skip_block_supports_serialization( $block_type, 'dimensions', $feature ); 72 73 $dimensions_block_styles[ $feature ] = null; 74 75 if ( $has_support && ! $skip_serialization ) { 76 $dimensions_block_styles[ $feature ] = $block_styles['dimensions'][ $feature ] ?? null; 77 } 74 78 } 79 75 80 $styles = wp_style_engine_get_styles( array( 'dimensions' => $dimensions_block_styles ) ); 76 81 -
trunk/src/wp-includes/class-wp-theme-json.php
r61618 r61619 238 238 * @since 6.6.0 Added `background-[image|position|repeat|size]` properties. 239 239 * @since 6.7.0 Added `background-attachment` property. 240 * @since 7.0.0 Added `dimensions.width`. 240 241 * @var array 241 242 */ … … 302 303 'filter' => array( 'filter', 'duotone' ), 303 304 'box-shadow' => array( 'shadow' ), 305 'width' => array( 'dimensions', 'width' ), 304 306 'writing-mode' => array( 'typography', 'writingMode' ), 305 307 ); … … 397 399 * @since 6.9.0 Added support for `border.radiusSizes`. 398 400 * @since 7.0.0 Added type markers to the schema for boolean values. 401 * Added support for `dimensions.width`. 399 402 * @var array 400 403 */ … … 436 439 'defaultAspectRatios' => null, 437 440 'minHeight' => null, 441 'width' => null, 438 442 ), 439 443 'layout' => array( … … 529 533 * @since 6.5.0 Added support for `dimensions.aspectRatio`. 530 534 * @since 6.6.0 Added `background` sub properties to top-level only. 535 * @since 7.0.0 Added support for `dimensions.width`. 531 536 * @var array 532 537 */ … … 557 562 'aspectRatio' => null, 558 563 'minHeight' => null, 564 'width' => null, 559 565 ), 560 566 'filter' => array( … … 656 662 * 657 663 * @since 6.1.0 664 * @since 7.0.0 Added support for `dimensions`. 658 665 * @var string[] 659 666 */ … … 661 668 '__experimentalBorder' => 'border', 662 669 'color' => 'color', 670 'dimensions' => 'dimensions', 663 671 'spacing' => 'spacing', 664 672 'typography' => 'typography', … … 765 773 * @since 6.4.0 Added `background.backgroundImage`. 766 774 * @since 6.5.0 Added `background.backgroundSize` and `dimensions.aspectRatio`. 775 * @since 7.0.0 Added `dimensions.width`. 767 776 * @var array 768 777 */ … … 780 789 array( 'dimensions', 'aspectRatio' ), 781 790 array( 'dimensions', 'minHeight' ), 791 array( 'dimensions', 'width' ), 782 792 array( 'position', 'sticky' ), 783 793 array( 'spacing', 'blockGap' ), -
trunk/src/wp-includes/style-engine/class-wp-style-engine.php
r60892 r61619 220 220 ), 221 221 ), 222 'width' => array( 223 'property_keys' => array( 224 'default' => 'width', 225 ), 226 'path' => array( 'dimensions', 'width' ), 227 ), 222 228 ), 223 229 'spacing' => array( -
trunk/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php
r55175 r61619 101 101 ); 102 102 } 103 104 /** 105 * Tests that width block support works as expected. 106 * 107 * @ticket 64200 108 * 109 * @covers ::wp_apply_dimensions_support 110 * 111 * @dataProvider data_width_block_support 112 * 113 * @param string $block_name The test block name to register. 114 * @param mixed $dimensions The dimensions block support settings. 115 * @param mixed $expected The expected results. 116 */ 117 public function test_width_block_support( $block_name, $dimensions, $expected ) { 118 $this->test_block_name = $block_name; 119 register_block_type( 120 $this->test_block_name, 121 array( 122 'api_version' => 2, 123 'attributes' => array( 124 'style' => array( 125 'type' => 'object', 126 ), 127 ), 128 'supports' => array( 129 'dimensions' => $dimensions, 130 ), 131 ) 132 ); 133 $registry = WP_Block_Type_Registry::get_instance(); 134 $block_type = $registry->get_registered( $this->test_block_name ); 135 $block_attrs = array( 136 'style' => array( 137 'dimensions' => array( 138 'width' => '300px', 139 ), 140 ), 141 ); 142 143 $actual = wp_apply_dimensions_support( $block_type, $block_attrs ); 144 145 $this->assertSame( $expected, $actual ); 146 } 147 148 /** 149 * Data provider. 150 * 151 * @return array 152 */ 153 public function data_width_block_support() { 154 return array( 155 'style is applied' => array( 156 'block_name' => 'test/width-style-is-applied', 157 'dimensions' => array( 158 'width' => true, 159 ), 160 'expected' => array( 161 'style' => 'width:300px;', 162 ), 163 ), 164 'style output is skipped when individual feature serialization is skipped' => array( 165 'block_name' => 'test/width-with-individual-skipped-serialization-block-supports', 166 'dimensions' => array( 167 'width' => true, 168 '__experimentalSkipSerialization' => array( 'width' ), 169 ), 170 'expected' => array(), 171 ), 172 ); 173 } 103 174 } -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r61618 r61619 282 282 'aspectRatio' => true, 283 283 'minHeight' => true, 284 'width' => true, 284 285 ), 285 286 'position' => array( … … 321 322 'aspectRatio' => true, 322 323 'minHeight' => true, 324 'width' => true, 323 325 ), 324 326 'position' => array(
Note: See TracChangeset
for help on using the changeset viewer.