Ticket #4529: delete-comment.10.diff

File delete-comment.10.diff, 25.0 KB (added by caesarsgrunt, 4 years ago)

slight change to enable an option for the length of time deleted comments should be kept to be added in the future

Line 
1Index: wp-includes/comment.php
2===================================================================
3--- wp-includes/comment.php     (revision 11710)
4+++ wp-includes/comment.php     (working copy)
5@@ -208,6 +208,8 @@
6                $approved = "comment_approved = '1'";
7        elseif ( 'spam' == $status )
8                $approved = "comment_approved = 'spam'";
9+       elseif ( 'deleted' == $status )
10+               $approved = "comment_approved = 'deleted'";
11        else
12                $approved = "( comment_approved = '0' OR comment_approved = '1' )";
13 
14@@ -699,7 +701,7 @@
15        $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
16 
17        $total = 0;
18-       $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam');
19+       $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted');
20        $known_types = array_keys( $approved );
21        foreach( (array) $count as $row_num => $row ) {
22                $total += $row['num_comments'];
23@@ -735,8 +737,13 @@
24  * @return bool False if delete comment query failure, true on success.
25  */
26 function wp_delete_comment($comment_id) {
27+       if (wp_get_comment_status($comment_id) != 'deleted' && wp_get_comment_status($comment_id) != 'spam')
28+               return wp_set_comment_status($comment_id, 'delete');
29+       
30        global $wpdb;
31        do_action('delete_comment', $comment_id);
32+       
33+       wp_unschedule_comment_destruction($comment_id);
34 
35        $comment = get_comment($comment_id);
36 
37@@ -784,6 +791,8 @@
38                return 'unapproved';
39        elseif ( $approved == 'spam' )
40                return 'spam';
41+       elseif ( $approved == 'deleted' )
42+               return 'deleted';
43        else
44                return false;
45 }
46@@ -1028,7 +1037,8 @@
47  */
48 function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
49        global $wpdb;
50-
51+       wp_unschedule_comment_destruction($comment_id);
52+       
53        $status = '0';
54        switch ( $comment_status ) {
55                case 'hold':
56@@ -1045,7 +1055,10 @@
57                        $status = 'spam';
58                        break;
59                case 'delete':
60-                       return wp_delete_comment($comment_id);
61+                       if (wp_get_comment_status($comment_id) == 'deleted' || wp_get_comment_status($comment_id) == 'spam')
62+                               return wp_delete_comment($comment_id);
63+                       $status = 'deleted';
64+                       wp_schedule_comment_destruction($comment_id);
65                        break;
66                default:
67                        return false;
68@@ -1071,6 +1084,42 @@
69 }
70 
71 /**
72+ * Schedules a comment for destruction in 30 days.
73+ *
74+ * @since 2.9.0
75+ *
76+ * @param int $comment_id Comment ID.
77+ * @return void
78+ */
79+function wp_schedule_comment_destruction($comment_id) {
80+       $to_destroy = get_option('to_destroy');
81+       if (!is_array($to_destroy))
82+               $to_destroy = array();
83+       
84+       $to_destroy['comments'][$comment_id] = time();
85+       
86+       update_option('to_destroy', $to_destroy);
87+}
88+
89+/**
90+ * Unschedules a comment for destruction.
91+ *
92+ * @since 2.9.0
93+ *
94+ * @param int $comment_id Comment ID.
95+ * @return void
96+ */
97+function wp_unschedule_comment_destruction($comment_id) {
98+       $to_destroy = get_option('to_destroy');
99+       if (!is_array($to_destroy))
100+               return;
101+       
102+       unset($to_destroy['comments'][$comment_id]);
103+       
104+       update_option('to_destroy', $to_destroy);
105+}
106+
107+/**
108  * Updates an existing comment in the database.
109  *
110  * Filters the comment and makes sure certain fields are valid before updating.
111Index: wp-includes/pluggable.php
112===================================================================
113--- wp-includes/pluggable.php   (revision 11710)
114+++ wp-includes/pluggable.php   (working copy)
115@@ -1767,4 +1767,32 @@
116 }
117 endif;
118 
119+/**
120+ * Destroys comments which have previously been scheduled for destruction.
121+ * Will do the same for posts, pages, etc in the future.
122+ *
123+ * @access private
124+ * @since 2.9.0
125+ *
126+ * @return void
127+ */
128+function _scheduled_destruction() {
129+       $to_destroy = get_option('to_destroy');
130+       if (!is_array($to_destroy))
131+               return;
132+       
133+       $deletetimestamp = time()-(60*60*24*30);
134+       foreach ($to_destroy['comments'] as $comment_id => $timestamp) {
135+               if ($timestamp < $deletetimestamp) {
136+                       wp_delete_comment($comment_id);
137+                       unset($to_destroy['comments'][$comment_id]);
138+               }
139+       }
140+       
141+       update_option('to_destroy', $to_destroy);
142+}
143+add_action( '_scheduled_destruction', '_scheduled_destruction' );
144+if ( !wp_next_scheduled('_scheduled_destruction') && !defined('WP_INSTALLING') )
145+       wp_schedule_event(time(), 'daily', '_scheduled_destruction');
146+
147 ?>
148Index: wp-includes/script-loader.php
149===================================================================
150--- wp-includes/script-loader.php       (revision 11710)
151+++ wp-includes/script-loader.php       (working copy)
152@@ -63,7 +63,7 @@
153        $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090623' );
154        $scripts->add_data( 'common', 'group', 1 );
155        $scripts->localize( 'common', 'commonL10n', array(
156-               'warnDelete' => __("You are about to delete the selected items.\n  'Cancel' to stop, 'OK' to delete."),
157+               'warnDelete' => __("You are about to permanently delete the selected items.\n  'Cancel' to stop, 'OK' to delete."),
158                'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};'
159        ) );
160 
161Index: wp-admin/edit-comments.php
162===================================================================
163--- wp-admin/edit-comments.php  (revision 11710)
164+++ wp-admin/edit-comments.php  (working copy)
165@@ -14,32 +14,36 @@
166 
167 $post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
168 
169-if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spam2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
170-       check_admin_referer('bulk-spam-delete', '_spam_nonce');
171-
172-       $delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] );
173-       if ( current_user_can('moderate_comments')) {
174-               $deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
175-       } else {
176-               $deleted_spam = 0;
177-       }
178-       $redirect_to = 'edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam;
179-       if ( $post_id )
180-               $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
181-       wp_redirect( $redirect_to );
182-} elseif ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) {
183+if ( isset($_REQUEST['doaction']) ||  isset($_REQUEST['doaction2']) || isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2']) ) {
184        check_admin_referer('bulk-comments');
185-       $doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
186-
187-       $deleted = $approved = $unapproved = $spammed = 0;
188-       foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each
189-               $comment_id = (int) $comment_id;
190+       
191+       if ((isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) {
192+               $comment_status = $wpdb->escape($_REQUEST['comment_status']);
193+               $delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']);
194+               $comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" );
195+               $doaction = 'destroy';
196+       } elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) {
197+               $comment_ids = $_REQUEST['delete_comments'];
198+               $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
199+       } else wp_redirect($_SERVER['HTTP_REFERER']);
200+       
201+       $approved = $unapproved = $spammed = $deleted = $destroyed = 0;
202+       
203+       foreach ($comment_ids as $comment_id) { // Check the permissions on each
204                $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
205 
206                if ( !current_user_can('edit_post', $_post_id) )
207                        continue;
208 
209                switch( $doaction ) {
210+                       case 'approve' :
211+                               wp_set_comment_status($comment_id, 'approve');
212+                               $approved++;
213+                               break;
214+                       case 'unapprove' :
215+                               wp_set_comment_status($comment_id, 'hold');
216+                               $unapproved++;
217+                               break;
218                        case 'markspam' :
219                                wp_set_comment_status($comment_id, 'spam');
220                                $spammed++;
221@@ -48,18 +52,14 @@
222                                wp_set_comment_status($comment_id, 'delete');
223                                $deleted++;
224                                break;
225-                       case 'approve' :
226-                               wp_set_comment_status($comment_id, 'approve');
227-                               $approved++;
228+                       case 'destroy' :
229+                               wp_set_comment_status($comment_id, 'delete');
230+                               $destroyed++;
231                                break;
232-                       case 'unapprove' :
233-                               wp_set_comment_status($comment_id, 'hold');
234-                               $unapproved++;
235-                               break;
236                }
237-       endforeach;
238+       }
239 
240-       $redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved;
241+       $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&deleted=' . $deleted . '&destroyed=' . $destroyed;
242        if ( $post_id )
243                $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
244        if ( isset($_REQUEST['apage']) )
245@@ -86,7 +86,7 @@
246 $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']);
247 
248 $comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all';
249-if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam')) )
250+if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'deleted')) )
251        $comment_status = 'all';
252 
253 $comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : '';
254@@ -102,26 +102,29 @@
255 </h2>
256 
257 <?php
258-if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) {
259+if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['destroyed'] ) || isset( $_GET['spam'] ) ) {
260        $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
261        $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
262+       $destroyed = isset( $_GET['destroyed'] ) ? (int) $_GET['destroyed'] : 0;
263        $spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0;
264 
265-       if ( $approved > 0 || $deleted > 0 || $spam > 0 ) {
266+       if ( $approved > 0 || $deleted > 0 || $destroyed > 0 || $spam > 0 ) {
267                echo '<div id="moderated" class="updated fade"><p>';
268 
269                if ( $approved > 0 ) {
270                        printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
271                        echo '<br />';
272                }
273-
274+               if ( $spam > 0 ) {
275+                       printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
276+                       echo '<br />';
277+               }
278                if ( $deleted > 0 ) {
279                        printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
280                        echo '<br />';
281                }
282-
283-               if ( $spam > 0 ) {
284-                       printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
285+               if ( $destroyed > 0 ) {
286+                       printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $destroyed ), $destroyed );
287                        echo '<br />';
288                }
289 
290@@ -139,9 +142,10 @@
291 //, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
292 $stati = array(
293                'all' => _n_noop('All', 'All'), // singular not used
294-               'moderated' => _n_noop('Pending (<span class="pending-count">%s</span>)', 'Pending (<span class="pending-count">%s</span>)'),
295+               'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'),
296                'approved' => _n_noop('Approved', 'Approved'), // singular not used
297-               'spam' => _n_noop('Spam (<span class="spam-count">%s</span>)', 'Spam (<span class="spam-count">%s</span>)')
298+               'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'),
299+               'deleted' => _n_noop('Deleted <span class="count">(<span class="deleted-count">%s</span>)</span>', 'Deleted <span class="count">(<span class="deleted-count">%s</span>)</span>')
300        );
301 $link = 'edit-comments.php';
302 if ( !empty($comment_type) && 'all' != $comment_type )
303@@ -246,13 +250,17 @@
304 <?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
305 <option value="unapprove"><?php _e('Unapprove'); ?></option>
306 <?php endif; ?>
307-<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
308+<?php if ( 'approved' != $comment_status ): ?>
309 <option value="approve"><?php _e('Approve'); ?></option>
310 <?php endif; ?>
311 <?php if ( 'spam' != $comment_status ): ?>
312 <option value="markspam"><?php _e('Mark as Spam'); ?></option>
313 <?php endif; ?>
314+<?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
315+<option value="destroy"><?php _e('Delete Permanently'); ?></option>
316+<?php else: ?>
317 <option value="delete"><?php _e('Delete'); ?></option>
318+<?php endif; ?>
319 </select>
320 <input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
321 <?php wp_nonce_field('bulk-comments'); ?>
322@@ -278,11 +286,11 @@
323        <input type="hidden" name="apage" value="<?php echo esc_attr( absint( $_GET['apage'] ) ); ?>" />
324 <?php }
325 
326-if ( 'spam' == $comment_status ) {
327-       wp_nonce_field('bulk-spam-delete', '_spam_nonce');
328+if ( 'spam' == $comment_status || 'deleted' == $comment_status ) {
329+       wp_nonce_field('bulk-destroy', '_destroy_nonce');
330         if ( current_user_can ('moderate_comments')) { ?>
331-               <input type="submit" name="delete_all_spam" value="<?php esc_attr_e('Delete All Spam'); ?>" class="button-secondary apply" />
332-<?php  }
333+               <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
334+<?php }
335 } ?>
336 <?php do_action('manage_comments_nav', $comment_status); ?>
337 </div>
338@@ -333,18 +341,22 @@
339 <?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
340 <option value="unapprove"><?php _e('Unapprove'); ?></option>
341 <?php endif; ?>
342-<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
343+<?php if ( 'approved' != $comment_status ): ?>
344 <option value="approve"><?php _e('Approve'); ?></option>
345 <?php endif; ?>
346 <?php if ( 'spam' != $comment_status ): ?>
347 <option value="markspam"><?php _e('Mark as Spam'); ?></option>
348 <?php endif; ?>
349+<?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
350+<option value="destroy"><?php _e('Delete Permanently'); ?></option>
351+<?php else: ?>
352 <option value="delete"><?php _e('Delete'); ?></option>
353+<?php endif; ?>
354 </select>
355 <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
356 
357-<?php if ( 'spam' == $comment_status ) { ?>
358-<input type="submit" name="delete_all_spam2" value="<?php esc_attr_e('Delete All Spam'); ?>" class="button-secondary apply" />
359+<?php if ( 'spam' == $comment_status || 'deleted' == $comment_status ) { ?>
360+<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
361 <?php } ?>
362 <?php do_action('manage_comments_nav', $comment_status); ?>
363 </div>
364Index: wp-admin/admin-ajax.php
365===================================================================
366--- wp-admin/admin-ajax.php     (revision 11710)
367+++ wp-admin/admin-ajax.php     (working copy)
368@@ -192,7 +192,7 @@
369                        die( (string) time() );
370                $r = wp_set_comment_status( $comment->comment_ID, 'spam' );
371        } else {
372-               $r = wp_delete_comment( $comment->comment_ID );
373+               $r = wp_set_comment_status( $comment->comment_ID, 'delete' );
374        }
375        if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
376                _wp_ajax_delete_comment_response( $comment->comment_ID );
377@@ -336,7 +336,7 @@
378                die( (string) time() );
379 
380        $r = 0;
381-       if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {
382+       if ( in_array( $current, array( 'unapproved', 'spam', 'deleted' ) ) ) {
383                check_ajax_referer( "approve-comment_$id" );
384                $result = wp_set_comment_status( $comment->comment_ID, 'approve', true );
385        } else {
386Index: wp-admin/wp-admin.css
387===================================================================
388--- wp-admin/wp-admin.css       (revision 11710)
389+++ wp-admin/wp-admin.css       (working copy)
390@@ -444,7 +444,7 @@
391        display: none;
392 }
393 
394-.unapproved .approve, .spam .approve {
395+.unapproved .approve, .spam .approve, .deleted .approve {
396        display: inline;
397 }
398 
399Index: wp-admin/includes/template.php
400===================================================================
401--- wp-admin/includes/template.php      (revision 11710)
402+++ wp-admin/includes/template.php      (working copy)
403@@ -2009,6 +2009,9 @@
404        } elseif ( 'spam' == $status ) {
405                $approved = "comment_approved = 'spam'";
406                $total = $count->spam;
407+       } elseif ( 'deleted' == $status ) {
408+               $approved = "comment_approved = 'deleted'";
409+               $total = $count->deleted;
410        } else {
411                $approved = "( comment_approved = '0' OR comment_approved = '1' )";
412                $total = $count->moderated + $count->approved;
413@@ -2148,10 +2151,13 @@
414                                        }
415                                        if ( 'spam' != $the_comment_status )
416                                                $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>';
417-                                       $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
418+                                       if ( 'deleted' == $the_comment_status || 'spam' == $the_comment_status )
419+                                               $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::deleted=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
420+                                       else
421+                                               $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
422                                        $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
423                                        $actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick&nbsp;Edit') . '</a>';
424-                                       if ( 'spam' != $the_comment_status )
425+                                       if ( 'spam' != $the_comment_status && 'deleted' != $the_comment_status )
426                                                $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
427 
428                                        $actions = apply_filters( 'comment_row_actions', $actions, $comment );
429Index: wp-admin/js/common.dev.js
430===================================================================
431--- wp-admin/js/common.dev.js   (revision 11710)
432+++ wp-admin/js/common.dev.js   (working copy)
433@@ -156,10 +156,13 @@
434 
435        // show warnings
436        $('#doaction, #doaction2').click(function(){
437-               if ( $('select[name="action"]').val() == 'delete' || $('select[name="action2"]').val() == 'delete' ) {
438+               if ( $('select[name="action"]').val() == 'destroy' || $('select[name="action2"]').val() == 'destroy' ) {
439                        return showNotice.warn();
440                }
441        });
442+       $('#destroy_all, #destroy_all2').click(function(){
443+               return showNotice.warn();
444+       });
445 
446        // screen settings tab
447        $('#show-settings-link').click(function () {
448Index: wp-admin/js/edit-comments.dev.js
449===================================================================
450--- wp-admin/js/edit-comments.dev.js    (revision 11710)
451+++ wp-admin/js/edit-comments.dev.js    (working copy)
452@@ -38,7 +38,7 @@
453                settings.data._page = pageInput.val();
454                settings.data._url = document.location.href;
455 
456-               if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && !settings.data.spam )
457+               if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && settings.data.deleted)
458                        return showNotice.warn() ? settings : false;
459 
460                return settings;
461@@ -91,7 +91,7 @@
462                        if ( isNaN(n) ) return;
463                        if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
464                                n = n + 1;
465-                       } else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam
466+                       } else if ( $('#' + settings.element).is('.spam') ) { // we approved, deleted, or destroyed a comment marked as spam
467                                n = n - 1;
468                        }
469                        if ( n < 0 ) { n = 0; }
470@@ -101,7 +101,26 @@
471                        a.html(n);
472                });
473 
474+               $('span.deleted-count').each( function() {
475+                       var a = $(this), n;
476+                       n = a.html().replace(/[ ,.]+/g, '');
477+                       n = parseInt(n,10);
478+                       if ( isNaN(n) ) return;
479+                       if ( $(settings.target).parents( 'span.delete' ).size() && $('#' + settings.element).is('.deleted,.spam') ) { // we destroyed a deleted or spam comment
480+                               n--;
481+                       } else if ( $(settings.target).parents( 'span.delete' ).size() ) { // we deleted a comment
482+                               n++;
483+                       } else if ( $('#' + settings.element).is('.deleted') ) { // we approved or spammed a deleted comment
484+                               n--;
485+                       }
486+                       if ( n < 0 ) { n = 0; }
487+                       n = n.toString();
488+                       if ( n.length > 3 )
489+                               n = n.substr(0, n.length-3)+' '+n.substr(-3);
490+                       a.html(n);
491+               });
492 
493+
494                // XML response
495                if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {
496                        // Set the total to the known good value (even if this value is a little old, newer values should only be a few less, and so shouldn't mess up the page links)
497Index: wp-admin/edit-form-comment.php
498===================================================================
499--- wp-admin/edit-form-comment.php      (revision 11710)
500+++ wp-admin/edit-form-comment.php      (working copy)
501@@ -38,19 +38,24 @@
502 <div class="submitbox" id="submitcomment">
503 <div id="minor-publishing">
504 
505+<?php if ($comment->comment_approved == '1') { ?>
506 <div id="minor-publishing-actions">
507 <div id="preview-action">
508 <a class="preview button" href="<?php echo get_comment_link(); ?>" target="_blank"><?php _e('View Comment'); ?></a>
509 </div>
510 <div class="clear"></div>
511 </div>
512+<?php } ?>
513 
514 <div id="misc-publishing-actions">
515 
516 <div class="misc-pub-section" id="comment-status-radio">
517 <label class="approved"><input type="radio"<?php checked( $comment->comment_approved, '1' ); ?> name="comment_status" value="1" /><?php /* translators: comment type radio button */ echo _x('Approved', 'adjective') ?></label><br />
518 <label class="waiting"><input type="radio"<?php checked( $comment->comment_approved, '0' ); ?> name="comment_status" value="0" /><?php /* translators: comment type radio button */ echo _x('Pending', 'adjective') ?></label><br />
519-<label class="spam"><input type="radio"<?php checked( $comment->comment_approved, 'spam' ); ?> name="comment_status" value="spam" /><?php /* translators: comment type radio button */ echo _x('Spam', 'adjective'); ?></label>
520+<label class="spam"><input type="radio"<?php checked( $comment->comment_approved, 'spam' ); ?> name="comment_status" value="spam" /><?php /* translators: comment type radio button */ echo _x('Spam', 'adjective'); ?></label><br />
521+<?php if ($comment->comment_approved == 'deleted') { ?>
522+<label class="deleted"><input type="radio"<?php checked( $comment->comment_approved, 'deleted' ); ?> name="comment_status" value="deleted" /><?php /* translators: comment type radio button */ echo _x('Deleted', 'adjective'); ?></label>
523+<?php } ?>
524 </div>
525 
526 <div class="misc-pub-section curtime misc-pub-section-last">
527@@ -69,7 +74,12 @@
528 
529 <div id="major-publishing-actions">
530 <div id="delete-action">
531-<?php echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=deletecomment&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "' onclick=\"if ( confirm('" . esc_js(__("You are about to delete this comment. \n  'Cancel' to stop, 'OK' to delete.")) . "') ){return true;}return false;\">" . __('Delete') . "</a>\n"; ?>
532+<?php
533+if ($comment->comment_approved == 'deleted')
534+       echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=deletecomment&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "' onclick=\"if ( confirm('" . esc_js(__("You are about to delete this comment. \n  'Cancel' to stop, 'OK' to delete.")) . "') ){return true;}return false;\">" . __('Delete Permanently') . "</a>\n";
535+else
536+       echo "<a class='submitdelete deletion' href='" . wp_nonce_url("comment.php?action=deletecomment&amp;c=$comment->comment_ID&amp;_wp_original_http_referer=" . urlencode(wp_get_referer()), 'delete-comment_' . $comment->comment_ID) . "'>" . __('Delete') . "</a>\n";
537+?>
538 </div>
539 <div id="publishing-action">
540 <input type="submit" name="save" value="<?php esc_attr_e('Update Comment'); ?>" tabindex="4" class="button-primary" />
541Index: wp-admin/css/colors-fresh.css
542===================================================================
543--- wp-admin/css/colors-fresh.css       (revision 11710)
544+++ wp-admin/css/colors-fresh.css       (working copy)
545@@ -58,7 +58,8 @@
546        border-color: #ccc;
547 }
548 
549-#poststuff .inside label.spam {
550+#poststuff .inside label.spam,
551+#poststuff .inside label.deleted {
552        color: red;
553 }
554 
555Index: wp-admin/css/colors-classic.css
556===================================================================
557--- wp-admin/css/colors-classic.css     (revision 11710)
558+++ wp-admin/css/colors-classic.css     (working copy)
559@@ -58,7 +58,8 @@
560        border-color: #ccc;
561 }
562 
563-#poststuff .inside label.spam {
564+#poststuff .inside label.spam,
565+#poststuff .inside label.deleted {
566        color: red;
567 }
568