Changeset 58222 for trunk/src/wp-includes/class-wp-theme-json.php
- Timestamp:
- 05/28/2024 06:04:37 AM (21 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-theme-json.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r58171 r58222 214 214 * @since 6.4.0 Added `writing-mode` property. 215 215 * @since 6.5.0 Added `aspect-ratio` property. 216 * @since 6.6.0 Added `background-[image|position|repeat|size]` properties. 216 217 * 217 218 * @var array … … 221 222 'background' => array( 'color', 'gradient' ), 222 223 'background-color' => array( 'color', 'background' ), 224 'background-image' => array( 'background', 'backgroundImage' ), 225 'background-position' => array( 'background', 'backgroundPosition' ), 226 'background-repeat' => array( 'background', 'backgroundRepeat' ), 227 'background-size' => array( 'background', 'backgroundSize' ), 223 228 'border-radius' => array( 'border', 'radius' ), 224 229 'border-top-left-radius' => array( 'border', 'radius', 'topLeft' ), … … 284 289 * Indirect properties are not output directly by `compute_style_properties`, 285 290 * but are used elsewhere in the processing of global styles. The indirect 286 * property is used to validate whether or nota style value is allowed.291 * property is used to validate whether a style value is allowed. 287 292 * 288 293 * @since 6.2.0 294 * @since 6.6.0 Added background-image properties. 289 295 * 290 296 * @var array … … 303 309 array( 'layout', 'contentSize' ), 304 310 array( 'layout', 'wideSize' ), 311 ), 312 'background-image' => array( 313 array( 'background', 'backgroundImage', 'url' ), 305 314 ), 306 315 ); … … 483 492 * @since 6.3.0 Added support for `typography.textColumns`. 484 493 * @since 6.5.0 Added support for `dimensions.aspectRatio`. 494 * @since 6.6.0 Added `background` sub properties to top-level only. 485 495 * 486 496 * @var array 487 497 */ 488 498 const VALID_STYLES = array( 499 'background' => array( 500 'backgroundImage' => 'top', 501 'backgroundPosition' => 'top', 502 'backgroundRepeat' => 'top', 503 'backgroundSize' => 'top', 504 ), 489 505 'border' => array( 490 506 'color' => null, … … 2052 2068 * @since 6.1.0 Added `$theme_json`, `$selector`, and `$use_root_padding` parameters. 2053 2069 * @since 6.5.0 Output a `min-height: unset` rule when `aspect-ratio` is set. 2054 * @since 6.6.0 Pass ing current theme JSON settings to wp_get_typography_font_size_value().2070 * @since 6.6.0 Pass current theme JSON settings to wp_get_typography_font_size_value(), and process background properties. 2055 2071 * 2056 2072 * @param array $styles Styles to process. … … 2104 2120 continue; 2105 2121 } 2122 } 2123 2124 // Processes background styles. 2125 if ( 'background' === $value_path[0] && isset( $styles['background'] ) ) { 2126 $background_styles = wp_style_engine_get_styles( array( 'background' => $styles['background'] ) ); 2127 $value = isset( $background_styles['declarations'][ $css_property ] ) ? $background_styles['declarations'][ $css_property ] : $value; 2106 2128 } 2107 2129 … … 2485 2507 * 2486 2508 * @since 6.1.0 2509 * @since 6.6.0 Setting a min-height of HTML when root styles have a background gradient or image. 2487 2510 * 2488 2511 * @param array $block_metadata Metadata about the block to get styles for. … … 2496 2519 $settings = isset( $this->theme_json['settings'] ) ? $this->theme_json['settings'] : array(); 2497 2520 $feature_declarations = static::get_feature_declarations_for_node( $block_metadata, $node ); 2521 $is_root_selector = static::ROOT_BLOCK_SELECTOR === $selector; 2498 2522 2499 2523 // If there are style variations, generate the declarations for them, including any feature selectors the block may have. … … 2578 2602 2579 2603 /* 2580 * 1. Separate the declarations that use the general selector 2604 * 1. Bespoke declaration modifiers: 2605 * - 'filter': Separate the declarations that use the general selector 2581 2606 * from the ones using the duotone selector. 2607 * - 'background|background-image': set the html min-height to 100% 2608 * to ensure the background covers the entire viewport. 2582 2609 */ 2583 $declarations_duotone = array(); 2610 $declarations_duotone = array(); 2611 $should_set_root_min_height = false; 2612 2584 2613 foreach ( $declarations as $index => $declaration ) { 2585 2614 if ( 'filter' === $declaration['name'] ) { 2615 /* 2616 * 'unset' filters happen when a filter is unset 2617 * in the site-editor UI. Because the 'unset' value 2618 * in the user origin overrides the value in the 2619 * theme origin, we can skip rendering anything 2620 * here as no filter needs to be applied anymore. 2621 * So only add declarations to with values other 2622 * than 'unset'. 2623 */ 2624 if ( 'unset' !== $declaration['value'] ) { 2625 $declarations_duotone[] = $declaration; 2626 } 2586 2627 unset( $declarations[ $index ] ); 2587 $declarations_duotone[] = $declaration; 2588 } 2628 } 2629 2630 if ( $is_root_selector && ( 'background-image' === $declaration['name'] || 'background' === $declaration['name'] ) ) { 2631 $should_set_root_min_height = true; 2632 } 2633 } 2634 2635 /* 2636 * If root styles has a background-image or a background (gradient) set, 2637 * set the min-height to '100%'. Minus `--wp-admin--admin-bar--height` for logged-in view. 2638 * Setting the CSS rule on the HTML tag ensures background gradients and images behave similarly, 2639 * and matches the behavior of the site editor. 2640 */ 2641 if ( $should_set_root_min_height ) { 2642 $block_rules .= static::to_ruleset( 2643 'html', 2644 array( 2645 array( 2646 'name' => 'min-height', 2647 'value' => 'calc(100% - var(--wp-admin--admin-bar--height, 0px))', 2648 ), 2649 ) 2650 ); 2589 2651 } 2590 2652 … … 2604 2666 // 4. Generate Layout block gap styles. 2605 2667 if ( 2606 static::ROOT_BLOCK_SELECTOR !== $selector &&2668 ! $is_root_selector && 2607 2669 ! empty( $block_metadata['name'] ) 2608 2670 ) {
Note: See TracChangeset
for help on using the changeset viewer.