widget_block_dynamic_classname
云策文档标注
概述
widget_block_dynamic_classname 是一个 WordPress 过滤器钩子,用于动态设置块小部件容器 HTML 的类名。它允许开发者根据块小部件中包含的块名称来定制类名。
关键要点
- 这是一个过滤器钩子,用于修改块小部件容器的类名。
- 接受两个参数:$classname(当前类名字符串)和 $block_name(块名称字符串)。
- 由 WP_Widget_Block::get_dynamic_classname() 方法调用,用于计算类名。
- 在 WordPress 5.8.0 版本中引入。
原文内容
The classname used in the block widget’s container HTML.
Description
This can be set according to the name of the block contained by the block widget.
Parameters
$classnamestring-
The classname to be used in the block widget’s container HTML, e.g. ‘widget_block widget_text’.
$block_namestring-
The name of the block contained by the block widget, e.g.
'core/paragraph'.
Source
return apply_filters( 'widget_block_dynamic_classname', $classname, $block_name );
Changelog
| Version | Description |
|---|---|
| 5.8.0 | Introduced. |