From 43e55c3336ca35a8d02a8630722369bfd4743d9e Mon Sep 17 00:00:00 2001 From: Justin Shreve Date: Wed, 31 Aug 2016 15:15:28 -0700 Subject: [PATCH] Instead of catching just the post_status, don't overwrite any filter args. --- includes/api/class-wc-rest-products-controller.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/api/class-wc-rest-products-controller.php b/includes/api/class-wc-rest-products-controller.php index 010d0d1d9f2..5432fd75280 100644 --- a/includes/api/class-wc-rest-products-controller.php +++ b/includes/api/class-wc-rest-products-controller.php @@ -130,11 +130,7 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller { */ public function query_args( $args, $request ) { // Set post_status. - if ( ! empty( $request['filter'] ) && ! empty( $request['filter']['post_status'] ) ) { - $args['post_status'] = $request['filter']['post_status']; - } else { - $args['post_status'] = $request['status']; - } + $args['post_status'] = $request['status']; // Taxonomy query to filter products by type, category, // tag, shipping class, and attribute. @@ -203,6 +199,11 @@ class WC_REST_Products_Controller extends WC_REST_Posts_Controller { $args['post_type'] = array( 'product', 'product_variation' ); } + if ( is_array( $request['filter'] ) ) { + $args = array_merge( $args, $request['filter'] ); + unset( $args['filter'] ); + } + return $args; }