$data =
$this->
add_additional_fields_to_object( $data,
$request );
$data =
$this->
filter_response_by_context( $data,
$context );
// Wrap the data in a response object.
$response =
rest_ensure_response( $data );
if ( rest_is_field_included( '_links',
$fields ) ||
rest_is_field_included( '_embedded',
$fields ) ) { $links =
$this->
prepare_links( $post );
$response->
add_links( $links );
if ( !
empty( $links['self'
]['href'
] ) ) { $actions =
$this->
get_available_actions( $post,
$request );
$self =
$links['self'
]['href'
];
foreach ( $actions as $rel ) { $response->
add_link( $rel,
$self );
} } } /**
* Filters the post data for a REST API response.
*
* The dynamic portion of the hook name, `$this->post_type`, refers to the post type slug.
*
* Possible hook names include:
*
* - `rest_prepare_post`
* - `rest_prepare_page`
* - `rest_prepare_attachment`
*
* @since 4.7.0
*
* @param WP_REST_Response $response The response object.
* @param WP_Post $post Post object.
* @param WP_REST_Request $request Request object.
*/