Skip to:
Content

bbPress.org

Changeset 4181


Ignore:
Timestamp:
09/03/2012 09:01:51 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Introduce bbp_register subaction:

  • Switch bbp_init priority to init 0.
  • Hook bbp_register to bbp_init, prority 0.
  • Hook _register_ actions onto bbp_register.
  • Registers post types, taxonomies, post statuses, shortcodes, and topic views early, so they are available ahead of 'init' action.
  • Fixes plugin dependency issue with bbPress objects not being registered when they are needed.
Location:
branches/plugin/bbp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-core-actions.php

    r4154 r4181  
    4242 */
    4343add_action( 'plugins_loaded',         'bbp_loaded',                 10 );
    44 add_action( 'init',                   'bbp_init',                   10 );
     44add_action( 'init',                   'bbp_init',                   0  ); // Early for bbp_register
     45add_action( 'parse_query',            'bbp_parse_query',            2  ); // Early for overrides
    4546add_action( 'widgets_init',           'bbp_widgets_init',           10 );
    46 add_action( 'parse_query',            'bbp_parse_query',            2  ); // Early for overrides
    4747add_action( 'generate_rewrite_rules', 'bbp_generate_rewrite_rules', 10 );
    4848add_action( 'wp_enqueue_scripts',     'bbp_enqueue_scripts',        10 );
     
    7777 * Attach various initialization actions to the init action.
    7878 * The load order helps to execute code at the correct time.
    79  *                                                    v---Load order
    80  */
    81 add_action( 'bbp_init', 'bbp_register_post_types',     10  );
    82 add_action( 'bbp_init', 'bbp_register_post_statuses',  12  );
    83 add_action( 'bbp_init', 'bbp_register_taxonomies',     14  );
    84 add_action( 'bbp_init', 'bbp_register_views',          16  );
    85 add_action( 'bbp_init', 'bbp_register_shortcodes',     18  );
    86 add_action( 'bbp_init', 'bbp_add_rewrite_tags',        20  );
    87 add_action( 'bbp_init', 'bbp_ready',                   999 );
     79 *                                              v---Load order
     80 */
     81add_action( 'bbp_init', 'bbp_register',         0   );
     82add_action( 'bbp_init', 'bbp_add_rewrite_tags', 20  );
     83add_action( 'bbp_init', 'bbp_ready',            999 );
     84
     85/**
     86 * bbp_register - Attached to 'init' above on 0 priority
     87 *
     88 * Attach various initialization actions early to the init action.
     89 * The load order helps to execute code at the correct time.
     90 *                                                         v---Load order
     91 */
     92add_action( 'bbp_register', 'bbp_register_post_types',     2  );
     93add_action( 'bbp_register', 'bbp_register_post_statuses',  4  );
     94add_action( 'bbp_register', 'bbp_register_taxonomies',     6  );
     95add_action( 'bbp_register', 'bbp_register_views',          8  );
     96add_action( 'bbp_register', 'bbp_register_shortcodes',     10 );
    8897
    8998// Autoembeds
  • branches/plugin/bbp-includes/bbp-core-dependency.php

    r4154 r4181  
    104104
    105105/**
     106 * Register any objects before anything is initialized
     107 *
     108 * @since bbPress (r4180)
     109 * @uses do_action() Calls 'bbp_register'
     110 */
     111function bbp_register() {
     112    do_action( 'bbp_register' );
     113}
     114
     115/**
    106116 * Initialize any code after everything has been loaded
    107117 *
     
    110120 */
    111121function bbp_init() {
    112     do_action ( 'bbp_init' );
     122    do_action( 'bbp_init' );
    113123}
    114124
     
    120130 */
    121131function bbp_widgets_init() {
    122     do_action ( 'bbp_widgets_init' );
     132    do_action( 'bbp_widgets_init' );
    123133}
    124134
     
    130140 */
    131141function bbp_setup_current_user() {
    132     do_action ( 'bbp_setup_current_user' );
     142    do_action( 'bbp_setup_current_user' );
    133143}
    134144
     
    162172 */
    163173function bbp_register_post_types() {
    164     do_action ( 'bbp_register_post_types' );
     174    do_action( 'bbp_register_post_types' );
    165175}
    166176
     
    172182 */
    173183function bbp_register_post_statuses() {
    174     do_action ( 'bbp_register_post_statuses' );
     184    do_action( 'bbp_register_post_statuses' );
    175185}
    176186
     
    182192 */
    183193function bbp_register_taxonomies() {
    184     do_action ( 'bbp_register_taxonomies' );
     194    do_action( 'bbp_register_taxonomies' );
    185195}
    186196
     
    192202 */
    193203function bbp_register_views() {
    194     do_action ( 'bbp_register_views' );
     204    do_action( 'bbp_register_views' );
    195205}
    196206
     
    202212 */
    203213function bbp_enqueue_scripts() {
    204     do_action ( 'bbp_enqueue_scripts' );
     214    do_action( 'bbp_enqueue_scripts' );
    205215}
    206216
     
    212222 */
    213223function bbp_add_rewrite_tags() {
    214     do_action ( 'bbp_add_rewrite_tags' );
     224    do_action( 'bbp_add_rewrite_tags' );
    215225}
    216226
     
    222232 */
    223233function bbp_login_form_login() {
    224     do_action ( 'bbp_login_form_login' );
     234    do_action( 'bbp_login_form_login' );
    225235}
    226236
Note: See TracChangeset for help on using the changeset viewer.