From 88003436a6a9a3dbac48d8e30d5bf64939ca401d Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Fri, 29 May 2015 10:04:02 -0300 Subject: [PATCH] [API] Add properly sanitization for categories and tags in products endpoint, closes #8251 --- includes/api/class-wc-api-products.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/api/class-wc-api-products.php b/includes/api/class-wc-api-products.php index cb0f5ffbe90..b78bddd9766 100644 --- a/includes/api/class-wc-api-products.php +++ b/includes/api/class-wc-api-products.php @@ -1136,13 +1136,13 @@ class WC_API_Products extends WC_API_Resource { // Product categories if ( isset( $data['categories'] ) && is_array( $data['categories'] ) ) { - $terms = array_map( 'wc_clean', $data['categories'] ); - wp_set_object_terms( $product_id, $terms, 'product_cat' ); + $term_ids = array_unique( array_map( 'intval', $data['categories'] ) ); + wp_set_object_terms( $product_id, $term_ids, 'product_cat' ); } // Product tags if ( isset( $data['tags'] ) && is_array( $data['tags'] ) ) { - $terms = array_map( 'wc_clean', $data['tags'] ); + $term_ids = array_unique( array_map( 'intval', $data['tags'] ) ); wp_set_object_terms( $product_id, $terms, 'product_tag' ); }