Closed mekshq closed 10 years ago
Thanks for reporting this @mekshq . I'll have a look at it now.
I have fixed it myself but maybe you will find a better approach. Here is my solution:
foreach ( $minit_todo as $t => $script ) { // Make sure this is a relative URL so that we can check if it is local $src = str_replace( $object->base_url, '', $object->registered[ $script ]->src ); // Skip if the file is not hosted locally if ( ! file_exists( ABSPATH . $src ) || empty( $src ) ) continue; $done[ $script ] = apply_filters( 'minit-item-' . $extension, file_get_contents( ABSPATH . $src ), $object, $script ); if($extension == 'css'){ if(isset($object->registered[ $script ]->extra['after']) && !empty($object->registered[ $script ]->extra['after'])){ foreach($object->registered[ $script ]->extra['after'] as $inline){ $done[ $script ] .= $inline; } } } }
I'm also about to add simple function which will compress css in this foreach loop, so css can be minified.
$done[ $script ] = compress_css_code(done[ $script ]); function compress_css_code($code) { // Remove Comments $code = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $code); // Remove tabs, spaces, newlines, etc. $code = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $code); return $code; }
What do you think?
Should be fixed with ae12afda2 and 1.0.
Hi,
First of all, thanks for the great plugin!
The only issue I have noticed is that it ignores styles added via wp_add_inline_style() function.
For example I have this:
This is just an example, $thr_dynamic_css is actually dynamicaly generated css string which is appended to a main css file. So, when I use "minit" everything is ok with the main css file, it just excludes style appended via wp_add_inline_style.
Can you please take a look?