Merge pull request #13 from tainacan/add_ep_integrate

fix: add support for elasticpress in searches used by blocksy
This commit is contained in:
Mateus Machado Luna 2022-11-30 10:00:38 -03:00 committed by GitHub
commit 8825e67247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 0 deletions

View File

@ -1,4 +1,21 @@
<?php <?php
/**
* add support for elasticpress in searches used by blocksy
*/
add_filter('pre_get_posts', function ($query) {
if (class_exists('\Tainacan\Elastic_Press')) {
$tainacan_Elastic_press = \Tainacan\Elastic_Press::get_instance();
if (
isset($tainacan_Elastic_press) &&
$tainacan_Elastic_press->is_active() &&
$query->is_search &&
(is_search() || wp_doing_ajax())
) {
$query->set('ep_integrate', true);
}
}
return $query;
});
/** /**
* Uses Template redirect for setting the proper template to items * Uses Template redirect for setting the proper template to items