Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/04/2023 01:06:03 AM (2 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 );
Note: See TracChangeset for help on using the changeset viewer.