From 8b17d35bb81110e9dc47329125b478389c915e6e Mon Sep 17 00:00:00 2001 From: Tung Du Date: Fri, 14 Oct 2022 21:22:16 +0700 Subject: [PATCH] fix deep array sort (https://github.com/woocommerce/woocommerce-blocks/pull/7403) --- .../src/BlockTypes/Cart.php | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/plugins/woocommerce-blocks/src/BlockTypes/Cart.php b/plugins/woocommerce-blocks/src/BlockTypes/Cart.php index 1396935bd1e..7ba966669a4 100644 --- a/plugins/woocommerce-blocks/src/BlockTypes/Cart.php +++ b/plugins/woocommerce-blocks/src/BlockTypes/Cart.php @@ -223,24 +223,14 @@ class Cart extends AbstractBlock { } $array_without_accents = array_map( - 'remove_accents', - array_map( - 'wc_strtolower', - array_map( - 'html_entity_decode', - array_map( - function ( $element ) { - if ( is_array( $element ) ) { - return $this->deep_sort_with_accents( $element ); - } - }, - $array - ) - ) - ) + function( $value ) { + return is_array( $value ) + ? $this->deep_sort_with_accents( $value ) + : remove_accents( wc_strtolower( html_entity_decode( $value ) ) ); + }, + $array ); - $array_without_accents = array_map( 'remove_accents', array_map( 'wc_strtolower', array_map( 'html_entity_decode', $array ) ) ); asort( $array_without_accents ); return array_replace( $array_without_accents, $array ); }