-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Block API: Allow more than 1 block stylesheets #32510
Conversation
210590e
to
384e64b
Compare
74bab5a
to
9ee2d1f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9ee2d1f
to
f5217a5
Compare
This comment has been minimized.
This comment has been minimized.
The same issue was raised in https://make.wordpress.org/core/2021/06/23/block-api-enhancements-in-wordpress-5-8/#comment-41466 for scripts. It isn't possible to provide in a simple way multiple scripts of the same type for the block using |
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 will need to be tested in the iframed editors (template editor and FSE).
f5217a5
to
5d6373c
Compare
Many of these things would be a lot easier to do directly in wp-core... I expect the logic to be greatly simplified when this (or a similar implementation) gets backported to core 🤞 |
7433886
to
1d836c1
Compare
a09a7bc
to
baac268
Compare
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.
Let's give it a try. I think it's in good shape after several iterations and covers all I can think of for now. We can further improve e2e tests as noted in the most recent comment.
The biggest remaining tasks are to prepare the dev note and find a way to backport those changes to WordPress core.
The next step to think about is how to bring feature parity for JS assets 😄
Awesome work as always. It's a pleasure to review your outstanding work.
Description
This PR aims to allow enqueing multiple stylesheets per-block.
Inside a
block.json
file:Allow defining
style
andeditorStyle
as an array. In the case of thepost-comments-form
block we needed to also enqueue styles for thebutton
block. This is now possible by changing the value fromto
From a theme/plugin
If a theme needs to add styles to a block, they can now do it using the
wp_enqueue_block_style
function:How has this been tested?
assets/blocks/site-title.css
and confirmed that the code above adds the styles when the template contains a site-title block.Checklist:
*.native.js
files for terms that need renaming or removal).