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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add defaultFontSizes theme.json (theme.json v3) #58409

Merged
merged 54 commits into from Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b2e4137
Add defaultFontSizes option to theme.json (#56661)
ajlende Jan 11, 2024
3b79149
Add migration for theme.json v2 to v3
ajlende Jan 26, 2024
71f2514
Use 'merge' to mimic old behavior
ajlende Jan 29, 2024
c02d54c
WIP
ajlende Feb 6, 2024
b2e9522
Fix PHP lint
ajlende Feb 6, 2024
365b9a8
Simplify logic
ajlende Feb 7, 2024
11e69f1
Tidy up comments
ajlende Feb 7, 2024
6a50fa6
Revert phpunit for now
ajlende Feb 7, 2024
1fb673f
Optimize prevent_override logic
ajlende Feb 7, 2024
9b0147a
preset -> preset_metadata
ajlende Feb 7, 2024
59c93c3
Bump core theme.json version
ajlende Feb 7, 2024
37d5910
Bump theme.json version in schema
ajlende Feb 7, 2024
5abb4e5
Reimplement old logic for "merge" value
ajlende Feb 7, 2024
6fcb936
Remove uniqByProperty
ajlende Feb 7, 2024
a0488fe
Fix WP_Theme_JSON_Gutenberg_Test failures
ajlende Feb 7, 2024
c60fb1c
Update WP_Theme_JSON_Schema_Gutenberg_Test with new migration
ajlende Feb 7, 2024
f26f484
Update migration docs
ajlende Feb 7, 2024
4e8dd5e
Update phpunit theme fixtures
ajlende Feb 7, 2024
4f36ed0
Try fixing WP_REST_Global_Styles_Controller_Gutenberg_Test failure
ajlende Feb 7, 2024
0ca202a
Fix PHP lint
ajlende Feb 7, 2024
ed2ec35
Default missing theme.json to latest schema
ajlende Feb 7, 2024
3e6aafd
Fix living docs title
ajlende Feb 7, 2024
e4d41f9
Refactor typography-panel a bit
ajlende Feb 7, 2024
6136799
Fix docs manifest
ajlende Feb 7, 2024
5148bf4
Clarify migration docs
ajlende Feb 7, 2024
c6bf672
Revert "Remove uniqByProperty"
ajlende Feb 7, 2024
044a6f9
Fix getUniqueFontSizesBySlug
ajlende Feb 7, 2024
3d2f8df
Update default schema elsewhere
ajlende Feb 7, 2024
78c55b9
Order the presets default, theme, custom
ajlende Feb 7, 2024
7f0577a
Reword the theme.json v2 backwards compatibility comment
ajlende Feb 9, 2024
cc530d6
Update rest controller test theme
ajlende Feb 9, 2024
b2c3882
PHP Lint
ajlende Feb 9, 2024
1105ad2
Update a few more theme.json files for tests
ajlende Feb 9, 2024
10081c1
Merge branch 'trunk' into fix/default-font-sizes-override
ajlende Feb 14, 2024
214e8f3
Remove the merge keyword that is no longer needed since #58951
ajlende Feb 14, 2024
84d3b5d
Merge branch 'trunk' into fix/default-font-sizes-override
ajlende Mar 6, 2024
d7e80e6
Merge branch 'trunk' into fix/default-font-sizes-override
ajlende Mar 12, 2024
1a7da7f
Merge branch 'trunk' into fix/default-font-sizes-override
ajlende Mar 13, 2024
b0cff00
Hacky way to fix DB save issues
ajlende Mar 13, 2024
a0e0831
Use $new instead of $old
ajlende Mar 18, 2024
14f4ae2
Skip defaultFontSizes migration for custom origin theme.json files
ajlende Mar 18, 2024
cdfd751
Merge branch 'trunk' into fix/default-font-sizes-override
ajlende Mar 18, 2024
70cccb7
Merge branch 'trunk' into fix/default-font-sizes-override
ajlende Apr 16, 2024
0472561
Fix missing textAlign in docs from merge
ajlende Apr 16, 2024
1dc4715
Remove empty line change
ajlende Apr 16, 2024
35e8eb8
Fix user styles not migrating correctly
ajlende Apr 17, 2024
a46414a
Reorder font size dropdown
ajlende Apr 17, 2024
d494c2e
Only run migration on themes with font sizes defined
ajlende Apr 17, 2024
930f297
Add more details to comment
ajlende Apr 17, 2024
ec14150
Ensure isGlobalStylesUserThemeJSON is set for migrations
ajlende Apr 17, 2024
e4459f0
Update tests since skipping for missing font sizes
ajlende Apr 23, 2024
b971b6e
Fix phpcs
ajlende Apr 23, 2024
c0db46c
Update migration docs
ajlende Apr 25, 2024
52bb2ca
Merge branch 'trunk' into fix/default-font-sizes-override
ajlende Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/manifest.json
Expand Up @@ -564,7 +564,7 @@
"parent": "reference-guides"
},
{
"title": "Theme.json Version 2",
"title": "Theme.json Version 3",
"slug": "theme-json-living",
"markdown_source": "../docs/reference-guides/theme-json-reference/theme-json-living.md",
"parent": "theme-json-reference"
Expand Down
@@ -1,10 +1,11 @@
# Theme.json Version 2
# Theme.json Version 3

> This is the living specification for **version 2** of `theme.json`. This version works with WordPress 5.9 or later, and the latest Gutenberg plugin.
> This is the living specification for **version 3** of `theme.json`. This version works with WordPress 5.9 or later, and the latest Gutenberg plugin.
>
> There are some related documents that you may be interested in:
> - the [theme.json v1](/docs/reference-guides/theme-json-reference/theme-json-v1.md) specification, and
> - the [reference to migrate from theme.json v1 to v2](/docs/reference-guides/theme-json-reference/theme-json-migrations.md).
> - the [theme.json v1](/docs/reference-guides/theme-json-reference/theme-json-v1.md) specification,
> - the [theme.json v2](/docs/reference-guides/theme-json-reference/theme-json-v2.md) specification, and
> - the [reference to migrate from older theme.json versions](/docs/reference-guides/theme-json-reference/theme-json-migrations.md).

This reference guide lists the settings and style properties defined in the `theme.json` schema. See the [theme.json how to guide](/docs/how-to-guides/themes/global-settings-and-styles.md) for examples and guidance on how to use the `theme.json` file in your theme.

Expand All @@ -17,7 +18,7 @@ Code editors can pick up the schema and can provide helpful hints and suggestion
```
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"version": 3,
...
}
```
Expand Down Expand Up @@ -179,6 +180,7 @@ Settings related to typography.

| Property | Type | Default | Props |
| --- | --- | --- |--- |
| defaultFontSizes | boolean | true | |
| customFontSize | boolean | true | |
| fontStyle | boolean | true | |
| fontWeight | boolean | true | |
Expand Down
Expand Up @@ -63,3 +63,27 @@ Additions to styles:
### Changes to property values

The default font sizes provided by core (`settings.typography.fontSizes`) have been updated. The Normal and Huge sizes (with `normal` and `huge` slugs) have been removed from the list, and Extra Large (`x-large` slug) has been added. When the UI controls show the default values provided by core, Normal and Huge will no longer be present. However, their CSS classes and CSS Custom Properties are still enqueued to make sure existing content that uses them still works as expected.

## Migrating from v2 to v3

Upgrading to v3 adjusts preset defaults to be more consistent with one another.

### How to migrate from v1 to v2:

1. Update `version` to `3`.
2. Configure the changed defaults.

### Changed defaults

#### `settings.typography.defaultFontSizes`

In theme.json v2, the default font sizes were only shown when theme sizes were not defined. A theme providing font sizes with the same slugs as the defaults would always override them.

The new `defaultFontSizes` option gives control over showing default font sizes and preventing those defaults from being overridden.

- When set to `true` it will show the default font sizes and prevent them from being overridden by the theme.
- When set to `false` it will hide the default font sizes and allow the theme to use the default slugs.
ajlende marked this conversation as resolved.
Show resolved Hide resolved

It is `true` by default when switching to v3. This is to be consistent with how other `default*` options work such as `settings.color.defaultPalette`.

To keep behavior similar to v2, set this value to `false`.