Add a menu with a dropdown to link that opens in a new window

Shortlink:

Add a menu, with a dropdown to link that opens in a new window


/*
* Add a menu, with a dropdown to link that opens in a new window
* Change the Menu title, the link title and and href link.
*/
function custom_adminbar_menu( $meta = TRUE ) {
global $wp_admin_bar;
if ( !is_user_logged_in() ) { return; }
if ( !is_super_admin() || !is_admin_bar_showing() ) { return; }
$wp_admin_bar->add_menu( array(
'id' => 'custom_menu',
'title' => __( 'Menu Name' ) ) /* set the menu name */
);
$wp_admin_bar->add_menu( array(
'parent' => 'custom_menu',
'id' => 'custom_links',
'title' => __( 'Google'), /* Set the link title
*/
'href' => 'http://google.com/', /* Set the link a href */
'meta' => array( target => '_blank' ) )
);
}
add_action( 'admin_bar_menu', 'custom_adminbar_menu', 15 );

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!