Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

toolbar-with-attributes

// Add Toolbar Menus
function custom_toolbar() {
	global $wp_admin_bar;

	$args = array(
		'id'     => 'menu-1',
		'title'  => __( 'Toolbar Menu', 'text_domain' ),
		'href'   => 'http://.../',
		'meta'   => array(
			'html'     => 'html',
			'class'    => 'custom-toolbar-class',
			'target'   => '_top',
			'onclick'  => 'doThisJS()',
			'title'    => 'Toolbar Menu',
			'tabindex' => '1',
		),
	);
	$wp_admin_bar->add_menu( $args );

}

// Hook into the 'wp_before_admin_bar_render' action
add_action( 'wp_before_admin_bar_render', 'custom_toolbar', 999 );