Remove All in One Pack from the admin bar

Hello I want to remove All in One Pack from the admin bar.

I can remove anything else but it. I have already removed other things like update from the admin bar using this method

Get the menu's id by this code:

// Debug admin bar menu and submen
if (!function_exists('aldous_debug_admin_menus')):
function aldous_debug_admin_menus() {
    global $submenu, $wp_admin_bar, $pagenow;
    if ( current_user_can('manage_options') ) { // ONLY DO THIS FOR ADMIN
        if( $pagenow == 'index.php' ) {  // PRINTS ON DASHBOARD
            echo 'pre'; print_r( $wp_admin_bar ); echo '/pre'; // TOP LEVEL MENUS
            echo 'pre'; print_r( $submenu ); echo '/pre'; // SUBMENUS
        }
    }
}
add_action( 'admin_notices', 'aldous_debug_admin_menus' );
endif;

and then remove the menu or the submenu by this code:

function aldous_remove_items_from_admin_bar( $wp_admin_bar ) {
    $wp_admin_bar-remove_node('updates');//remove the update from wordpress core.
    $wp_admin_bar-remove_node('all-in-one-seo-pack');// this code not work and I want it to work to remove the menu.
}
add_action( 'admin_bar_menu', 'aldous_remove_items_from_admin_bar', 999 );

In this image you will find the id by using the first code:

Topic admin-bar sub-menu admin-menu wp-admin plugin-all-in-one-seo Wordpress

Category Web


You are almost there! If you check out where the plugin developer is adding this action, you'll see they are setting a priority of 1000. While the priority of your function is being called at 999.

https://plugins.trac.wordpress.org/browser/all-in-one-seo-pack/trunk/aioseop_class.php#L3907

Update your priority to be greater than 1000:

add_action( 'admin_bar_menu', 'aldous_remove_items_from_admin_bar', 1200 );

Overriding function calls with plugins is a bit tricky, because you don't know what sort of priority they set on their calls.

Hope that helps!!

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.