wppaste
WordPress

WP_Admin_Bar

Since
3.1.0
Source
wp-includes/class-wp-admin-bar.php:15
Core class used to implement the Toolbar API.

Compatibility

WordPress
since 3.1.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 2

Every hook that fires from inside WP_Admin_Bar, in the order it appears in the class, grouped by the method that fires it.

Properties · 4

$nodesprivate
$boundprivate
$userpublic
$menuarraypublic
Deprecated menu property.

Methods · 20

Source code

#[AllowDynamicProperties]class WP_Admin_Bar {	private $nodes = array();	private $bound = false;	public $user; 	/**	 * Deprecated menu property.	 *	 * @since 3.1.0	 * @deprecated 3.3.0 Modify admin bar nodes with WP_Admin_Bar::get_node(),	 *                   WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node().	 * @var array	 */	public $menu = array(); 	/**	 * Initializes the admin bar.	 *	 * @since 3.1.0	 */	public function initialize() {		$this->user = new stdClass(); 		if ( is_user_logged_in() ) {			/* Populate settings we need for the menu based on the current user. */			$this->user->blogs = get_blogs_of_user( get_current_user_id() );			if ( is_multisite() ) {				$this->user->active_blog    = get_active_blog_for_user( get_current_user_id() );				$this->user->domain         = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );				$this->user->account_domain = $this->user->domain;			} else {				$this->user->active_blog    = $this->user->blogs[ get_current_blog_id() ];				$this->user->domain         = trailingslashit( home_url() );				$this->user->account_domain = $this->user->domain;			}		} 		add_action( 'wp_head', 'wp_admin_bar_header' ); 		add_action( 'admin_head', 'wp_admin_bar_header' ); 		if ( current_theme_supports( 'admin-bar' ) ) {			/**			 * To remove the default padding styles from WordPress for the Toolbar, use the following code:			 * add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) );			 */			$admin_bar_args  = get_theme_support( 'admin-bar' );			$header_callback = $admin_bar_args[0]['callback'];		} 		if ( empty( $header_callback ) ) {			$header_callback = '_admin_bar_bump_cb';		} 		add_action( 'wp_head', $header_callback ); 		wp_enqueue_script( 'admin-bar' );		wp_enqueue_style( 'admin-bar' ); 		/**		 * Fires after WP_Admin_Bar is initialized.		 *		 * @since 3.1.0		 */		do_action( 'admin_bar_init' );	} 	/**	 * Adds a node (menu item) to the admin bar menu.	 *	 * @since 3.3.0	 *	 * @param array $node The attributes that define the node.	 */	public function add_menu( $node ) {		$this->add_node( $node );	} 	/**

Changelog

Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/class-wp-admin-bar.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.