Hey Jean,
You can request any one of the various libraries WordPress comes
pre-packaged with using the wp_enqueue_script function in your theme or
plugins' functions.php file:
http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress
This section of the codex outlines the various libraries you can utilize
and all you have to do is use the corresponding handle as an argument
in the function. I would write a function that handles loading of all my
frontend scripts and hook into 'wp_enqueue_scripts' to load them on the
frontend. A basic implementation could look something like this:
<?php
// Add necessary JS scripts to
frontend
add_action('wp_enqueue_scripts',
'MYTHEME_frontend_js_scripts');
function
MYTHEME_frontend_js_scripts() {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core', false, array('jquery'));
wp_enqueue_script('jquery-ui-mouse', false , array('jquery'));
wp_enqueue_script('thickbox');
wp_enqueue_script('jquery-hotkeys', false , array('jquery'));
}
?>
The same could be done for a plugin or theme requiring certain libraries
on the admin side by hooking into the 'admin_enqueue_scripts' action.
Hope this helps,
Friday, April 27,
2012 10:31 AM