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

@@ -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' );