Skip to content

Instantly share code, notes, and snippets.

@djrmom
Created August 28, 2017 15:42
Show Gist options
  • Select an option

  • Save djrmom/6e8845fdd8df8bae374bcb973d3874cf to your computer and use it in GitHub Desktop.

Select an option

Save djrmom/6e8845fdd8df8bae374bcb973d3874cf to your computer and use it in GitHub Desktop.
facetwp custom source for lat/long
<?php
add_filter( 'facetwp_index_row', function( $params, $class ) {
if ( 'product_proximity' == $params['facet_name'] ) {
$latlng = $params['facet_display_value'];
if ( is_string( $latlng ) ) {
$latlng = preg_replace( '/[^0-9.,-]/', '', $latlng );
if ( preg_match( "/^([\d.-]+),([\d.-]+)$/", $latlng ) ) {
$latlng = explode( ',', $latlng );
$params['facet_value'] = $latlng[0];
$params['facet_display_value'] = $latlng[1];
}
}
}
return $params;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment