Problems adding stylesheet switcher to Options Framework Theme for WordPress

I have a problem adding a css style switcher to my Theme Options using the Options Framework Theme by Devin Price.
Everything seem to go fine but when I output the option I get 1.css 2.css 3.css instead of actual filename.

This is what I do:

Read More

I Pull all the Stylesheets in ‘styles’ directory into an array:

$alt_stylesheet_path = get_template_directory() . '/styles/';
$alt_stylesheets = array();
if ( is_dir($alt_stylesheet_path) ) {
    if ($alt_stylesheet_dir = opendir($alt_stylesheet_path) ) {
        while ( ($alt_stylesheet_file = readdir($alt_stylesheet_dir)) !== false ) {
            if(stristr($alt_stylesheet_file, ".css") !== false) {
                $alt_stylesheets[] = $alt_stylesheet_file;
            }
        }
    }
}

Then I create the option panel

$options[] = array(
    'name' => __('StyleSheet', 'mytheme'),
    'desc' => __('Select a color scheme', 'mytheme'),
    'id' => 'alt_stylesheet',
    'type' => 'select',
    'options' => $alt_stylesheets,
    "std" => "default.css");

And I call it this way in header.php

<link rel="stylesheet" href="<?php echo bloginfo('template_directory')?>/styles/<?php echo of_get_option('alt_stylesheet'); ?>.css" type="text/css" media="screen" />

How can I output the css file name (ex: green.css blue.css) instead of the option id (1.css, 2.css) ?

Any help would be much appreciated since I already lost a day trying. Thank you

Related posts

Leave a Reply