give
/
src
/
PaymentGateways
/
Gateways
/
Stripe
/
StripePaymentElementGateway
/
Actions
/
EnqueueStripeFormBuilderScripts.php
give
/
src
/
PaymentGateways
/
Gateways
/
Stripe
/
StripePaymentElementGateway
/
Actions
Last commit date
AddStripeAttributesToNewForms.php
2 years ago
EnqueueStripeFormBuilderScripts.php
2 years ago
UpdateStripeFormBuilderSettingsMeta.php
2 years ago
UpdateStripeInvoiceMetaData.php
1 year ago
EnqueueStripeFormBuilderScripts.php
55 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Actions; |
| 4 | |
| 5 | /** |
| 6 | * Class EnqueueStripeFormBuilderScripts |
| 7 | * |
| 8 | * @since 3.0.0 |
| 9 | */ |
| 10 | class EnqueueStripeFormBuilderScripts |
| 11 | { |
| 12 | |
| 13 | /** |
| 14 | * Enqueues the Stripe scripts and styles for the Form Builder. |
| 15 | * |
| 16 | * @return void |
| 17 | */ |
| 18 | public function __invoke() |
| 19 | { |
| 20 | $enabledGateways = array_keys(give_get_option('gateways_v3', [])); |
| 21 | $stripeEnabled = in_array('stripe_payment_element', $enabledGateways, true); |
| 22 | |
| 23 | if (!$stripeEnabled) { |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | $scriptAsset = require trailingslashit(GIVE_PLUGIN_DIR) . 'build/stripePaymentElementFormBuilder.asset.php'; |
| 28 | |
| 29 | wp_enqueue_script( |
| 30 | 'givewp-stripe-payment-element-form-builder', |
| 31 | GIVE_PLUGIN_URL . 'build/stripePaymentElementFormBuilder.js', |
| 32 | $scriptAsset['dependencies'], |
| 33 | false, |
| 34 | true |
| 35 | ); |
| 36 | |
| 37 | wp_localize_script( |
| 38 | 'givewp-stripe-payment-element-form-builder', |
| 39 | 'stripePaymentElementGatewaySettings', |
| 40 | [ |
| 41 | 'defaultAccount' => (bool)give_stripe_get_default_account(), |
| 42 | 'allAccounts' => give_stripe_get_all_accounts(), |
| 43 | 'stripeSettingsUrl' => admin_url( |
| 44 | 'edit.php?post_type=give_forms&page=give-settings&tab=gateways§ion=stripe-settings&group=accounts' |
| 45 | ), |
| 46 | ] |
| 47 | ); |
| 48 | |
| 49 | wp_enqueue_style( |
| 50 | 'givewp-stripe-payment-element-form-builder', |
| 51 | GIVE_PLUGIN_URL . 'build/stripePaymentElementFormBuilder.css' |
| 52 | ); |
| 53 | } |
| 54 | } |
| 55 |