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 othe

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:

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:

Share Improve this question asked Jul 31, 2019 at 22:11 Maher AldousMaher Aldous 1194 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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/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!!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745279867a4620227.html

相关推荐

  • 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 othe

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信