替代原点函数的另一个解决方案wptexturize
并更新所有相关筛选器。
define(\'EXCERPT_RARELY_2\', \'{[2}]\');
function wptexturize_custom($text = \'\')
{
$text = preg_replace(\'!(^|[^\\-])\\-\\-([^\\-]|$)!\', \'$1\' . EXCERPT_RARELY_2 . \'$2\', $text);
// get through origin filter
$text = wptexturize($text);
return str_replace(EXCERPT_RARELY_2, \'--\', $text);
}
// remove default filter
remove_filter(\'the_content\', \'wptexturize\');
// add custom filter
add_filter(\'the_content\', \'wptexturize_custom\');
// remove default filter
remove_filter(\'the_excerpt\', \'wptexturize\');
// add custom filter
add_filter(\'the_excerpt\', \'wptexturize_custom\');