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/screens/edit.php

    r13468 r13503  
    2121    }
    2222
    23     $profile_slug = bp_get_profile_slug();
    24     $path_chunks  = array(
    25         'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug ),
    26         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit', 'edit' ),
    27     );
    28 
    29 
    3023    // Make sure a group is set.
    3124    if ( ! bp_action_variable( 1 ) ) {
    32         $path_chunks['single_item_action_variables'] = array( bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit_group', 'group' ), 1 );
    33         bp_core_redirect( bp_displayed_user_url( $path_chunks ) );
     25        bp_core_redirect(
     26            bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_profile_slug(), 'edit', array( 'group', 1 ) ) ) )
     27        );
    3428    }
    3529
     
    4135
    4236    // No errors.
    43     $errors = false;
     37    $errors      = false;
     38    $path_chunks = array( bp_get_profile_slug(), 'edit' );
    4439
    4540    // Check to see if any new information has been submitted.
     
    5146        // Check we have field ID's.
    5247        if ( empty( $_POST['field_ids'] ) ) {
    53             $path_chunks['single_item_action_variables'] = array( bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit_group', 'group' ), bp_action_variable( 1 ) );
    54             bp_core_redirect( bp_displayed_user_url( $path_chunks ) );
     48            $path_chunks[] = array( 'group', bp_action_variable( 1 ) );
     49            bp_core_redirect( bp_displayed_user_url( bp_members_get_path_chunks( $path_chunks ) ) );
    5550        }
    5651
     
    165160
    166161            // Redirect back to the edit screen to display the updates and message.
    167             $path_chunks['single_item_action_variables'] = array( bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit_group', 'group' ), bp_action_variable( 1 ) );
    168             bp_core_redirect( bp_displayed_user_url( $path_chunks ) );
     162            $path_chunks[] = array( 'group', bp_action_variable( 1 ) );
     163            bp_core_redirect( bp_displayed_user_url( bp_members_get_path_chunks( $path_chunks ) ) );
    169164        }
    170165    }
Note: See TracChangeset for help on using the changeset viewer.