Plugin Directory

Changeset 678985


Ignore:
Timestamp:
03/10/2013 06:38:19 AM (13 years ago)
Author:
danielauener
Message:

fixing errors with not active or not working themes, tagging version 1.2

Location:
color-scheme-every-theme
Files:
5 edited
7 copied

Legend:

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

    r676649 r678985  
    1313
    1414        private function rglob($pattern='*', $flags = 0, $path='') {
    15             $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
    16             $files=glob($path.$pattern, $flags);
     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
    1720            foreach ($paths as $path) { $files=array_merge($files,$this->rglob($pattern, $flags, $path)); }
     21           
    1822            return $files;
    1923        }
     
    9094            $replace_colors = array();
    9195            $color_rules = array();
    92             $default_colors = array();         
    93             foreach ($this->rglob('*.css',0,get_stylesheet_directory()) as $css_file) {
     96            $default_colors = array();     
     97            $css_files = $this->rglob('*.css',0,get_stylesheet_directory());
     98            foreach ($css_files as $css_file) {
    9499                $clean_css = preg_replace(array_keys($regex),$regex,file_get_contents($css_file));         
    95100                $clean_css = str_replace(array("\r\n","\r","\n"),"",$clean_css);
     
    116121            }
    117122
    118             $default_colors_template = "/**\n * Default colors\n *\n";
    119             foreach ($default_colors as $color_id => $default_color) {
    120                 $default_colors_template .= " * ".$color_id.": ".$default_color.";\n";
     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                }
    121140            }
    122             $default_colors_template .=  " */\n\n\n";
    123            
    124             $css_template = "";
    125             foreach ($color_rules as $color_rule => $selectors) {
    126                 $css_template .= implode(",\n",$selectors)."{\n\t".$color_rule.";\n}\n";
    127             }
    128             $css_template = str_replace(array_keys($replace_colors),$replace_colors,$css_template);
    129             file_put_contents($this->current_css_tmpl,$default_colors_template.$css_template);         
    130141        }
    131142    }
  • color-scheme-every-theme/tags/1.2/color-scheme-every-theme.php

    r676649 r678985  
    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.1
     6    Version: 1.2
    77    Author: @danielauener
    88    Author URI: http://www.danielauener.se
  • color-scheme-every-theme/tags/1.2/readme.txt

    r676649 r678985  
    55Requires at least: 3.4
    66Tested up to: 3.5
    7 Stable tag: 1.1
     7Stable tag: 1.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5353= 1.1 =
    5454* 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!
     55
     56= 1.11 =
     57* Handle situations where no theme is activated or the current theme has no css file in it.
  • color-scheme-every-theme/tags/1.2/views/options.view.php

    r673507 r678985  
    1010                    if (!$template_exists) : ?>
    1111                        <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;
    1215                    elseif ($colors): ?>
    1316                        <textarea rows="10" style="width:100%;">if ( function_exists( 'cset_add_color_scheme' ) ) {
  • color-scheme-every-theme/trunk/classes/ColorExtractor.class.php

    r676649 r678985  
    1313
    1414        private function rglob($pattern='*', $flags = 0, $path='') {
    15             $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
    16             $files=glob($path.$pattern, $flags);
     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
    1720            foreach ($paths as $path) { $files=array_merge($files,$this->rglob($pattern, $flags, $path)); }
     21           
    1822            return $files;
    1923        }
     
    9094            $replace_colors = array();
    9195            $color_rules = array();
    92             $default_colors = array();         
    93             foreach ($this->rglob('*.css',0,get_stylesheet_directory()) as $css_file) {
     96            $default_colors = array();     
     97            $css_files = $this->rglob('*.css',0,get_stylesheet_directory());
     98            foreach ($css_files as $css_file) {
    9499                $clean_css = preg_replace(array_keys($regex),$regex,file_get_contents($css_file));         
    95100                $clean_css = str_replace(array("\r\n","\r","\n"),"",$clean_css);
     
    116121            }
    117122
    118             $default_colors_template = "/**\n * Default colors\n *\n";
    119             foreach ($default_colors as $color_id => $default_color) {
    120                 $default_colors_template .= " * ".$color_id.": ".$default_color.";\n";
     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                }
    121140            }
    122             $default_colors_template .=  " */\n\n\n";
    123            
    124             $css_template = "";
    125             foreach ($color_rules as $color_rule => $selectors) {
    126                 $css_template .= implode(",\n",$selectors)."{\n\t".$color_rule.";\n}\n";
    127             }
    128             $css_template = str_replace(array_keys($replace_colors),$replace_colors,$css_template);
    129             file_put_contents($this->current_css_tmpl,$default_colors_template.$css_template);         
    130141        }
    131142    }
  • color-scheme-every-theme/trunk/color-scheme-every-theme.php

    r676649 r678985  
    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.1
     6    Version: 1.2
    77    Author: @danielauener
    88    Author URI: http://www.danielauener.se
  • color-scheme-every-theme/trunk/readme.txt

    r676649 r678985  
    55Requires at least: 3.4
    66Tested up to: 3.5
    7 Stable tag: 1.1
     7Stable tag: 1.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5353= 1.1 =
    5454* 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!
     55
     56= 1.11 =
     57* Handle situations where no theme is activated or the current theme has no css file in it.
  • color-scheme-every-theme/trunk/views/options.view.php

    r673507 r678985  
    1010                    if (!$template_exists) : ?>
    1111                        <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;
    1215                    elseif ($colors): ?>
    1316                        <textarea rows="10" style="width:100%;">if ( function_exists( 'cset_add_color_scheme' ) ) {
Note: See TracChangeset for help on using the changeset viewer.