I'm creating my first Wordpress plugin. It's going good.
My question is getting the JS and CSS files written in the head.
I have used this code:
PHP Code:
add_action('wp_head', 'addHeaderCode');
function addHeaderCode() {
echo "\n".'<!-- Start Obama2008 -->'."\n";
echo '<link type="text/css" rel="stylesheet" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/obama2008ribbon/obama2008ribbon.css" />' . "\n";
wp_register_script('obama2008ribbon', get_bloginfo('wpurl') . '/wp-content/plugins/obama2008ribbon/obama2008ribbon.js');
wp_print_scripts('obama2008ribbon');
echo '<!-- End Of Obama2008 -->'."\n";
}
This code WORKS, but is this the best way to do it?
Bookmarks