Wordpress 删除后台侧边菜单

在企业网站开发中,避免客户去编辑或者删除改动代码,来通过代码隐藏后台侧边菜单。以下代码添加至 functions.php

<code class="language-php">/**
 * 删除后台侧边菜单
 */
function remove_menus(){
    remove_menu_page( 'index.php' );//仪表盘
    remove_menu_page( 'jetpack' ); //Jetpack*
    remove_menu_page( 'edit.php' );  //文章
    remove_menu_page( 'upload.php' );//媒体库
    remove_menu_page( 'edit.php?post_type=page' );//Pages
    remove_menu_page( 'edit-comments.php' );//评论
    remove_menu_page( 'themes.php' );//主题
    remove_menu_page( 'plugins.php' );//插件
    remove_menu_page( 'users.php' );//用户
    remove_menu_page( 'tools.php' );//工具
    remove_menu_page( 'options-general.php' );//设置
    remove_menu_page( 'snow.php' );//设置
    remove_menu_page( 'w3tc_dashboard' );//插件:w3tc
    remove_menu_page( 'wpml-translation-management/menu/languages.php'); //插件:wpml
}
add_action( 'admin_menu', 'remove_menus' );

Wordpress 删除后台侧边菜单
Share this