BP_REST_Notifications_Endpoint::prepare_links( BP_Notifications_Notification $notification )

Prepare links for the request.

Description

Parameters

$notification

(Required) Notification item.

Return

(array) Links for the given plugin.

Source

File: bp-notifications/classes/class-bp-rest-notifications-endpoint.php

764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
protected function prepare_links( $notification ) {
    $base = sprintf( '/%s/%s/', $this->namespace, $this->rest_base );
 
    // Entity meta.
    $links = array(
        'self'       => array(
            'href' => rest_url( $base . $notification->id ),
        ),
        'collection' => array(
            'href' => rest_url( $base ),
        ),
        'user'       => array(
            'href'       => rest_url( bp_rest_get_user_url( $notification->user_id ) ),
            'embeddable' => true,
        ),
    );
 
    /**
     * Filter links prepared for the REST response.
     *
     * @param array                         $links        The prepared links of the REST response.
     * @param BP_Notifications_Notification $notification Notification object.
     *
     * @since 0.1.0
     */
    return apply_filters( 'bp_rest_notifications_prepare_links', $links, $notification );
}

Changelog

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.