欢迎来到资源库(www.zyku.net)

WordPress

当前位置:首页 > CMS教程 > WordPress > 半角符号

WordPress禁止将英文半角符号转换成全角符号

时间:2017-03-03|栏目:WordPress|点击:|我要投稿

今天客户的网站刚用到的,记录一下,以后就知道了。菜单选项的转义用the_title即可解决。

WordPress 模式使用了 wptexturize函数将纯文本字符转换成格式化的 HTML 实体。

标签 <pre>, <code>, <kbd>, <style>, <script>和<tt>中的文本被忽略。

对于一般写单纯码文字的人来说,这个自动将英文半角符号转换成全角符号,是很方便、智能。

但如果你经常要粘贴一些代码,而且没有使用专门的代码高亮插件,你会发现,你代码中的半角符号都会被转换成全角了!别人复制后,根本没办法直接使用!

禁止字符转义的所有代码如下,你可以根据自己的需要,选自己要的代码,添加到主题的 functions.php 文件:

// 取消转义 Quotmarks Replacer 
$qmr_work_tags = array(
  'the_title',             // http://codex.wordpress.org/Function_Reference/the_title
  'the_content',           // http://codex.wordpress.org/Function_Reference/the_content
  'the_excerpt',           // http://codex.wordpress.org/Function_Reference/the_excerpt
  // 'list_cats',          Deprecated. http://codex.wordpress.org/Function_Reference/list_cats
  'single_post_title',     // http://codex.wordpress.org/Function_Reference/single_post_title
  'comment_author',        // http://codex.wordpress.org/Function_Reference/comment_author
  'comment_text',          // http://codex.wordpress.org/Function_Reference/comment_text
  // 'link_name',          Deprecated.
  // 'link_notes',         Deprecated.
  'link_description',      // Deprecated, but still widely used.
  'bloginfo',              // http://codex.wordpress.org/Function_Reference/bloginfo
  'wp_title',              // http://codex.wordpress.org/Function_Reference/wp_title
  'term_description',      // http://codex.wordpress.org/Function_Reference/term_description
  'category_description',  // http://codex.wordpress.org/Function_Reference/category_description
  'widget_title',          // Used by all widgets in themes
  'widget_text'            // Used by all widgets in themes
  );
 
foreach ( $qmr_work_tags as $qmr_work_tag ) {
  remove_filter ($qmr_work_tag, 'wptexturize');
}

当然,你还可以将上面的代码分别下面的形式:

/取消内容转义 
remove_filter('the_content', 'wptexturize');
//取消摘要转义
remove_filter('the_excerpt', 'wptexturize');
//取消评论转义 
remove_filter('comment_text', 'wptexturize');

如果不想修改代码的,直接下载安装 Quotmarks Replacer 插件

(资源库 www.zyku.net)

关于我们 | 版权申明 | 寻求合作 |

重要申明:本站所有的文章、图片、评论等内容,均由网友发表或上传并维护或收集自网络,仅供个人学习交流使用,版权归原作者所有。

如有侵犯您的版权,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:95148658 | 邮箱:mb8#qq.com(#换成@)

苏ICP备2020066115号-1

本网站由提供CDN加速/云存储服务