BP_REST_Media_Endpoint::prepare_links( BP_Media $media )
Prepare links for the request.
Description
Parameters
- $media
-
(Required) Media data.
Return
(array)
Source
File: bp-media/classes/class-bp-rest-media-endpoint.php
1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 | protected function prepare_links( $media ) { $base = sprintf( '/%s/%s/' , $this -> namespace , $this ->rest_base ); $url = $base . $media ->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( $media ->user_id ) ), 'embeddable' => true, ), ); if ( ! empty ( $media ->activity_id ) && bp_is_active( 'activity' ) ) { $activity_base = sprintf( '/%s/%s/' , $this -> namespace , buddypress()->activity->id ); $activity_url = $activity_base . $media ->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_Media $media Media data. */ return apply_filters( 'bp_rest_media_prepare_links' , $links , $media ); } |
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.