Changeset 13446
- Timestamp:
- 04/04/2023 01:06:03 AM (19 months ago)
- Location:
- trunk/src
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/screens/permalink.php
r13441 r13446 56 56 // Set redirect to group activity stream. 57 57 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 ); 59 60 } 60 61 } -
trunk/src/bp-core/deprecated/12.0.php
r13443 r13446 297 297 _deprecated_function( __FUNCTION__, '12.0.0', 'bp_displayed_user_url()' ); 298 298 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 */ 310 function 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 */ 325 function 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 */ 350 function 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 */ 366 function 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' ); 299 381 } 300 382 -
trunk/src/bp-groups/actions/access.php
r13437 r13446 33 33 $no_access_args = array( 34 34 '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 ), 36 39 'redirect' => false 37 40 ); -
trunk/src/bp-groups/bp-groups-functions.php
r13437 r13446 3836 3836 'position' => 10, 3837 3837 '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', 3838 3848 ), 3839 3849 'request-membership' => array( … … 3980 3990 return $context_screens; 3981 3991 } 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 */ 4001 function 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 161 161 } 162 162 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( 165 166 'tokens' => array( 166 167 'admin.id' => $admin_id, … … 168 169 'group.name' => $group->name, 169 170 '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 ) ), 171 172 'profile.url' => esc_url( bp_members_get_user_url( $requesting_user_id ) ), 172 173 'requesting-user.id' => $requesting_user_id, -
trunk/src/bp-groups/bp-groups-template.php
r13443 r13446 1243 1243 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 1244 1244 * 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 */ 1247 function 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 ) ); 1248 1256 } 1249 1257 … … 1257 1265 * An array of arguments. Optional. 1258 1266 * 1259 * @type string $single_item_component The component slug the action is relative to.1260 1267 * @type string $single_item_action The slug of the action to perform. 1261 1268 * @type array $single_item_action_variables An array of additional informations about the action to perform. … … 1306 1313 1307 1314 /** 1308 * Output the permalink for the group.1309 *1310 * @since 1.0.01311 * @deprecated 12.0.01312 *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.01324 * @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 string1329 */1330 function bp_get_group_permalink( $group = false ) {1331 /*1332 * This function is used at many places and we need to review all this1333 * places during the 12.0 development cycle. Using BP Rewrites means we1334 * cannot concatenate URL chunks to build our URL anymore. We now need1335 * to use `bp_get_group_url( $group, $array )` and make sure to use1336 * the right arguments inside this `$array`.1337 *1338 * @todo Once every link reviewed, we'll be able to remove this check1339 * 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.01351 * @since 2.5.0 Added the `$group` parameter.1352 * @deprecated 12.0.01353 *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 /**1361 1315 * Output an HTML-formatted link for the group. 1362 1316 * … … 1405 1359 1406 1360 /** 1407 * Output the permalink for the admin section of the group.1408 * 1409 * @since 1 .0.01361 * Outputs the requested group's manage URL. 1362 * 1363 * @since 12.0.0 1410 1364 * 1411 1365 * @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 */ 1369 function 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 */ 1394 function 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 } 1445 1423 1446 1424 /** … … 2125 2103 * @since 10.0.0 Added the `$group` parameter. 2126 2104 * 2105 * @todo Deprecate: this function is not used inside the codebase. 2106 * 2127 2107 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2128 2108 * Default: false. 2129 2109 */ 2130 2110 function 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 ) ); 2132 2112 } 2133 2113 /** … … 2136 2116 * @since 1.0.0 2137 2117 * @since 10.0.0 Updated to use `bp_get_group`. 2118 * 2119 * @todo Deprecate: this function is not used inside the codebase. 2138 2120 * 2139 2121 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. … … 2142 2124 */ 2143 2125 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 ); 2149 2128 2150 2129 /** … … 2154 2133 * @since 2.5.0 Added the `$group` parameter. 2155 2134 * 2156 * @param string $ valuePermalink of the Members page for a group.2135 * @param string $url Permalink of the Members page for a group. 2157 2136 * @param BP_Groups_Group $group The group object. 2158 2137 */ 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 ); 2160 2139 } 2161 2140 … … 2415 2394 */ 2416 2395 function bp_group_forum_permalink( $group = false ) { 2417 echo bp_get_group_forum_permalink( $group);2396 echo esc_url( bp_get_group_forum_permalink( $group ) ); 2418 2397 } 2419 2398 /** … … 2428 2407 */ 2429 2408 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 ); 2435 2411 2436 2412 /** … … 2443 2419 * @param BP_Groups_Group $group The group object. 2444 2420 */ 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 ); 2446 2422 } 2447 2423 … … 2888 2864 ); 2889 2865 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 ); 2891 2873 2892 2874 /** … … 2895 2877 * @since 1.1.0 2896 2878 * 2897 * @param string $ valueURL 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 ); 2900 2882 } 2901 2883 … … 2934 2916 ); 2935 2917 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 ); 2937 2925 2938 2926 /** … … 2941 2929 * @since 1.1.0 2942 2930 * 2943 * @param string $ valueURL 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 ); 2946 2934 } 2947 2935 … … 2973 2961 global $members_template; 2974 2962 2975 $group = bp_get_group( $group );2976 2977 if ( empty( $group->id ) ) {2978 return '';2979 }2980 2981 2963 if ( ! $user_id ) { 2982 2964 $user_id = $members_template->member->user_id; 2983 2965 } 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 ); 2984 2974 2985 2975 /** … … 2990 2980 * @since 10.0.0 Added the `$user_id` parameter. 2991 2981 * 2992 * @param string $ valueURL to use for demoting a user to member.2982 * @param string $url URL to use for demoting a user to member. 2993 2983 * @param BP_Groups_Group $group The group object. 2994 2984 * @param int $user_id The user ID. 2995 2985 */ 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 ); 3002 2987 } 3003 2988 … … 3029 3014 global $members_template; 3030 3015 3031 $group = bp_get_group( $group );3032 3033 if ( empty( $group->id ) ) {3034 return '';3035 }3036 3037 3016 if ( ! $user_id ) { 3038 3017 $user_id = $members_template->member->user_id; 3039 3018 } 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 ); 3040 3027 3041 3028 /** … … 3049 3036 * @param int $user_id The user ID. 3050 3037 */ 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 ); 3057 3039 } 3058 3040 … … 3084 3066 global $members_template; 3085 3067 3086 $group = bp_get_group( $group );3087 3088 if ( empty( $group->id ) ) {3089 return '';3090 }3091 3092 3068 if ( ! $user_id ) { 3093 3069 $user_id = $members_template->member->user_id; 3094 3070 } 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 ); 3095 3079 3096 3080 /** … … 3104 3088 * @param int $user_id The user ID. 3105 3089 */ 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 ); 3112 3091 } 3113 3092 … … 3139 3118 global $members_template; 3140 3119 3141 $group = bp_get_group( $group );3142 3143 if ( empty( $group->id ) ) {3144 return '';3145 }3146 3147 3120 if ( ! $user_id ) { 3148 3121 $user_id = $members_template->member->user_id; 3149 3122 } 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 ); 3150 3131 3151 3132 /** … … 3156 3137 * @since 10.0.0 Added the `$user_id` parameter. 3157 3138 * 3158 * @param string $ valueURL to use for removing a member.3139 * @param string $url URL to use for removing a member. 3159 3140 * @param BP_Groups_Group $group The group object. 3160 3141 * @param int $user_id The user ID. 3161 3142 */ 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 ); 3168 3144 } 3169 3145 … … 3647 3623 } 3648 3624 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 3649 3633 /** 3650 3634 * Filters the URL for confirming a request to leave a group. … … 3653 3637 * @since 2.5.0 Added the `$group` parameter. 3654 3638 * 3655 * @param string $ valueURL for confirming a request to leave a group.3639 * @param string $url URL for confirming a request to leave a group. 3656 3640 * @param object $group Group object. 3657 3641 */ 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 ); 3659 3643 } 3660 3644 … … 3719 3703 } 3720 3704 3705 $url = bp_get_group_url( 3706 $group, 3707 bp_groups_get_path_chunks( array( 'send-invites', 'send' ) ) 3708 ); 3709 3721 3710 /** 3722 3711 * Filters the 'action' attribute for a group send invite form. … … 3728 3717 * @param object $group Group object. 3729 3718 */ 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 ); 3731 3720 } 3732 3721 … … 3802 3791 return $button_args; 3803 3792 } 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 ); 3804 3801 3805 3802 // Setup button attributes. … … 3811 3808 'wrapper_class' => 'group-button ' . $group->status, 3812 3809 '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, 3814 3811 'link_text' => __( 'Leave Group', 'buddypress' ), 3815 3812 'link_title' => __( 'Leave Group', 'buddypress' ), … … 3826 3823 3827 3824 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 3828 3833 $button_args = array( 3829 3834 'id' => 'join_group', … … 3833 3838 'wrapper_class' => 'group-button ' . $group->status, 3834 3839 '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, 3836 3841 'link_text' => __( 'Join Group', 'buddypress' ), 3837 3842 'link_title' => __( 'Join Group', 'buddypress' ), … … 3877 3882 // show a "Request Membership" button. 3878 3883 } 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 3879 3892 $button_args = array( 3880 3893 'id' => 'request_membership', … … 3884 3897 'wrapper_class' => 'group-button ' . $group->status, 3885 3898 '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, 3887 3900 'link_text' => __( 'Request Membership', 'buddypress' ), 3888 3901 'link_title' => __( 'Request Membership', 'buddypress' ), … … 5939 5952 */ 5940 5953 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 ); 5942 5962 5943 5963 /** … … 5946 5966 * @since 1.1.0 5947 5967 * 5948 * @param string $ valueURL 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 ); 5951 5971 } 5952 5972 … … 6084 6104 global $requests_template; 6085 6105 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 ); 6091 6117 6092 6118 /** … … 6095 6121 * @since 1.2.6 6096 6122 * 6097 * @param string $ valueURL to use to reject a membership request.6123 * @param string $link URL to use to reject a membership request. 6098 6124 */ 6099 6125 return apply_filters( 'bp_get_group_request_reject_link', $link ); … … 6114 6140 global $requests_template; 6115 6141 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 ); 6121 6153 6122 6154 /** … … 6458 6490 $uninvite_url = bp_get_groups_directory_permalink() . 'create/step/group-invites/?user_id=' . $user_id; 6459 6491 } 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 ); 6461 6496 } 6462 6497 … … 6563 6598 */ 6564 6599 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 ); 6568 6604 6569 6605 /** … … 6742 6778 6743 6779 // 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 ); 6746 6785 } else { 6747 6786 $url = bp_get_group_url( $current_group ); -
trunk/src/bp-groups/classes/class-bp-group-extension.php
r13441 r13446 870 870 $current_group = groups_get_group( $this->group_id ); 871 871 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 ); 874 877 $no_access_args['redirect'] = false; 875 878 } -
trunk/src/bp-groups/classes/class-bp-groups-group-members-template.php
r13423 r13446 169 169 170 170 // 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() ); 172 172 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 ); 175 180 176 181 $members_args = $r; -
trunk/src/bp-groups/screens/single/admin.php
r11923 r13446 14 14 */ 15 15 function 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' ) ) { 17 17 return false; 18 } 18 19 19 if ( bp_action_variables() ) 20 if ( bp_action_variables() ) { 20 21 return false; 22 } 21 23 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 ); 23 30 } -
trunk/src/bp-groups/screens/single/admin/edit-details.php
r12381 r13446 54 54 do_action( 'groups_group_details_edited', $bp->groups->current_group->id ); 55 55 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 ); 57 62 } 58 63 -
trunk/src/bp-groups/screens/single/admin/group-settings.php
r12694 r13446 84 84 do_action( 'groups_group_settings_edited', $bp->groups->current_group->id ); 85 85 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 ); 87 92 } 88 93 -
trunk/src/bp-groups/screens/single/admin/manage-members.php
r11923 r13446 15 15 function groups_screen_group_admin_manage_members() { 16 16 17 if ( 'manage-members' != bp_get_group_current_admin_tab() ) 17 if ( 'manage-members' != bp_get_group_current_admin_tab() ) { 18 18 return false; 19 } 19 20 20 if ( ! bp_is_item_admin() ) 21 if ( ! bp_is_item_admin() ) { 21 22 return false; 23 } 22 24 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 ); 24 30 25 31 if ( bp_action_variable( 1 ) && bp_action_variable( 2 ) && bp_action_variable( 3 ) ) { … … 29 35 30 36 // Check the nonce first. 31 if ( ! check_admin_referer( 'groups_promote_member' ) )37 if ( ! check_admin_referer( 'groups_promote_member' ) ) { 32 38 return false; 39 } 33 40 34 41 // 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 ) ) { 36 43 bp_core_add_message( __( 'There was an error when promoting that user. Please try again.', 'buddypress' ), 'error' ); 37 else44 } else { 38 45 bp_core_add_message( __( 'User promoted successfully', 'buddypress' ) ); 46 } 39 47 40 48 /** … … 48 56 do_action( 'groups_promoted_member', $user_id, $bp->groups->current_group->id ); 49 57 50 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/');58 bp_core_redirect( $redirect ); 51 59 } 52 60 } … … 57 65 58 66 // Check the nonce first. 59 if ( ! check_admin_referer( 'groups_demote_member' ) )67 if ( ! check_admin_referer( 'groups_demote_member' ) ) { 60 68 return false; 69 } 61 70 62 71 // Stop sole admins from abandoning their group. 63 72 $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 ) { 65 74 bp_core_add_message( __( 'This group must have at least one admin', 'buddypress' ), 'error' ); 66 75 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 ) ) { 69 78 bp_core_add_message( __( 'There was an error when demoting that user. Please try again.', 'buddypress' ), 'error' ); 70 else79 } else { 71 80 bp_core_add_message( __( 'User demoted successfully', 'buddypress' ) ); 81 } 72 82 73 83 /** … … 81 91 do_action( 'groups_demoted_member', $user_id, $bp->groups->current_group->id ); 82 92 83 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/');93 bp_core_redirect( $redirect ); 84 94 } 85 95 … … 88 98 89 99 // Check the nonce first. 90 if ( ! check_admin_referer( 'groups_ban_member' ) )100 if ( ! check_admin_referer( 'groups_ban_member' ) ) { 91 101 return false; 102 } 92 103 93 104 // 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 ) ) { 95 106 bp_core_add_message( __( 'There was an error when banning that user. Please try again.', 'buddypress' ), 'error' ); 96 else107 } else { 97 108 bp_core_add_message( __( 'User banned successfully', 'buddypress' ) ); 109 } 98 110 99 111 /** … … 107 119 do_action( 'groups_banned_member', $user_id, $bp->groups->current_group->id ); 108 120 109 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/');121 bp_core_redirect( $redirect ); 110 122 } 111 123 … … 114 126 115 127 // Check the nonce first. 116 if ( ! check_admin_referer( 'groups_unban_member' ) )128 if ( ! check_admin_referer( 'groups_unban_member' ) ) { 117 129 return false; 130 } 118 131 119 132 // 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 ) ) { 121 134 bp_core_add_message( __( 'There was an error when unbanning that user. Please try again.', 'buddypress' ), 'error' ); 122 else135 } else { 123 136 bp_core_add_message( __( 'User ban removed successfully', 'buddypress' ) ); 137 } 124 138 125 139 /** … … 133 147 do_action( 'groups_unbanned_member', $user_id, $bp->groups->current_group->id ); 134 148 135 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/');149 bp_core_redirect( $redirect ); 136 150 } 137 151 … … 140 154 141 155 // Check the nonce first. 142 if ( ! check_admin_referer( 'groups_remove_member' ) )156 if ( ! check_admin_referer( 'groups_remove_member' ) ) { 143 157 return false; 158 } 144 159 145 160 // 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 ) ) { 147 162 bp_core_add_message( __( 'There was an error removing that user from the group. Please try again.', 'buddypress' ), 'error' ); 148 else163 } else { 149 164 bp_core_add_message( __( 'User removed successfully', 'buddypress' ) ); 165 } 150 166 151 167 /** … … 159 175 do_action( 'groups_removed_member', $user_id, $bp->groups->current_group->id ); 160 176 161 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'admin/manage-members/');177 bp_core_redirect( $redirect ); 162 178 } 163 179 } -
trunk/src/bp-groups/screens/single/admin/membership-requests.php
r12436 r13446 72 72 */ 73 73 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 ); 75 81 } 76 82 -
trunk/src/bp-members/bp-members-functions.php
r13443 r13446 140 140 141 141 /** 142 * Get members path chunks using an array of URL slugs.142 * Get single member's path chunks using an array of URL slugs. 143 143 * 144 144 * @since 12.0.0 … … 164 164 } 165 165 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 ) { 167 167 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 } 170 174 } 171 175 } -
trunk/src/bp-templates/bp-legacy/buddypress-functions.php
r13442 r13446 1423 1423 $user = new BP_Core_User( $friend_id ); 1424 1424 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 } 1428 1431 1429 1432 echo '<li id="uid-' . esc_attr( $user->id ) . '">'; … … 1641 1644 _e( 'Error joining group', 'buddypress' ); 1642 1645 } 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>'; 1644 1654 } 1645 1655 break; … … 1655 1665 _e( 'Error requesting membership', 'buddypress' ); 1656 1666 } 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>'; 1658 1675 } 1659 1676 break; … … 1675 1692 _e( 'Error leaving group', 'buddypress' ); 1676 1693 } 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>'; 1678 1702 } 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>'; 1680 1711 } 1681 1712 break;
Note: See TracChangeset
for help on using the changeset viewer.