Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created November 20, 2020 20:50
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/ded0cefd8dbeb0272d180d7731cac6f1 to your computer and use it in GitHub Desktop.
Save ronalfy/ded0cefd8dbeb0272d180d7731cac6f1 to your computer and use it in GitHub Desktop.
PMPro - De-register jQuery and Assign it new value
<?php
/**
* Deregister core WordPress scripts and use CDN jQuery instead.
*
* Not recommended for wide-use. May neeed to update this when WordPress 5.6 is released.
*
* 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( $scripts ) {
wp_deregister_script( 'jquery' );
wp_deregister_script( 'jquery-core' );
wp_deregister_script( 'jquery-js' );
wp_register_script( 'jquery-core', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js' );
wp_register_script( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ) );
wp_register_script( 'jquery-js', false, array( 'jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'my_pmpro_dequeue_script_in_theme' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment