FacetWP – disable Ultimate Member for ajax requests

<?php
/**
* Prevent Ultimate Member from running for FacetWP ajax refreshes
* @ref ticket #13727
*/

/**
* Disable redirect
*/
add_filter( 'wp_redirect', function( $location, $status = 302 ) {
    if ( filter_input( 0, 'action' ) === 'facetwp_refresh' && $status === 404 ) {
        $location = false;
    }
    return $location;
}, 10, 2 );

/**
* Disable Ultimate Member and its extensions
*/
add_filter( 'option_active_plugins', function( $value, $option ) {
    if ( filter_input( 0, 'action' ) === 'facetwp_refresh' ) {
        foreach ( $value as $i => $plugin ) {
            if ( $plugin === 'ultimate-member/ultimate-member.php' ) {
                unset( $value[ $i ] );
            }
            if ( strpos( $plugin, 'um-' ) === 0 ) {
                unset( $value[ $i ] );
            }
        }
    }
    return $value;
}, 10, 2 );