Last active
July 11, 2021 13:31
-
-
Save djrmom/7e9233b2b67393cf90bde4ca470e2961 to your computer and use it in GitHub Desktop.
facetwp add tooltips to slider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** adds tooltips to slider handles | |
** https://refreshless.com/nouislider/slider-options/#section-tooltips | |
** note that you need an array even if you want true for both handles | |
**/ | |
add_action( 'wp_footer', function() { ?> | |
<script> | |
(function($) { | |
if ('object' != typeof FWP) { | |
return; | |
} | |
FWP.hooks.addFilter('facetwp/set_options/slider', function(opts, facet) { | |
if (facet.facet_name == 'price') { | |
opts.tooltips = [true,true]; | |
return opts; | |
} | |
}); | |
})(jQuery); | |
</script> | |
<?php }, 100 ); |
Thanks! Anybody an idea how to hide the decimals? Since it does not "respect" the decimal settings of the facet itself.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Had this break on me due to a plugin update. Replacing "wp" with the "FWP" object got things working again. To be clear:
wp.hooks.addFilter('facetwp/set_options/slider', function(opts, facet)
becomes
FWP.hooks.addFilter('facetwp/set_options/slider', function(opts, facet)