[wp-hackers] Selective CSS based on Shortcode?

Ken Newman Ken at adcSTUDIO.com
Thu Jan 28 00:07:50 UTC 2010


On 1/27/2010 3:32 AM, Matthew Kettlewell wrote:
> I'm wanting to override CSS in posts that use a shortcode from my
> plugin....
>
> problem is that I'm not sure how to go about doing this...
>
> I'm using add_shortcode() to check in the post contents for the shortcode,
> but I'm needing to know if the shortcode is used when I'in in header.php.
>
> I've tried setting meta_data in my function that is called from
> add_shortcode(), but it's too late...
>
> Is there a way to get the shortcode value before header.php is called?
>
> Thanks
> Matt
>
>    
You could just output your styles into the content output, and use an 
html 5 doctype.

It's also interesting to note that with HTML 5, style tags are 
allowed/appropriate in the content and Valid according to the spec. :-) 
Further, most/all browsers support it (it was only considered bad 
practice due to standards) and as HTML 5 support improves, browsers will 
support the scoped attribute! As for the benifits of enqueing styles, 
perhaps a patch: if enque after head, place in content, else default 
behavior? I don't know too much about the internal workings there.

Tho the solutions involving buffering will still probably be appropriate 
for scripts.


More information about the wp-hackers mailing list