Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dequeue the JavaScript files from WooCommerce Square on all pages except the checkout page.
<?php // do not copy this line
/**
* Note: This has not been tested on a live site and is to be used at your own risk.
*
* This will dequeue the JavaScript files from WooCommerce Square on all pages except the checkout page.
*/
add_action( 'wp_enqueue_scripts', 'dequeue_wc_square_js_scripts_20200713', 999 );
function dequeue_wc_square_js_scripts_20200713() {
// Not needed in admin, and we want to keep in checkout
if ( is_admin() || is_checkout() ) {
return ;
}
// Remove the scripts from the queue.
wp_dequeue_script( 'wc-square' );
wp_dequeue_script( 'wc-square-payment-form' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment