rest_preprocess_comment хук-фильтрWP 4.7.0

Filters a comment added via the REST API after it is prepared for insertion into the database.

Allows modification of the comment right after it is prepared for the database.

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

add_filter( 'rest_preprocess_comment', 'wp_kama_rest_preprocess_comment_filter', 10, 2 );

/**
 * Function for `rest_preprocess_comment` filter-hook.
 * 
 * @param array           $prepared_comment The prepared comment data for `wp_insert_comment`.
 * @param WP_REST_Request $request          The current request.
 *
 * @return array
 */
function wp_kama_rest_preprocess_comment_filter( $prepared_comment, $request ){

	// filter...
	return $prepared_comment;
}
$prepared_comment(массив)
The prepared comment data for wp_insert_comment.
$request(WP_REST_Request)
The current request.

Список изменений

С версии 4.7.0 Введена.

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

WP_REST_Comments_Controller::prepare_item_for_database()
rest_preprocess_comment
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 1372
return apply_filters( 'rest_preprocess_comment', $prepared_comment, $request );

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

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