CSS minifier and color replaces


/ Published in: PHP
Save to your folder(s)

With this file you can load stylesheets and minify the code while changing colors. The stylesheets are loaded using file_get_contents and you can attach them one after another if you have multiple sheets. The colors are replaces based on a variable thats commented out of the css code, an example of the way thats formatted is below the cod block. The minification is done with a regular expression that removes all comments, line breaks, and un-needed spaces. The color replacement is done with a different regular expression and the colorize function that takes the variable and returns a color. You can use whatever method you want to get the color, but I personally am using variables from a Wordpress plugin (and stores using the Wordpress options function) to give users color customizability of their site.

If you have any questions or comments you can post a comment here or at the link, there is also a more in depth explanation at the link if your interested.

UPDATE: improved it's ability to find colors in the CSS declaration, also added the "transparent" keyword in as something it can find.

URL: http://fatfolderdesign.com/382/css/css-minifier-and-color-changer

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.