Remove plugin links from admin bar

I downloaded the Ultimate Branding plugin to adjust the admin bar, but there is no option to remove links to two of the plugins that I have installed (WordPress SEO by Yoast and NextGen Gallery). Also neither appear to be listed in /wp-includes/admin-bar.php so I can't find the id to remove them manually.

  • Gabe

    Hello. This is a frequently requested feature. The issue is that everyone requests the menu/submenu/admin bar item they need removed rather than an all in one solution. For example, this thread was created yesterday to hide the menu item created by JetPack.

    The other day I created this thread as an all-encompassing thread. We need to focus on one thread to show demand rather than a trickle of comments on many different threads.

    Staff, can we please do something about this? I.e. make a featured thread with a request to hide any/all options on the menu/submenu/admin bar as a new addition to the Ultimate Branding plugin? If we tallied up all of the threads that have been created (making more work for you) related to this function, we'd have significant demand.

  • Gabe

    In the meantime to get rid of the unwanted items on the menu bar, put the following code into a .php file and drop it into your plugins or mu-plugins folder:

    <?php
    /*
      Plugin Name: Hide Admin Bar Menus Custom
      Plugin URI: http://example.com
      Description: Custom plugin that hides items on the admin bar
      Author: You
      Version: 1.0
     */
    
    // Cleanup WP Admin bar
    function wps_admin_bar(){
      global $wp_admin_bar;
        if (!current_user_can('update_core')) {  // If user can't update core (i.e. not superadmin), remove menu items
        $wp_admin_bar->remove_menu('wpseo-menu');
        $wp_admin_bar->remove_menu('wpseo-kwresearch');
        $wp_admin_bar->remove_menu('wpseo-adwordsexternal');
        $wp_admin_bar->remove_menu('wpseo-googleinsights');
        $wp_admin_bar->remove_menu('wpseo-wordtracker');
      }
    }
    add_action( 'wp_before_admin_bar_render', 'wps_admin_bar' );
    ?>

    This will get rid of the extra admin bar menus added by WordPress SEO. I haven't played with NextGen Gallery, but it should have similar hooks that you can find and add. When you find the hook (it may take a couple of tries) just plug it into one of these lines and add it:
    $wp_admin_bar->remove_menu('XXnext-gen-gallery-hook-hereXX');

    Then just stick it right under:
    $wp_admin_bar->remove_menu('wpseo-wordtracker');

    Save it and refresh the page. If it's still visible, try another one. Remember that the above only hide the menus from non-super admins, so you won't notice a change if you're logged in as a super admin. If you want to hide it from everyone including superadmins, get rid of this conditional statement:

    if (!current_user_can('update_core')) {

    Remember to delete the closing } at the bottom.
    Hope this helps.

  • Timothy Bowers

    Looks like Gabe sorted you out on this one.

    :slight_smile:

    If we tallied up all of the threads that have been created (making more work for you) related to this function, we'd have significant demand.

    If everyone sought out pre existing feature requests it would also make it easier. We have discussed various different options to collate the support for an item. We even tried UserVoice which unfortunately didn't quite work out like we anticipated.

    We're looking for other options for the future :slight_smile:

    Cheers.

  • lsickles08

    Hi,

    I finally had a chance to try this and I was able to get rid of everything except for the WP SEO bar. Would you be able to take a look at this and let me know what I'm missing?

    <?php
    /*
    Plugin Name: Hide Admin Bar Menus Custom
    Plugin URI: http://www.hergamelife.com
    Description: Custom plugin that hides items on the admin bar
    Author: Lauren Sickles
    Version: 1.0
    */

    // Cleanup WP Admin bar
    function wps_admin_bar(){
    global $wp_admin_bar;
    if (!current_user_can('update_core')) { // If user can't update core (i.e. not superadmin), remove menu items
    $wp_admin_bar->remove_menu('wpseo-menu');
    $wp_admin_bar->remove_menu('wpseo-kwresearch');
    $wp_admin_bar->remove_menu('wpseo-adwordsexternal');
    $wp_admin_bar->remove_menu('wpseo-googleinsights');
    $wp_admin_bar->remove_menu('wpseo-wordtracker');
    $wp_admin_bar->remove_menu('wpseo-settings');
    $wp_admin_bar->remove_menu('wpseo-titles');
    $wp_admin_bar->remove_menu('wpseo-social');
    $wp_admin_bar->remove_menu('wpseo-xml');
    $wp_admin_bar->remove_menu('wpseo-permalinks');
    $wp_admin_bar->remove_menu('wpseo-internal-links');
    $wp_admin_bar->remove_menu('wpseo-rss');
    $wp_admin_bar->remove_menu('ngg-menu');
    $wp_admin_bar->remove_menu('ngg-menu-overview');
    $wp_admin_bar->remove_menu('ngg-menu-add-gallery');
    $wp_admin_bar->remove_menu('ngg-menu-manage-gallery');
    $wp_admin_bar->remove_menu('ngg-menu-manage-album');
    $wp_admin_bar->remove_menu('ngg-menu-tags');
    $wp_admin_bar->remove_menu('ngg-menu-options');
    $wp_admin_bar->remove_menu('ngg-menu-style');
    $wp_admin_bar->remove_menu('ngg-menu-about');
    $wp_admin_bar->remove_menu('freshthemes_theme_options');
    $wp_admin_bar->remove_menu('freshthemes_theme_options2');
    $wp_admin_bar->remove_menu('freshthemes_sidebar_manager');
    $wp_admin_bar->remove_menu('freshthemes_theme_backup_options');
    }
    }
    add_action( 'wp_before_admin_bar_render', 'wps_admin_bar' );
    ?>

    When I view the source code, this is what's left. The names match, so I'm not sure what's going on.

    <li id="wp-admin-bar-wdcab_root" class="">HerGameLife
    <li id="wp-admin-bar-wpseo-menu" class="menupop">SEO<div class="ab-sub-wrapper"><ul id="wp-admin-bar-wpseo-menu-default" class="ab-submenu">
    <li id="wp-admin-bar-wpseo-kwresearch" class="menupop"><div class="ab-item ab-empty-item" tabindex="10" aria-haspopup="true">Keyword Research</div><div class="ab-sub-wrapper"><ul id="wp-admin-bar-wpseo-kwresearch-default" class="ab-submenu">
    <li id="wp-admin-bar-wpseo-adwordsexternal" class="">AdWords External
    <li id="wp-admin-bar-wpseo-googleinsights" class="">Google Insights
    <li id="wp-admin-bar-wpseo-wordtracker" class="">SEO Book </div> </div> <ul id="wp-admin-bar-top-secondary" class="ab-top-secondary ab-top-menu">
    <li id="wp-admin-bar-my-account" class="menupop">Howdy, Fonda<div class="ab-sub-wrapper"><ul id="wp-admin-bar-user-actions" class=" ab-submenu">
    <li id="wp-admin-bar-user-info" class=""><span class='display-name'>Fonda</span><span class='username'>fonda</span>
    <li id="wp-admin-bar-edit-profile" class="">Edit My Profile
    <li id="wp-admin-bar-logout" class="">Log Out </div> </div>

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.