Skip to content

Instantly share code, notes, and snippets.

@ryelle
Created March 25, 2021 18:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryelle/5f38c7f2c7b5d99ca5a8e9f60a073611 to your computer and use it in GitHub Desktop.
Save ryelle/5f38c7f2c7b5d99ca5a8e9f60a073611 to your computer and use it in GitHub Desktop.
Add extra items to the top level of the WordPress admin bar
<?php
/**
* Plugin Name: Admin Bar Items
*/
add_action(
'admin_bar_menu',
function( $admin_bar ) {
$admin_bar->add_menu( array(
'id' => 'ryelle-demo-1',
'parent' => null,
'group' => null,
'title' => '<span class="dashicons dashicons-controls-volumeon" style="font-family:dashicons;"></span> Long Menu Title',
'href' => admin_url('admin.php?page=custom-page'),
) );
$admin_bar->add_menu( array(
'id' => 'ryelle-demo-2',
'parent' => null,
'group' => null,
'title' => '<span class="dashicons dashicons-format-status" style="font-family:dashicons;color:#68de7c;"></span> Status',
// 'href' => admin_url('admin.php?page=custom-page'),
) );
$admin_bar->add_menu( array(
'id' => 'ryelle-demo-3',
'parent' => null,
'group' => null,
'title' => '<span class="dashicons dashicons-admin-site-alt3" style="font-family:dashicons;"></span> View',
'href' => admin_url('admin.php?page=custom-page'),
) );
},
100
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment