SuperTaoer::Thanksgiving

聪明的人,有时候就是盲的人。

三月 6, 2007

wordpress取消自动替换字符串

文章类别: WordPress的 — SuperTaoer @ 2:38 pm

在wordpress显示内容的时候,发现会自动把“–”替换成“-”
这个在有些时候很不爽,比如实际上想显示 ./configure –help 实际却显示 ./configure -help

于是乎查看wp的源代码,终于找到根源了,
在wp-includes/formatting.php这个文件中
找到wptexturize这个函数,
在这个函数里面再找到如下代码,

  1. $static_characters = array_merge(array('---', ' -- ', '--', 'xn–', '...', '``', '\'s', '\'\'', ' (tm)'), $co
  2. ckney);

把这行注释起来就好了。

  1. //$static_characters = array_merge(array('---', ' -- ', '--', 'xn–', '...', '``', '\'s', '\'\'', ' (tm)'), $co
  2. ckney);

另外,紧接着下面的一行

  1. $static_replacements = array_merge(array('—', ' — ', '–', 'xn--', '…', '“', '’s'
  2. , '”', ' ™'), $cockneyreplace);

把这行也注释起来。。。
取而代之的是:

  1. $static_characters = array("");
  2. $static_replacements = array("");

或者更直接,在函数声明后面直接加上:

  1. function wptexturize($text) {
  2.    
  3.     return $text;
  4.     ......
  5. }

另外,如果你的wordpress版本比较老,例如1.x的版本,
则需要在 wp-includes/functions-formatting.php中找到wptexturize这个函数
找到类似于

  1. $curl = str_replace('---', '—', $curl);
  2. $curl = str_replace(' -- ', ' — ', $curl);
  3. $curl = str_replace('--', '–', $curl);
  4. $curl = str_replace('xn–', 'xn--', $curl);
  5. $curl = str_replace('...', '…', $curl);
  6. $curl = str_replace('``', '“', $curl);

这样的代码,进行注释

tags:


Leave a Message

No Messages

No Messages

RSS feed for comments on this post. TrackBack URI

Leave a Message





本站使用 WordPress架设