DeprecateOldTemplateHook.php
4 years ago
HookCommandInterface.php
5 years ago
SetupFieldConfirmation.php
4 years ago
SetupFieldEmailTag.php
4 years ago
SetupFieldPersistence.php
4 years ago
SetupFieldReceipt.php
4 years ago
SetupFieldValidation.php
4 years ago
SetupNewTemplateHook.php
4 years ago
SetupNewTemplateHook.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Form\LegacyConsumer\Commands; |
| 4 | |
| 5 | use Give\Form\LegacyConsumer\FieldView; |
| 6 | use Give\Framework\FieldsAPI\Group; |
| 7 | |
| 8 | /** |
| 9 | * @since 2.10.2 |
| 10 | */ |
| 11 | class SetupNewTemplateHook implements HookCommandInterface { |
| 12 | |
| 13 | /** |
| 14 | * @since 2.10.2 |
| 15 | * |
| 16 | * @param string $hook |
| 17 | * |
| 18 | * @return void |
| 19 | */ |
| 20 | public function __invoke( $hook ) { |
| 21 | // On the old hook, run the new hook and render the fields. |
| 22 | add_action( |
| 23 | "give_$hook", |
| 24 | static function ( $formId ) use ( $hook ) { |
| 25 | $collection = Group::make( $hook ); |
| 26 | do_action( "give_fields_$hook", $collection, $formId ); |
| 27 | $collection->walk( |
| 28 | static function ( $node ) use ( $formId ) { |
| 29 | FieldView::render( $node, $formId ); |
| 30 | } |
| 31 | ); |
| 32 | } |
| 33 | ); |
| 34 | } |
| 35 | } |
| 36 |