Skip to content

Commit 3c90964

Browse files
author
Askupa Software
committed
Added support for variable subscripts
1 parent 5ed7bbe commit 3c90964

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

compiler.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
* @package WordPress Dynamic CSS
4-
* @version 1.0.2
4+
* @version 1.0.3
55
* @author Askupa Software <[email protected]>
66
* @link https://github.com/askupasoftware/wp-dynamic-css
77
* @copyright 2016 Askupa Software
@@ -174,8 +174,13 @@ protected function filter_external( $style )
174174
*/
175175
protected function compile_css( $css, $callback )
176176
{
177-
return preg_replace_callback( '#\$([\w]+)#', function( $matches ) use ( $callback ) {
178-
return call_user_func_array( $callback, array($matches[1]) );
177+
return preg_replace_callback( "#\\$([\\w-]+)((?:\\['?[\\w-]+'?\\])*)#", function( $matches ) use ( $callback ) {
178+
// If this variable is an array, get the subscripts
179+
if( '' !== $matches[2] )
180+
{
181+
preg_match_all('/[\w-]+/i', $matches[2], $subscripts);
182+
}
183+
return call_user_func_array( $callback, array($matches[1],@$subscripts[0]) );
179184
}, $css);
180185
}
181186
}

0 commit comments

Comments
 (0)