Created
June 18, 2012 23:50
-
-
Save mdawaffe/2951506 to your computer and use it in GitHub Desktop.
WordPress (Ill-Advised) Hack: I Already Load jQuery "Manually"
This file contains 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 | |
/* | |
* Plugin Name: I Already Load jQuery "Manually" Hack | |
* Plugin URI: https://gist.github.com/2951506 | |
* Description: If you already load jQuery manually (i.e., without using WordPress' script API), this plugin will prevent other plugins that *do* use WordPress' script API from "double" loadin jQuery. There are probably better ways to prevent this unwanted double-loading behavior. If you have to use this plugin, you're probably doing_it_wrong(). Use at your own risk, it probably breaks something. | |
* Author: mdawaffe | |
* Version: 0.1 | |
* Author URI: http://blogwaffe.com | |
* License: GPL2+ | |
*/ | |
if ( !is_admin() ) { | |
// Hack: This reregisters the 'jquery' handle as a "group" instead of script. | |
// That way, a script tag won't be printed, but wp_print_scripts() won't | |
// treat the 'jquery' handle as missing, which would stop it from loading other | |
// scripts that depend on jquery | |
wp_register_script( 'jquery', false ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a proof of concept. I wouldn't use this :)