我正在尝试创建一个通用函数来删除管理仪表板wordpress中的菜单页。这是我的尝试。。。
function remove_menus(){
//Find admin...
$admin_url = get_admin_url();
//Find php-files in admin path
//and create an array of them
$admin_files = array();
foreach (glob("*.php") as $file) {
if($file == \'.\' || $file == \'..\') continue;
$admin_files[] = $file;
}
//Remove all menupages for all files in wp-admin folder
foreach($admin_files as $af) {
remove_menu_page( $af );
}
//Get all registered post types
// types will be a list of the post type names
$types = get_post_types();
//Remove pages for all registered post types as well
foreach( $types as $type ) {
remove_menu_page( \'edit.php?post_type=\' . $type);
}
//Get plugins and remove them from menu
$plugins = get_plugins();
foreach($plugins as $p) {
remove_menu_page( strtolower($p[\'Name\'] ) );
}
}
add_action( \'admin_init\', \'remove_menus\' ,99);
我想知道的是:
//Get plugins
$plugins = get_plugins();
foreach($plugins as $p) {
remove_menu_page( strtolower($p[\'Name\'] ) );
}
这只会删除插件名称设置为admin的插件。页面={插件名称}
Example:remove_menu_page(\'duplicator\');
将删除复印机插件,因为管理员。第页=duplicate
remove_menu_page(\'Yoast SEO\');
不会删除Yoast SEO插件,因为实际的slug是admin。php?第页=wpseo_dashboard (而不是admin.php?page=yoastseo)
要手动删除此插件,您必须
remove_menu_page(\'wpseo_dashboard\');
Is there a way to remove plugins in dashboard - where you cannot identify the slug by the plugins name?