wp_spam_comment example

$r = wp_untrash_comment( $comment );

        // Undo trash, not in Trash.         if ( ! isset( $_POST['comment_status'] ) || 'trash' !== $_POST['comment_status'] ) {
            $delta = 1;
        }
    } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) {
        if ( 'spam' === $status ) {
            wp_die( time() );
        }

        $r = wp_spam_comment( $comment );
    } elseif ( isset( $_POST['unspam'] ) && 1 == $_POST['unspam'] ) {
        if ( 'spam' !== $status ) {
            wp_die( time() );
        }

        $r = wp_unspam_comment( $comment );

        // Undo spam, not in spam.         if ( ! isset( $_POST['comment_status'] ) || 'spam' !== $_POST['comment_status'] ) {
            $delta = 1;
        }
    }
switch ( $doaction ) {
            case 'approve':
                wp_set_comment_status( $comment_id, 'approve' );
                $approved++;
                break;
            case 'unapprove':
                wp_set_comment_status( $comment_id, 'hold' );
                $unapproved++;
                break;
            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++;
                break;
            case 'untrash':
                
// If we got back a legit response then update the comment history             // other wise just bail now and try again later. No point in             // re-trying all the comments once we hit one failure.             if ( !empty( $event ) ) {
                delete_comment_meta( $comment_id, 'akismet_error' );
                self::update_comment_history( $comment_id, '', $event );
                update_comment_meta( $comment_id, 'akismet_result', $status );
                // make sure the comment status is still pending. if it isn't, that means the user has already moved it elsewhere.                 $comment = get_comment( $comment_id );
                if ( $comment && 'unapproved' == wp_get_comment_status( $comment_id ) ) {
                    if ( $status == 'true' ) {
                        wp_spam_comment( $comment_id );
                    } elseif ( $status == 'false' ) {
                        // comment is good, but it's still in the pending queue. depending on the moderation settings                         // we may need to change it to approved.                         if ( check_comment($comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type) )
                            wp_set_comment_status( $comment_id, 1 );
                        else if ( get_comment_meta( $comment_id, 'akismet_delayed_moderation_email', true ) )
                            wp_notify_moderator( $comment_id );
                    }
                }
                
                delete_comment_meta( $comment_id, 'akismet_delayed_moderation_email' );
            }
switch ( $new_status ) {
            case 'approved':
            case 'approve':
            case '1':
                $changed = wp_set_comment_status( $comment_id, 'approve' );
                break;
            case 'hold':
            case '0':
                $changed = wp_set_comment_status( $comment_id, 'hold' );
                break;
            case 'spam':
                $changed = wp_spam_comment( $comment_id );
                break;
            case 'unspam':
                $changed = wp_unspam_comment( $comment_id );
                break;
            case 'trash':
                $changed = wp_trash_comment( $comment_id );
                break;
            case 'untrash':
                $changed = wp_untrash_comment( $comment_id );
                break;
            default:
                
'trashed' => '1',
                        'ids'     => $comment_id,
                    ),
                    $redir
                );
                break;
            case 'untrashcomment':
                wp_untrash_comment( $comment );
                $redir = add_query_arg( array( 'untrashed' => '1' )$redir );
                break;
            case 'spamcomment':
                wp_spam_comment( $comment );
                $redir = add_query_arg(
                    array(
                        'spammed' => '1',
                        'ids'     => $comment_id,
                    ),
                    $redir
                );
                break;
            case 'unspamcomment':
                wp_unspam_comment( $comment );
                $redir = add_query_arg( array( 'unspammed' => '1' )$redir );
                
Home | Imprint | This part of the site doesn't use cookies.