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
236                self::$last_comment_result = 'spam';
237
238                $discard = ( isset( $commentdata['akismet_pro_tip'] ) && $commentdata['akismet_pro_tip'] === 'discard' && self::allow_discard() );
239
240                do_action( 'akismet_spam_caught', $discard );
241
242                if ( $discard ) {
243                     // The spam is obvious, so we're bailing out early. 
244                     // akismet_result_spam() won't be called so bump the counter here
245                     if ( $incr = apply_filters( 'akismet_spam_count_incr', 1 ) ) {
246                          update_option( 'akismet_spam_count', get_option( 'akismet_spam_count' ) + $incr );
247                     }
248
249                     if ( self::$is_api_call ) {
250                          return new WP_Error( 'akismet_rest_comment_discarded', __( 'Comment discarded.', 'akismet' ) );
251                     }
252                     else {
253                          // Redirect back to the previous page, or failing that, the post permalink, or failing that, the homepage of the blog.
254                          $redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : ( $post ? get_permalink( $post ) : home_url() );
 
Line Code
1091                // If the last comment we checked has had its approval set to 'trash',
1092                // then it failed the comment blacklist check. Let that blacklist override
1093                // the spam check, since users have the (valid) expectation that when
1094                // they fill out their blacklists, comments that match it will always
1095                // end up in the trash.
1096                return $approved;
1097           }
1098
1099           // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
1100           if ( $incr = apply_filters('akismet_spam_count_incr', 1) )
1101                update_option( 'akismet_spam_count', get_option('akismet_spam_count') + $incr );
1102
1103           return self::$last_comment_result;
1104      }
1105      
1106      /**
1107       * If Akismet is temporarily unreachable, we don't want to "spam" the blogger with
1108       * moderation emails for comments that will be automatically cleared or spammed on
1109       * the next retry.