Skip to:
Content

BuddyPress.org

Changeset 13446


Ignore:
Timestamp:
04/04/2023 01:06:03 AM (3 years ago)
Author:
imath
Message:

Use the BP Rewrites API to generate single Groups item links

  • Introduce the bp_groups_get_path_chunks() function to build BP Rewrites arguments using a regular array.
  • Improve bp_members_get_path_chunks() so that it avoids looking for a custom slug when the chunk is a numeric value.
  • Introduce the bp_get_group_manage_url() function to build Group's front-end Admin URLs using BP Rewrites.
  • Deprecate bp_group_admin_permalink() & bp_get_group_admin_permalink() in favor of bp_group_manage_url() & bp_get_group_manage_url().
  • Replace all remaining usage of bp_get_group_permalink() in favor of bp_get_group_url() or bp_get_group_manage_url().

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/81
See #4954

Location:
trunk/src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/screens/permalink.php

    r13441 r13446  
    5656                        // Set redirect to group activity stream.
    5757                        if ( $group = groups_get_group( $activity->item_id ) ) {
    58                                 $redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity->id . '/';
     58                                $path_chunks = bp_groups_get_path_chunks( array( bp_get_activity_slug(), $activity->id ) );
     59                                $redirect    = bp_get_group_url( $group, $path_chunks );
    5960                        }
    6061                }
  • trunk/src/bp-core/deprecated/12.0.php

    r13443 r13446  
    297297        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_displayed_user_url()' );
    298298        bp_displayed_user_url();
     299}
     300
     301/**
     302 * Output the permalink for the group.
     303 *
     304 * @since 1.0.0
     305 * @deprecated 12.0.0
     306 *
     307 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
     308 *                                                Default: false.
     309 */
     310function bp_group_permalink( $group = false ) {
     311        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_group_url' );
     312        bp_group_url( $group );
     313}
     314/**
     315 * Return the permalink for the group.
     316 *
     317 * @since 1.0.0
     318 * @since 10.0.0 Updated to use `bp_get_group`.
     319 * @deprecated 12.0.0
     320 *
     321 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
     322 *                                                Default: false.
     323 * @return string
     324 */
     325function bp_get_group_permalink( $group = false ) {
     326        $url = bp_get_group_url( $group );
     327
     328        /**
     329         * Filters the permalink for the group.
     330         *
     331         * @since 1.0.0
     332         * @since 2.5.0 Added the `$group` parameter.
     333         * @deprecated 12.0.0
     334         *
     335         * @param string          $url   Permalink for the group.
     336         * @param BP_Groups_Group $group The group object.
     337         */
     338        return apply_filters_deprecated( 'bp_get_group_permalink', array( $url, $group ), '12.0.0', 'bp_get_group_url' );
     339}
     340
     341/**
     342 * Output the permalink for the admin section of the group.
     343 *
     344 * @since 1.0.0
     345 * @deprecated 12.0.0
     346 *
     347 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
     348 *                                                Default: false.
     349 */
     350function bp_group_admin_permalink( $group = false ) {
     351        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_group_manage_url' );
     352        bp_group_manage_url( $group );
     353}
     354
     355/**
     356 * Return the permalink for the admin section of the group.
     357 *
     358 * @since 1.0.0
     359 * @since 10.0.0 Updated to use `bp_get_group`.
     360 * @deprecated 12.0.0
     361 *
     362 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
     363 *                                                Default: false.
     364 * @return string
     365 */
     366function bp_get_group_admin_permalink( $group = false ) {
     367        _deprecated_function( __FUNCTION__, '12.0.0', 'bp_get_group_manage_url' );
     368        $permalink = bp_get_group_manage_url( $group );
     369
     370        /**
     371         * Filters the permalink for the admin section of the group.
     372         *
     373         * @since 1.0.0
     374         * @since 2.5.0 Added the `$group` parameter.
     375         * @deprecated 12.0.0
     376         *
     377         * @param string          $permalink Permalink for the admin section of the group.
     378         * @param BP_Groups_Group $group     The group object.
     379         */
     380        return apply_filters_deprecated( 'bp_get_group_admin_permalink', array( $permalink, $group ), '12.0.0', 'bp_get_group_manage_url' );
    299381}
    300382
  • trunk/src/bp-groups/actions/access.php

    r13437 r13446  
    3333                        $no_access_args = array(
    3434                                'message'  => __( 'You do not have access to this group.', 'buddypress' ),
    35                                 'root'     => bp_get_group_permalink( $current_group ) . 'home/',
     35                                'root'     => bp_get_group_url(
     36                                        $current_group,
     37                                        bp_groups_get_path_chunks( array( 'home' ) )
     38                                ),
    3639                                'redirect' => false
    3740                        );
  • trunk/src/bp-groups/bp-groups-functions.php

    r13437 r13446  
    38363836                                'position'        => 10,
    38373837                                'item_css_id'     => 'home',
     3838                        ),
     3839                        'activity'            => array(
     3840                                'rewrite_id'      => 'bp_group_read_activity',
     3841                                'slug'            => 'activity',
     3842                                'name'            => _x( 'Activity', 'Group read screen', 'buddypress' ),
     3843                                'screen_function' => 'groups_screen_group_activity',
     3844                                'position'        => 11,
     3845                                'user_has_access' => false,
     3846                                'no_access_url'   => '',
     3847                                'item_css_id'     => 'activity',
    38383848                        ),
    38393849                        'request-membership' => array(
     
    39803990        return $context_screens;
    39813991}
     3992
     3993/**
     3994 * Get single group's path chunks using an array of URL slugs.
     3995 *
     3996 * @since 12.0.0
     3997 *
     3998 * @param array $chunks An array of URL slugs.
     3999 * @return array An array of BP Rewrites URL arguments.
     4000 */
     4001function bp_groups_get_path_chunks( $chunks = array(), $context = 'read' ) {
     4002        $path_chunks   = array();
     4003        $group_screens = bp_get_group_screens( $context );
     4004
     4005        if ( 'read' === $context ) {
     4006                $single_item_action = array_shift( $chunks );
     4007                if ( $single_item_action ) {
     4008                        if ( isset( $group_screens[ $single_item_action ]['rewrite_id'] ) ) {
     4009                                $item_action_rewrite_id            = $group_screens[ $single_item_action ]['rewrite_id'];
     4010                                $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'groups', $item_action_rewrite_id, $single_item_action );
     4011                        } else {
     4012                                $path_chunks['single_item_action'] = $single_item_action;
     4013                        }
     4014                }
     4015        }
     4016
     4017        if ( $chunks ) {
     4018                foreach ( $chunks as $chunk ) {
     4019                        if ( is_numeric( $chunk ) ) {
     4020                                $path_chunks['single_item_action_variables'][] = $chunk;
     4021                        } else {
     4022                                if ( isset( $group_screens[ $chunk ]['rewrite_id'] ) ) {
     4023                                        $item_action_variable_rewrite_id               = $group_screens[ $chunk ]['rewrite_id'];
     4024                                        $path_chunks['single_item_action_variables'][] = bp_rewrites_get_slug( 'groups', $item_action_variable_rewrite_id, $chunk );
     4025                                } else {
     4026                                        $path_chunks['single_item_action_variables'][] = $chunk;
     4027                                }
     4028                        }
     4029                }
     4030        }
     4031
     4032        return $path_chunks;
     4033}
  • trunk/src/bp-groups/bp-groups-notifications.php

    r13441 r13446  
    161161        }
    162162
    163         $group = groups_get_group( $group_id );
    164         $args  = array(
     163        $group       = groups_get_group( $group_id );
     164        $path_chunks = bp_groups_get_path_chunks( array( 'membership-requests' ), 'manage' );
     165        $args        = array(
    165166                'tokens' => array(
    166167                        'admin.id'             => $admin_id,
     
    168169                        'group.name'           => $group->name,
    169170                        'group.id'             => $group_id,
    170                         'group-requests.url'   => esc_url( bp_get_group_permalink( $group ) . 'admin/membership-requests' ),
     171                        'group-requests.url'   => esc_url( bp_get_group_manage_url( $group, $path_chunks ) ),
    171172                        'profile.url'          => esc_url( bp_members_get_user_url( $requesting_user_id ) ),
    172173                        'requesting-user.id'   => $requesting_user_id,
  • trunk/src/bp-groups/bp-groups-template.php

    r13443 r13446  
    12431243 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
    12441244 *                                                Default: false.
    1245  */
    1246 function bp_group_url( $group = false ) {
    1247         echo esc_url( bp_get_group_url( $group ) );
     1245 * @param array                            $chunk (Optional) A list of slugs to append to the URL.
     1246 */
     1247function bp_group_url( $group = false, $chunks = array() ) {
     1248        $path_chunks = array();
     1249        $chunks      = (array) $chunks;
     1250
     1251        if ( $chunks ) {
     1252                $path_chunks = bp_groups_get_path_chunks( $chunks );
     1253        }
     1254
     1255        echo esc_url( bp_get_group_url( $group, $path_chunks ) );
    12481256}
    12491257
     
    12571265 *     An array of arguments. Optional.
    12581266 *
    1259  *     @type string $single_item_component        The component slug the action is relative to.
    12601267 *     @type string $single_item_action           The slug of the action to perform.
    12611268 *     @type array  $single_item_action_variables An array of additional informations about the action to perform.
     
    13061313
    13071314/**
    1308  * Output the permalink for the group.
    1309  *
    1310  * @since 1.0.0
    1311  * @deprecated 12.0.0
    1312  *
    1313  * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
    1314  *                                                Default: false.
    1315  */
    1316 function bp_group_permalink( $group = false ) {
    1317         _deprecated_function( __FUNCTION__, '12.0.0', 'bp_group_url' );
    1318         bp_group_url( $group );
    1319 }
    1320         /**
    1321          * Return the permalink for the group.
    1322          *
    1323          * @since 1.0.0
    1324          * @since 10.0.0 Updated to use `bp_get_group`.
    1325          *
    1326          * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
    1327      *                                                Default: false.
    1328          * @return string
    1329          */
    1330         function bp_get_group_permalink( $group = false ) {
    1331                 /*
    1332                  * This function is used at many places and we need to review all this
    1333                  * places during the 12.0 development cycle. Using BP Rewrites means we
    1334                  * cannot concatenate URL chunks to build our URL anymore. We now need
    1335                  * to use `bp_get_group_url( $group, $array )` and make sure to use
    1336                  * the right arguments inside this `$array`.
    1337                  *
    1338                  * @todo Once every link reviewed, we'll be able to remove this check
    1339                  *       and let PHPUnit tell us the one we forgot, eventually!
    1340                  */
    1341                 if ( ! buddypress()->is_phpunit_running ) {
    1342                         _deprecated_function( __FUNCTION__, '12.0.0', 'bp_get_group_url' );
    1343                 }
    1344 
    1345                 $url = bp_get_group_url( $group );
    1346 
    1347                 /**
    1348                  * Filters the permalink for the group.
    1349                  *
    1350                  * @since 1.0.0
    1351                  * @since 2.5.0 Added the `$group` parameter.
    1352                  * @deprecated 12.0.0
    1353                  *
    1354                  * @param string          $url   Permalink for the group.
    1355                  * @param BP_Groups_Group $group The group object.
    1356                  */
    1357                 return apply_filters_deprecated( 'bp_get_group_permalink', array( $url, $group ), '12.0.0', 'bp_get_group_url' );
    1358         }
    1359 
    1360 /**
    13611315 * Output an HTML-formatted link for the group.
    13621316 *
     
    14051359
    14061360/**
    1407  * Output the permalink for the admin section of the group.
    1408  *
    1409  * @since 1.0.0
     1361 * Outputs the requested group's manage URL.
     1362 *
     1363 * @since 12.0.0
    14101364 *
    14111365 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
    1412  *                                                Default: false.
    1413  */
    1414 function bp_group_admin_permalink( $group = false ) {
    1415         echo bp_get_group_admin_permalink( $group );
    1416 }
    1417         /**
    1418          * Return the permalink for the admin section of the group.
    1419          *
    1420          * @since 1.0.0
    1421          * @since 10.0.0 Updated to use `bp_get_group`.
    1422          *
    1423          * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
    1424      *                                                Default: false.
    1425          * @return string
    1426          */
    1427         function bp_get_group_admin_permalink( $group = false ) {
    1428                 $group = bp_get_group( $group );
    1429 
    1430                 if ( empty( $group->id ) ) {
    1431                         return '';
    1432                 }
    1433 
    1434                 /**
    1435                  * Filters the permalink for the admin section of the group.
    1436                  *
    1437                  * @since 1.0.0
    1438                  * @since 2.5.0 Added the `$group` parameter.
    1439                  *
    1440                  * @param string          $permalink Permalink for the admin section of the group.
    1441                  * @param BP_Groups_Group $group     The group object.
    1442                  */
    1443                 return apply_filters( 'bp_get_group_admin_permalink', trailingslashit( bp_get_group_permalink( $group ) . 'admin' ), $group );
    1444         }
     1366 *                                                 Default: false.
     1367 * @param array                            $chunks (Optional) A list of slugs to append to the URL.
     1368 */
     1369function bp_group_manage_url( $group = false, $chunks = array() ) {
     1370        $path_chunks = array();
     1371        $chunks      = (array) $chunks;
     1372
     1373        if ( $chunks ) {
     1374                $path_chunks = bp_groups_get_path_chunks( $chunks, 'manage' );
     1375        }
     1376
     1377        echo esc_url( bp_get_group_manage_url( $group, $path_chunks ) );
     1378}
     1379
     1380/**
     1381 * Gets the requested group's manage URL.
     1382 *
     1383 * @since 12.0.0
     1384 *
     1385 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
     1386 *                                                 Default: false.
     1387 * @param array                            $path_chunks {
     1388 *     An array of arguments. Optional.
     1389 *
     1390 *     @type array  $single_item_action_variables An array of additional informations about the action to perform.
     1391 * }
     1392 * @return string The requested group's manage URL.
     1393 */
     1394function bp_get_group_manage_url( $group = false, $path_chunks = array() ) {
     1395        $group = bp_get_group( $group );
     1396        $url   = '';
     1397
     1398        if ( empty( $group->id ) ) {
     1399                return $url;
     1400        }
     1401
     1402        $admin_chunks = array(
     1403                'single_item_action' => bp_rewrites_get_slug( 'groups', 'bp_group_read_admin', 'admin' ),
     1404        );
     1405
     1406        if ( isset( $path_chunks['single_item_action_variables'] ) ) {
     1407                $admin_chunks['single_item_action_variables'] = (array) $path_chunks['single_item_action_variables'];
     1408        }
     1409
     1410        $url = bp_get_group_url( $group, $admin_chunks );
     1411
     1412        /**
     1413         * Filters the group's manage URL.
     1414         *
     1415         * @since 12.0.0
     1416         *
     1417         * @param string          $url         Permalink for the admin section of the group.
     1418         * @param BP_Groups_Group $group       The group object.
     1419         * @param array           $path_chunks BP Rewrites path chunks.
     1420         */
     1421        return apply_filters( 'bp_get_group_manage_url', $url, $group, $path_chunks );
     1422}
    14451423
    14461424/**
     
    21252103 * @since 10.0.0 Added the `$group` parameter.
    21262104 *
     2105 * @todo Deprecate: this function is not used inside the codebase.
     2106 *
    21272107 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
    21282108 *                                                Default: false.
    21292109 */
    21302110function bp_group_all_members_permalink( $group = false ) {
    2131         echo bp_get_group_all_members_permalink( $group );
     2111        echo esc_url( bp_get_group_all_members_permalink( $group ) );
    21322112}
    21332113        /**
     
    21362116         * @since 1.0.0
    21372117         * @since 10.0.0 Updated to use `bp_get_group`.
     2118         *
     2119         * @todo Deprecate: this function is not used inside the codebase.
    21382120         *
    21392121         * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object.
     
    21422124         */
    21432125        function bp_get_group_all_members_permalink( $group = false ) {
    2144                 $group = bp_get_group( $group );
    2145 
    2146                 if ( empty( $group->id ) ) {
    2147                         return '';
    2148                 }
     2126                $path_chunks = bp_groups_get_path_chunks( array( 'members' ) );
     2127                $url         = bp_get_group_url( $group, $path_chunks );
    21492128
    21502129                /**
     
    21542133                 * @since 2.5.0 Added the `$group` parameter.
    21552134                 *
    2156                  * @param string          $value Permalink of the Members page for a group.
     2135                 * @param string          $url  Permalink of the Members page for a group.
    21572136                 * @param BP_Groups_Group $group The group object.
    21582137                 */
    2159                 return apply_filters( 'bp_get_group_all_members_permalink', trailingslashit( bp_get_group_permalink( $group ) . 'members' ), $group );
     2138                return apply_filters( 'bp_get_group_all_members_permalink', $url, $group );
    21602139        }
    21612140
     
    24152394 */
    24162395function bp_group_forum_permalink( $group = false ) {
    2417         echo bp_get_group_forum_permalink( $group );
     2396        echo esc_url( bp_get_group_forum_permalink( $group ) );
    24182397}
    24192398        /**
     
    24282407         */
    24292408        function bp_get_group_forum_permalink( $group = false ) {
    2430                 $group = bp_get_group( $group );
    2431 
    2432                 if ( empty( $group->id ) ) {
    2433                         return '';
    2434                 }
     2409                $path_chunks = bp_groups_get_path_chunks( array( 'forum' ) );
     2410                $url         = bp_get_group_url( $group, $path_chunks );
    24352411
    24362412                /**
     
    24432419                 * @param BP_Groups_Group $group The group object.
    24442420                 */
    2445                 return apply_filters( 'bp_get_group_forum_permalink', trailingslashit( bp_get_group_permalink( $group ) . 'forum' ), $group );
     2421                return apply_filters( 'bp_get_group_forum_permalink', $url, $group );
    24462422        }
    24472423
     
    28882864                );
    28892865
    2890                 extract( $r, EXTR_SKIP );
     2866                $url = wp_nonce_url(
     2867                        bp_get_group_manage_url(
     2868                                $r['group'],
     2869                                bp_groups_get_path_chunks( array( 'manage-members', 'promote', 'mod', $r['user_id'] ), 'manage' )
     2870                        ),
     2871                        'groups_promote_member'
     2872                );
    28912873
    28922874                /**
     
    28952877                 * @since 1.1.0
    28962878                 *
    2897                  * @param string $value URL to use for promoting a user to moderator.
    2898                  */
    2899                 return apply_filters( 'bp_get_group_member_promote_mod_link', wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/promote/mod/' . $user_id ), 'groups_promote_member' ) );
     2879                 * @param string $url URL to use for promoting a user to moderator.
     2880                 */
     2881                return apply_filters( 'bp_get_group_member_promote_mod_link', $url );
    29002882        }
    29012883
     
    29342916                );
    29352917
    2936                 extract( $r, EXTR_SKIP );
     2918                $url = wp_nonce_url(
     2919                        bp_get_group_manage_url(
     2920                                $r['group'],
     2921                                bp_groups_get_path_chunks( array( 'manage-members', 'promote', 'admin', $r['user_id'] ), 'manage' )
     2922                        ),
     2923                        'groups_promote_member'
     2924                );
    29372925
    29382926                /**
     
    29412929                 * @since 1.1.0
    29422930                 *
    2943                  * @param string $value URL to use for promoting a user to admin.
    2944                  */
    2945                 return apply_filters( 'bp_get_group_member_promote_admin_link', wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/promote/admin/' . $user_id ), 'groups_promote_member' ) );
     2931                 * @param string $url URL to use for promoting a user to admin.
     2932                 */
     2933                return apply_filters( 'bp_get_group_member_promote_admin_link', $url );
    29462934        }
    29472935
     
    29732961                global $members_template;
    29742962
    2975                 $group = bp_get_group( $group );
    2976 
    2977                 if ( empty( $group->id ) ) {
    2978                         return '';
    2979                 }
    2980 
    29812963                if ( ! $user_id ) {
    29822964                        $user_id = $members_template->member->user_id;
    29832965                }
     2966
     2967                $url = wp_nonce_url(
     2968                        bp_get_group_manage_url(
     2969                                $group,
     2970                                bp_groups_get_path_chunks( array( 'manage-members', 'demote', $user_id ), 'manage' )
     2971                        ),
     2972                        'groups_demote_member'
     2973                );
    29842974
    29852975                /**
     
    29902980                 * @since 10.0.0 Added the `$user_id` parameter.
    29912981                 *
    2992                  * @param string          $value   URL to use for demoting a user to member.
     2982                 * @param string          $url     URL to use for demoting a user to member.
    29932983                 * @param BP_Groups_Group $group   The group object.
    29942984                 * @param int             $user_id The user ID.
    29952985                 */
    2996                 return apply_filters(
    2997                         'bp_get_group_member_demote_link',
    2998                         wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/demote/' . $user_id ), 'groups_demote_member' ),
    2999                         $group,
    3000                         $user_id
    3001                 );
     2986                return apply_filters( 'bp_get_group_member_demote_link', $url, $group, $user_id );
    30022987        }
    30032988
     
    30293014                global $members_template;
    30303015
    3031                 $group = bp_get_group( $group );
    3032 
    3033                 if ( empty( $group->id ) ) {
    3034                         return '';
    3035                 }
    3036 
    30373016                if ( ! $user_id ) {
    30383017                        $user_id = $members_template->member->user_id;
    30393018                }
     3019
     3020                $url = wp_nonce_url(
     3021                        bp_get_group_manage_url(
     3022                                $group,
     3023                                bp_groups_get_path_chunks( array( 'manage-members', 'ban', $user_id ), 'manage' )
     3024                        ),
     3025                        'groups_ban_member'
     3026                );
    30403027
    30413028                /**
     
    30493036                 * @param int             $user_id The user ID.
    30503037                 */
    3051                 return apply_filters(
    3052                         'bp_get_group_member_ban_link',
    3053                         wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/ban/' . $user_id ), 'groups_ban_member' ),
    3054                         $group,
    3055                         $user_id
    3056                 );
     3038                return apply_filters( 'bp_get_group_member_ban_link', $url, $group, $user_id );
    30573039        }
    30583040
     
    30843066                global $members_template;
    30853067
    3086                 $group = bp_get_group( $group );
    3087 
    3088                 if ( empty( $group->id ) ) {
    3089                         return '';
    3090                 }
    3091 
    30923068                if ( ! $user_id ) {
    30933069                        $user_id = $members_template->member->user_id;
    30943070                }
     3071
     3072                $url = wp_nonce_url(
     3073                        bp_get_group_manage_url(
     3074                                $group,
     3075                                bp_groups_get_path_chunks( array( 'manage-members', 'unban', $user_id ), 'manage' )
     3076                        ),
     3077                        'groups_unban_member'
     3078                );
    30953079
    30963080                /**
     
    31043088                 * @param int             $user_id The user ID.
    31053089                 */
    3106                 return apply_filters(
    3107                         'bp_get_group_member_unban_link',
    3108                         wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/unban/' . $user_id ), 'groups_unban_member' ),
    3109                         $group,
    3110                         $user_id
    3111                 );
     3090                return apply_filters( 'bp_get_group_member_unban_link', $url,   $group, $user_id );
    31123091        }
    31133092
     
    31393118                global $members_template;
    31403119
    3141                 $group = bp_get_group( $group );
    3142 
    3143                 if ( empty( $group->id ) ) {
    3144                         return '';
    3145                 }
    3146 
    31473120                if ( ! $user_id ) {
    31483121                        $user_id = $members_template->member->user_id;
    31493122                }
     3123
     3124                $url = wp_nonce_url(
     3125                        bp_get_group_manage_url(
     3126                                $group,
     3127                                bp_groups_get_path_chunks( array( 'manage-members', 'remove', $user_id ), 'manage' )
     3128                        ),
     3129                        'groups_remove_member'
     3130                );
    31503131
    31513132                /**
     
    31563137                 * @since 10.0.0 Added the `$user_id` parameter.
    31573138                 *
    3158                  * @param string          $value   URL to use for removing a member.
     3139                 * @param string          $url     URL to use for removing a member.
    31593140                 * @param BP_Groups_Group $group   The group object.
    31603141                 * @param int             $user_id The user ID.
    31613142                 */
    3162                 return apply_filters(
    3163                         'bp_get_group_member_remove_link',
    3164                         wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/remove/' . $user_id ), 'groups_remove_member' ),
    3165                         $group,
    3166                         $user_id
    3167                 );
     3143                return apply_filters( 'bp_get_group_member_remove_link', $url, $group, $user_id );
    31683144        }
    31693145
     
    36473623                }
    36483624
     3625                $url = wp_nonce_url(
     3626                        bp_get_group_url(
     3627                                $group,
     3628                                bp_groups_get_path_chunks( array( 'leave-group', 'yes' ) )
     3629                        ),
     3630                        'groups_leave_group'
     3631                );
     3632
    36493633                /**
    36503634                 * Filters the URL for confirming a request to leave a group.
     
    36533637                 * @since 2.5.0 Added the `$group` parameter.
    36543638                 *
    3655                  * @param string $value URL for confirming a request to leave a group.
     3639                 * @param string $url  URL for confirming a request to leave a group.
    36563640                 * @param object $group Group object.
    36573641                 */
    3658                 return apply_filters( 'bp_group_leave_confirm_link', wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'leave-group/yes' ), 'groups_leave_group' ), $group );
     3642                return apply_filters( 'bp_group_leave_confirm_link', $url, $group );
    36593643        }
    36603644
     
    37193703                }
    37203704
     3705                $url = bp_get_group_url(
     3706                        $group,
     3707                        bp_groups_get_path_chunks( array( 'send-invites', 'send' ) )
     3708                );
     3709
    37213710                /**
    37223711                 * Filters the 'action' attribute for a group send invite form.
     
    37283717                 * @param object $group Group object.
    37293718                 */
    3730                 return apply_filters( 'bp_group_send_invite_form_action', trailingslashit( bp_get_group_permalink( $group ) . 'send-invites/send' ), $group );
     3719                return apply_filters( 'bp_group_send_invite_form_action', $url, $group );
    37313720        }
    37323721
     
    38023791                                return $button_args;
    38033792                        }
     3793
     3794                        $url = wp_nonce_url(
     3795                                bp_get_group_url(
     3796                                        $group,
     3797                                        bp_groups_get_path_chunks( array( 'leave-group' ) )
     3798                                ),
     3799                                'groups_leave_group'
     3800                        );
    38043801
    38053802                        // Setup button attributes.
     
    38113808                                'wrapper_class'     => 'group-button ' . $group->status,
    38123809                                'wrapper_id'        => 'groupbutton-' . $group->id,
    3813                                 'link_href'         => wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'leave-group' ), 'groups_leave_group' ),
     3810                                'link_href'         => $url,
    38143811                                'link_text'         => __( 'Leave Group', 'buddypress' ),
    38153812                                'link_title'        => __( 'Leave Group', 'buddypress' ),
     
    38263823
    38273824                                case 'public':
     3825                                        $url = wp_nonce_url(
     3826                                                bp_get_group_url(
     3827                                                        $group,
     3828                                                        bp_groups_get_path_chunks( array( 'join' ) )
     3829                                                ),
     3830                                                'groups_join_group'
     3831                                        );
     3832
    38283833                                        $button_args = array(
    38293834                                                'id'                => 'join_group',
     
    38333838                                                'wrapper_class'     => 'group-button ' . $group->status,
    38343839                                                'wrapper_id'        => 'groupbutton-' . $group->id,
    3835                                                 'link_href'         => wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'join' ), 'groups_join_group' ),
     3840                                                'link_href'         => $url,
    38363841                                                'link_text'         => __( 'Join Group', 'buddypress' ),
    38373842                                                'link_title'        => __( 'Join Group', 'buddypress' ),
     
    38773882                                        // show a "Request Membership" button.
    38783883                                        } else {
     3884                                                $url = wp_nonce_url(
     3885                                                        bp_get_group_url(
     3886                                                                $group,
     3887                                                                bp_groups_get_path_chunks( array( 'request-membership' ) )
     3888                                                        ),
     3889                                                        'groups_request_membership'
     3890                                                );
     3891
    38793892                                                $button_args = array(
    38803893                                                        'id'                => 'request_membership',
     
    38843897                                                        'wrapper_class'     => 'group-button ' . $group->status,
    38853898                                                        'wrapper_id'        => 'groupbutton-' . $group->id,
    3886                                                         'link_href'         => wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'request-membership' ), 'groups_request_membership' ),
     3899                                                        'link_href'         => $url,
    38873900                                                        'link_text'         => __( 'Request Membership', 'buddypress' ),
    38883901                                                        'link_title'        => __( 'Request Membership', 'buddypress' ),
     
    59395952         */
    59405953        function bp_get_group_avatar_delete_link() {
    5941                 $bp = buddypress();
     5954                $group = groups_get_current_group();
     5955                $url   = wp_nonce_url(
     5956                        bp_get_group_manage_url(
     5957                                $group,
     5958                                bp_groups_get_path_chunks( array( 'group-avatar', 'delete' ), 'manage' )
     5959                        ),
     5960                        'bp_group_avatar_delete'
     5961                );
    59425962
    59435963                /**
     
    59465966                 * @since 1.1.0
    59475967                 *
    5948                  * @param string $value URL to delete the group avatar.
    5949                  */
    5950                 return apply_filters( 'bp_get_group_avatar_delete_link', wp_nonce_url( trailingslashit( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/group-avatar/delete' ), 'bp_group_avatar_delete' ) );
     5968                 * @param string $url URL to delete the group avatar.
     5969                 */
     5970                return apply_filters( 'bp_get_group_avatar_delete_link', $url );
    59515971        }
    59525972
     
    60846104                global $requests_template;
    60856105
    6086                 $link = add_query_arg( array(
    6087                         '_wpnonce' => wp_create_nonce( 'groups_reject_membership_request' ),
    6088                         'user_id'  => $requests_template->request->user_id,
    6089                         'action'   => 'reject'
    6090                 ), trailingslashit( bp_get_group_permalink( groups_get_current_group() ) ) . 'admin/membership-requests/' );
     6106                $link = add_query_arg(
     6107                        array(
     6108                                '_wpnonce' => wp_create_nonce( 'groups_reject_membership_request' ),
     6109                                'user_id'  => $requests_template->request->user_id,
     6110                                'action'   => 'reject'
     6111                        ),
     6112                        bp_get_group_manage_url(
     6113                                groups_get_current_group(),
     6114                                bp_groups_get_path_chunks( array( 'membership-requests' ), 'manage' )
     6115                        )
     6116                );
    60916117
    60926118                /**
     
    60956121                 * @since 1.2.6
    60966122                 *
    6097                  * @param string $value URL to use to reject a membership request.
     6123                 * @param string $link URL to use to reject a membership request.
    60986124                 */
    60996125                return apply_filters( 'bp_get_group_request_reject_link', $link );
     
    61146140                global $requests_template;
    61156141
    6116                 $link = add_query_arg( array(
    6117                         '_wpnonce' => wp_create_nonce( 'groups_accept_membership_request' ),
    6118                         'user_id'  => $requests_template->request->user_id,
    6119                         'action'   => 'accept'
    6120                 ), trailingslashit( bp_get_group_permalink( groups_get_current_group() ) ) . 'admin/membership-requests/' );
     6142                $link = add_query_arg(
     6143                        array(
     6144                                '_wpnonce' => wp_create_nonce( 'groups_accept_membership_request' ),
     6145                                'user_id'  => $requests_template->request->user_id,
     6146                                'action'   => 'accept'
     6147                        ),
     6148                        bp_get_group_manage_url(
     6149                                $group,
     6150                                bp_groups_get_path_chunks( array( 'membership-request' ), 'manage' )
     6151                        )
     6152                );
    61216153
    61226154                /**
     
    64586490                        $uninvite_url = bp_get_groups_directory_permalink() . 'create/step/group-invites/?user_id=' . $user_id;
    64596491                } else {
    6460                         $uninvite_url = trailingslashit( bp_get_group_permalink( groups_get_current_group() ) . 'send-invites/remove/' . $user_id );
     6492                        $uninvite_url = bp_get_group_url(
     6493                                groups_get_current_group(),
     6494                                bp_groups_get_path_chunks( array( 'send-invites', 'remove', $user_id ) )
     6495                        );
    64616496                }
    64626497
     
    65636598         */
    65646599        function bp_get_group_activity_feed_link() {
    6565                 $current_group = groups_get_current_group();
    6566                 $group_link    = bp_get_group_permalink( $current_group ) . 'feed';
    6567                 $feed_link     = trailingslashit( $group_link );
     6600                $feed_link = bp_get_group_url(
     6601                        groups_get_current_group(),
     6602                        bp_groups_get_path_chunks( array( 'feed' ) )
     6603                );
    65686604
    65696605                /**
     
    67426778
    67436779                        // Append $action to $url if provided
    6744                         if ( !empty( $action ) ) {
    6745                                 $url = bp_get_group_permalink( $current_group ) . $action;
     6780                        if ( ! empty( $action ) ) {
     6781                                $url = bp_get_group_url(
     6782                                        $current_group,
     6783                                        bp_groups_get_path_chunks( array( $action ) )
     6784                                );
    67466785                        } else {
    67476786                                $url = bp_get_group_url( $current_group );
  • trunk/src/bp-groups/classes/class-bp-group-extension.php

    r13441 r13446  
    870870                        $current_group = groups_get_group( $this->group_id );
    871871
    872                         $no_access_args['message'] = __( 'You do not have access to this content.', 'buddypress' );
    873                         $no_access_args['root'] = bp_get_group_permalink( $current_group ) . 'home/';
     872                        $no_access_args['message']  = __( 'You do not have access to this content.', 'buddypress' );
     873                        $no_access_args['root']     = bp_get_group_url(
     874                                $current_group,
     875                                bp_groups_get_path_chunks( array( 'home' ) )
     876                        );
    874877                        $no_access_args['redirect'] = false;
    875878                }
  • trunk/src/bp-groups/classes/class-bp-groups-group-members-template.php

    r13423 r13446  
    169169
    170170                // Assemble the base URL for pagination.
    171                 $base_url = trailingslashit( bp_get_group_permalink( $current_group ) . bp_current_action() );
     171                $chunks = array( bp_current_action() );
    172172                if ( bp_action_variable() ) {
    173                         $base_url = trailingslashit( $base_url . bp_action_variable() );
    174                 }
     173                        $chunks[] = bp_action_variable();
     174                }
     175
     176                $base_url = bp_get_group_url(
     177                        $current_group,
     178                        bp_groups_get_path_chunks( $chunks )
     179                );
    175180
    176181                $members_args = $r;
  • trunk/src/bp-groups/screens/single/admin.php

    r11923 r13446  
    1414 */
    1515function groups_screen_group_admin() {
    16         if ( !bp_is_groups_component() || !bp_is_current_action( 'admin' ) )
     16        if ( ! bp_is_groups_component() || ! bp_is_current_action( 'admin' ) ) {
    1717                return false;
     18        }
    1819
    19         if ( bp_action_variables() )
     20        if ( bp_action_variables() ) {
    2021                return false;
     22        }
    2123
    22         bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/edit-details/' );
     24        $redirect = bp_get_group_manage_url(
     25                groups_get_current_group(),
     26                bp_groups_get_path_chunks( array( 'edit-details' ), 'manage' )
     27        );
     28
     29        bp_core_redirect( $redirect );
    2330}
  • trunk/src/bp-groups/screens/single/admin/edit-details.php

    r12381 r13446  
    5454                        do_action( 'groups_group_details_edited', $bp->groups->current_group->id );
    5555
    56                         bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/edit-details/' );
     56                        $redirect = bp_get_group_manage_url(
     57                                groups_get_current_group(),
     58                                bp_groups_get_path_chunks( array( 'edit-details' ), 'manage' )
     59                        );
     60
     61                        bp_core_redirect( $redirect );
    5762                }
    5863
  • trunk/src/bp-groups/screens/single/admin/group-settings.php

    r12694 r13446  
    8484                do_action( 'groups_group_settings_edited', $bp->groups->current_group->id );
    8585
    86                 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/group-settings/' );
     86                $redirect = bp_get_group_manage_url(
     87                        groups_get_current_group(),
     88                        bp_groups_get_path_chunks( array( 'group-settings' ), 'manage' )
     89                );
     90
     91                bp_core_redirect( $redirect );
    8792        }
    8893
  • trunk/src/bp-groups/screens/single/admin/manage-members.php

    r11923 r13446  
    1515function groups_screen_group_admin_manage_members() {
    1616
    17         if ( 'manage-members' != bp_get_group_current_admin_tab() )
     17        if ( 'manage-members' != bp_get_group_current_admin_tab() ) {
    1818                return false;
     19        }
    1920
    20         if ( ! bp_is_item_admin() )
     21        if ( ! bp_is_item_admin() ) {
    2122                return false;
     23        }
    2224
    23         $bp = buddypress();
     25        $bp       = buddypress();
     26        $redirect = bp_get_group_manage_url(
     27                groups_get_current_group(),
     28                bp_groups_get_path_chunks( array( 'manage-members' ), 'manage' )
     29        );
    2430
    2531        if ( bp_action_variable( 1 ) && bp_action_variable( 2 ) && bp_action_variable( 3 ) ) {
     
    2935
    3036                        // Check the nonce first.
    31                         if ( !check_admin_referer( 'groups_promote_member' ) )
     37                        if ( ! check_admin_referer( 'groups_promote_member' ) ) {
    3238                                return false;
     39                        }
    3340
    3441                        // Promote a user.
    35                         if ( !groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) )
     42                        if ( ! groups_promote_member( $user_id, $bp->groups->current_group->id, $status ) ) {
    3643                                bp_core_add_message( __( 'There was an error when promoting that user. Please try again.', 'buddypress' ), 'error' );
    37                         else
     44                        } else {
    3845                                bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) );
     46                        }
    3947
    4048                        /**
     
    4856                        do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id );
    4957
    50                         bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/' );
     58                        bp_core_redirect( $redirect );
    5159                }
    5260        }
     
    5765
    5866                        // Check the nonce first.
    59                         if ( !check_admin_referer( 'groups_demote_member' ) )
     67                        if ( ! check_admin_referer( 'groups_demote_member' ) ) {
    6068                                return false;
     69                        }
    6170
    6271                        // Stop sole admins from abandoning their group.
    6372                        $group_admins = groups_get_group_admins( $bp->groups->current_group->id );
    64                         if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == $user_id )
     73                        if ( 1 == count( $group_admins ) && $group_admins[0]->user_id == $user_id ) {
    6574                                bp_core_add_message( __( 'This group must have at least one admin', 'buddypress' ), 'error' );
    6675
    67                         // Demote a user.
    68                         elseif ( !groups_demote_member( $user_id, $bp->groups->current_group->id ) )
     76                                // Demote a user.
     77                        } elseif ( ! groups_demote_member( $user_id, $bp->groups->current_group->id ) ) {
    6978                                bp_core_add_message( __( 'There was an error when demoting that user. Please try again.', 'buddypress' ), 'error' );
    70                         else
     79                        } else {
    7180                                bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) );
     81                        }
    7282
    7383                        /**
     
    8191                        do_action( 'groups_demoted_member', $user_id, $bp->groups->current_group->id );
    8292
    83                         bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/' );
     93                        bp_core_redirect( $redirect );
    8494                }
    8595
     
    8898
    8999                        // Check the nonce first.
    90                         if ( !check_admin_referer( 'groups_ban_member' ) )
     100                        if ( ! check_admin_referer( 'groups_ban_member' ) ) {
    91101                                return false;
     102                        }
    92103
    93104                        // Ban a user.
    94                         if ( !groups_ban_member( $user_id, $bp->groups->current_group->id ) )
     105                        if ( ! groups_ban_member( $user_id, $bp->groups->current_group->id ) ) {
    95106                                bp_core_add_message( __( 'There was an error when banning that user. Please try again.', 'buddypress' ), 'error' );
    96                         else
     107                        } else {
    97108                                bp_core_add_message( __( 'User banned successfully', 'buddypress' ) );
     109                        }
    98110
    99111                        /**
     
    107119                        do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id );
    108120
    109                         bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/' );
     121                        bp_core_redirect( $redirect );
    110122                }
    111123
     
    114126
    115127                        // Check the nonce first.
    116                         if ( !check_admin_referer( 'groups_unban_member' ) )
     128                        if ( ! check_admin_referer( 'groups_unban_member' ) ) {
    117129                                return false;
     130                        }
    118131
    119132                        // Remove a ban for user.
    120                         if ( !groups_unban_member( $user_id, $bp->groups->current_group->id ) )
     133                        if ( ! groups_unban_member( $user_id, $bp->groups->current_group->id ) ) {
    121134                                bp_core_add_message( __( 'There was an error when unbanning that user. Please try again.', 'buddypress' ), 'error' );
    122                         else
     135                        } else {
    123136                                bp_core_add_message( __( 'User ban removed successfully', 'buddypress' ) );
     137                        }
    124138
    125139                        /**
     
    133147                        do_action( 'groups_unbanned_member', $user_id, $bp->groups->current_group->id );
    134148
    135                         bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/' );
     149                        bp_core_redirect( $redirect );
    136150                }
    137151
     
    140154
    141155                        // Check the nonce first.
    142                         if ( !check_admin_referer( 'groups_remove_member' ) )
     156                        if ( ! check_admin_referer( 'groups_remove_member' ) ) {
    143157                                return false;
     158                        }
    144159
    145160                        // Remove a user.
    146                         if ( !groups_remove_member( $user_id, $bp->groups->current_group->id ) )
     161                        if ( ! groups_remove_member( $user_id, $bp->groups->current_group->id ) ) {
    147162                                bp_core_add_message( __( 'There was an error removing that user from the group. Please try again.', 'buddypress' ), 'error' );
    148                         else
     163                        } else {
    149164                                bp_core_add_message( __( 'User removed successfully', 'buddypress' ) );
     165                        }
    150166
    151167                        /**
     
    159175                        do_action( 'groups_removed_member', $user_id, $bp->groups->current_group->id );
    160176
    161                         bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/' );
     177                        bp_core_redirect( $redirect );
    162178                }
    163179        }
  • trunk/src/bp-groups/screens/single/admin/membership-requests.php

    r12436 r13446  
    7272                 */
    7373                do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id, $user_id, $group_id );
    74                 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/membership-requests/' );
     74
     75                $redirect = bp_get_group_manage_url(
     76                        groups_get_current_group(),
     77                        bp_groups_get_path_chunks( array( 'membership-requests' ), 'manage' )
     78                );
     79
     80                bp_core_redirect( $redirect );
    7581        }
    7682
  • trunk/src/bp-members/bp-members-functions.php

    r13443 r13446  
    140140
    141141/**
    142  * Get members path chunks using an array of URL slugs.
     142 * Get single member's path chunks using an array of URL slugs.
    143143 *
    144144 * @since 12.0.0
     
    164164        }
    165165
    166         if ( $chunks && $item_component_rewrite_id_suffix && $item_component_rewrite_id_suffix ) {
     166        if ( $chunks && $item_component_rewrite_id_suffix && $item_action_rewrite_id_suffix ) {
    167167                foreach ( $chunks as $chunk ) {
    168                         $item_action_variable_rewrite_id_suffix        =  str_replace( '-', '_', $chunk );
    169                         $path_chunks['single_item_action_variables'][] = bp_rewrites_get_slug( 'members', 'member_' . $item_component_rewrite_id_suffix . '_' . $item_action_rewrite_id_suffix . '_' . $item_action_variable_rewrite_id_suffix, $chunk );
     168                        if ( is_numeric( $chunk ) ) {
     169                                $path_chunks['single_item_action_variables'][] = $chunk;
     170                        } else {
     171                                $item_action_variable_rewrite_id_suffix        =  str_replace( '-', '_', $chunk );
     172                                $path_chunks['single_item_action_variables'][] = bp_rewrites_get_slug( 'members', 'member_' . $item_component_rewrite_id_suffix . '_' . $item_action_rewrite_id_suffix . '_' . $item_action_variable_rewrite_id_suffix, $chunk );
     173                        }
    170174                }
    171175        }
  • trunk/src/bp-templates/bp-legacy/buddypress-functions.php

    r13442 r13446  
    14231423                $user = new BP_Core_User( $friend_id );
    14241424
    1425                 $uninvite_url = bp_is_current_action( 'create' )
    1426                         ? bp_get_groups_directory_permalink() . 'create/step/group-invites/?user_id=' . $friend_id
    1427                         : bp_get_group_permalink( $group )    . 'send-invites/remove/' . $friend_id;
     1425                if ( bp_is_current_action( 'create' ) ) {
     1426                        $uninvite_url = bp_get_groups_directory_permalink() . 'create/step/group-invites/?user_id=' . $friend_id;
     1427                } else {
     1428                        $path_chunks  = bp_groups_get_path_chunks( array( 'send-invites', 'remove', $friend_id ) );
     1429                        $uninvite_url = bp_get_group_url( $group, $path_chunks );
     1430                }
    14281431
    14291432                echo '<li id="uid-' . esc_attr( $user->id ) . '">';
     
    16411644                                _e( 'Error joining group', 'buddypress' );
    16421645                        } else {
    1643                                 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button leave-group" rel="leave" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
     1646                                $leave_url = wp_nonce_url(
     1647                                        bp_get_group_url(
     1648                                                $group,
     1649                                                bp_groups_get_path_chunks( array( 'leave-group' ) )
     1650                                        ),
     1651                                        'groups_leave_group'
     1652                                );
     1653                                echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button leave-group" rel="leave" href="' . esc_url( $leave_url ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    16441654                        }
    16451655                break;
     
    16551665                                _e( 'Error requesting membership', 'buddypress' );
    16561666                        } else {
    1657                                 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button leave-group" rel="leave" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'leave-group', 'groups_leave_group' ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
     1667                                $leave_url = wp_nonce_url(
     1668                                        bp_get_group_url(
     1669                                                $group,
     1670                                                bp_groups_get_path_chunks( array( 'leave-group' ) )
     1671                                        ),
     1672                                        'groups_leave_group'
     1673                                );
     1674                                echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button leave-group" rel="leave" href="' . esc_url( $leave_url ) . '">' . __( 'Leave Group', 'buddypress' ) . '</a>';
    16581675                        }
    16591676                break;
     
    16751692                                _e( 'Error leaving group', 'buddypress' );
    16761693                        } elseif ( 'public' === $group->status ) {
    1677                                 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button join-group" rel="join" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'join', 'groups_join_group' ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
     1694                                $join_url = wp_nonce_url(
     1695                                        bp_get_group_url(
     1696                                                $group,
     1697                                                bp_groups_get_path_chunks( array( 'join' ) )
     1698                                        ),
     1699                                        'groups_join_group'
     1700                                );
     1701                                echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button join-group" rel="join" href="' . esc_url( $join_url ) . '">' . __( 'Join Group', 'buddypress' ) . '</a>';
    16781702                        } else {
    1679                                 echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button request-membership" rel="join" href="' . wp_nonce_url( bp_get_group_permalink( $group ) . 'request-membership', 'groups_request_membership' ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';
     1703                                $request_url = wp_nonce_url(
     1704                                        bp_get_group_url(
     1705                                                $group,
     1706                                                bp_groups_get_path_chunks( array( 'request-membership' ) )
     1707                                        ),
     1708                                        'groups_request_membership'
     1709                                );
     1710                                echo '<a id="group-' . esc_attr( $group->id ) . '" class="group-button request-membership" rel="join" href="' . esc_url( $request_url ) . '">' . __( 'Request Membership', 'buddypress' ) . '</a>';
    16801711                        }
    16811712                break;
Note: See TracChangeset for help on using the changeset viewer.