Skip to content

Commit

Permalink
Merge pull request #14 from oncletom/feature-14
Browse files Browse the repository at this point in the history
Systematic LESS rebuild through configuration
  • Loading branch information
Oncle Tom committed Oct 9, 2012
2 parents dcf621b + d0fc189 commit 5046c4e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
33 changes: 25 additions & 8 deletions lib/Configuration.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,37 @@ class WPLessConfiguration extends WPPluginToolkitConfiguration
*/
const VERSION = '1.5-dev';

/**
* @protected
* @see http://leafo.net/lessphp/docs/index.html#custom_functions
*/
protected $functions = array();
/**
* @protected
* @deprecated
* @var bool
*/
protected $alwaysRecompile = false;


protected function configure()
{
$this->configureOptions();
$this->configureOptions();
}

protected function configureOptions()
{
$this->alwaysRecompile((defined('WP_DEBUG') && WP_DEBUG) || (defined('WP_LESS_ALWAYS_RECOMPILE') && WP_LESS_ALWAYS_RECOMPILE));
}

protected function configureOptions()
/**
* Set compilation strategy
*
* @param $bFlag bool
* @return bool Actual compilation "strategy"
*/
public function alwaysRecompile($bFlag = null)
{
//
if (!is_null($bFlag))
{
$this->alwaysRecompile = !!$bFlag;
}

return $this->alwaysRecompile;
}
}
2 changes: 1 addition & 1 deletion lib/Plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Stylesheet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ public function getTargetUri()
*
* @author oncletom
* @since 1.0
* @version 1.2
* @version 1.3
* @return boolean
*/
public function hasToCompile()
{
return ($this->is_new || (defined('WP_DEBUG') && WP_DEBUG));
return $this->is_new;
}

/**
Expand Down

0 comments on commit 5046c4e

Please sign in to comment.