Commits

Doug Stewart committed d4d3ca2

Updated to the latest WP-LESS.

  • Participants
  • Parent commits a62c8bf

Comments (0)

Files changed (13)

includes/wp-less/README.md

-# Enables LESS in WordPress
+# Enable LESS CSS in WordPress
 
 LESS is an abstraction layer that adds some very powerful features to CSS. It
 will speed up your development process and make your life that much easier. Find
 
 ## Usage:
 
+You can either install the script as a standard plugin or use it as an include within a theme or plugin.
+
 For use with themes add the following lines to your functions.php:
 
 ```php
 <?php
 
-// Include the class
+// Include the class (unless you are using the script as a plugin)
 require_once( 'wp-less/wp-less.php' );
 
 // enqueue a .less style sheet
 add_filter( 'less_vars', 'my_less_vars', 10, 2 );
 function my_less_vars( $vars, $handle ) {
     // $handle is a reference to the handle used with wp_enqueue_style()
-    $vars[ 'color' ] => '#000000';
+    $vars[ 'color' ] = '#000000';
     return $vars;
 }
 
 // in this case 'style' is the handle we enqueued the .less file with
 add_filter( 'less_vars_style', 'style_less_vars' );
 function style_less_vars( $vars ) {
-    $vars[ 'color' ] => '#ffffff';
+    $vars[ 'color' ] = '#ffffff';
     return $vars;
 }
 
 
 ## Further Reading
 
-Read the LESS.js documentation here: http://lesscss.org/
+[Read the LESS.js documentation here](http://lesscss.org/)
+
 For documenation specific to the PHP parser: http://leafo.net/lessphp/docs/
+
+
+## Contributors
+
+Big massive thanks to those whose contributions and discussion has helped to improve the plugin.
+
+* [Tom Willmot](https://github.com/willmot)
+* [Franz Josef Kaiser](https://github.com/franz-josef-kaiser)
+
+## License
+
+The software is licensed under [WTFPL](http://sam.zoy.org/wtfpl/)

includes/wp-less/lessc/README.md

-# lessphp v0.3.1
-### <http://leafo.net/lessphp>
+# lessphp v0.3.0
+#### <http://leafo.net/lessphp>
 
 `lessphp` is a compiler for LESS written in PHP. The documentation is great,
-so check it out: <http://leafo.net/lessphp/docs/>.
+so check it out: <http://leafo.net/lessphp/docs/>. Here's a quick tutorial:
 
-Here's a quick tutorial:
-
-### How to use in your PHP project
+### How to use in your php project
 
 Copy `lessc.inc.php` to your include directory and include it into your project.
 
 
 	try {
 		lessc::ccompile('input.less', 'output.css');
-	} catch (exception $ex) {
+	catch (exception $ex) {
 		exit($ex->getMessage());
 	}
 
-`lessc::ccompile` is not aware of imported files that change. Read [about
-`lessc::cexecute`](http://leafo.net/lessphp/docs/#compiling_automatically).
-
 Note that all failures with lessc are reported through exceptions.
 If you need more control you can make your own instance of lessc.
 
 line. In the simplest invocation, you specify an input file and the compiled
 css is written to standard out:
 
-	$ plessc input.less > output.css
+	~> plessc input.less > output.css
 
 Using the -r flag, you can specify LESS code directly as an argument or, if 
 the argument is left off, from standard in:
 
-	$ plessc -r "my less code here"
+	~> plessc -r "my less code here"
 
 Finally, by using the -w flag you can watch a specified input file and have it 
 compile as needed to the output file
 
-	$ plessc -w input-file output-file
+	~> plessc -w input-file output-file
 
 Errors from watch mode are written to standard out.
 

includes/wp-less/lessc/docs/docs.md

-    title: v0.3.1 documentation
+    title: v0.3.0 documentation
     link_to_home: true
 --
 
     }
     ```
 
-#### `@arguments` Variable
-
-Within an mixin there is a special variable named `@arguments` that contains
-all the arguments passed to the mixin along with any remaining arguments that
-have default values. The value of the variable has all the values separated by
-spaces.
-
-This useful for quickly assigning all the arguments:
-
-    ```less
-    .box-shadow(@inset, @x, @y, @blur, @spread, @color) {
-      box-shadow: @arguments;
-      -webkit-box-shadow: @arguments;
-      -moz-box-shadow: @arguments;
-    }
-    .menu {
-      .box-shadow(1px, 1px, 5px, #aaa);
-    }
-    ```
-
-In addition to the arguments passed to the mixin, `@arguments` will also inlude
-remaining default values assigned by the mixin:
-
-
-    ```less
-    .border-mixin(@width, @style: solid, @color: black) {
-      border: @arguments;
-    }
-
-    pre {
-      .border-mixin(4px, dotted);
-    }
-
-    ```
-
 ### Import
 
 Multiple LESS files can be compiled into a single CSS file by using the
 * `floor(number)` -- returns the floor of a numerical input
 * `round(number)` -- returns the rounded value of numerical input
 
