Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/18/2023 04:11:04 AM (2 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-members/bp-members-adminbar.php

    r13493 r13503  
    211211
    212212    if ( bp_current_user_can( 'bp_members_invitations_view_screens' ) ) {
    213         $bp                 = buddypress();
    214         $invite_slug        = bp_get_members_invitations_slug();
    215         $custom_invite_slug = bp_rewrites_get_slug( 'members', 'member_' . $invite_slug, $invite_slug );
     213        $bp          = buddypress();
     214        $invite_slug = bp_get_members_invitations_slug();
    216215
    217216        $wp_admin_bar->add_node(
     
    220219                'parent' => $bp->my_account_menu_id,
    221220                'title'  => __( 'Invitations', 'buddypress' ),
    222                 'href'   => bp_loggedin_user_url(
    223                     array(
    224                         'single_item_component' => $custom_invite_slug,
    225                     )
    226                 ),
     221                'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $invite_slug ) ) ),
    227222                'meta'   => array(
    228223                    'class'  => 'ab-sub-secondary'
     
    237232                    'parent' => $bp->my_account_menu_id . '-invitations',
    238233                    'title'  => __( 'Send Invites', 'buddypress' ),
    239                     'href'   => bp_loggedin_user_url(
    240                         array(
    241                             'single_item_component' => $custom_invite_slug,
    242                             'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $invite_slug . '_send_invites', 'send-invites' ),
    243                         )
    244                     ),
     234                    'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $invite_slug, 'send-invites' ) ) ),
    245235                    'meta'   => array(
    246236                        'class'  => 'ab-sub-secondary'
     
    255245                'parent' => $bp->my_account_menu_id . '-invitations',
    256246                'title'  => __( 'Pending Invites', 'buddypress' ),
    257                 'href'   => bp_loggedin_user_url(
    258                     array(
    259                         'single_item_component' => $custom_invite_slug,
    260                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $invite_slug . '_list_invites', 'list-invites' ),
    261                     )
    262                 ),
     247                'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $invite_slug, 'list-invites' ) ) ),
    263248                'meta'   => array(
    264249                    'class'  => 'ab-sub-secondary'
Note: See TracChangeset for help on using the changeset viewer.