From 77e3da81b278cd52f5cab973c3774f9b6b028b92 Mon Sep 17 00:00:00 2001 From: Seghir Nadir Date: Wed, 29 Sep 2021 11:54:50 +0100 Subject: [PATCH] Checkout i2: support odd classes when transforming from Checkout i1 to Checkout i2 (https://github.com/woocommerce/woocommerce-blocks/pull/4866) * support odd classes for Checkout * support classNames at start of string * keep classNames and aligment on frontend --- .../woocommerce-blocks/src/BlockTypes/Checkout.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/woocommerce-blocks/src/BlockTypes/Checkout.php b/plugins/woocommerce-blocks/src/BlockTypes/Checkout.php index fe85f907c03..26e9df181d8 100644 --- a/plugins/woocommerce-blocks/src/BlockTypes/Checkout.php +++ b/plugins/woocommerce-blocks/src/BlockTypes/Checkout.php @@ -77,13 +77,14 @@ class Checkout extends AbstractBlock { wp_dequeue_style( 'select2' ); // If the content is empty, we may have transformed from an older checkout block. Insert the default list of blocks. - $is_empty = strstr( $content, '
' ); + $regex_for_empty_block = '/
<\/div>/mi'; + + $is_empty = preg_match( $regex_for_empty_block, $content ); if ( $is_empty ) { - $content = '
-
-
-
'; + $inner_blocks_html = '
'; + + $content = str_replace( '
', $inner_blocks_html . '', $content ); } return $this->inject_html_data_attributes( $content, $attributes );