Skip to content

Instantly share code, notes, and snippets.

@yasaryousuf
Created May 15, 2018 10:26
Show Gist options
  • Save yasaryousuf/fa2350d7ea6c1e018ca4d475707710fd to your computer and use it in GitHub Desktop.
Save yasaryousuf/fa2350d7ea6c1e018ca4d475707710fd to your computer and use it in GitHub Desktop.
<?php
public function compiler($in, $out)
{
try {
$scss = new Compiler();
$scss->setImportPaths(OP_PATH.'assets/scss/');
echo $css = $scss->compile(file_get_contents($in), $in);
file_put_contents($out, $css);
}
catch (Exception $e) {
$errors = array (
'file' => basename($in),
'message' => $e->getMessage(),
);
array_push($instance->compile_errors, $errors);
echo '<pre>'; print_r($errors); echo '</pre>';
}
}
public function wp_scss()
{
foreach(new DirectoryIterator($this->scss_dir) as $file)
{
if (substr($file, 0, 1) != "_" && pathinfo($file->getFilename(), PATHINFO_EXTENSION) == 'scss')
{
$input = $this->scss_dir.$file->getFilename();
$outputName = preg_replace("/\.[^$]*/",".css", $file->getFilename());
$output = $this->css_dir.$outputName;
$this->compiler($input, $output);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment