Skip to content
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/55415 make duotone support compatible with enhanced pagination #5540

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-duotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ private static function get_all_global_style_block_names() {
* @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 );
Expand Down
27 changes: 27 additions & 0 deletions tests/phpunit/tests/block-supports/duotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,33 @@ public function data_get_slug_from_attribute() {
);
}

/**
* 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() );

hellofromtonya marked this conversation as resolved.
Show resolved Hide resolved
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
*/
Expand Down
Loading