+/**
+ * Moves a comment to the Trash
+ *
+ * If trash is disabled, comment is permanently deleted.
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'trash_comment' before trashing
+ * @uses do_action() on 'trashed_comment' after trashing
+ * @uses wp_delete_comment() if trash is disabled
+ *
+ * @param int $comment_id Comment ID.
+ * @return mixed False on failure
+ */
+function wp_trash_comment($comment_id) {
+ if ( !EMPTY_TRASH_DAYS )
+ return wp_delete_comment($comment_id, true);
+
+ if ( !$comment = get_comment($comment_id) )
+ return false;
+
+ do_action('trash_comment', $comment_id);
+
+ if ( wp_set_comment_status($comment_id, 'trash') ) {
+ add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);
+ add_comment_meta($comment_id, '_wp_trash_meta_time', time() );
+ do_action('trashed_comment', $comment_id);
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Removes a comment from the Trash
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'untrash_comment' before untrashing
+ * @uses do_action() on 'untrashed_comment' after untrashing
+ *
+ * @param int $comment_id Comment ID.
+ * @return mixed False on failure
+ */
+function wp_untrash_comment($comment_id) {
+ if ( ! (int)$comment_id )
+ return false;
+
+ do_action('untrash_comment', $comment_id);
+
+ $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
+ if ( empty($status) )
+ $status = '0';
+
+ if ( wp_set_comment_status($comment_id, $status) ) {
+ delete_comment_meta($comment_id, '_wp_trash_meta_time');
+ delete_comment_meta($comment_id, '_wp_trash_meta_status');
+ do_action('untrashed_comment', $comment_id);
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Marks a comment as Spam
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'spam_comment' before spamming
+ * @uses do_action() on 'spammed_comment' after spamming
+ *
+ * @param int $comment_id Comment ID.
+ * @return mixed False on failure
+ */
+function wp_spam_comment($comment_id) {
+ if ( !$comment = get_comment($comment_id) )
+ return false;
+
+ do_action('spam_comment', $comment_id);
+
+ if ( wp_set_comment_status($comment_id, 'spam') ) {
+ add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);
+ do_action('spammed_comment', $comment_id);
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Removes a comment from the Spam
+ *
+ * @since 2.9.0
+ * @uses do_action() on 'unspam_comment' before unspamming
+ * @uses do_action() on 'unspammed_comment' after unspamming
+ *
+ * @param int $comment_id Comment ID.
+ * @return mixed False on failure
+ */
+function wp_unspam_comment($comment_id) {
+ if ( ! (int)$comment_id )
+ return false;
+
+ do_action('unspam_comment', $comment_id);
+
+ $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
+ if ( empty($status) )
+ $status = '0';
+
+ if ( wp_set_comment_status($comment_id, $status) ) {
+ delete_comment_meta($comment_id, '_wp_trash_meta_status');
+ do_action('unspammed_comment', $comment_id);
+ return true;
+ }
+
+ return false;
+}
+