Last active
March 7, 2018 12:02
-
-
Save timersys/fca60362573643c32656aaf90d4e3446 to your computer and use it in GitHub Desktop.
Pass custom data to GeotargetingWP plugins instead of the API
This file contains 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 | |
/** | |
* If you want to cancel API calls for any reason or to pass custom that you can use the following | |
* filter. Note that we use json_decode(json_encode to pass an object instead of an array | |
**/ | |
// Cancel query only for admins | |
add_filter('geot/cancel_query', function() { | |
if( ! current_user_can('administrator') ) | |
return false; | |
$data = []; | |
$data['city']['names'] = [ 'en' => 'Miami']; | |
$data['city']['zip'] = '33166'; | |
$data['continent']['names'] = 'North America'; | |
$data['continent']['iso_code'] = 'NA'; | |
$data['country']['iso_code'] = 'US'; | |
$data['country']['names'] = [ 'en' => 'United States']; | |
$data['state']['iso_code'] = 'FL'; | |
$data['state']['names'] = [ 'en' => 'Florida']; | |
$data['geolocation']['latitude'] = '11.11'; | |
$data['geolocation']['longitude'] = '11.11'; | |
$data['geolocation']['accuracy_radius']= '100'; | |
$data['geolocation']['time_zone'] = 'UTC'; | |
return json_decode(json_encode($data)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment