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

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

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

本文主要介绍WordPress取消英文标点符号,自动替换中文标点符号的优雅方法。有需要的朋友可以参考一下。

众所周知,中文版的WordPress有一个特性,会把每一个英文引号("")转换成中文引号("")。WordPress翻译文件中不仅定义了英文引号,还定义了很多自动转换符号。详情请参考此处。

对于文字博客来说,这是一个很好的功能,可以避免使用错误的英文标点。

但是WordPress是一个独立的php程序,中文社区的大部分用户都是技术博客。技术博客经常发布包含各种英文标点符号的代码,这很正常。这时候英文标点符号的自动转换就是一个很讨厌的画蛇添足的功能。

很多网络文章都是WordPress的核心文件。然而,WordPress是一个高度模块化的系统,必须有一个更优雅的解决方案。

经过一番搜索,我发现最简单的方法是安装一个名为QuotmarksReplacer的插件。地址在这里。

插件很简单,就是用系统界面去掉了WordPress中自动转换标点符号的功能。核心代码如下:

<?php /* PluginName:QuotmarksReplacer PluginURI:http://sparanoid.com/work/quotmarks-replacer/ Description:QuotmarksReplacerdisableswptexturizefunctionthatkeepsallquotationmarksandsuspensionpointsinhalf-widthform. Version:2.6.17 Author:TunghsiaoLiu AuthorURI:http://sparanoid.com/ AuthorEmail:[email protected] License:GPLv2orlater Copyright2016TunghsiaoLiu,aka.Sparanoid([email protected]) Thisprogramisfreesoftware;youcanredistributeitand/ormodify itunderthetermsoftheGNUGeneralPublicLicense,version2,as publishedbytheFreeSoftwareFoundation. Thisprogramisdistributedinthehopethatitwillbeuseful, butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe GNUGeneralPublicLicenseformoredetails. YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware Foundation,Inc.,51FranklinSt,FifthFloor,Boston,MA02110-1301USA */ $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,butstillwidelyused. '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',//Usedbyallwidgetsinthemes 'widget_text'//Usedbyallwidgetsinthemes ); foreach($qmr_work_tagsas$qmr_work_tag){ remove_filter($qmr_work_tag,'wptexturize'); }

当然,你也可以参考这篇文章:https://www.jb51.net/cms/261975.html

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/773901.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存