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

    r13499 r13503  
    534534     */
    535535    public function get_avatar_cover_image_admin_navs( $admin_bar_menu_id = '' ) {
    536         $wp_admin_nav        = array();
    537         $profile_slug        = bp_get_profile_slug();
    538         $custom_profile_slug = bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug );
     536        $wp_admin_nav = array();
     537        $profile_slug = bp_get_profile_slug();
    539538
    540539        if ( ! $admin_bar_menu_id ) {
     
    548547                'id'       => 'my-account-' . $admin_bar_menu_id . '-change-avatar',
    549548                'title'    => _x( 'Change Profile Photo', 'My Account Profile sub nav', 'buddypress' ),
    550                 'href'     => bp_loggedin_user_url(
    551                     array(
    552                         'single_item_component' => $custom_profile_slug,
    553                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_change_avatar', 'change-avatar' ),
    554                     )
    555                 ),
     549                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug, 'change-avatar' ) ) ),
    556550                'position' => 30,
    557551            );
     
    564558                'id'       => 'my-account-' . $admin_bar_menu_id . '-change-cover-image',
    565559                'title'    => _x( 'Change Cover Image', 'My Account Profile sub nav', 'buddypress' ),
    566                 'href'     => bp_loggedin_user_url(
    567                     array(
    568                         'single_item_component' => $custom_profile_slug,
    569                         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_change_cover_image', 'change-cover-image' ),
    570                     )
    571                 ),
     560                'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug, 'change-cover-image' ) ) ),
    572561                'position' => 40,
    573562            );
     
    587576        // Menus for logged in user.
    588577        if ( is_user_logged_in() ) {
    589             $profile_slug        = bp_get_profile_slug();
    590             $custom_profile_slug = bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug );
     578            $profile_slug = bp_get_profile_slug();
    591579
    592580            if ( ! bp_is_active( 'xprofile' ) ) {
     
    596584                    'id'     => 'my-account-' . $this->id,
    597585                    'title'  => _x( 'Profile', 'My Account Profile', 'buddypress' ),
    598                     'href'   => bp_loggedin_user_url(
    599                         array(
    600                             'single_item_component' => $custom_profile_slug,
    601                         )
    602                     ),
     586                    'href'   => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug ) ) ),
    603587                );
    604588
     
    608592                    'id'       => 'my-account-' . $this->id . '-public',
    609593                    'title'    => _x( 'View', 'My Account Profile sub nav', 'buddypress' ),
    610                     'href'     => bp_loggedin_user_url(
    611                         array(
    612                             'single_item_component' => $custom_profile_slug,
    613                             'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_public', 'public' ),
    614                         )
    615                     ),
     594                    'href'     => bp_loggedin_user_url( bp_members_get_path_chunks( array( $profile_slug, 'public' ) ) ),
    616595                    'position' => 10,
    617596                );
Note: See TracChangeset for help on using the changeset viewer.