Actions
3 years ago
Commands
3 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
TemplateHooks.php
55 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Form\LegacyConsumer; |
| 4 | |
| 5 | class TemplateHooks |
| 6 | { |
| 7 | /** |
| 8 | * A "full-ish" list of available actions. |
| 9 | * @note The `give_` prefix has been removed for interoperability. |
| 10 | * @note Update to account for previously deprecated hooks. |
| 11 | * @link https://givewp.com/documentation/developers/how-to-create-custom-form-fields/ |
| 12 | * @link https://givewp.com/add-content-donation-forms/ |
| 13 | */ |
| 14 | const TEMPLATE_HOOKS = [ |
| 15 | 'before_donation_levels', |
| 16 | 'after_donation_amount', |
| 17 | 'after_donation_levels', |
| 18 | 'payment_mode_top', |
| 19 | 'payment_mode_before_gateways', |
| 20 | 'payment_mode_after_gateways', |
| 21 | 'payment_mode_after_gateways_wrap', |
| 22 | 'payment_mode_bottom', |
| 23 | 'donation_form', |
| 24 | 'donation_form_top', |
| 25 | 'purchase_form_top', |
| 26 | 'donation_form_register_login_fields', |
| 27 | 'donation_form_before_cc_form', |
| 28 | 'cc_form', |
| 29 | 'before_cc_fields', |
| 30 | 'before_cc_expiration', |
| 31 | 'after_cc_expiration', |
| 32 | 'after_cc_fields', |
| 33 | 'donation_form_after_cc_form', |
| 34 | 'purchase_form_bottom', |
| 35 | 'donation_form_before_personal_info', |
| 36 | 'donation_form_after_personal_info', |
| 37 | ]; |
| 38 | |
| 39 | public function walk(callable $callback) |
| 40 | { |
| 41 | $hooks = $this->getHooks(); |
| 42 | array_walk($hooks, $callback); |
| 43 | } |
| 44 | |
| 45 | public function reduce(callable $callback, $initial = null) |
| 46 | { |
| 47 | return array_reduce($this->getHooks(), $callback, $initial); |
| 48 | } |
| 49 | |
| 50 | public function getHooks() |
| 51 | { |
| 52 | return self::TEMPLATE_HOOKS; |
| 53 | } |
| 54 | } |
| 55 |