DisableGatewayWhenDisabledPerForm.php
2 years ago
EnqueueOfflineFormBuilderScripts.php
1 year ago
UpdateOfflineMetaFromFormBuilder.php
2 years ago
EnqueueOfflineFormBuilderScripts.php
50 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 | * @since 3.16.2 On the "offlineEnabled" option check if the offline gateway is enabled for v3 forms instead of v2 forms |
| 13 | * |
| 14 | * @return void |
| 15 | */ |
| 16 | public function __invoke() |
| 17 | { |
| 18 | $scriptAsset = require trailingslashit(GIVE_PLUGIN_DIR) . 'build/offlineGatewayFormBuilder.asset.php'; |
| 19 | |
| 20 | wp_enqueue_style( |
| 21 | 'givewp-offline-gateway-form-builder', |
| 22 | GIVE_PLUGIN_URL . 'build/offlineGatewayFormBuilder.css', |
| 23 | [], |
| 24 | $scriptAsset['version'] |
| 25 | ); |
| 26 | |
| 27 | wp_enqueue_script( |
| 28 | 'givewp-offline-gateway-form-builder', |
| 29 | GIVE_PLUGIN_URL . 'build/offlineGatewayFormBuilder.js', |
| 30 | $scriptAsset['dependencies'], |
| 31 | $scriptAsset['version'], |
| 32 | true |
| 33 | ); |
| 34 | |
| 35 | wp_add_inline_script( |
| 36 | 'givewp-offline-gateway-form-builder', |
| 37 | 'window.giveOfflineGatewaySettings = ' . wp_json_encode( |
| 38 | [ |
| 39 | 'offlineEnabled' => give_is_gateway_active(OfflineGateway::id(), 3), |
| 40 | 'offlineSettingsUrl' => admin_url( |
| 41 | 'edit.php?post_type=give_forms&page=give-settings&tab=gateways§ion=offline-donations' |
| 42 | ), |
| 43 | 'defaultInstructions' => give_get_default_offline_donation_content(), |
| 44 | ] |
| 45 | ), |
| 46 | 'before' |
| 47 | ); |
| 48 | } |
| 49 | } |
| 50 |