Skip to:
Content

BuddyPress.org

Changeset 12985


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

Location:
trunk/src
Files:
2 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}
  • trunk/src/class-buddypress.php

    r12974 r12985  
    513513            require( $this->plugin_dir . 'bp-core/deprecated/7.0.php' );
    514514            require( $this->plugin_dir . 'bp-core/deprecated/8.0.php' );
     515            require( $this->plugin_dir . 'bp-core/deprecated/9.0.php' );
    515516        }
    516517
Note: See TracChangeset for help on using the changeset viewer.