admin管理员组文章数量:1417655
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 badges1 Answer
Reset to default 1You 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!!
本文标签: Remove All in One Pack from the admin bar
版权声明:本文标题:Remove All in One Pack from the admin bar 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745279867a2651372.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论