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

Krusty Ruffle krustyruffle at rustykruffle.com
Sat Nov 1 15:38:30 GMT 2008

Okay, after sleeping a whole bunch, recovering from some bad meat I ate, and
reading all the replies here this is what I ended up with:


// 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
        // set the timing to 9 to match the timing WP 2.7 will have when it
comes out
        add_action('wp_head', 'wp_print_styles', '9');

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


Thanks for all of the advice and help, I think this is working right now,
though I do think there may be issues with the timing of it. I'm thinking I
want this file to be the last .css file linked in the head, but I suppose it
could be filled with lots of !important's to override cascades. I think
there will still be a lot of plugins echoing links in there with the wp_head
action, and I think most of them will be running on a default timing of 10.

That just made me think. Should I set the init action to a later speed so
that I can try to ensure that this .css file is at least at the end of the
wp style queue?

On Fri, Oct 31, 2008 at 6:16 AM, Viper007Bond <viper at viper007bond.com>wrote:

> Default priority is 9.
> On Fri, Oct 31, 2008 at 1:37 AM, Ryan McCue <ryanmccue at cubegames.net>
> wrote:
> > Callum Macdonald wrote:
> > > Worst case scenario, it'll be called twice on 2.7. But that won't
> output
> > > the styles twice. The overhead will be minimal.
> > >
> >
> > As long as the priority, action and callback are the same, it won't add
> > it twice, but rather it will simply overwrite the first. (Unless, of
> > course, it doesn't work the way I think it does from memory.)
> >
> > --
> > Ryan McCue
> > <http://cubegames.net/>
> >
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> --
> Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/
> _______________________________________________
> 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