A lot of people would rather use Google Hosted JavaScript Libraries. Why? Here are three good reasons. Okay, great. How do you do it in WordPress? DigWP has you covered.
But if you want to do it for WordPress MultiSite, for all sites on your network, you can toss this into your mu-plugins folder. I named my file googlelib.php
and dropped it in. Bam.
Oh and there’s also the Use Google Libraries plugin, by Jason Penney, which works great too. Just drop the use-google-libraries.php
file into your mu-plugins folder and call it a day.
<?php /* Plugin Name: Google Lib Plugin URI: http://digwp.com/2009/06/use-google-hosted-javascript-libraries-still-the-right-way/ Description: Use Google Hosted JavaScript Libraries (... Still the right way) Version: 1.0 Author: Mika Epstein Author URI: http://ipstenu.org/ */ if( !is_admin()){ wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"), false, '1.4.4'); wp_enqueue_script('jquery'); } ?>
Comments
5 responses to “WordPress Google Libraries”
You should simply recommend Use Google Libraries or simply copy/paste it’s code since your code is much worse solution.
Literacy is optional for you, eh?
3rd paragraph is, and I quote:
Has a link and everything.
The code I showed you WILL work. Not everyone wants to. So you have options.
I’ve used a wrong wording (I’m not a native English speaker). Better would be if I said “You should only recommend Use Google Libraries without your code example, or if you want to show a code example, only use code from Use Google Libraries since its the only right way to enable this feature.
Yes, it will work, but not all things that work are recommended. If you edit a core, it will work, but is that a good thing to do?
I’m not suggesting you edit core. If English isn’t your first language, then it’s doubly careful for you to re-read what’s been said because you don’t seem to understand this at all.
1) I said you could use the plugin
2) I said how you could, essentially, make your OWN plugin.
What I’m suggesting people do is make a NEW file and put THAT in mu-plugins. It’s the same thing, effectively, as using the plugin and putting THAT in mu-plugins. You are never editing core. You’re making a plugin. I call it a ‘hack’ because it’s not a full-grown ‘I’m gonna support this’ plugin. Both ways are ‘right’, both ways are ‘correct’ and both ways work. Neither way will cause more problems than the other when you upgrade WordPress.
Basically – I get what you’re saying, but you don’t seem to understand what I said. What I said was ‘This is how you can take Digg WP’s code, which works and is great, and apply it to MultiSite without using Use Google Libraries.’
This comment cracked me up lol