I have written a small class that will handle enqueues in my theme :
<?php
class Header {
public function init_hooks()
{
add_action('wp_print_scripts', array(__CLASS__,'include_all_files'));
}
public function include_css_files()
{
wp_register_script('style.css', get_bloginfo('stylesheet_url'));
wp_enqueue_script('style.css');
}
public function include_js_files()
{
wp_register_script('jquery-min', "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js");
wp_enqueue_script('jquery-min');
}
public function include_all_files()
{
$this->include_css_files();
$this->include_js_files();
}
}
?>
I call it right before closing the head tag, like :
$header = new Header();
$header->init_hooks();
But it does not work. There is no error, but no script is added. Any ideas ?
<head>
tag, that's too late for the enqueues. The code needs to run beforewp_head()
does..