-* `lighten(color, percent)` -- lightens `color` by `percent` and returns it
-* `darken(color, percent)` -- darkens `color` by `percent` and returns it
+* `lighten(color, percent)` -- lightens color by percent and returns it
+* `darken(color, percent)` -- darkens color by percent and returns it
 
-* `saturate(color, percent)` -- saturates `color` by `percent` and returns it
-* `desaturate(color, percent)` -- desaturates `color` by `percent` and returns it
+* `saturate(color, percent)` -- saturates color by percent and returns it
+* `desaturate(color, percent)` -- desaturates color by percent and returns it
 
-* `fadein(color, percent)` -- makes `color` less transparent by `percent` and returns it
-* `fadeout(color, percent)` -- makes `color` more transparent by `percent` and returns it
+* `fadein(color, percent)` -- makes color less transparent by percent and returns it
+* `fadeout(color, percent)` -- makes color more transparent by percent and returns it
 
-* `spin(color, amount)` -- returns a color with `amount` degrees added to hue
-
-* `fade(color, amount)` -- retuns a color with the alpha set to `amount`
-
-* `hue(color)` -- retuns the hue of `color`
-
-* `saturation(color)` -- retuns the saturation of `color`
-
-* `lightness(color)` -- retuns the lightness of `color`
-
-* `alpha(color)` -- retuns the alpha value of `color` or 1.0 if it doesn't have an alpha
-
-* `percentage(number)` -- converts a floating point number to a percentage, eg. `0.65` -> `65%`
-
-* `mix(color1, color1, percent)` -- mixes two colors by percentagle where 100%
-  keeps all of `color1`, and 0% keeps all of `color2`. Will take into account
-  the alpha of the colors if it exists. See
-  <http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#mix-instance_method>.
+* `spin(color, amount)` -- returns a color with amount degrees added to hue
 
 * `rgbahex(color)` -- returns a string containing 4 part hex color.
    
 functions that will be exposed in LESS code during the compile. They can be a
 little tricky though because you need to work with the  **lessphp** type system.
 
-An instance of `lessc`, the **lessphp** compiler has two relevant methods:
-`registerFunction` and `unregisterFunction`. `registerFunction` takes two
-arguments, a name and a callable value. `unregisterFunction` just takes the
-name of an existing function to remove.
+By sub-classing `lessc`, and creating specially named methods we can extend
+**lessphp**. In order for a function to be visible in LESS, its name must
+start with `lib_`.
 
-Here's an example that adds a function called `double` that doubles any numeric
-argument:
+Let's make a function that doubles any numeric argument.
 
     ```php
     <?php
     include "lessc.inc.php";
 
-    function lessphp_double($arg) {
-        list($type, $value) = $arg;
-        return array($type, $value*2);
+    class myless extends lessc {
+        function lib_double($arg) {
+            list($type, $value) = $arg;
+            return array($type, $value*2);
+        }
     }
 
     $myless = new myless();
-    $myless->registerFunction("double", "lessphp_double");
-
-    // gives us a width of 800px
     echo $myless->parse("div { width: double(400px); }");
     ```
 
