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
169                $response = explode( "\r\n\r\n", $response, 2 );
170           }
171           return $response;
172      }
173 }
174
175 // filter handler used to return a spam result to pre_comment_approved
176 function akismet_result_spam( $approved ) {
177      // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
178      if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
179           update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
180      // this is a one-shot deal
181      remove_filter( 'pre_comment_approved', 'akismet_result_spam' );
182      return 'spam';
183 }
184
185 function akismet_result_hold( $approved ) {
186      // once only
187      remove_filter( 'pre_comment_approved', 'akismet_result_hold' );
 
Line Code
350           do_action( 'akismet_spam_caught' );
351
352           $post = get_post( $comment['comment_post_ID'] );
353           $last_updated = strtotime( $post->post_modified_gmt );
354           $diff = time() - $last_updated;
355           $diff = $diff / 86400;
356           
357           if ( $post->post_type == 'post' && $diff > 30 && get_option( 'akismet_discard_month' ) == 'true' && empty($comment['user_ID']) ) {
358                // akismet_result_spam() won't be called so bump the counter here
359                if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
360                     update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
361                wp_redirect( $_SERVER['HTTP_REFERER'] );
362                die();
363           }
364      }
365      
366      // if the response is neither true nor false, hold the comment for moderation and schedule a recheck
367      if ( 'true' != $response[1] && 'false' != $response[1] ) {
368           add_filter('pre_comment_approved', 'akismet_result_hold');