-
Notifications
You must be signed in to change notification settings - Fork 4.7k
FSE: Allow child theme.json to be merged with parent theme.json #35459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9dc0390
e297f71
5a19452
d7c53be
88d6630
6a6197e
b347362
966463b
e53fcb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,4 +255,63 @@ function test_add_theme_supports_are_loaded_for_themes_without_theme_json() { | |
| $this->assertSame( $color_palette, $settings['color']['palette']['theme'] ); | ||
| } | ||
|
|
||
| function test_merges_child_theme_json_into_parent_theme_json() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for this!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In #35759 I tweak a bit the test so that we test that single parts can be updated by the child while the untouched parent sections remain the same (the current tests checks that all the child sections override the parent). |
||
| switch_theme( 'fse-child' ); | ||
|
|
||
| $actual = WP_Theme_JSON_Resolver_Gutenberg::get_theme_data(); | ||
|
|
||
| // Should merge settings. | ||
| $this->assertSame( | ||
| array( | ||
| 'color' => array( | ||
| 'palette' => array( | ||
| 'theme' => array( | ||
| array( | ||
| 'slug' => 'light', | ||
| 'name' => 'Light', | ||
| 'color' => '#f3f4f6', | ||
| ), | ||
| array( | ||
| 'slug' => 'primary', | ||
| 'name' => 'Primary', | ||
| 'color' => '#3858e9', | ||
| ), | ||
| array( | ||
| 'slug' => 'dark', | ||
| 'name' => 'Dark', | ||
| 'color' => '#111827', | ||
| ), | ||
| ), | ||
| ), | ||
| 'custom' => true, | ||
| ), | ||
| 'blocks' => array( | ||
| 'core/paragraph' => array( | ||
| 'color' => array( | ||
| 'palette' => array( | ||
| 'theme' => array( | ||
| array( | ||
| 'slug' => 'light', | ||
| 'name' => 'Light', | ||
| 'color' => '#f3f4f6', | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| ), | ||
| $actual->get_settings() | ||
| ); | ||
|
|
||
| $this->assertSame( | ||
| $actual->get_custom_templates(), | ||
| array( | ||
| 'page-home' => array( | ||
| 'title' => 'Homepage', | ||
| 'postTypes' => array( 'page' ), | ||
| ), | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /* | ||
| Theme Name: FSE Child Theme | ||
| Theme URI: https://wordpress.org/ | ||
| Description: For testing purposes only. | ||
| Template: fse | ||
| Version: 1.0.0 | ||
| Text Domain: fse-child | ||
| */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| { | ||
| "version": 1, | ||
| "settings": { | ||
| "color": { | ||
| "palette": [ | ||
| { | ||
| "slug": "light", | ||
| "name": "Light", | ||
| "color": "#f3f4f6" | ||
| }, | ||
| { | ||
| "slug": "primary", | ||
| "name": "Primary", | ||
| "color": "#3858e9" | ||
| }, | ||
| { | ||
| "slug": "dark", | ||
| "name": "Dark", | ||
| "color": "#111827" | ||
| } | ||
| ], | ||
| "custom": true | ||
| }, | ||
| "blocks": { | ||
| "core/paragraph": { | ||
| "color": { | ||
| "palette": [ | ||
| { | ||
| "slug": "light", | ||
| "name": "Light", | ||
| "color": "#f3f4f6" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "customTemplates": [ | ||
| { | ||
| "name": "page-home", | ||
| "title": "Homepage" | ||
| } | ||
| ], | ||
| "templateParts": [ | ||
| { | ||
| "name": "small-header", | ||
| "title": "Small Header", | ||
| "area": "header" | ||
| } | ||
| ] | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.