-The second argument to `registerFunction` is any *callable value* that is
-understood by [`call_user_func`](http://php.net/call_user_func).
-
-If we are using PHP 5.3 or above then we are free to pass a function literal
-like so:
-
-    ```php
-    $myless->registerFunction("double", function($arg) {
-        list($type, $value) = $arg;
-        return array($type, $value*2);
-    });
-    ```
-
-Now let's talk about the `double` function itself.
-
-Although a little verbose, the implementation gives us some insight on the type
-system. All values in **lessphp** are stored in an array where the 0th element
-is a string representing the type, and the other elements make up the
+Although a little verbose, the implementation of `lib_double` gives us some
+insight on the type system. All values are stored in an array where the 0th
+element is a string representing the type, and the other elements make up the
 associated data for that value.
 
-The best way to get an understanding of the system is to register is dummy
+The best way to get an understanding of the system is to make a dummy `lib_`
 function which does a `vardump` on the argument. Try passing the function
 different values from LESS and see what the results are.
 
-The return value of the registered function must also be a **lessphp** type, but if it is
+The return value of the `lib_` function must also be a LESS type, but if it is
 a string or numeric value, it will automatically be coerced into an appropriate
 typed value. In our example, we reconstruct the value with our modifications
-while making sure that we preserve the original type.
+while making sure that we preserve the type.
 
-In addition to the arguments passed from **lessphp**, the instnace of
-**lessphp** itself is sent to the registered function as the second argument.
+All of the built in functions are implemented in this manner within the `lessc`
+class.
 
 ## Command Line Interface
 

includes/wp-less/lessc/lessc.inc.php

 <?php
 
 /**
- * lessphp v0.3.1
+ * lessphp v0.3.0
  * http://leafo.net/lessphp
  *
  * LESS css compiler, adapted from http://lesscss.org
 	protected $buffer;
 	protected $count;
 	protected $line;
-	protected $libFunctions = array();
-	static protected $nextBlockId = 0;
 
 	public $indentLevel;
 	public $indentChar = '  ';
 	/**
 	 * @link http://www.w3.org/TR/css3-values/
 	 */
-	static protected $units = array(
+	static protected $units=array(
 		'em', 'ex', 'px', 'gd', 'rem', 'vw', 'vh', 'vm', 'ch', // Relative length units
 		'in', 'cm', 'mm', 'pt', 'pc', // Absolute length units
 		'%', // Percentages
 
 			if (!$hidden) $this->append(array('block', $block));
 			foreach ($block->tags as $tag) {
-				if (isset($this->env->children[$tag])) {
-					$block = $this->mergeBlock($this->env->children[$tag], $block);
-				}
 				$this->env->children[$tag] = $block;
 			}
 
 			return true;
 		}
 
-		// mixin
+
+		// mixin 
 		if ($this->mixinTags($tags) &&
 			($this->argumentValues($argv) || true) && $this->end())
 		{
 		} else {
 			$this->seek($s);
 		}
-
 		// spare ;
 		if ($this->literal(';')) return true;
 
 	// a single tag
 	function tag(&$tag, $simple = false) {
 		if ($simple)
-			$chars = '^,:;{}\][>\(\) "\'';
+			$chars = '^,:;{}\][>\(\) ';
 		else
-			$chars = '^,;{}["\'';
+			$chars = '^,;{}[';
 
 		$tag = '';
 		while ($this->tagBracket($first)) $tag .= $first;
 		else return array('list', $delim, $items);
 	}
 
-	// just do a shallow propety merge, seems to be what lessjs does
-	function mergeBlock($target, $from) {
-		$target = clone $target;
-		$target->props = array_merge($target->props, $from->props);
-		return $target;
-	}
-
 	/**
 	 * Recursively compiles a block. 
 	 * @param $block the block
 	}
 
 	// attempt to find block pointed at by path within search_in or its parent
-	function findBlock($search_in, $path, $seen=array()) {
+	function findBlock($search_in, $path) {
 		if ($search_in == null) return null;
-		if (isset($seen[$search_in->id])) return null;
-		$seen[$search_in->id] = true;
-
 		$name = $path[0];
 
 		if (isset($search_in->children[$name])) {
 			if (count($path) == 1) {
 				return $block;
 			} else {
-				return $this->findBlock($block, array_slice($path, 1), $seen);
+				return $this->findBlock($block, array_slice($path, 1));
 			}
 		} else {
-			if ($search_in->parent === $search_in) return null;
-			return $this->findBlock($search_in->parent, $path, $seen);
+			return $this->findBlock($search_in->parent, $path);
 		}
 	}
 
 	// or the one passed in through $values
 	function zipSetArgs($args, $values) {
 		$i = 0;
-		$assigned_values = array();
 		foreach ($args as $a) {
 			if ($i < count($values) && !is_null($values[$i])) {
 				$value = $values[$i];
 				$value = $a[1];
 			} else $value = null;
 
-			$value = $this->reduce($value);
-			$this->set($this->vPrefix.$a[0], $value);
-			$assigned_values[] = $value;
+			$this->set($this->vPrefix.$a[0], $this->reduce($value));
 			$i++;
 		}
-
-		// copy over any extra default args
-		for ($i = count($values); $i < count($assigned_values); $i++) {
-			$values[] = $assigned_values[$i];
-		}
-
-		$this->env->arguments = $values;
 	}
 
 	// compile a prop and update $lines or $blocks appropriately
 			return array(array('color', 0, 0, 0));
 		}
 		list($color, $delta) = $args[2];
-		$color = $this->coerceColor($color);
-		if (is_null($color))
+		if ($color[0] != 'color')
 			$color = array('color', 0, 0, 0);
 
 		$delta = floatval($delta[1]);
 		return round($hsl[3]);
 	}
 
-	// get the alpha of a color
-	// defaults to 1 for non-colors or colors without an alpha
-	function lib_alpha($color) {
-		if ($color[0] != 'color') return 1;
-		return isset($color[4]) ? $color[4] : 1;
-	}
-
-	// set the alpha of the color
-	function lib_fade($args) {
-		list($color, $alpha) = $this->colorArgs($args);
-		$color[4] = $this->clamp($alpha / 100.0);
-		return $color;
-	}
-
-	function lib_percentage($number) {
-		return array('%', $number[1]*100);
-	}
-
-	// mixes two colors by weight
-	// mix(@color1, @color2, @weight);
-	// http://sass-lang.com/docs/yardoc/Sass/Script/Functions.html#mix-instance_method
-	function lib_mix($args) {
-		if ($args[0] != "list")
-			throw new exception("mix expects (color1, color2, weight)");
-
-		list($first, $second, $weight) = $args[2];
-		$first = $this->assertColor($first);
-		$second = $this->assertColor($second);
-
-		$first_a = $this->lib_alpha($first);
-		$second_a = $this->lib_alpha($second);
-		$weight = $weight[1] / 100.0;
-
-		$w = $weight * 2 - 1;
-		$a = $first_a - $second_a;
-
-		$w1 = (($w * $a == -1 ? $w : ($w + $a)/(1 + $w * $a)) + 1) / 2.0;
-		$w2 = 1.0 - $w1;
-
-		$new = array('color',
-			$w1 * $first[1] + $w2 * $second[1],
-			$w1 * $first[2] + $w2 * $second[2],
-			$w1 * $first[3] + $w2 * $second[3],
-		);
-
-		if ($first_a != 1.0 || $second_a != 1.0) {
-			$new[] = $first_a * $p + $second_a * ($p - 1);
-		}
-
-		return $this->fixColor($new);
-	}
-
-	function assertColor($value, $error = "expected color value") {
-		$color = $this->coerceColor($value);
-		if (is_null($color)) throw new exception($error);
-		return $color;
-	}
-
 	function toHSL($color) {
 		if ($color[0] == 'hsl') return $color;
 
 				else {
 					list($_, $name, $args) = $var;
 					if ($name == "%") $name = "_sprintf";
-					$f = isset($this->libFunctions[$name]) ?
-						$this->libFunctions[$name] : array($this, 'lib_'.$name);
-
+					$f = array($this, 'lib_'.$name);
 					if (is_callable($f)) {
 						if ($args[0] == 'list')
 							$args = $this->compressList($args[2], $args[1]);
 
-						$var = call_user_func($f, $this->reduce($args), $this);
+						$var = call_user_func($f, $this->reduce($args));
 
 						// convet to a typed value if the result is a php primitive
 						if (is_numeric($var)) $var = array('number', $var);
 		return $var;
 	}
 
-	function coerceColor($value) {
-		switch($value[0]) {
-			case 'color': return $value;
-			case 'keyword':
-				$name = $value[1];
-				if (isset(self::$cssColors[$name])) {
-					list($r, $g, $b) = explode(',', self::$cssColors[$name]);
-					return array('color', $r, $g, $b);
-				}
-				return null;
-		}
-	}
-
 	// evaluate an expression
 	function evaluate($op, $left, $right) {
 		$left = $this->reduce($left);
 		$right = $this->reduce($right);
 
-		if ($left_color = $this->coerceColor($left)) {
-			$left = $left_color;
-		}
-
-		if ($right_color = $this->coerceColor($right)) {
-			$right = $right_color;
-		}
-
 		if ($left[0] == 'color' && $right[0] == 'color') {
 			$out = $this->op_color_color($op, $left, $right);
 			return $out;
 		$b = new stdclass;
 		$b->parent = $this->env;
 
-		$b->id = self::$nextBlockId++;
 		$b->tags = $tags;
 		$b->props = array();
 		$b->children = array();
 	// get the highest occurrence entry for a name
 	function get($name) {
 		$current = $this->env;
-
-		$is_arguments = $name == $this->vPrefix . 'arguments';
 		while ($current) {
-			if ($is_arguments && isset($current->arguments)) {
-				return array('list', ' ', $current->arguments);
-			}
-
 			if (isset($current->store[$name]))
 				return $current->store[$name];
 			else
 		if ($this->count >= strlen($this->buffer)) return false;
 
 		// shortcut on single letter
-		if (!$eatWhitespace && strlen($what) == 1) {
+		if (!$eatWhitespace and strlen($what) == 1) {
 			if ($this->buffer{$this->count} == $what) {
 				$this->count++;
 				return true;
 		}
 	}
 
-	public function registerFunction($name, $func) {
-		$this->libFunctions[$name] = $func;
-	}
-
-	public function unregisterFunction($name) {
-		unset($this->libFunctions[$name]);
-	}
-
 	// remove comments from $text
 	// todo: make it work for all functions, not just url
 	function removeComments($text) {
 		}
 
 	}
-
-	static protected $cssColors = array(
-		'aliceblue' => '240,248,255',
-		'antiquewhite' => '250,235,215',
-		'aqua' => '0,255,255',
-		'aquamarine' => '127,255,212',
-		'azure' => '240,255,255',
-		'beige' => '245,245,220',
-		'bisque' => '255,228,196',
-		'black' => '0,0,0',
-		'blanchedalmond' => '255,235,205',
-		'blue' => '0,0,255',
-		'blueviolet' => '138,43,226',
-		'brown' => '165,42,42',
-		'burlywood' => '222,184,135',
-		'cadetblue' => '95,158,160',
-		'chartreuse' => '127,255,0',
-		'chocolate' => '210,105,30',
-		'coral' => '255,127,80',
-		'cornflowerblue' => '100,149,237',
-		'cornsilk' => '255,248,220',
-		'crimson' => '220,20,60',
-		'cyan' => '0,255,255',
-		'darkblue' => '0,0,139',
-		'darkcyan' => '0,139,139',
-		'darkgoldenrod' => '184,134,11',
-		'darkgray' => '169,169,169',
-		'darkgreen' => '0,100,0',
-		'darkgrey' => '169,169,169',
-		'darkkhaki' => '189,183,107',
-		'darkmagenta' => '139,0,139',
-		'darkolivegreen' => '85,107,47',
-		'darkorange' => '255,140,0',
-		'darkorchid' => '153,50,204',
-		'darkred' => '139,0,0',
-		'darksalmon' => '233,150,122',
-		'darkseagreen' => '143,188,143',
-		'darkslateblue' => '72,61,139',
-		'darkslategray' => '47,79,79',
-		'darkslategrey' => '47,79,79',
-		'darkturquoise' => '0,206,209',
-		'darkviolet' => '148,0,211',
-		'deeppink' => '255,20,147',
-		'deepskyblue' => '0,191,255',
-		'dimgray' => '105,105,105',
-		'dimgrey' => '105,105,105',
-		'dodgerblue' => '30,144,255',
-		'firebrick' => '178,34,34',
-		'floralwhite' => '255,250,240',
-		'forestgreen' => '34,139,34',
-		'fuchsia' => '255,0,255',
-		'gainsboro' => '220,220,220',
-		'ghostwhite' => '248,248,255',
-		'gold' => '255,215,0',
-		'goldenrod' => '218,165,32',
-		'gray' => '128,128,128',
-		'green' => '0,128,0',
-		'greenyellow' => '173,255,47',
-		'grey' => '128,128,128',
-		'honeydew' => '240,255,240',
-		'hotpink' => '255,105,180',
-		'indianred' => '205,92,92',
-		'indigo' => '75,0,130',
-		'ivory' => '255,255,240',
-		'khaki' => '240,230,140',
-		'lavender' => '230,230,250',
-		'lavenderblush' => '255,240,245',
-		'lawngreen' => '124,252,0',
-		'lemonchiffon' => '255,250,205',
-		'lightblue' => '173,216,230',
-		'lightcoral' => '240,128,128',
-		'lightcyan' => '224,255,255',
-		'lightgoldenrodyellow' => '250,250,210',
-		'lightgray' => '211,211,211',
-		'lightgreen' => '144,238,144',
-		'lightgrey' => '211,211,211',
-		'lightpink' => '255,182,193',
-		'lightsalmon' => '255,160,122',
-		'lightseagreen' => '32,178,170',
-		'lightskyblue' => '135,206,250',
-		'lightslategray' => '119,136,153',
-		'lightslategrey' => '119,136,153',
-		'lightsteelblue' => '176,196,222',
-		'lightyellow' => '255,255,224',
-		'lime' => '0,255,0',
-		'limegreen' => '50,205,50',
-		'linen' => '250,240,230',
-		'magenta' => '255,0,255',
-		'maroon' => '128,0,0',
-		'mediumaquamarine' => '102,205,170',
-		'mediumblue' => '0,0,205',
-		'mediumorchid' => '186,85,211',
-		'mediumpurple' => '147,112,219',
-		'mediumseagreen' => '60,179,113',
-		'mediumslateblue' => '123,104,238',
-		'mediumspringgreen' => '0,250,154',
-		'mediumturquoise' => '72,209,204',
-		'mediumvioletred' => '199,21,133',
-		'midnightblue' => '25,25,112',
-		'mintcream' => '245,255,250',
-		'mistyrose' => '255,228,225',
-		'moccasin' => '255,228,181',
-		'navajowhite' => '255,222,173',
-		'navy' => '0,0,128',
-		'oldlace' => '253,245,230',
-		'olive' => '128,128,0',
-		'olivedrab' => '107,142,35',
-		'orange' => '255,165,0',
-		'orangered' => '255,69,0',
-		'orchid' => '218,112,214',
-		'palegoldenrod' => '238,232,170',
-		'palegreen' => '152,251,152',
-		'paleturquoise' => '175,238,238',
-		'palevioletred' => '219,112,147',
-		'papayawhip' => '255,239,213',
-		'peachpuff' => '255,218,185',
-		'peru' => '205,133,63',
-		'pink' => '255,192,203',
-		'plum' => '221,160,221',
-		'powderblue' => '176,224,230',
-		'purple' => '128,0,128',
-		'red' => '255,0,0',
-		'rosybrown' => '188,143,143',
-		'royalblue' => '65,105,225',
-		'saddlebrown' => '139,69,19',
-		'salmon' => '250,128,114',
-		'sandybrown' => '244,164,96',
-		'seagreen' => '46,139,87',
-		'seashell' => '255,245,238',
-		'sienna' => '160,82,45',
-		'silver' => '192,192,192',
-		'skyblue' => '135,206,235',
-		'slateblue' => '106,90,205',
-		'slategray' => '112,128,144',
-		'slategrey' => '112,128,144',
-		'snow' => '255,250,250',
-		'springgreen' => '0,255,127',
-		'steelblue' => '70,130,180',
-		'tan' => '210,180,140',
-		'teal' => '0,128,128',
-		'thistle' => '216,191,216',
-		'tomato' => '255,99,71',
-		'turquoise' => '64,224,208',
-		'violet' => '238,130,238',
-		'wheat' => '245,222,179',
-		'white' => '255,255,255',
-		'whitesmoke' => '245,245,245',
-		'yellow' => '255,255,0',
-		'yellowgreen' => '154,205,50'
-	);
 }
 

includes/wp-less/lessc/tests/inputs/colors.less

 	zero: spin(#000000, 100);
 	zero: spin(#ffffff, 100);
 }
-
-
-alpha {
-	// g: alpha(red);
-	g: alpha(rgba(0,0,0,0));
-	g: alpha(rgb(155,55,0));
-}
-
-fade {
-	f: fade(red, 50%);
-	f: fade(#fff, 20%);
-	f: fade(rgba(34,23,64,0.4), 50%);
-}
-
-@a: rgb(255,255,255);
-@b: rgb(0,0,0);
-
-.mix {
-	color: mix(@a, @b, 50%);
-}
-
-.percent {
-	per: percentage(0.5);
-}
-
-// color keywords
-
-.colorz {
-	color: whitesmoke - 10;
-	color: spin(red, 34);
-}
-
-

includes/wp-less/lessc/tests/inputs/misc.less

 	background: url(/*no comment here*/);
 }
 
