Skip to:
Content

bbPress.org

Changeset 6118 for trunk/src/bbpress.php


Ignore:
Timestamp:
11/09/2016 09:51:11 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Roles: Fix infinite loops from load order changes in WordPress 4.7.

  • Do not translate "role names" which are actually role IDs
  • Add dummy function so literal role names are part of the pomo dictionary
  • Introduce common/locale.php for future localization code
  • Introduce roles variable to main bbPress class, and store loaded roles there
  • Introduce bbp_translate_user_role() to help with outputting literal role names in the proper language

See #3017. For trunk (2.6)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bbpress.php

    r6092 r6118  
    6767     * @var array Topic views
    6868     */
    69     public $views        = array();
     69    public $views = array();
    7070
    7171    /**
    7272     * @var array Overloads get_option()
    7373     */
    74     public $options      = array();
     74    public $options = array();
    7575
    7676    /**
     
    7878     */
    7979    public $user_options = array();
     80
     81    /**
     82     * @var array Dynamically initialized user roles
     83     */
     84    public $roles = array();
    8085
    8186    /** Singleton *************************************************************/
     
    316321        require $this->includes_dir . 'common/functions.php';
    317322        require $this->includes_dir . 'common/formatting.php';
     323        require $this->includes_dir . 'common/locale.php';
    318324        require $this->includes_dir . 'common/template.php';
    319325        require $this->includes_dir . 'common/widgets.php';
     
    383389            'setup_theme',              // Setup the default theme compat
    384390            'setup_current_user',       // Setup currently logged in user
     391            'roles_init',               // User roles init
    385392            'register_post_types',      // Register post types (forum|topic|reply)
    386393            'register_post_statuses',   // Register post statuses (closed|spam|orphan|hidden)
     
    745752     * Setup the currently logged-in user
    746753     *
    747      * Do not to call this prematurely, I.E. before the 'init' action has
    748      * started. This function is naturally hooked into 'init' to ensure proper
    749      * execution. get_currentuserinfo() is used to check for XMLRPC_REQUEST to
    750      * avoid xmlrpc errors.
    751      *
    752754     * @since 2.0.0 bbPress (r2697)
    753755     *
     
    756758    public function setup_current_user() {
    757759        $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     ) );
    758782    }
    759783
Note: See TracChangeset for help on using the changeset viewer.