wp_unspam_comment()
can accept a full object instead of comment_ID to reduce cache/db lookups..
See #33638. git-svn-id: https://develop.svn.wordpress.org/trunk@34130 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
166ee8674b
commit
b42a906512
@ -258,23 +258,23 @@ case 'unapprovecomment' :
|
||||
|
||||
switch ( $action ) {
|
||||
case 'deletecomment' :
|
||||
wp_delete_comment( $comment_id );
|
||||
wp_delete_comment( $comment );
|
||||
$redir = add_query_arg( array('deleted' => '1'), $redir );
|
||||
break;
|
||||
case 'trashcomment' :
|
||||
wp_trash_comment($comment_id);
|
||||
wp_trash_comment( $comment );
|
||||
$redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir );
|
||||
break;
|
||||
case 'untrashcomment' :
|
||||
wp_untrash_comment($comment_id);
|
||||
wp_untrash_comment( $comment );
|
||||
$redir = add_query_arg( array('untrashed' => '1'), $redir );
|
||||
break;
|
||||
case 'spamcomment' :
|
||||
wp_spam_comment($comment_id);
|
||||
wp_spam_comment( $comment );
|
||||
$redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir );
|
||||
break;
|
||||
case 'unspamcomment' :
|
||||
wp_unspam_comment($comment_id);
|
||||
wp_unspam_comment( $comment );
|
||||
$redir = add_query_arg( array('unspammed' => '1'), $redir );
|
||||
break;
|
||||
case 'approvecomment' :
|
||||
|
@ -526,25 +526,25 @@ function wp_ajax_delete_comment() {
|
||||
if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) {
|
||||
if ( 'trash' == $status )
|
||||
wp_die( time() );
|
||||
$r = wp_trash_comment( $comment->comment_ID );
|
||||
$r = wp_trash_comment( $comment );
|
||||
} elseif ( isset($_POST['untrash']) && 1 == $_POST['untrash'] ) {
|
||||
if ( 'trash' != $status )
|
||||
wp_die( time() );
|
||||
$r = wp_untrash_comment( $comment->comment_ID );
|
||||
$r = wp_untrash_comment( $comment );
|
||||
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) // undo trash, not in trash
|
||||
$delta = 1;
|
||||
} elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) {
|
||||
if ( 'spam' == $status )
|
||||
wp_die( time() );
|
||||
$r = wp_spam_comment( $comment->comment_ID );
|
||||
$r = wp_spam_comment( $comment );
|
||||
} elseif ( isset($_POST['unspam']) && 1 == $_POST['unspam'] ) {
|
||||
if ( 'spam' != $status )
|
||||
wp_die( time() );
|
||||
$r = wp_unspam_comment( $comment->comment_ID );
|
||||
$r = wp_unspam_comment( $comment );
|
||||
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) // undo spam, not in spam
|
||||
$delta = 1;
|
||||
} elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) {
|
||||
$r = wp_delete_comment( $comment->comment_ID );
|
||||
$r = wp_delete_comment( $comment );
|
||||
} else {
|
||||
wp_die( -1 );
|
||||
}
|
||||
|
@ -1164,13 +1164,10 @@ function wp_spam_comment( $comment_id ) {
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param int $comment_id Comment ID.
|
||||
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
function wp_unspam_comment($comment_id) {
|
||||
if ( ! (int)$comment_id )
|
||||
return false;
|
||||
|
||||
function wp_unspam_comment( $comment_id ) {
|
||||
$comment = get_comment( $comment_id );
|
||||
if ( ! $comment ) {
|
||||
return false;
|
||||
@ -1183,15 +1180,15 @@ function wp_unspam_comment($comment_id) {
|
||||
*
|
||||
* @param int $comment_id The comment ID.
|
||||
*/
|
||||
do_action( 'unspam_comment', $comment_id );
|
||||
do_action( 'unspam_comment', $comment->comment_ID );
|
||||
|
||||
$status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true);
|
||||
$status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
|
||||
if ( empty($status) )
|
||||
$status = '0';
|
||||
|
||||
if ( wp_set_comment_status( $comment, $status ) ) {
|
||||
delete_comment_meta( $comment_id, '_wp_trash_meta_status' );
|
||||
delete_comment_meta( $comment_id, '_wp_trash_meta_time' );
|
||||
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
|
||||
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
|
||||
/**
|
||||
* Fires immediately after a comment is unmarked as Spam.
|
||||
*
|
||||
@ -1199,7 +1196,7 @@ function wp_unspam_comment($comment_id) {
|
||||
*
|
||||
* @param int $comment_id The comment ID.
|
||||
*/
|
||||
do_action( 'unspammed_comment', $comment_id );
|
||||
do_action( 'unspammed_comment', $comment->comment_ID );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user