Compile_Less_Sass

The WooCommerce Predictive Search LITE Compile Less Sass class.

Defined (1)

The class is defined in the following location(s).

/admin/less/compile_less_sass_class.php  
  1. class Compile_Less_Sass { 
  2.  
  3. public function __construct() { 
  4. $this->init(); 
  5. public function init() { 
  6.  
  7. public function compileLessFile( $less_file = '', $css_file = '', $css_min_file = '' ) { 
  8. global $wp_filesystem; 
  9.  
  10. if( empty( $less_file ) ) 
  11. $less_file = dirname( __FILE__ ) . '/assets/css/style.less'; 
  12. if( empty( $css_file ) ) 
  13. $css_file = dirname( __FILE__ ) . '/assets/css/style.css'; 
  14. if( empty( $css_min_file ) ) 
  15. $css_min_file = dirname( __FILE__ ) . '/assets/css/style.min.css'; 
  16.  
  17. // Write less file 
  18. if ( is_writable( $css_file ) && is_writable( $css_min_file ) ) { 
  19.  
  20. if ( ! class_exists( 'a3_lessc' ) ) { 
  21. include( dirname( __FILE__ ) . '/lib/lessc.inc.php' ); 
  22. if ( ! class_exists( 'a3_CSSmin' ) ) { 
  23. include( dirname( __FILE__ ) . '/lib/cssmin.inc.php' ); 
  24.  
  25. try { 
  26.  
  27. $less = new a3_lessc(); 
  28.  
  29. $compiled_css = $less->compileFile( $less_file ); 
  30.  
  31. if ( $compiled_css != '' ) { 
  32. $wp_filesystem->put_contents( $css_file, $compiled_css ); 
  33.  
  34. $compressor = new a3_CSSmin(); 
  35. $compressor->set_memory_limit( '512M' ); 
  36. $compressor->set_max_execution_time( 120 ); 
  37.  
  38. $compiled_css_min = $compressor->run( $compiled_css ); 
  39. if ( $compiled_css_min != '' ) 
  40. $wp_filesystem->put_contents( $css_min_file, $compiled_css_min ); 
  41.  
  42. } catch ( exception $ex ) { 
  43.  
  44. //echo ( __( 'Could not compile .less:', 'sass' ) . ' ' . $ex->getMessage() ); 
  45.