BP_REST_Notifications_Endpoint::prepare_item_for_response( BP_Notifications_Notification $notification, WP_REST_Request $request )
Prepares notification data to return as an object.
Description Description
Parameters Parameters
- $notification
-
(Required) Notification data.
- $request
-
(Required) Full details about the request.
Return Return
(WP_REST_Response)
Source Source
File: bp-notifications/classes/class-bp-rest-notifications-endpoint.php
public function prepare_item_for_response( $notification, $request ) { $data = array( 'id' => $notification->id, 'user_id' => $notification->user_id, 'item_id' => $notification->item_id, 'secondary_item_id' => $notification->secondary_item_id, 'component' => $notification->component_name, 'action' => $notification->component_action, 'date' => bp_rest_prepare_date_response( $notification->date_notified ), 'is_new' => $notification->is_new, ); $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $data = $this->add_additional_fields_to_object( $data, $request ); $data = $this->filter_response_by_context( $data, $context ); // @todo add prepare_links $response = rest_ensure_response( $data ); /** * Filter a notification value returned from the API. * * @since 5.0.0 * * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request Request used to generate the response. * @param BP_Notifications_Notification $notification Notification object. */ return apply_filters( 'bp_rest_notifications_prepare_value', $response, $request, $notification ); }
Changelog Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |