mirrored from git://develop.git.wordpress.org/
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add backward compat shim for WP_Theme_JSON_Data::get_theme_json #6626
Closed
joemcgill
wants to merge
4
commits into
WordPress:trunk
from
joemcgill:fix/61112-wp-theme-json-data-compat
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
89dbb9f
Add backward compat shim for WP_Theme_JSON_Data::get_theme_json
joemcgill f314789
Merge branch 'trunk' into fix/61112-wp-theme-json-data-compat
joemcgill 327bb48
Ensure objects returned from filters are validated by `WP_Theme_JSON`
joemcgill 544d762
Prefer instanceof to is_a()
joemcgill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hi, is anyone able to reproduce this error?
I cannot repro the issue reported using latest WordPress
trunk
and Gutenberg 14.8.1 (the last release prior to updatingWP_Theme_JSON_Data_Gutenberg
). I'd like to understand this better before jumping into implementation.The only way I can think to reproduce the issue is by not using the provided structure to update the data as a consumer of this filter. This is, instead of doing:
Your plugin does something like:
Note that this is not supported or recommended. The
update_with
method is a requirement to use these filters, as stated in the devnote, because it makes sure everything works correctly (data migration, sanitization, etc.). This is what happened to @ryelle, as she reported.Is there any other use case?
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.
To be clear, I'm not against doing it, but I'm reluctant to given that it only happens if a plugin provides their own structure, which is not supported or recommended.
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.
The issue can be reproduced using the Blocks Everywhere plugin, which does the following, basically:
(full code here)
Which I suppose is incorrect according to the dev note, but it did work before the recent change.
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.
@oandregal I believe this was only reproducible prior to
WP_Theme_JSON_Data_Gutenberg::get_theme_json
being added in version 18.3.0, which shipped after the core change. If we don't need to worry about WP 6.6 compat with any Gutenberg versions prior to 18.3.0, then we can probably close this issue aswontfix
.However, I think this use case is instructive for us as we consider better ways of managing the
WP_Theme_JSON_
classes between the GB repo and the WP-dev repo to avoid these types of conflicts.