Created
April 11, 2018 16:19
-
-
Save djrmom/c9d9315df0c9d6ed976af493951e75c8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 js code to check for any facets being selected | |
| */ | |
| add_action( 'wp_head', function() { ?> | |
| <script> | |
| (function($) { | |
| $(document).on('facetwp-loaded', function() { | |
| var facets_in_use = function() { | |
| var in_use = false; | |
| $.each(FWP.facets, function(name, val) { | |
| if (0 < val.length && 'paged' !== name) { | |
| in_use = true; | |
| return false; // exit loop | |
| } | |
| }); | |
| return in_use; | |
| } | |
| if ( facets_in_use() ) { | |
| // do stuff when there are facets with selections | |
| $('.facetwp-template').addClass('visible'); | |
| } else { | |
| // do stuff like hide reset button when there are no facets selected | |
| $('.facetwp-template').removeClass('visible'); | |
| } | |
| }); | |
| })(jQuery); | |
| </script> | |
| <?php }, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment