WP-SCSS - Version 1.2.6

Version Description

  • Create cache dir if it doesn't exist [@XNBlank](https://github.com/ConnectThink/WP-SCSS/pull/135
  • Add cache dir as default @mhbapcc
Download this release

Release Info

Developer Sky Bolt
Plugin Icon wp plugin WP-SCSS
Version 1.2.6
Comparing to
See all releases

Code changes from version 1.2.5 to 1.2.6

cache/.gitkeep ADDED
File without changes
class/class-wp-scss.php CHANGED
@@ -33,11 +33,11 @@ class Wp_Scss {
33
 
34
  $scssc->setFormatter( $compile_method );
35
  $scssc->setImportPaths( $this->scss_dir );
36
-
37
  $this->sourcemaps = $sourcemaps;
38
  }
39
 
40
- /**
41
  * METHOD COMPILE
42
  * Loops through scss directory and compilers files that end
43
  * with .scss and do not have '_' in front.
@@ -53,77 +53,81 @@ class Wp_Scss {
53
  * @access public
54
  */
55
  public function compile() {
 
 
 
 
 
 
56
  global $scssc, $cache;
57
- $cache = WPSCSS_PLUGIN_DIR . '/cache/';
58
-
59
- //Compiler - Takes scss $in and writes compiled css to $out file
60
- // catches errors and puts them the object's compiled_errors property
61
- function compiler($in, $out, $instance) {
62
- global $scssc, $cache;
63
-
64
- if (is_writable($cache)) {
65
- try {
66
- $map = basename($out) . '.map';
67
- $scssc->setSourceMap(constant('Leafo\ScssPhp\Compiler::' . $instance->sourcemaps));
68
- $scssc->setSourceMapOptions(array(
69
- 'sourceMapWriteTo' => $instance->css_dir . $map, // absolute path to a file to write the map to
70
- 'sourceMapURL' => $map, // url of the map
71
- 'sourceMapBasepath' => rtrim(ABSPATH, '/'), // base path for filename normalization
72
- 'sourceRoot' => '/', // This value is prepended to the individual entries in the 'source' field.
73
- ));
74
-
75
- $css = $scssc->compile(file_get_contents($in), $in);
76
-
77
- file_put_contents($cache.basename($out), $css);
78
- } catch (Exception $e) {
79
- $errors = array (
80
- 'file' => basename($in),
81
- 'message' => $e->getMessage(),
82
- );
83
- array_push($instance->compile_errors, $errors);
84
- }
85
- } else {
86
  $errors = array (
87
- 'file' => $cache,
88
- 'message' => "File Permission Error, permission denied. Please make the cache directory writable."
89
  );
90
  array_push($instance->compile_errors, $errors);
91
  }
 
 
 
 
 
 
92
  }
 
93
 
94
- $input_files = array();
95
- // Loop through directory and get .scss file that do not start with '_'
96
- foreach(new DirectoryIterator($this->scss_dir) as $file) {
97
- if (substr($file, 0, 1) != "_" && pathinfo($file->getFilename(), PATHINFO_EXTENSION) == 'scss') {
98
- array_push($input_files, $file->getFilename());
99
- }
100
- }
101
-
102
- // For each input file, find matching css file and compile
103
- foreach ($input_files as $scss_file) {
104
- $input = $this->scss_dir.$scss_file;
105
- $outputName = preg_replace("/\.[^$]*/",".css", $scss_file);
106
- $output = $this->css_dir.$outputName;
107
-
108
- compiler($input, $output, $this);
109
  }
 
 
 
 
 
 
 
 
 
 
110
 
111
- if (count($this->compile_errors) < 1) {
112
- if ( is_writable($this->css_dir) ) {
113
- foreach (new DirectoryIterator($cache) as $cache_file) {
114
- if ( pathinfo($cache_file->getFilename(), PATHINFO_EXTENSION) == 'css') {
115
- file_put_contents($this->css_dir.$cache_file, file_get_contents($cache.$cache_file));
116
- unlink($cache.$cache_file->getFilename()); // Delete file on successful write
117
- }
118
  }
119
- } else {
120
- $errors = array(
121
- 'file' => 'CSS Directory',
122
- 'message' => "File Permissions Error, permission denied. Please make your CSS directory writable."
123
- );
124
- array_push($this->compile_errors, $errors);
125
  }
 
 
 
 
 
 
126
  }
 
127
  }
128
 
129
 
