Closed christoferw closed 8 years ago
It's too bad that it's so hard to understand the difference between this and the geo_mashup_search_query_args filter (which is already obscure, entirely my fault). I wonder if a dedicated geo_mashup_search_location_text filter would be easier to understand and use?
a post filter would be more general, a filter only for the geo_mashup_search_location_text could be easier to use. On the other hand we could add an example to the documentation with examples how to use the more general post filter.
Here is an example filter:
/* add country to the geo mashup search */
add_filter( 'geo_mashup_search_query_post', 'my_geo_mashup_search_query_post_filter');
function my_geo_mashup_search_query_post_filter($geo_post_args){
if(!is_array($geo_post_args)) {return; }
$geo_post_args['location_text'] = $geo_post_args['location_text'].','.$_SESSION['location_country'];
return $geo_post_args;
}
That one makes sense to me, though I might hard code the country for clarity in the example. I can't really think of a use case for the more general filter though that the existing geo_mashup_search_query_args filter wouldn't cover.
Looks good, thanks! I'll do a 1.8.9 release with it shortly.
Here is also a new example for the documentation
/* add country to the geo mashup search */
add_filter( 'geo_mashup_search_query_location_text', 'my_geo_mashup_search_query_location_text_filter');
function my_geo_mashup_search_query_location_text_filter($location_text){
if(!is_string($location_text) ) {return; }
$location_text = $location_text.',DE';
return $location_text;
}
Perfect, thanks!
add filter to e.g change the location_text before any geocoding performs. Can be used to fix the search to a country code as well.