Ticket #4529: delete-comment.3.diff
File delete-comment.3.diff, 8.1 KB (added by , 16 years ago) |
---|
-
wp-admin/edit-comments.php
122 122 $stati = array( 123 123 '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>"), 124 124 'approved' => _c('Approved|plural'), 125 '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>") 125 '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>"), 126 '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>") 126 127 ); 127 128 $class = ( '' === $comment_status ) ? ' class="current"' : ''; 128 129 $status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('Show All Comments')."</a>"; … … 184 185 <?php if ( empty($comment_status) || 'approved' == $comment_status ): ?> 185 186 <option value="unapprove"><?php _e('Unapprove'); ?></option> 186 187 <?php endif; ?> 187 <?php if ( empty($comment_status) || ' moderated' == $comment_status ): ?>188 <?php if ( empty($comment_status) || 'approved' != $comment_status ): ?> 188 189 <option value="approve"><?php _e('Approve'); ?></option> 189 190 <?php endif; ?> 190 <?php if ( 'spam' != $comment_status ): ?>191 <?php if ( 'spam' != $comment_status && 'deleted' != $comment_status ): ?> 191 192 <option value="markspam"><?php _e('Mark as Spam'); ?></option> 192 193 <?php endif; ?> 194 <?php if ( 'deleted' != $comment_status ): ?> 193 195 <option value="delete"><?php _e('Delete'); ?></option> 196 <?php else : ?> 197 <option value="delete"><?php _e('Delete Permenantly'); ?></option> 198 <?php endif; ?> 194 199 </select> 195 200 <input type="submit" name="doaction" id="doaction" value="<?php _e('Apply'); ?>" class="button-secondary apply" /> 196 201 <?php wp_nonce_field('bulk-comments'); ?> -
wp-admin/admin-ajax.php
183 183 if ( $_POST['new'] == $current ) 184 184 die('1'); 185 185 186 if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) {186 if ( in_array( $current, array( 'unapproved', 'spam', 'deleted' ) ) ) { 187 187 check_ajax_referer( "approve-comment_$id" ); 188 188 if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) 189 189 die('1'); -
wp-admin/wp-admin.css
258 258 display: none; 259 259 } 260 260 261 .unapproved .approve, .spam .approve {261 .unapproved .approve, .spam .approve, .deleted .approve { 262 262 display: inline; 263 263 } 264 264 -
wp-admin/includes/template.php
1542 1542 $approved = "comment_approved = '1'"; 1543 1543 elseif ( 'spam' == $status ) 1544 1544 $approved = "comment_approved = 'spam'"; 1545 elseif ( 'deleted' == $status ) 1546 $approved = "comment_approved = 'deleted'"; 1545 1547 else 1546 1548 $approved = "( comment_approved = '0' OR comment_approved = '1' )"; 1547 1549 … … 1642 1644 } 1643 1645 if ( 'spam' != $the_comment_status ) 1644 1646 $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>'; 1645 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>'; 1647 if ( 'deleted' == $the_comment_status ) 1648 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; 1649 else 1650 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>'; 1646 1651 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; 1647 1652 if ( 'spam' != $the_comment_status ) 1648 1653 $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>'; -
wp-admin/js/edit-comments.js
67 67 if ( n < 0 ) { n = 0; } 68 68 a.html( n.toString() ); 69 69 }); 70 $('li span.deleted-comment-count' ).each( function() { 71 var a = $(this); 72 var n = parseInt(a.html(),10); 73 if ( $(settings.target).parents( 'span.delete' ).size() && !$('#' + settings.element).is('.deleted') ) { // we deleted a comment 74 n = n + 1; 75 } else if ( $('#' + settings.element).is('.deleted') ) { // we approved or deleted a deleted comment 76 n = n - 1; 77 } 78 if ( n < 0 ) { n = 0; } 79 a.html( n.toString() ); 80 }); 70 81 71 82 if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { 72 83 return; -
wp-includes/comment.php
568 568 569 569 $total = 0; 570 570 $stats = array( ); 571 $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam' );571 $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted'); 572 572 foreach( (array) $count as $row_num => $row ) { 573 573 $total += $row['num_comments']; 574 574 $stats[$approved[$row['comment_approved']]] = $row['num_comments']; … … 605 605 do_action('delete_comment', $comment_id); 606 606 607 607 $comment = get_comment($comment_id); 608 609 if ($comment->comment_approved == 'deleted' && $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id))) { 610 return true; 611 } 612 else if ($wpdb->query($wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='deleted' WHERE comment_ID = %d LIMIT 1", $comment_id))) { 613 wp_schedule_single_event(time()+(60*60*24*30), 'wp_delete_comment', array($comment_id)); 614 return true; 615 } 616 else return false; 608 617 609 if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )610 return false;611 612 618 $post_id = $comment->comment_post_ID; 613 619 if ( $post_id && $comment->comment_approved == 1 ) 614 620 wp_update_comment_count($post_id); … … 618 624 do_action('wp_set_comment_status', $comment_id, 'delete'); 619 625 return true; 620 626 } 627 add_action('wp_delete_comment','wp_delete_comment'); // Needed for scheduled deletion using wp_cron. 621 628 622 629 /** 623 630 * The status of a comment by ID. … … 642 649 return 'unapproved'; 643 650 elseif ( $approved == 'spam' ) 644 651 return 'spam'; 652 elseif ( $approved == 'deleted' ) 653 return 'deleted'; 645 654 else 646 655 return false; 647 656 } … … 839 848 */ 840 849 function wp_set_comment_status($comment_id, $comment_status) { 841 850 global $wpdb; 842 851 843 852 switch ( $comment_status ) { 844 853 case 'hold': 845 854 $query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID = %d LIMIT 1", $comment_id); … … 850 859 $comment = get_comment($comment_id); 851 860 wp_notify_postauthor($comment_id, $comment->comment_type); 852 861 } 862 wp_unschedule_event(wp_next_scheduled('wp_delete_comment', array($comment_id)), 'wp_delete_comment', array($comment_id)); // Unschedule comment for deletion, if scheduled 853 863 break; 854 864 case 'spam': 855 865 $query = $wpdb->prepare("UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID = %d LIMIT 1", $comment_id);