public function delete_item( $request ) {
		$id = (int) $request['id'];
		$force = (bool) $request['force'];

		$post = $this->get_post( $id );

		if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
			return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post id.' ), array( 'status' => 404 ) );
		}

		$supports_trash = ( EMPTY_TRASH_DAYS > 0 );
		if ( 'attachment' === $post->post_type ) {
			$supports_trash = $supports_trash && MEDIA_TRASH;
		}

		/**
		 * Filter whether a post is trashable.
		 *
		 * Return false to disable trash support for the post.
		 *
		 * @param boolean $supports_trash Whether the post type support trashing.
		 * @param WP_Post $post           The Post object being considered for trashing support.
		 */
		$supports_trash = apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post );

		if ( ! $this->check_delete_permission( $post ) ) {
			return new WP_Error( 'rest_user_cannot_delete_post', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		$request->set_param( 'context', 'edit' );
		$response = $this->prepare_item_for_response( $post, $request );

		// If we're forcing, then delete permanently.
		if ( $force ) {
			$result = wp_delete_post( $id, true );
		} else {
			// If we don't support trashing for this type, error out.
			if ( ! $supports_trash ) {
				return new WP_Error( 'rest_trash_not_supported', __( 'The post does not support trashing.' ), array( 'status' => 501 ) );
			}

			// Otherwise, only trash if we haven't already.
			if ( 'trash' === $post->post_status ) {
				return new WP_Error( 'rest_already_trashed', __( 'The post has already been deleted.' ), array( 'status' => 410 ) );
			}

			// (Note that internally this falls through to `wp_delete_post` if
			// the trash is disabled.)
			$result = wp_trash_post( $id );
		}

		if ( ! $result ) {
			return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
		}

		/**
		 * Fires after a single post is deleted or trashed via the REST API.
		 *
		 * @param object           $post     The deleted or trashed post.
		 * @param WP_REST_Response $response The response data.
		 * @param WP_REST_Request  $request  The request sent to the API.
		 */
		do_action( "rest_delete_{$this->post_type}", $post, $response, $request );

		return $response;
	}
public function delete_item( $request ) {
		$id = (int) $request['id'];
		$force = (bool) $request['force'];

		$post = $this->get_post( $id );

		if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
			return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post id.' ), array( 'status' => 404 ) );
		}

		$supports_trash = ( EMPTY_TRASH_DAYS > 0 );
		if ( 'attachment' === $post->post_type ) {
			$supports_trash = $supports_trash && MEDIA_TRASH;
		}

		/**
		 * Filter whether a post is trashable.
		 *
		 * Return false to disable trash support for the post.
		 *
		 * @param boolean $supports_trash Whether the post type support trashing.
		 * @param WP_Post $post           The Post object being considered for trashing support.
		 */
		$supports_trash = apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post );

		if ( ! $this->check_delete_permission( $post ) ) {
			return new WP_Error( 'rest_user_cannot_delete_post', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) );
		}

		$request->set_param( 'context', 'edit' );
		$response = $this->prepare_item_for_response( $post, $request );

		// If we're forcing, then delete permanently.
		if ( $force ) {
			$result = wp_delete_post( $id, true );
		} else {
			// If we don't support trashing for this type, error out.
			if ( ! $supports_trash ) {
				return new WP_Error( 'rest_trash_not_supported', __( 'The post does not support trashing.' ), array( 'status' => 501 ) );
			}

			// Otherwise, only trash if we haven't already.
			if ( 'trash' === $post->post_status ) {
				return new WP_Error( 'rest_already_trashed', __( 'The post has already been deleted.' ), array( 'status' => 410 ) );
			}

			// (Note that internally this falls through to `wp_delete_post` if
			// the trash is disabled.)
			$result = wp_trash_post( $id );
		}

		if ( ! $result ) {
			return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) );
		}

		/**
		 * Fires after a single post is deleted or trashed via the REST API.
		 *
		 * @param object           $post     The deleted or trashed post.
		 * @param WP_REST_Response $response The response data.
		 * @param WP_REST_Request  $request  The request sent to the API.
		 */
		do_action( "rest_delete_{$this->post_type}", $post, $response, $request );

		return $response;
	}
public function delete_item ( $ request ) { $ id = ( int ) $ request [ 'id' ] ; $ force = ( bool ) $ request [ 'force' ] ; $ post = $ this -> get_post ( $ id ) ; if ( empty ( $ id ) || empty ( $ post -> ID ) || $ this -> post_type !== $ post -> post_type ) { return new WP_Error ( 'rest_post_invalid_id' , __ ( 'Invalid post id.' ) , array ( 'status' => 404 ) ) ; } $ supports_trash = ( EMPTY_TRASH_DAYS > 0 ) ; if ( 'attachment' === $ post -> post_type ) { $ supports_trash = $ supports_trash && MEDIA_TRASH ; } /**
		 * Filter whether a post is trashable.
		 *
		 * Return false to disable trash support for the post.
		 *
		 * @param boolean $supports_trash Whether the post type support trashing.
		 * @param WP_Post $post           The Post object being considered for trashing support.
		 */ $ supports_trash = apply_filters ( "rest_{$this->post_type}_trashable" , $ supports_trash , $ post ) ; if ( ! $ this -> check_delete_permission ( $ post ) ) { return new WP_Error ( 'rest_user_cannot_delete_post' , __ ( 'Sorry, you are not allowed to delete this post.' ) , array ( 'status' => rest_authorization_required_code ( ) ) ) ; } $ request -> set_param ( 'context' , 'edit' ) ; $ response = $ this -> prepare_item_for_response ( $ post , $ request ) ; // If we're forcing, then delete permanently. if ( $ force ) { $ result = wp_delete_post ( $ id , true ) ; } else { // If we don't support trashing for this type, error out. if ( ! $ supports_trash ) { return new WP_Error ( 'rest_trash_not_supported' , __ ( 'The post does not support trashing.' ) , array ( 'status' => 501 ) ) ; } // Otherwise, only trash if we haven't already. if ( 'trash' === $ post -> post_status ) { return new WP_Error ( 'rest_already_trashed' , __ ( 'The post has already been deleted.' ) , array ( 'status' => 410 ) ) ; } // (Note that internally this falls through to `wp_delete_post` if // the trash is disabled.) $ result = wp_trash_post ( $ id ) ; } if ( ! $ result ) { return new WP_Error ( 'rest_cannot_delete' , __ ( 'The post cannot be deleted.' ) , array ( 'status' => 500 ) ) ; } /**
		 * Fires after a single post is deleted or trashed via the REST API.
		 *
		 * @param object           $post     The deleted or trashed post.
		 * @param WP_REST_Response $response The response data.
		 * @param WP_REST_Request  $request  The request sent to the API.
		 */ do_action ( "rest_delete_{$this->post_type}" , $ post , $ response , $ request ) ; return $ response ; }
Delete a single post.

@param WP_REST_Request $request Full details about the request.
@return WP_REST_Response|WP_Error
Delete a single post .