Changeset 4293
- Timestamp:
- 11/02/2012 07:07:41 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/core/capabilities.php
r4292 r4293 544 544 */ 545 545 function bbp_add_caps() { 546 global $wp_roles;547 548 // Load roles if not set549 if ( ! isset( $wp_roles ) )550 $wp_roles = new WP_Roles();551 546 552 547 // Loop through available roles and add caps 553 foreach( $wp_roles->role_objects as $role ) {548 foreach( bbp_get_wp_roles()->role_objects as $role ) { 554 549 foreach ( bbp_get_caps_for_role( $role->name ) as $cap => $value ) { 555 550 $role->add_cap( $cap, $value ); … … 566 561 */ 567 562 function bbp_remove_caps() { 568 global $wp_roles;569 570 // Load roles if not set571 if ( ! isset( $wp_roles ) )572 $wp_roles = new WP_Roles();573 563 574 564 // Loop through available roles and remove caps 575 foreach( $wp_roles->role_objects as $role ) {565 foreach( bbp_get_wp_roles()->role_objects as $role ) { 576 566 foreach ( array_keys( bbp_get_caps_for_role( $role->name ) ) as $cap ) { 577 567 $role->remove_cap( $cap ); … … 582 572 } 583 573 584 /** Forum Roles ***************************************************************/ 585 586 /** 587 * Add the bbPress roles to the $wp_roles global. 588 * 589 * We do this to avoid adding these values to the database. 590 * 591 * @since bbPress (rxxxx) 592 * @global type $wp_roles 593 */ 594 function bbp_add_forums_roles() { 595 global $wp_roles, $wp_user_roles; 596 574 /** 575 * Get the $wp_roles global without needing to declare it everywhere 576 * 577 * @since bbPress (r4293) 578 * 579 * @global WP_Roles $wp_roles 580 * @return WP_Roles 581 */ 582 function bbp_get_wp_roles() { 583 global $wp_roles; 584 585 // Load roles if not set 597 586 if ( ! isset( $wp_roles ) ) 598 587 $wp_roles = new WP_Roles(); 599 588 600 // Loop through bbPress's roles and add them to the global $wp_roles 601 foreach( bbp_get_forums_editable_roles() as $role_id => $details ) { 589 return $wp_roles; 590 } 591 592 /** Forum Roles ***************************************************************/ 593 594 /** 595 * Add the bbPress roles to the $wp_roles global. 596 * 597 * We do this to avoid adding these values to the database. 598 * 599 * @since bbPress (r4290) 600 */ 601 function bbp_add_forums_roles() { 602 $wp_roles = bbp_get_wp_roles(); 603 604 foreach( bbp_get_editable_roles() as $role_id => $details ) { 602 605 $wp_roles->roles[$role_id] = $details; 603 606 $wp_roles->role_objects[$role_id] = new WP_Role( $details['name'], $details['capabilities'] ); 604 607 $wp_roles->role_names[$role_id] = $details['name']; 605 608 } 606 607 // Force WordPress not to use the DB608 $wp_user_roles = $wp_roles;609 609 } 610 610 … … 626 626 * @return array 627 627 */ 628 function bbp_get_ forums_editable_roles() {629 return (array) apply_filters( 'bbp_get_ forums_editable_roles', array(628 function bbp_get_editable_roles() { 629 return (array) apply_filters( 'bbp_get_editable_roles', array( 630 630 631 631 // Keymaster
Note: See TracChangeset
for help on using the changeset viewer.