2déc/090
Including JS and CSS in WP Header
Lot of people add Javascript and Css file by "echoing" them from theyre extension.
WordPress allow you to add correctly them to the page's head by using two functions :
// Add a new script file wp_enqueue_script($handle, $src, $deps, $ver, $in_footer); wp_enqueue_script('jsfoo', '/wp-content/plugins/myplugin/JS/foo.js'); // Add a new stylesheet wp_enqueue_style($handle, $src, $deps, $ver, $media); wp_enqueue_style('main', '/wp-content/plugins/myplugin/main.css');
For more informations :
wp_enqueue_style();
wp_enqueue_script();
