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

WC_REST_Product_Reviews_V1_Controller::prepare_item_for_database() protected WC 1.0

Prepare a single product review to be inserted into the database.

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

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

Массив/WP_Error. $prepared_review

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->prepare_item_for_database( $request );
$request(WP_REST_Request) (обязательный)
Request object.

Код WC_REST_Product_Reviews_V1_Controller::prepare_item_for_database() WC 4.7.0

<?php
protected function prepare_item_for_database( $request ) {
	$prepared_review = array( 'comment_approved' => 1, 'comment_type' => 'review' );

	if ( isset( $request['id'] ) ) {
		$prepared_review['comment_ID'] = (int) $request['id'];
	}

	if ( isset( $request['review'] ) ) {
		$prepared_review['comment_content'] = $request['review'];
	}

	if ( isset( $request['product_id'] ) ) {
		$prepared_review['comment_post_ID'] = (int) $request['product_id'];
	}

	if ( isset( $request['name'] ) ) {
		$prepared_review['comment_author'] = $request['name'];
	}

	if ( isset( $request['email'] ) ) {
		$prepared_review['comment_author_email'] = $request['email'];
	}

	if ( isset( $request['date_created'] ) ) {
		$prepared_review['comment_date'] = $request['date_created'];
	}

	if ( isset( $request['date_created_gmt'] ) ) {
		$prepared_review['comment_date_gmt'] = $request['date_created_gmt'];
	}

	return apply_filters( 'rest_preprocess_product_review', $prepared_review, $request );
}