diff --git a/lib/compat/wordpress-6.5/blocks.php b/lib/compat/wordpress-6.5/blocks.php index eeda2d5df535e2..a151bcbedb6fae 100644 --- a/lib/compat/wordpress-6.5/blocks.php +++ b/lib/compat/wordpress-6.5/blocks.php @@ -111,7 +111,7 @@ function gutenberg_block_bindings_replace_html( $block_content, $block_name, str foreach ( $selector_attrs as $attribute_key => $attribute_value ) { $amended_content->set_attribute( $attribute_key, $attribute_value ); } - if ( 'core/paragraph' === $block_name || 'core/heading' === $block_name || ( 'core/image' === $block_name && 'caption' === $attribute_name ) ) { + if ( 'core/paragraph' === $block_name || 'core/heading' === $block_name ) { return $amended_content->get_updated_html(); } if ( 'core/button' === $block_name ) { @@ -123,6 +123,10 @@ function gutenberg_block_bindings_replace_html( $block_content, $block_name, str } return $amended_button->get_updated_html(); } + if ( 'core/image' === $block_name && 'caption' === $attribute_name ) { + // TODO: Don't use regex. + return preg_replace( '/(]*>)(.*?)(<\/figcaption>)/i', $amended_content->get_updated_html(), $block_content ); + } } else { $block_reader->seek( 'iterate-selectors' ); }