-
-.mix(@arg) { color: @arg; }
-@aaa: aaa;
-@bbb: bbb;
-// make sure the opening selector isn't too greedy
-.cool {.mix("@{aaa}, @{bbb}")}
-
-.cool("{hello");
-.cool('{hello');
-
-
-// merging of mixins
-.span-17 { float: left; }
-.span-17 { width: 660px; }
-
-.x {.span-17;}
-
-.hi {
-	pre {
-		color: red;
-	}
-}
-
-.hi {
-	pre {
-		color: blue;
-	}
-}
-
-.rad {
-	.hi;
-}
-

includes/wp-less/lessc/tests/inputs/mixins.less

 }
 
 
-// arguments
-
-.spam(@something: 100) {
-	@wow: 23434;
-    foo: @arguments;
-    bar: @arguments;
-}
-
-.eggs {
-    .spam(1px, 2px, 4px, 8px);
-}
-
-.first(@one, @two, @three, @four: cool) {
-	cool: @arguments;
-}
-
-#hello {
-	.first(one, two, three);
-}
-
-
-.rad() {
-	cool: @arguments;
-}
-
-#world {
-	@hello: "world";
-	.rad("@{hello}");
-}
-
-.second() {
-	things: @arguments;
-}
-
-#another {
-	.second(red, blue, green);
-	.second(red blue green);
-}
-
-
-.another() {
-  .cool {
-    color: @arguments;
-  }
-}
-
-#day {
-	.another(one,two, three);
-	.another(one two three);
-}
-
-
-
-

includes/wp-less/lessc/tests/outputs/colors.css

   zero:#56124b;
   zero:#000000;
   zero:#ffffff;
-}
-alpha {
-  g:0;
-  g:1;
-}
-fade {
-  f:rgba(255,0,0,0.5);
-  f:rgba(255,255,255,0.2);
-  f:rgba(34,23,64,0.5);
-}
-.mix { color:#7f7f7f; }
-.percent { per:50%; }
-.colorz {
-  color:#ebebeb;
-  color:#ff9100;
 }

includes/wp-less/lessc/tests/outputs/misc.css

 @charset "utf-8";
-color:"aaa, bbb";
-color:"aaa, bbb";
 .topbar { background:url(/assets/images/test/topbar.png); }
 .hello { test:empty-function("/assets/images/test/",40%,to(#ffffff)); }
 .css3 { background-image:-webkit-gradient(linear,0% 0%,0% 90%,from(#e9a000),to(#a37000)); }
   world:'// neither is this';
   what-ever:100px;
   background:url(/*no comment here*/);
-}
-.cool { color:"aaa, bbb"; }
-.span-17 { float:left; }
-.span-17 { width:660px; }
-.x {
-  float:left;
-  width:660px;
-}
-.hi pre { color:red; }
-.hi pre { color:blue; }
-.rad pre { color:red; }
-.rad pre { color:blue; }
+}

includes/wp-less/lessc/tests/outputs/mixins.css

 }
 body b { color:blue; }
 .hello .world { color:blue; }
-.foobar { color:blue; }
-.eggs {
-  foo:1px 2px 4px 8px;
-  bar:1px 2px 4px 8px;
-}
-#hello { cool:one two three cool; }
-#world { cool:"world"; }
-#another {
-  things:red blue green;
-  things:red blue green;
-}
-#day .cool { color:one two three; }
-#day .cool { color:one two three; }
+.foobar { color:blue; }

includes/wp-less/lessc/tests/test.php

 $showDiff = flag('d', 'diff');
 echo ($compiling ? "Compiling" : "Running")." $count test".($count == 1 ? '' : 's').":\n";
 
-function dump($msgs, $depth = 1, $prefix="    ") {
+function dump($msgs, $depth = 1) {
 	if (!is_array($msgs)) $msgs = array($msgs);
 	foreach ($msgs as $m) {
-		echo str_repeat($prefix, $depth).' - '.$m."\n";
+		echo str_repeat("\t", $depth).' - '.$m."\n";
 	}
 }
 
-$fail_prefix = " ** ";
-
 $i = 1;
 foreach ($tests as $test) {
-	printf("    [Test %04d/%04d] %s -> %s\n", $i, $count, basename($test['in']), basename($test['out']));
+	printf("\t[Test %04d/%04d] %s -> %s\n", $i, $count, basename($test['in']), basename($test['out']));
 
 	try {
 		ob_start();
 			"Failed to compile input, reason:",
 			$e->getMessage(),
 			"Aborting"
-		), 1, $fail_prefix);
+		));
 		break;
 	}
 
 				"Failed to find output file: $test[out]",
 				"Maybe you forgot to compile tests?",
 				"Aborting"
-			), 1, $fail_prefix);
+			));
 			break;
 		}
 		$expected = trim(file_get_contents($test['out']));
 
 		if ($expected != $parsed) {
 			if ($showDiff) {
-				dump("Failed:", 1, $fail_prefix);
+				dump("Failed:");
 				$tmp = $test['out'].".tmp";
 				file_put_contents($tmp, $parsed);
 				system($difftool.' '.$test['out'].' '.$tmp);
 
 				dump("Aborting");
 				break;
-			} else dump("Failed, run with -d flag to view diff", 1, $fail_prefix);
+			} else dump("Failed, run with -d flag to view diff");
 		} else {
 			dump("Passed");
 		}

includes/wp-less/license.txt

-Copyright (C) 2011  Robert O'Rourke  http://sanchothefat.com/
+DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+Version 2, December 2004
 
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+Copyright (C) 2011  Robert O'Rourke <robert@o-rourke.org>  http://sanchothefat.com
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+Everyone is permitted to copy and distribute verbatim or modified
+copies of this license document, and changing it is allowed as long
+as the name is changed.
 
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>
+DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. You just DO WHAT THE FUCK YOU WANT TO.

includes/wp-less/wp-less.php

 <?php
 /**
+Plugin Name: LESS CSS Auto Compiler
+Plugin URI: https://github.com/sanchothefat/wp-less/
+Description: Allows you to enqueue .less files and have them automatically compiled whenever a change is detected.
+Author: Robert O'Rourke
+Version: 1.0
+Author URI: http://interconnectit.com
+License: WTFPL
+*/
+
+
+/**
  * Enables the use of LESS in WordPress
  *
  * See README.md for usage information
+ *
+ * Licensed under WTFPL
  */
 
 
 		function parse_stylesheet( $src, $handle ) {
 
 			// we only want to handle .less files
-			if ( ! strstr( $src, '.less' ) )
+			if ( ! preg_match( "/\.less(\.php)?$/", preg_replace( "/\?.*$/", "", $src ) ) )
 				return $src;
 
 			// get file path from $src
-			preg_match( "/^(.*?\/wp-content\/)([^\?]+)(.*)$/", $src, $src_bits );
-			$less_path = WP_CONTENT_DIR . '/' . $src_bits[ 2 ];
+			if ( ! strstr( $src, '?' ) )
+				$src .= '?';
+			list( $less_path, $query_string ) = explode( '?', str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $src ) );
 
 			// output css file name
 			$css_path = $this->get_cache_dir() . "/$handle.css";
 
 			// automatically regenerate files if source's modified time has changed or vars have changed
 			try {
+
 				// load the cache
 				$cache_path = "$css_path.cache";
+
 				if ( file_exists( $cache_path ) )
 					$full_cache = unserialize( file_get_contents( $cache_path ) );
-				else
+
+				// If the root path in the cache is wrong then regenerate
+				if ( ! isset( $full_cache['less']['root'] ) || ! file_exists( $full_cache['less']['root'] ) )
 					$full_cache = array( 'vars' => $vars, 'less' => $less_path );
 
 				$less_cache = lessc::cexecute( $full_cache[ 'less' ] );
+
 				if ( ! is_array( $less_cache ) || $less_cache['updated'] > $full_cache[ 'less' ]['updated'] || $vars !== $full_cache[ 'vars' ] ) {
 					$less = new lessc( $less_path );
 					file_put_contents( $cache_path, serialize( array( 'vars' => $vars, 'less' => $less_cache ) ) );
 					file_put_contents( $css_path, $less->parse( null, $vars ) );
 				}
+
 			} catch ( exception $ex ) {
-				wp_die( $ex->getMessage() );
+			  wp_die( $ex->getMessage() );
 			}
 
 			// return the compiled stylesheet with the query string it had if any
