diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 15357a9df3c8c..cfca9a2242b93 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -3268,6 +3268,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']; /* diff --git a/tests/phpunit/tests/theme/wpThemeJson.php b/tests/phpunit/tests/theme/wpThemeJson.php index 01370ffcc27e9..5b0653c6849a3 100644 --- a/tests/phpunit/tests/theme/wpThemeJson.php +++ b/tests/phpunit/tests/theme/wpThemeJson.php @@ -2344,7 +2344,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', ), @@ -2376,7 +2378,10 @@ public function test_merge_incoming_background_styles() { 'version' => WP_Theme_JSON::LATEST_SCHEMA, 'styles' => array( 'background' => array( - 'backgroundSize' => 'contain', + 'backgroundImage' => array( + 'url' => 'http://example.org/site.png', + ), + 'backgroundSize' => 'contain', ), 'blocks' => array( 'core/group' => array( @@ -2406,7 +2411,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', ),