-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Migrate theme.json v1 to v2 #36155
Migrate theme.json v1 to v2 #36155
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all your efforts on the theme.json v2 schema 👍
I appreciate this PR is still in a draft state with a few things left to do but I took it for a spin all the same.
✅ Theme.json doc updates make sense
✅ Unneeded custom
prefixes have been removed from class-wp-theme-json-gutenberg.php
✅ New v1 to v2 migration looks good
✅ Updates to global styles and theme.json match
✅ All theme.json related tests are passing
While testing I found a few extra updates we might wish to add to the to-do list if they aren't already.
- Update the Create Block Theme doc
- Update theme.json under the schemas package
- This was only added a couple of days ago in Add schemas package #35998
- This schema package landed after the previous removal of
custom
prefixes so we'll need to update all those properties.
Also, do we want to provide the same backwards compatibility bridge in useSetting
as the other properties that had their custom
prefix removed? Or, will that be removed itself soon enough?
Let me know if I can assist in updating the block supports etc that use the renamed theme.json flags. I'm happy to help wherever I can.
a92edc3
to
a42946e
Compare
Size Change: 0 B Total Size: 1.08 MB
ℹ️ View Unchanged
|
@aaronrobertshaw thanks for the early review! I've pushed all changes left (schema, tutorial, client) and updated the issue description with test instructions. This is ready for a final review. |
/** | ||
* Class that implements a migration from a v1 data structure into a v2 one. | ||
*/ | ||
class WP_Theme_JSON_Schema_V1_To_V2 implements WP_Theme_JSON_Schema { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one day we will need a v2 to v3 migration and v3 to v4...
Having a file "lib/class-wp-theme-json-schema-v1-to-v2.php" and class per migration "WP_Theme_JSON_Schema_V1_To_V2" does not scale well. Files and classes are part of the public API.
Could we have a single migrate class that then has private methods inside per migration we need?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things seem to work well, I guess we should just try to avoid having a class per migration.
/** | ||
* Class that implements a migration from a v1 data structure into a v2 one. | ||
*/ | ||
class WP_Theme_JSON_Schema_V1_To_V2 implements WP_Theme_JSON_Schema { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Classes should have _Gutenberg suffix otherwise when we pass the class with the same name to core we are going to have a crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did not test deeply but things seem to be working so I'm approving. I guess we can address my comments in a follow up PR.
I'm going to merge this and try refactoring this to a single class as a follow-up, as per Jorge's suggestion. |
Prepared #36182 to have a single class with all migrations. |
Part of #34349
Built on top of #36154
This PR implements v1 to v2 migrations: we only need to remove the
custom
prefix from some existing properties.Backward compatibility
useSetting( 'spacing.customPadding' )
will still work, although the recommended way is usingspacing.padding
.Test theme.json v1 still works
Using the following theme.json (for example, with the empty theme):
Verify that:
Set the above properties to
true
and verify that the UI controls are enabled.Test theme.json v2
Using the following theme.json (for example, with the empty theme):
Verify that:
Set the above properties to
true
and verify that the UI controls are enabled.