Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#56684 closed defect (bug) (reported-upstream)

Fluid and spacing settings in theme.json are lost when theme expor

Reported by: ramonopoly Owned by:
Priority: normal Milestone:
Component: Themes Version: 6.1
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

When exporting a theme that uses some settings.spacing values and/or settings.typography.fluid,

  • settings.spacing.spacingScale.steps -> field is lost
  • settings.spacing.spacingSizes.slug -> quotation is lost
  • settings.typography.fluid -> field is lost

## Step-by-step reproduction instructions

  • Use WP 6.1 nightly and Twenty Twenty Three without gutenberg plugin
  • Go to the site editor.
  • Select Three dots menu > Export

To fix:

  • Fluid typography needs to be added as a valid setting in WP_Theme_JSON
  • The spacing presets config for spacingScale needs to be removed in WP_Theme_JSON as only spacingSizes should be defined.

Issue on the Gutenberg repo: ​https://github.com/WordPress/gutenberg/issues/44546

Props to Github user mayuge3

Change History (9)

This ticket was mentioned in ​PR #3362 on ​WordPress/wordpress-develop by ​glendaviesnz.


4 years ago
#1

The new fluid typography setting is missing from the theme.json valid values in 6.1, which causes the value to be dropped from theme exports from the editor as ​reported here.

Trac ticket: https://core.trac.wordpress.org/ticket/56684

​ramonjd commented on ​PR #3362:


4 years ago
#2

Thank you @glendaviesnz 💟

It's looking good. Should the spacing slug value be a string? E.g., "slug": "30"

## 2023 theme.json

{{{json
"typography": {

"dropCap": false,
"fluid": true,
"fontFamilies": [

...

"spacing": {

"spacingScale": {

"steps": 0

},
"spacingSizes": [

{

"size": "clamp(1.5rem, 5vw, 2rem)",
"slug": "30",
"name": "30"

},

}}}

## Export before

{{{json

"typography": {

"dropCap": false,
"fontFamilies": [

....

"spacing": {

"spacingScale": [],
"spacingSizes": [

{

"name": "30",
"size": "clamp(1.5rem, 5vw, 2rem)",
"slug": 30

},

}}}
## After

{{{json
"typography": {

"dropCap": false,
"fluid": true,
"fontFamilies": [

...

"spacing": {

"spacingScale": {

"steps": 0

},
"spacingSizes": [

{

"name": "30",
"size": "clamp(1.5rem, 5vw, 2rem)",
"slug": 30

},

}}}

​dream-encode commented on ​PR #3362:


4 years ago
#3

I was looking to merge this, but I want to make sure this comment by @tellthemachines is addressed in the final PR:
​https://github.com/WordPress/gutenberg/pull/44555#pullrequestreview-1124645012

​dream-encode commented on ​PR #3362:


4 years ago
#4

After looking at the code and the comments, it appears the concerns are addressed. Prepping a merge commit to core.

#5 @davidbaumwald
4 years ago

  • Milestone Awaiting Review
  • Resolution → reported-upstream
  • Status new → closed

Closing this as reported-upstream in ​https://github.com/WordPress/gutenberg/issues/44546.

This ticket was mentioned in ​PR #3371 on ​WordPress/wordpress-develop by ​glendaviesnz.


4 years ago
#7

The new spacing preset slugs get cast to ints when a theme is exported as reported in ​https://github.com/WordPress/gutenberg/issues/44546. This PR makes sure they are cast back to strings if PHP converts them to ints when they are used as array keys.

Trac ticket: https://core.trac.wordpress.org/ticket/56684

### Testing

  • In a site with the 2023 theme set export the theme from the site editor
  • Make sure the exported theme.json has the settings.spacingScale slugs as strings
  • Check that the spacing presets still work as expected in post editor, site editor and frontend

#8 @davidbaumwald
4 years ago

In 54363:

Editor: Cast theme.json values to string on theme export.

Props glendaviesnz.
See #56684.

Note: See TracTickets for help on using tickets.