Use wc_check_utf8 function

This commit is contained in:
claudiulodro 2018-10-05 15:58:50 -04:00
parent dfad1306de
commit 91d2411aa9
2 changed files with 15 additions and 1 deletions

View File

@ -208,7 +208,7 @@ function wc_save_order_items( $order_id, $items ) {
$item_data = array(); $item_data = array();
foreach ( $data_keys as $key => $default ) { foreach ( $data_keys as $key => $default ) {
$item_data[ $key ] = isset( $items[ $key ][ $item_id ] ) ? wc_clean( wp_unslash( $items[ $key ][ $item_id ] ) ) : $default; $item_data[ $key ] = isset( $items[ $key ][ $item_id ] ) ? wc_check_invalid_utf8( wp_unslash( $items[ $key ][ $item_id ] ) ) : $default;
} }
if ( '0' === $item_data['order_item_qty'] ) { if ( '0' === $item_data['order_item_qty'] ) {

View File

@ -377,6 +377,20 @@ function wc_clean( $var ) {
} }
} }
/**
* wp_check_invalid_utf8 with recursive array support.
*
* @param string|array $var Data to sanitize.
* @return string|array
*/
function wc_check_invalid_utf8( $var ) {
if ( is_array( $var ) ) {
return array_map( 'wc_check_invalid_utf8', $var );
} else {
return wp_check_invalid_utf8( $var );
}
}
/** /**
* Run wc_clean over posted textarea but maintain line breaks. * Run wc_clean over posted textarea but maintain line breaks.
* *