Plugin Directory

Changeset 686557


Ignore:
Timestamp:
03/24/2013 10:27:08 AM (13 years ago)
Author:
danielauener
Message:

tagging version 2.0

Location:
color-scheme-every-theme
Files:
10 edited
8 copied

Legend:

Unmodified
Added
Removed
  • color-scheme-every-theme/tags/2.0/classes/ColorExtractor.class.php

    r678985 r686557  
    33    class Cset_ColorExtractor {
    44
    5         var $current_css_tmpl = false;
    6 
    7         public function __construct() {
    8             $uploads = wp_upload_dir( );
    9             $current_theme = wp_get_theme( );
    10             $this->current_css_tmpl = $uploads['basedir'].'/color-scheme-'.$current_theme->Name.'-'.$current_theme->Version.'.tss';
    11         }
    12 
    135
    146        private function rglob($pattern='*', $flags = 0, $path='') {
    15             $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
    16             $files = glob($path.$pattern, $flags);
    17            
    18             if (!is_array($paths) || !is_array($files)) return array();
    19 
     7            $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
     8            $files=glob($path.$pattern, $flags);
    209            foreach ($paths as $path) { $files=array_merge($files,$this->rglob($pattern, $flags, $path)); }
    21            
    2210            return $files;
    2311        }
     
    4230
    4331
    44         public function get_custom_styles() {
    45             if (file_exists($this->current_css_tmpl)) {
    46                 $styles = file_get_contents($this->current_css_tmpl);
    47                 $styles = preg_replace('/\/\*(.|\\n|\\r)+\*\//',"",$styles);
    48                 return $styles;
    49             }
    50             return '';
    51         }
    52 
    53 
    54         public function color_scheme_exists() {
    55             if (!file_exists($this->current_css_tmpl)) {
    56                 return false;
    57             }
    58             return true;
    59         }
    60 
    61 
    62         public function get_color_scheme() {
    63             if ($this->color_scheme_exists()) {
    64                 $scheme = file_get_contents($this->current_css_tmpl);
    65                 if (preg_match_all('/\$color-[0-9]+/',$scheme, $colors)) {
    66                     return $colors;
    67                 }
    68             }
    69             return false;
    70         }
    71 
    72 
    73         public function get_default_scheme() {
    74             if ($this->color_scheme_exists()) {
    75                 $scheme = file_get_contents($this->current_css_tmpl);
    76                 $start = strpos($scheme,"/*");
    77                 $stop = strpos($scheme,"*/");
    78                 if ($start >= 0 && $stop >= 0) {
    79                     return substr($scheme,$start,$stop-$start+2);
    80                 }
    81             }
    82             return false;
    83         }
    84 
    85 
    86         public function extract_color_scheme() {
     32        public function extract_color_scheme( $theme_dir, $css_tmpl ) {
    8733            $regex = array(
    8834                "`^([\t\s]+)`ism"=>'',
     
    9238                "`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism"=>"\n"
    9339            );
     40           
    9441            $replace_colors = array();
    9542            $color_rules = array();
    96             $default_colors = array();     
    97             $css_files = $this->rglob('*.css',0,get_stylesheet_directory());
    98             foreach ($css_files as $css_file) {
    99                 $clean_css = preg_replace(array_keys($regex),$regex,file_get_contents($css_file));         
    100                 $clean_css = str_replace(array("\r\n","\r","\n"),"",$clean_css);
    101                 foreach ($this->parse_css($clean_css) as $selector => $rules) {
    102                     foreach ($rules as $property => $value) {
    103                         if (preg_match_all('/#[a-f0-9]{3,6}/i',$value, $colors)) {
     43            $default_colors = array();         
     44           
     45            foreach ( $this->rglob( '*.css', 0, $theme_dir ) as $css_file ) {
     46               
     47                $clean_css = preg_replace( array_keys( $regex ), $regex, file_get_contents($css_file) );           
     48                $clean_css = str_replace( array( "\r\n", "\r", "\n" ), "", $clean_css );
     49               
     50                foreach ( $this->parse_css( $clean_css ) as $selector => $rules ) {
     51                   
     52                    foreach ( $rules as $property => $value ) {
     53                       
     54                        if ( preg_match_all( '/#[a-f0-9]{3,6}/i',$value, $colors ) ) {
     55                           
    10456                            foreach ($colors as $color) {
    105                                 $color_id = (isset($replace_colors[$color[0]])) ? $replace_colors[$color[0]] : '$color-'.(count($replace_colors)+1);
     57                           
     58                                $color_id = (isset($replace_colors[$color[0]])) ? $replace_colors[ $color[0] ] : '$color-'.( count( $replace_colors ) + 1 );
    10659                                $replace_colors[$color[0]] = $color_id;
    10760                                $default_colors[$color_id] = $color[0];
     61                           
    10862                            }
    109                             $color_rules[$property.":".$value][] = $selector;
     63                           
     64                            $color_rules[$property.":".$value][] = '$scheme_name '.$selector;
     65                       
    11066                        }
    111                         if (preg_match_all('/(rgba|rgb|hsl|hsla)\([0-9\,\.]+?\)/',$value, $colors)) {
     67                       
     68                        if ( preg_match_all( '/(rgba|rgb|hsl|hsla)\([0-9\,\.]+?\)/', $value, $colors ) ) {
     69                           
    11270                            foreach ($colors[0] as $color) {
     71                           
    11372                                $color_id = (isset($replace_colors[$color[0]])) ? $replace_colors[$color[0]] : '$color-'.(count($replace_colors)+1);
    11473                                $replace_colors[$color] = $color_id;
    11574                                $default_colors[$color_id] = $color;
     75                           
    11676                            }
    117                             $color_rules[$property.":".$value][] = $selector;                               
     77                           
     78                            $color_rules[$property.":".$value][] = '$scheme_name '.$selector;                               
    11879                        }
     80
    11981                    }
    12082                }
    12183            }
     84           
     85            $css_template = "";
     86           
     87            foreach ($color_rules as $color_rule => $selectors) {
     88                $css_template .= implode(",\n",$selectors)."{\n\t".$color_rule.";\n}\n";
     89            }
    12290
    123             if (!empty($css_files)) {
    124                 $default_colors_template = "/**\n * Default colors\n *\n";
    125                 foreach ($default_colors as $color_id => $default_color) {
    126                     $default_colors_template .= " * ".$color_id.": ".$default_color.";\n";
    127                 }
    128                 $default_colors_template .=  " */\n\n\n";
    129                
    130                 $css_template = "";
    131                 foreach ($color_rules as $color_rule => $selectors) {
    132                     $css_template .= implode(",\n",$selectors)."{\n\t".$color_rule.";\n}\n";
    133                 }
    134                 $css_template = str_replace(array_keys($replace_colors),$replace_colors,$css_template);
    135                 file_put_contents($this->current_css_tmpl,$default_colors_template.$css_template);         
    136             } else {
    137                 if (file_exists($this->current_css_tmpl)) {
    138                     unlink($this->current_css_tmpl);   
    139                 }
    140             }
     91            $css_template = str_replace( array_keys( $replace_colors ), $replace_colors, $css_template );
     92            file_put_contents( $css_tmpl, $css_template );
     93
     94            return $default_colors;
    14195        }
    14296    }
  • color-scheme-every-theme/tags/2.0/classes/Cset.class.php

    r673507 r686557  
    1313            $this->options = new Cset_Options();
    1414
     15            $this->schemes = array_merge(
     16                $this->options->get_schemes(),
     17                $this->schemes
     18            );
     19
    1520            add_action( 'customize_register', array($this,'customize_register') ); 
    16             add_action( 'wp_head', array($this,'customize_css' ) );     
     21            add_action( 'wp_head', array($this,'customize_css' ) );
    1722       
    1823        }
     
    5358            if (isset($this->schemes[get_theme_mod('color_scheme')])) {
    5459                $customized_script = new Cset_View("custom_styles");
    55                 $css_extractor = new Cset_ColorExtractor();
    56                 $styles = $css_extractor->get_custom_styles();
     60
     61                $styles = "";
     62                if (file_exists(($current_css_tmpl = $this->options->get_css_templ()))) {
     63                    $styles = file_get_contents($current_css_tmpl);
     64                }
     65
    5766                $styles = str_replace(
    5867                    array_reverse(array_keys($this->schemes[get_theme_mod('color_scheme')])),
     
    6069                    $styles
    6170                );
     71
     72                $styles = str_replace('$scheme_name ','',$styles);
     73
    6274                $customized_script->set('styles', $styles);
    6375                echo $customized_script->render();             
    6476            }
     77
     78            if (get_option('dynamic_theme_colors')) {
     79
     80                $customized_js = new Cset_View("js_schemes_array");
     81                $all_styles = "";
     82                $styles = file_get_contents($current_css_tmpl);
     83                $schemes = array();
     84               
     85                foreach ($this->schemes as $name => $colors) {
     86                    $name = 'cset-scheme-'.$name;
     87                    $mod_styles = str_replace(
     88                        array_reverse(array_keys($colors)),
     89                        array_reverse($colors),
     90                        $styles
     91                    );
     92                    $all_styles .= str_replace('$scheme_name','.'.$name,$mod_styles);   
     93                    $schemes[] = $name;                 
     94                }
     95
     96                $customized_script->set('styles', $all_styles);
     97                echo $customized_script->render();
     98
     99                $customized_js->set('schemes',$schemes);
     100                echo $customized_js->render();
     101            }
    65102        }
    66103    }
  • color-scheme-every-theme/tags/2.0/classes/Options.class.php

    r673507 r686557  
    66    class Cset_Options { 
    77       
     8        private $plugin_path = "";
     9
    810        private $options = array();
    911
     
    1214        private $css_extractor = null;
    1315
     16        private $current_css_tmpl = "";
     17
     18        private $current_theme_dir = "";
     19
     20        private $current_theme = "";
     21
    1422
    1523        public function __construct() {
     24
     25            $this->plugin_path = "/wp-content/plugins/".plugin_basename(dirname(dirname(__FILE__)));
     26
     27            if ( !( $this->options = get_option( 'cset_schemes' ) ) ) {
     28                $this->options = array();
     29            }
     30
    1631            add_action('admin_menu',array(&$this,'add_admin_options_menu'));
    1732            add_action('admin_init',array(&$this,'register_admin_options'));
    18            
     33
     34            $uploads = wp_upload_dir( );
     35            $this->current_theme = wp_get_theme( );
     36            $this->current_css_tmpl = $uploads['basedir'].'/color-scheme-'.$this->current_theme->Name.'-'.$this->current_theme->Version.'.tss';
     37            $this->current_theme_dir = get_stylesheet_directory();
     38
    1939            $this->options_view = new Cset_View("options");
    2040            $this->css_extractor = new Cset_ColorExtractor();
    2141
    2242            add_filter('plugin_action_links_color-scheme-every-theme/color-scheme-every-theme.php',array(&$this,'settings_link'));
    23        
    24             if (isset($_REQUEST['generate_color_scheme']) && $_REQUEST['generate_color_scheme'] == '1') {
    25                 $this->css_extractor->extract_color_scheme();
     43
     44            add_action( 'admin_enqueue_scripts', array( $this,'enqueue_css_js' ) );
     45
     46            $this->generate_scheme();
     47            $this->save_schemes();
     48
     49        }
     50
     51
     52        public function generate_scheme() {
     53            if (isset($_REQUEST['generate_color_scheme'])) {
     54
     55                if ( !array_key_exists( $this->current_theme->Name, $this->options ) ) {
     56                    $this->options[$this->current_theme->Name] = array();   
     57                }
     58               
     59                $this->options[$this->current_theme->Name][0] = $this->css_extractor->extract_color_scheme( $this->current_theme_dir, $this->current_css_tmpl );
     60                update_option( "cset_schemes", $this->options);
     61           
     62            }
     63        }
     64
     65        public function save_schemes() {
     66            if (array_key_exists('schemes',$_REQUEST) && array_key_exists($this->current_theme->Name,$_REQUEST['schemes'])) {
     67                foreach ($_REQUEST['schemes'][$this->current_theme->Name] as $scheme_idx => $scheme_colors) {
     68                    $scheme_idx++;
     69                    $this->options[$this->current_theme->Name][$scheme_idx] = array();
     70                    foreach ($scheme_colors as $color_idx => $color) {
     71                        $this->options[$this->current_theme->Name][$scheme_idx]["$".$color_idx] = $color;
     72                    }
     73
     74                }
    2675            }
    2776
     77            if (array_key_exists('delete_schemes',$_REQUEST) && array_key_exists($this->current_theme->Name,$_REQUEST['delete_schemes'])) {
     78                foreach ($_REQUEST['delete_schemes'][$this->current_theme->Name] as $scheme_idx => $delete) {
     79                    $scheme_idx++;
     80                    if ($delete == 1) {
     81                        unset($this->options[$this->current_theme->Name][$scheme_idx]);
     82                    }
     83                }
     84            }
     85
     86            if ( array_key_exists('new_scheme_changed',$_REQUEST) && $_REQUEST['new_scheme_changed'] && array_key_exists("new_scheme",$_REQUEST) && is_array($_REQUEST["new_scheme"])) {
     87                $scheme = array();
     88                foreach ($_REQUEST["new_scheme"] as $color_idx => $color) {
     89                    $scheme["$".$color_idx] = $color;
     90                }
     91                $this->options[$this->current_theme->Name][] = $scheme;
     92            }
     93
     94            update_option( "cset_schemes", $this->options);
     95
     96        }
     97
     98
     99        public function get_css_templ() {
     100            return $this->current_css_tmpl;
     101        }
     102
     103       
     104        public function get_schemes() {
     105            $schemes = array();
     106            if (array_key_exists($this->current_theme->Name,$this->options)) {
     107                foreach ($this->options[$this->current_theme->Name] as $scheme_idx => $scheme) {
     108                    $schemes["custom-scheme-"+$scheme_idx] = $scheme;
     109                }
     110            }
     111            return $schemes;
    28112        }
    29113
     
    36120
    37121
     122        public function enqueue_css_js() {
     123            wp_enqueue_style('cset-options',site_url().$this->plugin_path.'/views/css/options.css');
     124            wp_enqueue_script('cset-options',site_url().$this->plugin_path.'/views/js/options.js');
     125        }
     126       
     127
    38128        public function register_admin_options() {
    39             register_setting('color-scheme-every-theme','gmaps_api_key');
     129            register_setting('cset','default_scheme');
     130            register_setting('cset','custom_schemes');
     131            register_setting('cset','dynamic_theme_colors');
    40132        }
    41133
     
    46138                'Color Scheme every Theme',
    47139                'manage_options',
    48                 'color-scheme-every-theme',
     140                'cset',
    49141                array($this,'print_admin_options_page')
    50142            );
     
    56148                wp_die(__('You do not have sufficient permissions to access this page.', 'cset'));
    57149            }
    58 
    59             $this->options_view->set('template_exists', $this->css_extractor->color_scheme_exists());
    60             $this->options_view->set('colors', $this->css_extractor->get_color_scheme());
    61             $this->options_view->set('default_colors', $this->css_extractor->get_default_scheme());
     150            $this->options_view->set('template_exists', array_key_exists( $this->current_theme->Name, $this->options ) );
     151            $this->options_view->set('colors', $this->options);
     152            $this->options_view->set('theme', $this->current_theme->Name);
    62153            echo $this->options_view->render();
    63154        }
  • color-scheme-every-theme/tags/2.0/color-scheme-every-theme.php

    r678985 r686557  
    44    Plugin URI: http://www.danielauener.com/color-scheme-every-theme
    55    Description: This plugin lets you change the entire color scheme of the current theme via the theme customizer.
    6     Version: 1.2
     6    Version: 2.0
    77    Author: @danielauener
    88    Author URI: http://www.danielauener.se
  • color-scheme-every-theme/tags/2.0/readme.txt

    r678985 r686557  
    55Requires at least: 3.4
    66Tested up to: 3.5
    7 Stable tag: 1.2
     7Stable tag: 2.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2828A more detailed description is available on my blog [http://www.danielauener.com/color-scheme-every-theme/](http://www.danielauener.com/color-scheme-every-theme/). You are wellcome to give feedback/ask questions directly on my blog as well.
    2929
     30Read about the new features in version 2.0 here: [http://www.danielauener.com/color-scheme-every-theme/](http://www.danielauener.com/color-scheme-every-theme/). You are wellcome to give feedback/ask questions directly on my blog as well.
     31
    3032There is even a github-repository on: [https://github.com/danielauener/color-scheme-every-theme/](http://github.com/danielauener/color-scheme-every-theme/)
    3133
     
    4547
    46481. Theme customizer
     492. Edit color schemes directly on the settings page
    4750
    4851== Changelog ==
     
    5457* Fixed a bug that resulted in a blank page after generating the color scheme - thanks to Stiaan for reporting the bug and Ulrich P for helping me to reproduce it!
    5558
    56 = 1.11 =
    57 * Handle situations where no theme is activated or the current theme has no css file in it.
     59= 2.0 =
     60* Testet for multisite environment
     61* Making schemes editable on the settings page
     62* Adding an option to make all color schemes available on the front-end, could
     63be used for a javascript color scheme switcher
  • color-scheme-every-theme/tags/2.0/views/color_scheme_control.view.php

    r673507 r686557  
    33        <input type="radio" name="color_scheme" <?php echo $link; ?> value="<?php echo $name; ?>" /><?php echo $name; ?>
    44        <div style="height:50px;margin:10px 0;position:relative;"><?php
    5             asort($scheme);
    65            $color_count = count($scheme);
    76            foreach ($scheme as $color) : ?>
  • color-scheme-every-theme/tags/2.0/views/options.view.php

    r678985 r686557  
    33    <h2><?php _e("Color Scheme every Theme settings", 'cset'); ?></h2>
    44    <form method="post" action="options.php">
    5         <?php settings_fields('color-scheme-every-theme'); ?>
     5        <?php settings_fields('cset'); ?>
     6        <h3><?php _e("Existing schemes"); ?></h3>
     7        <table class="form-table">         
     8            <?php if (!$template_exists || count($colors[$theme]) == 0) : ?>
     9                <tr valign="top">
     10                    <th scope="row"><?php _e('Color Schemes', 'cset') ?></th>
     11                    <td>
     12                        <p><?php _e("There is no color scheme generatad for your current theme.", 'cset'); ?></p>
     13                    </td>
     14                </tr>
     15            <?php else: ?>
     16                <tr valign="top">
     17                    <th scope="row"><?php _e('Color Schemes', 'cset') ?></th>
     18                    <td><?php
     19                        foreach ($colors[$theme] as $scheme_idx => $theme_colors) : ?>
     20                            <div class="scheme">
     21                                <input type="hidden" class="delete-flag" name="delete_schemes[<?php echo $theme; ?>][<?php echo $scheme_idx-1; ?>]" value="0" />
     22                                <div class="scheme-name">
     23                                    <b>Scheme <?php echo ($scheme_idx == 0) ? __('default') : $scheme_idx; ?></b>
     24                                </div>
     25                                <div class="scheme-colors"><?php
     26                                    $width = 100/count($theme_colors);
     27                                    $color_idx = 1;
     28                                    foreach ($theme_colors as $color) : ?>
     29                                        <div style="width:<?php echo $width; ?>%;background:<?php echo $color; ?>;" class="scheme-color-<?php echo $color_idx; ?> scheme-color">
     30                                            <?php if ($scheme_idx > 0): ?>
     31                                                <input type="hidden" name="schemes[<?php echo $theme; ?>][<?php echo $scheme_idx-1; ?>][color-<?php echo $color_idx; ?>]" value="<?php echo $color; ?>" />
     32                                            <?php endif; ?>
     33                                        </div><?php
     34                                        $color_idx++;
     35                                    endforeach; ?>
     36                                </div><?php
     37                                if ($scheme_idx == 0): ?>
     38                                    <p class="description"><?php _e("The default colors, extracted from your current theme."); ?></p><?php
     39                                else: ?>
     40                                    <p>
     41                                        <a class="color-scheme-embed" href="#" ><?php _e('< embedd in theme >'); ?></a>
     42                                        | <a class="color-scheme-delete" href="#" ><?php _e('delete'); ?></a>
     43                                    </p>
     44                                    <p class="embed">
     45                                        <label><?php _e('Add this to the <em>functions.php</em> of your theme:'); ?></label>
     46                                        <textarea class="embed-code" rows="10" style="width:100%;">if ( function_exists( 'cset_add_color_scheme' ) ) {
     47    cset_add_color_scheme( 'cset_scheme-<?php echo $scheme_idx; ?>', array( <?php
     48        echo "\n";
     49
     50        foreach ($theme_colors as $color_idx => $color):
     51            echo "\t\t".'\''.$color_idx.'\' => \''.$color.'\','."\n";
     52        endforeach; ?>
     53    ) );
     54}</textarea></p><?php
     55                                endif; ?>
     56                            </div><?php                     
     57                        endforeach; ?>
     58                    </td>
     59                </tr>
     60            </table>
     61            <h3><?php _e("Add a new scheme"); ?></h3>
     62            <table class="form-table">
     63                <tr valign="top">
     64                    <th scope="row"><?php _e('New color scheme', 'cset') ?></th>
     65                    <td>
     66                        <div id="new-scheme" class="scheme-colors new-scheme">
     67                            <input type="hidden" name="new_scheme_changed" value="0" id="new-scheme-changed" /><?php
     68                            $width = 100/count($theme_colors);
     69                            $color_idx = 1;
     70                            foreach ($colors[$theme][0] as $color) : ?>
     71                                <div style="width:<?php echo $width; ?>%;background:<?php echo $color; ?>;" id="scheme-color-<?php echo $color_idx; ?>" class="scheme-color">
     72                                    <input type="hidden" name="new_scheme[color-<?php echo $color_idx; ?>]" value="<?php echo $color; ?>" />
     73                                </div><?php
     74                                $color_idx++;
     75                            endforeach; ?>
     76                            <div class="new-color">
     77                                <div class="input">
     78                                    <label><?php _e('Change color: '); ?></label><input type="text" id="new-color" class="regular-text" />
     79                                </div>
     80                            </div>
     81                        </div>                                             
     82                    </td>
     83                </tr>
     84            <?php endif; ?>
     85        </table>
     86        <h3><?php _e("Options"); ?></h3>
    687        <table class="form-table">
    788            <tr valign="top">
    8                 <th scope="row"><?php _e('Color Schemes', 'cset') ?></th>
    9                 <td><?php
    10                     if (!$template_exists) : ?>
    11                         <p><?php _e("There is no color scheme generatad for your current theme.", 'cset'); ?></p><?php
    12                         if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') : ?>
    13                             <p style="color:#990000;"><?php _e("There was an error while generating the color scheme. <br />Check if you have an active and working theme and if there is any css-file in your active theme!"); ?></p><?php
    14                         endif;
    15                     elseif ($colors): ?>
    16                         <textarea rows="10" style="width:100%;">if ( function_exists( 'cset_add_color_scheme' ) ) {
    17     cset_add_color_scheme( 'scheme-name', array( <?php
    18                             echo "\n";
    19 
    20                             foreach (array_unique($colors[0]) as $color):
    21                                 echo "\t\t".'\''.$color.'\' => \'#111111\','."\n";
    22                             endforeach; ?>
    23     ) );
    24 }</textarea>
    25                         <p class="description"><?php _e('Add this code to your <b>functions.php</b>, for every color scheme you want to add, and modify the color codes as you whish.', 'cset'); ?></p><br /><br />
    26                         <textarea rows="10" style="width:100%;"><?php
    27                             echo $default_colors;
    28                         ?></textarea>
    29                         <p class="description"><?php _e('These are the default colors, extracted from your current theme.', 'cset'); ?></p><?php
    30                     endif; ?>
     89                <th scope="row"><?php _e('Dynamic theme colors', 'cset') ?></th>
     90                <td>
     91                    <label for="dynamic_theme_colors">
     92                        <input name="dynamic_theme_colors" type="checkbox" id="dynamic_theme_colors" value="1" <?php checked('1', get_option('dynamic_theme_colors')); ?> />
     93                        <?php _e("Embed css for all color schemes in the current theme, so they can be changed dynamically via javascript.", 'cset'); ?>
     94                    </label>                                               
    3195                </td>
    32             </tr>   
    33         </table>
     96            </tr>
     97        </table>       
    3498        <p class="submit">
    35             <input type="hidden" name="generate_color_scheme" value="1" />
    36             <input type="submit" class="button-primary" value="<?php echo ($template_exists) ? _e('Regenerate Color Scheme', 'cset') : _e('Generate Color Scheme', 'cset'); ?>" />
     99            <input id="save-color-schemes" type="submit" name="save_color_schemes" class="button-primary" value="<?php _e('Save Schemes'); ?>" />
     100            <input type="submit" name="generate_color_scheme" class="<?php echo ($template_exists) ? 'button' : 'button-primary'; ?>" value="<?php echo ($template_exists) ? _e('Regenerate Color Scheme', 'cset') : _e('Generate Color Scheme', 'cset'); ?>" />
    37101        </p>
    38102    </form>
  • color-scheme-every-theme/trunk/classes/ColorExtractor.class.php

    r678985 r686557  
    33    class Cset_ColorExtractor {
    44
    5         var $current_css_tmpl = false;
    6 
    7         public function __construct() {
    8             $uploads = wp_upload_dir( );
    9             $current_theme = wp_get_theme( );
    10             $this->current_css_tmpl = $uploads['basedir'].'/color-scheme-'.$current_theme->Name.'-'.$current_theme->Version.'.tss';
    11         }
    12 
    135
    146        private function rglob($pattern='*', $flags = 0, $path='') {
    15             $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
    16             $files = glob($path.$pattern, $flags);
    17            
    18             if (!is_array($paths) || !is_array($files)) return array();
    19 
     7            $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
     8            $files=glob($path.$pattern, $flags);
    209            foreach ($paths as $path) { $files=array_merge($files,$this->rglob($pattern, $flags, $path)); }
    21            
    2210            return $files;
    2311        }
     
    4230
    4331
    44         public function get_custom_styles() {
    45             if (file_exists($this->current_css_tmpl)) {
    46                 $styles = file_get_contents($this->current_css_tmpl);
    47                 $styles = preg_replace('/\/\*(.|\\n|\\r)+\*\//',"",$styles);
    48                 return $styles;
    49             }
    50             return '';
    51         }
    52 
    53 
    54         public function color_scheme_exists() {
    55             if (!file_exists($this->current_css_tmpl)) {
    56                 return false;
    57             }
    58             return true;
    59         }
    60 
    61 
    62         public function get_color_scheme() {
    63             if ($this->color_scheme_exists()) {
    64                 $scheme = file_get_contents($this->current_css_tmpl);
    65                 if (preg_match_all('/\$color-[0-9]+/',$scheme, $colors)) {
    66                     return $colors;
    67                 }
    68             }
    69             return false;
    70         }
    71 
    72 
    73         public function get_default_scheme() {
    74             if ($this->color_scheme_exists()) {
    75                 $scheme = file_get_contents($this->current_css_tmpl);
    76                 $start = strpos($scheme,"/*");
    77                 $stop = strpos($scheme,"*/");
    78                 if ($start >= 0 && $stop >= 0) {
    79                     return substr($scheme,$start,$stop-$start+2);
    80                 }
    81             }
    82             return false;
    83         }
    84 
    85 
    86         public function extract_color_scheme() {
     32        public function extract_color_scheme( $theme_dir, $css_tmpl ) {
    8733            $regex = array(
    8834                "`^([\t\s]+)`ism"=>'',
     
    9238                "`(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+`ism"=>"\n"
    9339            );
     40           
    9441            $replace_colors = array();
    9542            $color_rules = array();
    96             $default_colors = array();     
    97             $css_files = $this->rglob('*.css',0,get_stylesheet_directory());
    98             foreach ($css_files as $css_file) {
    99                 $clean_css = preg_replace(array_keys($regex),$regex,file_get_contents($css_file));         
    100                 $clean_css = str_replace(array("\r\n","\r","\n"),"",$clean_css);
    101                 foreach ($this->parse_css($clean_css) as $selector => $rules) {
    102                     foreach ($rules as $property => $value) {
    103                         if (preg_match_all('/#[a-f0-9]{3,6}/i',$value, $colors)) {
     43            $default_colors = array();         
     44           
     45            foreach ( $this->rglob( '*.css', 0, $theme_dir ) as $css_file ) {
     46               
     47                $clean_css = preg_replace( array_keys( $regex ), $regex, file_get_contents($css_file) );           
     48                $clean_css = str_replace( array( "\r\n", "\r", "\n" ), "", $clean_css );
     49               
     50                foreach ( $this->parse_css( $clean_css ) as $selector => $rules ) {
     51                   
     52                    foreach ( $rules as $property => $value ) {
     53                       
     54                        if ( preg_match_all( '/#[a-f0-9]{3,6}/i',$value, $colors ) ) {
     55                           
    10456                            foreach ($colors as $color) {
    105                                 $color_id = (isset($replace_colors[$color[0]])) ? $replace_colors[$color[0]] : '$color-'.(count($replace_colors)+1);
     57                           
     58                                $color_id = (isset($replace_colors[$color[0]])) ? $replace_colors[ $color[0] ] : '$color-'.( count( $replace_colors ) + 1 );
    10659                                $replace_colors[$color[0]] = $color_id;
    10760                                $default_colors[$color_id] = $color[0];
     61                           
    10862                            }
    109                             $color_rules[$property.":".$value][] = $selector;
     63                           
     64                            $color_rules[$property.":".$value][] = '$scheme_name '.$selector;
     65                       
    11066                        }
    111                         if (preg_match_all('/(rgba|rgb|hsl|hsla)\([0-9\,\.]+?\)/',$value, $colors)) {
     67                       
     68                        if ( preg_match_all( '/(rgba|rgb|hsl|hsla)\([0-9\,\.]+?\)/', $value, $colors ) ) {
     69                           
    11270                            foreach ($colors[0] as $color) {
     71                           
    11372                                $color_id = (isset($replace_colors[$color[0]])) ? $replace_colors[$color[0]] : '$color-'.(count($replace_colors)+1);
    11473                                $replace_colors[$color] = $color_id;
    11574                                $default_colors[$color_id] = $color;
     75                           
    11676                            }
    117                             $color_rules[$property.":".$value][] = $selector;                               
     77                           
     78                            $color_rules[$property.":".$value][] = '$scheme_name '.$selector;                               
    11879                        }
     80
    11981                    }
    12082                }
    12183            }
     84           
     85            $css_template = "";
     86           
     87            foreach ($color_rules as $color_rule => $selectors) {
     88                $css_template .= implode(",\n",$selectors)."{\n\t".$color_rule.";\n}\n";
     89            }
    12290
    123             if (!empty($css_files)) {
    124                 $default_colors_template = "/**\n * Default colors\n *\n";
    125                 foreach ($default_colors as $color_id => $default_color) {
    126                     $default_colors_template .= " * ".$color_id.": ".$default_color.";\n";
    127                 }
    128                 $default_colors_template .=  " */\n\n\n";
    129                
    130                 $css_template = "";
    131                 foreach ($color_rules as $color_rule => $selectors) {
    132                     $css_template .= implode(",\n",$selectors)."{\n\t".$color_rule.";\n}\n";
    133                 }
    134                 $css_template = str_replace(array_keys($replace_colors),$replace_colors,$css_template);
    135                 file_put_contents($this->current_css_tmpl,$default_colors_template.$css_template);         
    136             } else {
    137                 if (file_exists($this->current_css_tmpl)) {
    138                     unlink($this->current_css_tmpl);   
    139                 }
    140             }
     91            $css_template = str_replace( array_keys( $replace_colors ), $replace_colors, $css_template );
     92            file_put_contents( $css_tmpl, $css_template );
     93
     94            return $default_colors;
    14195        }
    14296    }
  • color-scheme-every-theme/trunk/classes/Cset.class.php

    r673507 r686557  
    1313            $this->options = new Cset_Options();
    1414
     15            $this->schemes = array_merge(
     16                $this->options->get_schemes(),
     17                $this->schemes
     18            );
     19
    1520            add_action( 'customize_register', array($this,'customize_register') ); 
    16             add_action( 'wp_head', array($this,'customize_css' ) );     
     21            add_action( 'wp_head', array($this,'customize_css' ) );
    1722       
    1823        }
     
    5358            if (isset($this->schemes[get_theme_mod('color_scheme')])) {
    5459                $customized_script = new Cset_View("custom_styles");
    55                 $css_extractor = new Cset_ColorExtractor();
    56                 $styles = $css_extractor->get_custom_styles();
     60
     61                $styles = "";
     62                if (file_exists(($current_css_tmpl = $this->options->get_css_templ()))) {
     63                    $styles = file_get_contents($current_css_tmpl);
     64                }
     65
    5766                $styles = str_replace(
    5867                    array_reverse(array_keys($this->schemes[get_theme_mod('color_scheme')])),
     
    6069                    $styles
    6170                );
     71
     72                $styles = str_replace('$scheme_name ','',$styles);
     73
    6274                $customized_script->set('styles', $styles);
    6375                echo $customized_script->render();             
    6476            }
     77
     78            if (get_option('dynamic_theme_colors')) {
     79
     80                $customized_js = new Cset_View("js_schemes_array");
     81                $all_styles = "";
     82                $styles = file_get_contents($current_css_tmpl);
     83                $schemes = array();
     84               
     85                foreach ($this->schemes as $name => $colors) {
     86                    $name = 'cset-scheme-'.$name;
     87                    $mod_styles = str_replace(
     88                        array_reverse(array_keys($colors)),
     89                        array_reverse($colors),
     90                        $styles
     91                    );
     92                    $all_styles .= str_replace('$scheme_name','.'.$name,$mod_styles);   
     93                    $schemes[] = $name;                 
     94                }
     95
     96                $customized_script->set('styles', $all_styles);
     97                echo $customized_script->render();
     98
     99                $customized_js->set('schemes',$schemes);
     100                echo $customized_js->render();
     101            }
    65102        }
    66103    }
  • color-scheme-every-theme/trunk/classes/Options.class.php

    r673507 r686557  
    66    class Cset_Options { 
    77       
     8        private $plugin_path = "";
     9
    810        private $options = array();
    911
     
    1214        private $css_extractor = null;
    1315
     16        private $current_css_tmpl = "";
     17
     18        private $current_theme_dir = "";
     19
     20        private $current_theme = "";
     21
    1422
    1523        public function __construct() {
     24
     25            $this->plugin_path = "/wp-content/plugins/".plugin_basename(dirname(dirname(__FILE__)));
     26
     27            if ( !( $this->options = get_option( 'cset_schemes' ) ) ) {
     28                $this->options = array();
     29            }
     30
    1631            add_action('admin_menu',array(&$this,'add_admin_options_menu'));
    1732            add_action('admin_init',array(&$this,'register_admin_options'));
    18            
     33
     34            $uploads = wp_upload_dir( );
     35            $this->current_theme = wp_get_theme( );
     36            $this->current_css_tmpl = $uploads['basedir'].'/color-scheme-'.$this->current_theme->Name.'-'.$this->current_theme->Version.'.tss';
     37            $this->current_theme_dir = get_stylesheet_directory();
     38
    1939            $this->options_view = new Cset_View("options");
    2040            $this->css_extractor = new Cset_ColorExtractor();
    2141
    2242            add_filter('plugin_action_links_color-scheme-every-theme/color-scheme-every-theme.php',array(&$this,'settings_link'));
    23        
    24             if (isset($_REQUEST['generate_color_scheme']) && $_REQUEST['generate_color_scheme'] == '1') {
    25                 $this->css_extractor->extract_color_scheme();
     43
     44            add_action( 'admin_enqueue_scripts', array( $this,'enqueue_css_js' ) );
     45
     46            $this->generate_scheme();
     47            $this->save_schemes();
     48
     49        }
     50
     51
     52        public function generate_scheme() {
     53            if (isset($_REQUEST['generate_color_scheme'])) {
     54
     55                if ( !array_key_exists( $this->current_theme->Name, $this->options ) ) {
     56                    $this->options[$this->current_theme->Name] = array();   
     57                }
     58               
     59                $this->options[$this->current_theme->Name][0] = $this->css_extractor->extract_color_scheme( $this->current_theme_dir, $this->current_css_tmpl );
     60                update_option( "cset_schemes", $this->options);
     61           
     62            }
     63        }
     64
     65        public function save_schemes() {
     66            if (array_key_exists('schemes',$_REQUEST) && array_key_exists($this->current_theme->Name,$_REQUEST['schemes'])) {
     67                foreach ($_REQUEST['schemes'][$this->current_theme->Name] as $scheme_idx => $scheme_colors) {
     68                    $scheme_idx++;
     69                    $this->options[$this->current_theme->Name][$scheme_idx] = array();
     70                    foreach ($scheme_colors as $color_idx => $color) {
     71                        $this->options[$this->current_theme->Name][$scheme_idx]["$".$color_idx] = $color;
     72                    }
     73
     74                }
    2675            }
    2776
     77            if (array_key_exists('delete_schemes',$_REQUEST) && array_key_exists($this->current_theme->Name,$_REQUEST['delete_schemes'])) {
     78                foreach ($_REQUEST['delete_schemes'][$this->current_theme->Name] as $scheme_idx => $delete) {
     79                    $scheme_idx++;
     80                    if ($delete == 1) {
     81                        unset($this->options[$this->current_theme->Name][$scheme_idx]);
     82                    }
     83                }
     84            }
     85
     86            if ( array_key_exists('new_scheme_changed',$_REQUEST) && $_REQUEST['new_scheme_changed'] && array_key_exists("new_scheme",$_REQUEST) && is_array($_REQUEST["new_scheme"])) {
     87                $scheme = array();
     88                foreach ($_REQUEST["new_scheme"] as $color_idx => $color) {
     89                    $scheme["$".$color_idx] = $color;
     90                }
     91                $this->options[$this->current_theme->Name][] = $scheme;
     92            }
     93
     94            update_option( "cset_schemes", $this->options);
     95
     96        }
     97
     98
     99        public function get_css_templ() {
     100            return $this->current_css_tmpl;
     101        }
     102
     103       
     104        public function get_schemes() {
     105            $schemes = array();
     106            if (array_key_exists($this->current_theme->Name,$this->options)) {
     107                foreach ($this->options[$this->current_theme->Name] as $scheme_idx => $scheme) {
     108                    $schemes["custom-scheme-"+$scheme_idx] = $scheme;
     109                }
     110            }
     111            return $schemes;
    28112        }
    29113
     
    36120
    37121
     122        public function enqueue_css_js() {
     123            wp_enqueue_style('cset-options',site_url().$this->plugin_path.'/views/css/options.css');
     124            wp_enqueue_script('cset-options',site_url().$this->plugin_path.'/views/js/options.js');
     125        }
     126       
     127
    38128        public function register_admin_options() {
    39             register_setting('color-scheme-every-theme','gmaps_api_key');
     129            register_setting('cset','default_scheme');
     130            register_setting('cset','custom_schemes');
     131            register_setting('cset','dynamic_theme_colors');
    40132        }
    41133
     
    46138                'Color Scheme every Theme',
    47139                'manage_options',
    48                 'color-scheme-every-theme',
     140                'cset',
    49141                array($this,'print_admin_options_page')
    50142            );
     
    56148                wp_die(__('You do not have sufficient permissions to access this page.', 'cset'));
    57149            }
    58 
    59             $this->options_view->set('template_exists', $this->css_extractor->color_scheme_exists());
    60             $this->options_view->set('colors', $this->css_extractor->get_color_scheme());
    61             $this->options_view->set('default_colors', $this->css_extractor->get_default_scheme());
     150            $this->options_view->set('template_exists', array_key_exists( $this->current_theme->Name, $this->options ) );
     151            $this->options_view->set('colors', $this->options);
     152            $this->options_view->set('theme', $this->current_theme->Name);
    62153            echo $this->options_view->render();
    63154        }
  • color-scheme-every-theme/trunk/color-scheme-every-theme.php

    r678985 r686557  
    44    Plugin URI: http://www.danielauener.com/color-scheme-every-theme
    55    Description: This plugin lets you change the entire color scheme of the current theme via the theme customizer.
    6     Version: 1.2
     6    Version: 2.0
    77    Author: @danielauener
    88    Author URI: http://www.danielauener.se
  • color-scheme-every-theme/trunk/readme.txt

    r678985 r686557  
    55Requires at least: 3.4
    66Tested up to: 3.5
    7 Stable tag: 1.2
     7Stable tag: 2.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2828A more detailed description is available on my blog [http://www.danielauener.com/color-scheme-every-theme/](http://www.danielauener.com/color-scheme-every-theme/). You are wellcome to give feedback/ask questions directly on my blog as well.
    2929
     30Read about the new features in version 2.0 here: [http://www.danielauener.com/color-scheme-every-theme/](http://www.danielauener.com/color-scheme-every-theme/). You are wellcome to give feedback/ask questions directly on my blog as well.
     31
    3032There is even a github-repository on: [https://github.com/danielauener/color-scheme-every-theme/](http://github.com/danielauener/color-scheme-every-theme/)
    3133
     
    4547
    46481. Theme customizer
     492. Edit color schemes directly on the settings page
    4750
    4851== Changelog ==
     
    5457* Fixed a bug that resulted in a blank page after generating the color scheme - thanks to Stiaan for reporting the bug and Ulrich P for helping me to reproduce it!
    5558
    56 = 1.11 =
    57 * Handle situations where no theme is activated or the current theme has no css file in it.
     59= 2.0 =
     60* Testet for multisite environment
     61* Making schemes editable on the settings page
     62* Adding an option to make all color schemes available on the front-end, could
     63be used for a javascript color scheme switcher
  • color-scheme-every-theme/trunk/views/color_scheme_control.view.php

    r673507 r686557  
    33        <input type="radio" name="color_scheme" <?php echo $link; ?> value="<?php echo $name; ?>" /><?php echo $name; ?>
    44        <div style="height:50px;margin:10px 0;position:relative;"><?php
    5             asort($scheme);
    65            $color_count = count($scheme);
    76            foreach ($scheme as $color) : ?>
  • color-scheme-every-theme/trunk/views/options.view.php

    r678985 r686557  
    33    <h2><?php _e("Color Scheme every Theme settings", 'cset'); ?></h2>
    44    <form method="post" action="options.php">
    5         <?php settings_fields('color-scheme-every-theme'); ?>
     5        <?php settings_fields('cset'); ?>
     6        <h3><?php _e("Existing schemes"); ?></h3>
     7        <table class="form-table">         
     8            <?php if (!$template_exists || count($colors[$theme]) == 0) : ?>
     9                <tr valign="top">
     10                    <th scope="row"><?php _e('Color Schemes', 'cset') ?></th>
     11                    <td>
     12                        <p><?php _e("There is no color scheme generatad for your current theme.", 'cset'); ?></p>
     13                    </td>
     14                </tr>
     15            <?php else: ?>
     16                <tr valign="top">
     17                    <th scope="row"><?php _e('Color Schemes', 'cset') ?></th>
     18                    <td><?php
     19                        foreach ($colors[$theme] as $scheme_idx => $theme_colors) : ?>
     20                            <div class="scheme">
     21                                <input type="hidden" class="delete-flag" name="delete_schemes[<?php echo $theme; ?>][<?php echo $scheme_idx-1; ?>]" value="0" />
     22                                <div class="scheme-name">
     23                                    <b>Scheme <?php echo ($scheme_idx == 0) ? __('default') : $scheme_idx; ?></b>
     24                                </div>
     25                                <div class="scheme-colors"><?php
     26                                    $width = 100/count($theme_colors);
     27                                    $color_idx = 1;
     28                                    foreach ($theme_colors as $color) : ?>
     29                                        <div style="width:<?php echo $width; ?>%;background:<?php echo $color; ?>;" class="scheme-color-<?php echo $color_idx; ?> scheme-color">
     30                                            <?php if ($scheme_idx > 0): ?>
     31                                                <input type="hidden" name="schemes[<?php echo $theme; ?>][<?php echo $scheme_idx-1; ?>][color-<?php echo $color_idx; ?>]" value="<?php echo $color; ?>" />
     32                                            <?php endif; ?>
     33                                        </div><?php
     34                                        $color_idx++;
     35                                    endforeach; ?>
     36                                </div><?php
     37                                if ($scheme_idx == 0): ?>
     38                                    <p class="description"><?php _e("The default colors, extracted from your current theme."); ?></p><?php
     39                                else: ?>
     40                                    <p>
     41                                        <a class="color-scheme-embed" href="#" ><?php _e('< embedd in theme >'); ?></a>
     42                                        | <a class="color-scheme-delete" href="#" ><?php _e('delete'); ?></a>
     43                                    </p>
     44                                    <p class="embed">
     45                                        <label><?php _e('Add this to the <em>functions.php</em> of your theme:'); ?></label>
     46                                        <textarea class="embed-code" rows="10" style="width:100%;">if ( function_exists( 'cset_add_color_scheme' ) ) {
     47    cset_add_color_scheme( 'cset_scheme-<?php echo $scheme_idx; ?>', array( <?php
     48        echo "\n";
     49
     50        foreach ($theme_colors as $color_idx => $color):
     51            echo "\t\t".'\''.$color_idx.'\' => \''.$color.'\','."\n";
     52        endforeach; ?>
     53    ) );
     54}</textarea></p><?php
     55                                endif; ?>
     56                            </div><?php                     
     57                        endforeach; ?>
     58                    </td>
     59                </tr>
     60            </table>
     61            <h3><?php _e("Add a new scheme"); ?></h3>
     62            <table class="form-table">
     63                <tr valign="top">
     64                    <th scope="row"><?php _e('New color scheme', 'cset') ?></th>
     65                    <td>
     66                        <div id="new-scheme" class="scheme-colors new-scheme">
     67                            <input type="hidden" name="new_scheme_changed" value="0" id="new-scheme-changed" /><?php
     68                            $width = 100/count($theme_colors);
     69                            $color_idx = 1;
     70                            foreach ($colors[$theme][0] as $color) : ?>
     71                                <div style="width:<?php echo $width; ?>%;background:<?php echo $color; ?>;" id="scheme-color-<?php echo $color_idx; ?>" class="scheme-color">
     72                                    <input type="hidden" name="new_scheme[color-<?php echo $color_idx; ?>]" value="<?php echo $color; ?>" />
     73                                </div><?php
     74                                $color_idx++;
     75                            endforeach; ?>
     76                            <div class="new-color">
     77                                <div class="input">
     78                                    <label><?php _e('Change color: '); ?></label><input type="text" id="new-color" class="regular-text" />
     79                                </div>
     80                            </div>
     81                        </div>                                             
     82                    </td>
     83                </tr>
     84            <?php endif; ?>
     85        </table>
     86        <h3><?php _e("Options"); ?></h3>
    687        <table class="form-table">
    788            <tr valign="top">
    8                 <th scope="row"><?php _e('Color Schemes', 'cset') ?></th>
    9                 <td><?php
    10                     if (!$template_exists) : ?>
    11                         <p><?php _e("There is no color scheme generatad for your current theme.", 'cset'); ?></p><?php
    12                         if (isset($_GET['settings-updated']) && $_GET['settings-updated'] == 'true') : ?>
    13                             <p style="color:#990000;"><?php _e("There was an error while generating the color scheme. <br />Check if you have an active and working theme and if there is any css-file in your active theme!"); ?></p><?php
    14                         endif;
    15                     elseif ($colors): ?>
    16                         <textarea rows="10" style="width:100%;">if ( function_exists( 'cset_add_color_scheme' ) ) {
    17     cset_add_color_scheme( 'scheme-name', array( <?php
    18                             echo "\n";
    19 
    20                             foreach (array_unique($colors[0]) as $color):
    21                                 echo "\t\t".'\''.$color.'\' => \'#111111\','."\n";
    22                             endforeach; ?>
    23     ) );
    24 }</textarea>
    25                         <p class="description"><?php _e('Add this code to your <b>functions.php</b>, for every color scheme you want to add, and modify the color codes as you whish.', 'cset'); ?></p><br /><br />
    26                         <textarea rows="10" style="width:100%;"><?php
    27                             echo $default_colors;
    28                         ?></textarea>
    29                         <p class="description"><?php _e('These are the default colors, extracted from your current theme.', 'cset'); ?></p><?php
    30                     endif; ?>
     89                <th scope="row"><?php _e('Dynamic theme colors', 'cset') ?></th>
     90                <td>
     91                    <label for="dynamic_theme_colors">
     92                        <input name="dynamic_theme_colors" type="checkbox" id="dynamic_theme_colors" value="1" <?php checked('1', get_option('dynamic_theme_colors')); ?> />
     93                        <?php _e("Embed css for all color schemes in the current theme, so they can be changed dynamically via javascript.", 'cset'); ?>
     94                    </label>                                               
    3195                </td>
    32             </tr>   
    33         </table>
     96            </tr>
     97        </table>       
    3498        <p class="submit">
    35             <input type="hidden" name="generate_color_scheme" value="1" />
    36             <input type="submit" class="button-primary" value="<?php echo ($template_exists) ? _e('Regenerate Color Scheme', 'cset') : _e('Generate Color Scheme', 'cset'); ?>" />
     99            <input id="save-color-schemes" type="submit" name="save_color_schemes" class="button-primary" value="<?php _e('Save Schemes'); ?>" />
     100            <input type="submit" name="generate_color_scheme" class="<?php echo ($template_exists) ? 'button' : 'button-primary'; ?>" value="<?php echo ($template_exists) ? _e('Regenerate Color Scheme', 'cset') : _e('Generate Color Scheme', 'cset'); ?>" />
    37101        </p>
    38102    </form>
Note: See TracChangeset for help on using the changeset viewer.