"Trash" status for comments, first run, props caesarsgrunt, see #4529

git-svn-id: http://svn.automattic.com/wordpress/trunk@11731 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-07-21 03:11:12 +00:00
parent 19b743e7e2
commit d2fec31c0e
14 changed files with 211 additions and 80 deletions

View File

@ -192,7 +192,7 @@ case 'delete-comment' : // On success, die with time() instead of 1
die( (string) time() ); die( (string) time() );
$r = wp_set_comment_status( $comment->comment_ID, 'spam' ); $r = wp_set_comment_status( $comment->comment_ID, 'spam' );
} else { } else {
$r = wp_delete_comment( $comment->comment_ID ); $r = wp_set_comment_status( $comment->comment_ID, 'delete' );
} }
if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts
_wp_ajax_delete_comment_response( $comment->comment_ID ); _wp_ajax_delete_comment_response( $comment->comment_ID );

View File

@ -44,6 +44,9 @@ case 'editcomment' :
if ( !current_user_can('edit_post', $comment->comment_post_ID) ) if ( !current_user_can('edit_post', $comment->comment_post_ID) )
comment_footer_die( __('You are not allowed to edit comments on this post.') ); comment_footer_die( __('You are not allowed to edit comments on this post.') );
if ( 'deleted' == $comment->comment_status )
comment_footer_die( __('This comment has been deleted. Please move it out of the Trash if you want to edit it.') );
$comment = get_comment_to_edit( $comment_id ); $comment = get_comment_to_edit( $comment_id );
include('edit-form-comment.php'); include('edit-form-comment.php');

View File

@ -58,7 +58,8 @@ div.dashboard-widget,
border-color: #ccc; border-color: #ccc;
} }
#poststuff .inside label.spam { #poststuff .inside label.spam,
#poststuff .inside label.deleted {
color: red; color: red;
} }

View File

@ -58,7 +58,8 @@ div.dashboard-widget,
border-color: #ccc; border-color: #ccc;
} }
#poststuff .inside label.spam { #poststuff .inside label.spam,
#poststuff .inside label.deleted {
color: red; color: red;
} }

View File

