简体   繁体   English

从WordPress管理员隐藏WooThemes菜单

[英]Hide WooThemes menu from WordPress Admin

I'm using a WooThemes child theme and want to hide the menu from the WordPress admin bar. 我正在使用WooThemes子主题,并希望从WordPress管理栏中隐藏菜单。 I use the following code so that only the users held within the array get to see all the options. 我使用以下代码,以便只有数组中拥有的用户才能查看所有选项。

function remove_items_from_menu() {
$admins = array( 
    'Bill', 'Steve', 'Rob'
);
$current_user = wp_get_current_user();
 if( !in_array( $current_user->user_login, $admins ) ) {
         //   exit;
         add_filter('acf/settings/show_admin', '__return_false');

         remove_action('load-update-core.php','wp_update_plugins');

    remove_action( 'admin_notices', 'update_nag', 3 );
    remove_menu_page('edit.php?post_type=acf-field-group');
    remove_menu_page('edit-comments.php');
    remove_menu_page('tools.php');
    remove_submenu_page( 'index.php', 'update-core.php' );
    remove_menu_page('themes.php');
    remove_menu_page('plugins.php');
    remove_submenu_page( 'themes.php', 'themes.php' );
    remove_submenu_page( 'themes.php', 'widgets.php' );
    remove_submenu_page( 'themes.php', 'customize.php' );
    remove_submenu_page( 'themes.php', 'theme-editor.php' );
            remove_submenu_page('options-general.php', 'options-permalink.php');
            remove_submenu_page('options-general.php', 'options-media.php');
            remove_submenu_page('options-general.php', 'options-discussion.php');
            remove_submenu_page('options-general.php', 'options-reading.php');
            remove_submenu_page('options-general.php', 'options-writing.php');
            remove_submenu_page( 'options-general.php', 'social-sharing-admin' );    
}
}
add_action( 'admin_menu', 'remove_items_from_menu', 999 );

?>

Finding the page to hide for the theme displays itself as admin.php?page=woothemes, but adding the following line to the above code still doesn't hide it from view. 查找要隐藏的主题页面会将其自身显示为admin.php?page = woothemes,但是将以下行添加到上面的代码中仍然不会将其隐藏。

remove_menu_page('admin.php?page=woothemes');

Does anybody know how I can find out the correct page ID to hide this specific menu option? 有人知道我如何找到正确的页面ID来隐藏此特定菜单选项吗? I've searched online and cannot find how to hide a WooThemes menu from the admin bar. 我已经在线搜索过,无法找到如何从管理栏中隐藏WooThemes菜单。

Thanks. 谢谢。

It depends on the id passed to add_menu_page when it was called by the WooTheme. 它取决于WooTheme调用传递给add_menu_page的ID。 You can search over the code, but I think that 您可以搜索代码,但我认为

remove_menu_page('woothemes');

should do it. 应该这样做。

Hope it helps. 希望能帮助到你。

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

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