Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/02/2021 01:47:57 AM (3 years ago)
Author:
espellcaste
Message:

Introducing a new helper function bp_rest_get_object_url, used to grab a REST API endpoint url from a specific component.

We are also deprecating the legacy version bp_rest_get_user_url

Props imath

Fixes #8490

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-rest-api.php

    r12745 r12985  
    136136
    137137/**
    138  * Get user URL.
    139  *
    140  * @since 5.0.0
    141  *
    142  * @param  int $user_id User ID.
     138 * Get a REST API object URL from a component.
     139 *
     140 * @since 9.0.0
     141 *
     142 * @param integer $object_id   Object ID.
     143 * @param string  $object_path Path of the component endpoint.
    143144 * @return string
    144145 */
    145 function bp_rest_get_user_url( $user_id ) {
    146     return sprintf(
    147         '/%s/%s/members/%d',
    148         bp_rest_namespace(),
    149         bp_rest_version(),
    150         $user_id
     146function bp_rest_get_object_url( $object_id, $object_path ) {
     147    return rest_url(
     148        sprintf(
     149            '/%1$s/%2$s/%3$s/%4$d',
     150            bp_rest_namespace(),
     151            bp_rest_version(),
     152            $object_path,
     153            $object_id
     154        )
    151155    );
    152156}
Note: See TracChangeset for help on using the changeset viewer.