wordpress - style_loader_tag 过滤器正在转换特殊字符,即使禁用 wptexturize
问题描述
我正在使用 style_loader_tag 过滤器预加载一些 gfonts,问题是将所有“&”转换为“ 8;”。
我检查了我的函数,它正确输出了 html,所以我很确定是过滤器在做这个改变。
我尝试在该过滤器上禁用 wptexturize,但它不起作用。
remove_filter('style_loader_tag', 'wptexturize', 1);
add_filter('style_loader_tag', 'rubik_style_loader_tag_filter', 10, 2);
add_filter('style_loader_tag', 'wptexturize', 11);
我什至试过这个:
add_filter( 'run_wptexturize', '__return_false', 1 );
但是..还是什么都没有。
有什么建议吗?
解决方案
您可以使用过滤器设置要跳过的 html 标记。
将跳过包含在标签 pre、code、kbd、style、script 和 tt 中的文本。可以使用 no_texturize_tags 过滤器更改此标签列表。
https://developer.wordpress.org/reference/hooks/no_texturize_tags/
add_filter( 'no_texturize_tags', 'disable_link_filter', 1, 1 );
function disable_link_filter($filter){
$filter[] = "link"; //Add Link tag to the skip list
return filter;
}
编辑:要转储所有过滤器挂钩,您可以使用以下功能
function print_filters() {
global $wp_filter;
print '<pre>';
print_r( $wp_filter );
print '</pre>';
}
要调用它,您可以使用
print_filters();
推荐阅读
- windows - 我需要访问 Windows 开始菜单中列出的所有程序
- javascript - 如何在 Next.js 公共目录中使用环境变量
- visual-studio-code - 在 VSCode 编辑器中使用 `,,`(两个逗号)作为 Emmet “扩展缩写”命令
- entity-framework-core - EF Core 错误,两个导航属性指向同一实体
- php - Laravel - 使用帮助函数时无法获取更新的配置值
- email - 如何使用 gomail 从内存中发送附件?
- c - 用于rockchip vop和irqs的Linux drm图形驱动程序
- ios - 如果没有打开 iPhone wifi,Watch 应用无法发出直接请求
- airflow - 气流调度器模式
- python - 如何正确添加自定义字段作为 Django 管理员更改表单的可调用项?