Changeset 56614
- Timestamp:
- 09/19/2023 01:27:43 AM (12 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r56605 r56614 343 343 * `position.fixed` and `position.sticky`. 344 344 * @since 6.3.0 Added support for `typography.textColumns`, removed `layout.definitions`. 345 * @since 6.4.0 Added `layout.allowEditing` and `typography.writingMode`.346 * 345 * @since 6.4.0 Added support for `layout.allowEditing`, `background.backgroundImage`, 346 * and `typography.writingMode`. 347 347 * @var array 348 348 */ … … 350 350 'appearanceTools' => null, 351 351 'useRootPaddingAwareAlignments' => null, 352 'background' => array( 353 'backgroundImage' => null, 354 ), 352 355 'border' => array( 353 356 'color' => null, … … 564 567 * @since 6.0.0 565 568 * @since 6.2.0 Added `dimensions.minHeight` and `position.sticky`. 569 * @since 6.4.0 Added `background.backgroundImage`. 566 570 * @var array 567 571 */ 568 572 const APPEARANCE_TOOLS_OPT_INS = array( 573 array( 'background', 'backgroundImage' ), 569 574 array( 'border', 'color' ), 570 575 array( 'border', 'radius' ), -
trunk/src/wp-includes/style-engine/class-wp-style-engine.php
r56604 r56614 23 23 * @since 6.1.0 24 24 * @since 6.3.0 Added support for text-columns. 25 * @since 6.4.0 Added support for background.backgroundImage. 25 26 */ 26 27 #[AllowDynamicProperties] … … 52 53 */ 53 54 const BLOCK_STYLE_DEFINITIONS_METADATA = array( 55 'background' => array( 56 'backgroundImage' => array( 57 'property_keys' => array( 58 'default' => 'background-image', 59 ), 60 'value_func' => array( self::class, 'get_url_or_value_css_declaration' ), 61 'path' => array( 'background', 'backgroundImage' ), 62 ), 63 'backgroundSize' => array( 64 'property_keys' => array( 65 'default' => 'background-size', 66 ), 67 'path' => array( 'background', 'backgroundSize' ), 68 ), 69 ), 54 70 'color' => array( 55 71 'text' => array( … … 591 607 592 608 /** 609 * Style value parser that constructs a CSS definition array comprising a single CSS property and value. 610 * If the provided value is an array containing a `url` property, the function will return a CSS definition array 611 * with a single property and value, with `url` escaped and injected into a CSS `url()` function, 612 * e.g., array( 'background-image' => "url( '...' )" ). 613 * 614 * @since 6.4.0 615 * 616 * @param array $style_value A single raw style value from $block_styles array. 617 * @param array $style_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA. 618 * @return string[] An associative array of CSS definitions, e.g., array( "$property" => "$value", "$property" => "$value" ). 619 */ 620 protected static function get_url_or_value_css_declaration( $style_value, $style_definition ) { 621 if ( empty( $style_value ) ) { 622 return array(); 623 } 624 625 $css_declarations = array(); 626 627 if ( isset( $style_definition['property_keys']['default'] ) ) { 628 $value = null; 629 630 if ( ! empty( $style_value['url'] ) ) { 631 $value = "url('" . $style_value['url'] . "')"; 632 } elseif ( is_string( $style_value ) ) { 633 $value = $style_value; 634 } 635 636 if ( null !== $value ) { 637 $css_declarations[ $style_definition['property_keys']['default'] ] = $value; 638 } 639 } 640 641 return $css_declarations; 642 } 643 644 /** 593 645 * Returns compiled CSS from CSS declarations. 594 646 * -
trunk/src/wp-settings.php
r56500 r56614 341 341 require ABSPATH . WPINC . '/block-supports/utils.php'; 342 342 require ABSPATH . WPINC . '/block-supports/align.php'; 343 require ABSPATH . WPINC . '/block-supports/background.php'; 343 344 require ABSPATH . WPINC . '/block-supports/border.php'; 344 345 require ABSPATH . WPINC . '/block-supports/colors.php'; -
trunk/tests/phpunit/tests/style-engine/styleEngine.php
r56574 r56614 510 510 ), 511 511 ), 512 513 'inline_background_image_url_with_background_size' => array( 514 'block_styles' => array( 515 'background' => array( 516 'backgroundImage' => array( 517 'url' => 'https://example.com/image.jpg', 518 ), 519 'backgroundSize' => 'cover', 520 ), 521 ), 522 'options' => array(), 523 'expected_output' => array( 524 'css' => "background-image:url('https://example.com/image.jpg');background-size:cover;", 525 'declarations' => array( 526 'background-image' => "url('https://example.com/image.jpg')", 527 'background-size' => 'cover', 528 ), 529 ), 530 ), 512 531 ); 513 532 } -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r56548 r56614 263 263 $actual = $theme_json->get_settings(); 264 264 $expected = array( 265 'background' => array( 266 'backgroundImage' => true, 267 ), 265 268 'border' => array( 266 269 'width' => true, … … 296 299 ), 297 300 'core/group' => array( 301 'background' => array( 302 'backgroundImage' => true, 303 ), 298 304 'border' => array( 299 305 'width' => true,
Note: See TracChangeset
for help on using the changeset viewer.