Skip to content

Instantly share code, notes, and snippets.

@gnikolopoulos
Created August 27, 2015 10:49
Show Gist options
  • Save gnikolopoulos/02e177e5ea31d35b2349 to your computer and use it in GitHub Desktop.
Save gnikolopoulos/02e177e5ea31d35b2349 to your computer and use it in GitHub Desktop.
[Wordpress] Combile all your CSS into a single file
<?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