This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 10th, 2012  |  syntax: PHP  |  size: 1.41 KB  |  views: 52  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. function setBGMPMapShortcodeArguments( $options ) {
  4.     global $bgmp;
  5.     $ipAdd = getIP();
  6.         if ($ipAdd !== 'UNKNOWN'){  
  7.                 $apikey = 'yourKey';
  8.                 $secret = 'yourSecret';
  9.                 $quova = new Example_Quova_GeoIp($apikey, $secret);
  10.                 $location = json_decode($quova->getLocation($ipAdd));
  11.                 $coordinates = $bgmp->geocode($location->ipinfo->Location->CityData->postal_code);
  12.         } else { $coordinates = $bgmp->geocode( '33131' ); }
  13.    
  14.     $options[ 'mapWidth' ]                = 800;
  15.     $options[ 'mapHeight' ]               = 600;
  16.     $options[ 'latitude' ]                = $coordinates[ 'latitude' ];
  17.     $options[ 'longitude' ]               = $coordinates[ 'longitude' ];
  18.     $options[ 'zoom' ]                    = 18;
  19.     $options[ 'type' ]                    = 'ROADMAP';
  20.     $options[ 'typeControl' ]         = 'HORIZONTAL_BAR';
  21.     $options[ 'navigationControl' ]       = 'SMALL';
  22.     $options[ 'infoWindowMaxWidth' ]  = 350;
  23.    // $options[ 'categories' ]          = array( 'record-stores', 'parks' );
  24.    
  25.     return $options;
  26. }
  27. add_filter( 'bgmp_map-shortcode-arguments', 'setBGMPMapShortcodeArguments' );
  28.  
  29. function getIP() {
  30.         $ip;
  31.         if (getenv("HTTP_CLIENT_IP"))
  32.                 $ip = getenv("HTTP_CLIENT_IP");
  33.         else if(getenv("HTTP_X_FORWARDED_FOR"))
  34.                 $ip = getenv("HTTP_X_FORWARDED_FOR");
  35.         else if(getenv("REMOTE_ADDR"))
  36.                 $ip = getenv("REMOTE_ADDR");
  37.         else
  38.                 $ip = "UNKNOWN";
  39.         return $ip;
  40. }
  41.  
  42. ?>
clone this paste RAW Paste Data