Our plugins may need to add a menu item for pointing to settings page in admin bar. wp_before_admin_bar_render filter helps us to do that.
if(!function_exists('custom_admin_bar_menu')){
function custom_admin_bar_menu() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'id' => 'my_settingspage',
'title' => __('My settings'),
'href' => admin_url('/plugingsettingspage.php')
) );
}
}
add_action( 'wp_before_admin_bar_render', 'custom_admin_bar_menu' );
We can also make it as child to existing menu by adding the menu-id as a parent to that menu
No comments:
Post a Comment