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

    r13495 r13503  
    300300
    301301            // Setup the logged in user variables.
    302             $blogs_slug        = bp_get_blogs_slug();
    303             $custom_blogs_slug = bp_rewrites_get_slug( 'members', 'member_' . $blogs_slug, $blogs_slug );
     302            $blogs_slug = bp_get_blogs_slug();
    304303
    305304            // Add the "Sites" sub menu.
     
    308307                'id'     => 'my-account-' . $this->id,
    309308                'title'  => __( 'Sites', 'buddypress' ),
    310                 'href'   => bp_loggedin_user_url(
    311                     array(
    312                         'single_item_component' => $custom_blogs_slug,
    313                     )
    314                 ),
     309                'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $blogs_slug ) ) ),
    315310            );
    316311
     
    320315                'id'       => 'my-account-' . $this->id . '-my-sites',
    321316                'title'    => __( 'My Sites', 'buddypress' ),
    322                 'href'     => bp_loggedin_user_url(
    323                     array(
    324                         'single_item_component' => $custom_blogs_slug,
    325                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $blogs_slug . '_my_sites', 'my-sites' ),
    326                     )
    327                 ),
     317                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $blogs_slug, 'my-sites' ) ) ),
    328318                'position' => 10,
    329319            );
Note: See TracChangeset for help on using the changeset viewer.