Skip to content
Browse files

Introducing a new compilation strategy

  • Loading branch information...
1 parent dcf621b commit 3e17e5d1b780c6a0151eec14cfb30d06f1c4a7a0 oncletom committed Oct 7, 2012
Showing with 63 additions and 4 deletions.
  1. +62 −3 lib/Configuration.class.php
  2. +1 −1 lib/Plugin.class.php
View
65 lib/Configuration.class.php
@@ -18,14 +18,73 @@ class WPLessConfiguration extends WPPluginToolkitConfiguration
*/
protected $functions = array();
+ /**
+ * @protected
+ * @deprecated
+ * @var bool
+ */
+ protected $alwaysRecompile = false;
+
protected function configure()
{
- $this->configureOptions();
+ $this->configureOptions();
+ }
+
+ protected function configureOptions()
+ {
+ $this->setVariables(array());
+ }
+
+ /**
+ * Set global Less variables
+ *
+ * @since 1.4
+ */
+ public function addVariable($name, $value)
+ {
+ $this->variables[$name] = $value;
+ }
+
+ /**
+ * Returns the registered variables
+ *
+ * @since 1.4
+ * @return array
+ */
+ public function getVariables()
+ {
+ return $this->variables;
+ }
+
+ /**
+ * Set global Less variables
+ *
+ * @since 1.4
+ */
+ public function setVariables(array $variables)
+ {
+ $this->variables = $variables;
}
- protected function configureOptions()
+ /**
+ * Set compilation strategy
+ *
+ * @param $bFlag bool
+ */
+ public function alwaysRecompile($bFlag)
{
- //
+ $this->alwaysRecompile = !!$bFlag;
+ }
+
+ /**
+ * Return LESS functions
+ *
+ * @since 1.4.2
+ * @return array
+ */
+ public function getFunctions()
+ {
+ return $this->functions;
}
}
View
2 lib/Plugin.class.php
@@ -130,7 +130,7 @@ public function processStylesheet($handle, $force = false)
$wp_styles = $this->getStyles();
$stylesheet = new WPLessStylesheet($wp_styles->registered[$handle], $this->compiler->getVariables());
- if ((is_bool($force) && $force) || $stylesheet->hasToCompile())
+ if ((is_bool($force) && $force) || $this->configuration->alwaysRecompile() || $stylesheet->hasToCompile())
{
$this->compiler->saveStylesheet($stylesheet);
}

0 comments on commit 3e17e5d

Please sign in to comment.
Something went wrong with that request. Please try again.