-
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
Conversation
@@ -707,7 +707,7 @@ function gutenberg_extend_block_editor_settings_with_fse_theme_flag( $settings ) | |||
/** | |||
* Sets the editor styles to be consumed by JS. | |||
*/ | |||
function gutenberg_extend_block_editor_styles_html() { | |||
function gutenberg_add_iframed_editor_assets_html() { |
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.
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 as gutenberg_extend_block_editor_assets
— or alternatively along the lines of gutenberg_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.
It's not for the frontend, it's for the editor
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.
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.
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 replace gutenberg_
with wp_
. 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.
Size Change: 0 B Total Size: 1.62 MB ℹ️ View Unchanged
|
Description
See #31873 (comment)
How has this been tested?
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).