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

    r13496 r13503  
    29452945    function bp_get_group_form_action( $page, $group = false ) {
    29462946        $group = bp_get_group( $group );
     2947        $url   = '';
    29472948
    29482949        if ( empty( $group->id ) || empty( $page ) ) {
    2949             return '';
     2950            return $url;
    29502951        }
    29512952
    29522953        $screens = bp_get_group_screens( 'read' );
    29532954        if ( isset( $screens[ $page ]['rewrite_id'] ) ) {
    2954             $page = bp_rewrites_get_slug( 'groups', $screens[ $page ]['rewrite_id'], $page );
    2955         }
    2956 
    2957         $url = bp_get_group_url(
    2958             $group,
    2959             array(
    2960                 'single_item_action' => $page,
    2961             )
    2962         );
     2955            $url = bp_get_group_url(
     2956                $group,
     2957                bp_groups_get_path_chunks( array( $page ) )
     2958            );
     2959        }
    29632960
    29642961        /**
     
    30012998    function bp_get_group_admin_form_action( $page = false, $group = false ) {
    30022999        $group = bp_get_group( $group );
     3000        $url   = '';
    30033001
    30043002        if ( empty( $group->id ) ) {
    3005             return '';
     3003            return $url;
    30063004        }
    30073005
     
    30123010        $screens = bp_get_group_screens( 'manage' );
    30133011        if ( isset( $screens[ $page ]['rewrite_id'] ) ) {
    3014             $page = bp_rewrites_get_slug( 'groups', $screens[ $page ]['rewrite_id'], $page );
    3015         }
    3016 
    3017         $url = bp_get_group_url(
    3018             $group,
    3019             array(
    3020                 'single_item_action'           => bp_rewrites_get_slug( 'groups', 'bp_group_read_admin', 'admin' ),
    3021                 'single_item_action_variables' => $page,
    3022             )
    3023         );
     3012            $url = bp_get_group_manage_url(
     3013                $group,
     3014                bp_groups_get_path_chunks( array( $page ), 'manage' )
     3015            );
     3016        }
    30243017
    30253018        /**
     
    32123205        }
    32133206
    3214         $groups_slug = bp_get_groups_slug();
    3215         $path_chunks = array(
    3216             'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug, $groups_slug ),
    3217             'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites', 'invites' ),
    3218             'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites_accept', 'accept' ), $group->id ),
    3219         );
     3207        $path_chunks = bp_members_get_path_chunks( array( bp_get_groups_slug(), 'invites', array( 'accept', $group->id ) ) );
    32203208
    32213209        if ( bp_is_user() ) {
     
    32653253        }
    32663254
    3267         $groups_slug = bp_get_groups_slug();
    3268         $path_chunks = array(
    3269             'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug, $groups_slug ),
    3270             'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites', 'invites' ),
    3271             'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites_reject', 'reject' ), $group->id ),
    3272         );
     3255        $path_chunks = bp_members_get_path_chunks( array( bp_get_groups_slug(), 'invites', array( 'reject', $group->id ) ) );
    32733256
    32743257        if ( bp_is_user() ) {
Note: See TracChangeset for help on using the changeset viewer.