-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Plugin: viewScript does not work with multiple handles/files #45870
Comments
Thanks for the report. I think this is due to the handling of paths in Windows. I recently had a similar problem with a navigation block that has two This is included in Gutenberg 14.7 but has not yet been released as a plugin. If you can build the latest trunk, I believe this issue has been resolved. |
@t-hamano , probably your issue is fixed, but the one described in this ticker still is not. Please refer to the screenshot. The |
@rufus87
@aristath |
Hmmm the implementation was refactored in Core (see https://core.trac.wordpress.org/ticket/56408#no0), but from what I can tell here, the changes were not backported to Gutenberg. |
Thanks for the information, @aristath. I looked into it, but I couldn't figure out if we should move it to the For now, I would like to add the |
This caused some problems on WordPress.org, I suspect either:
Even if changes were made in core that were not back-ported to Gutenberg, this breakage seems to be clearly a bug in the Gutenberg filter. |
Good catch. I think we should move it to a different folder and prevent it from running in WordPress 6.1 and higher. The idea was that the plugin continues to work when a block defines an array but and older version of WordPress core expects a string. By the way, we might go also with an alternative approach and set the minimum version of WordPress to 6.1 as it seems to be good timing with WP 6.2 planned for the end of this month. |
Description
During block type registration from metadata (
register_block_type_from_metadata
function ) there is a great possibility to edit block metadata as it passes threw$metadata = apply_filters( 'block_type_metadata', $metadata );
filter. However there is a callback hooked inblock_type_metadata
filter in gutenberg plugin which registers all scripts ( handles or files ) but actually returns only the first handle name as the value ofviewScript
key in metadata array.Step-by-step reproduction instructions
viewScript
key in any block.json file:{ ... "viewScript": ["file:./slider.min.js", "file:./view.min.js"], }
the result should be
[ ... 'viewScript' => ['slider-handle-name', 'view-handle-name'] ]
the actual result is
[ ... 'viewScript' => 'slider-handle-name' ]
View script never contains an array of handle name, even if block.json does.
Screenshots, screen recording, code snippet
The above screenshot shows how is it implemented in current
14.5.3
version.Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: