rest_prepare_status filter-hookWP 4.7.0

Filters a post status returned from the REST API.

Allows modification of the status data right before it is returned.

Usage

add_filter( 'rest_prepare_status', 'wp_kama_rest_prepare_status_filter', 10, 3 );

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

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

Changelog

Since 4.7.0 Introduced.

Where the hook is called

WP_REST_Post_Statuses_Controller::prepare_item_for_response()
rest_prepare_status
wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php 285
return apply_filters( 'rest_prepare_status', $response, $status, $request );

Where the hook is used in WordPress

Usage not found.