@@ -145,40 +149,40 @@ class Wp_Scss {
145
  *
146
  * @return bool - true if compiling is needed
147
  */
148
- public function needs_compiling() {
149
- if (defined('WP_SCSS_ALWAYS_RECOMPILE') && WP_SCSS_ALWAYS_RECOMPILE) {
150
- return true;
151
- }
152
 
153
- $latest_scss = 0;
154
- $latest_css = 0;
155
 
156
- foreach ( new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->scss_dir), FilesystemIterator::SKIP_DOTS) as $sfile ) {
157
- if (pathinfo($sfile->getFilename(), PATHINFO_EXTENSION) == 'scss') {
158
- $file_time = $sfile->getMTime();
159
 
160
- if ( (int) $file_time > $latest_scss) {
161
- $latest_scss = $file_time;
162
- }
163
  }
164
  }
 
165
 
166
- foreach ( new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->css_dir), FilesystemIterator::SKIP_DOTS) as $cfile ) {
167
- if (pathinfo($cfile->getFilename(), PATHINFO_EXTENSION) == 'css') {
168
- $file_time = $cfile->getMTime();
169
 
170
- if ( (int) $file_time > $latest_css) {
171
- $latest_css = $file_time;
172
- }
173
  }
174
  }
 
175
 
176
- if ($latest_scss > $latest_css) {
177
- return true;
178
- } else {
179
- return false;
180
- }
181
  }
 
182
 
183
  public function style_url_enqueued($url){
184
  global $wp_styles;
@@ -199,30 +203,30 @@ class Wp_Scss {
199
  */
200
  public function enqueue_files($css_folder) {
201
 
202
- foreach( new DirectoryIterator($this->css_dir) as $stylesheet ) {
203
- if ( pathinfo($stylesheet->getFilename(), PATHINFO_EXTENSION) == 'css' ) {
204
- $name = $stylesheet->getBasename('.css') . '-style';
205
- $uri = get_stylesheet_directory_uri().$css_folder.$stylesheet->getFilename();
206
- $ver = $stylesheet->getMTime();
207
 
208
 
209
- wp_register_style(
210
- $name,
211
- $uri,
212
- array(),
213
- $ver,
214
- $media = 'all' );
215
 
216
- if(!$this->style_url_enqueued($uri)){
217
- wp_enqueue_style($name);
218
- }
219
  }
220
  }
 
221
  }
222
 
223
  public function set_variables(array $variables) {
224
- global $scssc;
225
- $scssc->setVariables($variables);
226
  }
227
 
228
  } // End Wp_Scss Class
33
 
34
  $scssc->setFormatter( $compile_method );
35
  $scssc->setImportPaths( $this->scss_dir );
36
+
37
  $this->sourcemaps = $sourcemaps;
38
  }
39
 
40
+ /**
41
  * METHOD COMPILE
42
  * Loops through scss directory and compilers files that end
43
  * with .scss and do not have '_' in front.
53
  * @access public
54
  */
55
  public function compile() {
56
+ global $scssc, $cache;
57
+ $cache = WPSCSS_PLUGIN_DIR . '/cache/';
58
+
59
+ //Compiler - Takes scss $in and writes compiled css to $out file
60
+ // catches errors and puts them the object's compiled_errors property
61
+ function compiler($in, $out, $instance) {
62
  global $scssc, $cache;
63
+
64
+ if (!file_exists($cache)) {
65
+ mkdir($cache, 0644);
66
+ }
67
+
68
+ if (is_writable($cache)) {
69
+ try {
70
+ $map = basename($out) . '.map';
71
+ $scssc->setSourceMap(constant('Leafo\ScssPhp\Compiler::' . $instance->sourcemaps));
72
+ $scssc->setSourceMapOptions(array(
73
+ 'sourceMapWriteTo' => $instance->css_dir . $map, // absolute path to a file to write the map to
74
+ 'sourceMapURL' => $map, // url of the map
75
+ 'sourceMapBasepath' => rtrim(ABSPATH, '/'), // base path for filename normalization
76
+ 'sourceRoot' => '/', // This value is prepended to the individual entries in the 'source' field.
77
+ ));
78
+
79
+ $css = $scssc->compile(file_get_contents($in), $in);
80
+
81
+ file_put_contents($cache.basename($out), $css);
82
+ } catch (Exception $e) {
 
 
 
 
 
 
 
 
 
83
  $errors = array (
84
+ 'file' => basename($in),
85
+ 'message' => $e->getMessage(),
86
  );
87
  array_push($instance->compile_errors, $errors);
88
  }
89
+ } else {
90
+ $errors = array (
91
+ 'file' => $cache,
92
+ 'message' => "File Permission Error, permission denied. Please make the cache directory writable."
93
+ );
94
+ array_push($instance->compile_errors, $errors);
95
  }
96
+ }
97
 
98
+ $input_files = array();
99
+ // Loop through directory and get .scss file that do not start with '_'
100
+ foreach(new DirectoryIterator($this->scss_dir) as $file) {
101
+ if (substr($file, 0, 1) != "_" && pathinfo($file->getFilename(), PATHINFO_EXTENSION) == 'scss') {
102
+ array_push($input_files, $file->getFilename());
 
 
 
 
 
 
 
 
 
 
103
  }
104
+ }
105
+
106
+ // For each input file, find matching css file and compile
107
+ foreach ($input_files as $scss_file) {
108
+ $input = $this->scss_dir.$scss_file;
109
+ $outputName = preg_replace("/\.[^$]*/",".css", $scss_file);
110
+ $output = $this->css_dir.$outputName;
111
+
112
+ compiler($input, $output, $this);
113
+ }
114
 
115
+ if (count($this->compile_errors) < 1) {
116
+ if ( is_writable($this->css_dir) ) {
117
+ foreach (new DirectoryIterator($cache) as $cache_file) {
118
+ if ( pathinfo($cache_file->getFilename(), PATHINFO_EXTENSION) == 'css') {
119
+ file_put_contents($this->css_dir.$cache_file, file_get_contents($cache.$cache_file));
120
+ unlink($cache.$cache_file->getFilename()); // Delete file on successful write
 
121
  }
 
 
 
 
 
 
122
  }
123
+ } else {
124
+ $errors = array(
125
+ 'file' => 'CSS Directory',
126
+ 'message' => "File Permissions Error, permission denied. Please make your CSS directory writable."
127
+ );
128
+ array_push($this->compile_errors, $errors);
129
  }
130
+ }
131
  }
132
 
133
 
149
  *
150
  * @return bool - true if compiling is needed
151
  */
152
+ public function needs_compiling() {
153
+ if (defined('WP_SCSS_ALWAYS_RECOMPILE') && WP_SCSS_ALWAYS_RECOMPILE) {
154
+ return true;
155
+ }
156
 
157
+ $latest_scss = 0;
158
+ $latest_css = 0;
159
 
160
+ foreach ( new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->scss_dir), FilesystemIterator::SKIP_DOTS) as $sfile ) {
161
+ if (pathinfo($sfile->getFilename(), PATHINFO_EXTENSION) == 'scss') {
162
+ $file_time = $sfile->getMTime();
163
 
164
+ if ( (int) $file_time > $latest_scss) {
165
+ $latest_scss = $file_time;
 
166
  }
167
  }
168
+ }
169
 
170
+ foreach ( new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->css_dir), FilesystemIterator::SKIP_DOTS) as $cfile ) {
171
+ if (pathinfo($cfile->getFilename(), PATHINFO_EXTENSION) == 'css') {
172
+ $file_time = $cfile->getMTime();
173
 
174
+ if ( (int) $file_time > $latest_css) {
175
+ $latest_css = $file_time;
 
176
  }
177
  }
178
+ }
179
 
180
+ if ($latest_scss > $latest_css) {
181
+ return true;
182
+ } else {
183
+ return false;
 
184
  }
185
+ }
186
 
187
  public function style_url_enqueued($url){
188
  global $wp_styles;
203
  */
204
  public function enqueue_files($css_folder) {
205
 
206
+ foreach( new DirectoryIterator($this->css_dir) as $stylesheet ) {
207
+ if ( pathinfo($stylesheet->getFilename(), PATHINFO_EXTENSION) == 'css' ) {
208
+ $name = $stylesheet->getBasename('.css') . '-style';
209
+ $uri = get_stylesheet_directory_uri().$css_folder.$stylesheet->getFilename();
210
+ $ver = $stylesheet->getMTime();
211
 
212
 
213
+ wp_register_style(
214
+ $name,
215
+ $uri,
216
+ array(),
217
+ $ver,
218
+ $media = 'all' );
219
 
220
+ if(!$this->style_url_enqueued($uri)){
221
+ wp_enqueue_style($name);
 
222
  }
223
  }
224
+ }
225
  }
226
 
227
  public function set_variables(array $variables) {
228
+ global $scssc;
229
+ $scssc->setVariables($variables);
230
  }
231
 
232
  } // End Wp_Scss Class
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: sass, scss, css
4
  Plugin URI: https://github.com/ConnectThink/WP-SCSS
5
  Requires at least: 3.0.1
6
  Tested up to: 5.3
7
- Stable tag: 1.2.5
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/copyleft/gpl.html
10
 
@@ -62,6 +62,10 @@ Make sure your directories are properly defined in the settings. Paths are defin
62
  If you are having issues with the plugin, create an issue on [github](https://github.com/ConnectThink/WP-SCSS), and we'll do our best to help.
63
 
64
  == Changelog ==
 
 
 
 
65
  = 1.2.5 =
66
  * Fix error when ".*" folders exist [@chameron](https://github.com/ConnectThink/WP-SCSS/pull/111)
67
  * Add detailed error description for the directory settings [@andreyc0d3r](https://github.com/ConnectThink/WP-SCSS/pull/121)
@@ -118,4 +122,4 @@ Various improvements from pull requests by [@jbrains](https://github.com/jbrains
118
  * Changed error log to .log for auto updating errors
119
 
120
  = 1.0.0 =
121
- * Initial Build
4
  Plugin URI: https://github.com/ConnectThink/WP-SCSS
5
  Requires at least: 3.0.1
6
  Tested up to: 5.3
7
+ Stable tag: 1.2.6
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/copyleft/gpl.html
10
 
62
  If you are having issues with the plugin, create an issue on [github](https://github.com/ConnectThink/WP-SCSS), and we'll do our best to help.
63
 
64
  == Changelog ==
65
+ = 1.2.6 =
66
+ * Create cache dir if it doesn't exist [@XNBlank](https://github.com/ConnectThink/WP-SCSS/pull/135
67
+ * Add cache dir as default [@mhbapcc](https://github.com/ConnectThink/WP-SCSS/pull/144)
68
+
69
  = 1.2.5 =
70
  * Fix error when ".*" folders exist [@chameron](https://github.com/ConnectThink/WP-SCSS/pull/111)
71
  * Add detailed error description for the directory settings [@andreyc0d3r](https://github.com/ConnectThink/WP-SCSS/pull/121)
122
  * Changed error log to .log for auto updating errors
123
 
124
  = 1.0.0 =
125
+ * Initial Build
scssphp/bin/pscss CHANGED
File without changes
scssphp/scss.inc.php CHANGED
File without changes
scssphp/src/Base/Range.php CHANGED
File without changes
scssphp/src/Block.php CHANGED
File without changes
scssphp/src/Colors.php CHANGED
File without changes
scssphp/src/Compiler.php CHANGED
File without changes
scssphp/src/Compiler/Environment.php CHANGED
File without changes
scssphp/src/Exception/CompilerException.php CHANGED
File without changes
scssphp/src/Exception/ParserException.php CHANGED
File without changes
scssphp/src/Exception/RangeException.php CHANGED
File without changes
scssphp/src/Exception/ServerException.php CHANGED
File without changes
scssphp/src/Formatter.php CHANGED
File without changes
scssphp/src/Formatter/Compact.php CHANGED
File without changes
scssphp/src/Formatter/Compressed.php CHANGED
File without changes
scssphp/src/Formatter/Crunched.php CHANGED
File without changes
scssphp/src/Formatter/Debug.php CHANGED
File without changes
scssphp/src/Formatter/Expanded.php CHANGED
File without changes
scssphp/src/Formatter/Nested.php CHANGED
File without changes
scssphp/src/Formatter/OutputBlock.php CHANGED
File without changes
scssphp/src/Node.php CHANGED
File without changes
scssphp/src/Node/Number.php CHANGED
File without changes
scssphp/src/Parser.php CHANGED
File without changes
scssphp/src/SourceMap/Base64VLQEncoder.php CHANGED
File without changes
scssphp/src/SourceMap/SourceMapGenerator.php CHANGED
File without changes
scssphp/src/Type.php CHANGED
File without changes
scssphp/src/Util.php CHANGED
File without changes
scssphp/src/Version.php CHANGED
File without changes
wp-scss.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WP-SCSS
4
  * Plugin URI: https://github.com/ConnectThink/WP-SCSS
5
  * Description: Compiles scss files live on WordPress.
6
- * Version: 1.2.5
7
  * Author: Connect Think
8
  * Author URI: http://connectthink.com
9
  * License: GPLv3
@@ -46,7 +46,7 @@ if (!defined('WPSCSS_VERSION_KEY'))
46
  define('WPSCSS_VERSION_KEY', 'wpscss_version');
47
 
48
  if (!defined('WPSCSS_VERSION_NUM'))
49
- define('WPSCSS_VERSION_NUM', '1.2.4');
50
 
51
  // Add version to options table
52
  if ( get_option( WPSCSS_VERSION_KEY ) !== false ) {
3
  * Plugin Name: WP-SCSS
4
  * Plugin URI: https://github.com/ConnectThink/WP-SCSS
5
  * Description: Compiles scss files live on WordPress.
6
+ * Version: 1.2.6
7
  * Author: Connect Think
8
  * Author URI: http://connectthink.com
9
  * License: GPLv3
46
  define('WPSCSS_VERSION_KEY', 'wpscss_version');
47
 
48
  if (!defined('WPSCSS_VERSION_NUM'))
49
+ define('WPSCSS_VERSION_NUM', '1.2.6');
50
 
51
  // Add version to options table
52
  if ( get_option( WPSCSS_VERSION_KEY ) !== false ) {