WP_Admin_Bar::add_group() WordPress Method

The WP_Admin_Bar::add_group() method allows you to add a group to the admin bar. Groups are used to organize admin bar items into logical groups. For example, you might want to create a group for all of the items related to a particular plugin.

WP_Admin_Bar::add_group( array $args ) #

Adds a group to a toolbar menu node.


Description

Groups can be used to organize toolbar items into distinct sections of a toolbar menu.


Top ↑

Parameters

$args

(array)(Required)Array of arguments for adding a group.

  • 'id'
    (string) ID of the item.
  • 'parent'
    (string) Optional. ID of the parent node. Default 'root'.
  • 'meta'
    (array) Meta data for the group including the following keys: 'class', 'onclick', 'target', and 'title'.


Top ↑

More Information

  • Toolbar items are also called “nodes”. Nodes can be parents for other nodes, which creates dropdown menus. When adding a group you’re actually adding a group node. Group nodes are not visible in the Toolbar, but nodes added to it are.
  • This function is a method of the WP_Admin_Bar class and $wp_admin_bar global object, which may not exist except during the ‘admin_bar_menu‘ or ‘wp_before_admin_bar_render‘ hooks.
  • The Toolbar replaces the Admin Bar since WordPress Version 3.3.

Top ↑

Source

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

	final public function add_group( $args ) {
		$args['group'] = true;

		$this->add_node( $args );
	}


Top ↑

Changelog

Changelog
VersionDescription
3.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.