[wp-hackers] requesting information about wp_*_style functions

Krusty Ruffle krustyruffle at rustykruffle.com
Thu Oct 30 05:33:45 GMT 2008


I found a couple of big blunders in the cade I posted before...

First, this line is wrong, if I'm looking at the parentheses right then that
would always evaluate to true as the template directory would always exist.
Unless you've deleted it without changing themes, but even then it would
change to the default and probably still be true...

    if (file_exists (get_template_directory()) . '/tweaks.css'){

Also, the calls to template functions will not work correctly if you are
using a 'child theme'. I've fixed them with stylesheet stuff instead, now
what I have looks like this:


// Include a link to the current templates tweaks.css if it exists...
function krusty_plugstyles(){
    if(file_exists(STYLESHEETPATH . '/tweaks.css')){
        // register and enqueue our css for later addition into the head of
the page
get_stylesheet_directory_uri() . '/tweaks.css', array(), '', 'screen');

        // since wp_print_styles() doesn't seem to run by default
        // we add a call to it with the wp_head action hook
        add_action('wp_head', 'wp_print_styles', '100');

// add an action to call our function when wordpress starts loading a page
add_action('init', 'krusty_plugstyles');


I'm still wondering if I should use a conditional on the wp_head ation or
not though...

Thanks again for the help :)


More information about the wp-hackers mailing list