[API] Add properly sanitization for categories and tags in products endpoint, closes #8251

This commit is contained in:
Claudio Sanches 2015-05-29 10:04:02 -03:00
parent b91d3358ef
commit 88003436a6
1 changed files with 3 additions and 3 deletions

View File

@ -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' );
}