_wp_admin_bar_init

Instantiate the admin bar object and set it up as a global for access elsewhere.

Description

_wp_admin_bar_init(); 

UNHOOKING THIS FUNCTION WILL NOT PROPERLY REMOVE THE ADMIN BAR. For that, use show_admin_bar(false) or the filter.


Usage

  1. if ( !function_exists( '_wp_admin_bar_init' ) ) { 
  2. require_once ABSPATH . WPINC . '/admin-bar.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = _wp_admin_bar_init(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/admin-bar.php  
  1. function _wp_admin_bar_init() { 
  2. global $wp_admin_bar; 
  3.  
  4. if ( ! is_admin_bar_showing() ) 
  5. return false; 
  6.  
  7. /** Load the admin bar class code ready for instantiation */ 
  8. require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' ); 
  9.  
  10. /** Instantiate the admin bar */ 
  11.  
  12. /** 
  13. * Filters the admin bar class to instantiate. 
  14. * @since 3.1.0 
  15. * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'. 
  16. */ 
  17. $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' ); 
  18. if ( class_exists( $admin_bar_class ) ) 
  19. $wp_admin_bar = new $admin_bar_class; 
  20. else 
  21. return false; 
  22.  
  23. $wp_admin_bar->initialize(); 
  24. $wp_admin_bar->add_menus(); 
  25.  
  26. return true;