Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/07/2023 04:28:08 AM (14 months ago)
Author:
imath
Message:

BP Rewrites: Introduce the bp_members_get_user_url() function

As many member URLs are built concatenating bp_core_get_user_domain()
with URL chunks, the safer way to make sure developers update the way they
build their member URLs in favor of using BP Rewrites is:

  1. to deprecate this function
  2. create a new function bp_members_get_user_url() which is a wrapper of

bp_rewrites_get_url()

  1. replace all bp_core_get_user_domain() occurrences by

bp_members_get_user_url()

This commit also deprecates bp_core_get_username() in favor of the new
bp_members_get_user_slug() function and updates PHPUnit tests.

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/70
See #4954

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/screens/permalink.php

    r12527 r13433  
    3636
    3737    // Do not redirect at default.
    38     $redirect = false;
     38    $redirect    = false;
     39    $path_chunks = array(
     40        'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     41        'single_item_action'    => $activity->id,
     42    );
    3943
    4044    // Redirect based on the type of activity.
     
    4347        // Activity is a user update.
    4448        if ( ! empty( $activity->user_id ) ) {
    45             $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
     49            $redirect = bp_members_get_user_url( $activity->user_id, $path_chunks );
    4650
    4751        // Activity is something else.
     
    5660    // Set redirect to users' activity stream.
    5761    } elseif ( ! empty( $activity->user_id ) ) {
    58         $redirect = bp_core_get_user_domain( $activity->user_id, $activity->user_nicename, $activity->user_login ) . bp_get_activity_slug() . '/' . $activity->id . '/';
     62        $redirect = bp_members_get_user_url( $activity->user_id, $path_chunks );
    5963    }
    6064
Note: See TracChangeset for help on using the changeset viewer.