From 2fd04bb9024109cdbc36af8a8b39b9964da80b31 Mon Sep 17 00:00:00 2001 From: matt 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: http://svn.automattic.com/wordpress/trunk@2580 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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']);