public function instantiateCompiler() { if (!class_exists('lessc')) { // Load the parent compiler class require $this->getLessCompilerPath(); } $this->compiler = new WPLessCompiler(); $this->compiler->setVariable('stylesheet_directory_uri', "'" . get_stylesheet_directory_uri() . "'"); $this->compiler->setVariable('template_directory_uri', "'" . get_template_directory_uri() . "'"); }
/** * Proxy method * * @see lessc::setImportDir() * @param array $dirs * @since 1.5.0 */ public function setImportDir($dirs) { $this->compiler->setImportDir($dirs); }
/** * Process a single stylesheet * * @author oncletom * @since 1.1 * @version 1.3 * @param string $handle * @param $force boolean If set to true, rebuild all stylesheets, without considering they are updated or not * @return WPLessStylesheet */ public function processStylesheet($handle, $force = false) { $wp_styles = $this->getStyles(); $stylesheet = new WPLessStylesheet($wp_styles->registered[$handle], $this->getConfiguration()->getVariables()); if (is_bool($force) && $force || $stylesheet->hasToCompile()) { $compiler = new WPLessCompiler($stylesheet->getSourcePath()); $compiler->registerFunctions($this->getConfiguration()->getFunctions()); $compiler->saveStylesheet($stylesheet); } $wp_styles->registered[$handle]->src = $stylesheet->getTargetUri(); return $stylesheet; }
/** * Re-init compiler property. It may be used if you must compile stylesheet with @import multiple times in a row. * */ public function resetCompiler() { $this->compiler = new WPLessCompiler(); $this->compiler->setVariable('stylesheet_directory_uri', "'" . get_stylesheet_directory_uri() . "'"); $this->compiler->setVariable('template_directory_uri', "'" . get_template_directory_uri() . "'"); }