Changeset 55176
- Timestamp:
- 02/01/2023 06:05:44 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r55175 r55176 116 116 * @since 6.0.0 Replaced `override` with `prevent_override` and updated the 117 117 * `prevent_override` value for `color.duotone` to use `color.defaultDuotone`. 118 * @since 6.2.0 Added 'shadow' presets. 118 119 * @var array 119 120 */ … … 177 178 'properties' => array( 'padding', 'margin' ), 178 179 ), 180 array( 181 'path' => array( 'shadow', 'presets' ), 182 'prevent_override' => array( 'shadow', 'defaultPresets' ), 183 'use_default_names' => false, 184 'value_key' => 'shadow', 185 'css_vars' => '--wp--preset--shadow--$slug', 186 'classes' => array(), 187 'properties' => array( 'box-shadow' ), 188 ), 179 189 ); 180 190 … … 295 305 * @since 6.0.0 Added `color.defaultDuotone`. 296 306 * @since 6.1.0 Added `layout.definitions` and `useRootPaddingAwareAlignments`. 297 * @since 6.2.0 Added `dimensions.minHeight` .307 * @since 6.2.0 Added `dimensions.minHeight`, 'shadow.presets', and 'shadow.defaultPresets'. 298 308 * @var array 299 309 */ … … 338 348 'padding' => null, 339 349 'units' => null, 350 ), 351 'shadow' => array( 352 'presets' => null, 353 'defaultPresets' => null, 340 354 ), 341 355 'typography' => array( -
trunk/src/wp-includes/theme.json
r54162 r55176 325 325 } 326 326 } 327 }, 328 "shadow": { 329 "presets": [ 330 { 331 "name": "Natural", 332 "slug": "natural", 333 "shadow": "0 .2rem .3rem 0 rgba(0,0,0, 0.3), 0 .5rem .6rem 0 rgba(0,0,0, 0.4)" 334 }, 335 { 336 "name": "Sharp", 337 "slug": "sharp", 338 "shadow": ".5rem .5rem 0 0 rgba(0,0,0, 0.4)" 339 } 340 ] 327 341 }, 328 342 "spacing": { -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r55175 r55176 4435 4435 $this->assertSame( $expected, $theme_json->get_stylesheet() ); 4436 4436 } 4437 4438 /** 4439 * @ticket 57559 4440 */ 4441 public function test_shadow_preset_styles() { 4442 $theme_json = new WP_Theme_JSON( 4443 array( 4444 'version' => WP_Theme_JSON::LATEST_SCHEMA, 4445 'settings' => array( 4446 'shadow' => array( 4447 'presets' => array( 4448 array( 4449 'slug' => 'natural', 4450 'shadow' => '5px 5px 5px 0 black', 4451 ), 4452 array( 4453 'slug' => 'sharp', 4454 'shadow' => '5px 5px black', 4455 ), 4456 ), 4457 ), 4458 ), 4459 ) 4460 ); 4461 4462 $expected_styles = 'body{--wp--preset--shadow--natural: 5px 5px 5px 0 black;--wp--preset--shadow--sharp: 5px 5px black;}'; 4463 $this->assertSame( $expected_styles, $theme_json->get_stylesheet(), 'Styles returned from "::get_stylesheet()" does not match expectations' ); 4464 $this->assertSame( $expected_styles, $theme_json->get_stylesheet( array( 'variables' ) ), 'Styles returned from "::get_stylesheet()" when requiring "variables" type does not match expectations' ); 4465 } 4466 4467 /** 4468 * @ticket 57559 4469 */ 4470 public function test_get_shadow_styles_for_blocks() { 4471 $theme_json = new WP_Theme_JSON( 4472 array( 4473 'version' => WP_Theme_JSON::LATEST_SCHEMA, 4474 'settings' => array( 4475 'shadow' => array( 4476 'presets' => array( 4477 array( 4478 'slug' => 'natural', 4479 'shadow' => '5px 5px 0 0 black', 4480 ), 4481 ), 4482 ), 4483 ), 4484 'styles' => array( 4485 'blocks' => array( 4486 'core/paragraph' => array( 4487 'shadow' => 'var(--wp--preset--shadow--natural)', 4488 ), 4489 ), 4490 'elements' => array( 4491 'button' => array( 4492 'shadow' => 'var:preset|shadow|natural', 4493 ), 4494 'link' => array( 4495 'shadow' => array( 'ref' => 'styles.elements.button.shadow' ), 4496 ), 4497 ), 4498 ), 4499 ) 4500 ); 4501 4502 $global_styles = 'body{--wp--preset--shadow--natural: 5px 5px 0 0 black;}body { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'; 4503 $element_styles = 'a:where(:not(.wp-element-button)){box-shadow: var(--wp--preset--shadow--natural);}.wp-element-button, .wp-block-button__link{box-shadow: var(--wp--preset--shadow--natural);}p{box-shadow: var(--wp--preset--shadow--natural);}'; 4504 $expected_styles = $global_styles . $element_styles; 4505 4506 $this->assertSame( $expected_styles, $theme_json->get_stylesheet() ); 4507 } 4437 4508 }
Note: See TracChangeset
for help on using the changeset viewer.