Skip to:
Content

BuddyPress.org

Changeset 13433


Ignore:
Timestamp:
03/07/2023 04:28:08 AM (12 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

Location:
trunk
Files:
60 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/actions/feeds.php

    r12907 r13433  
    176176        'description'   => sprintf( __( "Activity feed mentioning %s.", 'buddypress' ), bp_get_displayed_user_fullname() ),
    177177        'activity_args' => array(
    178             'search_terms' => '@' . bp_core_get_username( bp_displayed_user_id() )
     178            'search_terms' => '@' . bp_members_get_user_slug( bp_displayed_user_id() )
    179179        )
    180180    ) );
  • trunk/src/bp-activity/bp-activity-filters.php

    r13108 r13433  
    265265    // Linkify the mentions with the username.
    266266    foreach ( (array) $usernames as $user_id => $username ) {
    267         $content = preg_replace( '/(@' . $username . '\b)/', "<a class='bp-suggestions-mention' href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
     267        $content = preg_replace( '/(@' . $username . '\b)/', "<a class='bp-suggestions-mention' href='" . bp_members_get_user_url( $user_id ) . "' rel='nofollow'>@$username</a>", $content );
    268268    }
    269269
     
    306306        // Replace @mention text with userlinks.
    307307        foreach( (array) $usernames as $user_id => $username ) {
    308             $activity->content = preg_replace( '/(@' . $username . '\b)/', "<a class='bp-suggestions-mention' href='" . bp_core_get_user_domain( $user_id ) . "' rel='nofollow'>@$username</a>", $activity->content );
     308            $activity->content = preg_replace( '/(@' . $username . '\b)/', "<a class='bp-suggestions-mention' href='" . bp_members_get_user_url( $user_id ) . "' rel='nofollow'>@$username</a>", $activity->content );
    309309        }
    310310
  • trunk/src/bp-activity/bp-activity-notifications.php

    r12893 r13433  
    412412                        <?php
    413413                        /* translators: %s: the displayed user username */
    414                         printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_core_get_username( bp_displayed_user_id() ) );
     414                        printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), bp_members_get_user_slug( bp_displayed_user_id() ) );
    415415                        ?>
    416416                    </td>
  • trunk/src/bp-activity/bp-activity-template.php

    r13409 r13433  
    10071007            $link = $activities_template->activity->primary_link;
    10081008        } else {
    1009             $link = bp_core_get_user_domain( $activities_template->activity->user_id, $activities_template->activity->user_nicename, $activities_template->activity->user_login );
     1009            $link = bp_members_get_user_url( $activities_template->activity->user_id );
    10101010        }
    10111011
     
    15401540            if ( in_array( $activity_type, array( 'new_avatar', 'new_member', 'friendship_created', 'updated_profile' ), true ) ) {
    15411541                $generated_content->user_url = array(
    1542                     'value'             => bp_core_get_user_domain( $user_id ),
     1542                    'value'             => bp_members_get_user_url( $user_id ),
    15431543                    'sanitize_callback' => 'esc_url',
    15441544                );
     
    22552255     */
    22562256    function bp_get_activity_comment_user_link() {
    2257         $user_link = bp_core_get_user_domain( bp_get_activity_comment_user_id() );
     2257        $user_link = bp_members_get_user_url( bp_get_activity_comment_user_id() );
    22582258
    22592259        /**
     
    36533653
    36543654            // Get profile link for this user.
    3655             $profile_link = bp_core_get_user_domain( $user_id );
     3655            $profile_link = bp_members_get_user_url( $user_id );
    36563656
    36573657            // Get avatar for this user.
  • trunk/src/bp-activity/classes/class-bp-activity-oembed-extension.php

    r13241 r13433  
    138138            'title'        => __( 'Activity', 'buddypress' ),
    139139            'author_name'  => bp_core_get_user_displayname( $activity->user_id ),
    140             'author_url'   => bp_core_get_user_domain( $activity->user_id ),
     140            'author_url'   => bp_members_get_user_url( $activity->user_id ),
    141141
    142142            // Custom identifier.
  • 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
  • trunk/src/bp-blogs/bp-blogs-activity.php

    r13419 r13433  
    785785        'comment_author'       => bp_core_get_user_displayname( $params['user_id'] ),
    786786        'comment_author_email' => $user->user_email,
    787         'comment_author_url'   => bp_core_get_user_domain( $params['user_id'], $user->user_nicename, $user->user_login ),
     787        'comment_author_url'   => bp_members_get_user_url( $params['user_id'] ),
    788788        'comment_content'      => $params['content'],
    789789        'comment_type'         => '', // Could be interesting to add 'BuddyPress' here...
  • trunk/src/bp-core/admin/bp-core-admin-functions.php

    r13431 r13433  
    13111311
    13121312    // Create a "View" link.
    1313     $url             = bp_core_get_user_domain( $user_id );
     1313    $url             = bp_members_get_user_url( $user_id );
    13141314    $actions['view'] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $url ), esc_html__( 'View', 'buddypress' ) );
    13151315
  • trunk/src/bp-core/bp-core-catchuri.php

    r13162 r13433  
    591591    $user = wp_get_current_user();
    592592
    593     return bp_core_get_username( $user->ID, $user->user_nicename, $user->user_login );
     593    return bp_members_get_user_slug( $user->ID );
    594594}
    595595add_filter( 'bp_core_set_uri_globals_member_slug', 'bp_core_members_shortlink_redirector' );
  • trunk/src/bp-core/bp-core-filters.php

    r13395 r13433  
    292292
    293293    foreach( (array) $comments as $comment ) {
    294         if ( $comment->user_id )
     294        if ( $comment->user_id ) {
    295295            $user_ids[] = $comment->user_id;
    296     }
    297 
    298     if ( empty( $user_ids ) )
     296        }
     297    }
     298
     299    if ( empty( $user_ids ) ) {
    299300        return $comments;
     301    }
    300302
    301303    $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
    302304
    303     if ( !$userdata = $wpdb->get_results( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) )
     305    if ( ! $userdata = $wpdb->get_results( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) {
    304306        return $comments;
    305 
    306     foreach( (array) $userdata as $user )
    307         $users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login );
     307    }
     308
     309    foreach( (array) $userdata as $user ) {
     310        $users[$user->user_id] = bp_members_get_user_url( $user->user_id );
     311    }
    308312
    309313    foreach( (array) $comments as $i => $comment ) {
    310         if ( !empty( $comment->user_id ) ) {
    311             if ( !empty( $users[$comment->user_id] ) )
     314        if ( ! empty( $comment->user_id ) ) {
     315            if ( ! empty( $users[$comment->user_id] ) ) {
    312316                $comments[$i]->comment_author_url = $users[$comment->user_id];
     317            }
    313318        }
    314319    }
     
    12331238                $tokens['unsubscribe'] = esc_url( sprintf(
    12341239                    '%s%s/notifications/',
    1235                     bp_core_get_user_domain( $user_obj->ID ),
     1240                    bp_members_get_user_url( $user_obj->ID ),
    12361241                    bp_get_settings_slug()
    12371242                ) );
  • trunk/src/bp-core/bp-core-functions.php

    r13432 r13433  
    43364336
    43374337        if ( bp_is_active( 'settings' ) ) {
    4338             $redirect_to = sprintf(
    4339                 '%s%s/notifications/',
    4340                 bp_core_get_user_domain( get_current_user_id() ),
    4341                 bp_get_settings_slug()
     4338            $redirect_to = bp_members_get_user_url(
     4339                get_current_user_id(),
     4340                array(
     4341                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     4342                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_settings_notifications', 'notifications' ),
     4343                )
    43424344            );
    43434345        } else {
    4344             $redirect_to = bp_core_get_user_domain( get_current_user_id() );
     4346            $redirect_to = bp_members_get_user_url( get_current_user_id() );
    43454347        }
    43464348
     
    43684370            $redirect_to = sprintf(
    43694371                '%s%s/notifications/',
    4370                 bp_core_get_user_domain( $raw_user_id ),
     4372                bp_members_get_user_url( $raw_user_id ),
    43714373                bp_get_settings_slug()
    43724374            );
    43734375        } else {
    4374             $redirect_to = bp_core_get_user_domain( $raw_user_id );
     4376            $redirect_to = bp_members_get_user_url( $raw_user_id );
    43754377        }
    43764378
     
    43934395        // Template notices are only displayed on BP pages.
    43944396        bp_core_add_message( $message );
    4395         bp_core_redirect( bp_core_get_user_domain( $raw_user_id ) );
     4397        bp_core_redirect( bp_members_get_user_url( $raw_user_id ) );
    43964398
    43974399        exit;
  • 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;
  • trunk/src/bp-core/classes/class-bp-core-user.php

    r12791 r13433  
    156156            $full_name_field_name = bp_xprofile_fullname_field_name();
    157157
    158             $this->user_url  = bp_core_get_user_domain( $this->id, $this->profile_data['user_nicename'], $this->profile_data['user_login'] );
     158            $this->user_url  = bp_members_get_user_url( $this->id );
    159159            $this->fullname  = esc_attr( $this->profile_data[$full_name_field_name]['field_data'] );
    160160            $this->user_link = "<a href='{$this->user_url}'>{$this->fullname}</a>";
    161161            $this->email     = esc_attr( $this->profile_data['user_email'] );
    162162        } else {
    163             $this->user_url  = bp_core_get_user_domain( $this->id );
     163            $this->user_url  = bp_members_get_user_url( $this->id );
    164164            $this->user_link = bp_core_get_userlink( $this->id );
    165165            $this->fullname  = esc_attr( bp_core_get_user_displayname( $this->id ) );
  • trunk/src/bp-core/classes/class-bp-optouts-list-table.php

    r13225 r13433  
    325325            return;
    326326        }
    327         $user_link = bp_core_get_user_domain( $optout->user_id );
     327        $user_link = bp_members_get_user_url( $optout->user_id );
    328328        echo $avatar . sprintf( '<strong><a href="%1$s" class="edit">%2$s</a></strong><br/>', esc_url( $user_link ), esc_html( $inviter->user_login ) );
    329329    }
  • trunk/src/bp-core/deprecated/12.0.php

    r13432 r13433  
    158158    _deprecated_function( __FUNCTION__, '12.0.0' );
    159159}
     160
     161/**
     162 * Return the username for a user based on their user id.
     163 *
     164 * This function is sensitive to the BP_ENABLE_USERNAME_COMPATIBILITY_MODE,
     165 * so it will return the user_login or user_nicename as appropriate.
     166 *
     167 * @since 1.0.0
     168 * @deprecated 12.0.0
     169 *
     170 * @param int         $user_id       User ID to check.
     171 * @param string|bool $user_nicename Optional. user_nicename of user being checked.
     172 * @param string|bool $user_login    Optional. user_login of user being checked.
     173 * @return string The username of the matched user or an empty string if no user is found.
     174 */
     175function bp_core_get_username( $user_id = 0, $user_nicename = false, $user_login = false ) {
     176    _deprecated_function( __FUNCTION__, '12.0.0', 'bp_members_get_user_slug()' );
     177
     178    if ( ! $user_id ) {
     179        $value = $user_nicename;
     180        $field = 'slug';
     181
     182        if ( ! $user_nicename ) {
     183            $value = $user_login;
     184            $field = 'login';
     185        }
     186
     187        $user = get_user_by( $field, $value );
     188
     189        if ( $user instanceof WP_User ) {
     190            $user_id = (int) $user->ID;
     191        }
     192    }
     193
     194    $username = bp_members_get_user_slug( $user_id );
     195
     196    /**
     197     * Filters the username based on originally provided user ID.
     198     *
     199     * @since 1.0.1
     200     * @deprecated 12.0.0
     201     *
     202     * @param string $username Username determined by user ID.
     203     */
     204    return apply_filters_deprecated( 'bp_core_get_username', array( $username ), '12.0.0', 'bp_members_get_user_slug' );
     205}
     206
     207/**
     208 * Return the domain for the passed user: e.g. http://example.com/members/andy/.
     209 *
     210 * @since 1.0.0
     211 * @deprecated 12.0.0
     212 *
     213 * @param int         $user_id       The ID of the user.
     214 * @param string|bool $user_nicename Optional. user_nicename of the user.
     215 * @param string|bool $user_login    Optional. user_login of the user.
     216 * @return string
     217 */
     218function bp_core_get_user_domain( $user_id = 0, $user_nicename = false, $user_login = false ) {
     219    _deprecated_function( __FUNCTION__, '12.0.0', 'bp_members_get_user_url()' );
     220
     221    if ( empty( $user_id ) ) {
     222        return;
     223    }
     224
     225    $domain = bp_members_get_user_url( $user_id );
     226
     227    // Don't use this filter.  Subject to removal in a future release.
     228    // Use the 'bp_core_get_user_domain' filter instead.
     229    $domain = apply_filters_deprecated( 'bp_core_get_user_domain_pre_cache', array( $domain, $user_id, $user_nicename, $user_login), '12.0.0' );
     230
     231    /**
     232     * Filters the domain for the passed user.
     233     *
     234     * @since 1.0.1
     235     * @deprecated 12.0.0
     236     *
     237     * @param string $domain        Domain for the passed user.
     238     * @param int    $user_id       ID of the passed user.
     239     * @param string $user_nicename User nicename of the passed user.
     240     * @param string $user_login    User login of the passed user.
     241     */
     242    return apply_filters_deprecated( 'bp_core_get_user_domain', array( $domain, $user_id, $user_nicename, $user_login), '12.0.0', 'bp_members_get_user_url' );
     243}
  • trunk/src/bp-friends/bp-friends-blocks.php

    r13296 r13433  
    111111    $widget_id = uniqid( 'friends-list-' );
    112112
    113     $link = trailingslashit( bp_core_get_user_domain( $user_id ) . bp_get_friends_slug() );
     113    $link = bp_members_get_user_url(
     114        $user_id,
     115        array(
     116            'single_item_component' => bp_rewrites_get_slug( 'members', 'member_friends', bp_get_friends_slug() ),
     117        )
     118    );
    114119
    115120    /* translators: %s: member name */
     
    190195                    'php',
    191196                    array(
    192                         'data.link'              => bp_core_get_user_domain( $user->ID, $user->user_nicename, $user->user_login ),
     197                        'data.link'              => bp_members_get_user_url( $user->ID ),
    193198                        'data.name'              => $user->display_name,
    194199                        'data.avatar_urls.thumb' => bp_core_fetch_avatar(
  • 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,
  • trunk/src/bp-friends/bp-friends-template.php

    r13409 r13433  
    102102
    103103                <li>
    104                     <a href="<?php echo bp_core_get_user_domain( $friend_ids[$i] ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $friend_ids[$i], 'type' => 'thumb' ) ) ?></a>
     104                    <a href="<?php echo bp_members_get_user_url( $friend_ids[$i] ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $friend_ids[$i], 'type' => 'thumb' ) ) ?></a>
    105105                    <h5><?php echo bp_core_get_userlink($friend_ids[$i]) ?></h5>
    106106                </li>
     
    154154
    155155            <li>
    156                 <a href="<?php echo bp_core_get_user_domain( $user_ids['users'][$i]->id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_ids['users'][$i]->id, 'type' => 'thumb' ) ) ?></a>
     156                <a href="<?php echo bp_members_get_user_url( $user_ids['users'][$i]->id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_ids['users'][$i]->id, 'type' => 'thumb' ) ) ?></a>
    157157                <h5><?php echo bp_core_get_userlink( $user_ids['users'][$i]->id ) ?></h5>
    158158
  • trunk/src/bp-groups/bp-groups-admin.php

    r13372 r13433  
    10341034
    10351035                        <td class="uname-column">
    1036                             <a style="float: left;" href="<?php echo bp_core_get_user_domain( $type_user->ID ); ?>"><?php echo bp_core_fetch_avatar( array(
     1036                            <a style="float: left;" href="<?php echo bp_members_get_user_url( $type_user->ID ); ?>"><?php echo bp_core_fetch_avatar( array(
    10371037                                'item_id' => $type_user->ID,
    10381038                                'width'   => '32',
  • trunk/src/bp-groups/bp-groups-notifications.php

    r13293 r13433  
    169169            'group.id'             => $group_id,
    170170            'group-requests.url'   => esc_url( bp_get_group_permalink( $group ) . 'admin/membership-requests' ),
    171             'profile.url'          => esc_url( bp_core_get_user_domain( $requesting_user_id ) ),
     171            'profile.url'          => esc_url( bp_members_get_user_url( $requesting_user_id ) ),
    172172            'requesting-user.id'   => $requesting_user_id,
    173173            'requesting-user.name' => bp_core_get_user_displayname( $requesting_user_id ),
     
    337337    }
    338338
    339     $invited_link = bp_core_get_user_domain( $invited_user_id ) . bp_get_groups_slug();
     339    $invited_link = bp_members_get_user_url(
     340        $invited_user_id,
     341        array(
     342            'single_item_component' => bp_rewrites_get_slug( 'members', 'member_groups', bp_get_groups_slug() ),
     343        )
     344    );
    340345
    341346    $unsubscribe_args = array(
     
    360365            'group.name'     => $group->name,
    361366            'inviter.name'   => bp_core_get_userlink( $inviter_user_id, true, false ),
    362             'inviter.url'    => bp_core_get_user_domain( $inviter_user_id ),
     367            'inviter.url'    => bp_members_get_user_url( $inviter_user_id ),
    363368            'inviter.id'     => $inviter_user_id,
    364369            'invites.url'    => esc_url( $invited_link . '/invites/' ),
     
    12521257            'group.name'      => $group->name,
    12531258            'group.url'       => esc_url( bp_get_group_permalink( $group ) ),
    1254             'leave-group.url' => esc_url( bp_core_get_user_domain( $user_id ) . bp_get_groups_slug() ),
     1259            'leave-group.url' => esc_url(
     1260                bp_members_get_user_url(
     1261                    $user_id,
     1262                    array(
     1263                        'single_item_component' => bp_rewrites_get_slug( 'members', 'member_groups', bp_get_groups_slug() ),
     1264                    )
     1265                )
     1266            ),
    12551267        ),
    12561268    );
  • trunk/src/bp-groups/bp-groups-template.php

    r13409 r13433  
    16391639         * @param BP_Groups_Group $group     The group object.
    16401640         */
    1641         return apply_filters( 'bp_get_group_creator_permalink', bp_core_get_user_domain( $group->creator_id ), $group );
     1641        return apply_filters( 'bp_get_group_creator_permalink', bp_members_get_user_url( $group->creator_id ), $group );
    16421642    }
    16431643
     
    17971797                <li>
    17981798                    <a
    1799                         href="<?php echo esc_url( bp_core_get_user_domain( $admin->user_id, $admin->user_nicename, $admin->user_login ) ); ?>"
     1799                        href="<?php echo esc_url( bp_members_get_user_url( $admin->user_id ) ); ?>"
    18001800                        class="bp-tooltip"
    18011801                        data-bp-tooltip="<?php printf( ( '%s' ), bp_core_get_user_displayname( $admin->user_id ) ); ?>"
     
    18441844                <li>
    18451845                    <a
    1846                         href="<?php echo esc_url( bp_core_get_user_domain( $mod->user_id, $mod->user_nicename, $mod->user_login ) ); ?>"
     1846                        href="<?php echo esc_url( bp_members_get_user_url( $mod->user_id ) ); ?>"
    18471847                        class="bp-tooltip"
    18481848                        data-bp-tooltip="<?php printf( ( '%s' ), bp_core_get_user_displayname( $mod->user_id ) ); ?>">
     
    42734273         * @param string $value URL for the current user.
    42744274         */
    4275         return apply_filters( 'bp_get_group_member_url', bp_core_get_user_domain( $members_template->member->user_id, $members_template->member->user_nicename, $members_template->member->user_login ) );
     4275        return apply_filters( 'bp_get_group_member_url', bp_members_get_user_url( $members_template->member->user_id ) );
    42764276    }
    42774277
     
    42974297         * @param string $value HTML link for the current user.
    42984298         */
    4299         return apply_filters( 'bp_get_group_member_link', '<a href="' . bp_core_get_user_domain( $members_template->member->user_id, $members_template->member->user_nicename, $members_template->member->user_login ) . '">' . $members_template->member->display_name . '</a>' );
     4299        return apply_filters( 'bp_get_group_member_link', '<a href="' . bp_members_get_user_url( $members_template->member->user_id ) . '">' . $members_template->member->display_name . '</a>' );
    43004300    }
    43014301
     
    43214321         * @param string $value Domain for the current user.
    43224322         */
    4323         return apply_filters( 'bp_get_group_member_domain', bp_core_get_user_domain( $members_template->member->user_id, $members_template->member->user_nicename, $members_template->member->user_login ) );
     4323        return apply_filters( 'bp_get_group_member_domain', bp_members_get_user_url( $members_template->member->user_id ) );
    43244324    }
    43254325
  • trunk/src/bp-groups/classes/class-bp-groups-invite-template.php

    r13399 r13433  
    293293
    294294        $this->invite->user->email     = $this->invite->user->user_email;
    295         $this->invite->user->user_url  = bp_core_get_user_domain( $user_id, $this->invite->user->user_nicename, $this->invite->user->user_login );
     295        $this->invite->user->user_url  = bp_members_get_user_url( $user_id );
    296296        $this->invite->user->user_link = "<a href='{$this->invite->user->user_url}'>{$this->invite->user->fullname}</a>";
    297297
  • trunk/src/bp-members/actions/random.php

    r11927 r13433  
    1818
    1919    $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) );
    20     bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) );
     20    bp_core_redirect( bp_members_get_user_url( $user['users'][0]->id ) );
    2121}
    2222add_action( 'bp_actions', 'bp_core_get_random_member' );
  • trunk/src/bp-members/bp-members-blocks.php

    r13296 r13433  
    4444
    4545    // Mention variables.
    46     $username   = bp_core_get_username( $member_id );
     46    $username   = bp_members_get_user_slug( $member_id );
    4747    $at_mention = '';
    4848
     
    5858    // Member name variables.
    5959    $display_name = bp_core_get_user_displayname( $member_id );
    60     $member_link  = bp_core_get_user_domain( $member_id );
     60    $member_link  = bp_members_get_user_url( $member_id );
    6161
    6262    // Member action button.
     
    230230
    231231        // Get Member link.
    232         $member_link = bp_core_get_user_domain( $member->ID );
     232        $member_link = bp_members_get_user_url( $member->ID );
    233233
    234234        // Set the Avatar output.
     
    483483                    'php',
    484484                    array(
    485                         'data.link'              => bp_core_get_user_domain( $user->ID, $user->user_nicename, $user->user_login ),
     485                        'data.link'              => bp_members_get_user_url( $user->ID ),
    486486                        'data.name'              => $user->display_name,
    487487                        'data.avatar_urls.thumb' => bp_core_fetch_avatar(
     
    633633                    </a>
    634634                </div>',
    635                 esc_url( bp_core_get_user_domain( $member->ID, $member->user_nicename, $member->user_login ) ),
     635                esc_url( bp_members_get_user_url( $member->ID ) ),
    636636                esc_html( $member->display_name ),
    637637                bp_core_fetch_avatar(
  • trunk/src/bp-members/bp-members-filters.php

    r13105 r13433  
    109109    // If xprofile is active, use profile domain link.
    110110    if ( ! is_admin() && bp_is_active( 'xprofile' ) ) {
    111         $profile_link = trailingslashit( bp_core_get_user_domain( $user_id ) . bp_get_profile_slug() . '/edit' );
     111        $profile_link = bp_members_get_user_url(
     112            $user_id,
     113            array(
     114                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_profile', bp_get_profile_slug() ),
     115                'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_profile_edit', 'edit' ),
     116            )
     117        );
    112118
    113119    } else {
  • trunk/src/bp-members/bp-members-functions.php

    r13432 r13433  
    140140
    141141/**
    142  * Return the domain for the passed user: e.g. http://example.com/members/andy/.
    143  *
    144  * @since 1.0.0
    145  *
    146  * @param int         $user_id       The ID of the user.
    147  * @param string|bool $user_nicename Optional. user_nicename of the user.
    148  * @param string|bool $user_login    Optional. user_login of the user.
    149  * @return string
    150  */
    151 function bp_core_get_user_domain( $user_id = 0, $user_nicename = false, $user_login = false ) {
    152 
    153     if ( empty( $user_id ) ) {
    154         return;
    155     }
    156 
    157     $username = bp_core_get_username( $user_id, $user_nicename, $user_login );
    158 
    159     if ( bp_is_username_compatibility_mode() ) {
    160         $username = rawurlencode( $username );
    161     }
    162 
    163     $after_domain = bp_core_enable_root_profiles() ? $username : bp_get_members_root_slug() . '/' . $username;
    164     $domain       = trailingslashit( bp_get_root_domain() . '/' . $after_domain );
    165 
    166     // Don't use this filter.  Subject to removal in a future release.
    167     // Use the 'bp_core_get_user_domain' filter instead.
    168     $domain = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login );
     142 * Return the Mmbers single item's URL.
     143 *
     144 * @since 12.0.0
     145 *
     146 * @param integer $user_id  The user ID.
     147 * @param array   $action {
     148 *     An array of arguments. Optional.
     149 *
     150 *     @type string $single_item_component        The component slug the action is relative to.
     151 *     @type string $single_item_action           The slug of the action to perform.
     152 *     @type array  $single_item_action_variables An array of additional informations about the action to perform.
     153 * }
     154 * @return string The URL built for the BP Rewrites URL parser.
     155 */
     156function bp_members_get_user_url( $user_id = 0, $path_chunks = array() ) {
     157    $url  = '';
     158    $slug = bp_members_get_user_slug( $user_id );
     159
     160    if ( $slug ) {
     161        if ( bp_is_username_compatibility_mode() ) {
     162            $slug = rawurlencode( $slug );
     163        }
     164
     165        $supported_chunks = array_fill_keys( array( 'single_item_component', 'single_item_action', 'single_item_action_variables' ), true );
     166        $path_chunks      = bp_parse_args(
     167            array_intersect_key( $path_chunks, $supported_chunks ),
     168            array(
     169                'component_id' => 'members',
     170                'single_item'  => $slug,
     171            )
     172        );
     173
     174        $url = bp_rewrites_get_url( $path_chunks );
     175    }
    169176
    170177    /**
     
    172179     *
    173180     * @since 1.0.1
     181     * @deprecated 12.0.0
    174182     *
    175183     * @param string $domain        Domain for the passed user.
     
    178186     * @param string $user_login    User login of the passed user.
    179187     */
    180     return apply_filters( 'bp_core_get_user_domain', $domain, $user_id, $user_nicename, $user_login );
     188    $url = apply_filters_deprecated( 'bp_core_get_user_domain', array( $url, $user_id, false, false ), '12.0.0', 'bp_members_get_user_url' );
     189
     190    /**
     191     * Filters the domain for the passed user.
     192     *
     193     * @since 12.0.0
     194     *
     195     * @param string  $url      The user url.
     196     * @param integer $user_id  The user ID.
     197     * @param string  $slug     The user slug.
     198     * @param array   $path_chunks {
     199     *     An array of arguments. Optional.
     200     *
     201     *     @type string $single_item_component        The component slug the action is relative to.
     202     *     @type string $single_item_action           The slug of the action to perform.
     203     *     @type array  $single_item_action_variables An array of additional informations about the action to perform.
     204     * }
     205     */
     206    return apply_filters( 'bp_members_get_user_url', $url, $user_id, $slug, $path_chunks );
    181207}
    182208
     
    274300
    275301/**
    276  * Return the username for a user based on their user id.
    277  *
    278  * This function is sensitive to the BP_ENABLE_USERNAME_COMPATIBILITY_MODE,
    279  * so it will return the user_login or user_nicename as appropriate.
    280  *
    281  * @since 1.0.0
    282  *
    283  * @param int         $user_id       User ID to check.
    284  * @param string|bool $user_nicename Optional. user_nicename of user being checked.
    285  * @param string|bool $user_login    Optional. user_login of user being checked.
    286  * @return string The username of the matched user or an empty string if no user is found.
    287  */
    288 function bp_core_get_username( $user_id = 0, $user_nicename = false, $user_login = false ) {
    289 
    290     if ( ! $user_nicename && ! $user_login ) {
    291         // Pull an audible and maybe use the login over the nicename.
    292         if ( bp_is_username_compatibility_mode() ) {
    293             $username = get_the_author_meta( 'login', $user_id );
    294         } else {
    295             $username = get_the_author_meta( 'nicename', $user_id );
    296         }
     302 * Returns the members single item (member) slug.
     303 *
     304 * @since 12.0.0
     305 *
     306 * @param integer $user_id The User ID.
     307 * @return string The member slug.
     308 */
     309function bp_members_get_user_slug( $user_id = 0 ) {
     310    $bp  = buddypress();
     311    $lug = '';
     312
     313    $prop = 'user_nicename';
     314    if ( bp_is_username_compatibility_mode() ) {
     315        $prop = 'user_login';
     316    }
     317
     318    if ( (int) bp_loggedin_user_id() === (int) $user_id ) {
     319        $slug = isset( $bp->loggedin_user->userdata->{$prop} ) ? $bp->loggedin_user->userdata->{$prop} : null;
     320    } elseif ( (int) bp_displayed_user_id() === (int) $user_id ) {
     321        $slug = isset( $bp->displayed_user->userdata->{$prop} ) ? $bp->displayed_user->userdata->{$prop} : null;
    297322    } else {
    298         $username = bp_is_username_compatibility_mode() ? $user_login : $user_nicename;
     323        $user = get_user_by( 'id', $user_id );
     324
     325        if ( $user instanceof WP_User ) {
     326            $slug = $user->{$prop};
     327        }
    299328    }
    300329
     
    303332     *
    304333     * @since 1.0.1
    305      *
    306      * @param string $username Username determined by user ID.
    307      */
    308     return apply_filters( 'bp_core_get_username', $username );
     334     * @deprecated 12.0.0
     335     *
     336     * @param string $slug Username determined by user ID.
     337     */
     338    $slug = apply_filters_deprecated( 'bp_core_get_username', array( $slug ), '12.0.0', 'bp_members_get_user_slug' );
     339
     340    /**
     341     * Filter here to edit the user's slug.
     342     *
     343     * @since 12.0.0
     344     *
     345     * @param string $slug     The user's slug.
     346     * @param integer $user_id The user ID.
     347     */
     348    return apply_filters( 'bp_members_get_user_slug', $slug, $user_id );
    309349}
    310350
     
    381421    }
    382422
    383     if ( !$url = bp_core_get_user_domain( $user_id ) ) {
     423    if ( !$url = bp_members_get_user_url( $user_id ) ) {
    384424        return false;
    385425    }
     
    33163356    }
    33173357
    3318     $profile_url = bp_core_get_user_domain( $user_id );
     3358    $profile_url = bp_members_get_user_url( $user_id );
    33193359
    33203360    /**
  • trunk/src/bp-members/bp-members-notifications.php

    r13185 r13433  
    4848                }
    4949            } else {
    50                 $link   = add_query_arg( 'welcome', 1, bp_core_get_user_domain( $item_id ) );
     50                $link   = add_query_arg( 'welcome', 1, bp_members_get_user_url( $item_id ) );
    5151                $amount = 'single';
    5252
  • trunk/src/bp-members/bp-members-template.php

    r13432 r13433  
    902902        global $members_template;
    903903
    904         $permalink = bp_core_get_user_domain(
    905             $members_template->member->id,
    906             $members_template->member->user_nicename,
    907             $members_template->member->user_login
    908         );
     904        $permalink = bp_members_get_user_url( $members_template->member->id );
    909905
    910906        /**
     
    20502046
    20512047        if ( bp_displayed_user_id() ) {
    2052             $username = bp_core_get_username( bp_displayed_user_id(), $bp->displayed_user->userdata->user_nicename, $bp->displayed_user->userdata->user_login );
     2048            $username = bp_members_get_user_slug( bp_displayed_user_id() );
    20532049        } else {
    20542050            $username = '';
     
    20842080
    20852081        if ( bp_loggedin_user_id() ) {
    2086             $username = bp_core_get_username( bp_loggedin_user_id(), $bp->loggedin_user->userdata->user_nicename, $bp->loggedin_user->userdata->user_login );
     2082            $username = bp_members_get_user_slug( bp_loggedin_user_id() );
    20872083        } else {
    20882084            $username = '';
     
    35723568            $domain  = bp_loggedin_user_domain();
    35733569        } else {
    3574             $domain = bp_core_get_user_domain( (int) $user_id );
     3570            $domain = bp_members_get_user_url( (int) $user_id );
    35753571        }
    35763572
     
    36113607            $domain  = bp_loggedin_user_domain();
    36123608        } else {
    3613             $domain = bp_core_get_user_domain( (int) $user_id );
     3609            $domain = bp_members_get_user_url( (int) $user_id );
    36143610        }
    36153611
  • trunk/src/bp-members/classes/class-bp-members-admin.php

    r13404 r13433  
    13341334
    13351335                <div id="publishing-action">
    1336                     <a class="button bp-view-profile" href="<?php echo esc_url( bp_core_get_user_domain( $user->ID ) ); ?>" target="_blank"><?php esc_html_e( 'View Profile', 'buddypress' ); ?></a>
     1336                    <a class="button bp-view-profile" href="<?php echo esc_url( bp_members_get_user_url( $user->ID ) ); ?>" target="_blank"><?php esc_html_e( 'View Profile', 'buddypress' ); ?></a>
    13371337                    <?php submit_button( esc_html__( 'Update Profile', 'buddypress' ), 'primary', 'save', false ); ?>
    13381338                </div>
  • trunk/src/bp-members/classes/class-bp-members-component.php

    r13432 r13433  
    229229
    230230        // The domain for the user currently logged in. eg: http://example.com/members/andy.
    231         $bp->loggedin_user->domain = bp_core_get_user_domain( bp_loggedin_user_id() );
     231        $bp->loggedin_user->domain = bp_members_get_user_url( bp_loggedin_user_id() );
    232232
    233233        /** Displayed user ***************************************************
     
    241241
    242242        // The domain for the user currently being displayed.
    243         $bp->displayed_user->domain = bp_core_get_user_domain( bp_displayed_user_id() );
     243        $bp->displayed_user->domain = bp_members_get_user_url( bp_displayed_user_id() );
    244244
    245245        // If A user is displayed, check if there is a front template
  • trunk/src/bp-members/classes/class-bp-members-invitation-manager.php

    r13293 r13433  
    7474                'tokens' => array(
    7575                    'inviter.name'      => bp_core_get_userlink( $invitation->inviter_id, true, false ),
    76                     'inviter.url'       => bp_core_get_user_domain( $invitation->inviter_id ),
     76                    'inviter.url'       => bp_members_get_user_url( $invitation->inviter_id ),
    7777                    'inviter.id'        => $invitation->inviter_id,
    7878                    'invite.accept_url' => esc_url( $invite_url ),
  • trunk/src/bp-members/classes/class-bp-members-invitations-list-table.php

    r13225 r13433  
    426426        }
    427427
    428         $user_link = bp_core_get_user_domain( $invite->inviter_id );
     428        $user_link = bp_members_get_user_url( $invite->inviter_id );
    429429
    430430        printf( '%1$s <strong><a href="%2$s" class="edit">%3$s</a></strong><br/>', $avatar, esc_url( $user_link ), esc_html( $inviter->user_login ) );
  • trunk/src/bp-messages/bp-messages-functions.php

    r13395 r13433  
    627627            'tokens' => array(
    628628                'usermessage' => wp_strip_all_tags( stripslashes( $message ) ),
    629                 'message.url' => esc_url( bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() . '/view/' . $thread_id . '/' ),
     629                'message.url' => esc_url(
     630                    bp_members_get_user_url(
     631                        $recipient->user_id,
     632                        array(
     633                            'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     634                            'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_messages_view', 'view' ),
     635                            'single_item_action_variables' => array( $thread_id ),
     636                        )
     637                    )
     638                ),
    630639                'sender.name' => $sender_name,
    631640                'usersubject' => sanitize_text_field( stripslashes( $subject ) ),
  • trunk/src/bp-messages/bp-messages-star.php

    r13108 r13433  
    129129            // Empty or other.
    130130            default :
    131                 $user_domain = bp_core_get_user_domain( $r['user_id'] );
     131                $user_domain = bp_members_get_user_url( $r['user_id'] );
    132132                break;
    133133        }
  • trunk/src/bp-messages/bp-messages-template.php

    r13409 r13433  
    338338        }
    339339
    340         $domain = bp_core_get_user_domain( $user_id );
     340        $domain = bp_members_get_user_url( $user_id );
    341341
    342342        /**
     
    383383        }
    384384
    385         $domain = bp_core_get_user_domain( $user_id );
     385        $domain = bp_members_get_user_url( $user_id );
    386386
    387387        /**
     
    435435        }
    436436
    437         $domain = bp_core_get_user_domain( $user_id );
     437        $domain = bp_members_get_user_url( $user_id );
    438438
    439439        // Base unread URL.
     
    497497        }
    498498
    499         $domain = bp_core_get_user_domain( $user_id );
     499        $domain = bp_members_get_user_url( $user_id );
    500500
    501501        // Base read URL.
     
    14841484         * @param string $value URL for the Private Message link in member profile headers.
    14851485         */
    1486         return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_displayed_user_id() ) ) );
     1486        return apply_filters( 'bp_get_send_private_message_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_members_get_user_slug( bp_displayed_user_id() ) ) );
    14871487    }
    14881488
  • trunk/src/bp-notifications/bp-notifications-template.php

    r13147 r13433  
    6363            $domain  = bp_loggedin_user_domain();
    6464        } else {
    65             $domain = bp_core_get_user_domain( (int) $user_id );
     65            $domain = bp_members_get_user_url( (int) $user_id );
    6666        }
    6767
     
    104104            $domain  = bp_loggedin_user_domain();
    105105        } else {
    106             $domain = bp_core_get_user_domain( (int) $user_id );
     106            $domain = bp_members_get_user_url( (int) $user_id );
    107107        }
    108108
     
    144144            $domain  = bp_loggedin_user_domain();
    145145        } else {
    146             $domain = bp_core_get_user_domain( (int) $user_id );
     146            $domain = bp_members_get_user_url( (int) $user_id );
    147147        }
    148148
  • trunk/src/bp-templates/bp-nouveau/includes/activity/ajax.php

    r13395 r13433  
    268268    // If on a single activity redirect to user's home.
    269269    if ( ! empty( $_POST['is_single'] ) ) {
    270         $response['redirect'] = bp_core_get_user_domain( $activity->user_id );
     270        $response['redirect'] = bp_members_get_user_url( $activity->user_id );
    271271        bp_core_add_message( __( 'Activity deleted successfully', 'buddypress' ) );
    272272    }
     
    666666    // If on a single activity redirect to user's home.
    667667    if ( ! empty( $_POST['is_single'] ) ) {
    668         $response['redirect'] = bp_core_get_user_domain( $activity->user_id );
     668        $response['redirect'] = bp_members_get_user_url( $activity->user_id );
    669669        bp_core_add_message( __( 'This activity has been marked as spam and is no longer visible.', 'buddypress' ) );
    670670    }
  • trunk/src/bp-templates/bp-nouveau/includes/groups/functions.php

    r13302 r13433  
    254254                ),
    255255                'user_link' => bp_core_get_userlink( $inviter_id, false, true ),
    256                 'user_name' => bp_core_get_username( $inviter_id ),
     256                'user_name' => bp_members_get_user_slug( $inviter_id ),
    257257            );
    258258        }
  • trunk/src/bp-templates/bp-nouveau/includes/messages/ajax.php

    r13288 r13433  
    368368                    ) ) ),
    369369                    'user_link' => bp_core_get_userlink( $recipient->user_id, false, true ),
    370                     'user_name' => bp_core_get_username( $recipient->user_id ),
     370                    'user_name' => bp_members_get_user_slug( $recipient->user_id ),
    371371                );
    372372            }
     
    518518                    ) ) ),
    519519                    'user_link' => bp_core_get_userlink( $recipient->user_id, false, true ),
    520                     'user_name' => bp_core_get_username( $recipient->user_id ),
     520                    'user_name' => bp_members_get_user_slug( $recipient->user_id ),
    521521                );
    522522            }
  • trunk/src/bp-templates/bp-nouveau/includes/template-tags.php

    r13189 r13433  
    22682268    } elseif ( ! empty( $r['object'] ) && ! empty( $r['item_id'] ) ) {
    22692269        if ( 'user' === $r['object'] ) {
    2270             $url = rawurlencode( bp_core_get_user_domain( $r['item_id'] ) );
     2270            $url = rawurlencode( bp_members_get_user_url( $r['item_id'] ) );
    22712271
    22722272        } elseif ( 'group' === $r['object'] ) {
  • trunk/src/bp-xprofile/bp-xprofile-activity.php

    r13108 r13433  
    5050 */
    5151function bp_xprofile_format_activity_action_updated_profile( $action, $activity ) {
    52 
    53     // Note for translators: The natural phrasing in English, "Joe updated
    54     // his profile", requires that we know Joe's gender, which we don't. If
    55     // your language doesn't have this restriction, feel free to use a more
    56     // natural translation.
    57     $profile_link = trailingslashit( bp_core_get_user_domain( $activity->user_id ) . bp_get_profile_slug() );
     52    /*
     53     * Note for translators: The natural phrasing in English, "Joe updated
     54     * his profile", requires that we know Joe's gender, which we don't. If
     55     * your language doesn't have this restriction, feel free to use a more
     56     * natural translation.
     57     */
     58    $profile_link = bp_members_get_user_url(
     59        $activity->user_id,
     60        array(
     61            'single_item_component' => bp_rewrites_get_slug( 'members', 'member_profile', bp_get_profile_slug() ),
     62        )
     63    );
    5864
    5965    /* translators: %s: user profile link */
     
    247253
    248254    // If we've reached this point, assemble and post the activity item.
    249     $profile_link = trailingslashit( bp_core_get_user_domain( $user_id ) . bp_get_profile_slug() );
     255    $profile_link = bp_members_get_user_url(
     256        $user_id,
     257        array(
     258            'single_item_component' => bp_rewrites_get_slug( 'members', 'member_profile', bp_get_profile_slug() ),
     259        )
     260    );
    250261
    251262    return (bool) xprofile_record_activity( array(
  • trunk/tests/phpunit/includes/testcase.php

    r13314 r13433  
    210210        $bp->loggedin_user->fullname       = bp_core_get_user_displayname( $user_id );
    211211        $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( $user_id );
    212         $bp->loggedin_user->domain         = bp_core_get_user_domain( $user_id );
     212        $bp->loggedin_user->domain         = bp_members_get_user_url( $user_id );
    213213        $bp->loggedin_user->userdata       = bp_core_get_core_userdata( $user_id );
    214214
  • trunk/tests/phpunit/testcases/activity/filters.php

    r11737 r13433  
    2121
    2222        $u1_mention_name = bp_activity_get_user_mentionname( $u1 );
    23         $u1_domain = bp_core_get_user_domain( $u1 );
     23        $u1_domain = bp_members_get_user_url( $u1 );
    2424        $u2_mention_name = bp_activity_get_user_mentionname( $u2 );
    25         $u2_domain = bp_core_get_user_domain( $u2 );
     25        $u2_domain = bp_members_get_user_url( $u2 );
    2626
    2727        // mentions normal text should be replaced
  • trunk/tests/phpunit/testcases/activity/notifications.php

    r13414 r13433  
    77#[AllowDynamicProperties]
    88class BP_Tests_Activity_Notifications extends BP_UnitTestCase {
     9    protected $permalink_structure = '';
    910    protected $current_user;
    1011    protected $u1;
     
    1516    public function set_up() {
    1617        parent::set_up();
     18        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1719        $this->current_user = get_current_user_id();
    1820        $this->u1 = self::factory()->user->create();
     
    3133    public function tear_down() {
    3234        $this->set_current_user( $this->current_user );
     35        $this->set_permalink_structure( $this->permalink_structure );
     36
    3337        parent::tear_down();
    3438
     
    4347    public function test_bp_activity_remove_screen_notifications_on_single_activity_permalink() {
    4448        $this->create_notifications();
     49        $this->set_permalink_structure( '/%postname%/' );
    4550
    4651        $notifications = BP_Notifications_Notification::get( array(
     
    5257
    5358        // Go to the activity permalink page
    54         $this->go_to( bp_core_get_user_domain( $this->u1 ) . 'activity/' . $this->a1 );
     59        $this->go_to(
     60            bp_members_get_user_url(
     61                $this->u1,
     62                array(
     63                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     64                    'single_item_action'    => $this->a1,
     65                )
     66            )
     67        );
    5568
    5669        $notifications = BP_Notifications_Notification::get( array(
     
    6881    public function test_bp_activity_remove_screen_notifications_on_single_activity_permalink_logged_out() {
    6982        $this->create_notifications();
     83        $this->set_permalink_structure( '/%postname%/' );
    7084
    7185        $notifications = BP_Notifications_Notification::get( array(
     
    8094
    8195        // Go to the activity permalink page
    82         $this->go_to( bp_core_get_user_domain( $this->u1 ) . 'activity/' . $this->a1 );
     96        $this->go_to(
     97            bp_members_get_user_url(
     98                $this->u1,
     99                array(
     100                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     101                    'single_item_action'    => $this->a1,
     102                )
     103            )
     104        );
    83105
    84106        $notifications = BP_Notifications_Notification::get( array(
     
    98120    public function test_bp_activity_remove_screen_notifications_on_single_activity_permalink_wrong_user() {
    99121        $this->create_notifications();
     122        $this->set_permalink_structure( '/%postname%/' );
    100123
    101124        $notifications = BP_Notifications_Notification::get( array(
     
    110133
    111134        // Go to the activity permalink page
    112         $this->go_to( bp_core_get_user_domain( $this->u1 ) . 'activity/' . $this->a1 );
     135        $this->go_to(
     136            bp_members_get_user_url(
     137                $this->u1,
     138                array(
     139                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     140                    'single_item_action'    => $this->a1,
     141                )
     142            )
     143        );
    113144
    114145        $notifications = BP_Notifications_Notification::get( array(
     
    128159    public function test_bp_activity_remove_screen_notifications_on_mentions() {
    129160        $this->create_notifications();
     161        $this->set_permalink_structure( '/%postname%/' );
    130162
    131163        $notifications = BP_Notifications_Notification::get( array(
     
    137169
    138170        // Go to the My Activity page
    139         $this->go_to( bp_core_get_user_domain( $this->u1 ) . bp_get_activity_slug() . '/mentions/' );
     171        $this->go_to(
     172            bp_members_get_user_url(
     173                $this->u1,
     174                array(
     175                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     176                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_activity_mentions', 'mentions' ),
     177                )
     178            )
     179        );
    140180
    141181        $notifications = BP_Notifications_Notification::get( array(
     
    153193    public function test_bp_activity_remove_screen_notifications_on_mentions_logged_out() {
    154194        $this->create_notifications();
     195        $this->set_permalink_structure( '/%postname%/' );
    155196
    156197        $notifications = BP_Notifications_Notification::get( array(
     
    165206
    166207        // Go to the My Activity page
    167         $this->go_to( bp_core_get_user_domain( $this->u1 ) . bp_get_activity_slug() . '/mentions/' );
     208        $this->go_to(
     209            bp_members_get_user_url(
     210                $this->u1,
     211                array(
     212                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     213                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_activity_mentions', 'mentions' ),
     214                )
     215            )
     216        );
    168217
    169218        $notifications = BP_Notifications_Notification::get( array(
     
    184233    public function test_bp_activity_remove_screen_notifications_on_mentions_wrong_user() {
    185234        $this->create_notifications();
     235        $this->set_permalink_structure( '/%postname%/' );
    186236
    187237        $notifications = BP_Notifications_Notification::get( array(
     
    196246
    197247        // Go to the My Activity page
    198         $this->go_to( bp_core_get_user_domain( $this->u1 ) . bp_get_activity_slug() . '/mentions/' );
     248        $this->go_to(
     249            bp_members_get_user_url(
     250                $this->u1,
     251                array(
     252                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     253                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_activity_mentions', 'mentions' ),
     254                )
     255            )
     256        );
    199257
    200258        $notifications = BP_Notifications_Notification::get( array(
     
    215273    public function test_bp_activity_at_mention_delete_notification() {
    216274        $this->create_notifications();
     275        $this->set_permalink_structure( '/%postname%/' );
    217276
    218277        $notifications = BP_Notifications_Notification::get( array(
  • 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();
  • trunk/tests/phpunit/testcases/core/nav/bpCoreMaybeHookNewSubnavScreenFunction.php

    r11737 r13433  
    55 */
    66class BP_Tests_Core_Nav_BpCoreMaybeHookNewSubnavScreenFunction 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    public function test_user_has_access_true_no_callable_function() {
     
    5769        $old_current_user = get_current_user_id();
    5870        $this->set_current_user( $u );
    59 
    60         $this->go_to( bp_core_get_user_domain( $u ) );
    61 
    62         $subnav_item = array(
    63             'user_has_access' => false,
    64         );
    65 
    66         // Just test relevant info
    67         $found = bp_core_maybe_hook_new_subnav_screen_function( $subnav_item );
    68         $this->assertSame( 'failure', $found['status'] );
    69         $this->assertSame( bp_core_get_user_domain( $u ), $found['redirect_args']['root'] );
     71        $this->set_permalink_structure( '/%postname%/' );
     72
     73        $this->go_to( bp_members_get_user_url( $u ) );
     74
     75        $subnav_item = array(
     76            'user_has_access' => false,
     77        );
     78
     79        // Just test relevant info
     80        $found = bp_core_maybe_hook_new_subnav_screen_function( $subnav_item );
     81        $this->assertSame( 'failure', $found['status'] );
     82        $this->assertSame( bp_members_get_user_url( $u ), $found['redirect_args']['root'] );
    7083
    7184        $this->set_current_user( $old_current_user );
     
    7790        $old_current_user = get_current_user_id();
    7891        $this->set_current_user( $u1 );
    79 
    80         $this->go_to( bp_core_get_user_domain( $u2 ) );
     92        $this->set_permalink_structure( '/%postname%/' );
     93
     94        $this->go_to( bp_members_get_user_url( $u2 ) );
    8195
    8296        $old_bp_nav = buddypress()->bp_nav;
     
    104118
    105119        $this->assertSame( 'failure', $found['status'] );
    106         $this->assertSame( bp_core_get_user_domain( $u2 ), $found['redirect_args']['root'] );
     120        $this->assertSame( bp_members_get_user_url( $u2 ), $found['redirect_args']['root'] );
    107121    }
    108122
     
    112126        $old_current_user = get_current_user_id();
    113127        $this->set_current_user( $u1 );
    114 
    115         $this->go_to( bp_core_get_user_domain( $u2 ) );
     128        $this->set_permalink_structure( '/%postname%/' );
     129
     130        $this->go_to( bp_members_get_user_url( $u2 ) );
    116131
    117132        $old_bp_nav = buddypress()->bp_nav;
     
    140155
    141156        $this->assertSame( 'failure', $found['status'] );
    142         $this->assertSame( bp_core_get_user_domain( $u2 ) . bp_get_activity_slug() . '/', $found['redirect_args']['root'] );
     157        $this->assertSame(
     158            bp_members_get_user_url(
     159                $u2,
     160                array(
     161                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     162                )
     163            ),
     164            $found['redirect_args']['root']
     165        );
    143166    }
    144167
  • 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(
  • trunk/tests/phpunit/testcases/core/nav/bpCoreNewSubnavItem.php

    r12195 r13433  
    1616        $this->set_current_user( $u );
    1717
    18         $user_domain = bp_core_get_user_domain( $u );
     18        $user_domain = bp_members_get_user_url( $u );
    1919
    2020        $this->go_to( $user_domain );
     
    345345        $this->set_current_user( $u );
    346346
    347         $user_domain = bp_core_get_user_domain( $u );
     347        $user_domain = bp_members_get_user_url( $u );
    348348
    349349        // Register a subnav on 'bp_setup_nav' hook early (at priority zero).
  • trunk/tests/phpunit/testcases/core/nav/bpGetNavMenuItems.php

    r11737 r13433  
    66 */
    77class BP_Tests_Core_Nav_BpGetNavMenuItems 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     * @ticket BP7110
     
    1326
    1427        $this->set_current_user( $users[0] );
    15         $user_1_domain = bp_core_get_user_domain( $users[1] );
     28        $this->set_permalink_structure( '/%postname%/' );
     29
     30        $user_1_domain = bp_members_get_user_url( $users[1] );
    1631        $this->go_to( $user_1_domain );
    1732
     
    3752
    3853        $this->set_current_user( 0 );
    39         $user_domain = bp_core_get_user_domain( $user );
     54        $this->set_permalink_structure( '/%postname%/' );
     55
     56        $user_domain = bp_members_get_user_url( $user );
    4057        $this->go_to( $user_domain );
    4158
  • trunk/tests/phpunit/testcases/core/template/bpUserHasAccess.php

    r11737 r13433  
    55 */
    66class BP_Tests_Core_Template_BpUserHasAccess 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    }
     19
    720    public function test_should_return_true_for_bp_moderate_user() {
    821        $users = self::factory()->user->create_many( 2 );
     
    1023        $this->grant_bp_moderate( $users[0] );
    1124        $this->set_current_user( $users[0] );
     25        $this->set_permalink_structure( '/%postname%/' );
    1226
    13         $this->go_to( bp_core_get_user_domain( $users[1] ) );
     27        $this->go_to( bp_members_get_user_url( $users[1] ) );
    1428
    1529        $this->assertTrue( bp_user_has_access( $users[0] ) );
     
    2034
    2135        $this->set_current_user( $users[0] );
     36        $this->set_permalink_structure( '/%postname%/' );
    2237
    23         $this->go_to( bp_core_get_user_domain( $users[1] ) );
     38        $this->go_to( bp_members_get_user_url( $users[1] ) );
    2439
    2540        $this->assertFalse( bp_user_has_access( $users[0] ) );
     
    3045
    3146        $this->set_current_user( $users[0] );
     47        $this->set_permalink_structure( '/%postname%/' );
    3248
    33         $this->go_to( bp_core_get_user_domain( $users[0] ) );
     49        $this->go_to( bp_members_get_user_url( $users[0] ) );
    3450
    3551        $this->assertTrue( bp_user_has_access( $users[0] ) );
  • trunk/tests/phpunit/testcases/members/functions.php

    r13431 r13433  
    55#[AllowDynamicProperties]
    66class BP_Tests_Members_Functions 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    /**
     
    114126     * @group bp_core_get_directory_pages
    115127     */
    116     public function test_bp_core_get_user_domain_after_directory_page_update() {
     128    public function test_bp_members_get_user_url_after_directory_page_update() {
    117129        // Generate user
    118130        $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) );
     131        $this->set_permalink_structure( '/%postname%/' );
    119132
    120133        // Set object cache first for user domain
    121         $user_domain = bp_core_get_user_domain( $user_id );
     134        $user_domain = bp_members_get_user_url( $user_id );
    122135
    123136        // Now change the members directory slug
     
    137150        $user = new WP_User( $user_id );
    138151
    139         $this->assertSame( home_url( $new_members_slug ) . '/' . $user->user_nicename . '/', bp_core_get_user_domain( $user_id ) );
     152        $this->assertSame( home_url( $new_members_slug ) . '/' . $user->user_nicename . '/', bp_members_get_user_url( $user_id ) );
    140153    }
    141154
  • trunk/tests/phpunit/testcases/members/template.php

    r12791 r13433  
    44 */
    55class BP_Tests_Members_Template extends BP_UnitTestCase {
     6    protected $permalink_structure = '';
     7
     8    public function set_up() {
     9        parent::set_up();
     10        $this->permalink_structure = get_option( 'permalink_structure', '' );
     11    }
     12
     13    public function tear_down() {
     14        $this->set_permalink_structure( $this->permalink_structure );
     15
     16        parent::tear_down();
     17    }
     18
    619    public function test_bp_has_members_include_on_user_page() {
    720        $u1 = self::factory()->user->create();
    821        $u2 = self::factory()->user->create();
    9 
    10         $this->go_to( bp_core_get_user_domain( $u1 ) );
     22        $this->set_permalink_structure( '/%postname%/' );
     23
     24        $this->go_to( bp_members_get_user_url( $u1 ) );
    1125
    1226        global $members_template;
     
    5973        $old_user = get_current_user_id();
    6074        $this->set_current_user( $u2 );
    61 
    62         $this->go_to( bp_core_get_user_domain( $u2 ) . bp_get_friends_slug() . '/requests/' );
     75        $this->set_permalink_structure( '/%postname%/' );
     76
     77        $this->go_to(
     78            bp_members_get_user_url(
     79                $u2,
     80                array(
     81                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_friends', bp_get_friends_slug() ),
     82                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_friends_requests', 'requests' ),
     83                )
     84            )
     85        );
    6386        $this->restore_admins();
    6487
     
    86109        $old_user = get_current_user_id();
    87110        $this->set_current_user( $u2 );
     111        $this->set_permalink_structure( '/%postname%/' );
    88112
    89113        // For some reason, in all the user switching, the cache gets
     
    93117        wp_cache_delete( 'bp_user_domain_' . $u2, 'bp' );
    94118
    95         $this->go_to( bp_core_get_user_domain( $u2 ) . bp_get_friends_slug() . '/requests/' );
     119        $this->go_to(
     120            bp_members_get_user_url(
     121                $u2,
     122                array(
     123                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_friends', bp_get_friends_slug() ),
     124                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_friends_requests', 'requests' ),
     125                )
     126            )
     127        );
    96128        $this->restore_admins();
    97129
  • trunk/tests/phpunit/testcases/routing/activity.php

    r13431 r13433  
    66class BP_Tests_Routing_Activity extends BP_UnitTestCase {
    77    protected $old_current_user = 0;
     8    protected $permalink_structure = '';
    89
    910    public function set_up() {
     
    1112
    1213        $this->old_current_user = get_current_user_id();
     14        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1315        $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1416    }
     
    1719        parent::tear_down();
    1820        $this->set_current_user( $this->old_current_user );
     21        $this->set_permalink_structure( $this->permalink_structure );
    1922    }
    2023
    2124    function test_activity_directory() {
     25        $this->set_permalink_structure( '/%postname%/' );
    2226        $this->go_to( bp_get_activity_directory_permalink() );
    2327
     
    3236     */
    3337    function test_activity_permalink() {
     38        $this->set_permalink_structure( '/%postname%/' );
    3439        $a = self::factory()->activity->create();
    3540        $activity = self::factory()->activity->get_object_by_id( $a );
    3641
    37         $url = bp_core_get_user_domain( $activity->user_id ) . bp_get_activity_slug() . '/' . $activity->id . '/';
     42        $url = bp_members_get_user_url(
     43            $activity->user_id,
     44            array(
     45                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     46                'single_item_action'    => $activity->id,
     47            )
     48        );
    3849        $this->go_to( $url );
    3950        $this->assertTrue( bp_is_single_activity() );
     
    4152
    4253    function test_member_activity() {
    43         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() );
     54        $this->set_permalink_structure( '/%postname%/' );
     55        $this->go_to(
     56            bp_members_get_user_url(
     57                bp_loggedin_user_id(),
     58                array(
     59                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     60                )
     61            )
     62        );
    4463        $this->assertTrue( bp_is_user_activity() );
    4564    }
    4665
    4766    function test_member_activity_mentions() {
    48         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() . '/mentions'  );
     67        $this->set_permalink_structure( '/%postname%/' );
     68        $this->go_to(
     69            bp_members_get_user_url(
     70                bp_loggedin_user_id(),
     71                array(
     72                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     73                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_activity_mentions', 'mentions' ),
     74                )
     75            )
     76        );
    4977        $this->assertTrue( bp_is_user_activity() );
    5078    }
    5179
    5280    function test_member_activity_favourites() {
    53         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() . '/favorites'  );
     81        $this->set_permalink_structure( '/%postname%/' );
     82        $this->go_to(
     83            bp_members_get_user_url(
     84                bp_loggedin_user_id(),
     85                array(
     86                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     87                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_activity_favorites', 'favorites' ),
     88                )
     89            )
     90        );
    5491        $this->assertTrue( bp_is_user_activity() );
    5592    }
     
    5996     */
    6097    function test_member_activity_friends() {
    61         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() . '/' . bp_get_friends_slug() );
     98        $this->set_permalink_structure( '/%postname%/' );
     99        $this->go_to(
     100            bp_members_get_user_url(
     101                bp_loggedin_user_id(),
     102                array(
     103                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     104                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_activity_friends', bp_get_friends_slug() ),
     105                )
     106            )
     107        );
    62108        $this->assertTrue( bp_is_user_friends_activity() );
    63109    }
     
    67113     */
    68114    function test_member_activity_groups() {
    69         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_activity_slug() . '/' . bp_get_groups_slug() );
     115        $this->set_permalink_structure( '/%postname%/' );
     116        $this->go_to(
     117            bp_members_get_user_url(
     118                bp_loggedin_user_id(),
     119                array(
     120                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     121                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_activity_groups', bp_get_groups_slug() ),
     122                )
     123            )
     124        );
    70125        $this->assertTrue( bp_is_user_groups_activity() );
    71126    }
  • trunk/tests/phpunit/testcases/routing/friends.php

    r13314 r13433  
    66class BP_Tests_Routing_Friends extends BP_UnitTestCase {
    77    protected $old_current_user = 0;
     8    protected $permalink_structure = '';
    89
    910    public function set_up() {
     
    1112
    1213        $this->old_current_user = get_current_user_id();
     14        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1315        $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1416    }
     
    1719        parent::tear_down();
    1820        $this->set_current_user( $this->old_current_user );
     21        $this->set_permalink_structure( $this->permalink_structure );
    1922    }
    2023
    2124    function test_member_friends() {
    22         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_friends_slug() );
     25        $this->set_permalink_structure( '/%postname%/' );
     26        $this->go_to(
     27            bp_members_get_user_url(
     28                bp_loggedin_user_id(),
     29                array(
     30                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_friends', bp_get_friends_slug() ),
     31                )
     32            )
     33        );
    2334        $this->assertTrue( bp_is_user_friends() );
    2435    }
    2536
    2637    function test_member_friends_requests() {
    27         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_friends_slug()  . '/requests' );
     38        $this->set_permalink_structure( '/%postname%/' );
     39        $this->go_to(
     40            bp_members_get_user_url(
     41                bp_loggedin_user_id(),
     42                array(
     43                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_friends', bp_get_friends_slug() ),
     44                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_friends_requests', 'requests' ),
     45                )
     46            )
     47        );
    2848        $this->assertTrue( bp_is_user_friend_requests() );
    2949    }
  • trunk/tests/phpunit/testcases/routing/groups.php

    r13314 r13433  
    66class BP_Tests_Routing_Groups extends BP_UnitTestCase {
    77    protected $old_current_user = 0;
     8    protected $permalink_structure = '';
    89
    910    public function set_up() {
     
    1213        buddypress()->members->types = array();
    1314        $this->old_current_user = get_current_user_id();
     15        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1416        $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1517    }
     
    1820        parent::tear_down();
    1921        $this->set_current_user( $this->old_current_user );
     22        $this->set_permalink_structure( $this->permalink_structure );
    2023    }
    2124
    2225    function test_member_groups() {
    23         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_groups_slug() );
     26        $this->set_permalink_structure( '/%postname%/' );
     27        $this->go_to(
     28            bp_members_get_user_url(
     29                bp_loggedin_user_id(),
     30                array(
     31                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_groups', bp_get_groups_slug() ),
     32                )
     33            )
     34        );
    2435        $this->assertTrue( bp_is_user_groups() );
    2536    }
    2637
    2738    function test_member_groups_invitations() {
    28         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_groups_slug() . '/invites' );
     39        $this->set_permalink_structure( '/%postname%/' );
     40        $this->go_to(
     41            bp_members_get_user_url(
     42                bp_loggedin_user_id(),
     43                array(
     44                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_groups', bp_get_groups_slug() ),
     45                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_friends_invites', 'invites' ),
     46                )
     47            )
     48        );
    2949        $this->assertTrue( bp_is_user_groups() && bp_is_current_action( 'invites' ) );
    3050    }
     
    3454     */
    3555    public function test_group_directory_with_type() {
     56        $this->set_permalink_structure( '/%postname%/' );
    3657        bp_groups_register_group_type( 'foo' );
    3758        $this->go_to( bp_get_groups_directory_permalink() . 'type/foo/' );
     
    4364     */
    4465    public function test_group_directory_with_type_that_has_custom_directory_slug() {
     66        $this->set_permalink_structure( '/%postname%/' );
    4567        bp_groups_register_group_type( 'foo', array( 'has_directory' => 'foos' ) );
    4668        $this->go_to( bp_get_groups_directory_permalink() . 'type/foos/' );
     
    5274     */
    5375    public function test_group_directory_should_404_for_group_types_that_have_no_directory() {
     76        $this->set_permalink_structure( '/%postname%/' );
    5477        bp_register_member_type( 'foo', array( 'has_directory' => false ) );
    5578        $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
     
    6184     */
    6285    public function test_group_directory_should_404_for_invalid_group_types() {
     86        $this->set_permalink_structure( '/%postname%/' );
    6387        $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
    6488        $this->assertTrue( is_404() );
     
    6993     */
    7094    public function test_group_previous_slug_current_slug_should_resolve() {
     95        $this->set_permalink_structure( '/%postname%/' );
    7196        $g1 = self::factory()->group->create( array(
    7297            'slug' => 'george',
     
    86111     */
    87112    public function test_group_previous_slug_should_resolve() {
     113        $this->set_permalink_structure( '/%postname%/' );
    88114        $g1 = self::factory()->group->create( array(
    89115            'slug' => 'george',
     
    104130     */
    105131    public function test_group_previous_slug_most_recent_takes_precedence() {
     132        $this->set_permalink_structure( '/%postname%/' );
    106133        $g1 = self::factory()->group->create( array(
    107134            'slug' => 'george',
  • trunk/tests/phpunit/testcases/routing/members.php

    r13431 r13433  
    66class BP_Tests_Routing_Members extends BP_UnitTestCase {
    77    protected $old_current_user = 0;
     8    protected $permalink_structure = '';
    89
    910    public function set_up() {
     
    1213        buddypress()->members->types = array();
    1314        $this->old_current_user = get_current_user_id();
     15        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1416        $this->set_current_user( self::factory()->user->create( array( 'user_login' => 'paulgibbs', 'role' => 'subscriber' ) ) );
    1517    }
     
    1719    public function tear_down() {
    1820        $this->set_current_user( $this->old_current_user );
     21        $this->set_permalink_structure( $this->permalink_structure );
    1922        parent::tear_down();
    2023    }
    2124
    2225    function test_members_directory() {
     26        $this->set_permalink_structure( '/%postname%/' );
    2327        $this->go_to( bp_get_members_directory_permalink() );
    2428
     
    3034
    3135    function test_member_permalink() {
    32         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) );
     36        $this->set_permalink_structure( '/%postname%/' );
     37        $this->go_to( bp_members_get_user_url( bp_loggedin_user_id() ) );
    3338        $this->assertTrue( bp_is_my_profile() );
    3439    }
     
    3944     */
    4045    public function test_member_directory_with_member_type() {
     46        $this->set_permalink_structure( '/%postname%/' );
    4147        bp_register_member_type( 'foo' );
    4248        $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
     
    4955     */
    5056    public function test_member_directory_with_member_type_should_obey_filtered_type_slug() {
     57        $this->set_permalink_structure( '/%postname%/' );
    5158        bp_register_member_type( 'foo' );
    5259
     
    6673     */
    6774    public function test_member_directory_with_member_type_that_has_custom_directory_slug() {
     75        $this->set_permalink_structure( '/%postname%/' );
    6876        bp_register_member_type( 'foo', array( 'has_directory' => 'foos' ) );
    6977        $this->go_to( bp_get_members_directory_permalink() . 'type/foos/' );
     
    7684     */
    7785    public function test_member_directory_with_member_type_should_be_overridden_by_member_with_same_nicename() {
     86        $this->set_permalink_structure( '/%postname%/' );
    7887        $u = self::factory()->user->create( array( 'user_nicename' => 'foo' ) );
    7988        bp_register_member_type( 'foo' );
     
    91100     */
    92101    public function test_member_directory_should_404_for_member_types_that_have_no_directory() {
     102        $this->set_permalink_structure( '/%postname%/' );
    93103        bp_register_member_type( 'foo', array( 'has_directory' => false ) );
    94104        $this->go_to( bp_get_members_directory_permalink() . 'type/foo/' );
     
    100110     */
    101111    function test_members_shortlink_redirector() {
     112        $this->set_permalink_structure( '/%postname%/' );
    102113        $shortlink_member_slug = 'me';
    103114
  • trunk/tests/phpunit/testcases/routing/messages.php

    r13314 r13433  
    66class BP_Tests_Routing_Messages extends BP_UnitTestCase {
    77    protected $old_current_user = 0;
     8    protected $permalink_structure = '';
    89
    910    public function set_up() {
     
    1112
    1213        $this->old_current_user = get_current_user_id();
     14        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1315        $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1416    }
     
    1719        parent::tear_down();
    1820        $this->set_current_user( $this->old_current_user );
     21        $this->set_permalink_structure( $this->permalink_structure );
    1922    }
    2023
    2124    function test_member_messages() {
    22         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_messages_slug() );
     25        $this->set_permalink_structure( '/%postname%/' );
     26        $this->go_to(
     27            bp_members_get_user_url(
     28                bp_loggedin_user_id(),
     29                array(
     30                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     31                )
     32            )
     33        );
    2334        $this->assertTrue( bp_is_messages_inbox() );
    2435    }
    2536
    2637    function test_member_messages_sentbox() {
    27         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_messages_slug() . '/sentbox' );
     38        $this->set_permalink_structure( '/%postname%/' );
     39        $this->go_to(
     40            bp_members_get_user_url(
     41                bp_loggedin_user_id(),
     42                array(
     43                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     44                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_messages_sentbox', 'sentbox' ),
     45                )
     46            )
     47        );
    2848        $this->assertTrue( bp_is_messages_sentbox() );
    2949    }
    3050
    3151    function test_member_messages_compose() {
    32         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_messages_slug() . '/compose' );
     52        $this->set_permalink_structure( '/%postname%/' );
     53        $this->go_to(
     54            bp_members_get_user_url(
     55                bp_loggedin_user_id(),
     56                array(
     57                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     58                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_messages_compose', 'compose' ),
     59                )
     60            )
     61        );
    3362        $this->assertTrue( bp_is_messages_compose_screen() );
    3463    }
    3564
    3665    function test_member_messages_notices() {
    37         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_messages_slug() . '/notices' );
     66        $this->set_permalink_structure( '/%postname%/' );
     67        $this->go_to(
     68            bp_members_get_user_url(
     69                bp_loggedin_user_id(),
     70                array(
     71                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_messages', bp_get_messages_slug() ),
     72                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_messages_notices', 'notices' ),
     73                )
     74            )
     75        );
    3876        $this->assertTrue( bp_is_notices() );
    3977    }
  • trunk/tests/phpunit/testcases/routing/settings.php

    r13314 r13433  
    66class BP_Tests_Routing_Settings extends BP_UnitTestCase {
    77    protected $old_current_user = 0;
     8    protected $permalink_structure = '';
    89
    910    public function set_up() {
     
    1112
    1213        $this->old_current_user = get_current_user_id();
     14        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1315        $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1416    }
     
    1719        parent::tear_down();
    1820        $this->set_current_user( $this->old_current_user );
     21        $this->set_permalink_structure( $this->permalink_structure );
    1922    }
    2023
    2124    function test_member_settings() {
    22         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() );
     25        $this->set_permalink_structure( '/%postname%/' );
     26        $this->go_to(
     27            bp_members_get_user_url(
     28                bp_loggedin_user_id(),
     29                array(
     30                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     31                )
     32            )
     33        );
    2334        $this->assertTrue( bp_is_user_settings_general() );
    2435    }
    2536
    2637    function test_member_settings_notifications() {
    27         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() . '/notifications' );
     38        $this->set_permalink_structure( '/%postname%/' );
     39        $this->go_to(
     40            bp_members_get_user_url(
     41                bp_loggedin_user_id(),
     42                array(
     43                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     44                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_settings_notifications', 'notifications' ),
     45                )
     46            )
     47        );
    2848        $this->assertTrue( bp_is_user_settings_notifications() );
    2949    }
     
    3151    // @todo How best to test this?
    3252    /*function bp_is_user_settings_account_capbilities() {
    33         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() . '/capabilities' );
     53        $this->set_permalink_structure( '/%postname%/' );
     54        $this->go_to(
     55            bp_members_get_user_url(
     56                bp_loggedin_user_id(),
     57                array(
     58                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     59                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_settings_capabilities', 'capabilities' ),
     60                )
     61            )
     62        );
    3463    }*/
    3564
    3665    function bp_is_user_settings_account_delete() {
    37         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_settings_slug() . '/delete-account' );
     66        $this->set_permalink_structure( '/%postname%/' );
     67        $this->go_to(
     68            bp_members_get_user_url(
     69                bp_loggedin_user_id(),
     70                array(
     71                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_settings', bp_get_settings_slug() ),
     72                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_settings_delete_account', 'delete-account' ),
     73                )
     74            )
     75        );
    3876        $this->assertTrue( bp_is_user_settings_account_delete() );
    3977    }
  • trunk/tests/phpunit/testcases/routing/xprofile.php

    r13314 r13433  
    66class BP_Tests_Routing_XProfile extends BP_UnitTestCase {
    77    protected $old_current_user = 0;
     8    protected $permalink_structure = '';
    89
    910    public function set_up() {
     
    1112
    1213        $this->old_current_user = get_current_user_id();
     14        $this->permalink_structure = get_option( 'permalink_structure', '' );
    1315        $this->set_current_user( self::factory()->user->create( array( 'role' => 'subscriber' ) ) );
    1416    }
     
    1719        parent::tear_down();
    1820        $this->set_current_user( $this->old_current_user );
     21        $this->set_permalink_structure( $this->permalink_structure );
    1922    }
    2023
    2124    function test_member_profile() {
    22         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_profile_slug() );
     25        $this->set_permalink_structure( '/%postname%/' );
     26        $this->go_to(
     27            bp_members_get_user_url(
     28                bp_loggedin_user_id(),
     29                array(
     30                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_profile', bp_get_profile_slug() ),
     31                )
     32            )
     33        );
    2334        $this->assertTrue( bp_is_user_profile() );
    2435    }
    2536
    2637    function test_member_profile_edit() {
    27         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_profile_slug() . '/edit' );
     38        $this->set_permalink_structure( '/%postname%/' );
     39        $this->go_to(
     40            bp_members_get_user_url(
     41                bp_loggedin_user_id(),
     42                array(
     43                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_profile', bp_get_profile_slug() ),
     44                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_profile_edit', 'edit' ),
     45                )
     46            )
     47        );
    2848        $this->assertTrue( bp_is_user_profile_edit() );
    2949    }
    3050
    3151    function test_member_profile_change_avatar() {
    32         $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_profile_slug() . '/change-avatar' );
     52        $this->set_permalink_structure( '/%postname%/' );
     53        $this->go_to(
     54            bp_members_get_user_url(
     55                bp_loggedin_user_id(),
     56                array(
     57                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_profile', bp_get_profile_slug() ),
     58                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_profile_change_avatar', 'change-avatar' ),
     59                )
     60            )
     61        );
    3362        $this->assertTrue( bp_is_user_change_avatar() );
    3463    }
  • trunk/tests/phpunit/testcases/xprofile/activity.php

    r13314 r13433  
    307307        ) );
    308308
    309         $expected = sprintf( esc_html__( "%s's profile was updated", 'buddypress' ), '<a href="' . bp_core_get_user_domain( $u ) . bp_get_profile_slug() . '/">' . bp_core_get_user_displayname( $u ) . '</a>' );
     309        $link     = bp_members_get_user_url(
     310            $u,
     311            array(
     312                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_profile', bp_get_profile_slug() ),
     313            )
     314        );
     315        $expected = sprintf( esc_html__( "%s's profile was updated", 'buddypress' ), '<a href="' . esc_url( $link ) . '">' . bp_core_get_user_displayname( $u ) . '</a>' );
    310316
    311317        $a_obj = new BP_Activity_Activity( $a );
Note: See TracChangeset for help on using the changeset viewer.