From 0b4f8e72d5e475a887b303a5617dc5e950af5038 Mon Sep 17 00:00:00 2001 From: Florian Brinkmann Date: Fri, 15 Dec 2023 18:41:10 +0100 Subject: [PATCH] chore: move threshold filters in `Rules.php` before the loop and the score check after it --- src/Handlers/Rules.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Handlers/Rules.php b/src/Handlers/Rules.php index 4b8f7e84..eaab4de9 100644 --- a/src/Handlers/Rules.php +++ b/src/Handlers/Rules.php @@ -20,6 +20,9 @@ public function apply( $item ) { $item['reaction_type'] = $this->type; $rules = self::get( $this->type, true ); + $no_spam_threshold = (float) apply_filters( 'antispam_bee_no_spam_threshold', 0.0 ); + $spam_threshold = (float) apply_filters( 'antispam_bee_spam_threshold', 0.0 ); + $score = 0.0; foreach ( $rules as $rule ) { $rule_score = $rule::verify( $item ) * $rule::get_weight(); @@ -31,17 +34,14 @@ public function apply( $item ) { } $score += $rule_score; + } - $no_spam_threshold = (float) apply_filters( 'antispam_bee_no_spam_threshold', 0.0 ); - $spam_threshold = (float) apply_filters( 'antispam_bee_spam_threshold', 0.0 ); - - if ( $no_spam_threshold < 0.0 && $score <= $no_spam_threshold ) { - return false; - } + if ( $no_spam_threshold < 0.0 && $score <= $no_spam_threshold ) { + return false; + } - if ( $spam_threshold > 0.0 && $score >= $spam_threshold ) { - return true; - } + if ( $spam_threshold > 0.0 && $score >= $spam_threshold ) { + return true; } return $score > 0.0;