Fix WPML wrong language on front-end when logged-in

<?php
// Fixes an issue with the language randomly switching on facet refresh to the admin language 
// instead of front end language. Seems to happen when logged-in mostly.
// See: 
// https://facetwp.com/help-center/using-facetwp-with/multilingual/#fix-wpml-using-the-wrong-language-for-post-listing-and-facets

add_filter( 'facetwp_query_args', function( $args) {
    $http = FWP()->facet->http_params;
    if ( isset( $http['lang'] ) ) {
        do_action( 'wpml_switch_language', $http['lang'] );
    }
    return $args;
}, 11 );