Undo for setting a comment as spam, props caesarsgrunt, fixes #11260, see #4529

git-svn-id: http://svn.automattic.com/wordpress/trunk@12286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-11-27 10:34:09 +00:00
parent e0f5abc2d3
commit fe29434e05
14 changed files with 208 additions and 92 deletions

View File

@ -219,7 +219,11 @@ case 'delete-comment' : // On success, die with time() instead of 1
} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
if ( 'spam' == $status )
die( (string) time() );
$r = wp_set_comment_status( $comment->comment_ID, 'spam' );
$r = wp_spam_comment( $comment->comment_ID );
} elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
if ( 'spam' != $status )
die( (string) time() );
$r = wp_unspam_comment( $comment->comment_ID );
} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
$r = wp_delete_comment( $comment->comment_ID );
} else {

View File

@ -168,6 +168,8 @@ case 'deletecomment' :
case 'trashcomment' :
case 'untrashcomment' :
case 'spamcomment' :
case 'unspamcomment' :
$comment_id = absint( $_REQUEST['c'] );
$noredir = isset($_REQUEST['noredir']);
@ -185,14 +187,25 @@ case 'untrashcomment' :
else
$redir = admin_url('edit-comments.php');
$redir = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $redir );
$redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids'), $redir );
if ( $action == 'trashcomment' ) {
wp_trash_comment($comment_id);
$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
} else {
wp_untrash_comment($comment_id);
$redir = add_query_arg( array('untrashed' => '1'), $redir );
switch ( $action ) {
case 'trashcomment' :
wp_trash_comment($comment_id);
$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
break;
case 'untrashcomment' :
wp_untrash_comment($comment_id);
$redir = add_query_arg( array('untrashed' => '1'), $redir );
break;
case 'spamcomment' :
wp_spam_comment($comment_id);
$redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir );
break;
case 'unspamcomment' :
wp_unspam_comment($comment_id);
$redir = add_query_arg( array('unspammed' => '1'), $redir );
break;
}
wp_redirect( $redir );

File diff suppressed because one or more lines are too long

View File

@ -1685,6 +1685,6 @@ div.widgets-sortables,
opacity: 0.4;
}
#dashboard_recent_comments .trash-undo {
#dashboard_recent_comments div.undo {
border-top-color: #dfdfdf;
}

File diff suppressed because one or more lines are too long

View File

@ -1674,6 +1674,6 @@ div.widgets-sortables,
opacity: 0.4;
}
#dashboard_recent_comments .trash-undo {
#dashboard_recent_comments div.undo {
border-top-color: #dfdfdf;
}

View File

