Actions
3 years ago
Commands
2 years ago
Traits
4 years ago
Validators
4 years ago
resources
3 years ago
templates
3 years ago
AddEnctypeAttributeInDonationForm.php
4 years ago
FieldView.php
3 years ago
FilterCallbackCollection.php
3 years ago
ServiceProvider.php
4 years ago
TemplateHooks.php
4 years ago
UniqueIdAttributeGenerator.php
4 years ago
functions.php
4 years ago
ServiceProvider.php
102 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Form\LegacyConsumer; |
| 4 | |
| 5 | use Give\Form\LegacyConsumer\Commands\DeprecateOldTemplateHook; |
| 6 | use Give\Receipt\DonationReceipt; |
| 7 | use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface; |
| 8 | use Give_Donate_Form; |
| 9 | |
| 10 | class ServiceProvider implements ServiceProviderInterface |
| 11 | { |
| 12 | |
| 13 | /** |
| 14 | * @inheritDoc |
| 15 | */ |
| 16 | public function register() |
| 17 | { |
| 18 | include_once plugin_dir_path(__FILE__) . '/functions.php'; |
| 19 | give()->bind( |
| 20 | DeprecateOldTemplateHook::class, |
| 21 | function () { |
| 22 | global $wp_filter; |
| 23 | |
| 24 | return new DeprecateOldTemplateHook($wp_filter); |
| 25 | } |
| 26 | ); |
| 27 | |
| 28 | give()->singleton(UniqueIdAttributeGenerator::class); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @inheritDoc |
| 33 | */ |
| 34 | public function boot() |
| 35 | { |
| 36 | give(TemplateHooks::class)->walk(give(Commands\SetupNewTemplateHook::class)); |
| 37 | if ( ! wp_doing_ajax()) { |
| 38 | give(TemplateHooks::class)->walk(give(Commands\DeprecateOldTemplateHook::class)); |
| 39 | } |
| 40 | |
| 41 | add_action( |
| 42 | 'give_checkout_error_checks', |
| 43 | function () { |
| 44 | $formId = absint($_POST['give-form-id']); |
| 45 | give(TemplateHooks::class)->walk(new Commands\SetupFieldValidation($formId)); |
| 46 | } |
| 47 | ); |
| 48 | |
| 49 | add_action( |
| 50 | 'give_form_html_tags', |
| 51 | /** |
| 52 | * @since 2.14.0 |
| 53 | * |
| 54 | * @param array $formHtmlAttributes |
| 55 | * @param Give_Donate_Form $form |
| 56 | * |
| 57 | * @return void |
| 58 | */ |
| 59 | function ($formHtmlAttributes, $form) { |
| 60 | return give(TemplateHooks::class)->reduce( |
| 61 | new AddEnctypeAttributeInDonationForm($form->ID), |
| 62 | $formHtmlAttributes |
| 63 | ); |
| 64 | }, |
| 65 | 10, |
| 66 | 2 |
| 67 | ); |
| 68 | |
| 69 | add_action( |
| 70 | 'give_insert_payment', |
| 71 | function ($donationID, $donationData) { |
| 72 | give(TemplateHooks::class)->walk(new Commands\SetupFieldPersistence($donationID, $donationData)); |
| 73 | }, |
| 74 | 10, |
| 75 | 2 |
| 76 | ); |
| 77 | |
| 78 | add_action( |
| 79 | 'give_new_receipt', |
| 80 | function (DonationReceipt $receipt) { |
| 81 | give(TemplateHooks::class)->walk(new Commands\SetupFieldReceipt($receipt)); |
| 82 | } |
| 83 | ); |
| 84 | |
| 85 | add_action( |
| 86 | 'give_payment_receipt_after', |
| 87 | function ($payment, $receipt_args) { |
| 88 | give(TemplateHooks::class)->walk(new Commands\SetupFieldConfirmation($payment, $receipt_args)); |
| 89 | }, |
| 90 | 10, |
| 91 | 2 |
| 92 | ); |
| 93 | |
| 94 | add_action( |
| 95 | 'give_add_email_tags', |
| 96 | function () { |
| 97 | give(TemplateHooks::class)->walk(new Commands\SetupFieldEmailTag); |
| 98 | } |
| 99 | ); |
| 100 | } |
| 101 | } |
| 102 |