更新了WordPress3.5之后,插件post-views不好用了。原因有一位网友在wordpress的论坛已经指出了,帖子地址:http://wordpress.org/support/topic/not-woking-with-wordpress-35
Wordpress3.5做了如下修改:
r22304 | r22429 | |
---|---|---|
988 | 988 | * if there was something to prepare |
989 | 989 | */ |
990 | function prepare( $query |
|
990 | function prepare( $query, $args ) { | |
991 | 991 | if ( is_null( $query ) ) |
992 | 992 | return; |
地址:https://core.trac.wordpress.org/changeset/22429#file0
所以调用了prepare函数的地方会报错,说函数调用缺少参数2:
“Views Today: Warning: Missing argument 2 for wpdb::prepare(), called in /var/www/vhosts/xxxxxx.com/xxxxxx/wp-content/plugins/post-views/post-views.php on line 2517 and defined in /var/www/vhosts/xxxxxx.com/xxxxxxx/wp-includes/wp-db.php on line 990 80″
最简单的解决问题就是定义一个变量$args = null;然后在所有prepare函数调用的地方加上这一个参数,因为在prepare函数内部对于第二个参数有初始化的语句,所以传null进去就可以了。
修改以后的语句大概是这个样子的:
$args = null;
$arc_query = $wpdb->prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts ORDER BY post_date DESC",$args);
以上仅为救急解决方案,整个插件对于prepare函数的调用达29处之多,所以如果不是特别急用,就先停用插件等待作者更新吧,应该会很快的。
PS:更新3.5之后CKEditor似乎也不好用了。
PS2:感谢LR童鞋对本文做出的贡献,不懂PHP的人伤不起啊(┬_┬)