I noticed a few quirks in the CSS colorizer, so I made an update. This will now grab any HEX color code in the same declaration, no matter where it is. That means that you can use it to change compact background with image styles or border colors. Also added a catch for the “transparent” keyword it’ll catch that as well. Code is below, snipplrs been updated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php require('../../../wp-load.php'); function colorize($m){ // Your code to get the new colors, this is grabbing values stored by the wordpress theme's option page. $c=get_option('tc_'.$m[4]); $m[3] = $c; if($c!=''){ return $c; }else{ return $m[0]; } } header("Content-type: text/css"); $css = file_get_contents('style.css'); $css = preg_replace('~/\*.*\*/|\n|\t|(?<=:)\s+|(?<={)\s+|(?<=})\s+|(?<=,)\s+|\s+(?=;)|\s+(?={)|\s+(?=})|\s+(?<=:)~sU','',preg_replace_callback('~((transparent|#[A-F0-9a-f]{6}))(?=(.)+(?=/\*#(.+)#\*/))~U','colorize',$css)); echo $css; ?> |
The changes only take place in the regular expressions, specifically the second one. Leave any new feedback in the comments and I’ll keep making changes as needed.