Last active
August 29, 2015 14:26
-
-
Save badfun/3a9a3799a0b77ff895d9 to your computer and use it in GitHub Desktop.
Sometimes in WordPress, for reasons unknown, jQuery does not get registered or loaded. This function checks if jQuery has been enqueued, and if not, registers and enqueues it.
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
function bfp_load_jquery_if_not_loading(){ | |
if( ! wp_script_is( 'jquery', 'enqueued') && ! is_admin() ){ | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3'); | |
wp_enqueue_script('jquery'); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'bfp_load_jquery_if_not_loading'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment