Akismet
1 week ago
Exceptions
1 year ago
EmailAddressWhiteList.php
1 week ago
ServiceProvider.php
1 week ago
ServiceProvider.php
49 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonationSpam; |
| 4 | |
| 5 | use Give\DonationSpam\Akismet\Actions\ValidateDonationOnFinalSubmission; |
| 6 | use Give\Helpers\Hooks; |
| 7 | use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface; |
| 8 | |
| 9 | /** |
| 10 | * @since 3.15.0 |
| 11 | */ |
| 12 | class ServiceProvider implements ServiceProviderInterface |
| 13 | { |
| 14 | /** |
| 15 | * @since 3.15.0 |
| 16 | * @inheritDoc |
| 17 | */ |
| 18 | public function register(): void |
| 19 | { |
| 20 | /** |
| 21 | * @since 3.15.1 Case filtered value as an array to enforce type. |
| 22 | * @since 3.15.0 |
| 23 | */ |
| 24 | give()->singleton(EmailAddressWhiteList::class, function () { |
| 25 | return new EmailAddressWhiteList( |
| 26 | (array)apply_filters('give_akismet_whitelist_emails', give_akismet_get_whitelisted_emails()) |
| 27 | ); |
| 28 | }); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @since 4.16.0 register an invokable action that gates the Akismet check to the final submission |
| 33 | * @since 3.22.0 updated Akismet validation to use new givewp_donation_form_fields_validated action |
| 34 | * @since 3.15.0 |
| 35 | * |
| 36 | * @inheritDoc |
| 37 | */ |
| 38 | public function boot(): void |
| 39 | { |
| 40 | Hooks::addAction( |
| 41 | 'givewp_donation_form_fields_validated', |
| 42 | ValidateDonationOnFinalSubmission::class, |
| 43 | '__invoke', |
| 44 | 10, |
| 45 | 2 |
| 46 | ); |
| 47 | } |
| 48 | } |
| 49 |