Skip to content

Instantly share code, notes, and snippets.

@jessepearson
Last active January 27, 2021 12:25
Show Gist options
  • Save jessepearson/6e20f1e5ea2267b0fc51ad24ff39d1ed to your computer and use it in GitHub Desktop.
Save jessepearson/6e20f1e5ea2267b0fc51ad24ff39d1ed to your computer and use it in GitHub Desktop.
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