EP_Sync_Manager::action_queue_meta_sync PHP Method

action_queue_meta_sync() public method

When whitelisted meta is updated, queue the post for reindex
Since: 2.0
public action_queue_meta_sync ( integer $meta_id, integer $object_id, string $meta_key, string $meta_value )
$meta_id integer
$object_id integer
$meta_key string
$meta_value string
    public function action_queue_meta_sync($meta_id, $object_id, $meta_key, $meta_value)
    {
        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($object_id);
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || 'revision' === $post_type) {
            // Bypass saving if doing autosave or post type is revision
            return;
        }
        $post = get_post($object_id);
        // If the post is an auto-draft - let's abort.
        if ('auto-draft' == $post->post_status) {
            return;
        }
        if (in_array($post->post_status, $indexable_post_statuses)) {
            $indexable_post_types = ep_get_indexable_post_types();
            if (in_array($post_type, $indexable_post_types)) {
                // Using this function to hook in after all the meta applicable filters
                $prepared_post = ep_prepare_post($object_id);
                // Make sure meta key that was changed is actually relevant
                if (!isset($prepared_post['meta'][$meta_key])) {
                    return;
                }
                $this->sync_post_queue[$object_id] = true;
            }
        }
    }