diff --git a/lib/compat/wordpress-6.5/blocks.php b/lib/compat/wordpress-6.5/blocks.php index a151bcbedb6fae..8aae938597a12f 100644 --- a/lib/compat/wordpress-6.5/blocks.php +++ b/lib/compat/wordpress-6.5/blocks.php @@ -125,7 +125,13 @@ function gutenberg_block_bindings_replace_html( $block_content, $block_name, str } if ( 'core/image' === $block_name && 'caption' === $attribute_name ) { // TODO: Don't use regex. - return preg_replace( '/(<figcaption[^>]*>)(.*?)(<\/figcaption>)/i', $amended_content->get_updated_html(), $block_content ); + return preg_replace_callback( + '/<figcaption[^>]*>.*?<\/figcaption>/is', + function () use ( $amended_content ) { + return $amended_content->get_updated_html(); + }, + $block_content + ); } } else { $block_reader->seek( 'iterate-selectors' );