rest_prepare_revision filter-hookWP 4.7.0

Filters a revision returned from the REST API.

Allows modification of the revision right before it is returned.

Usage

add_filter( 'rest_prepare_revision', 'wp_kama_rest_prepare_revision_filter', 10, 3 );

/**
 * Function for `rest_prepare_revision` filter-hook.
 * 
 * @param WP_REST_Response $response The response object.
 * @param WP_Post          $post     The original revision object.
 * @param WP_REST_Request  $request  Request used to generate the response.
 *
 * @return WP_REST_Response
 */
function wp_kama_rest_prepare_revision_filter( $response, $post, $request ){

	// filter...
	return $response;
}
$response(WP_REST_Response)
The response object.
$post(WP_Post)
The original revision object.
$request(WP_REST_Request)
Request used to generate the response.

Changelog

Since 4.7.0 Introduced.

Where the hook is called

WP_REST_Revisions_Controller::prepare_item_for_response()
rest_prepare_revision
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php 667
return apply_filters( 'rest_prepare_revision', $response, $post, $request );

Where the hook is used in WordPress

Usage not found.