コード例 #1
0
ファイル: geopress.php プロジェクト: netconstructor/geopress
function the_address()
{
    global $post;
    $geo = GeoPress::get_geo($post->ID);
    $addr = $geo->loc;
    return $addr;
}
コード例 #2
0
ファイル: geopress.php プロジェクト: ajturner/geopress
 function update_post($id)
 {
     // delete_post_meta($id, '_geopress_id');
     global $wpdb;
     $postdata = $wpdb->get_row("SELECT * FROM {$wpdb->posts} WHERE ID = '{$id}'");
     $addr = $_POST['addr'];
     $geometry = $_POST['geometry'];
     $locname = $_POST['locname'];
     // Allow the location to be set within the post body
     if (preg_match_all('/GEOPRESS_LOCATION\\((.+)\\)/', $postdata->post_content, $matches) > 0) {
         // $locname = $matches[1];
         $addr = $matches[1][0];
     } elseif (preg_match_all('/geo:lat=([-\\d\\.]+)(.*)?geo:lon[g]?=([-\\d\\.]+)/', $postdata->post_content, $matches) > 0) {
         // $locname = $matches[1];
         $addr = "[" . $matches[1][0] . "," . $matches[3][0] . "]";
     } else {
     }
     // $map_format = $_POST['geopress_map_format'];
     // $map_zoom = $_POST['geopress_map_zoom'];
     // $map_type = $_POST['geopress_map_type'];
     if ($addr) {
         // if just lat/lon coordinates were given, don't geocode
         if (!preg_match('/\\[(.+),[ ]?(.+)\\]/', $addr, $matches)) {
             // If the user set the coordinates via the web interface (using the geocoder), don't change it here.
             if (preg_match('/(.+),[ ]?(.+)/', $geometry, $matches)) {
                 $lat = $matches[1];
                 $lon = $matches[2];
             } else {
                 list($lat, $lon) = geocode($addr);
             }
         } else {
             $lat = $matches[1];
             $lon = $matches[2];
         }
         list($warn, $mapurl) = yahoo_mapurl($addr);
         $coords = "{$lat} {$lon}";
         $coord_type = "point";
         // Create a new loc - therefore -1
         $geo_id = GeoPress::save_geo(-1, $locname, $addr, $coords, $coord_type, $warn, $mapurl, 1, $map_format, $map_zoom, $map_type);
         $updated = update_post_meta($id, '_geopress_id', $geo_id);
         if (!$updated) {
             add_post_meta($id, '_geopress_id', $geo_id);
         }
     }
 }