Geeky Nuggets

Stylesheet Chooser Version 0.2

September 02, 2004 | 2 Minute Read

This plugin is deprecated.

I had tried for a while to find a way to allow users to choose their favorite theme for this website. I decided to do it as a Wordpress plugin, which I offer today for other Wordpress users.

Installing it is quite simple: Download, rename to stylesheet_chooser.php, upload it to your wp-contents/plugins directory and activate it from the admin interface.

To define which stylesheets to use (no, it’s not automatic…), you have to define an array called $styles, before you call any of the other functions.You can do it like this, for example :

$styles=array("styles/default","styles/no-style")

if your stylesheets are in the styles directory. Omit the ‘.css’ part. The first one in the list will be used as your default style. The plugin will automatically select the last part of the path (in this case new, default and no-style) and use them as the text in the selection box. The optional parameter - for example style_link(false) - can be set to ‘true’ (default) if you want to @import the style sheets (ignored by NS4), or to ‘false’ to get this kind of links: <link rel=”stylesheet” title=”….> for the current chosen style sheet and like this:<link rel=”alternate stylesheet” title=”….> for the other(s).

style_chooser() will insert the form that is used to select the stylesheet. Place it wherever you want, in your sidebar for example.

In version 0.23+, it is possible to have a short comment appear below the selection dropdown. For this, the only thing you have to do is insert it in your stylesheets like this:

/*
Comment: Write your comment here.
*/

And that’s it, now each stylesheet has it’s own “introduction text”.

Now that you know all this, you can :

  • Download
  • write a comment,
  • or Contact me in case you have problems