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

WC_REST_Product_Reviews_Controller::prepare_item_for_response() public WC 1.0

Prepare a single product review output for response.

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

Хуки из метода
Возвращает

WP_REST_Response. $response Response data.

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

$WC_REST_Product_Reviews_Controller = new WC_REST_Product_Reviews_Controller();
$WC_REST_Product_Reviews_Controller->prepare_item_for_response( $review, $request );
$review(WP_Comment) (обязательный)
Product review object.
$request(WP_REST_Request) (обязательный)
Request object.

Код WC_REST_Product_Reviews_Controller::prepare_item_for_response() WC 5.2.2

<?php
public function prepare_item_for_response( $review, $request ) {
	$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
	$fields  = $this->get_fields_for_response( $request );
	$data    = array();

	if ( in_array( 'id', $fields, true ) ) {
		$data['id'] = (int) $review->comment_ID;
	}
	if ( in_array( 'date_created', $fields, true ) ) {
		$data['date_created'] = wc_rest_prepare_date_response( $review->comment_date );
	}
	if ( in_array( 'date_created_gmt', $fields, true ) ) {
		$data['date_created_gmt'] = wc_rest_prepare_date_response( $review->comment_date_gmt );
	}
	if ( in_array( 'product_id', $fields, true ) ) {
		$data['product_id'] = (int) $review->comment_post_ID;
	}
	if ( in_array( 'status', $fields, true ) ) {
		$data['status'] = $this->prepare_status_response( (string) $review->comment_approved );
	}
	if ( in_array( 'reviewer', $fields, true ) ) {
		$data['reviewer'] = $review->comment_author;
	}
	if ( in_array( 'reviewer_email', $fields, true ) ) {
		$data['reviewer_email'] = $review->comment_author_email;
	}
	if ( in_array( 'review', $fields, true ) ) {
		$data['review'] = 'view' === $context ? wpautop( $review->comment_content ) : $review->comment_content;
	}
	if ( in_array( 'rating', $fields, true ) ) {
		$data['rating'] = (int) get_comment_meta( $review->comment_ID, 'rating', true );
	}
	if ( in_array( 'verified', $fields, true ) ) {
		$data['verified'] = wc_review_is_from_verified_owner( $review->comment_ID );
	}
	if ( in_array( 'reviewer_avatar_urls', $fields, true ) ) {
		$data['reviewer_avatar_urls'] = rest_get_avatar_urls( $review->comment_author_email );
	}

	$data = $this->add_additional_fields_to_object( $data, $request );
	$data = $this->filter_response_by_context( $data, $context );

	// Wrap the data in a response object.
	$response = rest_ensure_response( $data );

	$response->add_links( $this->prepare_links( $review ) );

	/**
	 * Filter product reviews object returned from the REST API.
	 *
	 * @param WP_REST_Response $response The response object.
	 * @param WP_Comment       $review   Product review object used to create response.
	 * @param WP_REST_Request  $request  Request object.
	 */
	return apply_filters( 'woocommerce_rest_prepare_product_review', $response, $review, $request );
}