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

    r13495 r13503  
    289289        if ( is_user_logged_in() ) {
    290290            $profile_slug = bp_get_profile_slug();
    291             $path_chunks  = array(
    292                 'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug ),
    293             );
    294291
    295292            // Add the "Profile" sub menu.
     
    298295                'id'     => 'my-account-' . $this->id,
    299296                'title'  => _x( 'Profile', 'My Account Profile', 'buddypress' ),
    300                 'href'   => bp_loggedin_user_url( $path_chunks ),
     297                'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug ) ) ),
    301298            );
    302 
    303             $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_public', 'public' );
    304299
    305300            // View Profile.
     
    308303                'id'       => 'my-account-' . $this->id . '-public',
    309304                'title'    => _x( 'View', 'My Account Profile sub nav', 'buddypress' ),
    310                 'href'     => bp_loggedin_user_url( $path_chunks ),
     305                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug, 'public' ) ) ),
    311306                'position' => 10,
    312307            );
    313 
    314             $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit', 'edit' );
    315308
    316309            // Edit Profile.
     
    319312                'id'       => 'my-account-' . $this->id . '-edit',
    320313                'title'    => _x( 'Edit', 'My Account Profile sub nav', 'buddypress' ),
    321                 'href'     => bp_loggedin_user_url( $path_chunks ),
     314                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug, 'edit' ) ) ),
    322315                'position' => 20,
    323316            );
     
    392385     */
    393386    public function setup_settings_admin_nav( $wp_admin_nav ) {
    394 
    395         // Setup the logged in user variables.
    396         $settings_slug = bp_get_settings_slug();
    397         $path_chunks   = array(
    398             'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $settings_slug, $settings_slug ),
    399             'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $settings_slug . '_profile', 'profile' ),
    400         );
    401 
    402387        // Add the "Profile" subnav item.
    403388        $wp_admin_nav[] = array(
     
    405390            'id'     => 'my-account-' . buddypress()->settings->id . '-profile',
    406391            'title'  => _x( 'Profile', 'My Account Settings sub nav', 'buddypress' ),
    407             'href'   => bp_loggedin_user_url( $path_chunks ),
     392            'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_settings_slug(), 'profile' ) ) ),
    408393        );
    409394
Note: See TracChangeset for help on using the changeset viewer.