Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/18/2023 04:11:04 AM (16 months 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/bp-friends-notifications.php

    r13441 r13503  
    2929 */
    3030function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
    31     $friends_slug        = bp_get_friends_slug();
    32     $custom_friends_slug = bp_rewrites_get_slug( 'members', 'member_' . $friends_slug, $friends_slug );
     31    $friends_slug = bp_get_friends_slug();
    3332
    3433    switch ( $action ) {
    3534        case 'friendship_accepted':
    36             $link = bp_loggedin_user_url(
    37                 array(
    38                     'single_item_component' => $custom_friends_slug,
    39                     'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_my_friends', 'my-friends' ),
    40                 )
    41             );
     35            $link = bp_loggedin_user_url( bp_members_get_path_chunks( array( $friends_slug, 'my-friends' ) ) );
    4236
    4337            // $action and $amount are used to generate dynamic filter names.
     
    6155                'new',
    6256                1,
    63                 bp_loggedin_user_url(
    64                     array(
    65                         'single_item_component' => $custom_friends_slug,
    66                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests', 'requests' ),
    67                     )
    68                 )
     57                bp_loggedin_user_url( bp_members_get_path_chunks( array( $friends_slug, 'requests' ) ) )
    6958            );
    7059
Note: See TracChangeset for help on using the changeset viewer.