facetwp fselect levels

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** adds css class to designate level in hierarcy fselect **/
add_action( ‘wp_footer’, function() {
?>
<script>
(function($) {
$(document).on(‘facetwp-loaded’, function() {
$.each( $( “.fs-option” ), function() {
var label = $(this).children(“.fs-option-label”).first().html();
if ( -1 !== label.indexOf(”    “) ) {
$(this).addClass( ‘third’ );
} else if ( -1 !== label.indexOf(”  “) ) {
$(this).addClass( ‘second’ );
} else {
$(this).addClass( ‘first’ );
}
} )
});
})(jQuery);
</script>
<?php
}, 100 );
{{/gist}}