From d306d1ef40937d666a97dd42ee87c08a7008e23c Mon Sep 17 00:00:00 2001 From: Tung Du Date: Mon, 15 Jan 2024 15:34:11 +0700 Subject: [PATCH 1/2] fix: allow svg in storefront messages, such as notices --- ...refront-woocommerce-template-functions.php | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/inc/woocommerce/storefront-woocommerce-template-functions.php b/inc/woocommerce/storefront-woocommerce-template-functions.php index d034eea2..098b032f 100644 --- a/inc/woocommerce/storefront-woocommerce-template-functions.php +++ b/inc/woocommerce/storefront-woocommerce-template-functions.php @@ -235,9 +235,33 @@ function storefront_product_columns_wrapper_close() { */ function storefront_shop_messages() { if ( ! is_checkout() ) { - echo wp_kses_post( storefront_do_shortcode( 'woocommerce_messages' ) ); + $kses_defaults = wp_kses_allowed_html( 'post' ); + + $svg_args = array( + 'svg' => array( + 'class' => true, + 'aria-hidden' => true, + 'aria-labelledby' => true, + 'role' => true, + 'xmlns' => true, + 'width' => true, + 'height' => true, + 'viewbox' => true, + ), + 'g' => array( 'fill' => true ), + 'title' => array( 'title' => true ), + 'path' => array( + 'd' => true, + 'fill' => true + ) + ); + + $allowed_tags = array_merge( $kses_defaults, $svg_args ); + + echo wp_kses( storefront_do_shortcode( 'woocommerce_messages' ), $allowed_tags ); } } + } if ( ! function_exists( 'storefront_woocommerce_pagination' ) ) { From fe63f3c467477cfbde8f6fb77aca1c18614ff03a Mon Sep 17 00:00:00 2001 From: Tung Du Date: Mon, 15 Jan 2024 15:43:42 +0700 Subject: [PATCH 2/2] chore: phpcs --- .../storefront-woocommerce-template-functions.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/inc/woocommerce/storefront-woocommerce-template-functions.php b/inc/woocommerce/storefront-woocommerce-template-functions.php index 098b032f..f97e0eba 100644 --- a/inc/woocommerce/storefront-woocommerce-template-functions.php +++ b/inc/woocommerce/storefront-woocommerce-template-functions.php @@ -248,12 +248,16 @@ function storefront_shop_messages() { 'height' => true, 'viewbox' => true, ), - 'g' => array( 'fill' => true ), - 'title' => array( 'title' => true ), + 'g' => array( + 'fill' => true, + ), + 'title' => array( + 'title' => true, + ), 'path' => array( - 'd' => true, - 'fill' => true - ) + 'd' => true, + 'fill' => true, + ), ); $allowed_tags = array_merge( $kses_defaults, $svg_args ); @@ -261,7 +265,6 @@ function storefront_shop_messages() { echo wp_kses( storefront_do_shortcode( 'woocommerce_messages' ), $allowed_tags ); } } - } if ( ! function_exists( 'storefront_woocommerce_pagination' ) ) {