Skip to content

Instantly share code, notes, and snippets.

@petertwise
Last active June 7, 2023 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petertwise/064082a8490a816d23a0cf352e75f843 to your computer and use it in GitHub Desktop.
Save petertwise/064082a8490a816d23a0cf352e75f843 to your computer and use it in GitHub Desktop.
Resolve GiveWP and WooCommerce stripe-js loading twice conflict
<?php
// account for conflicts between GiveWP Stripe AND WooCommerce Stripe script loading
function squarecandy_givewp_woocommerce_stripe_resolve() {
// check if both Stripe plugins are active
if ( is_plugin_active( 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php' ) && is_plugin_active( 'give-stripe/give-stripe.php' ) ) :
// WC doesn't load stripe on every page.
// Check if they are both being enqueued in the current context before disabling one.
if ( wp_script_is( 'stripe', 'enqueued' ) && wp_script_is( 'give-stripe-js', 'enqueued' ) ) {
// @TODO - should we compare and make sure the file contents are actually the same here?
// deregister one of the copies of stripe-js
wp_deregister_script( 'give-stripe-js' );
}
endif;
}
add_action( 'wp_enqueue_scripts', 'squarecandy_givewp_woocommerce_stripe_resolve', 9999999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment