From 561dd7050a9e59b2b6fa4bd710a7cb6b9baed84c Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 18 Feb 2010 20:08:35 +0000 Subject: [PATCH] Deny commenting on any post with a non-public status. see #9674 git-svn-id: https://develop.svn.wordpress.org/trunk@13200 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-comments-post.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-comments-post.php b/wp-comments-post.php index e60d159ddc..2991711779 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -24,15 +24,19 @@ $status = $wpdb->get_row( $wpdb->prepare("SELECT post_status, comment_status FRO if ( empty($status->comment_status) ) { do_action('comment_id_not_found', $comment_post_ID); exit; -} elseif ( !comments_open($comment_post_ID) ) { +} + +$status_obj = get_post_status_object($status->post_status); + +if ( !comments_open($comment_post_ID) ) { do_action('comment_closed', $comment_post_ID); wp_die( __('Sorry, comments are closed for this item.') ); -} elseif ( in_array($status->post_status, array('draft', 'future', 'pending') ) ) { - do_action('comment_on_draft', $comment_post_ID); - exit; } elseif ( 'trash' == $status->post_status ) { do_action('comment_on_trash', $comment_post_ID); exit; +} elseif ( !$status_obj->public ) { + do_action('comment_on_draft', $comment_post_ID); + exit; } elseif ( post_password_required($comment_post_ID) ) { do_action('comment_on_password_protected', $comment_post_ID); exit;