| 1 | Index: wp-admin/edit-comments.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/edit-comments.php (revision 9027) |
|---|
| 4 | +++ wp-admin/edit-comments.php (working copy) |
|---|
| 5 | @@ -122,7 +122,8 @@ |
|---|
| 6 | $stati = array( |
|---|
| 7 | 'moderated' => sprintf(__ngettext('Awaiting Moderation (%s)', 'Awaiting Moderation (%s)', number_format_i18n($num_comments->moderated) ), "<span class='comment-count'>" . number_format_i18n($num_comments->moderated) . "</span>"), |
|---|
| 8 | 'approved' => _c('Approved|plural'), |
|---|
| 9 | - 'spam' => sprintf(__ngettext('Spam (%s)', 'Spam (%s)', number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>") |
|---|
| 10 | + 'spam' => sprintf(__ngettext('Spam (%s)', 'Spam (%s)', number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>"), |
|---|
| 11 | + 'deleted' => sprintf(__ngettext('Deleted (%s)', 'Deleted (%s)', number_format_i18n($num_comments->deleted) ), "<span class='deleted-comment-count'>" . number_format_i18n($num_comments->deleted) . "</span>") |
|---|
| 12 | ); |
|---|
| 13 | $class = ( '' === $comment_status ) ? ' class="current"' : ''; |
|---|
| 14 | $status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('Show All Comments')."</a>"; |
|---|
| 15 | @@ -184,13 +185,17 @@ |
|---|
| 16 | <?php if ( empty($comment_status) || 'approved' == $comment_status ): ?> |
|---|
| 17 | <option value="unapprove"><?php _e('Unapprove'); ?></option> |
|---|
| 18 | <?php endif; ?> |
|---|
| 19 | -<?php if ( empty($comment_status) || 'moderated' == $comment_status ): ?> |
|---|
| 20 | +<?php if ( empty($comment_status) || 'approved' != $comment_status ): ?> |
|---|
| 21 | <option value="approve"><?php _e('Approve'); ?></option> |
|---|
| 22 | <?php endif; ?> |
|---|
| 23 | -<?php if ( 'spam' != $comment_status ): ?> |
|---|
| 24 | +<?php if ( 'spam' != $comment_status && 'deleted' != $comment_status ): ?> |
|---|
| 25 | <option value="markspam"><?php _e('Mark as Spam'); ?></option> |
|---|
| 26 | <?php endif; ?> |
|---|
| 27 | +<?php if ( 'deleted' != $comment_status ): ?> |
|---|
| 28 | <option value="delete"><?php _e('Delete'); ?></option> |
|---|
| 29 | +<?php else : ?> |
|---|
| 30 | +<option value="delete"><?php _e('Delete Permenantly'); ?></option> |
|---|
| 31 | +<?php endif; ?> |
|---|
| 32 | </select> |
|---|
| 33 | <input type="submit" name="doaction" id="doaction" value="<?php _e('Apply'); ?>" class="button-secondary apply" /> |
|---|
| 34 | <?php wp_nonce_field('bulk-comments'); ?> |
|---|
| 35 | Index: wp-admin/admin-ajax.php |
|---|
| 36 | =================================================================== |
|---|
| 37 | --- wp-admin/admin-ajax.php (revision 9027) |
|---|
| 38 | +++ wp-admin/admin-ajax.php (working copy) |
|---|
| 39 | @@ -183,7 +183,7 @@ |
|---|
| 40 | if ( $_POST['new'] == $current ) |
|---|
| 41 | die('1'); |
|---|
| 42 | |
|---|
| 43 | - if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) { |
|---|
| 44 | + if ( in_array( $current, array( 'unapproved', 'spam', 'deleted' ) ) ) { |
|---|
| 45 | check_ajax_referer( "approve-comment_$id" ); |
|---|
| 46 | if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) |
|---|
| 47 | die('1'); |
|---|
| 48 | Index: wp-admin/wp-admin.css |
|---|
| 49 | =================================================================== |
|---|
| 50 | --- wp-admin/wp-admin.css (revision 9027) |
|---|
| 51 | +++ wp-admin/wp-admin.css (working copy) |
|---|
| 52 | @@ -258,7 +258,7 @@ |
|---|
| 53 | display: none; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | -.unapproved .approve, .spam .approve { |
|---|
| 57 | +.unapproved .approve, .spam .approve, .deleted .approve { |
|---|
| 58 | display: inline; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | Index: wp-admin/includes/template.php |
|---|
| 62 | =================================================================== |
|---|
| 63 | --- wp-admin/includes/template.php (revision 9027) |
|---|
| 64 | +++ wp-admin/includes/template.php (working copy) |
|---|
| 65 | @@ -1542,6 +1542,8 @@ |
|---|
| 66 | $approved = "comment_approved = '1'"; |
|---|
| 67 | elseif ( 'spam' == $status ) |
|---|
| 68 | $approved = "comment_approved = 'spam'"; |
|---|
| 69 | + elseif ( 'deleted' == $status ) |
|---|
| 70 | + $approved = "comment_approved = 'deleted'"; |
|---|
| 71 | else |
|---|
| 72 | $approved = "( comment_approved = '0' OR comment_approved = '1' )"; |
|---|
| 73 | |
|---|
| 74 | @@ -1642,7 +1644,10 @@ |
|---|
| 75 | } |
|---|
| 76 | if ( 'spam' != $the_comment_status ) |
|---|
| 77 | $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' ) . "'>" . __( 'Spam' ) . '</a>'; |
|---|
| 78 | - $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>'; |
|---|
| 79 | + if ( 'deleted' == $the_comment_status ) |
|---|
| 80 | + $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; |
|---|
| 81 | + else |
|---|
| 82 | + $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>'; |
|---|
| 83 | $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; |
|---|
| 84 | if ( 'spam' != $the_comment_status ) |
|---|
| 85 | $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\',this);return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; |
|---|
| 86 | Index: wp-admin/js/edit-comments.js |
|---|
| 87 | =================================================================== |
|---|
| 88 | --- wp-admin/js/edit-comments.js (revision 9027) |
|---|
| 89 | +++ wp-admin/js/edit-comments.js (working copy) |
|---|
| 90 | @@ -67,6 +67,17 @@ |
|---|
| 91 | if ( n < 0 ) { n = 0; } |
|---|
| 92 | a.html( n.toString() ); |
|---|
| 93 | }); |
|---|
| 94 | + $('li span.deleted-comment-count' ).each( function() { |
|---|
| 95 | + var a = $(this); |
|---|
| 96 | + var n = parseInt(a.html(),10); |
|---|
| 97 | + if ( $(settings.target).parents( 'span.delete' ).size() && !$('#' + settings.element).is('.deleted') ) { // we deleted a comment |
|---|
| 98 | + n = n + 1; |
|---|
| 99 | + } else if ( $('#' + settings.element).is('.deleted') ) { // we approved or deleted a deleted comment |
|---|
| 100 | + n = n - 1; |
|---|
| 101 | + } |
|---|
| 102 | + if ( n < 0 ) { n = 0; } |
|---|
| 103 | + a.html( n.toString() ); |
|---|
| 104 | + }); |
|---|
| 105 | |
|---|
| 106 | if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { |
|---|
| 107 | return; |
|---|
| 108 | Index: wp-includes/comment.php |
|---|
| 109 | =================================================================== |
|---|
| 110 | --- wp-includes/comment.php (revision 9027) |
|---|
| 111 | +++ wp-includes/comment.php (working copy) |
|---|
| 112 | @@ -568,7 +568,7 @@ |
|---|
| 113 | |
|---|
| 114 | $total = 0; |
|---|
| 115 | $stats = array( ); |
|---|
| 116 | - $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam'); |
|---|
| 117 | + $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted'); |
|---|
| 118 | foreach( (array) $count as $row_num => $row ) { |
|---|
| 119 | $total += $row['num_comments']; |
|---|
| 120 | $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|---|
| 121 | @@ -605,10 +605,16 @@ |
|---|
| 122 | do_action('delete_comment', $comment_id); |
|---|
| 123 | |
|---|
| 124 | $comment = get_comment($comment_id); |
|---|
| 125 | + |
|---|
| 126 | + if ($comment->comment_approved == 'deleted' && $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id))) { |
|---|
| 127 | + return true; |
|---|
| 128 | + } |
|---|
| 129 | + else if ($wpdb->query($wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='deleted' WHERE comment_ID = %d LIMIT 1", $comment_id))) { |
|---|
| 130 | + wp_schedule_single_event(time()+(60*60*24*30), 'wp_delete_comment', array($comment_id)); |
|---|
| 131 | + return true; |
|---|
| 132 | + } |
|---|
| 133 | + else return false; |
|---|
| 134 | |
|---|
| 135 | - if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) ) |
|---|
| 136 | - return false; |
|---|
| 137 | - |
|---|
| 138 | $post_id = $comment->comment_post_ID; |
|---|
| 139 | if ( $post_id && $comment->comment_approved == 1 ) |
|---|
| 140 | wp_update_comment_count($post_id); |
|---|
| 141 | @@ -618,6 +624,7 @@ |
|---|
| 142 | do_action('wp_set_comment_status', $comment_id, 'delete'); |
|---|
| 143 | return true; |
|---|
| 144 | } |
|---|
| 145 | +add_action('wp_delete_comment','wp_delete_comment'); // Needed for scheduled deletion using wp_cron. |
|---|
| 146 | |
|---|
| 147 | /** |
|---|
| 148 | * The status of a comment by ID. |
|---|
| 149 | @@ -642,6 +649,8 @@ |
|---|
| 150 | return 'unapproved'; |
|---|
| 151 | elseif ( $approved == 'spam' ) |
|---|
| 152 | return 'spam'; |
|---|
| 153 | + elseif ( $approved == 'deleted' ) |
|---|
| 154 | + return 'deleted'; |
|---|
| 155 | else |
|---|
| 156 | return false; |
|---|
| 157 | } |
|---|
| 158 | @@ -839,7 +848,7 @@ |
|---|
| 159 | */ |
|---|
| 160 | function wp_set_comment_status($comment_id, $comment_status) { |
|---|
| 161 | global $wpdb; |
|---|
| 162 | - |
|---|
| 163 | + |
|---|
| 164 | switch ( $comment_status ) { |
|---|
| 165 | case 'hold': |
|---|
| 166 | $query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID = %d LIMIT 1", $comment_id); |
|---|
| 167 | @@ -850,6 +859,7 @@ |
|---|
| 168 | $comment = get_comment($comment_id); |
|---|
| 169 | wp_notify_postauthor($comment_id, $comment->comment_type); |
|---|
| 170 | } |
|---|
| 171 | + wp_unschedule_event(wp_next_scheduled('wp_delete_comment', array($comment_id)), 'wp_delete_comment', array($comment_id)); // Unschedule comment for deletion, if scheduled |
|---|
| 172 | break; |
|---|
| 173 | case 'spam': |
|---|
| 174 | $query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID = %d LIMIT 1", $comment_id); |
|---|