do_action_ref_array( 'admin_bar_menu', WP_Admin_Bar $wp_admin_bar )
Load all necessary admin bar items.
Description Description
This is the hook used to add, remove, or manipulate admin bar items.
Parameters Parameters
- $wp_admin_bar
-
(WP_Admin_Bar) WP_Admin_Bar instance, passed by reference
Source Source
Changelog Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
This hook is used to add the admin bar menu.
Example:-
add_action( 'admin_bar_menu', 'admin_bar_item', 500 ); function admin_bar_item ( WP_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 ] ) ); }Expand full source codeCollapse full source code
Find the order that hooks and filters are called here: https://codex.wordpress.org/Plugin_API/Action_Reference