admin_bar_menu
最后更新于:2021-11-25 19:24:41
do_action_ref_array( ‘admin_bar_menu’, GC_Admin_Bar $gc_admin_bar )
Load all necessary admin bar items.
参数
- $gc_admin_bar
-
(GC_Admin_Bar)
GC_Admin_Bar instance, passed by reference
源文件
文件: gc-includes/admin-bar.php
add_action( 'admin_bar_menu', 'admin_bar_item', 500 ); function admin_bar_item ( GC_Admin_Bar $admin_bar ) { if ( ! current_user_can( 'manage_options' ) ) { return; } $admin_bar->add_menu( array( 'id' => 'menu-id', 'parent' => null, 'group' => null, 'title' => 'Menu Title', //you can use img tag with image link. it will show the image icon Instead of the title. 'href' => admin_url('admin.php?page=custom-page'), 'meta' => [ 'title' => __( 'Menu Title', 'textdomain' ), //This title will show on hover ] ) ); }
add_action( 'admin_bar_menu', 'admin_bar_item', 500 ); function admin_bar_menus( GC_Admin_Bar $gc_admin_bar ) { $parent_slug = 'license-manager-gcpt'; $gc_admin_bar->add_menu( array( 'id' => $parent_slug, 'parent' => 'top-secondary', 'group' => null, 'title' => __( 'License Manager', 'lmfgcpt' ), 'href' => admin_url('admin.php?page=license-manager-gcpt'), ) ); }