-
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
Iframed editor: rename PHP function for assets #32010
Closed
Closed
Changes from all commits
Commits
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
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.
@gziolo How would this be named in WP core?
@mcsf Is this a good name? :)
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.
Is the mention of iframe too implementation-specific? Ultimately, the function returns nothing and has the side effect of
echo "<script>window.__editorAssets = $editor_assets</script>";
, so I'd favour something as close to the original asgutenberg_extend_block_editor_assets
— or alternatively along the lines ofgutenberg_prepare_block_editor_frontend_assets
?Also, don't forget to update the doc comment for the function!
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.
It's not for the frontend, it's for the editor. It's also very specific for the use in the iframe and ideally we need to refactor this to not output HTML but hopefully the sources formatted as JSON.
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.
Right, that's the reason for my poor attempt with
_block_editor_frontend_
. But since some of the assets will be editor-only, it's no good.Hm, that's fair. I'm ok with your initial suggestion, then. :)
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.
It's a hard one to name properly, mayby
gutenberg_share_block_editor_assets_with_iframe
. It's a callback for the filter so in WP core we can replacegutenberg_
withwp_
. At least this is the most popular handling. The challenge here is also to ensure it doesn't get printed twice, so in Gutenberg, we should either bail out early when the function is defined in core or maybe better to remove the filter that WP core registers.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.
What should we do now that this has landed in core? Should we remove the core filter when adding this in Gutenberg?
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.
If we want to override the filter that exists in WP core we should remove the original one, before adding a newer version. If the version present in WP core is good enough we would need something to bridge WP 5.7 anyway. We can use an action name that is in WP 5.8 as a way to perform feature detection.
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.
What we currently do in Gutenberg, does it not output the scripts twice? So we'll have to do it.