宝塔面板wordpress_如何在WordPress管理面板中删除菜单项

宝塔面板wordpress

Have you ever worked with a client who has a hard time understanding technology? Well, as a consultant, designer, or developer, it is your job to make things easier for them. WordPress admin panel comes with a lot of options in the menu, but you can get rid of them fairly easily if necessary. With one of our clients, we needed to get rid of few menu items, so it is easier for her to understand things. In this article, we will show you how easy it is to remove a menu item in the WordPress Admin Panel.

您是否曾与难以理解技术的客户一起工作? 好吧,作为顾问,设计师或开发人员,使他们的事情变得简单是您的工作。 WordPress管理面板在菜单中带有很多选项,但是如果有必要,您可以轻松地摆脱它们。 与我们的一位客户一起,我们需要摆脱一些菜单项,因此她更容易理解事物。 在本文中,我们将向您展示在WordPress管理面板中删除菜单项有多么容易。

For WordPress 3.1 or above, just paste the following code in your theme’s functions.php file:

对于WordPress 3.1或更高版本,只需将以下代码粘贴到主题的functions.php文件中:


	add_action( 'admin_menu', 'my_remove_menu_pages' );
	function my_remove_menu_pages() {
		remove_menu_page('link-manager.php');	
	}

In version prior to WordPress 3.1, you would need to paste the following code in your theme’s functions.php file:

在WordPress 3.1之前的版本中,您需要将以下代码粘贴到主题的functions.php文件中:

function remove_menus () {
global $menu;
	$restricted = array(__('Links'));
	end ($menu);
	while (prev($menu)){
		$value = explode(' ',$menu[key($menu)][0]);
		if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){unset($menu[key($menu)]);}
	}
}
add_action('admin_menu', 'remove_menus');

The code above will get rid of the Links option for all users (including administrators). Only two user roles are allowed to see the Link tab (Administrators and Editors). Now if this is for a multi-author site (where there are many editors), and you as an administrator still want access to the Links menu, then you can add parameters to do so.

上面的代码将为所有用户(包括管理员)删除“链接”选项。 仅允许两个用户角色查看“链接”选项卡(管理员和编辑者)。 现在,如果这是用于多作者站点(其中有许多编辑器),并且您作为管理员仍希望访问“链接”菜单,则可以添加参数来这样做。

You would need to utilize the function current_user_can(), and with a simple if statement, you can get rid of the link menu or other items for specific user role.

您将需要使用函数current_user_can() ,并使用简单的if语句,就可以摆脱链接菜单或其他针对特定用户角色的项目。

This is a very handy trick for consultants and developers who work on larger sites.

对于在大型网站上工作的顾问和开发人员来说,这是一个非常方便的技巧。

Additional Sources

其他来源

Remove Menu PageCurrent User Can Function ReferenceUser Roles and Capabilities Chart

删除菜单页面 当前用户可以参考功能 用户角色和功能表

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-remove-menu-item-in-wordpress-admin-panel/

宝塔面板wordpress

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值