diff --git a/src/wp-includes/class-wp-duotone.php b/src/wp-includes/class-wp-duotone.php index d0b978eacef21..b75b01619fbee 100644 --- a/src/wp-includes/class-wp-duotone.php +++ b/src/wp-includes/class-wp-duotone.php @@ -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' ); diff --git a/tests/phpunit/tests/block-supports/duotone.php b/tests/phpunit/tests/block-supports/duotone.php index 808903a072452..fef2e74929286 100644 --- a/tests/phpunit/tests/block-supports/duotone.php +++ b/tests/phpunit/tests/block-supports/duotone.php @@ -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 = '

