BP_REST_Forums_Endpoint::prepare_links( WP_Post $post )

Prepare links for the request.

Description

Parameters

$post

(Required) Post object.

Return

(array)

Source

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

1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
protected function prepare_links( $post ) {
    $base = sprintf( '/%s/%s/', $this->namespace, $this->rest_base );
 
    // Entity meta.
    $links = array(
        'self'       => array(
            'href' => rest_url( $base . $post->ID ),
        ),
        'collection' => array(
            'href' => rest_url( $base ),
        ),
        'user'       => array(
            'href'       => rest_url( bp_rest_get_user_url( $post->post_author ) ),
            'embeddable' => true,
        ),
    );
 
    /**
     * Filter links prepared for the REST response.
     *
     * @param array   $links The prepared links of the REST response.
     * @param WP_Post $post  Post object.
     *
     * @since 0.1.0
     */
    return apply_filters( 'bp_rest_forum_prepare_links', $links, $post );
}

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.