WP_REST_Font_Faces_Controller::prepare_item_for_response()
Prepares a single font face output for response.
Method of the class: WP_REST_Font_Faces_Controller{}
Hooks from the method
Return
WP_REST_Response
. Response object.
Usage
$WP_REST_Font_Faces_Controller = new WP_REST_Font_Faces_Controller(); $WP_REST_Font_Faces_Controller->prepare_item_for_response( $item, $request );
- $item(WP_Post) (required)
- Post object.
- $request(WP_REST_Request) (required)
- Request object.
Changelog
Since 6.5.0 | Introduced. |
WP_REST_Font_Faces_Controller::prepare_item_for_response() WP REST Font Faces Controller::prepare item for response code WP 6.6.2
public function prepare_item_for_response( $item, $request ) { $fields = $this->get_fields_for_response( $request ); $data = array(); if ( rest_is_field_included( 'id', $fields ) ) { $data['id'] = $item->ID; } if ( rest_is_field_included( 'theme_json_version', $fields ) ) { $data['theme_json_version'] = static::LATEST_THEME_JSON_VERSION_SUPPORTED; } if ( rest_is_field_included( 'parent', $fields ) ) { $data['parent'] = $item->post_parent; } if ( rest_is_field_included( 'font_face_settings', $fields ) ) { $data['font_face_settings'] = $this->get_settings_from_post( $item ); } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); if ( rest_is_field_included( '_links', $fields ) || rest_is_field_included( '_embedded', $fields ) ) { $links = $this->prepare_links( $item ); $response->add_links( $links ); } /** * Filters the font face data for a REST API response. * * @since 6.5.0 * * @param WP_REST_Response $response The response object. * @param WP_Post $post Font face post object. * @param WP_REST_Request $request Request object. */ return apply_filters( 'rest_prepare_wp_font_face', $response, $item, $request ); }