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 | WP-SCSS |
Version | 1.2.6 |
Comparing to | |
See all releases |
Code changes from version 1.2.5 to 1.2.6
- cache/.gitkeep +0 -0
- class/class-wp-scss.php +104 -100
- readme.txt +6 -2
- scssphp/bin/pscss +0 -0
- scssphp/scss.inc.php +0 -0
- scssphp/src/Base/Range.php +0 -0
- scssphp/src/Block.php +0 -0
- scssphp/src/Colors.php +0 -0
- scssphp/src/Compiler.php +0 -0
- scssphp/src/Compiler/Environment.php +0 -0
- scssphp/src/Exception/CompilerException.php +0 -0
- scssphp/src/Exception/ParserException.php +0 -0
- scssphp/src/Exception/RangeException.php +0 -0
- scssphp/src/Exception/ServerException.php +0 -0
- scssphp/src/Formatter.php +0 -0
- scssphp/src/Formatter/Compact.php +0 -0
- scssphp/src/Formatter/Compressed.php +0 -0
- scssphp/src/Formatter/Crunched.php +0 -0
- scssphp/src/Formatter/Debug.php +0 -0
- scssphp/src/Formatter/Expanded.php +0 -0
- scssphp/src/Formatter/Nested.php +0 -0
- scssphp/src/Formatter/OutputBlock.php +0 -0
- scssphp/src/Node.php +0 -0
- scssphp/src/Node/Number.php +0 -0
- scssphp/src/Parser.php +0 -0
- scssphp/src/SourceMap/Base64VLQEncoder.php +0 -0
- scssphp/src/SourceMap/SourceMapGenerator.php +0 -0
- scssphp/src/Type.php +0 -0
- scssphp/src/Util.php +0 -0
- scssphp/src/Version.php +0 -0
- wp-scss.php +2 -2
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 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
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' => $
|
88 |
-
'message' =>
|
89 |
);
|
90 |
array_push($instance->compile_errors, $errors);
|
91 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
}
|
|
|
93 |
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
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 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
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 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
|
153 |
-
|
154 |
-
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
}
|
163 |
}
|
164 |
}
|
|
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
}
|
173 |
}
|
174 |
}
|
|
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
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 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
}
|
219 |
}
|
220 |
}
|
|
|
221 |
}
|
222 |
|
223 |
public function set_variables(array $variables) {
|
224 |
-
|
225 |
-
|
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.
|
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.
|
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.
|
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 ) {
|