Is there a function to replace the active theme’s stylesheet with a different one (not just adding a new one, but actually replacing the current one)?
I’m developing a plugin, and using shortcodes (eg: [design style=”dark”]) and I want this shortcode to remove the current stylesheet and apply a new one, along with new HTML for the page as well.
In fact, I want this shortcode to completely replace all of the source code for that specific post.
Can anybody point me in the right direction? Thanks in advance.
Main stylesheet of theme is surprisingly rigid concept. It is usually semi-hardcoded in
header.php
before any meaningful hooks and is very hard to change by code and reliably.Since your context is actually wider and includes markup as well, you are better of hijacking template entirely, see
template_redirect
action for starters.AFAIK there is no such function what you’re asking for.
You might want to look at the Theme Switch and Preview plugin, uses shortcodes ([nkthemeswitch]).