dynamic_sidebar_has_widgets
云策文档标注
概述
dynamic_sidebar_has_widgets 是一个 WordPress 过滤器,用于控制侧边栏是否包含小部件。它适用于前端和后端,包括 Widgets 屏幕中的 Inactive Widgets 侧边栏。
关键要点
- 过滤器名称:dynamic_sidebar_has_widgets
- 参数:$did_one(布尔值,表示是否至少渲染了一个小部件,默认 false)和 $index(整数或字符串,表示动态侧边栏的索引、名称或 ID)
- 应用场景:评估空侧边栏,并用于动态侧边栏的显示判断
- 相关函数:dynamic_sidebar()
- 引入版本:WordPress 3.9.0
原文内容
Filters whether a sidebar has widgets.
Description
Note: The filter is also evaluated for empty sidebars, and on both the front end and back end, including the Inactive Widgets sidebar on the Widgets screen.
Parameters
$did_onebool-
Whether at least one widget was rendered in the sidebar.
Default false. $indexint|string-
Index, name, or ID of the dynamic sidebar.
Source
return apply_filters( 'dynamic_sidebar_has_widgets', $did_one, $index );
Changelog
| Version | Description |
|---|---|
| 3.9.0 | Introduced. |