Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //CSS Compressor
- //By: Donnie Archer
- //v1.0.0
- header("Content-type: text/css");
- /*
- * Set this to true so it will separate the content by files and not compress it.
- */
- $disable = false;
- /*
- * Too add stylesheets not in this dir, add the paths to the otherStylesheets array
- */
- $otherStylesheets = array();
- $otherStylesheets[] = "layout.css";
- $otherStylesheets[] = "menu.css";
- $otherStylesheets[] = "sidebar-menu.css";
- $otherStylesheets[] = "layout-full-span.css";
- $otherStylesheets[] = "custom.css";
- $css = "";
- //Uncomment the following line to auto scan the directory this file is in and import those css files.
- //$stylesheets = scandir(__DIR__);
- if(is_array($stylesheets)){
- $stylesheets = array_merge($stylesheets,$otherStylesheets);
- }else{
- $stylesheets = $otherStylesheets;
- }
- foreach($stylesheets AS $x => $file){
- if(preg_match("/\.css/",$file)){
- if($disable){
- $css .= "\n\n/*{$file}/*\n";
- }
- $css .= file_get_contents($file);
- }
- }
- if(!$disable){
- $css = str_replace(array("\n","\t","\r"),"",$css);
- $css = preg_replace("/\/\*[a-z0-9:]+\*\//i", "", $css);
- }
- echo $css;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement