| @@ -12,9 +12,9 @@ | ||
| 12 | 12 | $hasCleanTalk = self::isCleantalkActivated(); |
| 13 | 13 | if ($hasCleanTalk) { |
| 14 | 14 | wp_enqueue_script( |
| 15 | 15 | 'ct_bot_detector', |
| 16 | - 'https://moderate.cleantalk.org/ct-bot-detector-wrapper.js', | |
| 16 | + 'https://fd.cleantalk.org/ct-bot-detector-wrapper.js', | |
| 17 | 17 | [], |
| 18 | 18 | FLUENTFORM_VERSION, |
| 19 | 19 | [ |
| 20 | 20 | 'in_footer' => false, |
| @@ -57,10 +57,8 @@ | ||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public static function spamSubmissionCheckWithApi($formData, $form) |
| 60 | 60 | { |
| 61 | - global $fluentformCleantalkExecuted; | |
| 62 | - | |
| 63 | 61 | $accessKey = ArrayHelper::get(get_option('_fluentform_cleantalk_details'), 'accessKey'); |
| 64 | 62 | |
| 65 | 63 | if (!$accessKey) { |
| 66 | 64 | return false; |
| @@ -65,8 +63,12 @@ | ||
| 65 | 63 | if (!$accessKey) { |
| 66 | 64 | return false; |
| 67 | 65 | } |
| 68 | 66 | |
| 67 | + if (!self::claimExecution()) { | |
| 68 | + return false; | |
| 69 | + } | |
| 70 | + | |
| 69 | 71 | $eventToken = ArrayHelper::get($formData, 'ct_bot_detector_event_token'); |
| 70 | 72 | $submitTime = isset($formData['ff_ct_form_load_time']) ? time() - (int)$formData['ff_ct_form_load_time'] : null; |
| 71 | 73 | |
| 72 | 74 | $cleanTalkRequest = [ |
| @@ -134,11 +136,29 @@ | ||
| 134 | 136 | $response = json_decode(wp_remote_retrieve_body($response)); |
| 135 | 137 | |
| 136 | 138 | $cleantalkPassed = $response->allow == 1 && $response->spam == 0 && $response->account_status == 1; |
| 137 | 139 | |
| 140 | + return !$cleantalkPassed; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public static function hasExecuted() | |
| 144 | + { | |
| 145 | + global $fluentformCleantalkExecuted; | |
| 146 | + | |
| 147 | + return isset($fluentformCleantalkExecuted) && true === $fluentformCleantalkExecuted; | |
| 148 | + } | |
| 149 | + | |
| 150 | + protected static function claimExecution() | |
| 151 | + { | |
| 152 | + global $fluentformCleantalkExecuted; | |
| 153 | + | |
| 154 | + if (self::hasExecuted()) { | |
| 155 | + return false; | |
| 156 | + } | |
| 157 | + | |
| 138 | 158 | $fluentformCleantalkExecuted = true; |
| 139 | 159 | |
| 140 | - return !$cleantalkPassed; | |
| 160 | + return true; | |
| 141 | 161 | } |
| 142 | 162 | |
| 143 | 163 | public static function isCleantalkActivated() |
| 144 | 164 | { |
| @@ -144,12 +164,12 @@ | ||
| 144 | 164 | { |
| 145 | 165 | $settings = get_option('_fluentform_cleantalk_details'); |
| 146 | 166 | return $settings && ArrayHelper::get($settings, 'status'); |
| 147 | 167 | } |
| 148 | - | |
| 168 | + | |
| 149 | 169 | public static function isEnabled() |
| 150 | 170 | { |
| 151 | - if (!self::isPluginEnabled()) { | |
| 171 | + if (self::isCleantalkActivated() || !self::isPluginEnabled()) { | |
| 152 | 172 | return false; |
| 153 | 173 | } |
| 154 | 174 | |
| 155 | 175 | $settings = get_option('_fluentform_global_form_settings'); |
| @@ -167,8 +187,12 @@ | ||
| 167 | 187 | } |
| 168 | 188 | |
| 169 | 189 | public static function isSpamSubmission($formData, $form) |
| 170 | 190 | { |
| 191 | + if (!self::claimExecution()) { | |
| 192 | + return false; | |
| 193 | + } | |
| 194 | + | |
| 171 | 195 | $cleanTalkRequest = self::getCleanTalkRequest($formData, $form); |
| 172 | 196 | $cleanTalk = new \Cleantalk\Antispam\Cleantalk(); |
| 173 | 197 | $cleanTalk->server_url = 'https://moderate.cleantalk.org'; |
| 174 | 198 | $response = $cleanTalk->isAllowMessage($cleanTalkRequest); |