Skip to:
Content

BuddyPress.org

Changeset 5300


Ignore:
Timestamp:
11/08/2011 12:11:29 AM (13 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.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-loader.php

    r5282 r5300  
    331331}
    332332
    333 // Create the activity component
    334 $bp->activity = new BP_Activity_Component();
     333function bp_setup_activity() {
     334    global $bp;
     335
     336    $bp->activity = new BP_Activity_Component();
     337}
     338add_action( 'bp_setup_components', 'bp_setup_activity', 6 );
     339
    335340?>
  • trunk/bp-blogs/bp-blogs-loader.php

    r5282 r5300  
    192192    }
    193193}
    194 // Create the blogs component
    195 $bp->blogs = new BP_Blogs_Component();
     194
     195function bp_setup_blogs() {
     196    global $bp;
     197    $bp->blogs = new BP_Blogs_Component();
     198}
     199add_action( 'bp_setup_components', 'bp_setup_blogs', 6 );
    196200
    197201?>
  • 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 */
  • trunk/bp-core/bp-core-loader.php

    r5272 r5300  
    230230}
    231231
    232 // Initialize the BuddyPress Core
    233 $bp->core = new BP_Core();
     232function bp_setup_core() {
     233    global $bp;
     234    $bp->core = new BP_Core();
     235}
     236add_action( 'bp_setup_components', 'bp_setup_core', 2 );
    234237
    235238?>
  • trunk/bp-forums/bp-forums-loader.php

    r5282 r5300  
    248248    }
    249249}
    250 // Create the forums component
    251 $bp->forums = new BP_Forums_Component();
     250
     251function bp_setup_forums() {
     252    global $bp;
     253
     254    $bp->forums = new BP_Forums_Component();
     255}
     256add_action( 'bp_setup_components', 'bp_setup_forums', 6 );
    252257
    253258?>
  • trunk/bp-friends/bp-friends-loader.php

    r5282 r5300  
    207207    }
    208208}
    209 // Create the friends component
    210 $bp->friends = new BP_Friends_Component();
     209
     210function bp_setup_friends() {
     211    global $bp;
     212    $bp->friends = new BP_Friends_Component();
     213}
     214add_action( 'bp_setup_components', 'bp_setup_friends', 6 );
    211215
    212216?>
  • trunk/bp-groups/bp-groups-loader.php

    r5282 r5300  
    472472    }
    473473}
    474 // Create the groups component
    475 $bp->groups = new BP_Groups_Component();
     474
     475
     476function bp_setup_groups() {
     477    global $bp;
     478
     479    $bp->groups = new BP_Groups_Component();
     480}
     481add_action( 'bp_setup_components', 'bp_setup_groups', 6 );
    476482
    477483?>
  • trunk/bp-members/bp-members-loader.php

    r5098 r5300  
    186186        parent::setup_title();
    187187    }
     188}
    188189
     190function bp_setup_members() {
     191    global $bp;
     192    $bp->members = new BP_Members_Component();
    189193}
    190 // Create the users component
    191 $bp->members = new BP_Members_Component();
     194add_action( 'bp_setup_components', 'bp_setup_members', 1 );
    192195
    193196?>
  • trunk/bp-messages/bp-messages-loader.php

    r5282 r5300  
    252252    }
    253253}
    254 // Create the messages component
    255 $bp->messages = new BP_Messages_Component();
     254
     255function bp_setup_messages() {
     256    global $bp;
     257    $bp->messages = new BP_Messages_Component();
     258}
     259add_action( 'bp_setup_components', 'bp_setup_messages', 6 );
    256260
    257261?>
  • trunk/bp-settings/bp-settings-loader.php

    r5282 r5300  
    182182    }
    183183}
    184 // Create the settingss component
    185 $bp->settings = new BP_Settings_Component();
     184
     185function bp_setup_settings() {
     186    global $bp;
     187    $bp->settings = new BP_Settings_Component();
     188}
     189add_action( 'bp_setup_components', 'bp_setup_settings', 6 );
    186190
    187191?>
  • trunk/bp-xprofile/bp-xprofile-loader.php

    r5282 r5300  
    231231    }
    232232}
    233 // Create the xprofile component
    234 if ( !isset( $bp->profile->id ) )
    235     $bp->profile = new BP_XProfile_Component();
     233
     234function bp_setup_xprofile() {
     235    global $bp;
     236
     237    if ( !isset( $bp->profile->id ) )
     238        $bp->profile = new BP_XProfile_Component();
     239}
     240add_action( 'bp_setup_components', 'bp_setup_xprofile', 6 );
    236241
    237242?>
Note: See TracChangeset for help on using the changeset viewer.