EP_WP_Query_Integration::action_the_post PHP Method

action_the_post() public method

Switch to the correct site if the post site id is different than the actual one
Since: 0.9
public action_the_post ( array $post )
$post array
    public function action_the_post($post)
    {
        if (!is_multisite()) {
            return;
        }
        if (empty($this->query_stack)) {
            return;
        }
        if (!ep_elasticpress_enabled($this->query_stack[0]) || apply_filters('ep_skip_query_integration', false, $this->query_stack[0])) {
            return;
        }
        if (!empty($post->site_id) && get_current_blog_id() != $post->site_id) {
            restore_current_blog();
            switch_to_blog($post->site_id);
            remove_action('the_post', array($this, 'action_the_post'), 10, 1);
            setup_postdata($post);
            add_action('the_post', array($this, 'action_the_post'), 10, 1);
        }
    }