rest_pre_insert_product_review хук-фильтрWC 1.0

Filter a product review (comment) before it is inserted via the REST API.

Allows modification of the comment right before it is inserted via wp_insert_comment.

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

add_filter( 'rest_pre_insert_product_review', 'wp_kama_rest_pre_insert_product_review_filter', 10, 2 );

/**
 * Function for `rest_pre_insert_product_review` filter-hook.
 * 
 * @param array           $prepared_review The prepared comment data for `wp_insert_comment`.
 * @param WP_REST_Request $request         Request used to insert the comment.
 *
 * @return array
 */
function wp_kama_rest_pre_insert_product_review_filter( $prepared_review, $request ){

	// filter...
	return $prepared_review;
}
$prepared_review(массив)
The prepared comment data for wp_insert_comment.
$request(WP_REST_Request)
Request used to insert the comment.

Где вызывается хук

WC_REST_Product_Reviews_V1_Controller::create_item()
rest_pre_insert_product_review
woocommerce/includes/rest-api/Controllers/Version1/class-wc-rest-product-reviews-v1-controller.php 300
$prepared_review = apply_filters( 'rest_pre_insert_product_review', $prepared_review, $request );

Где используется хук в WooCommerce

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