Skip to content

Instantly share code, notes, and snippets.

@seb86
Forked from jessepearson/functions.php
Created January 27, 2021 12:25
Show Gist options
  • Save seb86/318d12dcfd4f0c09a6678532e7d44875 to your computer and use it in GitHub Desktop.
Save seb86/318d12dcfd4f0c09a6678532e7d44875 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