Changeset 6118
- Timestamp:
- 11/09/2016 09:51:11 PM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bbpress.php
r6092 r6118 67 67 * @var array Topic views 68 68 */ 69 public $views 69 public $views = array(); 70 70 71 71 /** 72 72 * @var array Overloads get_option() 73 73 */ 74 public $options 74 public $options = array(); 75 75 76 76 /** … … 78 78 */ 79 79 public $user_options = array(); 80 81 /** 82 * @var array Dynamically initialized user roles 83 */ 84 public $roles = array(); 80 85 81 86 /** Singleton *************************************************************/ … … 316 321 require $this->includes_dir . 'common/functions.php'; 317 322 require $this->includes_dir . 'common/formatting.php'; 323 require $this->includes_dir . 'common/locale.php'; 318 324 require $this->includes_dir . 'common/template.php'; 319 325 require $this->includes_dir . 'common/widgets.php'; … … 383 389 'setup_theme', // Setup the default theme compat 384 390 'setup_current_user', // Setup currently logged in user 391 'roles_init', // User roles init 385 392 'register_post_types', // Register post types (forum|topic|reply) 386 393 'register_post_statuses', // Register post statuses (closed|spam|orphan|hidden) … … 745 752 * Setup the currently logged-in user 746 753 * 747 * Do not to call this prematurely, I.E. before the 'init' action has748 * started. This function is naturally hooked into 'init' to ensure proper749 * execution. get_currentuserinfo() is used to check for XMLRPC_REQUEST to750 * avoid xmlrpc errors.751 *752 754 * @since 2.0.0 bbPress (r2697) 753 755 * … … 756 758 public function setup_current_user() { 757 759 $this->current_user = wp_get_current_user(); 760 } 761 762 /** 763 * Initialize forum-specific roles 764 * 765 * @since 2.6.0 766 */ 767 public function roles_init() { 768 769 // Get role IDs 770 $keymaster = bbp_get_keymaster_role(); 771 $moderator = bbp_get_moderator_role(); 772 $participant = bbp_get_participant_role(); 773 $spectator = bbp_get_spectator_role(); 774 $blocked = bbp_get_blocked_role(); 775 776 // Build the roles into one useful array 777 $this->roles[ $keymaster ] = new WP_Role( 'Keymaster', bbp_get_caps_for_role( $keymaster ) ); 778 $this->roles[ $moderator ] = new WP_Role( 'Moderator', bbp_get_caps_for_role( $moderator ) ); 779 $this->roles[ $participant ] = new WP_Role( 'Participant', bbp_get_caps_for_role( $participant ) ); 780 $this->roles[ $spectator ] = new WP_Role( 'Spectator', bbp_get_caps_for_role( $spectator ) ); 781 $this->roles[ $blocked ] = new WP_Role( 'Blocked', bbp_get_caps_for_role( $blocked ) ); 758 782 } 759 783 -
trunk/src/includes/admin/settings.php
r6089 r6118 536 536 <?php foreach ( bbp_get_dynamic_roles() as $role => $details ) : ?> 537 537 538 <option <?php selected( $default_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>538 <option <?php selected( $default_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option> 539 539 540 540 <?php endforeach; ?> -
trunk/src/includes/admin/users.php
r6061 r6118 119 119 <?php foreach ( $dynamic_roles as $role => $details ) : ?> 120 120 121 <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>121 <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option> 122 122 123 123 <?php endforeach; ?> … … 170 170 <option value=''><?php esc_html_e( 'Change forum role to…', 'bbpress' ) ?></option> 171 171 <?php foreach ( $dynamic_roles as $role => $details ) : ?> 172 <option value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>172 <option value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option> 173 173 <?php endforeach; ?> 174 174 </select><?php submit_button( __( 'Change', 'bbpress' ), 'secondary', $button_id, false ); … … 289 289 if ( ! empty( $user_role ) ) { 290 290 $roles = bbp_get_dynamic_roles(); 291 $retval = translate_user_role( $roles[ $user_role ]['name'] );291 $retval = bbp_translate_user_role( $roles[ $user_role ]['name'] ); 292 292 } 293 293 } -
trunk/src/includes/core/actions.php
r6106 r6118 91 91 * v---Load order 92 92 */ 93 add_action( 'bbp_roles_init', 'bbp_add_forums_roles', 1);93 add_action( 'bbp_roles_init', 'bbp_add_forums_roles', 8 ); 94 94 95 95 /** -
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() -
trunk/src/includes/users/template.php
r6062 r6118 1326 1326 <?php foreach ( $blog_roles as $role => $details ) : ?> 1327 1327 1328 <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>1328 <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option> 1329 1329 1330 1330 <?php endforeach; ?> … … 1363 1363 <?php foreach ( $dynamic_roles as $role => $details ) : ?> 1364 1364 1365 <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo translate_user_role( $details['name'] ); ?></option>1365 <option <?php selected( $user_role, $role ); ?> value="<?php echo esc_attr( $role ); ?>"><?php echo bbp_translate_user_role( $details['name'] ); ?></option> 1366 1366 1367 1367 <?php endforeach; ?>
Note: See TracChangeset
for help on using the changeset viewer.