WordPress add admin bar button

How to add buttons to your Admin Toolbar? There are two ways you can do that: using a plugin, or using code.|
We’ll go over the second way below.

function custom_button_example($wp_admin_bar){
$args = array(
'id' => 'custom-button',
'title' => 'Custom Button',
'href' => 'http://example.com/',
'meta' => array(
'class' => 'custom-button-class'
)
);
$wp_admin_bar->add_node($args);
} add_action('admin_bar_menu', 'custom_button_example', 50);

Note! The position of your custom item depends on it’s priority. In the example above I set the priority to 50.

Have a look at the following list of items added by default and their priorities:

wp_admin_bar_wp_menu – 10
wp_admin_bar_my_sites_menu – 20
wp_admin_bar_site_menu – 30
wp_admin_bar_updates_menu – 40
wp_admin_bar_comments_menu – 60
wp_admin_bar_new_content_menu – 70
wp_admin_bar_edit_menu – 80

The item with lowest priority number is positioned first.

Source: https://stanhub.com/how-to-add-a-custom-button-in-wordpress-admin-bar/