Commands
5 years ago
templates
5 years ago
FieldView.php
5 years ago
FilterCallbackCollection.php
5 years ago
ServiceProvider.php
5 years ago
TemplateHooks.php
5 years ago
functions.php
5 years ago
ServiceProvider.php
85 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Form\LegacyConsumer; |
| 4 | |
| 5 | use Give\Helpers\Hooks; |
| 6 | use Give\Receipt\DonationReceipt; |
| 7 | use Give\ServiceProviders\ServiceProvider as ServiceProviderInterface; |
| 8 | use Give\Form\LegacyConsumer\Commands\DeprecateOldTemplateHook; |
| 9 | |
| 10 | class ServiceProvider implements ServiceProviderInterface { |
| 11 | |
| 12 | /** |
| 13 | * @inheritDoc |
| 14 | */ |
| 15 | public function register() { |
| 16 | include_once plugin_dir_path( __FILE__ ) . '/functions.php'; |
| 17 | give()->bind( |
| 18 | DeprecateOldTemplateHook::class, |
| 19 | function() { |
| 20 | global $wp_filter; |
| 21 | return new DeprecateOldTemplateHook( $wp_filter ); |
| 22 | } |
| 23 | ); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @inheritDoc |
| 28 | */ |
| 29 | public function boot() { |
| 30 | |
| 31 | give( TemplateHooks::class )->walk( give( Commands\SetupNewTemplateHook::class ) ); |
| 32 | if ( ! wp_doing_ajax() ) { |
| 33 | give( TemplateHooks::class )->walk( give( Commands\DeprecateOldTemplateHook::class ) ); |
| 34 | } |
| 35 | |
| 36 | add_filter( |
| 37 | 'give_donation_form_required_fields', |
| 38 | function( $requiredFields, $formID ) { |
| 39 | return give( TemplateHooks::class )->reduce( new Commands\SetupFieldValidation( $formID ), $requiredFields ); |
| 40 | }, |
| 41 | 10, |
| 42 | 2 |
| 43 | ); |
| 44 | |
| 45 | add_action( |
| 46 | 'give_insert_payment', |
| 47 | function( $donationID, $donationData ) { |
| 48 | give( TemplateHooks::class )->walk( new Commands\SetupFieldPersistance( $donationID, $donationData ) ); |
| 49 | }, |
| 50 | 10, |
| 51 | 2 |
| 52 | ); |
| 53 | |
| 54 | add_action( |
| 55 | 'give_view_donation_details_billing_after', |
| 56 | function( $donationID ) { |
| 57 | give( TemplateHooks::class )->walk( new Commands\SetupPaymentDetailsDisplay( $donationID ) ); |
| 58 | } |
| 59 | ); |
| 60 | |
| 61 | add_action( |
| 62 | 'give_new_receipt', |
| 63 | function( DonationReceipt $receipt ) { |
| 64 | give( TemplateHooks::class )->walk( new Commands\SetupFieldReceipt( $receipt ) ); |
| 65 | } |
| 66 | ); |
| 67 | |
| 68 | add_action( |
| 69 | 'give_payment_receipt_after', |
| 70 | function( $payment, $receipt_args ) { |
| 71 | give( TemplateHooks::class )->walk( new Commands\SetupFieldConfirmation( $payment, $receipt_args ) ); |
| 72 | }, |
| 73 | 10, |
| 74 | 2 |
| 75 | ); |
| 76 | |
| 77 | add_action( |
| 78 | 'give_add_email_tags', |
| 79 | function() { |
| 80 | give( TemplateHooks::class )->walk( new Commands\SetupFieldEmailTag ); |
| 81 | } |
| 82 | ); |
| 83 | } |
| 84 | } |
| 85 |