For the options page this might help, read the comments as there is a small issue, download the sample theme as the code below is based on it but not tested!
The Stylesheets
Create a folder in the theme called /styles/ and add in your alternate stylesheets.
These can only change fonts, colors and graphics not the layout, give them a friendly lowercase names like crimson.css, purple.css, blue.css, colbolt.css.
NOTE: Based on a childtheme and using STYLESHEETPATH change to TEMPLATEPATH if not creating a Child Theme.
In the theme-options.php.php add a function to get the stylesheet names and a variable.
// Get the Stylesheets
function sa_list_styles(){
$path = STYLESHEETPATH .'/styles/';
$list = array();
$dir_handle = @opendir($path) or die("Unable to open $path");
while($file = readdir($dir_handle)){
if($file == "." || $file == ".."){continue;}
$filename = explode(".",$file);
$cnt = count($filename); $cnt--; $ext = $filename[$cnt];
$name = $filename[0];
if(strtolower($ext) == ('css') ) {
$list[$name] = array( 'value' => $name, 'label' => $name );
}
}
return $list;
}
$sa_css = sa_list_styles();
array_unshift($sa_css, "");
Add in the stylesheet options in the general section for switching stylesheets.
// Default options values
$sa_general = array(
'default_css' => '',
'footer_copyright' => '? ' . date('Y') . ' ' . get_bloginfo('name'),
'intro_text' => '',
'featured_cat' => '',
);
Then to display the option on the options page.
<tr valign="top"><th scope="row"><label for="default_css">Default Stylesheet</label></th>
<td>
<select id="default_css" name="sa_general[default_css]">
<?php
foreach ( $sa_css as $style ) :
$label = $style['label'];
$selected = '';
if ( $style['value'] == $settings['default_css'] )
$selected = 'selected="selected"';
echo '<option style="padding-right: 10px;" value="' . esc_attr( $style['value'] ) . '" ' . $selected . '>' . $label . '</option>';
endforeach;
?>
</select>
</td>
</tr>
header.php
$settings = get_option( 'sa_general' );
if( isset( $settings['default_css']) && $settings['default_css'] ) {
wp_register_style( 'customstyle', get_stylesheet_directory_uri() .'/styles/'.$settings['default_css'] .'.css', '', '0.1' );
wp_enqueue_style( 'customstyle' );
}
That is about it!
David