Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/07/2023 04:28:08 AM (21 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/class-bp-button.php

    r13314 r13433  
    66 */
    77class BP_Tests_BP_Button extends BP_UnitTestCase {
     8    protected $permalink_structure = '';
     9
     10    public function set_up() {
     11        parent::set_up();
     12        $this->permalink_structure = get_option( 'permalink_structure', '' );
     13    }
     14
     15    public function tear_down() {
     16        $this->set_permalink_structure( $this->permalink_structure );
     17
     18        parent::tear_down();
     19    }
     20
    821    /**
    922     * @group block_self
     
    1225        $u = self::factory()->user->create();
    1326        $this->set_current_user( $u );
    14 
    15         $this->go_to( bp_core_get_user_domain( $u ) );
     27        $this->set_permalink_structure( '/%postname%/' );
     28
     29        $this->go_to( bp_members_get_user_url( $u ) );
    1630
    1731        $b = new BP_Button( array(
     
    3044        $u1 = self::factory()->user->create();
    3145        $this->set_current_user( $u1 );
     46        $this->set_permalink_structure( '/%postname%/' );
    3247
    3348        $u2 = self::factory()->user->create();
    34         $this->go_to( bp_core_get_user_domain( $u2 ) );
     49        $this->go_to( bp_members_get_user_url( $u2 ) );
    3550
    3651        $b = new BP_Button( array(
     
    136151
    137152        $this->set_current_user( $u1 );
    138         $this->go_to( bp_core_get_user_domain( $u1 ) );
     153        $this->set_permalink_structure( '/%postname%/' );
     154        $this->go_to( bp_members_get_user_url( $u1 ) );
    139155
    140156        $found = array();
Note: See TracChangeset for help on using the changeset viewer.