handle_status_param example

$comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) );

        if ( ! $comment_id ) {
            return new WP_Error(
                'rest_comment_failed_create',
                __( 'Creating comment failed.' ),
                array( 'status' => 500 )
            );
        }

        if ( isset( $request['status'] ) ) {
            $this->handle_status_param( $request['status']$comment_id );
        }

        $comment = get_comment( $comment_id );

        /** * Fires after a comment is created or updated via the REST API. * * @since 4.7.0 * * @param WP_Comment $comment Inserted or updated comment object. * @param WP_REST_Request $request Request object. * @param bool $creating True when creating a comment, false * when updating. */
            $prepared_post->post_type = get_post_type( $request['id'] );
        }

        $post_type = get_post_type_object( $prepared_post->post_type );

        // Post status.         if (
            ! empty( $schema['properties']['status'] ) &&
            isset( $request['status'] ) &&
            ( ! $current_status || $current_status !== $request['status'] )
        ) {
            $status = $this->handle_status_param( $request['status']$post_type );

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

            $prepared_post->post_status = $status;
        }

        // Post date.         if ( ! empty( $schema['properties']['date'] ) && ! empty( $request['date'] ) ) {
            $current_date = isset( $prepared_post->ID ) ? get_post( $prepared_post->ID )->post_date : false;
            
Home | Imprint | This part of the site doesn't use cookies.