Changeset 5827 for trunk/src/includes/core/capabilities.php
- Timestamp:
- 07/14/2015 12:31:42 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/core/capabilities.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/core/capabilities.php
r5770 r5827 244 244 245 245 /** 246 * Get the $wp_rolesglobal without needing to declare it everywhere246 * Get the `$wp_roles` global without needing to declare it everywhere 247 247 * 248 248 * @since bbPress (r4293) 249 249 * 250 * @global WP_Roles $wp_roles251 250 * @return WP_Roles 252 251 */ 253 252 function bbp_get_wp_roles() { 254 global $wp_roles; 255 256 // Load roles if not set 257 if ( ! isset( $wp_roles ) ) { 258 $wp_roles = new WP_Roles(); 259 } 260 261 return $wp_roles; 253 254 // Try to get `$wp_roles` 255 $retval = bbp_get_global_object( 'wp_roles', 'WP_Roles' ); 256 257 // Set roles if not loaded 258 if ( is_null( $retval ) ) { 259 $retval = $GLOBALS['wp_roles'] = new WP_Roles(); 260 } 261 262 return $retval; 262 263 } 263 264 … … 273 274 274 275 // Get WordPress's roles (returns $wp_roles global) 275 $wp_roles = bbp_get_wp_roles();276 $wp_roles = bbp_get_wp_roles(); 276 277 277 278 // Apply the WordPress 'editable_roles' filter to let plugins ride along. … … 302 303 303 304 foreach ( bbp_get_dynamic_roles() as $role_id => $details ) { 304 $wp_roles->roles[ $role_id] = $details;305 $wp_roles->role_objects[ $role_id] = new WP_Role( $role_id, $details['capabilities'] );306 $wp_roles->role_names[ $role_id] = $details['name'];305 $wp_roles->roles[ $role_id ] = $details; 306 $wp_roles->role_objects[ $role_id ] = new WP_Role( $role_id, $details['capabilities'] ); 307 $wp_roles->role_names[ $role_id ] = $details['name']; 307 308 } 308 309 … … 316 317 * 317 318 * @see _bbp_reinit_dynamic_roles() 318 *319 * @global WPDB $wpdb Used to get the database prefix320 319 */ 321 320 function bbp_filter_user_roles_option() { 322 global $wpdb; 323 324 $role_key = $wpdb->prefix . 'user_roles'; 321 $role_key = bbp_db()->prefix . 'user_roles'; 325 322 326 323 add_filter( 'option_' . $role_key, '_bbp_reinit_dynamic_roles' ); … … 419 416 function bbp_get_dynamic_role_name( $role_id = '' ) { 420 417 $roles = bbp_get_dynamic_roles(); 421 $role = isset( $roles[ $role_id] ) ? $roles[$role_id]['name'] : '';418 $role = isset( $roles[ $role_id ] ) ? $roles[ $role_id ]['name'] : ''; 422 419 423 420 return apply_filters( 'bbp_get_dynamic_role_name', $role, $role_id, $roles ); … … 445 442 // If keys match, unset 446 443 if ( $wp_role === $bbp_role ) { 447 unset( $all_roles[ $wp_role] );444 unset( $all_roles[ $wp_role ] ); 448 445 } 449 446 }
Note: See TracChangeset
for help on using the changeset viewer.