remove_menu_page()移除后台管理界面的菜单

目录

描述

Remove a top level admin menu.

Please be aware that this would not prevent a user from accessing these screens directly. Removing a menu does not replace the need to filter a user's permissions as appropriate.

remove_menu_page() 描述

用法

This function should be called on the admin_menu action hook. Calling it elsewhere could cause issues : either the function is not defined or the global $menu variable used but this function is not yet declared.<?php 
function custom_menu_page_removing() {
    
remove_menu_page$menu_slug );
}
add_action'admin_menu''custom_menu_page_removing' );
?>

remove_menu_page() 用法

参数

$menu_slug

(string) (必填) The slug of the menu (typically the name of the PHP script for the built in menu items; example: edit-comments.php)

默认值: None

remove_menu_page() 参数

返回值

(array|boolean) 

The removed menu on success, false if not found.

remove_menu_page() 返回值

示例

Removes every menu for all users. To remove only certain menu items include only those you want to hide within the function. To remove menus for only certain users you may want to utilize current_user_can().

remove_menu_page() 示例

注意

  • 使用到 global: (unknown type) $menu
  • To remove submenu items in the admin, use remove_submenu_page. Using remove_menu_page() will not work for submenu items.

remove_menu_page() 注意

历史

添加于 版本: 3.1.0

remove_menu_page() 历史

源文件

remove_menu_page() 函数的代码位于 /wp-admin/includes/plugin.php.

remove_menu_page() 源文件

相关