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/tests/phpunit/testcases/core/nav/bpCoreNewNavItem.php

    r11737 r13433  
    55 */
    66class BP_Tests_Core_Nav_BpCoreNewNavItem extends BP_UnitTestCase {
     7    protected $permalink_structure = '';
     8
     9    public function set_up() {
     10        parent::set_up();
     11        $this->permalink_structure = get_option( 'permalink_structure', '' );
     12    }
     13
     14    public function tear_down() {
     15        $this->set_permalink_structure( $this->permalink_structure );
     16
     17        parent::tear_down();
     18    }
    719
    820    /**
     
    1527        $old_current_user = get_current_user_id();
    1628        $this->set_current_user( $u );
    17 
    18         $this->go_to( bp_core_get_user_domain( $u ) );
     29        $this->set_permalink_structure( '/%postname%/' );
     30
     31        $this->go_to( bp_members_get_user_url( $u ) );
    1932
    2033        bp_core_new_nav_item( array(
     
    2942            'name'                    => 'Foo',
    3043            'slug'                    => 'foo',
    31             'link'                    => trailingslashit( bp_core_get_user_domain( $u ) . 'foo' ),
     44            'link'                    => bp_members_get_user_url(
     45                $u,
     46                array(
     47                    'single_item_component' => 'foo',
     48                )
     49            ),
    3250            'css_id'                  => 'foo',
    3351            'show_for_displayed_user' => true,
     
    147165        $old_current_user = get_current_user_id();
    148166        $this->set_current_user( $u2 );
    149 
    150         $this->go_to( bp_core_get_user_domain( $u ) );
     167        $this->set_permalink_structure( '/%postname%/' );
     168
     169        $this->go_to( bp_members_get_user_url( $u ) );
    151170
    152171        $expected = array(
     
    182201        $old_current_user = get_current_user_id();
    183202        $this->set_current_user( $u2 );
    184 
    185         $this->go_to( bp_core_get_user_domain( $u ) );
     203        $this->set_permalink_structure( '/%postname%/' );
     204
     205        $this->go_to( bp_members_get_user_url( $u ) );
    186206
    187207        bp_core_new_nav_item( array(
Note: See TracChangeset for help on using the changeset viewer.