Example #1
0
 /**
  * Process all stylesheets to compile just in time
  *
  * @author oncletom
  * @since 1.0
  * @version 1.1
  * @param $force boolean If set to true, rebuild all stylesheets, without considering they are updated or not
  */
 public function processStylesheets($force = false)
 {
     $styles = $this->getQueuedStylesToProcess();
     $force = is_bool($force) && $force ? !!$force : false;
     WPScssStylesheet::$upload_dir = $this->configuration->getUploadDir();
     WPScssStylesheet::$upload_uri = $this->configuration->getUploadUrl();
     if (empty($styles)) {
         return;
     }
     if (!wp_mkdir_p(WPScssStylesheet::$upload_dir)) {
         throw new WPScssException(sprintf('The upload dir folder (`%s`) is not writable from %s.', WPScssStylesheet::$upload_dir, get_class($this)));
     }
     foreach ($styles as $style_id) {
         $this->processStylesheet($style_id, $force);
     }
     do_action('wp-scss_plugin_process_stylesheets', $styles);
 }
Example #2
0
 /**
  * Process a WPScssStylesheet
  *
  * This logic was previously held in WPScssStylesheet::save()
  *
  * @since 1.4.2
  * @param WPScssStylesheet $stylesheet
  * @param null $css
  */
 public function saveStylesheet(WPScssStylesheet $stylesheet, $css = null)
 {
     wp_mkdir_p(dirname($stylesheet->getTargetPath()));
     try {
         do_action('wp-scss_stylesheet_save_pre', $stylesheet, $this->getVariables());
         if ($css === null) {
             $css = $this->compile(file_get_contents($stylesheet->getSourcePath()));
         }
         file_put_contents($stylesheet->getTargetPath(), apply_filters('wp-scss_stylesheet_save', $css, $stylesheet));
         //chmod($stylesheet->getTargetPath(), 0666);
         $stylesheet->save();
         do_action('wp-scss_stylesheet_save_post', $stylesheet);
     } catch (Exception $e) {
         wp_die($e->getMessage());
     }
 }
Example #3
0
 /**
  * Configure directories
  *
  * @param \WPScssPlugin $WPScssPlugin
  * @access private
  */
 private function configDirs(\WPScssPlugin $WPScssPlugin)
 {
     $scss_config = $WPScssPlugin->getConfiguration();
     if (isset($this->upload_dir) && isset($this->upload_url)) {
         $scss_config->setUploadDir($this->upload_dir);
         $scss_config->setUploadUrl($this->upload_url);
     }
     $css_template_path = FileSystem::getDirectory('css_template_path');
     $WPScssPlugin->setImportDir($css_template_path);
     \WPScssStylesheet::$upload_dir = $scss_config->getUploadDir();
     \WPScssStylesheet::$upload_uri = $scss_config->getUploadUrl();
 }