中文引号 php,WordPress英文引号变成中文解决方法

自不久前WP升至4.0后很长一段时间 偶然发现之前用纯CSS转的高亮代码中,英文引号全部都变成中文引号了,半角变全角。

有两种方法可以搞定,

方法一

升级之后wp-include目录下的formatting.php也有所不同,这次要找到四句条件判断将其注释掉。以下:

elseif ( empty( $no_texturize_shortcodes_stack ) && empty( $no_texturize_tags_stack ) ) {

// This is neither a delimiter, nor is this content inside of no_texturize pairs. Do texturize.

// $curl = str_replace( $static_characters, $static_replacements, $curl );

if ( false !== strpos( $curl, "'" ) ) {

// $curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl );

}

if ( false !== strpos( $curl, '"' ) ) {

// $curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl );

}

if ( false !== strpos( $curl, '-' ) ) {

// $curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl );

}

将红色部分变量$curl的替换语句注释掉即可。

方法二

将下面的代码加入functions.php文件内即可。(根据需要添加)

//禁止转义引号字符

remove_filter('the_content', 'wptexturize'); // 禁止英文引号转义为中文引号

remove_filter('the_content', 'balanceTags'); //禁止对标签自动校正

remove_filter('the_content', 'wpautop'); //禁止自动为段落加

以上。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值