Created
November 20, 2020 20:50
-
-
Save ronalfy/ded0cefd8dbeb0272d180d7731cac6f1 to your computer and use it in GitHub Desktop.
PMPro - De-register jQuery and Assign it new value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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