-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Try: bundle WP_Theme_JSON
class instead of inheriting per WordPress version
#46579
Conversation
It was added to clear the static variables that were set from running the core class first. Now that this class won't inherit from the core one, it is no longer necessary. See #42776
theme.json
class instead of inheriting per WordPress versionWP_Theme_JSON
class instead of inheriting per WordPress version
Yeah. That's going to be something that we find in the resolver already (e.g.: webfonts). Some ideas:
Essentially, we need to look at how other areas deal with this. My thinking is that different situations may need different approaches. By looking at the list of backports we missed in the 6.1 cycle, we cannot say the current approach is working or is better than this. This is the list of backports we missed (only considering the
My point is that we may want to ship this and figure how to deal with the experimental stuff when we have a specific case (the resolver will have one already: webfonts). |
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.
This change makes sense to me. Simpler is usually better. I suggest we get it merged ASAP to avoid dealing with lots of conflicts.
OK, going to go ahead with this. Thanks all for the testing. I'll follow up with a PR for the resolver next week, and we can continue the conversation about experimental code over there. |
Follow-up for the resolver at #46750 |
I'm including this in a patch release of 14.8, because it is required for compatibility with WordPress 6.0. I looked through the PR changes, and each deleted file was not modified after 14.8 was released. Assuming this PR is mostly a refactor (maintaining functionality rather than changing how the feature works), including it in 14.8 won't functionally change how 14.8 works. See #46811 for more info |
What?
This PR proposes a different way to organize theme.json code.
Why?
The existing mechanism uses an inheritance model, where Gutenberg modifies only certain parts of WordPress. This approach:
How?
The current mechanism relies on inheritance. The code in Gutenberg inherits from the core class and modifies the relevant parts of it, scoped to a specific WordPress version so backports were easier. This means that we have:
WP_Theme_JSON
class that lives in the runtime.WP_Theme_JSON_6_1
class atlib/compat/wordpress-6.1
for features to be shipped in WordPress 6.1.WP_Theme_JSON_6_2
class atlib/compat/wordpress-6.2
for features to be shipped in WordPress 6.2.WP_Theme_JSON_Gutenberg
class atlib/compat/experimental
for features that are not ready to be shipped and/or as a placeholder. The whole Gutenberg codebase we should useWP_Theme_JSON_Gutenberg
to have the latest changes.This PR proposes that we have a single class,
WP_Theme_JSON_Gutenberg
, that does not inherit from the core one. Comparing the core and the Gutenberg classes is a matter of using a diff tool over a single file.Questions
Is there a better setup?
I don't think the current setup is working for the reasons I mentioned above, so it's best if we change it. Happy to hear alternatives if people have them.
Where this single class should live?
Initially, this PR proposed to have it at
lib/compat/wordpress-6.2
. It was switched to live atlib/
, which follows what we do forlib/block-supports
and other files (client-assets.php
).Using the
@since
tagThe expectations for this class going forward should be that we use
@since
PHPDoc tag to document the changes like we do in WordPress core.Testing Instructions
Given this moves code from one place to another, it's difficult to provide a test plan. The fact that automated tests pass gives us some certainty the main paths are working.
This is what I've done, though you may want to try things you're most familiar with:
Theme with
theme.json
(TwentyTwentyThree):Theme without
theme.json
(TwentyTwenty):Next steps
I'd like to merge this one as soon as the tests pass. This is an active area of development and it the PR is up for more than a few days is going to consume a lot of time to keep it up with the changes.
The same should be done for
WP_Theme_JSON_Resolver
. Given this is a big change in terms of lines of code touched, I'd prefer to do it individually, to manage scope, if at all possible.