コード例 #1
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());
     $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
 /**
  * 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);
     }
 }