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-friends/bp-friends-functions.php

    r13395 r13433  
    878878    $args = array(
    879879        'tokens' => array(
    880             'friend-requests.url' => esc_url( bp_core_get_user_domain( $friend_id ) . bp_get_friends_slug() . '/requests/' ),
     880            'friend-requests.url' => esc_url(
     881                bp_members_get_user_url(
     882                    $friend_id,
     883                    array(
     884                        'single_item_component' => bp_rewrites_get_slug( 'members', 'member_friends', bp_get_friends_slug() ),
     885                        'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_friends_requests', 'requests' ),
     886                    )
     887                )
     888            ),
    881889            'friend.id'           => $friend_id,
    882890            'friendship.id'       => $friendship_id,
    883891            'initiator.id'        => $initiator_id,
    884             'initiator.url'       => esc_url( bp_core_get_user_domain( $initiator_id ) ),
     892            'initiator.url'       => esc_url( bp_members_get_user_url( $initiator_id ) ),
    885893            'initiator.name'      => bp_core_get_user_displayname( $initiator_id ),
    886894            'unsubscribe'         => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ),
     
    916924        'tokens' => array(
    917925            'friend.id'      => $friend_id,
    918             'friendship.url' => esc_url( bp_core_get_user_domain( $friend_id ) ),
     926            'friendship.url' => esc_url( bp_members_get_user_url( $friend_id ) ),
    919927            'friend.name'    => bp_core_get_user_displayname( $friend_id ),
    920928            'friendship.id'  => $friendship_id,
Note: See TracChangeset for help on using the changeset viewer.