PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / DonationForms / Rules / HoneyPotRule.php

HoneyPotRule.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/DonationForms/Rules/HoneyPotRule.php

46 lines 979 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Give\DonationForms\Rules;
3
4 use Closure;
5 use Give\DonationSpam\Exceptions\SpamDonationException;
6 use Give\Log\Log;
7 use Give\Vendors\StellarWP\Validation\Contracts\ValidationRule;
8
9 /**
10 * @since 3.16.2
11 */
12 class HoneyPotRule implements ValidationRule
13 {
14
15 /**
16 * @since 3.16.2
17 */
18 public static function id(): string
19 {
20 return 'honeypot';
21 }
22
23 /**
24 * @since 3.16.2
25 */
26 public static function fromString(string $options = null): ValidationRule
27 {
28 return new self();
29 }
30
31 /**
32 * @since 3.16.2
33 * @throws SpamDonationException
34 */
35 public function __invoke($value, Closure $fail, string $key, array $values)
36 {
37 if (!empty($value)) {
38 Log::spam('Spam donation detected via Honeypot field.', [
39 'formId' => $values['formId'] ?? null,
40 ]);
41
42 throw new SpamDonationException(__('Thank you for the submission!', 'give'));
43 }
44 }
45 }
46