Created
August 28, 2017 15:42
-
-
Save djrmom/6e8845fdd8df8bae374bcb973d3874cf to your computer and use it in GitHub Desktop.
facetwp custom source for lat/long
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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