为了与Wordpress 3.4.2配合使用,我修改了一个废弃的badge插件Stackoverflow表单,它确实做到了。全文如下:http://pastebin.com/Ta91zXiL
升级到Wordpress v3时。5、我在发布帖子(或发表评论)时收到以下警告:
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 355 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 355 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 342 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 355 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/wp-content/plugins/rockhoist-badges/rh-badges.php on line 355 and defined in /public_html/wp-includes/wp-db.php on line 990
Warning: Cannot modify header information - headers already sent by (output started at /public_html/wp-includes/wp-db.php:990) in /public_html/wp-includes/pluggable.php on line 876
因此,它似乎与第342行和第355行有关:function rhb_get_user_comment_count( $args = \'\' ) {
global $wpdb;
$comment_count = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*)
FROM " . $wpdb->prefix . "comments
WHERE user_id = " . $args[\'user_ID\'] . "
AND comment_approved = \'1\'" ) ); // line 342
return $comment_count;
}
function rhb_get_user_post_count( $args = \'\' ) {
global $wpdb;
$post_count = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*)
FROM " . $wpdb->prefix . "posts
WHERE post_author = " . $args[\'user_ID\'] . "
AND post_status = \'publish\'
AND post_type = \'post\'" ) ); // line 355
return $post_count;
}
我一整天都在试图理解这些警告,但都失败了。有没有人能帮我解决这个问题,这样我们就可以为WP 3.5提供一个非常有用的徽章系统的工作版本?