cyberhobo / wordpress-geo-mashup

Official repository for Geo Mashup, the plugin that makes WordPress into a GeoCMS. Documentation:
https://github.com/cyberhobo/wordpress-geo-mashup/wiki/Getting-Started
63 stars 15 forks source link

Update geo-mashup-search.php #746

Closed christoferw closed 8 years ago

christoferw commented 8 years ago

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.

cyberhobo commented 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?

christoferw commented 8 years ago

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.

christoferw commented 8 years ago

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;
}
cyberhobo commented 8 years ago

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.

cyberhobo commented 8 years ago

Looks good, thanks! I'll do a 1.8.9 release with it shortly.

christoferw commented 8 years ago

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;
}
cyberhobo commented 8 years ago

Perfect, thanks!