-
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
Fix: Global styles for non-core blocks aren't loaded on the front end #44053
Closed
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
t-hamano
added
[Type] Bug
An existing feature does not function as intended
Global Styles
Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
labels
Sep 11, 2022
t-hamano
commented
Sep 11, 2022
@@ -33,16 +45,23 @@ function wp_add_global_styles_for_blocks() { | |||
array_filter( | |||
$metadata['path'], | |||
function ( $item ) { | |||
if ( str_contains( $item, 'core/' ) ) { | |||
if ( str_contains( $item, '/' ) ) { |
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.
I think to check only slashes is the only way to include non-core blocks, is there a better approach?
The GitHub action failing will be resolved if #44052 is merged. |
I did something very similar here! #44018 |
Sorry, I should have checked my past PRs. |
This was referenced Apr 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Global Styles
Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
[Type] Bug
An existing feature does not function as intended
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.
Fix #43679
What?
This PR fixes that global styles for non-core blocks aren't loaded on the front end,
Why?
I think this is due to the fact that non-core blocks were excluded in wp_add_global_styles_for_blocks.
How?
I have applied the logic of script handle generation in the WordPress core.
This will ensure that global styles for non-core blocks and global styles for the elements property of non-core blocks are output correctly.
Testing Instructions
npx @wordpress/create-block gutenpride
outside gutenberg repository..wp-env.override.json
.npm run wp-env start -- --update
emptytheme
and put the following code intheme.json
.Global styles should be output via the block handle on the front-end
create-block-gutenpride-style-inline-css
) on the front end.Global styles should be output via the global-styles handle on the front-end
add_filter( 'should_load_separate_core_block_assets', '__return_false' );
infunctions.php
.global-styles-inline-css
) on the front end.