From aa46824ece6cd02ceaff4445398aa8b1c56bfa0d Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Fri, 18 Jan 2019 17:04:39 -0200 Subject: [PATCH] debugs API elasticpress --- .../endpoints/class-tainacan-rest-items-controller.php | 1 + src/classes/class-tainacan-elastic-press.php | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/api/endpoints/class-tainacan-rest-items-controller.php b/src/api/endpoints/class-tainacan-rest-items-controller.php index 699ff0e21..57063cf90 100644 --- a/src/api/endpoints/class-tainacan-rest-items-controller.php +++ b/src/api/endpoints/class-tainacan-rest-items-controller.php @@ -279,6 +279,7 @@ class REST_Items_Controller extends REST_Controller { $items = $this->items_repository->fetch($args, $collection_id, 'WP_Query'); + //mas e se não estiver usando o plugin? vai voltar "null" $items_aggregations = \Tainacan\Elastic_Press::get_instance()->last_aggregations; //if elasticPress active $response['facets'] = $items_aggregations; $response['items'] = []; diff --git a/src/classes/class-tainacan-elastic-press.php b/src/classes/class-tainacan-elastic-press.php index 4d9702c7c..faf62d85c 100644 --- a/src/classes/class-tainacan-elastic-press.php +++ b/src/classes/class-tainacan-elastic-press.php @@ -38,9 +38,10 @@ class Elastic_Press { $this->last_aggregations = $aggregations; }, 10, 3); - //add_action('ep_add_query_log', function($query) { //using to DEBUG - //error_log($query["args"]["body"]); - //}); + // add_action('ep_add_query_log', function($query) { //using to DEBUG + // error_log("DEGUG:"); + // error_log($query["args"]["body"]); + // }); } function filter_args($args, $type) { @@ -137,7 +138,7 @@ class Elastic_Press { foreach ($custom_filter['bool']['must'] as $item) { if ( isset($item['bool'])) { foreach ($item['bool']["must"] as $item_filter) { - if ( !isset( $item_filter["terms"][$filter['key']] ) ) { + if ( !isset( $item_filter["terms"][$filter['key']] ) ) { //do use array_filter ? $temp[] = $item; } }