WP_Admin_Bar::add_menu( array $node )

Adds a node (menu item) to the admin bar menu.

Parameters

$nodearrayrequired
The attributes that define the node.

More Information

Initial items in the Admin Bar are($menu_id):

  • my-account-with-avatar – Dashboard, User settings
  • new-content – Short-cut to all custom post types and original ones
  • comments – Comments moderation
  • appearance – Theme selection and Widgets

Parameter $node takes an array of arguments:

id
(string) (required) The ID of the node.

Default: false
title
(string) (optional) The text that will be visible in the Toolbar. Including html tags is allowed.

Default: false
parent
(string) (optional) The ID of the parent node.

Default: false
href
(string) (optional) The ‘href’ attribute for the link. If ‘href’ is not set the node will be a text node.

Default: false
group
(boolean) (optional) This will make the node a group (node) if set to ‘true’. Group nodes are not visible in the Toolbar, but nodes added to it are. See add_group().

Default: false
meta
(array) (optional) An array of meta data for the node.

Default: array()
  • ‘html’ – The html used for the node.
  • ‘class’ – The class attribute for the list item containing the link or text node.
  • ‘rel’ – The rel attribute.
  • ‘onclick’ – The onclick attribute for the link. This will only be set if the ‘href’ argument is present.
  • ‘target’ – The target attribute for the link. This will only be set if the ‘href’ argument is present.
  • ‘title’ – The title attribute. Will be set to the link or to a div containing a text node.
  • ‘tabindex’ – The tabindex attribute. Will be set to the link or to a div containing a text node.

Source

public function add_menu( $node ) {
	$this->add_node( $node );
}

Changelog

VersionDescription
3.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.