@ -20,20 +20,22 @@ $post_id = isset($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0;
if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2']) ) {
check_admin_referer('bulk-comments');
if ((isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) && !empty($_REQUEST['pagegen_timestamp'])) {
if ( (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_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 = 'delete';
} elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) {
} elseif ( ($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments']) ) {
$comment_ids = $_REQUEST['delete_comments'];
$doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2'];
} elseif ($_REQUEST['action'] == 'untrash' && isset($_REQUEST['ids'])) {
$comment_ids = explode(',', $_REQUEST['ids']);
$doaction = 'untrash';
} else wp_redirect($_SERVER['HTTP_REFERER']);
} elseif ( $_REQUEST['doaction'] == 'undo' && isset($_REQUEST['ids']) ) {
$comment_ids = array_map( 'absint', explode(',', $_REQUEST['ids']) );
$doaction = $_REQUEST['action'];
} else {
wp_redirect($_SERVER['HTTP_REFERER']);
}
$approved = $unapproved = $spammed = $trashed = $untrashed = $deleted = 0;
$approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 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) );
@ -50,10 +52,14 @@ if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_R
wp_set_comment_status($comment_id, 'hold');
$unapproved++;
break;
case 'markspam' :
wp_set_comment_status($comment_id, 'spam');
case 'spam' :
wp_spam_comment($comment_id);
$spammed++;
break;
case 'unspam' :
wp_unspam_comment($comment_id);
$unspammed++;
break;
case 'trash' :
wp_trash_comment($comment_id);
$trashed++;
@ -69,7 +75,25 @@ if ( isset($_REQUEST['doaction']) || isset($_REQUEST['doaction2']) || isset($_R
}
}
$redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&trashed=' . $trashed . '&untrashed=' . $untrashed . '&deleted=' . $deleted . '&ids=' . join(',', $comment_ids);
$redirect_to = 'edit-comments.php';
if ( $approved )
$redirect_to = add_query_arg( 'approved', $approved, $redirect_to );
if ( $unapproved )
$redirect_to = add_query_arg( 'unapproved', $unapproved, $redirect_to );
if ( $spammed )
$redirect_to = add_query_arg( 'spammed', $spammed, $redirect_to );
if ( $unspammed )
$redirect_to = add_query_arg( 'unspammed', $unspammed, $redirect_to );
if ( $trashed )
$redirect_to = add_query_arg( 'trashed', $trashed, $redirect_to );
if ( $untrashed )
$redirect_to = add_query_arg( 'untrashed', $untrashed, $redirect_to );
if ( $deleted )
$redirect_to = add_query_arg( 'deleted', $deleted, $redirect_to );
if ( $trashed || $spammed )
$redirect_to = add_query_arg( 'ids', join(',', $comment_ids), $redirect_to );
if ( $post_id )
$redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to );
if ( isset($_REQUEST['apage']) )
@ -112,22 +136,28 @@ if ( isset($_GET['s']) && $_GET['s'] )
</h2>
<?php
if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spam']) ) {
if ( isset($_GET['approved']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) || isset($_GET['spammed']) || isset($_GET['unspammed']) ) {
$approved = isset($_GET['approved']) ? (int) $_GET['approved'] : 0;
$deleted = isset($_GET['deleted']) ? (int) $_GET['deleted'] : 0;
$trashed = isset($_GET['trashed']) ? (int) $_GET['trashed'] : 0;
$untrashed = isset($_GET['untrashed']) ? (int) $_GET['untrashed'] : 0;
$spam = isset($_GET['spam']) ? (int) $_GET['spam'] : 0;
$spammed = isset($_GET['spammed']) ? (int) $_GET['spammed'] : 0;
$unspammed = isset($_GET['unspammed']) ? (int) $_GET['unspammed'] : 0;
if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spam > 0 ) {
if ( $approved > 0 || $deleted > 0 || $trashed > 0 || $untrashed > 0 || $spammed > 0 || $unspammed > 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 );
if ( $spammed > 0 ) {
printf( _n( '%s comment marked as spam.', '%s comments marked as spam.', $spammed ), $spammed );
$ids = isset($_GET['ids']) ? $_GET['ids'] : 0;
echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=unspam&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo?') . '</a><br />';
}
if ( $unspammed > 0 ) {
printf( _n( '%s comment restored from the spam', '%s comments restored from the spam', $unspammed ), $unspammed );
echo '<br />';
}
if ( $trashed > 0 ) {
@ -275,10 +305,12 @@ $page_links = paginate_links( array(
<option value="approve"><?php _e('Approve'); ?></option>
<?php endif; ?>
<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
<option value="markspam"><?php _e('Mark as Spam'); ?></option>
<option value="spam"><?php _e('Mark as Spam'); ?></option>
<?php endif; ?>
<?php if ( 'trash' == $comment_status ): ?>
<option value="untrash"><?php _e('Restore'); ?></option>
<?php elseif ( 'spam' == $comment_status ): ?>
<option value="unspam"><?php _e('Not Spam'); ?></option>
<?php endif; ?>
<?php if ( 'trash' == $comment_status || 'spam' == $comment_status || !EMPTY_TRASH_DAYS ): ?>
<option value="delete"><?php _e('Delete Permanently'); ?></option>
@ -371,13 +403,15 @@ if ( $page_links )
<option value="approve"><?php _e('Approve'); ?></option>
<?php endif; ?>
<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
<option value="markspam"><?php _e('Mark as Spam'); ?></option>
<option value="spam"><?php _e('Mark as Spam'); ?></option>
<?php endif; ?>
<?php if ( 'trash' == $comment_status ): ?>
<option value="untrash"><?php _e('Restore'); ?></option>
<?php endif; ?>
<?php if ( 'trash' == $comment_status || 'spam' == $comment_status || !EMPTY_TRASH_DAYS ): ?>
<option value="delete"><?php _e('Delete Permanently'); ?></option>
<?php elseif ( 'spam' == $comment_status ): ?>
<option value="unspam"><?php _e('Not Spam'); ?></option>
<?php else: ?>
<option value="trash"><?php _e('Move to Trash'); ?></option>
<?php endif; ?>

View File

@ -2114,12 +2114,13 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
$del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) );
$approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) );
$delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
$approve_url = esc_url( "comment.php?action=approvecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
$unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$post->ID&c=$comment->comment_ID&$approve_nonce" );
$spam_url = esc_url( "comment.php?action=deletecomment&dt=spam&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
$spam_url = esc_url( "comment.php?action=spamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
$unspam_url = esc_url( "comment.php?action=unspamcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
$trash_url = esc_url( "comment.php?action=trashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
$untrash_url = esc_url( "comment.php?action=untrashcomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
$delete_url = esc_url( "comment.php?action=deletecomment&p=$post->ID&c=$comment->comment_ID&$del_nonce" );
}
echo "<tr id='comment-$comment->comment_ID' class='$the_comment_status'>";
@ -2160,35 +2161,33 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
$actions = array();
if ( $user_can ) {
if ( 'trash' == $the_comment_status ) {
$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:ABF888:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</a>';
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</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&amp;new=unapproved vim-u vim-destructive' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
else if ( 'unapproved' == $the_comment_status )
$actions['approve'] = "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:e7e7d3:action=dim-comment&amp;new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</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&amp;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&amp;new=approved vim-a vim-destructive' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
unset($actions['unapprove']);
}
}
if ( 'spam' != $the_comment_status && 'trash' != $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>';
} elseif ( 'spam' == $the_comment_status ) {
$actions['unspam'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:ABF888:unspam=1 vim-z vim-destructive'>" . __( 'Not Spam' ) . '</a>';
} elseif ( 'trash' == $the_comment_status ) {
$actions['untrash'] = "<a href='$untrash_url' class='delete:the-comment-list:comment-$comment->comment_ID:ABF888:untrash=1 vim-z vim-destructive'>" . __( 'Restore' ) . '</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>';
}
if ( 'spam' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . __( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
}
if ( 'spam' == $the_comment_status || 'trash' == $the_comment_status || !EMPTY_TRASH_DAYS ) {
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::delete=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
} else {
$actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-d vim-destructive' title='" . __( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>';
}
if ( 'trash' != $the_comment_status ) {
$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>';
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>';
}
@ -2204,7 +2203,7 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
// Reply and quickedit need a hide-if-no-js span when not added with ajax
if ( ('reply' == $action || 'quickedit' == $action) && ! $from_ajax )
$action .= ' hide-if-no-js';
elseif ($action == 'untrash' && $the_comment_status == 'trash') {
elseif ( ($action == 'untrash' && $the_comment_status == 'trash') || ($action == 'unspam' && $the_comment_status == 'spam') ) {
if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true))
$action .= ' approve';
else
@ -2371,8 +2370,11 @@ function wp_comment_reply($position = '1', $checkbox = false, $mode = 'single',
*/
function wp_comment_trashnotice() {
?>
<div class="hidden" id="undo-holder">
<div class="trash-undo-inside"><?php _e('Comment by'); ?> <strong></strong> <?php _e('moved to the trash.'); ?> <span class="untrash"><a class="undo-trash" href="#"><?php _e('Undo'); ?></a></span></div>
<div class="hidden" id="trash-undo-holder">
<div class="trash-undo-inside"><?php printf(__('Comment by %s moved to the trash.'), '<strong></strong>'); ?> <span class="undo untrash"><a href="#"><?php _e('Undo'); ?></a></span></div>
</div>
<div class="hidden" id="spam-undo-holder">
<div class="spam-undo-inside"><?php printf(__('Comment by %s marked as spam.'), '<strong></strong>'); ?> <span class="undo unspam"><a href="#"><?php _e('Undo'); ?></a></span></div>
</div>
<?php
}

View File

@ -32,17 +32,22 @@ setCommentsList = function() {
// Send current total, page, per_page and url
delBefore = function( settings, list ) {
var cl = $(settings.target).attr('className'), id, el, n, h, a, author;
var cl = $(settings.target).attr('className'), id, el, n, h, a, author, action = false;
settings.data._total = totalInput.val() || 0;
settings.data._per_page = perPageInput.val() || 0;
settings.data._page = pageInput.val() || 0;
settings.data._url = document.location.href;
if ( cl.indexOf(':trash=1') != -1 ) {
if ( cl.indexOf(':trash=1') != -1 )
action = 'trash';
else if ( cl.indexOf(':spam=1') != -1 )
action = 'spam';
if ( action ) {
id = cl.replace(/.*?comment-([0-9]+).*/, '$1');
el = $('#comment-' + id);
note = $('#undo-holder').html();
note = $('#' + action + '-undo-holder').html();
if ( el.siblings('#replyrow').length && commentReply.cid == id )
commentReply.close();
@ -50,23 +55,23 @@ setCommentsList = function() {
if ( el.is('tr') ) {
n = el.children(':visible').length;
author = $('.author strong', el).text();
h = $('<tr id="trashundo-' + id + '" class="trash-undo" style="display:none;"><td colspan="' + n + '">' + note + '</td></tr>');
h = $('<tr id="undo-' + id + '" class="undo un' + action + '" style="display:none;"><td colspan="' + n + '">' + note + '</td></tr>');
} else {
author = $('.comment-author', el).text();
h = $('<div id="trashundo-' + id + '" style="display:none;" class="trash-undo">' + note + '</div>');
h = $('<div id="undo-' + id + '" style="display:none;" class="undo un' + action + '">' + note + '</div>');
}
el.before(h);
$('strong', '#trashundo-' + id).text(author + ' ');
a = $('a.undo-trash', '#trashundo-' + id);
a.attr('href', 'comment.php?action=untrashcomment&c=' + id + '&_ajax_nonce=' + settings.data._ajax_nonce);
a.attr('className', 'delete:the-comment-list:comment-' + id + '::untrash=1 vim-z vim-destructive');
$('.avatar', el).clone().prependTo('#trashundo-' + id + ' .trash-undo-inside');
$('strong', '#undo-' + id).text(author + ' ');
a = $('.undo a', '#undo-' + id);
a.attr('href', 'comment.php?action=un' + action + 'comment&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce);
a.attr('className', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1 vim-z vim-destructive');
$('.avatar', el).clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
a.click(function(){
list.wpList.del(this);
$('#trashundo-' + id).fadeOut(300, function(){
$('#undo-' + id).fadeOut(300, function(){
$(this).remove();
$('#comment-' + id).css('backgroundColor', '').fadeIn(300, function(){ $(this).show() });
});
@ -135,7 +140,7 @@ setCommentsList = function() {
// In admin-ajax.php, we send back the unix time stamp instead of 1 on success
delAfter = function( r, settings ) {
var total, pageLinks, N, untrash = $(settings.target).parent().is('span.untrash'), spam, trash;
var total, pageLinks, N, untrash = $(settings.target).parent().is('span.untrash'), unspam = $(settings.target).parent().is('span.unspam'), spam, trash;
function getUpdate(s) {
if ( $(settings.target).parent().is('span.' + s) )
@ -150,11 +155,13 @@ setCommentsList = function() {
if ( untrash )
trash = -1;
if ( unspam )
spam = -1;
$('span.pending-count').each( function() {
var a = $(this), n = getCount(a), unapproved = $('#' + settings.element).is('.unapproved');
if ( $(settings.target).parent().is('span.unapprove') || ( untrash && unapproved ) ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"
n = n + 1;
} else if ( unapproved ) { // we deleted a formerly unapproved comment
n = n - 1;
@ -212,8 +219,8 @@ setCommentsList = function() {
.bind('wpListDelEnd', function(e, s){
var id = s.element.replace(/[^0-9]+/g, '');
if ( s.target.className.indexOf(':trash=1') != -1 )
$('#trashundo-' + id).fadeIn(300, function(){ $(this).show() });
if ( s.target.className.indexOf(':trash=1') != -1 || s.target.className.indexOf(':spam=1') != -1 )
$('#undo-' + id).fadeIn(300, function(){ $(this).show() });
});
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3516,7 +3516,7 @@ span.imgedit-scale-warn {
padding: 2px 10px;
}
#dashboard_recent_comments .trash-undo {
#dashboard_recent_comments div.undo {
border-top-style: solid;
border-top-width: 1px;
margin: 0 -10px;
@ -3524,11 +3524,13 @@ span.imgedit-scale-warn {
font-size: 11px;
}
.trash-undo-inside {
.trash-undo-inside,
.spam-undo-inside {
margin: 1px 8px 1px 0;
line-height: 16px;
}
.spam-undo-inside .avatar,
.trash-undo-inside .avatar {
height: 20px;
width: 20px;

View File

@ -866,22 +866,22 @@ function wp_trash_comment($comment_id) {
do_action('trash_comment', $comment_id);
add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);
add_comment_meta($comment_id, '_wp_trash_meta_time', time() );
if ( wp_set_comment_status($comment_id, 'trash') ) {
add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);
add_comment_meta($comment_id, '_wp_trash_meta_time', time() );
do_action('trashed_comment', $comment_id);
return true;
}
wp_set_comment_status($comment_id, 'trash');
do_action('trashed_comment', $comment_id);
return true;
return false;
}
/**
* Removes a comment from the Trash
*
* @since 2.9.0
* @uses do_action() on 'untrash_comment' before undeletion
* @uses do_action() on 'untrashed_comment' after undeletion
* @uses do_action() on 'untrash_comment' before untrashing
* @uses do_action() on 'untrashed_comment' after untrashing
*
* @param int $comment_id Comment ID.
* @return mixed False on failure
@ -892,7 +892,7 @@ function wp_untrash_comment($comment_id) {
do_action('untrash_comment', $comment_id);
$comment = array('comment_ID'=>$comment_id);
$comment = array('comment_ID' => $comment_id);
$status = get_comment_meta($comment_id, '_wp_trash_meta_status', true);
if ( empty($status) )
@ -900,14 +900,68 @@ function wp_untrash_comment($comment_id) {
$comment['comment_approved'] = $status;
delete_comment_meta($comment_id, '_wp_trash_meta_time');
delete_comment_meta($comment_id, '_wp_trash_meta_status');
if ( wp_update_comment($comment) ) {
delete_comment_meta($comment_id, '_wp_trash_meta_time');
delete_comment_meta($comment_id, '_wp_trash_meta_status');
do_action('untrashed_comment', $comment_id);
return true;
}
wp_update_comment($comment);
return false;
}
do_action('untrashed_comment', $comment_id);
/**
* Marks a comment as Spam
*
* @since 2.9.0
* @uses do_action() on 'spam_comment' before spamming
* @uses do_action() on 'spammed_comment' after spamming
*
* @param int $comment_id Comment ID.
* @return mixed False on failure
*/
function wp_spam_comment($comment_id) {
if ( !$comment = get_comment($comment_id) )
return false;
return true;
do_action('spam_comment', $comment_id);
if ( wp_set_comment_status($comment_id, 'spam') ) {
add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved);
do_action('spammed_comment', $comment_id);
return true;
}
return false;
}
/**
* Removes a comment from the Spam
*
* @since 2.9.0
* @uses do_action() on 'unspam_comment' before unspamming
* @uses do_action() on 'unspammed_comment' after unspamming
*
* @param int $comment_id Comment ID.
* @return mixed False on failure
*/
function wp_unspam_comment($comment_id) {
if ( ! (int)$comment_id )
return false;
do_action('unspam_comment', $comment_id);
$status = get_comment_meta($comment_id, '_wp_trash_meta_status', true);
if ( empty($status) )
$status = '0';
if ( wp_set_comment_status($comment_id, "$status") ) {
delete_comment_meta($comment_id, '_wp_trash_meta_status');
do_action('unspammed_comment', $comment_id);
return true;
}
return false;
}
/**

View File

@ -263,7 +263,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'), '20091125' );
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20091126' );
$scripts->add_data( 'admin-comments', 'group', 1 );
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),
@ -425,9 +425,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 = '20091125';
$colors_version = '20091126';
$styles->add( 'wp-admin', "/wp-admin/wp-admin$suffix.css", array(), '20091125' );
$styles->add( 'wp-admin', "/wp-admin/wp-admin$suffix.css", array(), '20091126' );
$styles->add_data( 'wp-admin', 'rtl', "/wp-admin/rtl$suffix.css" );
$styles->add( 'ie', '/wp-admin/css/ie.css', array(), '20090922' );