mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Editor: Fix render_duotone_support() to be compatible with enhanced pagination.
Some blocks do not have content. For duotone support, blocks without content still need to run through the `render_duotone_support()` to render their duotone CSS. This fix makes the duotone compatible with the enhanced pagination (introduced in 6.4.0) by making sure that the CSS is always on the page, even when the posts have no featured image. It also prevents the duotone from interfering with other blocks using `wp_unique_id()`. References: * [https://github.com/WordPress/gutenberg/pull/55415 Gutenberg PR 55415] Follow-up to [56226]. Props cbravobernal, luisherranz, hellofromTonya, isabel_brison, jorbin. Fixes #59694. git-svn-id: https://develop.svn.wordpress.org/trunk@56991 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
51ae4e67d0
commit
ee631556b4
@ -1074,7 +1074,7 @@ class WP_Duotone {
|
||||
* @return string Filtered block content.
|
||||
*/
|
||||
public static function render_duotone_support( $block_content, $block, $wp_block ) {
|
||||
if ( empty( $block_content ) || ! $block['blockName'] ) {
|
||||
if ( ! $block['blockName'] ) {
|
||||
return $block_content;
|
||||
}
|
||||
$duotone_selector = self::get_selector( $wp_block->block_type );
|
||||
|
||||
@ -102,6 +102,33 @@ class Tests_Block_Supports_Duotone extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the CSS declarations are generated even if the block content is
|
||||
* empty. This is needed to make the CSS output stable across paginations for
|
||||
* features like the enhanced pagination of the Query block.
|
||||
*
|
||||
* @ticket 59694
|
||||
*
|
||||
* @covers ::render_duotone_support
|
||||
*/
|
||||
public function test_css_declarations_are_generated_even_with_empty_block_content() {
|
||||
$block = array(
|
||||
'blockName' => 'core/image',
|
||||
'attrs' => array( 'style' => array( 'color' => array( 'duotone' => 'var:preset|duotone|blue-orange' ) ) ),
|
||||
);
|
||||
$wp_block = new WP_Block( $block );
|
||||
$block_css_declarations_property = new ReflectionProperty( 'WP_Duotone', 'block_css_declarations' );
|
||||
$block_css_declarations_property->setAccessible( true );
|
||||
$block_css_declarations_property->setValue( $wp_block, array() );
|
||||
|
||||
WP_Duotone::render_duotone_support( '', $block, $wp_block );
|
||||
$actual = $block_css_declarations_property->getValue();
|
||||
// Reset the property's visibility.
|
||||
$block_css_declarations_property->setAccessible( false );
|
||||
|
||||
$this->assertNotEmpty( $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_is_preset
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user