Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/18/2023 04:11:04 AM (3 years ago)
Author:
imath
Message:

BP Rewrites: optimize the code used to build URLs

The bp_members_get_path_chunks() & bp_groups_get_path_chunks() functions are making sure URL chunks are customized according to the slugs settings. Instead of redoing at many places all or some of the operations performed by these functions, update the code to build URLs so that it uses these functions.

See #4954
Fixes #8923
Closes https://github.com/buddypress/buddypress/pull/117

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-friends/classes/class-bp-friends-component.php

    r13495 r13503  
    242242
    243243            // Setup the logged in user variables.
    244             $friends_slug        = bp_get_friends_slug();
    245             $custom_friends_slug = bp_rewrites_get_slug( 'members', 'member_' . $friends_slug, $friends_slug );
     244            $friends_slug = bp_get_friends_slug();
    246245
    247246            // Pending friend requests.
     
    268267                'id'     => 'my-account-' . $this->id,
    269268                'title'  => $title,
    270                 'href'   => bp_loggedin_user_url(
    271                     array(
    272                         'single_item_component' => $custom_friends_slug,
    273                     )
    274                 ),
     269                'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $friends_slug ) ) ),
    275270            );
    276271
     
    280275                'id'       => 'my-account-' . $this->id . '-friendships',
    281276                'title'    => _x( 'Friendships', 'My Account Friends menu sub nav', 'buddypress' ),
    282                 'href'     => bp_loggedin_user_url(
    283                     array(
    284                         'single_item_component' => $custom_friends_slug,
    285                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_my_friends', 'my-friends' ),
    286                     )
    287                 ),
     277                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $friends_slug, 'my-friends' ) ) ),
    288278                'position' => 10,
    289279            );
     
    294284                'id'       => 'my-account-' . $this->id . '-requests',
    295285                'title'    => $pending,
    296                 'href'     => bp_loggedin_user_url(
    297                     array(
    298                         'single_item_component' => $custom_friends_slug,
    299                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests', 'requests' ),
    300                     )
    301                 ),
     286                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $friends_slug, 'requests' ) ) ),
    302287                'position' => 20,
    303288            );
Note: See TracChangeset for help on using the changeset viewer.