Hi Preeminent,
Yes and No - Plugins are really a series of functions run in a specific order, or at specific times.
With WordPress, you can add functions that you would normally run in a plugin from functions.php. Essentially, anything that is available for plugins, can be used in functions.php.
The code I provided is to load JQuery from Google in your header. It can be called in a plugin, or it can be called directly from the functions.php file.
The add_action on 'wp_print_scripts' will run all the commands in the function you define:
http://codex.wordpress.org/Function_Reference/add_action
The call of
add_action('wp_print_scripts','add_google_jquery');
Basically tells WordPress to run your function add_google_jquery just before WordPress prints registered JavaScript scripts into the page header (wp_print_scripts).
The function itself uses the wordpress enqueue script function to make sure that jQuery is loaded properly.
Once you have all the code in, jQuery will automatically be loaded when you site loads. (I made a small mod to the code below by removing the ( ) around the link to the google jquery).
function add_google_jquery() {
if ( !is_admin() ) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js', false);
wp_enqueue_script('jquery');
}
}
add_action('wp_print_scripts ', 'add_google_jquery');
It's worthwhile spending some time looking at the Action Reference for WordPress:
http://codex.wordpress.org/Plugin_API/Action_Reference
To load you scripts in the footer, you need to look at the wp_enqueue_script function:
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
Currently, the function above will load jQuery into the header.
To load your script in the footer, you would use:
function add_google_jquery() {
if ( !is_admin() ) {
wp_deregister_script('jquery');
wp_enqueue_script('jquery','http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js',,'1.4.1',true);
}
}
add_action('wp_print_scripts ', 'add_google_jquery');
In the above example, I've removed the wp_register_script and done it all in the wp_enqueue_script function.
I would recommend testing loading the function in your header first and then test the moving of the script to the footer.
To test if this working, load your site without the function active. Check your page source and see what / where jquery is loaded - in most standard WP Themes, it's called from the wp-includes folder.
Activate your function, load your site with the function activated and check the page source again. If the function is working correctly, you'll see jquery being loaded from the Google CDN.
Charly