Created
August 27, 2015 10:49
-
-
Save gnikolopoulos/02e177e5ea31d35b2349 to your computer and use it in GitHub Desktop.
[Wordpress] Combile all your CSS into a single file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-type: text/css'); | |
ob_start("compress"); | |
function compress( $minify ) | |
{ | |
/* remove comments */ | |
$minify = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $minify ); | |
/* remove tabs, spaces, newlines, etc. */ | |
$minify = str_replace( array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $minify ); | |
return $minify; | |
} | |
/* css files for combining */ | |
include('base.css'); | |
include('style.css'); | |
include('another-css.css'); | |
ob_end_flush(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment