解决 WordPress 半角符号自动变成全角符号的方法
WordPress 总是喜欢自作主张的把英文的单引号 ‘ 和双引号 ” 变成中文的全角 ’ 和 “
尽管一般情况下,这种自作主张无伤大雅,但如果在张贴程序代码的时候,就足以导致致命错误。解决的方法:编辑在 WordPress 目录下的 wp-includes/formatting.php 文件:
将如下代码
for ( $i = 0; $i < $stop; $i++ ) {
$curl = $textarr[$i];if (isset($curl{0}) && ‘<‘ != $curl{0} && ‘[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag
// static strings
$curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
} elseif (strpos($curl, '<code') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) {
$next = false;
} elseif (strpos($curl, '<pre') !== false) {
$has_pre_parent = true;
} elseif (strpos($curl, '</pre>') !== false) {
$has_pre_parent = false;
} else {
$next = true;
} $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/‘, ‘&$1‘, $curl);
$output .= $curl;
}
改为
for ( $i = 0; $i < $stop; $i++ ) {
$curl = $textarr[$i];if (isset($curl{0}) && ‘<‘ != $curl{0} && ‘[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag
// static strings
//$curl = str_replace($static_characters, $static_replacements, $curl);
// regular expressions
//$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
} elseif (strpos($curl, '<code') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) {
$next = false;
} elseif (strpos($curl, '<pre') !== false) {
$has_pre_parent = true;
} elseif (strpos($curl, '</pre>') !== false) {
$has_pre_parent = false;
} else {
$next = true;
}$curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/‘, ‘&$1‘, $curl);
$output .= $curl;
}
1 Comment
Hi, interest post. I’ll write you later about few questions!
KattyBlackyard
23:52