/**
  * Checks to see if we should be integrating and if so, sets up the appropriate actions and filters.
  * @since 0.9
  */
 public function setup()
 {
     // Ensure we aren't on the admin (unless overridden)
     if (is_admin() && !apply_filters('ep_admin_wp_query_integration', false)) {
         return;
     }
     // Ensure that we are currently allowing ElasticPress to override the normal WP_Query search
     if (!ep_is_activated()) {
         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);
     // Search 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);
     // Check the cache before performing an ES search
     add_filter('ep_pre_wp_query_search', array($this, 'filter_check_query_cache'), 10, 2);
     // Store search results in the cache
     add_action('ep_wp_query_search', array($this, 'action_cache_query_results'), 10, 3);
 }
 /**
  * Checks to see if we should be integrating and if so, sets up the appropriate actions and filters.
  * @since 0.9
  */
 public function setup()
 {
     $do_show_rp = get_site_option(namespace\SHOW_RELATED_POSTS_FIELD, false);
     if (!$do_show_rp) {
         return;
     }
     if (!ep_is_activated()) {
         return;
     }
     add_filter('the_content', [$this, 'filter_related_posts_after_content'], 10, 1);
 }
 /**
  * Checks to see if we should be integrating and if so, sets up the appropriate actions and filters.
  * @since 0.9
  */
 public function setup()
 {
     /**
      * By default EP will not integrate on admin or ajax requests. Since admin-ajax.php is
      * technically an admin request, there is some weird logic here. If we are doing ajax
      * and ep_ajax_wp_query_integration is filtered true, then we skip the next admin check.
      */
     $admin_integration = apply_filters('ep_admin_wp_query_integration', false);
     if (defined('DOING_AJAX') && DOING_AJAX) {
         if (!apply_filters('ep_ajax_wp_query_integration', false)) {
             return;
         } else {
             $admin_integration = true;
         }
     }
     if (is_admin() && !$admin_integration) {
         return;
     }
     // Ensure that we are currently allowing ElasticPress to override the normal WP_Query search
     if (!ep_is_activated()) {
         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);
     // Search 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);
 }
Пример #4
0
 /**
  * Return current status of ElasticPress
  *
  * @subcommand is-active
  *
  * @since 0.9.3
  */
 public function is_activated()
 {
     $this->_connect_check();
     $active = ep_is_activated();
     if ($active) {
         WP_CLI::log('ElasticPress is currently activated.');
     } else {
         WP_CLI::log('ElasticPress is currently deactivated.');
     }
 }