update class to use version 3.0 of elasticpress plugin
This commit is contained in:
parent
565656080b
commit
bc638a1121
|
@ -29,7 +29,8 @@ class Elastic_Press {
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if (!class_exists('EP_API')) {
|
//if (!class_exists('EP_API')) {
|
||||||
|
if (!class_exists('ElasticPress\Elasticsearch')) {
|
||||||
return; // ElasticPress not active
|
return; // ElasticPress not active
|
||||||
}
|
}
|
||||||
$this->last_aggregations = [];
|
$this->last_aggregations = [];
|
||||||
|
@ -106,7 +107,8 @@ class Elastic_Press {
|
||||||
if ($type == 'items' && (!isset($args['ep_integrate']) || $args['ep_integrate'] === true)) {
|
if ($type == 'items' && (!isset($args['ep_integrate']) || $args['ep_integrate'] === true)) {
|
||||||
$args['ep_integrate'] = true;
|
$args['ep_integrate'] = true;
|
||||||
|
|
||||||
add_action('ep_retrieve_aggregations', function ( array $aggregations, $scope, $args ) {
|
add_action('ep_valid_response', function ( $response, $query, $query_args ) {
|
||||||
|
$aggregations = $response['aggregations'];
|
||||||
$this->last_aggregations = $this->format_aggregations($aggregations);
|
$this->last_aggregations = $this->format_aggregations($aggregations);
|
||||||
}, 10, 3);
|
}, 10, 3);
|
||||||
|
|
||||||
|
@ -265,15 +267,15 @@ class Elastic_Press {
|
||||||
$formatted_args = $this->prepare_request_for_facet($formatted_args);
|
$formatted_args = $this->prepare_request_for_facet($formatted_args);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( isset($formatted_args['sort']) ) {
|
// if( isset($formatted_args['sort']) ) {
|
||||||
$new_sort = [];
|
// $new_sort = [];
|
||||||
foreach ($formatted_args['sort'] as $sort) {
|
// foreach ($formatted_args['sort'] as $sort) {
|
||||||
foreach ($sort as $key => $value) {
|
// foreach ($sort as $key => $value) {
|
||||||
$new_sort["$key.raw"] = $value;
|
// $new_sort["$key.raw"] = $value;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
$formatted_args['sort'] = $new_sort;
|
// $formatted_args['sort'] = $new_sort;
|
||||||
}
|
// }
|
||||||
return $formatted_args;
|
return $formatted_args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue