[wp-hackers] Adding A CSS Loader
Jamie Holly
hovercrafter at earthlink.net
Mon Apr 23 17:28:15 GMT 2007
> In default-filters.php, there's this:
>
> add_action('wp_head', 'wp_print_scripts');
>
> Which does just what you're thinking, printing out the scripts and
> their dependencies and such. Plugins can indeed use
> wp_enqueue_script() to make it load in the head. The widgets plugin
> did that (before it became integrated into the core, of course).
>
> I'm not sure there's a real need for a CSS specific loading function.
> The entire function is basically just going to be something like this:
>
> `function add_css($cssfile) {
> add_action('wp_head', create_function('$a', 'echo "<link
> rel=\"stylesheet\" href=\"'.$cssfile.'\" type=\"text/css\" />";');
> }`
>
> Because all it will do will add the line to the head. Nothing
> particularly special. Sure, it's a shortened form and a convenience to
> plugin/theme devs, but is it really necessary?
>
>
My original post was that we could use the new method to then add a caching
mechanism to have WP combine all CSS files into one "master" CSS file that
could be generated and stored/called from a server writeable directory (ie -
cache or uploads). That way when you got a bunch of plugins working off this
system, instead of having all those make additional server requests for
their independent CSS file, a single CSS file would load. Of course we would
have to look at options, such as enabling/disabling the caching and a cache
delete function for plugin updates.
Jamie Holly
http://www.intoxination.net
More information about the wp-hackers
mailing list