Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/08/2011 12:11:29 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Attach component creation to 'bp_setup_component' action. Clean up bp-core-hooks.php and include new 'bp_setup_component' hook. Fixes issue with $bp reference in global scope in each component. See #3738.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-hooks.php

    r5289 r5300  
    33if ( !defined( 'ABSPATH' ) ) exit;
    44
    5 /** Loaded ********************************************************************/
     5/**
     6 * BuddyPress Filters & Actions
     7 *
     8 * @package BuddyPress
     9 * @subpackage Hooks
     10 *
     11 * This file contains the actions and filters that are used through-out BuddyPress.
     12 * They are consolidated here to make searching for them easier, and to help
     13 * developers understand at a glance the order in which things occur.
     14 *
     15 */
    616
    7 add_action( 'plugins_loaded', 'bp_loaded',  10 );
     17// Exit if accessed directly
     18if ( !defined( 'ABSPATH' ) ) exit;
    819
    9 add_action( 'bp_loaded',      'bp_include', 2  );
     20/** ACTIONS *******************************************************************/
    1021
    11 add_action( 'wp',             'bp_actions', 3  );
     22/**
     23 * Attach BuddyPress to WordPress
     24 *
     25 * BuddyPress uses its own internal actions to help aid in additional plugin
     26 * development, and to limit the amount of potential future code changes when
     27 * updates to WordPress occur.
     28 */
     29add_action( 'plugins_loaded',         'bp_loaded',                 10 );
     30add_action( 'init',                   'bp_init',                   10 );
     31add_action( 'wp',                     'bp_ready',                  10 );
     32//add_action( 'generate_rewrite_rules', 'bp_generate_rewrite_rules', 10 );
     33//add_action( 'wp_enqueue_scripts',     'bp_enqueue_scripts',        10 );
     34//add_filter( 'template_include',       'bp_template_include',       10 );
    1235
    13 add_action( 'wp',             'bp_screens', 4  );
     36/**
     37 * bp_loaded - Attached to 'plugins_loaded' above
     38 *
     39 * Attach various loader actions to the bp_loaded action.
     40 * The load order helps to execute code at the correct time.
     41 *                                                 v---Load order
     42 */
     43add_action( 'bp_loaded', 'bp_setup_components',    2  );
     44add_action( 'bp_loaded', 'bp_include',             4  );
     45add_action( 'bp_loaded', 'bp_setup_widgets',       6  );
     46add_action( 'bp_loaded', 'bp_core_load_admin_bar', 10 );
    1447
    15 /** Init **********************************************************************/
     48/**
     49 * bp_init - Attached to 'init' above
     50 *
     51 * Attach various initialization actions to the bp_init action.
     52 * The load order helps to execute code at the correct time.
     53 *                                                 v---Load order
     54 */
     55add_action( 'bp_init', 'bp_core_set_uri_globals',  2 );
     56add_action( 'bp_init', 'bp_setup_globals',         4 );
     57add_action( 'bp_init', 'bp_setup_nav',             6 );
     58add_action( 'bp_init', 'bp_setup_title',           8 );
    1659
    17 // Attach bp_init to WordPress init
    18 add_action( 'init',           'bp_init'                     );
     60/**
     61 * bp_ready - Attached to 'wp' above
     62 *
     63 * Attach various initialization actions to the bp_init action.
     64 * The load order helps to execute code at the correct time.
     65 *                                    v---Load order
     66 */
     67add_action( 'bp_ready', 'bp_actions', 2 );
     68add_action( 'bp_ready', 'bp_screens', 4 );
    1969
    20 // Parse the URI and set globals
    21 add_action( 'bp_init',        'bp_core_set_uri_globals',  2 );
    22 
    23 // Setup component globals
    24 add_action( 'bp_init',        'bp_setup_globals',         4 );
    25 
    26 // Setup the navigation menu
    27 add_action( 'bp_init',        'bp_setup_nav',             7 );
     70/** Admin Bar *****************************************************************/
    2871
    2972// Setup the navigation menu
    3073add_action( 'admin_bar_menu', 'bp_setup_admin_bar',      11 );
    31 
    32 // Setup the title
    33 add_action( 'bp_init',        'bp_setup_title',           9 );
    34 
    35 // Setup widgets
    36 add_action( 'bp_loaded',      'bp_setup_widgets'            );
    37 
    38 // Setup admin bar
    39 add_action( 'bp_loaded',      'bp_core_load_admin_bar'      );
    4074
    4175/** The hooks *****************************************************************/
     
    4680function bp_include() {
    4781    do_action( 'bp_include' );
     82}
     83
     84/**
     85 * Include files on this action
     86 */
     87function bp_setup_components() {
     88    do_action( 'bp_setup_components' );
    4889}
    4990
     
    99140
    100141/**
     142 * Attached to wp
     143 */
     144function bp_ready() {
     145    do_action( 'bp_ready' );
     146}
     147
     148/**
    101149 * Attach potential template actions
    102150 */
Note: See TracChangeset for help on using the changeset viewer.