Changeset 56179
- Timestamp:
- 07/09/2023 09:38:35 PM (16 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json-resolver.php
r56157 r56179 359 359 null === _wp_array_get( $config, array( 'styles', 'blocks', $block_name, 'spacing', 'blockGap' ), null ) 360 360 ) { 361 // Ensure an empty placeholder value exists for the block, if it provides a default blockGap value. 362 // The real blockGap value to be used will be determined when the styles are rendered for output. 361 /* 362 * Ensure an empty placeholder value exists for the block, if it provides a default blockGap value. 363 * The real blockGap value to be used will be determined when the styles are rendered for output. 364 */ 363 365 $config['styles']['blocks'][ $block_name ]['spacing']['blockGap'] = null; 364 366 } … … 513 515 } 514 516 515 // Very important to verify that the flag isGlobalStylesUserThemeJSON is true. 516 // If it's not true then the content was not escaped and is not safe. 517 /* 518 * Very important to verify that the flag isGlobalStylesUserThemeJSON is true. 519 * If it's not true then the content was not escaped and is not safe. 520 */ 517 521 if ( 518 522 is_array( $decoded_data ) && -
trunk/src/wp-includes/class-wp-theme-json.php
r56101 r56179 546 546 $class_name = ''; 547 547 548 // TODO: Replace array_key_exists() with isset() check once WordPress drops 549 // support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 548 /* 549 * TODO: Replace array_key_exists() with isset() check once WordPress drops 550 * support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 551 */ 550 552 if ( array_key_exists( $element, static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES ) ) { 551 553 $class_name = static::__EXPERIMENTAL_ELEMENT_CLASS_NAMES[ $element ]; … … 672 674 protected static function do_opt_in_into_settings( &$context ) { 673 675 foreach ( static::APPEARANCE_TOOLS_OPT_INS as $path ) { 674 // Use "unset prop" as a marker instead of "null" because 675 // "null" can be a valid value for some props (e.g. blockGap). 676 /* 677 * Use "unset prop" as a marker instead of "null" because 678 * "null" can be a valid value for some props (e.g. blockGap). 679 */ 676 680 if ( 'unset prop' === _wp_array_get( $context, $path, 'unset prop' ) ) { 677 681 _wp_array_set( $context, $path, true ); … … 737 741 $schema_styles_elements[ $element ] = $styles_non_top_level; 738 742 739 // TODO: Replace array_key_exists() with isset() check once WordPress drops 740 // support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 743 /* 744 * TODO: Replace array_key_exists() with isset() check once WordPress drops 745 * support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 746 */ 741 747 if ( array_key_exists( $element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { 742 748 foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) { … … 1084 1090 $root_selector = $options['root_selector']; 1085 1091 } 1086 // Base layout styles are provided as part of `styles`, so only output separately if explicitly requested. 1087 // For backwards compatibility, the Columns block is explicitly included, to support a different default gap value. 1092 /* 1093 * Base layout styles are provided as part of `styles`, so only output separately if explicitly requested. 1094 * For backwards compatibility, the Columns block is explicitly included, to support a different default gap value. 1095 */ 1088 1096 $base_styles_nodes = array( 1089 1097 array( … … 1276 1284 $layout_selector_pattern = '/^[a-zA-Z0-9\-\.\ *+>:\(\)]*$/'; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors. 1277 1285 1278 // Gap styles will only be output if the theme has block gap support, or supports a fallback gap. 1279 // Default layout gap styles will be skipped for themes that do not explicitly opt-in to blockGap with a `true` or `false` value. 1286 /* 1287 * Gap styles will only be output if the theme has block gap support, or supports a fallback gap. 1288 * Default layout gap styles will be skipped for themes that do not explicitly opt-in to blockGap with a `true` or `false` value. 1289 */ 1280 1290 if ( $has_block_gap_support || $has_fallback_gap_support ) { 1281 1291 $block_gap_value = null; … … 1555 1565 protected static function compute_preset_classes( $settings, $selector, $origins ) { 1556 1566 if ( static::ROOT_BLOCK_SELECTOR === $selector ) { 1557 // Classes at the global level do not need any CSS prefixed, 1558 // and we don't want to increase its specificity. 1567 /* 1568 * Classes at the global level do not need any CSS prefixed, 1569 * and we don't want to increase its specificity. 1570 */ 1559 1571 $selector = ''; 1560 1572 } … … 1898 1910 continue; 1899 1911 } 1900 // Root-level padding styles don't currently support strings with CSS shorthand values. 1901 // This may change: https://github.com/WordPress/gutenberg/issues/40132. 1912 /* 1913 * Root-level padding styles don't currently support strings with CSS shorthand values. 1914 * This may change: https://github.com/WordPress/gutenberg/issues/40132. 1915 */ 1902 1916 if ( '--wp--style--root--padding' === $css_property && is_string( $value ) ) { 1903 1917 continue; … … 1908 1922 } 1909 1923 1910 // Look up protected properties, keyed by value path. 1911 // Skip protected properties that are explicitly set to `null`. 1924 /* 1925 * Look up protected properties, keyed by value path. 1926 * Skip protected properties that are explicitly set to `null`. 1927 */ 1912 1928 if ( is_array( $value_path ) ) { 1913 1929 $path_string = implode( '.', $value_path ); 1914 1930 if ( 1915 // TODO: Replace array_key_exists() with isset() check once WordPress drops 1916 // support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 1931 /* 1932 * TODO: Replace array_key_exists() with isset() check once WordPress drops 1933 * support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 1934 */ 1917 1935 array_key_exists( $path_string, static::PROTECTED_PROPERTIES ) && 1918 1936 _wp_array_get( $settings, static::PROTECTED_PROPERTIES[ $path_string ], null ) === null … … 2119 2137 ); 2120 2138 2121 // Handle any pseudo selectors for the element. 2122 // TODO: Replace array_key_exists() with isset() check once WordPress drops 2123 // support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 2139 /* 2140 * Handle any pseudo selectors for the element. 2141 * TODO: Replace array_key_exists() with isset() check once WordPress drops 2142 * support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 2143 */ 2124 2144 if ( array_key_exists( $element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { 2125 2145 foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) { … … 2271 2291 ); 2272 2292 2273 // Handle any pseudo selectors for the element. 2274 // TODO: Replace array_key_exists() with isset() check once WordPress drops 2275 // support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 2293 /* 2294 * Handle any pseudo selectors for the element. 2295 * TODO: Replace array_key_exists() with isset() check once WordPress drops 2296 * support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 2297 */ 2276 2298 if ( array_key_exists( $element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { 2277 2299 foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $element ] as $pseudo_selector ) { … … 2352 2374 $element_pseudo_allowed = array(); 2353 2375 2354 // TODO: Replace array_key_exists() with isset() check once WordPress drops 2355 // support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 2376 /* 2377 * TODO: Replace array_key_exists() with isset() check once WordPress drops 2378 * support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 2379 */ 2356 2380 if ( array_key_exists( $current_element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { 2357 2381 $element_pseudo_allowed = static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ]; … … 2379 2403 */ 2380 2404 if ( $pseudo_selector && isset( $node[ $pseudo_selector ] ) && 2381 // TODO: Replace array_key_exists() with isset() check once WordPress drops 2382 // support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 2405 /* 2406 * TODO: Replace array_key_exists() with isset() check once WordPress drops 2407 * support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 2408 */ 2383 2409 array_key_exists( $current_element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) 2384 2410 && in_array( $pseudo_selector, static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ], true ) … … 2870 2896 * $output is stripped of pseudo selectors. Re-add and process them 2871 2897 * or insecure styles here. 2898 * 2899 * TODO: Replace array_key_exists() with isset() check once WordPress drops 2900 * support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067. 2872 2901 */ 2873 // TODO: Replace array_key_exists() with isset() check once WordPress drops2874 // support for PHP 5.6. See https://core.trac.wordpress.org/ticket/57067.2875 2902 if ( array_key_exists( $current_element, static::VALID_ELEMENT_PSEUDO_SELECTORS ) ) { 2876 2903 foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $current_element ] as $pseudo_selector ) { … … 2993 3020 $path = static::PROPERTIES_METADATA[ $declaration['name'] ]; 2994 3021 2995 // Check the value isn't an array before adding so as to not 2996 // double up shorthand and longhand styles. 3022 /* 3023 * Check the value isn't an array before adding so as to not 3024 * double up shorthand and longhand styles. 3025 */ 2997 3026 $value = _wp_array_get( $input, $path, array() ); 2998 3027 if ( ! is_array( $value ) ) { … … 3237 3266 } 3238 3267 3239 // If all of the static::APPEARANCE_TOOLS_OPT_INS are true, 3240 // this code unsets them and sets 'appearanceTools' instead. 3268 /* 3269 * If all of the static::APPEARANCE_TOOLS_OPT_INS are true, 3270 * this code unsets them and sets 'appearanceTools' instead. 3271 */ 3241 3272 foreach ( $nodes as $node ) { 3242 3273 $all_opt_ins_are_set = true; … … 3246 3277 $full_path[] = $opt_in_path_item; 3247 3278 } 3248 // Use "unset prop" as a marker instead of "null" because 3249 // "null" can be a valid value for some props (e.g. blockGap). 3279 /* 3280 * Use "unset prop" as a marker instead of "null" because 3281 * "null" can be a valid value for some props (e.g. blockGap). 3282 */ 3250 3283 $opt_in_value = _wp_array_get( $output, $full_path, 'unset prop' ); 3251 3284 if ( 'unset prop' === $opt_in_value ) { … … 3264 3297 $full_path[] = $opt_in_path_item; 3265 3298 } 3266 // Use "unset prop" as a marker instead of "null" because 3267 // "null" can be a valid value for some props (e.g. blockGap). 3299 /* 3300 * Use "unset prop" as a marker instead of "null" because 3301 * "null" can be a valid value for some props (e.g. blockGap). 3302 */ 3268 3303 $opt_in_value = _wp_array_get( $output, $full_path, 'unset prop' ); 3269 3304 if ( true !== $opt_in_value ) { … … 3271 3306 } 3272 3307 3273 // The following could be improved to be path independent. 3274 // At the moment it relies on a couple of assumptions: 3275 // 3276 // - all opt-ins having a path of size 2. 3277 // - there's two sources of settings: the top-level and the block-level. 3308 /* 3309 * The following could be improved to be path independent. 3310 * At the moment it relies on a couple of assumptions: 3311 * 3312 * - all opt-ins having a path of size 2. 3313 * - there's two sources of settings: the top-level and the block-level. 3314 */ 3278 3315 if ( 3279 3316 ( 1 === count( $node['path'] ) ) && … … 3511 3548 */ 3512 3549 protected static function get_block_element_selectors( $root_selector ) { 3513 // Assign defaults, then override those that the block sets by itself. 3514 // If the block selector is compounded, will append the element to each 3515 // individual block selector. 3516 $block_selectors = explode( ',', $root_selector ); 3517 $element_selectors = array(); 3518 3550 /* 3551 * Assign defaults, then override those that the block sets by itself. 3552 * If the block selector is compounded, will append the element to each 3553 * individual block selector. 3554 * $block_selectors = explode( ',', $root_selector ); 3555 * $element_selectors = array(); 3556 */ 3519 3557 foreach ( static::ELEMENTS as $el_name => $el_selector ) { 3520 3558 $element_selector = array(); … … 3555 3593 3556 3594 foreach ( $metadata['selectors'] as $feature => $feature_selectors ) { 3557 // Skip if this is the block's root selector or the block doesn't 3558 // have any styles for the feature. 3595 /* 3596 * Skip if this is the block's root selector or the block doesn't 3597 * have any styles for the feature. 3598 */ 3559 3599 if ( 'root' === $feature || empty( $node[ $feature ] ) ) { 3560 3600 continue; … … 3567 3607 } 3568 3608 3569 // Create temporary node containing only the subfeature data 3570 // to leverage existing `compute_style_properties` function. 3609 /* 3610 * Create temporary node containing only the subfeature data 3611 * to leverage existing `compute_style_properties` function. 3612 */ 3571 3613 $subfeature_node = array( 3572 3614 $feature => array( … … 3587 3629 } 3588 3630 3589 // Remove the subfeature from the block's node now its 3590 // styles will be included under its own selector not the 3591 // block's. 3631 /* 3632 * Remove the subfeature from the block's node now its 3633 * styles will be included under its own selector not the 3634 * block's. 3635 */ 3592 3636 unset( $node[ $feature ][ $subfeature ] ); 3593 3637 } 3594 3638 } 3595 3639 3596 // Now subfeatures have been processed and removed we can process 3597 // feature root selector or simple string selector. 3640 /* 3641 * Now subfeatures have been processed and removed we can process 3642 * feature root selector or simple string selector. 3643 */ 3598 3644 if ( 3599 3645 is_string( $feature_selectors ) || … … 3602 3648 $feature_selector = is_string( $feature_selectors ) ? $feature_selectors : $feature_selectors['root']; 3603 3649 3604 // Create temporary node containing only the feature data 3605 // to leverage existing `compute_style_properties` function. 3650 /* 3651 * Create temporary node containing only the feature data 3652 * to leverage existing `compute_style_properties` function. 3653 */ 3606 3654 $feature_node = array( $feature => $node[ $feature ] ); 3607 3655 … … 3609 3657 $new_declarations = static::compute_style_properties( $feature_node, $settings, null, $this->theme_json ); 3610 3658 3611 // Merge new declarations with any that already exist for 3612 // the feature selector. This may occur when multiple block 3613 // support features use the same custom selector. 3659 /* 3660 * Merge new declarations with any that already exist for 3661 * the feature selector. This may occur when multiple block 3662 * support features use the same custom selector. 3663 */ 3614 3664 if ( isset( $declarations[ $feature_selector ] ) ) { 3615 3665 foreach ( $new_declarations as $new_declaration ) { … … 3620 3670 } 3621 3671 3622 // Remove the feature from the block's node now its styles 3623 // will be included under its own selector not the block's. 3672 /* 3673 * Remove the feature from the block's node now its styles 3674 * will be included under its own selector not the block's. 3675 */ 3624 3676 unset( $node[ $feature ] ); 3625 3677 }
Note: See TracChangeset
for help on using the changeset viewer.