wp_admin_bar_show_site_icons
云策文档标注
概述
wp_admin_bar_show_site_icons 是一个 WordPress 过滤器钩子,用于控制是否在工具栏中显示站点图标。开发者可以通过此钩子自定义显示行为,例如隐藏图标以优化性能。
关键要点
- 此钩子用于过滤工具栏中站点图标的显示状态,默认值为 true(显示)。
- 返回 false 是推荐的隐藏站点图标的方法,而返回真值可能在大型多站点网络中影响性能。
- 钩子参数为布尔值 $show_site_icons,表示是否显示站点图标。
- 在 wp_admin_bar_my_sites_menu() 函数中使用,用于添加“我的站点”菜单。
- 自 WordPress 6.0.0 版本引入。
原文内容
Filters whether to show the site icons in toolbar.
Description
Returning false to this hook is the recommended way to hide site icons in the toolbar.
A truthy return may have negative performance impact on large multisites.
Parameters
$show_site_iconsbool-
Whether site icons should be shown in the toolbar. Default true.
Source
$show_site_icons = apply_filters( 'wp_admin_bar_show_site_icons', true );
Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |