Ticket #6501: 6501.02.patch
| File 6501.02.patch, 2.3 KB (added by , 11 years ago) |
|---|
-
src/bp-core/bp-core-caps.php
263 263 /** 264 264 * Check whether the current user has a given capability. 265 265 * 266 * Can be passed blog ID, or will use the root blog by default.267 *268 266 * @since BuddyPress (1.6.0) 269 267 * 270 * @param string $capability Capability or role name. 271 * @param int $blog_id Optional. Blog ID. Defaults to the BP root blog. 268 * @param string $capability Capability or role name. 269 * @param array|int $args { 270 * Array of extra arguments applicable to the capability check. 271 * @type int $blog_id Optional. Blog ID. Defaults to the BP root blog. 272 * @type mixed $a,... Optional. Extra arguments applicable to the capability check. 273 * } 272 274 * @return bool True if the user has the cap for the given blog. 273 275 */ 274 function bp_current_user_can( $capability, $blog_id = 0 ) { 276 function bp_current_user_can( $capability, $args = array() ) { 277 $blog_id = 0; 278 279 // Backward compatibility for older $blog_id parameter 280 if ( is_int( $args ) ) { 281 $blog_id = $args; 282 $args = array(); 283 284 // New format for second parameter 285 } elseif ( is_array( $args ) && isset( $args['blog_id'] ) ) { 286 // Get the blog ID if set 287 $blog_id = (int) $args['blog_id']; 288 unset( $args['blog_id'] ); 289 } 275 290 276 291 // Use root blog if no ID passed 277 292 if ( empty( $blog_id ) ) { 278 293 $blog_id = bp_get_root_blog_id(); 279 294 } 280 295 281 $retval = current_user_can_for_blog( $blog_id, $capability ); 296 $args = array( $blog_id, $capability, $args ); 297 $retval = call_user_func_array( 'current_user_can_for_blog', $args ); 282 298 283 299 /** 284 300 * Filters whether or not the current user has a given capability. 285 301 * 286 302 * @since BuddyPress (1.6.0) 303 * @since BuddyPress (2.4.0) Pass $args variable. 287 304 * 288 305 * @param bool $retval Whether or not the current user has the capability. 289 306 * @param string $capability The capability being checked for. 290 307 * @param int $blog_id Blog ID. Defaults to the BP root blog. 308 * @param array $args Array of extra arguments passed. 291 309 */ 292 return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id );310 return (bool) apply_filters( 'bp_current_user_can', $retval, $capability, $blog_id, $args ); 293 311 } 294 312 295 313 /**