Skip to content

Commit

Permalink
Theme JSON: replace top-level background style objects on merge (#66656)
Browse files Browse the repository at this point in the history
This commit fixes an omission in the theme json merge logic where top-level background image objects are not replaced, rather they are merged, which was the state of affairs before #64128

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
  • Loading branch information
3 people authored Nov 1, 2024
1 parent 99d2275 commit 11e2d06
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions backport-changelog/6.8/7697.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/7697

* https://github.com/WordPress/gutenberg/pull/66656
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

1 comment on commit 11e2d06

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 11e2d06.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11624479633
📝 Reported issues:

Please sign in to comment.