Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function setBGMPMapShortcodeArguments( $options ) {
- global $bgmp;
- $ipAdd = getIP();
- if ($ipAdd !== 'UNKNOWN'){
- $apikey = 'yourKey';
- $secret = 'yourSecret';
- $quova = new Example_Quova_GeoIp($apikey, $secret);
- $location = json_decode($quova->getLocation($ipAdd));
- $coordinates = $bgmp->geocode($location->ipinfo->Location->CityData->postal_code);
- } else { $coordinates = $bgmp->geocode( '33131' ); }
- $options[ 'mapWidth' ] = 800;
- $options[ 'mapHeight' ] = 600;
- $options[ 'latitude' ] = $coordinates[ 'latitude' ];
- $options[ 'longitude' ] = $coordinates[ 'longitude' ];
- $options[ 'zoom' ] = 18;
- $options[ 'type' ] = 'ROADMAP';
- $options[ 'typeControl' ] = 'HORIZONTAL_BAR';
- $options[ 'navigationControl' ] = 'SMALL';
- $options[ 'infoWindowMaxWidth' ] = 350;
- // $options[ 'categories' ] = array( 'record-stores', 'parks' );
- return $options;
- }
- add_filter( 'bgmp_map-shortcode-arguments', 'setBGMPMapShortcodeArguments' );
- function getIP() {
- $ip;
- if (getenv("HTTP_CLIENT_IP"))
- $ip = getenv("HTTP_CLIENT_IP");
- else if(getenv("HTTP_X_FORWARDED_FOR"))
- $ip = getenv("HTTP_X_FORWARDED_FOR");
- else if(getenv("REMOTE_ADDR"))
- $ip = getenv("REMOTE_ADDR");
- else
- $ip = "UNKNOWN";
- return $ip;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement