虽然主管理菜单(即屏幕左侧的菜单)只能有2个深度(A>B),但toolbar 可以任意深。
我不知道使用工具栏是否适合您,但如果是这样的话,您可以执行以下操作:
add_action (\'wp_before_admin_bar_render\', \'wpse_admin_toolbar_test\') ;
function
admin_toolbar ()
{
global $wp_admin_bar ;
$args = array (
\'id\' => \'wpse_admin_toolbar_test\',
\'title\' => \'WPSE Admin Toolbar Test\',
) ;
$node = $wp_admin_bar->add_node ($args) ;
for ($i = 0 ; $i < 4 ; $i++) {
$args = array (
\'id\' => "wpse_admin_toolbar_test_item_{$i}",
\'parent\' => \'wpse_admin_toolbar_test\',
\'title\' => "Item $i",
) ;
$wp_admin_bar->add_node ($args) ;
for ($y = 0 ; $y < 3 ; $y++) {
$args = array (
\'id\' => "wpse_admin_toolbar_test_item_{$i}_subitem_{$y}",
\'parent\' => "wpse_admin_toolbar_test_item_{$i}",
\'title\' => "Sub Item $y",
) ;
$wp_admin_bar->add_node ($args) ;
for ($z = 0 ; $z < 2 ; $z++) {
$args = array (
\'id\' => "wpse_admin_toolbar_test_item_{$i}_subitem_{$y}_subitem_{$z}",
\'parent\' => "wpse_admin_toolbar_test_item_{$i}_subitem_{$y}",
\'title\' => "Sub-Sub Item $z",
// in the real-world, this URL would be to something that
// would perform the action for this node
\'href\' => admin_url (),
) ;
$wp_admin_bar->add_node ($args) ;
}
}
}
return ;
}
以上将产生以下结果: