woof_husky_txt_templates
当插件中不存在默认模板文件时,过滤 Husky 文本搜索结果模板的文件路径,允许自定义模板位置。
参数
$template (string) — 用于定位自定义模板文件的已清理模板键(例如“default”)
源文件
ext/by_text/index.php:1033
代码示例
add_filter('woof_husky_txt_templates', function($template) {
$custom_path = get_stylesheet_directory() . '/woof/search-templates/' . $template . '.php';
return file_exists($custom_path) ? $custom_path : '';
});
使用说明
- 仅当插件的 views/templates 目录中不存在默认模板文件时调用。
- 如果过滤器返回的路径不存在,则会回退到主题的 woof/ext/by_text/views/templates/ 目录。
- 模板值在使用前通过 sanitize_key() 进行清理。