WordPress.org

Make WordPress Core

Ticket #7531: akismet_die_on_spam.diff

File akismet_die_on_spam.diff, 1.5 KB (added by ozh, 6 years ago)

Die on spam

  • akismet.php

     
    55Description: Akismet checks your comments against the Akismet web service to see if they look like spam or not. You need a <a href="http://wordpress.com/api-keys/">WordPress.com API key</a> to use it. You can review the spam it catches under "Comments." To show off your Akismet stats just put <code>&lt;?php akismet_counter(); ?></code> in your template. See also: <a href="http://wordpress.org/extend/plugins/stats/">WP Stats plugin</a>. 
    66Version: 2.1.6 
    77Author: Matt Mullenweg 
    8 Author URI: http://photomatt.net/ 
     8Author URI: http://ma.tt/ 
    99*/ 
    1010 
    1111// If you hardcode a WP.com API key here, all key config screens will be hidden 
     
    203203        $response = akismet_http_post($query_string, $akismet_api_host, '/1.1/comment-check', $akismet_api_port); 
    204204        if ( 'true' == $response[1] ) { 
    205205                add_filter('pre_comment_approved', create_function('$a', 'return \'spam\';')); 
     206                add_filter('comment_post_redirect', 'akismet_reject_screen'); 
    206207                update_option( 'akismet_spam_count', get_option('akismet_spam_count') + 1 ); 
    207208 
    208209                do_action( 'akismet_spam_caught' ); 
     
    219220        return $comment; 
    220221} 
    221222 
     223function akismet_reject_screen() { 
     224        header('HTTP/1.1 403 Forbidden'); 
     225        wp_die(__('Sorry, your comment was considered as spam and rejected')); 
     226} 
     227 
    222228function akismet_delete_old() { 
    223229        global $wpdb; 
    224230        $now_gmt = current_time('mysql', 1);