Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/18/2023 04:11:04 AM (18 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-settings/actions/general.php

    r13443 r13503  
    5151    $feedback      = array();                // array of strings for feedback.
    5252    $user_id       = bp_displayed_user_id(); // The ID of the user being displayed.
    53     $settings_slug = bp_get_settings_slug();
    54     $path_chunks   = array(
    55         'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $settings_slug, $settings_slug ),
    56     );
     53    $path_chunks   = array( bp_get_settings_slug() );
    5754
    5855    // Nonce check.
     
    235232
    236233    // Set the URL to redirect the user to.
    237     $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'members', 'member_' . $settings_slug . '_general', 'general' );
    238     $redirect_to = bp_displayed_user_url( $path_chunks );
     234    $path_chunks[] = 'general';
     235    $redirect_to   = bp_displayed_user_url( bp_members_get_path_chunks( $path_chunks ) );
    239236
    240237    /**
     
    271268    }
    272269
    273     $settings_slug = bp_get_settings_slug();
    274     $path_chunks   = array(
    275         'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $settings_slug, $settings_slug )
    276     );
    277     $redirect_to = bp_displayed_user_url( $path_chunks );
     270    $redirect_to = bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_settings_slug() ) ) );
    278271
    279272    // Email change is being verified.
Note: See TracChangeset for help on using the changeset viewer.