Changeset 61632 for trunk/src/wp-includes/class-wp-theme-json.php
- Timestamp:
- 02/13/2026 01:51:03 AM (7 weeks ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-theme-json.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r61631 r61632 248 248 * @since 6.7.0 Added `background-attachment` property. 249 249 * @since 7.0.0 Added `dimensions.width` and `dimensions.height`. 250 * Added `text-indent` property. 250 251 * @var array 251 252 */ … … 310 311 'text-decoration' => array( 'typography', 'textDecoration' ), 311 312 'text-transform' => array( 'typography', 'textTransform' ), 313 'text-indent' => array( 'typography', 'textIndent' ), 312 314 'filter' => array( 'filter', 'duotone' ), 313 315 'box-shadow' => array( 'shadow' ), … … 410 412 * @since 7.0.0 Added type markers to the schema for boolean values. 411 413 * Added support for `dimensions.width` and `dimensions.height`. 414 * Added support for `typography.textIndent`. 412 415 * @var array 413 416 */ … … 495 498 'textColumns' => null, 496 499 'textDecoration' => null, 500 'textIndent' => null, 497 501 'textTransform' => null, 498 502 'writingMode' => null, … … 602 606 'textColumns' => null, 603 607 'textDecoration' => null, 608 'textIndent' => null, 604 609 'textTransform' => null, 605 610 'writingMode' => null, … … 2751 2756 2752 2757 /** 2758 * Updates the text indent selector for paragraph blocks based on the textIndent setting. 2759 * 2760 * The textIndent setting can be 'subsequent' (default), 'all', or false. 2761 * When set to 'all', the selector should be '.wp-block-paragraph' instead of 2762 * '.wp-block-paragraph + .wp-block-paragraph' to apply indent to all paragraphs. 2763 * 2764 * @since 7.0.0 2765 * 2766 * @param array $feature_declarations The feature declarations keyed by selector. 2767 * @param array $settings The theme.json settings. 2768 * @param string $block_name The block name being processed. 2769 * @return array The updated feature declarations. 2770 */ 2771 private static function update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name ) { 2772 if ( 'core/paragraph' !== $block_name ) { 2773 return $feature_declarations; 2774 } 2775 2776 // Check block-level settings first, then fall back to global settings. 2777 $block_settings = $settings['blocks']['core/paragraph'] ?? null; 2778 $text_indent_setting = $block_settings['typography']['textIndent'] 2779 ?? $settings['typography']['textIndent'] 2780 ?? 'subsequent'; 2781 2782 if ( 'all' !== $text_indent_setting ) { 2783 return $feature_declarations; 2784 } 2785 2786 // Look for the text indent selector and replace it. 2787 $old_selector = '.wp-block-paragraph + .wp-block-paragraph'; 2788 $new_selector = '.wp-block-paragraph'; 2789 2790 if ( isset( $feature_declarations[ $old_selector ] ) ) { 2791 $declarations = $feature_declarations[ $old_selector ]; 2792 unset( $feature_declarations[ $old_selector ] ); 2793 $feature_declarations[ $new_selector ] = $declarations; 2794 } 2795 2796 return $feature_declarations; 2797 } 2798 2799 /** 2753 2800 * An internal method to get the block nodes from a theme.json file. 2754 2801 * … … 2911 2958 $is_root_selector = static::ROOT_BLOCK_SELECTOR === $selector; 2912 2959 2960 // Update text indent selector for paragraph blocks based on the textIndent setting. 2961 $block_name = $block_metadata['name'] ?? null; 2962 $feature_declarations = static::update_paragraph_text_indent_selector( $feature_declarations, $settings, $block_name ); 2963 2913 2964 // If there are style variations, generate the declarations for them, including any feature selectors the block may have. 2914 2965 $style_variation_declarations = array(); … … 2922 2973 // Generate any feature/subfeature style declarations for the current style variation. 2923 2974 $variation_declarations = static::get_feature_declarations_for_node( $block_metadata, $style_variation_node ); 2975 2976 // Update text indent selector for paragraph blocks based on the textIndent setting. 2977 $variation_declarations = static::update_paragraph_text_indent_selector( $variation_declarations, $settings, $block_name ); 2924 2978 2925 2979 // Combine selectors with style variation's selector and add to overall style variation declarations.
Note: See TracChangeset
for help on using the changeset viewer.