Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created November 20, 2020 19:57
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 ronalfy/0ae14f6ef326a91ab07ca74d68b0b2cc to your computer and use it in GitHub Desktop.
Save ronalfy/0ae14f6ef326a91ab07ca74d68b0b2cc to your computer and use it in GitHub Desktop.
PMPro - Prevent Multiple jQuery Scripts From Running
<?php
/**
* Dequeue's theme's custom JS handler, forces jQuery as a dependency. Testing code is commented out below.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_dequeue_script_in_theme() {
wp_register_script( 'jquery-js', false, array( 'jquery' ) );
}
add_action( 'init', 'my_pmpro_dequeue_script_in_theme' );
/*
add_action(
'wp_enqueue_scripts',
function() {
wp_enqueue_script( 'jquery-js', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js' );
}
);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment