From 3be4f01a25b9efdb9bd8954fd3acc3d2c5ca015b Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Wed, 29 Jul 2026 10:05:38 +0800 Subject: [PATCH 1/2] fix: preserve slashes for woocommerce product duplicate --- src/compatibility/woocommerce.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/compatibility/woocommerce.php b/src/compatibility/woocommerce.php index 47dfe27f06..0f8b60ce90 100644 --- a/src/compatibility/woocommerce.php +++ b/src/compatibility/woocommerce.php @@ -58,3 +58,29 @@ function stackable_get_woocommerce_shop_page_id( $post_id ) { add_filter( 'stackable/get_post_id_for_cached_css', 'stackable_get_woocommerce_shop_page_id' ); } + +/** + * Preserve escaped block attributes when WooCommerce duplicates a product. + * + * WooCommerce passes a product description read from the database directly to + * wp_insert_post(), which expects slashed data. Without restoring that slash + * layer, escaped characters in block comment JSON (for example, \u003c in an + * SVG icon or \u002d in a preset CSS variable) lose their backslashes. + */ +if ( ! function_exists( 'stackable_preserve_woocommerce_duplicate_block_escaping' ) ) { + + function stackable_preserve_woocommerce_duplicate_block_escaping( $duplicate, $product ) { + $description = $duplicate->get_description( 'edit' ); + + if ( strpos( $description, '