-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Reduce layout rule specificity and add compound classname #4623
Changes from all commits
41833b3
b0cebb4
d6d2052
c8b09e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1221,6 +1221,7 @@ protected function get_block_classes( $style_nodes ) { | |
* Gets the CSS layout rules for a particular block from theme.json layout definitions. | ||
* | ||
* @since 6.1.0 | ||
* @since 6.3.0 Reduced specificity for layout margin rules. | ||
* | ||
* @param array $block_metadata Metadata about the block to get styles for. | ||
* @return string Layout styles for the block. | ||
|
@@ -1317,7 +1318,7 @@ protected function get_layout_styles( $block_metadata ) { | |
$spacing_rule['selector'] | ||
); | ||
} else { | ||
$format = static::ROOT_BLOCK_SELECTOR === $selector ? '%s .%s%s' : '%s.%s%s'; | ||
$format = static::ROOT_BLOCK_SELECTOR === $selector ? ':where(%s .%s) %s' : '%s-%s%s'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, thanks! |
||
$layout_selector = sprintf( | ||
$format, | ||
$selector, | ||
|
@@ -2532,8 +2533,9 @@ public function get_root_layout_rules( $selector, $block_metadata ) { | |
$has_block_gap_support = _wp_array_get( $this->theme_json, array( 'settings', 'spacing', 'blockGap' ) ) !== null; | ||
if ( $has_block_gap_support ) { | ||
$block_gap_value = static::get_property_value( $this->theme_json, array( 'styles', 'spacing', 'blockGap' ) ); | ||
$css .= '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }'; | ||
$css .= ".wp-site-blocks > * + * { margin-block-start: $block_gap_value; }"; | ||
$css .= ":where(.wp-site-blocks) > * { margin-block-start: $block_gap_value; margin-block-end: 0; }"; | ||
$css .= ':where(.wp-site-blocks) > :first-child:first-child { margin-block-start: 0; }'; | ||
$css .= ':where(.wp-site-blocks) > :last-child:last-child { margin-block-end: 0; }'; | ||
|
||
// For backwards compatibility, ensure the legacy block gap CSS variable is still available. | ||
$css .= "$selector { --wp--style--block-gap: $block_gap_value; }"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3827,6 +3827,7 @@ public function data_wp_get_loading_attr_default_before_and_no_loop() { | |
* image in the loop when using a block theme. | ||
* | ||
* @ticket 56930 | ||
* @ticket 58548 | ||
* | ||
* @covers ::wp_filter_content_tags | ||
* @covers ::wp_get_loading_attr_default | ||
|
@@ -3863,14 +3864,15 @@ public function test_wp_filter_content_tags_does_not_lazy_load_first_image_in_bl | |
$_wp_current_template_content = '<!-- wp:post-content /-->'; | ||
|
||
$html = get_the_block_template_html(); | ||
$this->assertSame( '<div class="wp-site-blocks"><div class="entry-content wp-block-post-content is-layout-flow">' . $expected_content . '</div></div>', $html ); | ||
$this->assertSame( '<div class="wp-site-blocks"><div class="entry-content wp-block-post-content is-layout-flow wp-block-post-content-is-layout-flow">' . $expected_content . '</div></div>', $html ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
} | ||
|
||
/** | ||
* Tests that wp_filter_content_tags() does not add loading="lazy" | ||
* to the featured image when using a block theme. | ||
* | ||
* @ticket 56930 | ||
* @ticket 58548 | ||
* | ||
* @covers ::wp_filter_content_tags | ||
* @covers ::wp_get_loading_attr_default | ||
|
@@ -3918,7 +3920,7 @@ static function( $attr ) { | |
$_wp_current_template_content = '<!-- wp:post-featured-image /--> <!-- wp:post-content /-->'; | ||
|
||
$html = get_the_block_template_html(); | ||
$this->assertSame( '<div class="wp-site-blocks">' . $expected_featured_image . ' <div class="entry-content wp-block-post-content is-layout-flow">' . $expected_content . '</div></div>', $html ); | ||
$this->assertSame( '<div class="wp-site-blocks">' . $expected_featured_image . ' <div class="entry-content wp-block-post-content is-layout-flow wp-block-post-content-is-layout-flow">' . $expected_content . '</div></div>', $html ); | ||
} | ||
|
||
/** | ||
|
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.
For
wp_render_layout_support_flag
annotation:@since 6.3.0 Adds compound class to layout wrapper for global spacing styles.
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.
Aha, thanks!