Skip to content

Commit

Permalink
This commit fixes an omission in the theme json merge logic where top…
Browse files Browse the repository at this point in the history
…-level background image objects are not replaced, rather they are merged, which was the state of affairs before #64128
  • Loading branch information
ramonjd committed Nov 1, 2024
1 parent fbdc0f9 commit 80d5fd6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -3297,6 +3297,10 @@ public function merge( $incoming ) {
array(),
array( 'include_node_paths_only' => true )
);

// Add top-level styles.
$style_nodes[] = array( 'path' => array( 'styles' ) );

foreach ( $style_nodes as $style_node ) {
$path = $style_node['path'];
/*
Expand Down
11 changes: 8 additions & 3 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2301,7 +2301,9 @@ public function test_merge_incoming_background_styles() {
'styles' => array(
'background' => array(
'backgroundImage' => array(
'url' => 'http://example.org/quote.png',
'id' => 'uploaded',
'source' => 'file',
'url' => 'http://example.org/quote.png',
),
'backgroundSize' => 'cover',
),
Expand Down Expand Up @@ -2333,7 +2335,10 @@ public function test_merge_incoming_background_styles() {
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'styles' => array(
'background' => array(
'backgroundSize' => 'contain',
'backgroundImage' => array(
'url' => 'http://example.org/site.png',
),
'backgroundSize' => 'contain',
),
'blocks' => array(
'core/group' => array(
Expand Down Expand Up @@ -2363,7 +2368,7 @@ public function test_merge_incoming_background_styles() {
'styles' => array(
'background' => array(
'backgroundImage' => array(
'url' => 'http://example.org/quote.png',
'url' => 'http://example.org/site.png',
),
'backgroundSize' => 'contain',
),
Expand Down

0 comments on commit 80d5fd6

Please sign in to comment.