Dynamic data for distance in Bricks builder

<?php 
/**
 ** in functions.php, custom hooks, or a snippets plugin,
 ** add a function to return the distance
 ** that you want to output, change the function as need to
 ** output your formatted distance
 ** https://facetwp.com/help-center/facets/facet-types/proximity/#display-the-post-distance-in-brick-with-a-dynamic-data-tag
 ** add to your bricks template as a custom dynamic data tag echo:
 ** {echo: fwp_distance()}
 ** https://d.pr/i/gaXXUf
 ** https://academy.bricksbuilder.io/article/dynamic-data/#advanced
 ** Alternatively, use a custom shortcode:
 ** https://facetwp.com/help-center/facets/facet-types/proximity/#display-the-post-distance-with-a-custom-shortcode
 **/

function fwp_distance() {

    $distance = facetwp_get_distance();
 
    // Round distance to 2 decimals and append ' mi' (or ' km')
    if ( false !== $distance ) {
        return round( $distance, 2 ) . ' mi';
    }

    return '';
}