-
-
Save jakebresnehan/6d9dc1b0c617bebbd16d to your computer and use it in GitHub Desktop.
create links in the WP admin bar for development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* set up some quick links for the admin bar | |
* | |
* @param WP_Admin_Bar $wp_admin_bar [description] | |
* @return [type] [description] | |
*/ | |
function rkv_admin_bar_static( WP_Admin_Bar $wp_admin_bar ) { | |
// bail if current user doesnt have cap | |
if ( ! current_user_can( 'manage_options' ) ) { | |
return; | |
} | |
// add a parent item | |
$wp_admin_bar->add_node( | |
array( | |
'id' => 'rkv-dev-links', | |
'title' => 'RKV Dev Links', | |
) | |
); | |
// add GitHub issues | |
$wp_admin_bar->add_node( | |
array( | |
'id' => 'github-issues', | |
'title' => 'GitHub Issues', | |
'href' => 'https://github.com/project-name/issues', | |
'position' => 0, | |
'parent' => 'rkv-dev-links', | |
'meta' => array( | |
'title' => 'GitHub Issues', | |
'target' => '_blank' | |
) | |
) | |
); | |
// add CMB2 wiki | |
$wp_admin_bar->add_node( | |
array( | |
'id' => 'cmb2-wiki-site', | |
'title' => 'CMB2 Wiki', | |
'href' => 'https://github.com/WebDevStudios/CMB2/wiki/', | |
'parent' => 'rkv-dev-links', | |
'position' => 0, | |
'meta' => array( | |
'title' => 'CMB2 Wiki', | |
'target' => '_blank' | |
) | |
) | |
); | |
// add live staging site | |
$wp_admin_bar->add_node( | |
array( | |
'id' => 'staging-site', | |
'title' => 'Staging Site', | |
'href' => 'http://devsite-url.com/', | |
'parent' => 'rkv-dev-links', | |
'position' => 0, | |
'meta' => array( | |
'title' => 'Staging Site', | |
'target' => '_blank' | |
) | |
) | |
); | |
} | |
add_action( 'admin_bar_menu', 'rkv_admin_bar_static', 9999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment