[wp-hackers] Adding A CSS Loader

Computer Guru computerguru at neosmart.net
Mon Apr 23 19:17:27 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris wrote:
> Another point..
> Because CSS files are a cascade, would the order that plugins insert
> their CSS files potentially change the final CSS result?
> Chris

Technically, yes.
In reality, no.

The reason is that if you had

<link rel="stylesheet" href="mycss1.css" />
<link rel="stylesheet" href="mycss2_from_plugin.css" />

it's the same as

$css_text = get_file_contents("mycss1.css");
$css_text .= get_file_contents("mycss2_from_plugin.css");

<link rel="stylesheet" href="dynamicstylesheet.php" />

Order is still there and hasn't changed. Plus, the WP_Filter priority
thing would work great here too...

add_filter("wp_css", "my_css_making_function", -1); //Load this
particular CSS before anything else. -1 is the priority here.


One more workaround:
append !important to css that needs to be prioritized (i.e. it overrides
some other CSS from somewhere else, doesn't define something new)

e.g.

CSS1:
.p {
font-family: arial;
}

CSS2:
.p {
font-family: Calibri !important;
}

the !important tells the browser that if there is another .p CSS
definition defined elsewhere, use prioritize this particular line instead.

CHeers!

- --
Computer Guru
NeoSmart Technologies
http://neosmart.net/blog/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGLQZH3SICh4XKUt0RAswQAJ9eZOIwfG/cauP5CCQ4frhcxX7JgwCg3Zbl
fi/0Pfcov5i3tYmOzDzTftE=
=501F
-----END PGP SIGNATURE-----


More information about the wp-hackers mailing list