-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Backport: Gutenberg PR #44363 > Add missing blocks origin to theme.json #3319
Conversation
Thank you @scruffian! I can confirm that the following:
isn't present on |
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.
Thank you @scruffian! This is mostly looking good, except for one gutenberg_
prefix that we need to change 😊
I'll also rebase this quickly since a lot of stuff has been merged to |
56b6ed8
to
e006b20
Compare
Thanks for fixing @ockham |
Self-assigning for commit review and prep. |
UPDATE: |
Oh wait, I see. This PR is a partial and should be paired with PR #3313. Aha. So with 48c8fea, this PR is now a complete backport of the original Gutenberg PR WordPress/gutenberg#44363. This means PR #3313 is no longer needed. I'll close that one in favor of this one (since I already updated this one 🤣 ). |
Thank you, @hellofromtonya! And sorry for the extra work -- we should've probably made clearer that this one was originally just to unblock #3313 😅 |
No problem @ockham Took me a few minutes to realize - doh - what was going on. But now the two are consolidated for a complete backport 🎉 I'm currently looking at the tests and doing manual testing. |
Test ReportEnv:
Test 1: Test that the styles are enqueued when the blocks are in useInstructions
Results:Expectations > Results:
Results: HTML<style id="wp-block-pullquote-inline-css">
/**
* Colors
*/
/**
* Breakpoints & Media Queries
*/
/**
* SCSS Variables.
*
* Please use variables from this sheet to ensure consistency across the UI.
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
*/
/**
* Colors
*/
/**
* Fonts & basic variables.
*/
/**
* Grid System.
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
*/
/**
* Dimensions.
*/
/**
* Shadows.
*/
/**
* Editor widths.
*/
/**
* Block & Editor UI.
*/
/**
* Block paddings.
*/
/**
* React Native specific.
* These variables do not appear to be used anywhere else.
*/
/**
* Converts a hex value into the rgb equivalent.
*
* @param {string} hex - the hexadecimal value to convert
* @return {string} comma separated rgb values
*/
/**
* Breakpoint mixins
*/
/**
* Long content fade mixin
*
* Creates a fading overlay to signify that the content is longer
* than the space allows.
*/
/**
* Focus styles.
*/
/**
* Applies editor left position to the selector passed as argument
*/
/**
* Styles that are reused verbatim in a few places
*/
/**
* Allows users to opt-out of animations via OS-level preferences.
*/
/**
* Reset default styles for JavaScript UI based pages.
* This is a WP-admin agnostic reset
*/
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
.wp-block-pullquote {
margin: 0 0 1em 0;
padding: 3em 0;
text-align: center;
overflow-wrap: break-word;
box-sizing: border-box;
}
.wp-block-pullquote p,
.wp-block-pullquote blockquote,
.wp-block-pullquote cite {
color: inherit;
}
.wp-block-pullquote.alignleft, .wp-block-pullquote.alignright {
max-width: 420px;
}
.wp-block-pullquote cite,
.wp-block-pullquote footer {
position: relative;
}
.wp-block-pullquote .has-text-color a {
color: inherit;
}
.wp-block-pullquote.has-text-align-left blockquote {
text-align: left;
}
.wp-block-pullquote.has-text-align-right blockquote {
text-align: right;
}
.wp-block-pullquote.is-style-solid-color {
border: none;
}
.wp-block-pullquote.is-style-solid-color blockquote {
margin-left: auto;
margin-right: auto;
max-width: 60%;
}
.wp-block-pullquote.is-style-solid-color blockquote p {
margin-top: 0;
margin-bottom: 0;
font-size: 2em;
}
.wp-block-pullquote.is-style-solid-color blockquote cite {
text-transform: none;
font-style: normal;
}
.wp-block-pullquote cite {
color: inherit;
}
/**
* Colors
*/
/**
* Breakpoints & Media Queries
*/
/**
* SCSS Variables.
*
* Please use variables from this sheet to ensure consistency across the UI.
* Don't add to this sheet unless you're pretty sure the value will be reused in many places.
* For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
*/
/**
* Colors
*/
/**
* Fonts & basic variables.
*/
/**
* Grid System.
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
*/
/**
* Dimensions.
*/
/**
* Shadows.
*/
/**
* Editor widths.
*/
/**
* Block & Editor UI.
*/
/**
* Block paddings.
*/
/**
* React Native specific.
* These variables do not appear to be used anywhere else.
*/
/**
* Converts a hex value into the rgb equivalent.
*
* @param {string} hex - the hexadecimal value to convert
* @return {string} comma separated rgb values
*/
/**
* Breakpoint mixins
*/
/**
* Long content fade mixin
*
* Creates a fading overlay to signify that the content is longer
* than the space allows.
*/
/**
* Focus styles.
*/
/**
* Applies editor left position to the selector passed as argument
*/
/**
* Styles that are reused verbatim in a few places
*/
/**
* Allows users to opt-out of animations via OS-level preferences.
*/
/**
* Reset default styles for JavaScript UI based pages.
* This is a WP-admin agnostic reset
*/
/**
* Reset the WP Admin page styles for Gutenberg-like pages.
*/
.wp-block-pullquote {
border-top: 4px solid currentColor;
border-bottom: 4px solid currentColor;
margin-bottom: 1.75em;
color: currentColor;
}
.wp-block-pullquote cite,
.wp-block-pullquote footer, .wp-block-pullquote__citation {
color: currentColor;
text-transform: uppercase;
font-size: 0.8125em;
font-style: normal;
}
</style>
Results: HTML<style id="wp-block-pullquote-inline-css">
.wp-block-navigation a:where(:not(.wp-element-button)){color: inherit;}
</style> Test 2: Test that the styles are not enqueued when the blocks are not in use:Instructions
ResultsExpectations > Results:
Test 3: Test that themes can opt-out from loading blocks separately even if the post uses the blocks:Instructions
ResultsExpectations > Results:
|
@oandregal @scruffian @ockham Can you double check this backport. Using the test instructions, notice the ❌ items (in my Test Report) that did not meet the expectations. Something is missing. Maybe there's another backport that's missing? |
Committer Note: This PR is not yet ready for commit as it is not meeting the defined testing expectations. |
@hellofromtonya @ockham I can confirm I got the same results as Tonya when I tried this PR without the commit 48c8fea that ported WordPress/gutenberg#44363 So probably the root cause is not that. I've noticed that the other PR we're porting WordPress/gutenberg#42005 had a few follow-ups so I wonder if we're missing something else. |
Thank you @hellofromtonya and @oandregal! Apologies, this has been on my list for a while, but I haven't gotten around to look into it yet. I'll be AFK on Friday and Monday; maybe @c4rl0sbr4v0 and @michalczaplinski can help figure this out? 😊 |
bb7ddf5
to
29d5956
Compare
Rebased. |
@michalczaplinski Could you re-test this and see if the re-base fixed the items that didn't work ❌ for @hellofromtonya? If things still don't work, also try with the following patch: diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php
index 344ad3ed99..0520fbd1d6 100644
--- a/src/wp-includes/class-wp-theme-json-resolver.php
+++ b/src/wp-includes/class-wp-theme-json-resolver.php
@@ -178,7 +178,7 @@ class WP_Theme_JSON_Resolver {
$options = wp_parse_args( $options, array( 'with_supports' => true ) );
- if ( null === static::$theme ) {
+ // if ( null === static::$theme ) {
$theme_json_data = static::read_json_file( static::get_file_path_from_theme( 'theme.json' ) );
$theme_json_data = static::translate( $theme_json_data, wp_get_theme()->get( 'TextDomain' ) );
/**
@@ -203,7 +203,7 @@ class WP_Theme_JSON_Resolver {
$parent_theme->merge( static::$theme );
static::$theme = $parent_theme;
}
- }
+ // }
if ( ! $options['with_supports'] ) {
return static::$theme; And if that still doesn't do the trick -- any help to investigate this and track it down is appreciated 😅 |
Investigating this now 👀 |
I've tested locally by reproducing the testing instructions from above and I can still confirm the same results. The result is the same with and without the patch. |
I've rebased and tested this locally and it works as expected. Coordinating with Ben to see who can rebase it. |
29d5956
to
50fc760
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.
This is ready to be committed.
This works as advertised as per these testing instructions. I've also verified that in classic themes (teste with Canape) the block styles defined in block.json are loaded in the global styles stylesheet.
This PR fixes two issues:
- prevent data coming from block.json for blocks overwriting theme data coming from theme.json (presets) Add
blocks
to the list of valid origins fortheme.json
gutenberg#44363 - make sure the block styles defined via block.json work as expected in all situations Global Styles: Always load block CSS from __experimentalStyle gutenberg#42005
As asked by @oandregal, this was committed in https://core.trac.wordpress.org/changeset/54408 |
For future reference, this PR bundles two different things that are unrelated to each other. The SVN commit and issue description does not reflect that well.
|
Trac ticket: https://core.trac.wordpress.org/ticket/56467
Backports WordPress/gutenberg#44363
To test, you can follow the testing instructions on WordPress/gutenberg#44363.
This PR adds a missing origin to the code that processes
theme.json
. It also consolidates its name toblocks
to be more reflective of what it affects. If the data coming from theblocks
origin contained presets, it would be overriden by the data coming from thetheme
origin, which is not expected.Commit message:
Editor: Fix missing
blocks
origin for processingtheme.json
.This commit updates the
blocks
origin name fromcore
toblocks
and adds it to the list of valid origins fortheme.json
. (See the original fix in [https://github.com//pull/3319 Gutenberg's PR 44363].)Why?
core
name is not reflective of what it does, as this data origin is related to block styles, whether they come with WordPress or third-party blocks.theme_json_blocks
, to reflect it filters "block" data.core
origin was used in the past fordefault
, this commit reverts it. Why? It was confusing. The goal is to use names that communicate what part of the pipeline are processing (default > blocks > theme > custom
).How?
core
toblocks
.blocks
to the list of valid origins.$theme_json->get_stylesheet()
call uses the proper$origins
at all times.Follow-up to [54162], [54251].
Props oandregal, czapla, jorgefilipecosta, scruffian, bernhard-reiter hellofromTonya.
See #56467.