recheck_comment example

$moderation = $wpdb->get_col( $wpdb->prepare( "SELECT * FROM {$wpdb->comments} WHERE comment_approved = '0' LIMIT %d OFFSET %d", $limit$start ) );

        $result_counts = array(
            'processed' => is_countable( $moderation ) ? count( $moderation ) : 0,
            'spam' => 0,
            'ham' => 0,
            'error' => 0,
        );

        foreach ( $moderation as $comment_id ) {
            $api_response = Akismet::recheck_comment( $comment_id, 'recheck_queue' );

            if ( 'true' === $api_response ) {
                ++$result_counts['spam'];
            }
            elseif ( 'false' === $api_response ) {
                ++$result_counts['ham'];
            }
            else {
                ++$result_counts['error'];
            }
        }

        

    public function check( $args$assoc_args ) {
        foreach ( $args as $comment_id ) {
            if ( isset( $assoc_args['noaction'] ) ) {
                // Check the comment, but don't reclassify it.                 $api_response = Akismet::check_db_comment( $comment_id, 'wp-cli' );
            }
            else {
                $api_response = Akismet::recheck_comment( $comment_id, 'wp-cli' );
            }
            
            if ( 'true' === $api_response ) {
                WP_CLI::line( sprintf( __( "Comment #%d is spam.", 'akismet' )$comment_id ) );
            }
            else if ( 'false' === $api_response ) {
                WP_CLI::line( sprintf( __( "Comment #%d is not spam.", 'akismet' )$comment_id ) );
            }
            else {
                if ( false === $api_response ) {
                    WP_CLI::error( __( "Failed to connect to Akismet.", 'akismet' ) );
                }
Home | Imprint | This part of the site doesn't use cookies.