HEX
Server: LiteSpeed
System: Linux premium221.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
User: madepabj (2566)
PHP: 8.3.26
Disabled: NONE
Upload Files
File: /home/madepabj/hc-cosmetics.com/wp-content/themes/dbea/framework/class-compilesass.php
<?php
if ( ! class_exists( 'DBeaCompileSass' ) ) {
	class DBeaCompileSass {
		function dbea_getstyle($compile = 2, $scss = array('dir' => '', 'name' => ''), $css = array('dir' => '', 'name' => ''), $format = 'scss_formatter_compressed', $variables = array() ) {
			
			if($css['name'] == '') $css['name'] = $scss['name'];
			$scss_variables = '';
			if($variables) {
				foreach($variables as $propety => $value) {
					$scss_variables .= $propety . ':' . $value . ';';
					$css['name'] .= '-'.strtolower(preg_replace('/\W/i', '', $value));
				}
			}
			if( $compile == 2 || !file_exists(get_template_directory() . '/assets/css/' . $css['name'] . '.css') )
				$this->dbea_compilescss($scss, $css, $format, $scss_variables);
			return $css['name'] . '.css';
		}
		function dbea_compilescss($scss, $css, $format, $scss_variables) {
			global $wp_filesystem;
			if (empty($wp_filesystem)) {
				require_once ABSPATH . '/wp-admin/includes/file.php';
				WP_Filesystem();
			}
			if ( class_exists('ScssPhp\ScssPhp\Compiler') ) {
				$sass = new ScssPhp\ScssPhp\Compiler();
				if ( $format != NULL && $format != "scss_formatter" ){
					if ( $format == "scss_formatter_compressed" ) {
						$format = 'ScssPhp\ScssPhp\Formatter\Compressed';
						
					}elseif( $format == "scss_formatter_nested" ){
						$format = 'ScssPhp\ScssPhp\Formatter\Nested';
					}
					$sass->setFormatter($format);
				}
				
				$sass->addImportPath($scss['dir']);
				$string_sass = $scss_variables . $wp_filesystem->get_contents($scss['dir'] . $scss['name'] . '.scss'); //var_dump($string_sass); die();
				$string_css = $sass->compile($string_sass);
				$wp_filesystem->put_contents(
					$css['dir'] . $css['name'] . '.css',
					$string_css,
				  	FS_CHMOD_FILE
				);
			}
		}
	}
}
?>