How do you add the default colors in Button module?
I was working on a site which have same color of button on lot of pages. By default button module have blank color under style->color section. So every time I was setting the color and it was very frustrated work for me. Therefore I can create a general template and add the button module there. But I did not want it. So I used some custom code and solved it.
For client site button’s color would be:
background color = #f59120
background hovercolor = #808080
text color = #fff
text hover color = #fff
So I opened my functions.php file and put this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
add_filter( 'fl_builder_settings_form_defaults', 'wpbw_default_color_button_module', 20, 2 ); function wpbw_default_color_button_module( $defaults, $type ) { if( $type == "button-module" ) { $defaults->bg_color = "f59120"; $defaults->bg_hover_color = "808080"; $defaults->text_color = "ffffff"; $defaults->text_hover_color = "ffffff"; } return $defaults; } |
This doesn’t seem to be working anymore. Where is $type == “button-module” coming from?
Now it’s working. Odd. Still want to know the answer though on that type question. 🙂
Module slug would be module file name with ‘-module’ suffix. e.g: Heading module’s file name is heading.php. So slug would be ‘heading-module’ for Heading module.
I’ve been looking for exactly this tip — looking forward to trying it. Thanks!
Wow! Great! Does this set the default color for all buttons in all modules? For example, forms, subscribe buttons, etc.?
Nope. It will only work for button module. But your idea is good. I liked it. I shall test it.
Wow, very very handy, Chinmoy, Thanks!
Awesome time-saver, thanks Chinmoy.
Welcome 🙂
Great tip Chimoy!