W3cubDocs

/WordPress

WP_Admin_Bar::add_menu( array $node )

Add a node (menu item) to the Admin Bar menu.

Parameters

$node

(array) (Required) 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

File: wp-includes/class-wp-admin-bar.php

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

Changelog

Version Description
3.3.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_admin_bar/add_menu