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

    r13492 r13503  
    765765            if ( bp_is_item_admin() ) {
    766766                // Get the "manage" screens.
    767                 $manage_screens    = bp_get_group_screens( 'manage', true );
    768                 $admin_link        = bp_get_group_url(
    769                     $this->current_group,
    770                     array(
    771                         'single_item_action' => bp_rewrites_get_slug( 'groups', 'bp_group_read_admin', 'admin' ),
    772                     )
    773                 );
     767                $manage_screens = bp_get_group_screens( 'manage', true );
    774768
    775769                // Common params to all nav items.
     
    840834
    841835            // Setup the logged in user variables.
    842             $groups_slug        = bp_get_groups_slug();
    843             $custom_groups_slug = bp_rewrites_get_slug( 'members', 'member_' . $groups_slug, $groups_slug );
     836            $groups_slug = bp_get_groups_slug();
    844837
    845838            $title   = _x( 'Groups', 'My Account Groups', 'buddypress' );
     
    869862                'id'     => 'my-account-' . $this->id,
    870863                'title'  => $title,
    871                 'href'   => bp_loggedin_user_url(
    872                     array(
    873                         'single_item_component' => $custom_groups_slug,
    874                     )
    875                 ),
     864                'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $groups_slug ) ) ),
    876865            );
    877866
     
    881870                'id'       => 'my-account-' . $this->id . '-memberships',
    882871                'title'    => _x( 'Memberships', 'My Account Groups sub nav', 'buddypress' ),
    883                 'href'     => bp_loggedin_user_url(
    884                     array(
    885                         'single_item_component' => $custom_groups_slug,
    886                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_my_groups', 'my-groups' ),
    887                     )
    888                 ),
     872                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $groups_slug, 'my-groups' ) ) ),
    889873                'position' => 10,
    890874            );
     
    896880                    'id'       => 'my-account-' . $this->id . '-invites',
    897881                    'title'    => $pending,
    898                     'href'     => bp_loggedin_user_url(
    899                         array(
    900                             'single_item_component' => $custom_groups_slug,
    901                             'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites', 'invites' ),
    902                         )
    903                     ),
     882                    'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $groups_slug, 'invites' ) ) ),
    904883                    'position' => 30,
    905884                );
Note: See TracChangeset for help on using the changeset viewer.