每个人都应该了解的WordPress Admin Bar

WordPress comes with an admin bar that displays handy shortcuts for logged in users. This gives you quick access to admin tasks even when viewing your website’s front-end. In this article, we will explain what is the WordPress admin bar, and how you can utilize or customize it to your own needs.

WordPress附带一个管理栏,为登录的用户显示方便的快捷方式。 这样,即使在查看网站的前端时,也可以快速访问管理任务。 在本文中,我们将解释什么是WordPress管理栏,以及如何根据自己的需要使用或自定义它。

What you need to know about WordPress admin bar
什么是WordPress管理员栏? (What is WordPress Admin Bar?)

WordPress admin bar is a floating bar displayed for logged in users. It contains links to different admin screens, which allows logged in users to quickly switch to admin area when viewing the website.

WordPress管理栏是为登录用户显示的浮动栏。 它包含指向不同管理屏幕的链接,允许登录的用户在查看网站时快速切换到管理区域

WordPress admin bar

The admin bar is displayed for all users inside the admin area. Individual users can hide the admin bar when viewing the website by editing their user profile.

将为管理区域内的所有用户显示管理栏。 个别用户在查看网站时可以通过编辑其用户资料来隐藏管理栏。

Show or hide admin bar when viewing website

The items displayed in the WordPress admin bar change based on user role and permissions. For example, users with administrator role see different items in the menu bar than users with editor role and so on.

WordPress管理栏中显示的项目根据用户角色和权限而变化 。 例如,具有管理员角色的用户在菜单栏中看到的项目与具有编辑者角色的用户等不同。

在WordPress管理栏中显示或隐藏项目 (Show or Hide Items in WordPress Admin Bar)

Just like everything else in WordPress, the Admin bar is fully customizable via custom code or plugins. Some plugins already take advantage of this feature by adding their own menus in the admin bar.

就像WordPress中的其他所有内容一样,管理栏可以通过自定义代码或插件完全自定义。 一些插件已经通过在管理栏中添加自己的菜单来利用此功能。

Plugins adding their own items in admin bar

To take control of the admin bar, first you will need to install and activate the Adminimize plugin. For more details, see our step by step guide on how to install a WordPress plugin.

要控制管理栏,首先您需要安装并激活Adminimize插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, go to Settings » Adminimize page and look for Admin Bar Backend Options and Admin Bar Front End Options tabs.

激活后,转到“设置”»“管理”页面,然后查找“管理栏后端选项”和“管理栏前端选项”选项卡。

Admin bar options

Clicking on each of them will take you to the admin bar options where you can select which items to display in WordPress admin bar. You can also choose items visible to each user role.

单击每个按钮将带您到管理栏选项,您可以在其中选择要在WordPress管理栏中显示的项目。 您还可以选择每个用户角色可见的项目。

Show or hide items from WordPress admin bar

Don’t forget to click on ‘Update options’ button to save your changes.

不要忘记单击“更新选项”按钮以保存您的更改。

Adminimize is a powerful plugin and allows you to change not just the admin bar but any admin screen on your WordPress site. To learn more, see our guide on how to hide unnecessary items from WordPress admin with Adminimize

Adminimize是一个功能强大的插件,可让您不仅更改管理栏,还可以更改WordPress网站上的任何管理屏幕。 要了解更多信息,请参阅我们的指南,了解如何使用Adminimize从WordPress管理员隐藏不必要的项目

将自定义链接添加到WordPress管理栏 (Add Custom Links to WordPress Admin Bar)

The purpose of the WordPress admin bar is to provide quick shortcuts to different admin screens. You can further customize it by adding your own custom links to the admin bar.

WordPress管理栏的目的是为不同的管理屏幕提供快速的快捷方式。 您可以通过将自己的自定义链接添加到管理栏来进一步自定义它。

For this, you will need to add custom code to your WordPress files. If you haven’t done this before, then take a look at our guide on how to copy and paste code in WordPress.

为此,您将需要向WordPress文件添加自定义代码。 如果您以前没有做过,请查看我们的指南,了解如何在WordPress中复制和粘贴代码

First you need to add this code to your theme’s functions.php file or a site-specific plugin.

首先,您需要将此代码添加到主题的functions.php文件或特定站点的插件中


// add a link to the WP Toolbar
function wpb_custom_toolbar_link($wp_admin_bar) {
    $args = array(
        'id' => 'wpbeginner',
        'title' => 'Search WPBeginner', 
        'href' => 'https://www.google.com:443/cse/publicurl?cx=014650714884974928014:oga60h37xim', 
        'meta' => array(
            'class' => 'wpbeginner', 
            'title' => 'Search WPBeginner Tutorials'
            )
    );
    $wp_admin_bar->add_node($args);
}
add_action('admin_bar_menu', 'wpb_custom_toolbar_link', 999);

In this code, we have added a link to Google that searches WPBeginner. You need to replace ID, title, and href values with your own.

在此代码中,我们向Google添加了一个搜索WPBeginner的链接。 您需要用自己的ID,title和href值替换。

Adding custom link to WordPress admin bar

For more details, see our guide on how to easily add custom links to your WordPress admin bar.

有关更多详细信息,请参阅有关如何轻松将自定义链接添加到WordPress管理栏的指南

对除管理员以外的所有用户禁用管理栏 (Disable Admin Bar for All Users Except Administrators)

Admin bar is highly useful for site administrators, editors, and authors. However, it is not very useful if you are running a WordPress membership website or just require users to login for certain tasks.

管理员栏对于站点管理员,编辑者和作者非常有用。 但是,如果您正在运行WordPress成员资格网站或仅要求用户登录才能执行某些任务,则它不是很有用。

In that case, you may want to disable the admin bar for all users except site administrators. You will need to add the following code to your theme’s functions.php file or a site-specific plugin.

在这种情况下,您可能要禁用网站管理员以外的所有用户的管理栏。 您将需要在主题的functions.php文件或特定站点的插件中添加以下代码。



add_action('after_setup_theme', 'wpb_remove_admin_bar');
 
function wpb_remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
  show_admin_bar(false);
}
}

For more details see our article on how to disable WordPress admin bar for all users except administrators.

有关更多详细信息,请参阅有关如何为除管理员之外的所有用户禁用WordPress管理栏的文章。

We hope this article helped you learn more about the WordPress admin bar. You may also want to see our ultimate step by step WordPress security guide to keep your WordPress admin area safe and secure.

我们希望本文能帮助您了解有关WordPress管理栏的更多信息。 您可能还希望查看我们的终极WordPress分步指南,以确保WordPress管理区域的安全。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/what-everybody-ought-to-know-about-the-wordpress-admin-bar/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值