-
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
Allow themes to add inline styles for all blocks when using lazy styles loading #32275
Merged
Conversation
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
aristath
added
the
[Feature] Themes
Questions or issues with incorporating or styling blocks in a theme.
label
May 27, 2021
aristath
requested review from
ajitbohra,
mkaz,
spacedmonkey and
TimothyBJacobs
as code owners
May 27, 2021 13:23
aristath
changed the title
register empty styles for blocks that don't have any
Allow themes to add inline styles for all blocks when using lazy styles loading
May 27, 2021
gziolo
reviewed
Jun 7, 2021
gziolo
reviewed
Jun 7, 2021
aristath
force-pushed
the
add/block-styles-register-no-file
branch
2 times, most recently
from
June 7, 2021 13:26
7e2d8cf
to
3a39cea
Compare
aristath
force-pushed
the
add/block-styles-register-no-file
branch
from
June 8, 2021 09:51
3a39cea
to
67582a8
Compare
gziolo
approved these changes
Jun 8, 2021
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 all looks good. Let's get this in and ensure that the same logic gets included in WordPress core as part of the 5.8 release.
I left a minor note about the proposed location for the filter. Comment with a version when it can be removed is fine for now, too.
youknowriad
pushed a commit
that referenced
this pull request
Jun 8, 2021
…es loading (#32275) * register empty styles for blocks that don't have any * add style & editorStyle in block.json where missing * only do this if the file doesn't exist * meh, missed the 2nd arg here * Use a filter instead of modifying each block.json file. * Use the register_block_type_args filter * Move filter to compat files
aristath
added
the
Backport to WP 6.7 Beta/RC
Pull request that needs to be backported to the WordPress major release that's currently in beta
label
Jun 8, 2021
youknowriad
removed
the
Backport to WP 6.7 Beta/RC
Pull request that needs to be backported to the WordPress major release that's currently in beta
label
Jun 8, 2021
aristath
added a commit
to aristath/wordpress-develop
that referenced
this pull request
Jun 8, 2021
youknowriad
pushed a commit
that referenced
this pull request
Jun 8, 2021
…es loading (#32275) * register empty styles for blocks that don't have any * add style & editorStyle in block.json where missing * only do this if the file doesn't exist * meh, missed the 2nd arg here * Use a filter instead of modifying each block.json file. * Use the register_block_type_args filter * Move filter to compat files
3 tasks
aristath
added a commit
to aristath/wordpress-develop
that referenced
this pull request
Jun 15, 2021
aristath
added a commit
to aristath/wordpress-develop
that referenced
this pull request
Jun 23, 2021
aristath
added a commit
to aristath/wordpress-develop
that referenced
this pull request
Jun 24, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Now that themes can opt-in to only load styles for rendered blocks, theme-authors can attach additional styles to specific blocks by using
wp_add_inline_style( 'wp-block-group', '.wp-block-group{padding:2em;}' );
. However, they are unable to do that for all blocks, so they can't conditionally load styles depending on what blocks exist on a page.This PR fixes this issue by adding
style
andeditorStyle
in allblock.json
files where missing. Then, insidegutenberg_register_core_block_styles
if a file doesn't exist for the registered style, a stylesheet will be registered usingfalse
assrc
. This way, if a theme adds inline styles to one of these blocks, they will be printed.How has this been tested?
In a block them added the following inside the functions.php file:
then went to the frontend and confirmed that the site-title block was rotated.
Checklist:
*.native.js
files for terms that need renaming or removal).