-} elseif ( !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);
+}
+
+// get_post_status() will get the parent status for attachments.
+$status = get_post_status($post);
+
+$status_obj = get_post_status_object($status);
+
+if ( ! comments_open( $comment_post_ID ) ) {
+ /**
+ * Fires when a comment is attempted on a post that has comments closed.
+ *
+ * @since 1.5.0
+ *
+ * @param int $comment_post_ID Post ID.
+ */
+ do_action( 'comment_closed', $comment_post_ID );
+ wp_die( __( 'Sorry, comments are closed for this item.' ), 403 );
+} elseif ( 'trash' == $status ) {
+ /**
+ * Fires when a comment is attempted on a trashed post.
+ *
+ * @since 2.9.0
+ *
+ * @param int $comment_post_ID Post ID.
+ */
+ do_action( 'comment_on_trash', $comment_post_ID );