Skip to content
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

Increment theme.json version to 3 #40232

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This guide documents the changes between different `theme.json` versions and how to upgrade. Using older versions will continue to be supported. Upgrading is recommended because new development will continue in the newer versions.

## Migrating from v2 to v3

Update `version` to `3`. No other changes necessary.

## Migrating from v1 to v2

Upgrading to v2 enables some new features and adjusts the naming of some old features to be more consistent with one another.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public static function migrate( $theme_json ) {
$theme_json = self::migrate_v1_to_v2( $theme_json );
}

if ( 2 === $theme_json['version'] ) {
$theme_json['version'] = 3;
}
Comment on lines +80 to +82
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate this change is trivial but for consistency with the other theme.json classes and 6.0 related changes should we override this class in the same manner? I'm also ok with leaving it here.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, you're right, should this land, we need to fix it.


return $theme_json;
}

Expand Down
7 changes: 7 additions & 0 deletions lib/compat/wordpress-6.0/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ class WP_Theme_JSON_Gutenberg extends WP_Theme_JSON_5_9 {
),
);

/**
* The latest version of the schema in use.
*
* @var int
*/
const LATEST_SCHEMA = 3;

/**
* Returns the current theme's wanted patterns(slugs) to be
* registered from Pattern Directory.
Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.0/theme.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 2,
"version": 3,
"settings": {
"appearanceTools": false,
"border": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function test_get_theme_items() {
$data = $response->get_data();
$expected = array(
array(
'version' => 2,
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
Expand Down
14 changes: 7 additions & 7 deletions phpunit/class-wp-theme-json-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2263,7 +2263,7 @@ function test_sanitization() {

$actual = $theme_json->get_raw_data();
$expected = array(
'version' => 2,
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'styles' => array(
'spacing' => array(
'blockGap' => 'valid value',
Expand Down Expand Up @@ -2329,7 +2329,7 @@ function test_export_data() {
$theme->merge( $user );
$actual = $theme->get_data();
$expected = array(
'version' => 2,
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
Expand Down Expand Up @@ -2381,7 +2381,7 @@ function test_export_data_deals_with_empty_user_data() {

$actual = $theme->get_data();
$expected = array(
'version' => 2,
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
Expand Down Expand Up @@ -2429,7 +2429,7 @@ function test_export_data_deals_with_empty_theme_data() {

$actual = $user->get_data();
$expected = array(
'version' => 2,
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
Expand Down Expand Up @@ -2459,7 +2459,7 @@ function test_export_data_deals_with_empty_data() {
'theme'
);
$actual_v2 = $theme_v2->get_data();
$expected_v2 = array( 'version' => 2 );
$expected_v2 = array( 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA );
$this->assertEqualSetsWithIndex( $expected_v2, $actual_v2 );

$theme_v1 = new WP_Theme_JSON_Gutenberg(
Expand All @@ -2469,7 +2469,7 @@ function test_export_data_deals_with_empty_data() {
'theme'
);
$actual_v1 = $theme_v1->get_data();
$expected_v1 = array( 'version' => 2 );
$expected_v1 = array( 'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA );
$this->assertEqualSetsWithIndex( $expected_v1, $actual_v1 );
}

Expand All @@ -2490,7 +2490,7 @@ function test_export_data_sets_appearance_tools() {

$actual = $theme->get_data();
$expected = array(
'version' => 2,
'version' => WP_Theme_JSON_Gutenberg::LATEST_SCHEMA,
'settings' => array(
'appearanceTools' => true,
'blocks' => array(
Expand Down