Skip to:
Content

bbPress.org

Changeset 6106


Ignore:
Timestamp:
11/01/2016 05:14:29 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Roles: Introduce bbp_roles_init subaction, and use this for future dynamic roles initialization.

See: #2452;

Location:
trunk/src/includes/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/abstraction.php

    r6057 r6106  
    88 *
    99 * Many of the functions in this file are considered superfluous by
    10  * WordPress coding standards, but
     10 * WordPress coding standards, but they're handy for plugins of plugins to use.
    1111 *
    1212 * @package bbPress
     
    4949    // Filter & return
    5050    return apply_filters( 'bbp_get_global_object', $retval, $name, $type, $default );
     51}
     52
     53/**
     54 * Get the `$wp_roles` global without needing to declare it everywhere
     55 *
     56 * @since 2.2.0 bbPress (r4293)
     57 *
     58 * @return WP_Roles
     59 */
     60function bbp_get_wp_roles() {
     61    return bbp_get_global_object( 'wp_roles', 'WP_Roles' );
    5162}
    5263
  • trunk/src/includes/core/actions.php

    r6058 r6106  
    4242add_action( 'parse_query',              'bbp_parse_query',            2     ); // Early for overrides
    4343add_action( 'widgets_init',             'bbp_widgets_init',           10    );
     44add_action( 'wp_roles_init',            'bbp_roles_init',             10    );
    4445add_action( 'generate_rewrite_rules',   'bbp_generate_rewrite_rules', 10    );
    4546add_action( 'wp_enqueue_scripts',       'bbp_enqueue_scripts',        10    );
     
    6869add_action( 'bbp_loaded', 'bbp_setup_user_option_filters', 12 );
    6970add_action( 'bbp_loaded', 'bbp_register_theme_packages',   14 );
    70 add_action( 'bbp_loaded', 'bbp_filter_user_roles_option',  16 );
    7171
    7272/**
     
    8585
    8686/**
    87  * There is no action API for roles to use, so hook in immediately after
    88  * everything is included (including the theme's functions.php. This is after
    89  * the $wp_roles global is set but before $wp->init().
    90  *
    91  * If it's hooked in any sooner, role names may not be translated correctly.
    92  *
    93  * @link https://bbpress.trac.wordpress.org/ticket/2219
    94  *
    95  * This is kind of lame, but is all we have for now.
    96  */
    97 add_action( 'bbp_after_setup_theme', 'bbp_add_forums_roles', 1 );
     87 * bbp_roles_init - Attached to 'wp_roles_init' above
     88 *
     89 * Attach various role related actions to the wp_roles_init action.
     90 * The load order helps to execute code at the correct time.
     91 *                                                    v---Load order
     92 */
     93add_action( 'bbp_roles_init', 'bbp_add_forums_roles', 1 );
    9894
    9995/**
  • trunk/src/includes/core/sub-actions.php

    r6105 r6106  
    134134function bbp_init() {
    135135    do_action( 'bbp_init' );
     136}
     137
     138/**
     139 * Initialize roles
     140 *
     141 * @since 2.6.0 bbPress (r6106)
     142 *
     143 * @uses do_action() Calls 'bbp_roles_init'
     144 *
     145 * @param WP_Roles $wp_roles The array of WP_Role objects that was initialized
     146 */
     147function bbp_roles_init( $wp_roles ) {
     148    do_action( 'bbp_roles_init', $wp_roles );
    136149}
    137150
Note: See TracChangeset for help on using the changeset viewer.