create_post_autosave example

$post_lock = wp_check_post_lock( $post->ID );
        $is_draft  = 'draft' === $post->post_status || 'auto-draft' === $post->post_status;

        if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock ) {
            /* * Draft posts for the same author: autosaving updates the post and does not create a revision. * Convert the post object to an array and add slashes, wp_update_post() expects escaped array. */
            $autosave_id = wp_update_post( wp_slash( (array) $prepared_post ), true );
        } else {
            // Non-draft posts: create or update the post autosave.             $autosave_id = $this->create_post_autosave( (array) $prepared_post );
        }

        if ( is_wp_error( $autosave_id ) ) {
            return $autosave_id;
        }

        $autosave = get_post( $autosave_id );
        $request->set_param( 'context', 'edit' );

        $response = $this->prepare_item_for_response( $autosave$request );
        $response = rest_ensure_response( $response );

        
Home | Imprint | This part of the site doesn't use cookies.