Changeset 6118 for trunk/src/includes/core/capabilities.php
- Timestamp:
- 11/09/2016 09:51:11 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/core/capabilities.php
r6108 r6118 288 288 function bbp_add_forums_roles( $wp_roles = null ) { 289 289 290 // Attempt to get global roles if not passed in & not mid-initialization 291 if ( ( null === $wp_roles ) && ! doing_action( 'wp_roles_init' ) ) { 292 $wp_roles = bbp_get_wp_roles(); 293 } 290 // Get the dynamic roles 291 $bbp_roles = bbp_get_dynamic_roles(); 294 292 295 293 // Loop through dynamic roles and add them to the $wp_roles array 296 foreach ( bbp_get_dynamic_roles()as $role_id => $details ) {294 foreach ( $bbp_roles as $role_id => $details ) { 297 295 $wp_roles->roles[ $role_id ] = $details; 298 296 $wp_roles->role_objects[ $role_id ] = new WP_Role( $role_id, $details['capabilities'] ); … … 363 361 * 364 362 * @since 2.2.0 bbPress (r4284) 363 * @since 2.6.0 bbPress (r6117) Use bbpress()->roles 365 364 * 366 365 * @return array 367 366 */ 368 367 function bbp_get_dynamic_roles() { 369 static $bbp_roles = null; 370 371 // Only run once 372 if ( null === $bbp_roles ) { 373 $bbp_roles = array( 374 375 // Keymaster 376 bbp_get_keymaster_role() => array( 377 'name' => __( 'Keymaster', 'bbpress' ), 378 'capabilities' => bbp_get_caps_for_role( bbp_get_keymaster_role() ) 379 ), 380 381 // Moderator 382 bbp_get_moderator_role() => array( 383 'name' => __( 'Moderator', 'bbpress' ), 384 'capabilities' => bbp_get_caps_for_role( bbp_get_moderator_role() ) 385 ), 386 387 // Participant 388 bbp_get_participant_role() => array( 389 'name' => __( 'Participant', 'bbpress' ), 390 'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) 391 ), 392 393 // Spectator 394 bbp_get_spectator_role() => array( 395 'name' => __( 'Spectator', 'bbpress' ), 396 'capabilities' => bbp_get_caps_for_role( bbp_get_spectator_role() ) 397 ), 398 399 // Blocked 400 bbp_get_blocked_role() => array( 401 'name' => __( 'Blocked', 'bbpress' ), 402 'capabilities' => bbp_get_caps_for_role( bbp_get_blocked_role() ) 403 ) 404 ); 368 369 // Defaults 370 $to_array = array(); 371 $roles = bbpress()->roles; 372 373 // Convert WP_Roles objects to arrays 374 foreach ( $roles as $role_id => $wp_role ) { 375 $to_array[ $role_id ] = (array) $wp_role; 405 376 } 406 377 407 378 // Filter & return 408 return (array) apply_filters( 'bbp_get_dynamic_roles', $ bbp_roles );379 return (array) apply_filters( 'bbp_get_dynamic_roles', $to_array, $roles ); 409 380 } 410 381 … … 413 384 * 414 385 * @since 2.3.0 bbPress (r4792) 386 * @since 2.6.0 bbPress (r6117) Use bbp_translate_user_role() 415 387 * 416 388 * @param string $role_id … … 419 391 function bbp_get_dynamic_role_name( $role_id = '' ) { 420 392 $roles = bbp_get_dynamic_roles(); 421 $role = isset( $roles[ $role_id ] ) ? $roles[ $role_id ]['name'] : ''; 393 $role = isset( $roles[ $role_id ] ) 394 ? bbp_translate_user_role( $roles[ $role_id ]['name'] ) 395 : ''; 422 396 423 397 return apply_filters( 'bbp_get_dynamic_role_name', $role, $role_id, $roles ); … … 433 407 * 434 408 * @param array $all_roles All registered roles 435 * @return array 409 * @return array 436 410 */ 437 411 function bbp_filter_blog_editable_roles( $all_roles = array() ) { … … 527 501 * Removes bbPress-specific user roles from the `wp_user_roles` array. 528 502 * 529 * This is currently only used when updating, uninstalling, or resetting bbPress. 503 * This is currently only used when updating, uninstalling, or resetting bbPress. 530 504 * 531 505 * @see bbp_admin_reset_handler()
Note: See TracChangeset
for help on using the changeset viewer.