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-core/bp-core-rewrites.php

    r13432 r13433  
    7373 *
    7474 * @param string $component_id The BuddyPress component's ID.
    75  * @param string $rewrite_id   The view rewrite ID.
    76  * @param string $default_slug The view default slug.
     75 * @param string $rewrite_id   The view rewrite ID, used to find the custom slugs.
     76 *                             Eg: `member_profile_edit` will try to find the xProfile edit's slug.
     77 * @param string $default_slug The view default slug, used as a fallback.
    7778 * @return string The slug to use for the view belonging to the requested component.
    7879 */
     
    8485        return $slug;
    8586    }
     87
     88    // Make sure a `bp_` prefix is used.
     89    $rewrite_id = 'bp_' . str_replace( 'bp_', '', sanitize_key( $rewrite_id ) );
    8690
    8791    $custom_slugs = (array) $directory_pages->{$component_id}->custom_slugs;
Note: See TracChangeset for help on using the changeset viewer.