facetwp auto enable filtering button on map

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/**
** enable filtering on load of map
**/
add_action( ‘wp_footer’, function() {
?>
<script>
(function($) {
$(document).on(‘facetwp-loaded’, function() {
var filterButton = $( “.facetwp-map-filtering” );
if ( !filterButton.hasClass(‘enabled’) && ‘undefined’ == typeof FWP_MAP.enableFiltering ) {
filterButton.text(FWP_JSON[‘map’][‘resetText’]);
FWP_MAP.is_filtering = true;
filterButton.addClass(‘enabled’);
FWP_MAP.enableFiltering = true;
}
});
})(jQuery);
</script>
<?php
}, 100 );
{{/gist}}