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-notifications/classes/class-bp-notifications-component.php

    r13495 r13503  
    232232        // Menus for logged in user.
    233233        if ( is_user_logged_in() ) {
    234             $notifications_slug        = bp_get_notifications_slug();
    235             $custom_notifications_slug = bp_rewrites_get_slug( 'members', 'member_' . $notifications_slug, $notifications_slug );
     234            $notifications_slug = bp_get_notifications_slug();
    236235
    237236            // Pending notification requests.
     
    258257                'id'     => 'my-account-' . $this->id,
    259258                'title'  => $title,
    260                 'href'   => bp_loggedin_user_url(
    261                     array(
    262                         'single_item_component' => $custom_notifications_slug,
    263                     )
    264                 ),
     259                'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $notifications_slug ) ) ),
    265260            );
    266261
     
    270265                'id'       => 'my-account-' . $this->id . '-unread',
    271266                'title'    => $unread,
    272                 'href'     => bp_loggedin_user_url(
    273                     array(
    274                         'single_item_component' => $custom_notifications_slug,
    275                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $notifications_slug . '_unread', 'unread' ),
    276                     )
    277                 ),
     267                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $notifications_slug, 'unread' ) ) ),
    278268                'position' => 10,
    279269            );
     
    284274                'id'       => 'my-account-' . $this->id . '-read',
    285275                'title'    => _x( 'Read', 'My Account Notification sub nav', 'buddypress' ),
    286                 'href'     => bp_loggedin_user_url(
    287                     array(
    288                         'single_item_component' => $custom_notifications_slug,
    289                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $notifications_slug . '_read', 'read' ),
    290                     )
    291                 ),
     276                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $notifications_slug, 'read' ) ) ),
    292277                'position' => 20,
    293278            );
Note: See TracChangeset for help on using the changeset viewer.