Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
668c31e
Backport 58409 class-wp-theme-json.php
ajlende Jun 3, 2024
4c02184
Backport 58409 class-wp-theme-json-schema.php
ajlende May 23, 2024
a4e24a0
Backport 58409 class-wp-theme-json-data.php
ajlende May 23, 2024
4696b35
Backport 58409 class-wp-theme-json-resolver.php
ajlende May 23, 2024
97a24e0
Backport 58409 theme.json
ajlende May 23, 2024
719a4bd
Backport 58409 PHPUnit wpThemeJsonSchema.php
ajlende May 23, 2024
9a0e4b4
Backport 58409 PHPUnit wpThemeJson.php
ajlende May 23, 2024
915f254
Backport 58409 PHPUnit rest-global-styles-controller.php
ajlende May 23, 2024
2f9b431
Backport 58409 PHPUnit data
ajlende May 23, 2024
3769e79
Backport 61842 class-wp-theme-json.php
ajlende May 23, 2024
dc57d38
Backport 61842 class-wp-theme-json-resolver.php
ajlende May 23, 2024
943d9bb
Backport 61842 class-wp-theme-json-schema.php
ajlende May 23, 2024
0a33eb1
Backport 61842 theme.json
ajlende May 23, 2024
35695f2
Backport 61842 PHPUnit wpThemeJsonSchema.php
ajlende May 23, 2024
7599a7f
Backport 61842 PHPUnit wpThemeJson.php
ajlende May 23, 2024
ca161da
Merge 6.6 `@since` tags
ajlende Jun 3, 2024
caaeb72
Update LATEST_THEME_JSON_VERSION_SUPPORTED in font-faces controller
ajlende Jun 3, 2024
6569a11
Add default-font-sizes options for classic themes
ajlende Jun 3, 2024
d073251
Add default-spacing-sizes options for classic themes
ajlende Jun 3, 2024
93e3c82
Add editor-spacing-sizes for consistency
ajlende Jun 3, 2024
ea23bf0
Update LATEST_THEME_JSON_VERSION_SUPPORTED in font-families controller
ajlende Jun 3, 2024
afe235e
Fix phpunit tests
ajlende Jun 3, 2024
1b583a1
Update wp-api-generated
ajlende Jun 3, 2024
1e93db4
Added 6.6.0 doc comments
ajlende Jun 3, 2024
c8cdcc1
register_theme_feature( 'editor-spacing-sizes' )
ajlende Jun 4, 2024
5214e4f
Copy spacingSizes from editor-spacing-sizes
ajlende Jun 4, 2024
6b6d2b6
Fix tests
ajlende Jun 4, 2024
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
Prev Previous commit
Next Next commit
Backport 61842 class-wp-theme-json-schema.php
  • Loading branch information
ajlende authored and ellatrix committed Jun 4, 2024
commit 943d9bbe07051bee3c0ba1c3d9f88665bc40ffdd
44 changes: 38 additions & 6 deletions src/wp-includes/class-wp-theme-json-schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ private static function migrate_v2_to_v3( $old ) {
}

/*
* Even though defaultFontSizes is a new setting, we need to migrate
* it as it controls the PRESETS_METADATA prevent_override which was
* previously hardcoded to false. This only needs to happen when the
* theme provided font sizes as they could match the default ones and
* affect the generated CSS. And in v2 we provided default font sizes
* when the theme did not provide any.
* Even though defaultFontSizes and defaultSpacingSizes are new
* settings, we need to migrate them as they each control
* PRESETS_METADATA prevent_override values which were previously
* hardcoded to false. This only needs to happen when the theme provides
* fontSizes or spacingSizes as they could match the default ones and
* affect the generated CSS.
*/
if ( isset( $old['settings']['typography']['fontSizes'] ) ) {
if ( ! isset( $new['settings'] ) ) {
Expand All @@ -138,6 +138,38 @@ private static function migrate_v2_to_v3( $old ) {
$new['settings']['typography']['defaultFontSizes'] = false;
}

/*
* Similarly to defaultFontSizes, we need to migrate defaultSpacingSizes
* as it controls the PRESETS_METADATA prevent_override which was
* previously hardcoded to false. This only needs to happen when the
* theme provided spacing sizes via spacingSizes or spacingScale.
*/
if (
isset( $old['settings']['spacing']['spacingSizes'] ) ||
isset( $old['settings']['spacing']['spacingScale'] )
) {
if ( ! isset( $new['settings'] ) ) {
$new['settings'] = array();
}
if ( ! isset( $new['settings']['spacing'] ) ) {
$new['settings']['spacing'] = array();
}
$new['settings']['spacing']['defaultSpacingSizes'] = false;
Copy link
Member

@ramonjd ramonjd Jun 4, 2024

Choose a reason for hiding this comment

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

As with the defaultFontSizes above, in PHP you can set the value of a nested array item:

$new = [];
$new['settings']['spacing']['defaultSpacingSizes'] = false;
var_dump( $new );

/*
Output:
array(1) {
  ["settings"]=>
  array(1) {
    ["spacing"]=>
    array(1) {
      ["defaultSpacingSizes"]=>
      bool(false)
    }
  }
}*/

Copy link
Member

Choose a reason for hiding this comment

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

Let's follow-up with this.

}

/*
* In v3 spacingSizes is merged with the generated spacingScale sizes
* instead of completely replacing them. The v3 behavior is what was
* documented for the v2 schema, but the code never actually did work
* that way. Instead of surprising users with a behavior change two
* years after the fact at the same time as a v3 update is introduced,
* we'll continue using the "bugged" behavior for v2 themes. And treat
* the "bug fix" as a breaking change for v3.
*/
if ( isset( $old['settings']['spacing']['spacingSizes'] ) ) {
unset( $new['settings']['spacing']['spacingScale'] );
}

return $new;
}

Expand Down