Skip to:
Content

BuddyPress.org

Changeset 6762


Ignore:
Timestamp:
02/04/2013 01:35:38 AM (7 years ago)
Author:
johnjamesjacoby
Message:

Move bp_core_load_admin_bar() to bp_init, and also move the function itself into bp-core-adminbar.php next to bp_core_load_admin_bar_css(). Fixes bug causing current user to be loaded out of order. Fixes #4803. See #3661.

Location:
trunk/bp-core
Files:
3 edited

Legend:

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

    r6724 r6762  
    5454add_action( 'bp_loaded', 'bp_include',                  4  );
    5555add_action( 'bp_loaded', 'bp_setup_widgets',            6  );
    56 add_action( 'bp_loaded', 'bp_core_load_admin_bar',      10 );
    5756add_action( 'bp_loaded', 'bp_register_theme_packages',  12 );
    5857add_action( 'bp_loaded', 'bp_register_theme_directory', 14 );
     
    6362 * Attach various initialization actions to the bp_init action.
    6463 * The load order helps to execute code at the correct time.
    65  *                                                 v---Load order
     64 *                                                   v---Load order
    6665 */
    67 add_action( 'bp_init', 'bp_core_set_uri_globals',  2  );
    68 add_action( 'bp_init', 'bp_setup_globals',         4  );
    69 add_action( 'bp_init', 'bp_setup_nav',             6  );
    70 add_action( 'bp_init', 'bp_setup_title',           8  );
     66add_action( 'bp_init', 'bp_core_set_uri_globals',    2  );
     67add_action( 'bp_init', 'bp_setup_globals',           4  );
     68add_action( 'bp_init', 'bp_setup_nav',               6  );
     69add_action( 'bp_init', 'bp_setup_title',             8  );
     70add_action( 'bp_init', 'bp_core_load_admin_bar',     10 );
     71add_action( 'bp_init', 'bp_core_load_admin_bar_css', 12 );
    7172
    7273/**
  • trunk/bp-core/bp-core-adminbar.php

    r6342 r6762  
    4545
    4646/**
     47 * Handle the Toolbar/BuddyBar business
     48 *
     49 * @since BuddyPress (1.2)
     50 *
     51 * @global string $wp_version
     52 * @uses bp_get_option()
     53 * @uses is_user_logged_in()
     54 * @uses bp_use_wp_admin_bar()
     55 * @uses show_admin_bar()
     56 * @uses add_action() To hook 'bp_adminbar_logo' to 'bp_adminbar_logo'
     57 * @uses add_action() To hook 'bp_adminbar_login_menu' to 'bp_adminbar_menus'
     58 * @uses add_action() To hook 'bp_adminbar_account_menu' to 'bp_adminbar_menus'
     59 * @uses add_action() To hook 'bp_adminbar_thisblog_menu' to 'bp_adminbar_menus'
     60 * @uses add_action() To hook 'bp_adminbar_random_menu' to 'bp_adminbar_menus'
     61 * @uses add_action() To hook 'bp_core_admin_bar' to 'wp_footer'
     62 * @uses add_action() To hook 'bp_core_admin_bar' to 'admin_footer'
     63 */
     64function bp_core_load_admin_bar() {
     65    global $wp_version;
     66
     67    // Don't show if Toolbar is disabled for non-logged in users
     68    if ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && ! is_user_logged_in() )
     69        return;
     70
     71    // Show the WordPress Toolbar
     72    if ( bp_use_wp_admin_bar() && $wp_version >= 3.1 ) {
     73
     74        // Respect user's Toolbar display preferences
     75        if ( is_user_logged_in() && ( bp_get_admin_bar_pref( 'front', bp_loggedin_user_id() ) || bp_get_admin_bar_pref( 'admin', bp_loggedin_user_id() ) ) )
     76            return;
     77
     78        show_admin_bar( true );
     79
     80    // Hide the WordPress Toolbar
     81    } elseif ( !bp_use_wp_admin_bar() ) {
     82
     83        // Keep the WP Toolbar from loading
     84        show_admin_bar( false );
     85
     86        // Actions used to build the BP Toolbar
     87        add_action( 'bp_adminbar_logo',  'bp_adminbar_logo'               );
     88        add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu',    2   );
     89        add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu',  4   );
     90        add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6   );
     91        add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu',   100 );
     92
     93        // Actions used to append BP Toolbar to footer
     94        add_action( 'wp_footer',    'bp_core_admin_bar', 8 );
     95        add_action( 'admin_footer', 'bp_core_admin_bar'    );
     96    }
     97}
     98
     99/**
    47100 * Handle the Toolbar CSS
    48101 *
     
    65118        $wp_styles->add_data( 'bp-admin-bar', 'suffix', $min );
    66119}
    67 add_action( 'bp_init', 'bp_core_load_admin_bar_css' );
  • trunk/bp-core/bp-core-buddybar.php

    r6442 r6762  
    614614
    615615/**
    616  * Handle the Toolbar/BuddyBar business
    617  *
    618  * @since BuddyPress (1.2)
    619  *
    620  * @global string $wp_version
    621  * @uses bp_get_option()
    622  * @uses is_user_logged_in()
    623  * @uses bp_use_wp_admin_bar()
    624  * @uses show_admin_bar()
    625  * @uses add_action() To hook 'bp_adminbar_logo' to 'bp_adminbar_logo'
    626  * @uses add_action() To hook 'bp_adminbar_login_menu' to 'bp_adminbar_menus'
    627  * @uses add_action() To hook 'bp_adminbar_account_menu' to 'bp_adminbar_menus'
    628  * @uses add_action() To hook 'bp_adminbar_thisblog_menu' to 'bp_adminbar_menus'
    629  * @uses add_action() To hook 'bp_adminbar_random_menu' to 'bp_adminbar_menus'
    630  * @uses add_action() To hook 'bp_core_admin_bar' to 'wp_footer'
    631  * @uses add_action() To hook 'bp_core_admin_bar' to 'admin_footer'
    632  */
    633 function bp_core_load_admin_bar() {
    634     global $wp_version;
    635 
    636     // Don't show if Toolbar is disabled for non-logged in users
    637     if ( (int) bp_get_option( 'hide-loggedout-adminbar' ) && ! is_user_logged_in() )
    638         return;
    639 
    640     // Show the WordPress Toolbar
    641     if ( bp_use_wp_admin_bar() && $wp_version >= 3.1 ) {
    642 
    643         // Respect user's Toolbar display preferences
    644         if ( is_user_logged_in() && ( bp_get_admin_bar_pref( 'front', bp_loggedin_user_id() ) || bp_get_admin_bar_pref( 'admin', bp_loggedin_user_id() ) ) )
    645             return;
    646 
    647         show_admin_bar( true );
    648 
    649     // Hide the WordPress Toolbar
    650     } elseif ( !bp_use_wp_admin_bar() ) {
    651         // Keep the WP Toolbar from loading
    652         show_admin_bar( false );
    653 
    654         // Actions used to build the BP Toolbar
    655         add_action( 'bp_adminbar_logo',  'bp_adminbar_logo' );
    656         add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu',         2   );
    657         add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu',       4   );
    658         add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu',      6   );
    659         add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu',        100 );
    660 
    661         // Actions used to append BP Toolbar to footer
    662         add_action( 'wp_footer',    'bp_core_admin_bar', 8 );
    663         add_action( 'admin_footer', 'bp_core_admin_bar'    );
    664     }
    665 }
    666 
    667 /**
    668616 * Handle the BuddyBar CSS
    669617 */
Note: See TracChangeset for help on using the changeset viewer.