给网站添加了WP Chinese Conversion,可以进行简体繁体转换了。

目前这个WP Chinese Conversion插件的版本是1.1.16,已经5年没更新了。PHP升级后有了些变化,于是这个插件就有了些error/warning。自己动手将就改了一下,修改都在wp-chinese-conversion.php,把error/warning fixed了。本文记录一下。
each function被新版PHP给deprecated了
把这用到each的代码,比如这个
while(list($key, $val) = each($robots))
if(strstr($ua, strtoupper($val)))
return true;
while(list($key, $val) = each($robots))
if(strstr($ua, strtoupper($val)))
return true;
while(list($key, $val) = each($robots)) if(strstr($ua, strtoupper($val))) return true;
改成
$n = count($robots);
$i = 0;
while ($i < $n) {
$val = $robots[$i];
if(strstr($ua, strtoupper($val))) {
return true;
}
$i++;
}
$n = count($robots);
$i = 0;
while ($i < $n) {
$val = $robots[$i];
if(strstr($ua, strtoupper($val))) {
return true;
}
$i++;
}
$n = count($robots); $i = 0; while ($i < $n) { $val = $robots[$i]; if(strstr($ua, strtoupper($val))) { return true; } $i++; }
create_function也被PHP给deprecated了
把用到create_function的地方改成anonymous function,比如这段
add_filter('posts_distinct', create_function('$s', 'return \'DISTINCT\';'));
add_filter('posts_distinct', create_function('$s', 'return \'DISTINCT\';'));
add_filter('posts_distinct', create_function('$s', 'return \'DISTINCT\';'));
改成
add_filter('posts_distinct', function($s) {
return 'DISTINCT';
});
add_filter('posts_distinct', function($s) {
return 'DISTINCT';
});
add_filter('posts_distinct', function($s) { return 'DISTINCT'; });
总结
修改这两function用到的地方后,就正常工作了。