简体   繁体   English

如何隐藏wordpress插件生成的管理菜单

[英]How to hide admin menu generate by plugins in wordpress

Recently i have installed two plugins in my site.最近我在我的网站上安装了两个插件。 The plugins generate two admin menu.该插件生成两个管理菜单。 I wanna hide these menu.我想隐藏这些菜单。

Menu name are :菜单名称是:

WP Metaboxer Mouse hover link (mysite.com/wp-admin/edit.php?post_type=mtbxr_metabox) WP Metaboxer鼠标悬停链接 (mysite.com/wp-admin/edit.php?post_type=mtbxr_metabox)

BWS Plugins Mouse hover link (mysite.com/wp-admin/admin.php?page=bws_plugins) BWS 插件鼠标悬停链接 (mysite.com/wp-admin/admin.php?page=bws_plugins)

I can hide other default menu by these code我可以通过这些代码隐藏其他默认菜单

function remove_admin_menu_items() {
  $remove_menu_items = array(__('Media'),__('Links'), __('Comments'), __('Tools'), __('Appearance'), __('Posts'),__('Settings'),__('Plugins')));
  global $menu;
  end ($menu);
  while (prev($menu)){
    $item = explode(' ',$menu[key($menu)][0]);
    if(in_array($item[0] != NULL?$item[0]:"" , $remove_menu_items)){
      unset($menu[key($menu)]);}
    }
  }
add_action('admin_menu', 'remove_admin_menu_items');

add the following at the bottom of remove_admin_menu_items:在 remove_admin_menu_items 的底部添加以下内容:

remove_menu_page( 'edit.php?post_type=mtbxr_metabox' );
remove_menu_page( 'admin.php?page=bws_plugins' );

then change the priority of your action to run last:然后将您的操作的优先级更改为最后运行:

add_action('admin_menu', 'remove_admin_menu_items', 9999);

Thank you for the answer.谢谢你的回答。 I had the same issues.我有同样的问题。
To remove a plugin menu item, just by name you can check the structure of the URL.要删除插件菜单项,只需按名称即可检查 URL 的结构。

For instance, Visual Composer has: /admin.php?page= vc-general例如,Visual Composer 有: /admin.php?page= vc-general

remove_menu_page( 'vc-general' );
remove_menu_page( 'revslider' );
remove_menu_page( 'bws_plugins' );

Some Plugins add the menu item as submenu items, so you have to use the following function.一些插件将菜单项添加为子菜单项,因此您必须使用以下功能。

remove_submenu_page( 'options-general.php', 'disable-emails' );

here the WP-Reference for both functions: https://developer.wordpress.org/reference/functions/remove_submenu_page/ https://developer.wordpress.org/reference/functions/remove_menu_page/这里是两个功能的 WP-Reference: https : //developer.wordpress.org/reference/functions/remove_submenu_page/ https://developer.wordpress.org/reference/functions/remove_menu_page/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM