From 423287de0de9d92a4604a996839289a148511792 Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Tue, 3 May 2005 07:31:29 +0000 Subject: [PATCH] Don't accept comments on drafts - http://mosquito.wordpress.org/view.php?id=946 git-svn-id: https://develop.svn.wordpress.org/trunk@2580 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-comments-post.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-comments-post.php b/wp-comments-post.php index 554abd570d..c7d5a6fd1e 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -3,14 +3,17 @@ require( dirname(__FILE__) . '/wp-config.php' ); $comment_post_ID = (int) $_POST['comment_post_ID']; -$post_status = $wpdb->get_var("SELECT comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'"); +$status = $wpdb->get_row("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = '$comment_post_ID'"); -if ( empty($post_status) ) { +if ( empty($status->comment_status) ) { do_action('comment_id_not_found', $comment_post_ID); exit; -} elseif ( 'closed' == $post_status ) { +} elseif ( 'closed' == $status->comment_status ) { do_action('comment_closed', $comment_post_ID); die( __('Sorry, comments are closed for this item.') ); +} elseif ( 'draft' == $status->post_status ) { + do_action('comment_on_draft', $comment_post_ID); + exit; } $comment_author = trim($_POST['author']);