Make WordPress Core


Ignore:
Timestamp:
07/06/2026 03:09:22 AM (8 weeks ago)
Author:
isabel_brison
Message:

Editor: ensure no incorrect selector output for pseudo-states.

The output for combined feature selectors and pseudo-states was fixed in [62444] and this removes an extra loop that was outputting an incorrect selector and adds a test.

Props onemaggie, isabel_brison, wildworks.
Fixes #64838.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json.php

    r62607 r62639  
    35003500
    35013501                /*
    3502                  * Check if we're processing a block pseudo-selector.
    3503                  * $block_metadata['path'] = array( 'styles', 'blocks', 'core/button', ':hover' );
    3504                  */
    3505                 $is_processing_block_pseudo = false;
    3506                 $block_pseudo_selector      = null;
    3507                 if ( in_array( 'blocks', $block_metadata['path'], true ) && count( $block_metadata['path'] ) >= 4 ) {
    3508                         $block_name        = static::get_block_name_from_metadata_path( $block_metadata ); // 'core/button'
    3509                         $last_path_element = $block_metadata['path'][ count( $block_metadata['path'] ) - 1 ]; // ':hover'
    3510 
    3511                         if ( isset( static::VALID_BLOCK_PSEUDO_SELECTORS[ $block_name ] ) &&
    3512                                 in_array( $last_path_element, static::VALID_BLOCK_PSEUDO_SELECTORS[ $block_name ], true ) ) {
    3513                                 $is_processing_block_pseudo = true;
    3514                                 $block_pseudo_selector      = $last_path_element;
    3515                         }
    3516                 }
    3517 
    3518                 /*
    35193502                 * Check for allowed pseudo classes (e.g. ":hover") from the $selector ("a:hover").
    35203503                 * This also resets the array keys.
     
    35453528                ) {
    35463529                        $declarations = static::compute_style_properties( $node[ $pseudo_selector ], $settings, null, $this->theme_json, $selector, $use_root_padding );
    3547                 } elseif ( $is_processing_block_pseudo ) {
    3548                         // Process block pseudo-selector styles
    3549                         // For block pseudo-selectors, we need to get the block data first, then access the pseudo-selector
    3550                         $block_name  = static::get_block_name_from_metadata_path( $block_metadata ); // 'core/button'
    3551                         $block_data  = _wp_array_get( $this->theme_json, array( 'styles', 'blocks', $block_name ), array() );
    3552                         $pseudo_data = $block_data[ $block_pseudo_selector ] ?? array();
    3553 
    3554                         $declarations = static::compute_style_properties( $pseudo_data, $settings, null, $this->theme_json, $selector, $use_root_padding );
    35553530                } else {
     3531                        /*
     3532                         * For block pseudo-selector nodes (e.g. ':hover'), $node has already had any
     3533                         * feature-selector properties (e.g. writingMode) removed by get_feature_declarations_for_node,
     3534                         * so those properties are not output twice.
     3535                         */
    35563536                        $declarations = static::compute_style_properties( $node, $settings, null, $this->theme_json, $selector, $use_root_padding );
    35573537                }
Note: See TracChangeset for help on using the changeset viewer.