public function setup()
{
// Ensure that we are currently allowing ElasticPress to override the normal WP_Query
if (ep_is_indexing()) {
return;
}
// Make sure we return nothing for MySQL posts query
add_filter('posts_request', array($this, 'filter_posts_request'), 10, 2);
// Add header
add_action('pre_get_posts', array($this, 'action_pre_get_posts'), 5);
// Nukes the FOUND_ROWS() database query
add_filter('found_posts_query', array($this, 'filter_found_posts_query'), 5, 2);
// Query and filter in EP_Posts to WP_Query
add_filter('the_posts', array($this, 'filter_the_posts'), 10, 2);
// Ensure we're in a loop before we allow blog switching
add_action('loop_start', array($this, 'action_loop_start'), 10, 1);
// Properly restore blog if necessary
add_action('loop_end', array($this, 'action_loop_end'), 10, 1);
// Properly switch to blog if necessary
add_action('the_post', array($this, 'action_the_post'), 10, 1);
}