Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: akismet_spam_count_incr

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
147                // akismet_spam_count will be incremented later by comment_is_spam()
148                self::$last_comment_result = 'spam';
149
150                $discard = ( isset( $commentdata['akismet_pro_tip'] ) && $commentdata['akismet_pro_tip'] === 'discard' && self::allow_discard() );
151
152                do_action( 'akismet_spam_caught', $discard );
153
154                if ( $discard ) {
155                     // akismet_result_spam() won't be called so bump the counter here
156                     if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
157                          update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
158                     $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : get_permalink( $post );
159                     wp_safe_redirect( esc_url_raw( $redirect_to ) );
160                     die();
161                }
162           }
163           
164           // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
165           if ( 'true' != $response[1] && 'false' != $response[1] ) {
 
Line Code
769      // filter handler used to return a spam result to pre_comment_approved
770      public static function last_comment_status( $approved, $comment ) {
771           // Only do this if it's the correct comment
772           if ( is_null(self::$last_comment_result) || ! self::matches_last_comment( $comment ) ) {
773                self::log( "comment_is_spam mismatched comment, returning unaltered $approved" );
774                return $approved;
775           }
776
777           // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
778           if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
779                update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
780
781           return self::$last_comment_result;
782      }
783      
784      /**
785       * If Akismet is temporarily unreachable, we don't want to "spam" the blogger with
786       * moderation emails for comments that will be automatically cleared or spammed on
787       * the next retry.