-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically change variables #42
Comments
In the code, It's fairly easy to modify that for your needs: function my_less_vars( $vars ) {
// insert code to grab the values of $data and $background here
$vars[ 'bg-color' ] = $data['background_color'];
$vars['background'] = $background;
return $vars;
}
add_filter( 'less_vars', 'my_less_vars' ); |
That's cool, thanks, but that's obviously not all changes I need to make. This code handles php to css conversation every time I change options in admin panel and hit save or reset.
Now I can't figure out how to adjust it, so it would reload less vars instead. |
Hi, when you pass those values into less as soon they're changed in admin |
Hi, thank you for your answer. It seems that I cant even get it working as it is, without SMOF.
I use @main-color variable in my less styles. The page loads normally but no changes are applied. What I'm doing wrong? |
Can you paste in the less code and if possible the compiled CSS? |
Well, I now realize that this code doesn't save anything to style.css. Whar do i miss? Do i need to set a path to css folder somewhere? I've just delited style.css and re-saved the function.php and no new css file showed up. |
Ah right, the only folder you can rely on being writable in Wordpress is Sorry should have explained that! |
Ok, i have that folder but it's empty. When saving changes to the code nothing appears in that folder. |
It's not empty, the style.css and style.css.cache appear when i reload the page. But here's another weird thing, when I change a @main-color it will appear in that style.css only after I manually delete the file and then reload the page. |
Sorry for taking your time and thank you for tying to help me! |
Hi there, I'm still experiencing that problem. Changes won't apply until i manually delete css file from wp-less-cache folder and reload the page. What could be the problem? |
This is happening to me as well with Advanced Custom Fields. Anybody find a fix? |
Possible filemtime() issue... PR #73 might fix it |
Hello there,
I'm trying to combine wp-less with SMOF(https://github.com/sy4mil/Options-Framework) in my theme development.
SMOF uses variables that could be changed by users via admin options page. For example:
The following code is used in style.php and saved to css on the fly:
It's kind of handy, but since all styles are written in less, wp-less is much more desirable.
Now, how can i use SMOF's variables here:
Sorry if it's kind of stupid question, I'm new to wp & php.
Thanks!
The text was updated successfully, but these errors were encountered: