Skip to content
Open
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
3 changes: 1 addition & 2 deletions src/wp-includes/class-wp-duotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -1191,8 +1191,7 @@ public static function restore_image_outer_container( $block_content ) {
$tags->set_bookmark( 'wrapper-div' );
$tags->next_tag();

$inner_classnames = explode( ' ', $tags->get_attribute( 'class' ) );
foreach ( $inner_classnames as $classname ) {
foreach ( $tags->class_list() as $classname ) {
if ( str_starts_with( $classname, 'wp-duotone' ) ) {
$tags->remove_class( $classname );
$tags->seek( 'wrapper-div' );
Expand Down
12 changes: 12 additions & 0 deletions tests/phpunit/tests/block-supports/duotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ public function test_render_duotone_support_custom() {
$this->assertMatchesRegularExpression( $expected, WP_Duotone::render_duotone_support( $block_content, $block, $wp_block ) );
}

/**
* @covers ::restore_image_outer_container
*/
public function test_restore_image_outer_container_moves_duotone_class_to_wrapper_in_classic_theme() {
switch_theme( 'default' );

$block_content = '<div class="wp-block-image"><figure class="alignright wp-duotone-blue-orange size-full"><img src="/my-image.jpg"></figure></div>';
$expected = '<div class="wp-block-image wp-duotone-blue-orange"><figure class="alignright size-full"><img src="/my-image.jpg"></figure></div>';

$this->assertEqualHTML( $expected, WP_Duotone::restore_image_outer_container( $block_content ) );
}

/**
* Tests whether the slug is extracted from the attribute.
*
Expand Down
Loading