BP_REST_Activity_Endpoint::prepare_links( BP_Activity_Activity $activity )
Prepare links for the request.
Description
Parameters
- $activity
-
(Required) Activity object.
Return
(array)
Source
File: bp-activity/classes/class-bp-rest-activity-endpoint.php
protected function prepare_links( $activity ) { $base = sprintf( '/%s/%s/', $this->namespace, $this->rest_base ); $url = $base . $activity->id; // Entity meta. $links = array( 'self' => array( 'href' => rest_url( $url ), ), 'collection' => array( 'href' => rest_url( $base ), ), 'user' => array( 'href' => rest_url( bp_rest_get_user_url( $activity->user_id ) ), 'embeddable' => true, ), ); if ( 'activity_comment' === $activity->type ) { $links['up'] = array( 'href' => rest_url( $url ), ); } if ( bp_activity_can_favorite() ) { $links['favorite'] = array( 'href' => rest_url( $url . '/favorite' ), ); } if ( bp_is_active( 'groups' ) && 'groups' === $activity->component && ! empty( $activity->item_id ) ) { $group = groups_get_group( $activity->item_id ); $links['group'] = array( 'href' => bp_get_group_permalink( $group ), 'embeddable' => true, ); } /** * Filter links prepared for the REST response. * * @param array $links The prepared links of the REST response. * @param BP_Activity_Activity $activity Activity object. * * @since 0.1.0 */ return apply_filters( 'bp_rest_activity_prepare_links', $links, $activity ); }
Changelog
Version | Description |
---|---|
0.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.