Make WordPress Core

Changeset 59335


Ignore:
Timestamp:
11/01/2024 05:24:53 AM (6 weeks ago)
Author:
ramonopoly
Message:

Theme JSON: replace top-level background style objects on merge

This commit fixes an omission in the logic of WP_Theme_JSON::merge() where top-level background image style objects are not replaced, rather they are merged. Because background images are self contained objects, their properties are unique and should not be merged. Blocks are already catered for via WP_Theme_JSON::get_block_nodes().

Follow-up to [61858].

Props ramonopoly, andrewserong.
Fixes #62328.

Location:
trunk
Files:
2 edited

Legend:

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

    r59328 r59335  
    32693269            array( 'include_node_paths_only' => true )
    32703270        );
     3271
     3272        // Add top-level styles.
     3273        $style_nodes[] = array( 'path' => array( 'styles' ) );
     3274
    32713275        foreach ( $style_nodes as $style_node ) {
    32723276            $path = $style_node['path'];
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r59213 r59335  
    23452345                    'background' => array(
    23462346                        'backgroundImage' => array(
    2347                             'url' => 'http://example.org/quote.png',
     2347                            'id'     => 'uploaded',
     2348                            'source' => 'file',
     2349                            'url'    => 'http://example.org/quote.png',
    23482350                        ),
    23492351                        'backgroundSize'  => 'cover',
     
    23772379            'styles'  => array(
    23782380                'background' => array(
    2379                     'backgroundSize' => 'contain',
     2381                    'backgroundImage' => array(
     2382                        'url' => 'http://example.org/site.png',
     2383                    ),
     2384                    'backgroundSize'  => 'contain',
    23802385                ),
    23812386                'blocks'     => array(
     
    24072412                'background' => array(
    24082413                    'backgroundImage' => array(
    2409                         'url' => 'http://example.org/quote.png',
     2414                        'url' => 'http://example.org/site.png',
    24102415                    ),
    24112416                    'backgroundSize'  => 'contain',
Note: See TracChangeset for help on using the changeset viewer.