-			return $this->get_cache_dir( false ) . "/$handle.css" . ( isset( $src_bits[ 3 ] ) ? $src_bits[ 3 ] : '' );
+			return $this->get_cache_dir( false ) . "/$handle.css" . ( ! empty( $query_string ) ? '?' . $query_string : '' );
 
 		}
 
 		 */
 		function url_to_handle( $url ) {
 
-			$url = preg_replace( "/^.*?\/wp-content\/themes\//", '', $url );
-			$url = str_replace( '.less', '', $url );
+			$url = parse_url( $url );
+			$url = str_replace( '.less', '', basename( $url[ 'path' ] ) );
 			$url = str_replace( '/', '-', $url );
 
 			return sanitize_key( $url );
 			$upload_dir = wp_upload_dir();
 
 			if ( $path ) {
-				$dir = str_replace( $upload_dir[ 'subdir' ], '', $upload_dir[ 'path' ] ) . '/wp-less-cache';
+				$dir = apply_filters( 'wp_less_cache_path', trailingslashit( $upload_dir[ 'basedir' ] ) . 'wp-less-cache' );
 				// create folder if it doesn't exist yet
 				if ( ! file_exists( $dir ) )
 					wp_mkdir_p( $dir );
 			} else {
-				$dir = str_replace( $upload_dir[ 'subdir' ], '', $upload_dir[ 'url' ] ) . '/wp-less-cache';
+				$dir = apply_filters( 'wp_less_cache_url', trailingslashit( $upload_dir[ 'baseurl' ] ) . 'wp-less-cache' );
 			}
 
-			return $dir;
+			return rtrim( $dir, '/' );
 
 		}
 
+
+		/**
+		 * Escape a string that has non alpha numeric characters variable for use within .less stylesheets
+		 *
+		 * @param string $str The string to escape
+		 *
+		 * @return string    String ready for passing into the compiler
+		 */
+		function sanitize_string( $str ) {
+			return '~"' . $str . '"';
+		}
+
 	}
 
 	// initialise