コード例 #1
0
ファイル: Compiler.class.php プロジェクト: scottnkerr/eeco
 /**
  * Smart caching and retrieval of a tree of @import LESS stylesheets
  *
  * @since 1.5
  * @param WPLessStylesheet $stylesheet
  * @param bool $force
  */
 public function cacheStylesheet(WPLessStylesheet $stylesheet, $force = false)
 {
     $cache_name = 'wp_less_compiled_' . md5($stylesheet->getSourcePath());
     $s_cache_name = 'wp_less_stylesheet_data_' . md5($stylesheet->getSourcePath());
     $compiled_cache = get_transient($cache_name);
     if (!$force && !file_exists($stylesheet->getTargetPath())) {
         $force = true;
     }
     $compiled_cache = $this->cachedCompile($compiled_cache ? $compiled_cache : $stylesheet->getSourcePath(), $force);
     // saving compiled stuff
     if (isset($compiled_cache['compiled']) && $compiled_cache['compiled']) {
         $stylesheet->setSourceTimestamp($compiled_cache['updated']);
         $this->saveStylesheet($stylesheet, $compiled_cache['compiled']);
         // since 30.09.2013
         remove_action('wp-less_stylesheet_save_post', 'presscore_stylesheet_is_writable');
         $s_cache = array();
         $s_cache['target_uri'] = $stylesheet->getTargetUri();
         // if can not create compiled css - save pure css
         if (!get_option('presscore_less_css_is_writable')) {
             $s_cache['compiled'] = preg_replace("/\r|\n/", "", $compiled_cache['compiled']);
             $s_cache['compiled'] = apply_filters('wp-less_stylesheet_save', $s_cache['compiled'], $stylesheet);
         }
         update_option($s_cache_name, $s_cache);
         $compiled_cache['compiled'] = NULL;
         set_transient($cache_name, $compiled_cache);
     }
 }
コード例 #2
0
ファイル: Compiler.class.php プロジェクト: rixtox/wp-less
 /**
  * Smart caching and retrieval of a tree of @import LESS stylesheets
  *
  * @since 1.5
  * @param WPLessStylesheet $stylesheet
  * @param bool $force
  */
 public function cacheStylesheet(WPLessStylesheet $stylesheet, $force = false)
 {
     $cache_name = 'wp_less_compiled_' . md5($stylesheet->getSourcePath());
     $compiled_cache = get_transient($cache_name);
     $compiled_cache = $this->cachedCompile($compiled_cache ? $compiled_cache : $stylesheet->getSourcePath(), $force);
     // saving compiled stuff
     if (isset($compiled_cache['compiled']) && $compiled_cache['compiled']) {
         $this->saveStylesheet($stylesheet, $compiled_cache['compiled']);
         $compiled_cache['compiled'] = NULL;
         set_transient($cache_name, $compiled_cache);
     }
 }
コード例 #3
0
 /**
  * Smart caching and retrieval of a tree of @import LESS stylesheets
  *
  * @since 1.5
  * @param WPLessStylesheet $stylesheet
  * @param bool $force
  */
 public function cacheStylesheet(WPLessStylesheet $stylesheet, $force = false)
 {
     $cache_name = 'wp_less_compiled_' . md5($stylesheet->getSourcePath());
     $compiled_cache = get_transient($cache_name);
     if (!$force && !file_exists($stylesheet->getTargetPath())) {
         $force = true;
     }
     $compiled_cache = $this->cachedCompile($compiled_cache ? $compiled_cache : $stylesheet->getSourcePath(), $force);
     // saving compiled stuff
     if (isset($compiled_cache['compiled']) && $compiled_cache['compiled']) {
         $stylesheet->setSourceTimestamp($compiled_cache['updated']);
         $this->saveStylesheet($stylesheet, $compiled_cache['compiled']);
         $compiled_cache['compiled'] = NULL;
         set_transient($cache_name, $compiled_cache);
     }
 }
コード例 #4
0
 /**
  * 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;
 }