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 #2565

Closed
wants to merge 2 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
4 changes: 4 additions & 0 deletions src/wp-includes/class-wp-theme-json-schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,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;
}

return $theme_json;
}

Expand Down
3 changes: 2 additions & 1 deletion src/wp-includes/class-wp-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,10 @@ class WP_Theme_JSON {
*
* @since 5.8.0
* @since 5.9.0 Changed value from 1 to 2.
* @since 6.0.0 Changes value from 2 to 3.
* @var int
*/
const LATEST_SCHEMA = 2;
const LATEST_SCHEMA = 3;

/**
* Constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/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 @@ -470,7 +470,7 @@ public function test_get_theme_items() {
$data = $response->get_data();
$expected = array(
array(
'version' => 2,
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
Expand Down
14 changes: 7 additions & 7 deletions tests/phpunit/tests/theme/wpThemeJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -2366,7 +2366,7 @@ public function test_sanitization() {

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

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

$actual = $user->get_data();
$expected = array(
'version' => 2,
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
Expand Down Expand Up @@ -2574,7 +2574,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::LATEST_SCHEMA );
$this->assertEqualSetsWithIndex( $expected_v2, $actual_v2 );

$theme_v1 = new WP_Theme_JSON(
Expand All @@ -2584,7 +2584,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::LATEST_SCHEMA );
$this->assertEqualSetsWithIndex( $expected_v1, $actual_v1 );
}

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

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