WP Pagenavi support

<?php

// If your website is not in English, change "page" matches in line 14 to whatever it is in your language.

function fwp_pagenavi_support() {
?>
<script>
(function($) {
    $(document).on('facetwp-refresh', function() {
        if (! FWP.loaded) {
            $(document).on('click', '.wp-pagenavi a.page', function(e) {
                e.preventDefault();
                var matches = $(this).attr('href').match(/\/page\/(\d+)/);
                if (null != matches) {
                    FWP.paged = parseInt(matches[1]);
                }
                FWP.soft_refresh = true;
                FWP.refresh();
            });
        }
    });
})(jQuery);
</script>
<?php
}
add_action( 'wp_head', 'fwp_pagenavi_support', 50 );