EP_API::index_post PHP Method

index_post() public method

Index a post under a given site index or the global index ($site_id = 0)
Since: 0.1.0
public index_post ( array $post, boolean $blocking = true ) : array | boolean | mixed
$post array
$blocking boolean
return array | boolean | mixed
    public function index_post($post, $blocking = true)
    {
        /**
         * Filter post prior to indexing
         *
         * Allows for last minute indexing of post information.
         *
         * @since 1.7
         *
         * @param         array Array of post information to index.
         */
        $post = apply_filters('ep_pre_index_post', $post);
        $index = trailingslashit(ep_get_index_name());
        $path = $index . 'post/' . $post['post_id'];
        if (function_exists('wp_json_encode')) {
            $encoded_post = wp_json_encode($post);
        } else {
            $encoded_post = json_encode($post);
        }
        $request_args = array('body' => $encoded_post, 'method' => 'PUT', 'timeout' => 15, 'blocking' => $blocking);
        $request = ep_remote_request($path, apply_filters('ep_index_post_request_args', $request_args, $post));
        do_action('ep_index_post_retrieve_raw_response', $request, $post, $path);
        if (!is_wp_error($request)) {
            $response_body = wp_remote_retrieve_body($request);
            return json_decode($response_body);
        }
        return false;
    }