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
460                self::$last_comment_result = 'spam';
461
462                $discard = ( isset( $commentdata['akismet_pro_tip'] ) && $commentdata['akismet_pro_tip'] === 'discard' && self::allow_discard() );
463
464                do_action( 'akismet_spam_caught', $discard );
465
466                if ( $discard ) {
467                     // The spam is obvious, so we're bailing out early.
468                     // akismet_result_spam() won't be called so bump the counter here
469                     if ( $incr = apply_filters( 'akismet_spam_count_incr', 1 ) ) {
470                          update_option( 'akismet_spam_count', get_option( 'akismet_spam_count' ) + $incr );
471                     }
472
473                     if ( 'rest_api' === $context ) {
474                          return new WP_Error( 'akismet_rest_comment_discarded', __( 'Comment discarded.', 'akismet' ) );
475                     } elseif ( 'xml-rpc' === $context ) {
476                          // If this is a pingback that we're pre-checking, the discard behavior is the same as the normal spam response behavior.
477                          return $commentdata;
478                     } else {
 
Line Code
1550                // If the last comment we checked has had its approval set to 'trash',
1551                // then it failed the comment blacklist check. Let that blacklist override
1552                // the spam check, since users have the (valid) expectation that when
1553                // they fill out their blacklists, comments that match it will always
1554                // end up in the trash.
1555                return $approved;
1556           }
1557
1558           // bump the counter here instead of when the filter is added to reduce the possibility of overcounting
1559           if ( $incr = apply_filters( 'akismet_spam_count_incr', 1 ) ) {
1560                update_option( 'akismet_spam_count', get_option( 'akismet_spam_count' ) + $incr );
1561           }
1562
1563           return self::$last_comment_result;
1564      }
1565
1566      /**
1567       * If Akismet is temporarily unreachable, we don't want to "spam" the blogger or post author
1568       * with emails for comments that will be automatically cleared or spammed on the next retry.