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/bp-xprofile-template.php

    r13484 r13503  
    408408
    409409        // Build the form action URL.
    410         $profile_slug = bp_get_profile_slug();
    411         $path_chunks  = array(
    412             'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug ),
    413             'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit', 'edit' ),
    414             'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit_group', 'group' ), $group->id ),
    415         );
    416         $form_action = bp_displayed_user_url( $path_chunks );
     410        $form_action = bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_profile_slug(), 'edit', array( 'group', $group->id ) ) ) );
    417411
    418412        /**
     
    11291123
    11301124        // Build the profile field group link.
    1131         $profile_slug = bp_get_profile_slug();
    1132         $path_chunks  = array(
    1133             'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug ),
    1134             'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit', 'edit' ),
    1135             'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit_group', 'group' ), $groups[ $i ]->id ),
    1136         );
    1137         $link         = bp_displayed_user_url( $path_chunks );
     1125        $link = bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_profile_slug(), 'edit', array( 'group', $groups[ $i ]->id ) ) ) );
    11381126
    11391127        // Add tab to end of tabs array.
     
    12931281 */
    12941282function bp_edit_profile_button() {
    1295     $profile_slug = bp_get_profile_slug();
    1296     $path_chunks  = array(
    1297         'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug ),
    1298         'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit', 'edit' ),
    1299     );
    1300 
    13011283    bp_button( array(
    13021284        'id'                => 'edit_profile',
     
    13041286        'must_be_logged_in' => true,
    13051287        'block_self'        => true,
    1306         'link_href'         => bp_displayed_user_url( $path_chunks ),
     1288        'link_href'         => bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_profile_slug(), 'edit' ) ) ),
    13071289        'link_class'        => 'edit',
    13081290        'link_text'         => __( 'Edit Profile', 'buddypress' ),
Note: See TracChangeset for help on using the changeset viewer.