[API] Add properly sanitization for categories and tags in products endpoint, closes #8251
This commit is contained in:
parent
b91d3358ef
commit
88003436a6
|
@ -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' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue