facetwp auto-check facet

<?php

function fwp_update_facets() {
	?>
	<script>
        (function($) {
            $(document).on('facetwp-loaded', function() {
                if ( 'trainings-finden' == FWP_HTTP.uri ) {
                    if ( FWP.facets['standort'].indexOf("aarau") > -1 && ! ( FWP.facets['standort'].indexOf("flexibel") > -1 ) ) {
                        FWP.is_reset = true;
                        FWP.facets['standort'].push("flexibel");
                        FWP.refresh();
                    }
                }
            });
        })(jQuery);
	</script>
	<?php
}
add_action( 'wp_head', 'fwp_update_facets' );