@ -14,40 +14,28 @@ enqueue_comment_hotkeys_js();
$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; $post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spam2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) { if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2']) ) {
check_admin_referer('bulk-spam-delete', '_spam_nonce');
$delete_time = $wpdb->escape( $_REQUEST['pagegen_timestamp'] );
if ( current_user_can('moderate_comments')) {
$deleted_spam = $wpdb->query( "DELETE FROM $wpdb->comments WHERE comment_approved = 'spam' AND '$delete_time' > comment_date_gmt" );
} else {
$deleted_spam = 0;
}
$redirect_to = 'edit-comments.php?comment_status=spam&deleted=' . (int) $deleted_spam;
if ( $post_id )
$redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
wp_redirect( $redirect_to );
} elseif ( isset($_REQUEST['delete_comments']) && isset($_REQUEST['action']) && ( -1 != $_REQUEST['action'] || -1 != $_REQUEST['action2'] ) ) {
check_admin_referer('bulk-comments'); check_admin_referer('bulk-comments');
$doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
$deleted = $approved = $unapproved = $spammed = 0; if ((isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) {
foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each $comment_status = $wpdb->escape($_REQUEST['comment_status']);
$comment_id = (int) $comment_id; $delete_time = $wpdb->escape($_REQUEST['pagegen_timestamp']);
$comment_ids = $wpdb->get_col( "SELECT comment_ID FROM $wpdb->comments WHERE comment_approved = '$comment_status' AND '$delete_time' > comment_date_gmt" );
$doaction = 'destroy';
} elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) {
$comment_ids = $_REQUEST['delete_comments'];
$doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
} else wp_redirect($_SERVER['HTTP_REFERER']);
$approved = $unapproved = $spammed = $deleted = $destroyed = 0;
foreach ($comment_ids as $comment_id) { // Check the permissions on each
$_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) ); $_post_id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = %d", $comment_id) );
if ( !current_user_can('edit_post', $_post_id) ) if ( !current_user_can('edit_post', $_post_id) )
continue; continue;
switch( $doaction ) { switch( $doaction ) {
case 'markspam' :
wp_set_comment_status($comment_id, 'spam');
$spammed++;
break;
case 'delete' :
wp_set_comment_status($comment_id, 'delete');
$deleted++;
break;
case 'approve' : case 'approve' :
wp_set_comment_status($comment_id, 'approve'); wp_set_comment_status($comment_id, 'approve');
$approved++; $approved++;
@ -56,10 +44,22 @@ if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spa
wp_set_comment_status($comment_id, 'hold'); wp_set_comment_status($comment_id, 'hold');
$unapproved++; $unapproved++;
break; break;
case 'markspam' :
wp_set_comment_status($comment_id, 'spam');
$spammed++;
break;
case 'delete' :
wp_set_comment_status($comment_id, 'delete');
$deleted++;
break;
case 'destroy' :
wp_set_comment_status($comment_id, 'delete');
$destroyed++;
break;
}
} }
endforeach;
$redirect_to = 'edit-comments.php?deleted=' . $deleted . '&approved=' . $approved . '&spam=' . $spammed . '&unapproved=' . $unapproved; $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&deleted=' . $deleted . '&destroyed=' . $destroyed;
if ( $post_id ) if ( $post_id )
$redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to ); $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
if ( isset($_REQUEST['apage']) ) if ( isset($_REQUEST['apage']) )
@ -86,7 +86,7 @@ require_once('admin-header.php');
$mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']); $mode = ( ! isset($_GET['mode']) || empty($_GET['mode']) ) ? 'detail' : esc_attr($_GET['mode']);
$comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all'; $comment_status = isset($_REQUEST['comment_status']) ? $_REQUEST['comment_status'] : 'all';
if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam')) ) if ( !in_array($comment_status, array('all', 'moderated', 'approved', 'spam', 'deleted')) )
$comment_status = 'all'; $comment_status = 'all';
$comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : ''; $comment_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : '';
@ -102,26 +102,29 @@ if ( isset($_GET['s']) && $_GET['s'] )
</h2> </h2>
<?php <?php
if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['spam'] ) ) { if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['destroyed'] ) || isset( $_GET['spam'] ) ) {
$approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0; $approved = isset( $_GET['approved'] ) ? (int) $_GET['approved'] : 0;
$deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0; $deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
$destroyed = isset( $_GET['destroyed'] ) ? (int) $_GET['destroyed'] : 0;
$spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0; $spam = isset( $_GET['spam'] ) ? (int) $_GET['spam'] : 0;
if ( $approved > 0 || $deleted > 0 || $spam > 0 ) { if ( $approved > 0 || $deleted > 0 || $destroyed > 0 || $spam > 0 ) {
echo '<div id="moderated" class="updated fade"><p>'; echo '<div id="moderated" class="updated fade"><p>';
if ( $approved > 0 ) { if ( $approved > 0 ) {
printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved ); printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
echo '<br />'; echo '<br />';
} }
if ( $spam > 0 ) {
printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
echo '<br />';
}
if ( $deleted > 0 ) { if ( $deleted > 0 ) {
printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted ); printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
echo '<br />'; echo '<br />';
} }
if ( $destroyed > 0 ) {
if ( $spam > 0 ) { printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $destroyed ), $destroyed );
printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
echo '<br />'; echo '<br />';
} }
@ -139,9 +142,10 @@ $num_comments = ( $post_id ) ? wp_count_comments( $post_id ) : wp_count_comments
//, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>") //, number_format_i18n($num_comments->spam) ), "<span class='spam-comment-count'>" . number_format_i18n($num_comments->spam) . "</span>")
$stati = array( $stati = array(
'all' => _n_noop('All', 'All'), // singular not used 'all' => _n_noop('All', 'All'), // singular not used
'moderated' => _n_noop('Pending (<span class="pending-count">%s</span>)', 'Pending (<span class="pending-count">%s</span>)'), '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>'),
'approved' => _n_noop('Approved', 'Approved'), // singular not used 'approved' => _n_noop('Approved', 'Approved'), // singular not used
'spam' => _n_noop('Spam (<span class="spam-count">%s</span>)', 'Spam (<span class="spam-count">%s</span>)') '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>'),
'deleted' => _n_noop('Trash <span class="count">(<span class="deleted-count">%s</span>)</span>', 'Trash <span class="count">(<span class="deleted-count">%s</span>)</span>')
); );
$link = 'edit-comments.php'; $link = 'edit-comments.php';
if ( !empty($comment_type) && 'all' != $comment_type ) if ( !empty($comment_type) && 'all' != $comment_type )
@ -246,13 +250,17 @@ $page_links = paginate_links( array(
<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?> <?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
<option value="unapprove"><?php _e('Unapprove'); ?></option> <option value="unapprove"><?php _e('Unapprove'); ?></option>
<?php endif; ?> <?php endif; ?>
<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?> <?php if ( 'approved' != $comment_status ): ?>
<option value="approve"><?php _e('Approve'); ?></option> <option value="approve"><?php _e('Approve'); ?></option>
<?php endif; ?> <?php endif; ?>
<?php if ( 'spam' != $comment_status ): ?> <?php if ( 'spam' != $comment_status ): ?>
<option value="markspam"><?php _e('Mark as Spam'); ?></option> <option value="markspam"><?php _e('Mark as Spam'); ?></option>
<?php endif; ?> <?php endif; ?>
<?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
<option value="destroy"><?php _e('Delete Permanently'); ?></option>
<?php else: ?>
<option value="delete"><?php _e('Delete'); ?></option> <option value="delete"><?php _e('Delete'); ?></option>
<?php endif; ?>
</select> </select>
<input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" /> <input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
<?php wp_nonce_field('bulk-comments'); ?> <?php wp_nonce_field('bulk-comments'); ?>
@ -278,10 +286,10 @@ $page_links = paginate_links( array(
<input type="hidden" name="apage" value="<?php echo esc_attr( absint( $_GET['apage'] ) ); ?>" /> <input type="hidden" name="apage" value="<?php echo esc_attr( absint( $_GET['apage'] ) ); ?>" />
<?php } <?php }
if ( 'spam' == $comment_status ) { if ( 'spam' == $comment_status || 'deleted' == $comment_status ) {
wp_nonce_field('bulk-spam-delete', '_spam_nonce'); wp_nonce_field('bulk-destroy', '_destroy_nonce');
if ( current_user_can ('moderate_comments')) { ?> if ( current_user_can ('moderate_comments')) { ?>
<input type="submit" name="delete_all_spam" value="<?php esc_attr_e('Delete All Spam'); ?>" class="button-secondary apply" /> <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
<?php } <?php }
} ?> } ?>
<?php do_action('manage_comments_nav', $comment_status); ?> <?php do_action('manage_comments_nav', $comment_status); ?>
@ -333,18 +341,22 @@ if ( $page_links )
<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?> <?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
<option value="unapprove"><?php _e('Unapprove'); ?></option> <option value="unapprove"><?php _e('Unapprove'); ?></option>
<?php endif; ?> <?php endif; ?>
<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?> <?php if ( 'approved' != $comment_status ): ?>
<option value="approve"><?php _e('Approve'); ?></option> <option value="approve"><?php _e('Approve'); ?></option>
<?php endif; ?> <?php endif; ?>
<?php if ( 'spam' != $comment_status ): ?> <?php if ( 'spam' != $comment_status ): ?>
<option value="markspam"><?php _e('Mark as Spam'); ?></option> <option value="markspam"><?php _e('Mark as Spam'); ?></option>
<?php endif; ?> <?php endif; ?>
<?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
<option value="destroy"><?php _e('Delete Permanently'); ?></option>
<?php else: ?>
<option value="delete"><?php _e('Delete'); ?></option> <option value="delete"><?php _e('Delete'); ?></option>
<?php endif; ?>
</select> </select>
<input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" /> <input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
<?php if ( 'spam' == $comment_status ) { ?> <?php if ( 'spam' == $comment_status || 'deleted' == $comment_status ) { ?>
<input type="submit" name="delete_all_spam2" value="<?php esc_attr_e('Delete All Spam'); ?>" class="button-secondary apply" /> <input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
<?php } ?> <?php } ?>
<?php do_action('manage_comments_nav', $comment_status); ?> <?php do_action('manage_comments_nav', $comment_status); ?>
</div> </div>

View File

@ -2009,6 +2009,9 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0
} elseif ( 'spam' == $status ) { } elseif ( 'spam' == $status ) {
$approved = "comment_approved = 'spam'"; $approved = "comment_approved = 'spam'";
$total = $count->spam; $total = $count->spam;
} elseif ( 'deleted' == $status ) {
$approved = "comment_approved = 'deleted'";
$total = $count->deleted;
} else { } else {
$approved = "( comment_approved = '0' OR comment_approved = '1' )"; $approved = "( comment_approved = '0' OR comment_approved = '1' )";
$total = $count->moderated + $count->approved; $total = $count->moderated + $count->approved;
@ -2135,8 +2138,13 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
$actions = array(); $actions = array();
if ( $user_can ) { if ( $user_can ) {
if ( 'deleted' == $the_comment_status ) {
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . __( 'Return this comment to Unapproved status' ) . "'>" . __( 'Return to Pending' ) . '</a>';
$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>';
} else {
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; $actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
$actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
if ( 'approved' == $the_comment_status ) { if ( 'approved' == $the_comment_status ) {
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; $actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
@ -2146,13 +2154,20 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
unset($actions['unapprove']); unset($actions['unapprove']);
} }
} }
if ( 'spam' != $the_comment_status )
if ( 'spam' == $the_comment_status ) {
$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>';
} else {
$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>'; $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>';
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>'; $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
}
$actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
$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>'; $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>';
if ( 'spam' != $the_comment_status ) if ( 'spam' != $the_comment_status )
$actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$post->ID.'\');return false;" class="vim-r" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>';
}
$actions = apply_filters( 'comment_row_actions', $actions, $comment ); $actions = apply_filters( 'comment_row_actions', $actions, $comment );

View File

@ -156,10 +156,13 @@ jQuery(document).ready( function($) {
// show warnings // show warnings
$('#doaction, #doaction2').click(function(){ $('#doaction, #doaction2').click(function(){
if ( $('select[name="action"]').val() == 'delete' || $('select[name="action2"]').val() == 'delete' ) { if ( $('select[name="action"]').val() == 'destroy' || $('select[name="action2"]').val() == 'destroy' ) {
return showNotice.warn(); return showNotice.warn();
} }
}); });
$('#destroy_all, #destroy_all2').click(function(){
return showNotice.warn();
});
// screen settings tab // screen settings tab
$('#show-settings-link').click(function () { $('#show-settings-link').click(function () {

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,7 @@ setCommentsList = function() {
settings.data._page = pageInput.val(); settings.data._page = pageInput.val();
settings.data._url = document.location.href; settings.data._url = document.location.href;
if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && !settings.data.spam ) if ( 'undefined' != showNotice && settings.data.action && settings.data.action == 'delete-comment' && settings.data.deleted)
return showNotice.warn() ? settings : false; return showNotice.warn() ? settings : false;
return settings; return settings;
@ -91,7 +91,7 @@ setCommentsList = function() {
if ( isNaN(n) ) return; if ( isNaN(n) ) return;
if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
n = n + 1; n = n + 1;
} else if ( $('#' + settings.element).is('.spam') ) { // we approved or deleted a comment marked as spam } else if ( $('#' + settings.element).is('.spam') ) { // we approved, deleted, or destroyed a comment marked as spam
n = n - 1; n = n - 1;
} }
if ( n < 0 ) { n = 0; } if ( n < 0 ) { n = 0; }
@ -101,6 +101,25 @@ setCommentsList = function() {
a.html(n); a.html(n);
}); });
$('span.deleted-count').each( function() {
var a = $(this), n;
n = a.html().replace(/[ ,.]+/g, '');
n = parseInt(n,10);
if ( isNaN(n) ) return;
if ( $(settings.target).parents( 'span.delete' ).size() && $('#' + settings.element).is('.deleted,.spam') ) { // we destroyed a deleted or spam comment
n--;
} else if ( $(settings.target).parents( 'span.delete' ).size() ) { // we deleted a comment
n++;
} else if ( $('#' + settings.element).is('.deleted') ) { // we approved or spammed a deleted comment
n--;
}
if ( n < 0 ) { n = 0; }
n = n.toString();
if ( n.length > 3 )
n = n.substr(0, n.length-3)+' '+n.substr(-3);
a.html(n);
});
// XML response // XML response
if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) { if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {

File diff suppressed because one or more lines are too long

View File

@ -444,7 +444,7 @@ a.button-secondary {
display: none; display: none;
} }
.unapproved .approve, .spam .approve { .unapproved .approve, .spam .approve, .deleted .approve {
display: inline; display: inline;
} }

View File

@ -208,6 +208,8 @@ function get_comments( $args = '' ) {
$approved = "comment_approved = '1'"; $approved = "comment_approved = '1'";
elseif ( 'spam' == $status ) elseif ( 'spam' == $status )
$approved = "comment_approved = 'spam'"; $approved = "comment_approved = 'spam'";
elseif ( 'deleted' == $status )
$approved = "comment_approved = 'deleted'";
else else
$approved = "( comment_approved = '0' OR comment_approved = '1' )"; $approved = "( comment_approved = '0' OR comment_approved = '1' )";
@ -699,7 +701,7 @@ function wp_count_comments( $post_id = 0 ) {
$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
$total = 0; $total = 0;
$approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam'); $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted');
$known_types = array_keys( $approved ); $known_types = array_keys( $approved );
foreach( (array) $count as $row_num => $row ) { foreach( (array) $count as $row_num => $row ) {
$total += $row['num_comments']; $total += $row['num_comments'];
@ -735,9 +737,14 @@ function wp_count_comments( $post_id = 0 ) {
* @return bool False if delete comment query failure, true on success. * @return bool False if delete comment query failure, true on success.
*/ */
function wp_delete_comment($comment_id) { function wp_delete_comment($comment_id) {
if (wp_get_comment_status($comment_id) != 'deleted' && wp_get_comment_status($comment_id) != 'spam')
return wp_set_comment_status($comment_id, 'delete');
global $wpdb; global $wpdb;
do_action('delete_comment', $comment_id); do_action('delete_comment', $comment_id);
wp_unschedule_comment_destruction($comment_id);
$comment = get_comment($comment_id); $comment = get_comment($comment_id);
if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) ) if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
@ -784,6 +791,8 @@ function wp_get_comment_status($comment_id) {
return 'unapproved'; return 'unapproved';
elseif ( $approved == 'spam' ) elseif ( $approved == 'spam' )
return 'spam'; return 'spam';
elseif ( $approved == 'deleted' )
return 'deleted';
else else
return false; return false;
} }
@ -1028,6 +1037,7 @@ function wp_new_comment( $commentdata ) {
*/ */
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) { function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
global $wpdb; global $wpdb;
wp_unschedule_comment_destruction($comment_id);
$status = '0'; $status = '0';
switch ( $comment_status ) { switch ( $comment_status ) {
@ -1045,7 +1055,10 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
$status = 'spam'; $status = 'spam';
break; break;
case 'delete': case 'delete':
if (wp_get_comment_status($comment_id) == 'deleted' || wp_get_comment_status($comment_id) == 'spam')
return wp_delete_comment($comment_id); return wp_delete_comment($comment_id);
$status = 'deleted';
wp_schedule_comment_destruction($comment_id);
break; break;
default: default:
return false; return false;
@ -1070,6 +1083,42 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
return true; return true;
} }
/**
* Schedules a comment for destruction in 30 days.
*
* @since 2.9.0
*
* @param int $comment_id Comment ID.
* @return void
*/
function wp_schedule_comment_destruction($comment_id) {
$to_destroy = get_option('to_destroy');
if (!is_array($to_destroy))
$to_destroy = array();
$to_destroy['comments'][$comment_id] = time();
update_option('to_destroy', $to_destroy);
}
/**
* Unschedules a comment for destruction.
*
* @since 2.9.0
*
* @param int $comment_id Comment ID.
* @return void
*/
function wp_unschedule_comment_destruction($comment_id) {
$to_destroy = get_option('to_destroy');
if (!is_array($to_destroy))
return;
unset($to_destroy['comments'][$comment_id]);
update_option('to_destroy', $to_destroy);
}
/** /**
* Updates an existing comment in the database. * Updates an existing comment in the database.
* *

View File

@ -1767,4 +1767,32 @@ function wp_text_diff( $left_string, $right_string, $args = null ) {
} }
endif; endif;
?> /**
* Destroys comments which have previously been scheduled for destruction.
* Will do the same for posts, pages, etc in the future.
*
* @access private
* @since 2.9.0
*
* @return void
*/
function _scheduled_destruction() {
$to_destroy = get_option('to_destroy');
if (!is_array($to_destroy))
return;
$deletetimestamp = time()-(60*60*24*30);
foreach ($to_destroy['comments'] as $comment_id => $timestamp) {
if ($timestamp < $deletetimestamp) {
wp_delete_comment($comment_id);
unset($to_destroy['comments'][$comment_id]);
}
}
update_option('to_destroy', $to_destroy);
}
add_action( '_scheduled_destruction', '_scheduled_destruction' );
if ( !wp_next_scheduled('_scheduled_destruction') && !defined('WP_INSTALLING') )
wp_schedule_event(time(), 'daily', '_scheduled_destruction');

View File

@ -60,10 +60,10 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' ); $scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090623' ); $scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090720' );
$scripts->add_data( 'common', 'group', 1 ); $scripts->add_data( 'common', 'group', 1 );
$scripts->localize( 'common', 'commonL10n', array( $scripts->localize( 'common', 'commonL10n', array(
'warnDelete' => __("You are about to delete the selected items.\n 'Cancel' to stop, 'OK' to delete."), 'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete."),
'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};' 'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};'
) ); ) );
@ -245,7 +245,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20090514' ); $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20090514' );
$scripts->add_data( 'user-profile', 'group', 1 ); $scripts->add_data( 'user-profile', 'group', 1 );
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090627' ); $scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090720' );
$scripts->add_data( 'admin-comments', 'group', 1 ); $scripts->add_data( 'admin-comments', 'group', 1 );
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array( $scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']), 'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
@ -426,9 +426,9 @@ function wp_default_styles( &$styles ) {
$rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' ); $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets', 'press-this', 'plugin-install', 'farbtastic' );
// all colors stylesheets need to have the same query strings (cache manifest compat) // all colors stylesheets need to have the same query strings (cache manifest compat)
$colors_version = '20090625'; $colors_version = '20090720';
$styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20090625' ); $styles->add( 'wp-admin', '/wp-admin/wp-admin.css', array(), '20090720' );
$styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' ); $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' );
$styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20090630' ); $styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20090630' );