add_group()向工具栏加入一组自定义链接

目录

描述

This function adds a new group to the Toolbar. Groups allow you to group Toolbar items together into distinct sections of a toolbar menu.

The Toolbar replaces the Admin Bar since WordPress Version 3.3.

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.

note: 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.

add_group() 描述

用法

<?php $wp_admin_bar->add_group$args ); ?>

add_group() 用法

参数

$args

(array) (必填) An array of arguments.

默认值: None

Arguments

id

(string) (必填) The ID of the group (node).

默认值: false

parent

(string) (可选) The ID of the parent node.

默认值: false

meta

(array) (可选) An array of meta data for the group (node).

默认值: array()

  • 'class' - The class attribute for the unordered list containing the child nodes.

add_group() 参数

示例

Adding a group to a parent node

This example adds a parent node, child nodes and a group to the toolbar.

The output from this example in the toolbar will be:

add_group() 示例

源文件

add_group() 函数的代码位于 wp-includes/class-wp-admin-bar.php.

add_group() 源文件

相关