BP_REST_Messages_Endpoint::prepare_links( BP_Messages_Thread $thread )
Prepare links for the request.
Description
Parameters
- $thread
-
(Required) Thread object.
Return
(array) Links for the given thread.
Source
File: bp-messages/classes/class-bp-rest-messages-endpoint.php
protected function prepare_links( $thread ) { $base = sprintf( '/%s/%s/', $this->namespace, $this->rest_base ); // Entity meta. $links = array( 'self' => array( 'href' => rest_url( $base . $thread->thread_id ), ), 'collection' => array( 'href' => rest_url( $base ), ), ); // Add star links for each message of the thread. if ( bp_is_active( 'messages', 'star' ) ) { $starred_base = $base . bp_get_messages_starred_slug() . '/'; foreach ( $thread->messages as $message ) { $links[ $message->id ] = array( 'href' => rest_url( $starred_base . $message->id ), ); } } /** * Filter links prepared for the REST response. * * @param array $links The prepared links of the REST response. * @param BP_Messages_Thread $thread Thread object. * * @since 0.1.0 */ return apply_filters( 'bp_rest_messages_prepare_links', $links, $thread ); }
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.