WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

WC_REST_Product_Reviews_V1_Controller::delete_item() public WC 1.0

Delete a product review.

{} Это метод класса: WC_REST_Product_Reviews_V1_Controller{}

Возвращает

true/false/WP_Error/WP_REST_Response.

Использование

$WC_REST_Product_Reviews_V1_Controller = new WC_REST_Product_Reviews_V1_Controller();
$WC_REST_Product_Reviews_V1_Controller->delete_item( $request );
$request(WP_REST_Request) (обязательный)
Full details about the request

Код WC_REST_Product_Reviews_V1_Controller::delete_item() WC 4.7.1

<?php
public function delete_item( $request ) {
	$product_review_id = absint( is_array( $request['id'] ) ? $request['id']['id'] : $request['id'] );
	$force             = isset( $request['force'] ) ? (bool) $request['force']     : false;

	$product_review = get_comment( $product_review_id );
	if ( empty( $product_review_id ) || empty( $product_review->comment_ID ) || empty( $product_review->comment_post_ID ) ) {
		return new WP_Error( 'woocommerce_rest_product_review_invalid_id', __( 'Invalid product review ID.', 'woocommerce' ), array( 'status' => 404 ) );
	}

	/**
	 * Filter whether a product review is trashable.
	 *
	 * Return false to disable trash support for the product review.
	 *
	 * @param boolean $supports_trash        Whether the object supports trashing.
	 * @param WP_Post $product_review        The object being considered for trashing support.
	 */
	$supports_trash = apply_filters( 'rest_product_review_trashable', ( EMPTY_TRASH_DAYS > 0 ), $product_review );

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

	if ( $force ) {
		$result = wp_delete_comment( $product_review_id, true );
	} else {
		if ( ! $supports_trash ) {
			return new WP_Error( 'rest_trash_not_supported', __( 'The product review does not support trashing.', 'woocommerce' ), array( 'status' => 501 ) );
		}

		if ( 'trash' === $product_review->comment_approved ) {
			return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.', 'woocommerce' ), array( 'status' => 410 ) );
		}

		$result = wp_trash_comment( $product_review->comment_ID );
	}

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

	/**
	 * Fires after a product review is deleted via the REST API.
	 *
	 * @param object           $product_review  The deleted item.
	 * @param WP_REST_Response $response        The response data.
	 * @param WP_REST_Request  $request         The request sent to the API.
	 */
	do_action( 'rest_delete_product_review', $product_review, $response, $request );

	return $response;
}