BP_REST_Document_Endpoint::prepare_links( BP_Document $document )
Prepare links for the request.
Description
Parameters
- $document
-
(Required) Document data.
Return
(array)
Source
File: bp-document/classes/class-bp-rest-document-endpoint.php
1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 | protected function prepare_links( $document ) { $base = sprintf( '/%s/%s/' , $this -> namespace , ( empty ( $document ->attachment_id ) ? 'document/folder' : $this ->rest_base ) ); $url = $base . $document ->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( $document ->user_id ) ), 'embeddable' => true, ), ); if ( ! empty ( $document ->activity_id ) && bp_is_active( 'activity' ) ) { $activity_base = sprintf( '/%s/%s/' , $this -> namespace , buddypress()->activity->id ); $activity_url = $activity_base . $document ->activity_id; $links [ 'activity' ] = array ( 'href' => rest_url( $activity_url ), 'embeddable' => true, ); } /** * Filter links prepared for the REST response. * * @since 0.1.0 * * @param array $links The prepared links of the REST response. * @param BP_Document $document Document data. */ return apply_filters( 'bp_rest_document_prepare_links' , $links , $document ); } |
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.