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

Theme export: Stop slugs being cast to ints when theme is exported #44589

Merged
merged 1 commit into from
Sep 30, 2022

Conversation

glendaviesnz
Copy link
Contributor

What?

Prevent slugs containing only digits from being cast to ints by PHP when used as keys in theme.json processing

Why?

Fixes one of the issues noted in #44546 that spacing preset slugs are cast to ints when a theme is exported via the site editor

How?

Cast the array key to a string when converting back to the preset sizing array

Testing Instructions

  • 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

Screenshots or screencast

before:
Screen Shot 2022-09-30 at 10 49 43 AM

after:
Screen Shot 2022-09-30 at 10 49 50 AM

@glendaviesnz glendaviesnz added [Type] Bug An existing feature does not function as intended Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Sep 29, 2022
@glendaviesnz glendaviesnz self-assigned this Sep 29, 2022
@glendaviesnz
Copy link
Contributor Author

PR to port to core at WordPress/wordpress-develop#3371

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

Slugs LGTM

"spacing": {
	"spacingScale": [],
	"spacingSizes": [
		{
			"name": "1",
			"size": "clamp(1.5rem, 5vw, 2rem)",
			"slug": "30"
		},
		{
			"name": "2",
			"size": "clamp(1.8rem, 1.8rem + ((1vw - 0.48rem) * 2.885), 3rem)",
			"slug": "40"
		},
		{
			"name": "3",
			"size": "clamp(2.5rem, 8vw, 6.5rem)",
			"slug": "50"
		},
		{
			"name": "4",
			"size": "clamp(3.75rem, 10vw, 7rem)",
			"slug": "60"
		},
		{
			"name": "5",
			"size": "clamp(5rem, 5.25rem + ((1vw - 0.48rem) * 9.096), 8rem)",
			"slug": "70"
		},
		{
			"name": "6",
			"size": "clamp(7rem, 14vw, 11rem)",
			"slug": "80"
		}
	],

Spacing scale absence will be fixed in #44555 I take it

@glendaviesnz glendaviesnz merged commit 66e39ae into trunk Sep 30, 2022
@glendaviesnz glendaviesnz deleted the fix/slug-casting-issues branch September 30, 2022 00:18
@github-actions github-actions bot added this to the Gutenberg 14.3 milestone Sep 30, 2022
@cbravobernal cbravobernal removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 3, 2022
@aaronrobertshaw aaronrobertshaw removed the Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json label Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Bug An existing feature does not function as intended
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

4 participants