Posted By

crs on 03/01/11


Tagged

bar wordpress admin


Versions (?)

Add/Remove WP Admin Bar Links


 / Published in: PHP
 

Here are some IDs for the default links WP 3.1 adds, found in /wp-includes/admin-bar.php:

my-account / my-account-with-avatar : the first link, to your account. Note that the ID here changes depending on if you have Avatars enabled or not. my-blogs : the 'My Sites' menu if the user has more than one site get-shortlink : provides a Shortlink to that page edit : link to Edit [content-type] new-content : the 'Add New' dropdown comments : the 'Comments' dropdown appearance : the 'Appearance' dropdown updates : the 'Updates' dropdown

  1. <?php
  2. function mytheme_admin_bar_render() {
  3. global $wp_admin_bar;
  4. // we can remove a menu item, like the COMMENTS link
  5. // just by knowing the right $id
  6. $wp_admin_bar->remove_menu('comments');
  7. // we can add a submenu item too
  8. $wp_admin_bar->add_menu( array(
  9. 'parent' => 'new-content',
  10. 'id' => 'new_media',
  11. 'title' => __('Media'),
  12. 'href' => admin_url( 'media-new.php')
  13. ) );
  14. }
  15. // and we hook our function via
  16. add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
  17. ?>

Report this snippet  

You need to login to post a comment.