Closed rahularyan closed 11 years ago
Solved this:
if ( empty( $cache ) || empty( $cache[ 'less' ][ 'updated' ] ) || $less_cache[ 'updated' ] > $cache[ 'less' ][ 'updated' ] ) { file_put_contents( $cache_path, serialize( array( 'vars' => $this->vars, 'less' => $less_cache ) ) ); file_put_contents( $css_path, $less_cache[ 'compiled' ] ); }elseif ($this->vars !== $cache[ 'vars' ]){ $less_cache = $less->cachedCompile( $cache[ 'less' ], apply_filters( 'less_force_compile', true ) ); file_put_contents( $cache_path, serialize( array( 'vars' => $this->vars, 'less' => $less_cache ) ) ); file_put_contents( $css_path, $less_cache[ 'compiled' ] ); }
Currently having the same problem. I replaced this with your code above:
if ( empty( $cache ) || empty( $cache[ 'less' ][ 'updated' ] ) || $less_cache[ 'updated' ] > $cache[ 'less' ][ 'updated' ] || $this->vars !== $cache[ 'vars' ] ) {
file_put_contents( $cache_path, serialize( array( 'vars' => $this->vars, 'less' => $less_cache ) ) );
file_put_contents( $css_path, $less_cache[ 'compiled' ] );
}
Not sure if I did that correctly but I have no reload. However, the variable is changing in my cache file. I am trying to use Advanced Custom Fields with this. It works but I have to clear the cache everytime.
I updated this code to this:
if ( empty( $cache ) || empty( $cache[ 'less' ][ 'updated' ] ) || $less_cache[ 'updated' ] > $cache[ 'less' ][ 'updated' ] ) {
file_put_contents( $cache_path, serialize( array( 'vars' => $this->vars, 'less' => $less_cache ) ) );
file_put_contents( $css_path, $less_cache[ 'compiled' ] );
} else ($this->vars != $cache[ 'vars' ]){
$less_cache = $less->cachedCompile( $cache[ 'less' ], apply_filters( 'less_force_compile', true ) );
file_put_contents( $cache_path, serialize( array( 'vars' => $this->vars, 'less' => $less_cache ) ) );
file_put_contents( $css_path, $less_cache[ 'compiled' ] );
}
The elseif statement was allowing it to not recompile. Also you had "!==" instead of "!=".
My code is working fine, you can see my project https://github.com/rahularyan/rabs, I will upload it tomorrow
@rahularyan great! That is strange it did not work for me and these adjustments did. Very cool though. Just trying to help!
I am including wp-less in my theme, But I am stucked. I am changing variable from
get_option
, like:$vars['headerBG'] = get_option('color_header');
And I am calling this variable in
theme.less
, Like:Everything work fine until here, Compile result is :
now if I change value of
get_option('color_header')
then as usual cache filetheme.less.cache
andtheme.less.css
get updated. Variable@headerBG
s new value was updated incache
files but not incss
files. NOTE: CSS file is recompiling but color is not updating.That is my problem! please help me to fix it.