dynamic_sidebar
云策文档标注
概述
dynamic_sidebar 是一个 WordPress 动作钩子,在调用小部件的显示回调之前触发。它适用于前端和后端,包括小部件屏幕上的非活动小部件侧边栏,但不会为空侧边栏触发。
关键要点
- 触发时机:在小部件的显示回调被调用之前执行。
- 适用范围:同时作用于前端和后端,包括 Widgets 屏幕中的 Inactive Widgets 侧边栏。
- 限制条件:不会为空侧边栏触发此动作。
- 参数说明:接受一个关联数组 $widget,包含 name、id、callback、params、classname、description 和 _callback 等键,用于传递小部件相关信息。
- 相关函数:与 wp_render_widget() 和 dynamic_sidebar() 函数关联,用于小部件的渲染和显示。
- 版本历史:自 WordPress 3.0.0 版本引入。
原文内容
Fires before a widget’s display callback is called.
Description
Note: The action fires on both the front end and back end, including for widgets in the Inactive Widgets sidebar on the Widgets screen.
The action is not fired for empty sidebars.
Parameters
$widgetarray-
An associative array of widget arguments.
namestringName of the widget.idstringWidget ID.callbackcallableWhen the hook is fired on the front end,$callbackis an array containing the widget object. Fired on the back end,$callbackis'wp_widget_control', see$_callback.paramsarrayAn associative array of multi-widget arguments.classnamestringCSS class applied to the widget container.descriptionstringThe widget description._callbackarrayWhen the hook is fired on the back end,$_callbackis populated with an array containing the widget object, see$callback.
Source
do_action( 'dynamic_sidebar', $wp_registered_widgets[ $id ] );
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |