当前所在位置: 首页>>百科全书

WordPress取消英文标点符号自动替换中文标点符号的优雅方法

发布时间:2025-10-23 09:53:25 本站作者 【 字体: 】 浏览:66 次

众所周知,WordPress中文版有个特性,会将每一处英文引号("")都稀里哗啦转化为中文引号(“”)。不仅仅是英文引号,在WordPress翻译文件定义了不少自动转换符号,具体可以参考这里

对文字博客来说,这是个好功能,这样会避免用错英文标点。

然而,WordPress是独立的php程序,中文社区中懂得使用者,大部分都是技术博客。而技术博客会经常贴出代码,里面包含各种英文标点是再正常不过的事情。这时候,英文标点符号自动转换就是一个恼人的画蛇添足功能了。

网上很多文章都是让该WordPress核心文件。只不过,WordPress是一个高度模块化的系统,肯定有更优雅的解决方案。

一番搜寻之后,发现最简单的办法,就是安装一个叫Quotmarks Replacer的插件,地址在这里

插件很简单,就是将WordPress自动转换标点符号的函数用系统接口去掉。核心代码如下:

<?php
/*
Plugin Name: Quotmarks Replacer
Plugin URI: http://sparanoid.com/work/quotmarks-replacer/
Description: Quotmarks Replacer disables wptexturize function that keeps all quotation marks and suspension points in half-width form.
Version: 2.6.17
Author: Tunghsiao Liu
Author URI: http://sparanoid.com/
Author EmAIl: t@sparanoid.com
License: GPLv2 or later
Copyright 2016 Tunghsiao Liu, aka. Sparanoid (t@sparanoid.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
$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');
}

当然你也可以参考这篇文章:https://www.freexyz.cn/cms/bee94fdf6816331685a559f0aec28cfd.html


上一篇:如何手动将本地WordPress站点迁移到主机/服务器?

下一篇:Win10电脑skype一直转圈登录不了怎么办?

最新发布
Office2010怎么激活?附Office2010激活工具

Office2010怎么激活?附Office2010激活工具

Office2010怎么激活?附Office2010激活工具
现在很多网友在使用Office2010版本的软件,多数网友表示刚下载使用的时候是正常的,但是使用一段时间后就发现会出现激活失败的问题,那么Office2010要如何激活呢?下面就给大家分享Office2010激活的教程。在激活的过程中需要借助激活工具:1、下载好激活工具后解压并运行其中的激活程序“mini-KMS_Activator_v1.2_O...
office2016怎么激活密钥?office2016产品激活密钥安装图文教程

office2016怎么激活密钥?office2016产品激活密钥安装图文教程

office2016怎么激活密钥?office2016产品激活密钥安装图文教程
MicrosoftOffice2016是微软公司推出的一款办公软件套件。它包含了Word、Excel、PowerPoint、Outlook、OneNote、Publisher、Access等常见的办公软件,为用户提供了一个全面的解决方案。今天就让小编为大家解答一下office2016怎么激活密钥?office2016怎么安装的吧!一、如何安装office2016?office2016电脑版是款...
Office2016激活秘钥免费激活码,Office2016最新激活密钥分享

Office2016激活秘钥免费激活码,Office2016最新激活密钥分享

Office2016激活秘钥免费激活码,Office2016最新激活密钥分享
作为一款基于Windows系统的办公软件套装,Office在世界各地都不乏拥趸,中国当然也不例外,甚至还有不少企业仍在使用经典的Office2016!但想要永久破解Office2016,还需要购买最新的产品密钥或在网络中找寻尚未失效的Office2016永久激活秘钥,下面小编就来分享一些Office2016激活密钥。&nbs...
office2016永久激活密钥,office2016产品永久激活的方法(亲测可以正常激活)

office2016永久激活密钥,office2016产品永久激活的方法(亲测可以正常激活)

office2016永久激活密钥,office2016产品永久激活的方法(亲测可以正常激活)
如果要永久激活Office2016需要购买最新的产品密钥,因为网上分享的Office 2016永久激活密钥容易失效,所以要时刻关注新发布的Office2016永久激活码,或者直接购买Office2016永久序列号。这边小编为大家整理分享最新office2016永久激活密钥 office2016激活码及永久激活office2016。那么如何永久激活Office2016呢,以及激活的...