"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:
parent
19b743e7e2
commit
d2fec31c0e
|
@ -192,7 +192,7 @@ case 'delete-comment' : // On success, die with time() instead of 1
|
|||
die( (string) time() );
|
||||
$r = wp_set_comment_status( $comment->comment_ID, 'spam' );
|
||||
} 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
|
||||
_wp_ajax_delete_comment_response( $comment->comment_ID );
|
||||
|
|
|
@ -44,6 +44,9 @@ case 'editcomment' :
|
|||
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
|
||||
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 );
|
||||
|
||||
include('edit-form-comment.php');
|
||||
|
|
|
@ -58,7 +58,8 @@ div.dashboard-widget,
|
|||
border-color: #ccc;
|
||||
}
|
||||
|
||||
#poststuff .inside label.spam {
|
||||
#poststuff .inside label.spam,
|
||||
#poststuff .inside label.deleted {
|
||||
color: red;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,8 @@ div.dashboard-widget,
|
|||
border-color: #ccc;
|
||||
}
|
||||
|
||||
#poststuff .inside label.spam {
|
||||
#poststuff .inside label.spam,
|
||||
#poststuff .inside label.deleted {
|
||||
color: red;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,40 +14,28 @@ enqueue_comment_hotkeys_js();
|
|||
|
||||
$post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
|
||||
|
||||
if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spam2'] ) ) && !empty( $_REQUEST['pagegen_timestamp'] ) ) {
|
||||
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'] ) ) {
|
||||
if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2']) ) {
|
||||
check_admin_referer('bulk-comments');
|
||||
$doaction = ( -1 != $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2'];
|
||||
|
||||
$deleted = $approved = $unapproved = $spammed = 0;
|
||||
foreach ( (array) $_REQUEST['delete_comments'] as $comment_id) : // Check the permissions on each
|
||||
$comment_id = (int) $comment_id;
|
||||
|
||||
if ((isset($_REQUEST['destroy_all']) || isset($_REQUEST['destroy_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) {
|
||||
$comment_status = $wpdb->escape($_REQUEST['comment_status']);
|
||||
$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) );
|
||||
|
||||
if ( !current_user_can('edit_post', $_post_id) )
|
||||
continue;
|
||||
|
||||
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' :
|
||||
wp_set_comment_status($comment_id, 'approve');
|
||||
$approved++;
|
||||
|
@ -56,10 +44,22 @@ if ( ( isset( $_REQUEST['delete_all_spam'] ) || isset( $_REQUEST['delete_all_spa
|
|||
wp_set_comment_status($comment_id, 'hold');
|
||||
$unapproved++;
|
||||
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 )
|
||||
$redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
|
||||
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']);
|
||||
|
||||
$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_type = !empty($_GET['comment_type']) ? esc_attr($_GET['comment_type']) : '';
|
||||
|
@ -102,26 +102,29 @@ if ( isset($_GET['s']) && $_GET['s'] )
|
|||
</h2>
|
||||
|
||||
<?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;
|
||||
$deleted = isset( $_GET['deleted'] ) ? (int) $_GET['deleted'] : 0;
|
||||
$destroyed = isset( $_GET['destroyed'] ) ? (int) $_GET['destroyed'] : 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>';
|
||||
|
||||
if ( $approved > 0 ) {
|
||||
printf( _n( '%s comment approved', '%s comments approved', $approved ), $approved );
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
if ( $spam > 0 ) {
|
||||
printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
|
||||
echo '<br />';
|
||||
}
|
||||
if ( $deleted > 0 ) {
|
||||
printf( _n( '%s comment deleted', '%s comments deleted', $deleted ), $deleted );
|
||||
echo '<br />';
|
||||
}
|
||||
|
||||
if ( $spam > 0 ) {
|
||||
printf( _n( '%s comment marked as spam', '%s comments marked as spam', $spam ), $spam );
|
||||
if ( $destroyed > 0 ) {
|
||||
printf( _n( '%s comment permanently deleted', '%s comments permanently deleted', $destroyed ), $destroyed );
|
||||
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>")
|
||||
$stati = array(
|
||||
'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
|
||||
'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';
|
||||
if ( !empty($comment_type) && 'all' != $comment_type )
|
||||
|
@ -246,13 +250,17 @@ $page_links = paginate_links( array(
|
|||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
|
||||
<option value="unapprove"><?php _e('Unapprove'); ?></option>
|
||||
<?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>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'spam' != $comment_status ): ?>
|
||||
<option value="markspam"><?php _e('Mark as Spam'); ?></option>
|
||||
<?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>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
|
||||
<?php wp_nonce_field('bulk-comments'); ?>
|
||||
|
@ -278,11 +286,11 @@ $page_links = paginate_links( array(
|
|||
<input type="hidden" name="apage" value="<?php echo esc_attr( absint( $_GET['apage'] ) ); ?>" />
|
||||
<?php }
|
||||
|
||||
if ( 'spam' == $comment_status ) {
|
||||
wp_nonce_field('bulk-spam-delete', '_spam_nonce');
|
||||
if ( 'spam' == $comment_status || 'deleted' == $comment_status ) {
|
||||
wp_nonce_field('bulk-destroy', '_destroy_nonce');
|
||||
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" />
|
||||
<?php }
|
||||
<input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
|
||||
<?php }
|
||||
} ?>
|
||||
<?php do_action('manage_comments_nav', $comment_status); ?>
|
||||
</div>
|
||||
|
@ -333,18 +341,22 @@ if ( $page_links )
|
|||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
|
||||
<option value="unapprove"><?php _e('Unapprove'); ?></option>
|
||||
<?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>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'spam' != $comment_status ): ?>
|
||||
<option value="markspam"><?php _e('Mark as Spam'); ?></option>
|
||||
<?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>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
|
||||
|
||||
<?php if ( 'spam' == $comment_status ) { ?>
|
||||
<input type="submit" name="delete_all_spam2" value="<?php esc_attr_e('Delete All Spam'); ?>" class="button-secondary apply" />
|
||||
<?php if ( 'spam' == $comment_status || 'deleted' == $comment_status ) { ?>
|
||||
<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
<?php do_action('manage_comments_nav', $comment_status); ?>
|
||||
</div>
|
||||
|
|
|
@ -2009,6 +2009,9 @@ function _wp_get_comment_list( $status = '', $s = false, $start, $num, $post = 0
|
|||
} elseif ( 'spam' == $status ) {
|
||||
$approved = "comment_approved = 'spam'";
|
||||
$total = $count->spam;
|
||||
} elseif ( 'deleted' == $status ) {
|
||||
$approved = "comment_approved = 'deleted'";
|
||||
$total = $count->deleted;
|
||||
} else {
|
||||
$approved = "( comment_approved = '0' OR comment_approved = '1' )";
|
||||
$total = $count->moderated + $count->approved;
|
||||
|
@ -2135,24 +2138,36 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
|
|||
$actions = array();
|
||||
|
||||
if ( $user_can ) {
|
||||
$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>';
|
||||
if ( $comment_status && 'all' != $comment_status ) { // not looking at all comments
|
||||
if ( 'approved' == $the_comment_status ) {
|
||||
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
unset($actions['approve']);
|
||||
} else {
|
||||
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
unset($actions['unapprove']);
|
||||
if ( 'deleted' == $the_comment_status ) {
|
||||
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&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['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 ( 'approved' == $the_comment_status ) {
|
||||
$actions['unapprove'] = "<a href='$unapprove_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
|
||||
unset($actions['approve']);
|
||||
} else {
|
||||
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
unset($actions['unapprove']);
|
||||
}
|
||||
}
|
||||
|
||||
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['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&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 Edit') . '</a>';
|
||||
|
||||
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>';
|
||||
}
|
||||
if ( 'spam' != $the_comment_status )
|
||||
$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['edit'] = "<a href='comment.php?action=editcomment&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 Edit') . '</a>';
|
||||
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 = apply_filters( 'comment_row_actions', $actions, $comment );
|
||||
|
||||
|
|
|
@ -156,10 +156,13 @@ jQuery(document).ready( function($) {
|
|||
|
||||
// show warnings
|
||||
$('#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();
|
||||
}
|
||||
});
|
||||
$('#destroy_all, #destroy_all2').click(function(){
|
||||
return showNotice.warn();
|
||||
});
|
||||
|
||||
// screen settings tab
|
||||
$('#show-settings-link').click(function () {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -38,7 +38,7 @@ setCommentsList = function() {
|
|||
settings.data._page = pageInput.val();
|
||||
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 settings;
|
||||
|
@ -91,7 +91,7 @@ setCommentsList = function() {
|
|||
if ( isNaN(n) ) return;
|
||||
if ( $(settings.target).parents( 'span.spam' ).size() ) { // we marked a comment as spam
|
||||
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;
|
||||
}
|
||||
if ( n < 0 ) { n = 0; }
|
||||
|
@ -101,6 +101,25 @@ setCommentsList = function() {
|
|||
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
|
||||
if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -444,7 +444,7 @@ a.button-secondary {
|
|||
display: none;
|
||||
}
|
||||
|
||||
.unapproved .approve, .spam .approve {
|
||||
.unapproved .approve, .spam .approve, .deleted .approve {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,6 +208,8 @@ function get_comments( $args = '' ) {
|
|||
$approved = "comment_approved = '1'";
|
||||
elseif ( 'spam' == $status )
|
||||
$approved = "comment_approved = 'spam'";
|
||||
elseif ( 'deleted' == $status )
|
||||
$approved = "comment_approved = 'deleted'";
|
||||
else
|
||||
$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 );
|
||||
|
||||
$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 );
|
||||
foreach( (array) $count as $row_num => $row ) {
|
||||
$total += $row['num_comments'];
|
||||
|
@ -735,8 +737,13 @@ function wp_count_comments( $post_id = 0 ) {
|
|||
* @return bool False if delete comment query failure, true on success.
|
||||
*/
|
||||
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;
|
||||
do_action('delete_comment', $comment_id);
|
||||
|
||||
wp_unschedule_comment_destruction($comment_id);
|
||||
|
||||
$comment = get_comment($comment_id);
|
||||
|
||||
|
@ -784,6 +791,8 @@ function wp_get_comment_status($comment_id) {
|
|||
return 'unapproved';
|
||||
elseif ( $approved == 'spam' )
|
||||
return 'spam';
|
||||
elseif ( $approved == 'deleted' )
|
||||
return 'deleted';
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
@ -1028,7 +1037,8 @@ function wp_new_comment( $commentdata ) {
|
|||
*/
|
||||
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
|
||||
global $wpdb;
|
||||
|
||||
wp_unschedule_comment_destruction($comment_id);
|
||||
|
||||
$status = '0';
|
||||
switch ( $comment_status ) {
|
||||
case 'hold':
|
||||
|
@ -1045,7 +1055,10 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
|
|||
$status = 'spam';
|
||||
break;
|
||||
case 'delete':
|
||||
return wp_delete_comment($comment_id);
|
||||
if (wp_get_comment_status($comment_id) == 'deleted' || wp_get_comment_status($comment_id) == 'spam')
|
||||
return wp_delete_comment($comment_id);
|
||||
$status = 'deleted';
|
||||
wp_schedule_comment_destruction($comment_id);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
@ -1070,6 +1083,42 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -1767,4 +1767,32 @@ function wp_text_diff( $left_string, $right_string, $args = null ) {
|
|||
}
|
||||
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');
|
||||
|
||||
|
||||
|
|
|
@ -60,10 +60,10 @@ function wp_default_scripts( &$scripts ) {
|
|||
|
||||
$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->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){};'
|
||||
) );
|
||||
|
||||
|
@ -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_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->localize( 'admin-comments', 'adminCommentsL10n', array(
|
||||
'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' );
|
||||
|
||||
// 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( 'ie', '/wp-admin/css/ie.css', array(), '20090630' );
|
||||
|
|
Loading…
Reference in New Issue