<?php
/** prepend selected value label of fselect with default value **/
add_action( 'wp_footer', function() {
?>
<script>
(function($) {
if ('object' !== typeof FWP) {
return;
}
$(function() {
FWP.hooks.addAction('facetwp/loaded', function() {
$('.facetwp-type-fselect').each(function() {
var facet_name = $(this).attr('data-name');
var facet_label = $(this).find('.facetwp-dropdown > option:first-child').text();
if ( 'undefined' !== typeof FWP.facets[facet_name] && FWP.facets[facet_name].length > 0 ) {
var label = $(this).find('.fs-label');
if ( ! ( -1 < label.html().indexOf(facet_label) ) ) {
label.prepend( facet_label + ': ' );
}
}
});
}, 100 );
});
})(jQuery);
</script>
<?php
}, 100 );