Skip to content

Commit

Permalink
Fix regex
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Jun 11, 2024
1 parent 54f3eb1 commit 94e4020
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/compat/wordpress-6.5/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down

0 comments on commit 94e4020

Please sign in to comment.