ELLY66
7十一/101

一个小贴士:解决wp-syntax自动转义问题(续)

一个小贴士:解决wp-syntax自动转义问题中,我说了一下如何修改wp_syntax_highlight函数解决自动转义问题。但是,今天我又发现了一个新的问题:单引号。单引号的字符实体是&#39。显示的代码是“&#39”,而不是“’”。接着上次的修改:

if ($escaped != "false") $code = htmlspecialchars_decode($code);

查阅了一下,上面的htmlspecialchars_decode()的语法是

htmlspecialchars_decode(string,quotestyle)

quotestyle有三个参数:ENT_COMPAT(默认,仅解码双引号)、ENT_QUOTES(解码双引号和单引号)、ENT_NOQUOTES(不解码任何引号)。因此,我们需要做的就是:把

if ($escaped != "false") $code = htmlspecialchars_decode($code);

变成

if ($escaped != "false") $code = htmlspecialchars_decode($code,ENT_QUOTES);

保存,Over!

原创文章,转载请注明: 转载自ELLY66

本文链接地址: 一个小贴士:解决wp-syntax自动转义问题(续)

文章的脚注信息由WordPress的wp-posturl插件自动生成

Evernote lets you save all the interesting things you see online into a single place. Access all those saved pages from your computer, phone or the web. Sign up now or learn more. It's free!

 
评论 (1) 引用 (0)
  1. 这个高级了。。


Leave a comment

(required)

还没有引用.

Switch to our mobile site