woof_taxonomy_type_objects_front_render
决定一个分类法类型对象是否应作为当前筛选器类型渲染,并允许传递调整后的参数,支持自定义分类法渲染扩展。
参数
$is (bool) — 布尔值,指示当前对象的 html_type 是否与配置的分类法类型匹配
$html_type (string) — 被检查的当前分类法类型扩展对象的 html_type 键
$tax_type (string) — 当前分类法配置的分类法类型(例如:'radio'、'checkbox'、'select')
$args (array) — 渲染参数数组,包含 woof_settings、taxonomies_info 及其他模板数据
源文件
views/woof.php:291
代码示例
add_filter('woof_taxonomy_type_objects_front_render', function($is, $html_type, $tax_type, $args) {
// Force a custom renderer for a specific taxonomy
if ('my_custom_tax' === $html_type) {
return array(
'is' => true,
'args' => array_merge($args, array('custom_data' => 'value'))
);
}
return $is;
}, 10, 4);
使用说明
- 当筛选器返回包含 'args' 键的数组时,这些参数会覆盖现有的 $args 变量以用于后续渲染。
- 当 'is' 返回 true(且未被覆盖)时,将渲染扩展的 html_type 视图。
- 如果没有匹配的分类法类型扩展,则默认使用单选视图作为回退。