Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. # Only recompile sass when in dev mode.
  2. # This block also handles the minification of CSS and JS.
  3. if ($config['dev']) {
  4.     $scss = new \Leafo\ScssPhp\Compiler();
  5.     $scss->setImportPaths(dirname(__FILE__) . '/assets/scss/');
  6.     foreach (glob(dirname(__FILE__) . '/assets/scss/' . '**/*', GLOB_ONLYDIR) as $path)
  7.         $scss->addImportPath($path);
  8.  
  9.     $scss->setFormatter('\Leafo\ScssPhp\Formatter\Crunched');
  10.     $css = $scss->compile(file_get_contents(dirname(__FILE__) . '/assets/scss/style.scss'));
  11.     file_put_contents(dirname(__FILE__) . '/style.css', \Theme\Utils::cssHeader() . $css);
  12.  
  13.     $js = new \Theme\Js($config['js']);
  14.     file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'script.js', $js->minify());
  15. }
  16.  
  17.  
  18. # Enqueue the minified JS.
  19. wp_enqueue_script('js-minified', get_stylesheet_directory_uri() . DIRECTORY_SEPARATOR . 'script.js', array(), null, true);
  20.  
  21. # Enqueue the minified CSS.
  22. wp_enqueue_style('css-minified', get_stylesheet_directory_uri() . DIRECTORY_SEPARATOR . 'style.css', [], null, 'all');
  23. wp_enqueue_style('font-awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', [], null, 'all');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement