-
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
Theme JSON: remove unused vars in layout class #59938
Conversation
$has_block_gap_support is only used once
@@ -2729,9 +2729,7 @@ public function get_root_layout_rules( $selector, $block_metadata ) { | |||
$css .= '.wp-site-blocks > .alignright { float: right; margin-left: 2em; }'; | |||
$css .= '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'; | |||
|
|||
$block_gap_value = $this->theme_json['styles']['spacing']['blockGap'] ?? '0.5em'; |
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'm still seeing a fallback in the JS
Should the fallback of '0.5em'
be used in the if statement if static::get_property_value
returns empty?
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.
Good question! A couple of considerations:
- Core's
lib/theme.json
includes astyles.spacing.blockGap
value of24px
, so in practice, was the0.5em
value ever being output? I'm curious if the0.5em
default spacing was ever being displayed visually for anyone 🤔 - I think the
0.5em
fallback was originally intended for flex layouts so that on classic themes where there might not be any blockGap value, things like Buttons spacing would still get a visually pleasing default value. In the case of root layout rules, that might not be necessary?
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
Good catch! ✨
✅ Smoke tested that root layout block spacing rules are still output when settings.spacing.blockGap
is either true
or false
✅ They are not output when blockGap
is set to null
✅ Styles are output correctly, and the previous fallback value was never being used anyway
LGTM, just left a note about whether it's worth adding a one-line comment to flag that blockGap
outputs in true
and false
but not null
.
Remove unused vars: - $block_gap_value is immediately overwritten in the if block - $has_block_gap_support is only used once Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
What?
Removing some unused vars in the Theme JSON class.
Noticed while working on #42084
Why?
$has_block_gap_support
is only used once$block_gap_value
is immediately overwritten in the subsequentif
blockTesting Instructions
Tests should pass.
On the frontend, there should be no regressions: the block gap value should be correctly output where the ✅ is:
:where(.wp-site-blocks) > * { margin-block-start: ✅ ; margin-block-end: 0; }
andbody { --wp--style--block-gap: ✅; }