DisableGatewayWhenDisabledPerForm.php
2 years ago
EnqueueOfflineFormBuilderScripts.php
2 years ago
UpdateOfflineMetaFromFormBuilder.php
2 years ago
EnqueueOfflineFormBuilderScripts.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\PaymentGateways\Gateways\Offline\Actions; |
| 4 | |
| 5 | use Give\PaymentGateways\Gateways\Offline\OfflineGateway; |
| 6 | |
| 7 | class EnqueueOfflineFormBuilderScripts |
| 8 | { |
| 9 | /** |
| 10 | * Enqueues the Stripe scripts and styles for the Form Builder. |
| 11 | * |
| 12 | * @return void |
| 13 | */ |
| 14 | public function __invoke() |
| 15 | { |
| 16 | $scriptAsset = require trailingslashit(GIVE_PLUGIN_DIR) . 'build/offlineGatewayFormBuilder.asset.php'; |
| 17 | |
| 18 | wp_enqueue_style( |
| 19 | 'givewp-offline-gateway-form-builder', |
| 20 | GIVE_PLUGIN_URL . 'build/offlineGatewayFormBuilder.css', |
| 21 | [], |
| 22 | $scriptAsset['version'] |
| 23 | ); |
| 24 | |
| 25 | wp_enqueue_script( |
| 26 | 'givewp-offline-gateway-form-builder', |
| 27 | GIVE_PLUGIN_URL . 'build/offlineGatewayFormBuilder.js', |
| 28 | $scriptAsset['dependencies'], |
| 29 | $scriptAsset['version'], |
| 30 | true |
| 31 | ); |
| 32 | |
| 33 | wp_add_inline_script( |
| 34 | 'givewp-offline-gateway-form-builder', |
| 35 | 'window.giveOfflineGatewaySettings = ' . wp_json_encode( |
| 36 | [ |
| 37 | 'offlineEnabled' => give_is_gateway_active(OfflineGateway::id()), |
| 38 | 'offlineSettingsUrl' => admin_url( |
| 39 | 'edit.php?post_type=give_forms&page=give-settings&tab=gateways§ion=offline-donations' |
| 40 | ), |
| 41 | 'defaultInstructions' => give_get_default_offline_donation_content(), |
| 42 | ] |
| 43 | ), |
| 44 | 'before' |
| 45 | ); |
| 46 | } |
| 47 | } |
| 48 |