Advertisement
DidouS

Toolbox Customizer reset theme_mod using a filter

Jan 16th, 2020
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2.  
  3. // Toolbox Customizer > 1.6.2 needed
  4.  
  5. /**
  6.  * these variables for LESS are define in your plugin
  7.  * notice the filter, that's the hookname that is going to get applied
  8.  * if more variables need the same filter you can do that like shown below
  9.  */
  10.  
  11. 'dbraflex_button_border_width'      => toolbox_customizer_css::gtm( 'dbraflex_button_border_width' , array( 'filter' => 'dbraflex_false_on_zero' ) , 'px' ),
  12. 'dbraflex_some_other_border_width'      => toolbox_customizer_css::gtm( 'dbraflex_some_other_border_width' , array( 'filter' => 'dbraflex_false_on_zero' ) , 'px' ),
  13.  
  14.  
  15.  
  16. /**
  17.  * Then, somewhere at the end of the file or at least outside of the load_my_variables() function you hook this function to
  18.  * the filter_hook
  19.  */
  20. add_filter( 'dbraflex_false_on_zero' , function( $value , $theme_mod , $unit ) {
  21.  
  22.     if ( get_theme_mod( $theme_mod ) == 0 ) return false;
  23.  
  24.     return $value;
  25.  
  26. } , 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement