From 0cbf68ce1269e34e932aea6915fa9305a7b9bfd2 Mon Sep 17 00:00:00 2001 From: Luigi Date: Thu, 6 Jan 2022 17:14:42 +0100 Subject: [PATCH] update regex --- src/BlockTypes/LegacyTemplate.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/BlockTypes/LegacyTemplate.php b/src/BlockTypes/LegacyTemplate.php index 75a717cd587..82ae999204f 100644 --- a/src/BlockTypes/LegacyTemplate.php +++ b/src/BlockTypes/LegacyTemplate.php @@ -220,9 +220,7 @@ public function add_alignment_class_to_wrapper( string $content, array $block ) // If there is a tag, but it doesn't have a class attribute, add the class attribute. if ( isset( $matches[0] ) && strpos( $matches[0], ' class=' ) === false ) { $pattern_before_tag_closing = '/.+?(?=>)/'; - $matches = array(); - preg_match( $pattern_before_tag_closing, $content, $matches ); - return preg_replace( $pattern_before_tag_closing, $matches[0] . ' class="' . $align_class_and_style['class'] . '"', $content, 1 ); + return preg_replace( $pattern_before_tag_closing, '$0' . ' class="' . $align_class_and_style['class'] . '"', $content, 1 ); } // If there is a tag, and it has a class already, add the class attribute.