Skip to content
This repository
Browse code

Introducing a new compilation strategy

  • Loading branch information...
commit 3e17e5d1b780c6a0151eec14cfb30d06f1c4a7a0 1 parent dcf621b
Thomas Parisot authored

Showing 2 changed files with 63 additions and 4 deletions. Show diff stats Hide diff stats

  1. +62 3 lib/Configuration.class.php
  2. +1 1  lib/Plugin.class.php
65 lib/Configuration.class.php
@@ -18,14 +18,73 @@ class WPLessConfiguration extends WPPluginToolkitConfiguration
18 18 */
19 19 protected $functions = array();
20 20
  21 + /**
  22 + * @protected
  23 + * @deprecated
  24 + * @var bool
  25 + */
  26 + protected $alwaysRecompile = false;
  27 +
21 28
22 29 protected function configure()
23 30 {
24   - $this->configureOptions();
  31 + $this->configureOptions();
  32 + }
  33 +
  34 + protected function configureOptions()
  35 + {
  36 + $this->setVariables(array());
  37 + }
  38 +
  39 + /**
  40 + * Set global Less variables
  41 + *
  42 + * @since 1.4
  43 + */
  44 + public function addVariable($name, $value)
  45 + {
  46 + $this->variables[$name] = $value;
  47 + }
  48 +
  49 + /**
  50 + * Returns the registered variables
  51 + *
  52 + * @since 1.4
  53 + * @return array
  54 + */
  55 + public function getVariables()
  56 + {
  57 + return $this->variables;
  58 + }
  59 +
  60 + /**
  61 + * Set global Less variables
  62 + *
  63 + * @since 1.4
  64 + */
  65 + public function setVariables(array $variables)
  66 + {
  67 + $this->variables = $variables;
25 68 }
26 69
27   - protected function configureOptions()
  70 + /**
  71 + * Set compilation strategy
  72 + *
  73 + * @param $bFlag bool
  74 + */
  75 + public function alwaysRecompile($bFlag)
28 76 {
29   - //
  77 + $this->alwaysRecompile = !!$bFlag;
  78 + }
  79 +
  80 + /**
  81 + * Return LESS functions
  82 + *
  83 + * @since 1.4.2
  84 + * @return array
  85 + */
  86 + public function getFunctions()
  87 + {
  88 + return $this->functions;
30 89 }
31 90 }
2  lib/Plugin.class.php
@@ -130,7 +130,7 @@ public function processStylesheet($handle, $force = false)
130 130 $wp_styles = $this->getStyles();
131 131 $stylesheet = new WPLessStylesheet($wp_styles->registered[$handle], $this->compiler->getVariables());
132 132
133   - if ((is_bool($force) && $force) || $stylesheet->hasToCompile())
  133 + if ((is_bool($force) && $force) || $this->configuration->alwaysRecompile() || $stylesheet->hasToCompile())
134 134 {
135 135 $this->compiler->saveStylesheet($stylesheet);
136 136 }

0 comments on commit 3e17e5d

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