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

DD32 wordpress at dd32.id.au
Thu Oct 30 05:42:27 GMT 2008


Just a FYI:
As of WordPress 2.7, The Print styles hook is included in core for  
front-end requests too:
http://trac.wordpress.org/browser/trunk/wp-includes/default-filters.php#L165

add_action('wp_head', 'rsd_link');
add_action('wp_head', 'wlwmanifest_link');
add_action('wp_head', 'locale_stylesheet');
add_action('publish_future_post', 'check_and_publish_future_post', 10, 1);
add_action('wp_head', 'noindex', 1);
add_action('wp_head', 'wp_print_styles', 9);
add_action('wp_head', 'wp_print_scripts');
add_action('wp_head', 'wp_generator');

On Thu, 30 Oct 2008 16:33:45 +1100, Krusty Ruffle  
<krustyruffle at rustykruffle.com> wrote:

> DOLP!!
>
> 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:
>
> <?php
>
> // 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
>         wp_register_style('krusted-plugstyles',
> get_stylesheet_directory_uri() . '/tweaks.css', array(), '', 'screen');
>         wp_enqueue_style('krusted-plugstyles');
>
>         // 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 :)
>
> ~Krusty
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>




More information about the wp-hackers mailing list