Google Map Shortcode - Version 2.0.1

Version Description

  • Geocoding API request changed.
    • Html width parameter included.
Download this release

Release Info

Developer alaingg
Plugin Icon wp plugin Google Map Shortcode
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0 to 2.0.1

Files changed (2) hide show
  1. google-map-shortcode.php +88 -51
  2. readme.txt +10 -4
google-map-shortcode.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Google Map Shortcode
4
  Plugin URI: http://web-argument.com/google-map-shortcode-2-0-total-solution/
5
  Description: Include Google Map in your blogs with just one click.
6
- Version: 2.0
7
  Author: Alain Gonzalez
8
  Author URI: http://web-argument.com/
9
  */
@@ -17,6 +17,7 @@ define('GMSHC_VERSION','2.0');
17
  */
18
  function get_gmshc_options ($default = false){
19
 
 
20
  $gmshc_default = array(
21
  'zoom' => '10',
22
  'width' => '400',
@@ -24,7 +25,7 @@ function get_gmshc_options ($default = false){
24
  'number' => 50,
25
  'language' => 'en',
26
  'windowhtml' => gmshc_defaul_windowhtml(),
27
- 'icon' => '',
28
  'use_icon' => 'default',
29
  'default_icon' => 'marker.png',
30
  'custom_icon' => '',
@@ -309,16 +310,16 @@ function gmshc_tab_process(){
309
  */
310
  function gmshc_defaul_windowhtml(){
311
 
312
- $defaul_gmshc_windowhtml = "<div style='margin:0; padding:0px; height:110px; width:310px; overflow:hidden'>\n";
313
  $defaul_gmshc_windowhtml .= "<div style='float:left; width:200px'>\n";
314
- $defaul_gmshc_windowhtml .= "<a class='title' href='%link%' style='clear:both; display:block'>%title%</a>\n";
315
- $defaul_gmshc_windowhtml .= "<div style='font-size:11px; clear:both'><strong>%address%</strong></div>\n";
316
- $defaul_gmshc_windowhtml .= "<div style='font-size:11px; clear:both; line-height:16px'>%excerpt%</div>\n";
317
  $defaul_gmshc_windowhtml .= "<a href='%link%' style='font-size:11px; float:left; display:block'>more &raquo;</a>\n";
318
  $defaul_gmshc_windowhtml .= "<img src='".GMSC_PLUGIN_URL."/images/open.jpg\' style='float: right; margin-right:5px'/> \n";
319
  $defaul_gmshc_windowhtml .= "<a href='%open_map%' target='_blank' style='font-size:11px; float: right; display:block;'>Open Map</a>\n";
320
  $defaul_gmshc_windowhtml .= "</div>\n";
321
- $defaul_gmshc_windowhtml .= "<img src='%thubnail%' style='float:left; margin:8px 0 0 8px; width:90px; height:90px'/>\n";
322
  $defaul_gmshc_windowhtml .= "</div>\n";
323
 
324
  return $defaul_gmshc_windowhtml;
@@ -479,7 +480,6 @@ function gmshc_sc($atts) {
479
 
480
  if ( count($the_items) > 0 ) {
481
 
482
-
483
  $canvas = "canvas_".wp_generate_password(4, false);
484
 
485
 
@@ -506,12 +506,18 @@ function gmshc_sc($atts) {
506
  $open_map = "http://maps.google.com/?q=".str_replace(" ","%20",$single_point['address']);
507
  $point_title = isset($single_point['title'])?$single_point['title']:"";
508
  $point_link = isset($single_point['link'])?$single_point['link']:"";
509
- $point_img = isset($single_point['img'])?$single_point['img']:"";
 
 
 
 
 
 
510
  $point_excerpt = isset($single_point['excerpt'])?$single_point['excerpt']:"";
511
 
512
 
513
- $find = array("\f","\v","\t","\r","\n","\\","\"","%title%","%link%","%thubnail%", "%excerpt%","%address%","%open_map%");
514
- $replace = array("","","","","","","'",$point_title,$point_link,$point_img,$point_excerpt,$single_point['address'],$open_map);
515
 
516
  $info = str_replace( $find,$replace, $windowhtml);
517
 
@@ -895,7 +901,11 @@ function gmshc_options_page() {
895
  <tr>
896
  <td align="right"><strong>%open_map%</strong></td>
897
  <td><?php _e("Open this point on Google Map") ?></td>
898
- </tr>
 
 
 
 
899
  </table>
900
  <br />
901
 
@@ -924,47 +934,47 @@ function gmshc_options_page() {
924
  </p>
925
 
926
  <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;">Use</h3>
927
- <p>You can include a Google Map Shortcode everywhere</p>
928
 
929
- <p>In your post using: <strong>[google-map-sc option = "option value"]</strong></p>
930
- <p>In your theme files using: <strong> < ?php echo do_shortcode [google-map-sc option = "option value"] ? ></strong></p>
931
 
932
  <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;">Options</h3>
933
 
934
  <table width="80%%" border="0" cellspacing="10" cellpadding="0">
935
  <tr>
936
- <td width="150"><div align="right"><strong>address</strong></div></td>
937
- <td>Specific address</td>
938
  </tr>
939
  <tr>
940
  <td><div align="right"><strong>id</strong></div></td>
941
- <td>Specific post ID</td>
942
  </tr>
943
  <tr>
944
- <td><div align="right"><strong>cat</strong></div></td>
945
- <td>Include post under this categories. (category number separated by comma)</td>
946
  </tr>
947
  <tr>
948
- <td><div align="right"><strong>number</strong></div></td>
949
- <td>Number of points/post on your map (Default 10)</td>
950
  </tr>
951
  <tr>
952
- <td><div align="right"><strong>zoom</strong></div></td>
953
- <td>Inicial zoom (Default 10)</td>
954
  </tr>
955
  <tr>
956
- <td><div align="right"><strong>width</strong></div></td>
957
- <td>Width of your map</td>
958
  </tr>
959
  <tr>
960
- <td><div align="right"><strong>height</strong></div></td>
961
- <td>Height of your map</td>
962
  </tr>
963
  </table>
964
 
965
  <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;">Feedback</h3>
966
 
967
- <p>For more details and examples visite the <a href="http://web-argument.com/2011/05/04/google-map-shortcode-2-0-total-solution/">Plugin Page</a>. All the comments are welcome.</p>
968
 
969
 
970
  <p class="submit">
@@ -999,49 +1009,76 @@ function gmshc_options_page() {
999
  <?php }
1000
 
1001
  function gmshc_point ($address,$ltlg){
1002
-
1003
- if (!empty($ltlg)) $query = $ltlg;
1004
- else if (!empty($address)) {
 
 
 
 
 
 
 
1005
 
1006
  $find = array("\n","\r"," ");
1007
  $replace = array("","","+");
1008
  $address = str_replace( $find,$replace, $address);
1009
 
1010
  $query = $address;
 
1011
  }
1012
  else return false;
1013
 
1014
- $gmshc_key = get_option('gmshc_key');
1015
-
1016
- $url = 'http://maps.google.com/maps/geo?q='.$query.'&key='.$gmshc_key.'&sensor=false&output=xml&oe=utf8';
1017
-
1018
- $response = gmshc_xml2array($url);
1019
-
1020
- if (isset($response['kml']['Response']['Placemark']['Point'])) {
1021
-
1022
- $coordinates = $response['kml']['Response']['Placemark']['Point']['coordinates'];
1023
- $address = $response['kml']['Response']['Placemark']['address'];
 
 
 
 
1024
 
1025
- if (!empty($coordinates)) {
1026
 
1027
- $point_array = split(",",$coordinates);
1028
 
1029
- $point = $point_array[1].",".$point_array[0];
1030
 
1031
- $response = array('point'=>$point,'address'=>$address);
1032
 
1033
- return $response;
 
 
 
 
 
 
 
 
 
1034
 
1035
- }
1036
-
1037
- } else {
1038
 
1039
- return false;
1040
 
 
 
1041
  }
 
 
1042
 
1043
  }
1044
 
 
 
1045
  //from http://us3.php.net/manual/en/function.xml-parse.php
1046
  function gmshc_xml2array($url, $get_attributes = 1, $priority = 'tag')
1047
  {
3
  Plugin Name: Google Map Shortcode
4
  Plugin URI: http://web-argument.com/google-map-shortcode-2-0-total-solution/
5
  Description: Include Google Map in your blogs with just one click.
6
+ Version: 2.0.1
7
  Author: Alain Gonzalez
8
  Author URI: http://web-argument.com/
9
  */
17
  */
18
  function get_gmshc_options ($default = false){
19
 
20
+
21
  $gmshc_default = array(
22
  'zoom' => '10',
23
  'width' => '400',
25
  'number' => 50,
26
  'language' => 'en',
27
  'windowhtml' => gmshc_defaul_windowhtml(),
28
+ 'icon' => GMSC_PLUGIN_URL.'/images/icons/marker.png',
29
  'use_icon' => 'default',
30
  'default_icon' => 'marker.png',
31
  'custom_icon' => '',
310
  */
311
  function gmshc_defaul_windowhtml(){
312
 
313
+ $defaul_gmshc_windowhtml = "<div style='margin:0; padding:0px; height:110px; width:%with%; overflow:hidden; font-size:11px; clear:both; line-height: 16px;'>\n";
314
  $defaul_gmshc_windowhtml .= "<div style='float:left; width:200px'>\n";
315
+ $defaul_gmshc_windowhtml .= "<a class='title' href='%link%' style='clear:both; display:block; font-size:12px; line-height: 18px; font-weight:bold;'>%title%</a>\n";
316
+ $defaul_gmshc_windowhtml .= "<div><strong>%address%</strong></div>\n";
317
+ $defaul_gmshc_windowhtml .= "<div>%excerpt%</div>\n";
318
  $defaul_gmshc_windowhtml .= "<a href='%link%' style='font-size:11px; float:left; display:block'>more &raquo;</a>\n";
319
  $defaul_gmshc_windowhtml .= "<img src='".GMSC_PLUGIN_URL."/images/open.jpg\' style='float: right; margin-right:5px'/> \n";
320
  $defaul_gmshc_windowhtml .= "<a href='%open_map%' target='_blank' style='font-size:11px; float: right; display:block;'>Open Map</a>\n";
321
  $defaul_gmshc_windowhtml .= "</div>\n";
322
+ $defaul_gmshc_windowhtml .= "<div style='float:left'>%thubnail%</div>\n";
323
  $defaul_gmshc_windowhtml .= "</div>\n";
324
 
325
  return $defaul_gmshc_windowhtml;
480
 
481
  if ( count($the_items) > 0 ) {
482
 
 
483
  $canvas = "canvas_".wp_generate_password(4, false);
484
 
485
 
506
  $open_map = "http://maps.google.com/?q=".str_replace(" ","%20",$single_point['address']);
507
  $point_title = isset($single_point['title'])?$single_point['title']:"";
508
  $point_link = isset($single_point['link'])?$single_point['link']:"";
509
+ if(isset($single_point['img'])) {
510
+ $point_img = "<img src='".$single_point['img']."' style='margin:8px 0 0 8px; width:90px; height:90px'/>";
511
+ $html_with = "310px";
512
+ } else {
513
+ $point_img = "";
514
+ $html_with = "auto";
515
+ }
516
  $point_excerpt = isset($single_point['excerpt'])?$single_point['excerpt']:"";
517
 
518
 
519
+ $find = array("\f","\v","\t","\r","\n","\\","\"","%title%","%link%","%thubnail%", "%excerpt%","%address%","%open_map%","%with%");
520
+ $replace = array("","","","","","","'",$point_title,$point_link,$point_img,$point_excerpt,$single_point['address'],$open_map,$html_with);
521
 
522
  $info = str_replace( $find,$replace, $windowhtml);
523
 
901
  <tr>
902
  <td align="right"><strong>%open_map%</strong></td>
903
  <td><?php _e("Open this point on Google Map") ?></td>
904
+ </tr>
905
+ <tr>
906
+ <td align="right"><strong>%width%</strong></td>
907
+ <td><?php _e("Info Html width") ?></td>
908
+ </tr>
909
  </table>
910
  <br />
911
 
934
  </p>
935
 
936
  <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;">Use</h3>
937
+ <p><?php _e("You can include a Google Map Shortcode everywhere") ?></p>
938
 
939
+ <p><?php _e("In your post using: ") ?><strong>[google-map-sc option = "option value"]</strong></p>
940
+ <p><?php _e("In your theme files using: ") ?><strong> echo do_shortcode ('[google-map-sc option = "option value"]') </strong></p>
941
 
942
  <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;">Options</h3>
943
 
944
  <table width="80%%" border="0" cellspacing="10" cellpadding="0">
945
  <tr>
946
+ <td width="150"><div align="right"><strong><?php _e("address") ?></strong></div></td>
947
+ <td><?php _e("Specific address") ?></td>
948
  </tr>
949
  <tr>
950
  <td><div align="right"><strong>id</strong></div></td>
951
+ <td><?php _e("Specific post ID") ?></td>
952
  </tr>
953
  <tr>
954
+ <td><div align="right"><strong><?php _e("cat") ?></strong></div></td>
955
+ <td><?php _e("Include post under this categories. (category number separated by comma)") ?></td>
956
  </tr>
957
  <tr>
958
+ <td><div align="right"><strong><?php _e("number") ?></strong></div></td>
959
+ <td><?php _e("Number of points/post on your map (Default 10)") ?></td>
960
  </tr>
961
  <tr>
962
+ <td><div align="right"><strong><?php _e("zoom") ?></strong></div></td>
963
+ <td><?php _e("Inicial zoom (Default 10)") ?></td>
964
  </tr>
965
  <tr>
966
+ <td><div align="right"><strong>width") ?></strong></div></td>
967
+ <td><?php _e("Width of your map") ?></td>
968
  </tr>
969
  <tr>
970
+ <td><div align="right"><strong><?php _e("height") ?></strong></div></td>
971
+ <td><?php _e("Height of your map") ?></td>
972
  </tr>
973
  </table>
974
 
975
  <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;">Feedback</h3>
976
 
977
+ <p><?php _e('For more details and examples visite the <a href="http://web-argument.com/2011/05/04/google-map-shortcode-2-0-total-solution/">Plugin Page</a>. All the comments are welcome.') ?></p>
978
 
979
 
980
  <p class="submit">
1009
  <?php }
1010
 
1011
  function gmshc_point ($address,$ltlg){
1012
+ //http://code.google.com/apis/maps/documentation/geocoding/
1013
+
1014
+ $formatted_address = "";
1015
+ $point = "";
1016
+ $response = false;
1017
+
1018
+ if (!empty($ltlg)) {
1019
+ $query = $ltlg;
1020
+ $type = "latlng";
1021
+ } else if (!empty($address)) {
1022
 
1023
  $find = array("\n","\r"," ");
1024
  $replace = array("","","+");
1025
  $address = str_replace( $find,$replace, $address);
1026
 
1027
  $query = $address;
1028
+ $type = "address";
1029
  }
1030
  else return false;
1031
 
1032
+ if(function_exists('json_decode')){
1033
+
1034
+ $options = get_gmshc_options();
1035
+ $api_url = "http://maps.googleapis.com/maps/api/geocode/json?".$type."=".$query."&sensor=false&language=".$options['language'];
1036
+
1037
+ $json_answ = file_get_contents($api_url);
1038
+ $answ_arr = json_decode($json_answ,true);
1039
+
1040
+ if (isset($answ_arr["status"]) && $answ_arr["status"] == "OK"){
1041
+ $formatted_address = $answ_arr["results"]["0"]["formatted_address"];
1042
+ $point = $answ_arr["results"]["0"]["geometry"]["location"]["lat"].",".$answ_arr["results"]["0"]["geometry"]["location"]["lng"];
1043
+ }
1044
+
1045
+ } else {
1046
 
1047
+ $gmshc_key = get_option('gmshc_key');
1048
 
1049
+ $url = 'http://maps.google.com/maps/geo?q='.$query.'&key='.$gmshc_key.'&sensor=false&output=xml&oe=utf8';
1050
 
1051
+ $response = gmshc_xml2array($url);
1052
 
1053
+ if (isset($response['kml']['Response']['Placemark']['Point'])) {
1054
 
1055
+ $coordinates = $response['kml']['Response']['Placemark']['Point']['coordinates'];
1056
+ $formatted_address = $response['kml']['Response']['Placemark']['address'];
1057
+
1058
+ if (!empty($coordinates)) {
1059
+
1060
+ $point_array = split(",",$coordinates);
1061
+
1062
+ $point = $point_array[1].",".$point_array[0];
1063
+
1064
+ }
1065
 
1066
+ }
1067
+
1068
+ }
1069
 
1070
+ if (!empty($point) && !empty($formatted_address)){
1071
 
1072
+ $response = array('point'=>$point,'address'=>$formatted_address);
1073
+
1074
  }
1075
+
1076
+ return $response;
1077
 
1078
  }
1079
 
1080
+
1081
+
1082
  //from http://us3.php.net/manual/en/function.xml-parse.php
1083
  function gmshc_xml2array($url, $get_attributes = 1, $priority = 'tag')
1084
  {
readme.txt CHANGED
@@ -4,9 +4,9 @@ Donate link: http://web-argument.com/google-map-shortcode-2-0-total-solution/
4
  Tags: google map, shortcode, map, categories, widget, post map, point, marker, list, location, address, images
5
  Requires at least: 2.5
6
  Tested up to: 3.1.2
7
- Stable tag: 2.0
8
 
9
- Friendly integration of Google Map instances into your blogs. Allows to display multiples map on your pages. Insert points on maps easily.
10
 
11
  == Description ==
12
 
@@ -14,8 +14,10 @@ This plugin allows you to include instances of Google Map in your blogs using sh
14
 
15
  Special Features:
16
 
17
- * Editor button added, to include easily the points to the map.
18
  * Custom markers allows.
 
 
19
  * Open Google Map in new window - included to the html windows.
20
  * Post ID include as shortcode parameter.
21
  * Map in multiple languages allows.
@@ -35,7 +37,7 @@ For more details and examples visit the <a href="http://web-argument.com/google-
35
  1. Upload 'Google Map Short Code' folder to the '/wp-content/plugins/' directory.
36
  2. Activate the plugin through the 'Plugins' menu in WordPress.
37
  3. Go to the Google Map Shortcode Options page under settings and save your prefered options.
38
- 4. Using the Google Map editor panel button insert the address or latitude/longitude.
39
 
40
 
41
  == Screenshots ==
@@ -49,6 +51,10 @@ For more details and examples visit the <a href="http://web-argument.com/google-
49
 
50
  == Changelog ==
51
 
 
 
 
 
52
  = 2.0 =
53
  * Custom marker added.
54
  * Google Map Javascript v3 integrated.
4
  Tags: google map, shortcode, map, categories, widget, post map, point, marker, list, location, address, images
5
  Requires at least: 2.5
6
  Tested up to: 3.1.2
7
+ Stable tag: 2.0.1
8
 
9
+ Friendly integration of Google Map instances into your blogs. Allows to display multiples map on your pages. Insert points into maps easily.
10
 
11
  == Description ==
12
 
14
 
15
  Special Features:
16
 
17
+ * Editor button added, to include the points to the map easily.
18
  * Custom markers allows.
19
+ * Based on Google Maps Javascript API Version 3.
20
+ * Faster and more applicable to mobile devices.
21
  * Open Google Map in new window - included to the html windows.
22
  * Post ID include as shortcode parameter.
23
  * Map in multiple languages allows.
37
  1. Upload 'Google Map Short Code' folder to the '/wp-content/plugins/' directory.
38
  2. Activate the plugin through the 'Plugins' menu in WordPress.
39
  3. Go to the Google Map Shortcode Options page under settings and save your prefered options.
40
+ 4. Using the Google Map editor button insert the address or latitude/longitude and add the map on your posts/pages.
41
 
42
 
43
  == Screenshots ==
51
 
52
  == Changelog ==
53
 
54
+ = 2.0.1 =
55
+ * Geocoding API request changed.
56
+ * Html width parameter included.
57
+
58
  = 2.0 =
59
  * Custom marker added.
60
  * Google Map Javascript v3 integrated.