EP_Sync_Manager::action_sync_on_update PHP 메소드

action_sync_on_update() 공개 메소드

Sync ES index with what happened to the post being saved
부터: 0.1.0
public action_sync_on_update ( $post_ID )
$post_ID
    public function action_sync_on_update($post_ID)
    {
        global $importer;
        // If we have an importer we must be doing an import - let's abort
        if (!empty($importer)) {
            return;
        }
        $indexable_post_statuses = ep_get_indexable_post_status();
        $post_type = get_post_type($post_ID);
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || 'revision' === $post_type) {
            // Bypass saving if doing autosave or post type is revision
            return;
        }
        if (!apply_filters('ep_sync_insert_permissions_bypass', false, $post_ID)) {
            if (!current_user_can('edit_post', $post_ID) && (!defined('DOING_CRON') || !DOING_CRON)) {
                // Bypass saving if user does not have access to edit post and we're not in a cron process
                return;
            }
        }
        $post = get_post($post_ID);
        // If the post is an auto-draft - let's abort.
        if ('auto-draft' == $post->post_status) {
            return;
        }
        // Our post was published, but is no longer, so let's remove it from the Elasticsearch index
        if (!in_array($post->post_status, $indexable_post_statuses)) {
            $this->action_delete_post($post_ID);
        } else {
            $post_type = get_post_type($post_ID);
            $indexable_post_types = ep_get_indexable_post_types();
            if (in_array($post_type, $indexable_post_types)) {
                do_action('ep_sync_on_transition', $post_ID);
                $this->sync_post($post_ID, false);
            }
        }
    }