do_action( 'akismet_spam_caught',
$discard );
if ( $discard ) { // The spam is obvious, so we're bailing out early.
// akismet_result_spam() won't be called so bump the counter here
if ( $incr =
apply_filters( 'akismet_spam_count_incr', 1
) ) { update_option( 'akismet_spam_count',
get_option( 'akismet_spam_count'
) +
$incr );
} if ( 'rest_api' ===
$context ) { return new WP_Error( 'akismet_rest_comment_discarded',
__( 'Comment discarded.', 'akismet'
) );
} else if ( 'xml-rpc' ===
$context ) { // If this is a pingback that we're pre-checking, the discard behavior is the same as the normal spam response behavior.
return $commentdata;
} else { // Redirect back to the previous page, or failing that, the post permalink, or failing that, the homepage of the blog.
$redirect_to =
isset( $_SERVER['HTTP_REFERER'
] ) ?
$_SERVER['HTTP_REFERER'
] :
( $post ?
get_permalink( $post ) :
home_url() );
wp_safe_redirect( esc_url_raw( $redirect_to ) );
die();
} } else if ( 'rest_api' ===
$context ) {