wp_unspam_comment example

$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':
                wp_untrash_comment( $comment_id );
                $untrashed++;
                break;
            case 'delete':
                
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:
                $changed = false;
                break;
        }

        
 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;
        }
    } elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) {
        $r = wp_delete_comment( $comment );
    } else {
        wp_die( -1 );
    }

    
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 );
                break;
            case 'approvecomment':
                wp_set_comment_status( $comment, 'approve' );
                $redir = add_query_arg( array( 'approved' => 1 )$redir );
                break;
            case 'unapprovecomment':
                wp_set_comment_status( $comment, 'hold' );
                $redir = add_query_arg( array( 'unapproved' => 1 )$redir );
                break;
        }

        
Home | Imprint | This part of the site doesn't use cookies.