Google Map Shortcode - Version 2.1

Version Description

  • Allows selecting single point icon, title and description.
    • Html filters added.
    • Just one custom field by post to include all the points.
    • Icon selection improved.
Download this release

Release Info

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

Code changes from version 2.0.1 to 2.1

google-map-shortcode.php CHANGED
@@ -3,14 +3,18 @@
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
  */
10
 
11
  define('GMSC_PLUGIN_DIR', WP_PLUGIN_DIR."/".dirname(plugin_basename(__FILE__)));
12
  define('GMSC_PLUGIN_URL', WP_PLUGIN_URL."/".dirname(plugin_basename(__FILE__)));
13
- define('GMSHC_VERSION','2.0');
 
 
 
 
14
 
15
  /**
16
  * Default Options
@@ -20,18 +24,15 @@ function get_gmshc_options ($default = false){
20
 
21
  $gmshc_default = array(
22
  'zoom' => '10',
23
- 'width' => '400',
24
- 'height' => '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' => '',
32
- 'version' => GMSHC_VERSION
33
  );
34
-
35
 
36
  if ($default) {
37
  update_option('gmshc_op', $gmshc_default);
@@ -41,7 +42,7 @@ function get_gmshc_options ($default = false){
41
  $options = get_option('gmshc_op');
42
  if (isset($options)){
43
  if (isset($options['version'])) {
44
- $chk_version = version_compare(GMSHC_VERSION,$options['version']);
45
  if ($chk_version == 0) return $options;
46
  else if ($chk_version > 0) $options = $gmshc_default;
47
  } else {
@@ -60,17 +61,14 @@ function gmshc_head() {
60
 
61
  $options = get_gmshc_options();
62
  $language = $options['language'];
63
- $key = get_option('gmshc_key');
64
 
65
- $gmshc_header = "\n<!-- Google Map Shortcode Version ".GMSHC_VERSION."-->\n";
66
  $gmshc_header .= "<script src=\"http://maps.google.com/maps/api/js?sensor=false";
67
- if(isset($key))
68
- $gmshc_header .= "&key=".$key;
69
  if(isset($language))
70
  $gmshc_header .= "&language=".$language;
71
  $gmshc_header .="\" type=\"text/javascript\"></script>\n";
72
- $gmshc_header .= "<script type=\"text/javascript\" src=\"".GMSC_PLUGIN_URL."/google-map-sc-v3.js\"></script>\n";
73
- $gmshc_header .= "<!-- /Google Map Shortcode Version ".GMSHC_VERSION."-->\n";
74
 
75
  print($gmshc_header);
76
 
@@ -78,7 +76,6 @@ function gmshc_head() {
78
 
79
  add_action('wp_head', 'gmshc_head');
80
 
81
-
82
  /**
83
  * Google Map SC Editor Button
84
  */
@@ -106,9 +103,15 @@ function gmshc_tab_process(){
106
  $options = get_gmshc_options();
107
 
108
  $post_id = $_REQUEST["post_id"];
109
- $custum_fieds = get_post_custom($post_id);
110
- $points_addr = isset($custum_fieds['google-map-sc-address'])?$custum_fieds['google-map-sc-address'] : array();
111
- $points_ltlg = isset($custum_fieds['google-map-sc-latlng'])?$custum_fieds['google-map-sc-latlng'] : array();
 
 
 
 
 
 
112
  $add_point = isset($_REQUEST['add_point']) ? $_REQUEST['add_point'] : '';
113
  $del_point = isset($_REQUEST['delp']) ? $_REQUEST['delp'] : '';
114
  $update_point = isset($_REQUEST['update']) ? $_REQUEST['update'] : '';
@@ -116,65 +119,46 @@ function gmshc_tab_process(){
116
  $height = isset($_REQUEST['height']) ? $_REQUEST['height'] : $options['height'];
117
  $zoom = isset($_REQUEST['zoom']) ? $_REQUEST['zoom'] : $options['zoom'];
118
 
119
- if (!empty($add_point)) {
 
 
 
 
 
120
 
121
- if (isset($_REQUEST['full_address'])){
122
- if ($gmshc_point = gmshc_point ($_REQUEST['full_address'],"")) {
123
-
124
- add_post_meta($post_id , "google-map-sc-address", $gmshc_point['address'], false);
125
- add_post_meta($post_id , "google-map-sc-latlng", $gmshc_point['point'], false);
126
-
127
- } else {
128
-
129
- echo "<div class='error'><p>".__("The Address can't be located.")."</p></div>";
130
-
131
  }
132
- }
133
-
134
  }
135
 
136
- if ($del_point != '') {
137
-
138
- foreach ($points_addr as $id => $single_addr) {
139
-
140
- if ($del_point == $id) delete_post_meta($post_id, "google-map-sc-address", $single_addr);
141
-
142
- }
143
-
144
- foreach ($points_ltlg as $id => $single_ltlg) {
145
- if ($del_point == $id) delete_post_meta($post_id, "google-map-sc-latlng", $single_ltlg);
146
-
147
- }
148
-
149
- echo "<div class='updated'><p>".__("The Point was deleted.")."</p></div>";
150
 
 
 
 
151
  }
152
-
153
- if (!empty($update_point)) {
154
 
155
- $posted_addr = $_REQUEST['addr'];
156
- $posted_ltlg = $_REQUEST['ltlg'];
157
-
158
- for ($j = 0; $j < count($posted_ltlg); $j++ ) {
159
-
160
- update_post_meta($post_id, "google-map-sc-address", $posted_addr[$j], $points_addr[$j]);
161
-
162
- update_post_meta($post_id, "google-map-sc-latlng", $posted_ltlg[$j], $points_ltlg[$j]);
163
-
164
- }
165
-
166
- echo "<div class='updated'><p>".__("The Point was updated.")."</p></div>";
167
- }
168
 
169
- $custum_fieds = get_post_custom($post_id);
170
- $points_addr = isset($custum_fieds['google-map-sc-address'])?$custum_fieds['google-map-sc-address'] : array();
171
- $points_ltlg = isset($custum_fieds['google-map-sc-latlng'])?$custum_fieds['google-map-sc-latlng'] : array();
172
-
173
  ?>
174
- <div style="width:620px; margin:10px auto">
 
 
 
 
175
 
176
  <form action="#" method="post">
177
-
178
  <table width="620" border="0" cellspacing="10" cellpadding="10">
179
  <tr>
180
  <td colspan="2">
@@ -197,126 +181,154 @@ function gmshc_tab_process(){
197
  <td colspan="2">
198
  <h3><?php _e("Add New Point"); ?></h3>
199
  </td>
200
- </tr>
201
  <tr>
202
  <td align="right" valign="top">
203
- <?php _e("Full Address"); ?>
204
  </td>
205
- <td valign="top">
206
- <textarea name="full_address" cols="50" rows="4" id="full_address"></textarea>
207
- </td>
208
- </tr>
209
- </table>
210
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  <p><input class="button" value="<?php _e("Add Point") ?>" name="add_point" type="submit"></p>
212
 
213
  <?php
214
- if (count($points_addr) > 0 || count($points_ltlg) > 0 ){
215
  ?>
216
-
217
  <table class="widefat" cellspacing="0">
218
  <thead>
219
  <tr>
220
- <th><?php _e("Address"); ?></th>
221
- <th><?php _e("Latitude/Longitude"); ?></th>
 
 
222
  </tr>
223
  </thead>
224
- <tbody class="media-item-info">
225
- <?php
226
- $i = 0;
227
- while ($i < count($points_addr) || $i < count($points_ltlg)) {
228
- if (!isset( $points_ltlg[$i]) ){
229
- $this_ltlg = gmshc_point ($points_addr[$i],"");
230
- $points_ltlg[$i] = $this_ltlg['point'];
231
- update_post_meta($post_id, "google-map-sc-latlng", $points_ltlg[$i], "");
232
- }
233
- if (!isset( $points_addr[$i]) ){
234
- $this_addr = gmshc_point ("",$points_ltlg[$i]);
235
- $points_addr[$i] = $this_addr['address'];
236
- update_post_meta($post_id, "google-map-sc-address", $points_addr[$i], "");
237
- }
238
- ?>
239
  <tr>
240
- <td>
241
- <textarea name="addr[]" cols="30" rows="3" id="addr_<?php echo $i ?>"><?php echo $points_addr[$i] ?></textarea>
242
- </td>
243
- <td>
244
- <input name="ltlg[]" type="text" id="ltlg_<?php echo $i ?>" size="30" value = "<?php echo $points_ltlg[$i] ?>"/>
245
- <div style="padding:15px 0;">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  <input class="button" value="<?php _e("Update"); ?>" name="update" type="submit">
247
- <a href="" class="thickbox" onclick="delete_point(<?php echo $i ?>); return false"><?php _e("Delete"); ?></a>
248
  </div>
249
- </td>
250
- </tr>
251
- <?php
252
- $i ++;
253
- }
254
- ?>
255
  </tbody>
256
  </table>
257
 
258
- <p><input class="button-primary" value="<?php _e("Insert Map"); ?>" type="button" onclick="add_map(); return false;"></p>
259
 
260
- <?php } ?>
261
  </form>
262
  </div>
263
 
264
-
265
- <script type="text/javascript">
266
-
267
- function add_map (){
268
- var width = jQuery("#width").val();
269
- var height = jQuery("#height").val();
270
- var zoom = jQuery("#zoom").val();
271
-
272
- str = "[google-map-sc";
273
- if (width != '')
274
- str += " width="+width;
275
- if (height != '')
276
- str += " height="+height;
277
- if (zoom != '')
278
- str += " zoom="+zoom;
279
- str +="]";
280
-
281
- if (parent.tinyMCE){
282
- parent.tinyMCE.activeEditor.setContent(parent.tinyMCE.activeEditor.getContent() + str);
283
- }else{
284
- parent.document.getElementById("content").value = parent.document.getElementById("content").value + "\r\n" +str;
285
- }
286
- }
287
-
288
- function delete_point(id){
289
- var answer = confirm ('<?php _e("You will not be able to roll back deletion. Are you sure?"); ?>');
290
- if (answer) {
291
- var width = jQuery("#width").val();
292
- var height = jQuery("#height").val();
293
- var zoom = jQuery("#zoom").val();
294
-
295
- var url = "?post_id=<?php echo $post_id ?>&tab=gmshc&delp="+id+"&width="+width+"&height="+height+"&zoom="+zoom;
296
- window.location = url;
297
- } else {
298
- return false;
299
- }
300
- }
301
-
302
- </script>
303
-
304
  <?php
305
  }
306
 
307
-
308
  /**
309
  * Default Open Window Html
 
 
 
 
 
 
 
 
 
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";
@@ -326,34 +338,6 @@ function gmshc_tab_process(){
326
 
327
  }
328
 
329
-
330
- /**
331
- * Get the thumbnail
332
- */
333
- function gmshc_post_thumb($the_parent){
334
-
335
- if( function_exists('has_post_thumbnail') && has_post_thumbnail($the_parent)) {
336
- $thumbnail_id = get_post_thumbnail_id( $the_parent );
337
- if(!empty($thumbnail_id))
338
- $img = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail' );
339
- } else {
340
- $attachments = get_children( array(
341
- 'post_parent' => $the_parent,
342
- 'post_type' => 'attachment',
343
- 'post_mime_type' => 'image',
344
- 'orderby' => 'menu_order',
345
- 'order' => 'ASC',
346
- 'numberposts' => 1) );
347
- if($attachments == true) :
348
- foreach($attachments as $id => $attachment) :
349
- $img = wp_get_attachment_image_src($id, 'thumbnail');
350
- endforeach;
351
- endif;
352
- }
353
- if (isset($img[0])) return $img[0];
354
-
355
- }
356
-
357
  /**
358
  * The Sortcode
359
  */
@@ -368,8 +352,7 @@ function gmshc_sc($atts) {
368
  $width = $options['width'];
369
  $height = $options['height'];
370
  $zoom = $options['zoom'];
371
- $number = $options['number'];
372
- $icon = $options['icon'];
373
  $language = $options['language'];
374
 
375
  // First Point in the post
@@ -378,279 +361,76 @@ function gmshc_sc($atts) {
378
 
379
  $the_address = isset($address_meta[0]) ? $address_meta[0] : '';
380
  $point = isset($point_meta[0]) ? $point_meta[0] : '';
381
- $the_items = array();
382
 
383
  extract(shortcode_atts(array(
384
- 'address' => '',
 
 
 
 
385
  'id' => '',
386
  'cat' => '',
387
- 'number' => $number,
388
  'zoom' => $zoom,
389
  'width' => $width,
390
- 'height' => $height,
391
- 'icon' => $icon,
392
  'language' => $language
393
  ), $atts));
394
 
 
395
 
396
- // When address is set
397
- if (!empty($address)) {
398
-
399
- if( $item = gmshc_fill_item('','',$address) ) {
400
- $the_items[0] = $item;
401
- } else {
402
- return __("The Address can't be located.");
403
- }
404
- // When id is set
405
- } else if (!empty($id)) {
406
-
407
- $post_obj = get_posts(array('include'=>$id,'numberposts'=>1));
408
-
409
- if(isset($post_obj)) {
410
-
411
- if ($post_points = gmshc_retrive_point($post_obj[0])){
412
-
413
- for ($i = 0; $i < count($post_points); $i++) {
414
-
415
- if ($i == $number) break;
416
-
417
- if($item = gmshc_fill_item($post_obj[0], $post_points[$i]['point'],$post_points[$i]['address'])) {
418
- $the_items[$i] = $item;
419
- }
420
-
421
 
422
- }
423
-
424
- }
425
-
426
- }
427
-
428
- } else if ($cat != '') {
429
-
430
- $categories = split (",",$cat);
431
- $j = 0;
432
-
433
- $post_obj = get_posts(array('category__in'=>$categories,'numberposts'=>-1));
434
-
435
- foreach ($post_obj as $post_item) {
436
-
437
-
438
- if ($j < $number) {
439
-
440
- if ($post_points = gmshc_retrive_point($post_item)){
441
-
442
- for ($i = 0; $i < count($post_points); $i++) {
443
-
444
- if ($i == $number) break;
445
-
446
- if($item = gmshc_fill_item($post_item, $post_points[$i]['point'],$post_points[$i]['address'])) {
447
- $the_items[$j] = $item;
448
- $j++;
449
- }
450
-
451
- }
452
-
453
  }
454
-
455
-
456
-
457
- }
458
 
459
- }
460
-
461
-
462
- } else {
463
-
464
- if ($post_points = gmshc_retrive_point($post)){
465
 
466
- for ($i = 0; $i < count($post_points); $i++) {
467
-
468
- if ($i == $number) break;
469
-
470
- if( $item = gmshc_fill_item($post, $post_points[$i]['point'],$post_points[$i]['address']) ) {
471
- $the_items[$i] = $item;
472
- }
473
-
474
- }
475
 
476
  }
477
 
478
- }
479
-
480
 
481
- if ( count($the_items) > 0 ) {
482
-
483
- $canvas = "canvas_".wp_generate_password(4, false);
484
-
485
-
486
- $i = 0;
487
-
488
-
489
- $output ='<div id="'.$canvas.'" class = "gmsc" style="width:'.$width.'px; height:'.$height.'px; margin:10px auto"></div>';
490
- $output .= "<script type=\"text/javascript\">\n";
491
-
492
- $output .= "var map_".$canvas.";\n";
493
- $output .= "var map_points_".$canvas." = new Array();\n";
494
-
495
- foreach ($the_items as $single_point){
496
-
497
- $options = get_option('gmshc_op');
498
- $windowhtml = $options['windowhtml'];
499
-
500
- list($lat, $long) = split(",",$single_point['point']);
501
-
502
- if (isset($single_point['address'])) {
503
-
504
- if (empty($windowhtml)) $windowhtml = gmshc_defaul_windowhtml();
505
 
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
-
524
- //open map
525
-
526
- $output .= "map_points_".$canvas."[".$i."] = {\"address\":\"".$single_point['address']."\",\"point\":{\"lat\":\"".$lat."\",\"long\":\"".$long."\"},\"info\":\"".$info."\",\"icon\":\"".$icon."\"};\n";
527
-
528
- } else {
529
-
530
- $output .= "map_points_".$canvas."[".$i."] = {\"address\":\"".$single_point['address']."\",\"point\":{\"lat\":\"".$lat."\",\"long\":\"".$long."\"},\"icon\":\"".$icon."\"};\n";
531
-
532
- }
533
-
534
- $i ++;
535
- }
536
-
537
- $output .= "addLoadEvent(function(){\n";
538
- $output .= "gmshc_render(\"".$canvas."\",map_points_".$canvas.", ".$zoom.");\n";
539
- $output .= "});\n";
540
- $output .= "</script>\n";
541
-
542
-
543
- return $output;
544
-
545
-
546
  }
547
-
548
  else return __("There is not points to locate on the map");
549
-
550
-
551
  }
552
 
553
 
554
- function gmshc_get_excerpt($text) { // Fakes an excerpt if needed
555
-
556
- if ( '' != $text ) {
557
-
558
- $text = strip_shortcodes( $text );
559
-
560
- $text = apply_filters('the_content', $text);
561
- $text = str_replace(']]>', ']]&gt;', $text);
562
- $text = strip_tags($text);
563
- $excerpt_length = 10;
564
- $words = explode(' ', $text, $excerpt_length + 1);
565
- if (count($words) > $excerpt_length) {
566
- array_pop($words);
567
- array_push($words, '[...]');
568
- $text = implode(' ', $words);
569
- }
570
- }
571
- return $text;
572
- }
573
-
574
-
575
-
576
- function gmshc_fill_item($post,$point,$address){
577
-
578
- if (empty($point) && empty($address)) return false;
579
-
580
- if (empty($point) && !empty($address)) {
581
-
582
- if ($the_point = gmshc_point($address,"")) {
583
- $address = $the_point['address'];
584
- $point = $the_point['point'];
585
- } else {
586
- return false;
587
- }
588
- }
589
-
590
- if (!empty($post)){
591
-
592
- $the_image = gmshc_post_thumb($post -> ID);
593
- $the_title = $post -> post_title;
594
- $the_link = get_permalink($post -> ID);
595
-
596
- $find = array("\"", "[", "]", "\n","\r");
597
- $replace = array("'","","","","");
598
-
599
- $the_excerpt = str_replace( $find,$replace, gmshc_get_excerpt($post -> post_content));
600
-
601
- if (!empty($address)) {
602
-
603
- $item = array("point"=>$point,"address" => $address,"img" => $the_image,"title" => $the_title,"link" => $the_link, "excerpt" => $the_excerpt);
604
-
605
- } else {
606
-
607
- $item = array("point"=>$point,"img" => $the_image,"title" => $the_title,"link" => $the_link, "excerpt" => $the_excerpt);
608
-
609
- }
610
-
611
-
612
- } else {
613
-
614
- $item = array("point"=>$point,"address" => $address);
615
-
616
- }
617
-
618
- return $item;
619
- }
620
-
621
- function gmshc_retrive_point($post) {
622
-
623
- $post_points = array();
624
- $custum_fieds = get_post_custom($post->ID);
625
- $points_addr = isset($custum_fieds['google-map-sc-address'])?$custum_fieds['google-map-sc-address'] : array();
626
- $points_ltlg = isset($custum_fieds['google-map-sc-latlng'])?$custum_fieds['google-map-sc-latlng'] : array();
627
-
628
- $num_addr = count($points_addr);
629
- $num_ltlg = count($points_ltlg );
630
-
631
- if ($num_ltlg > 0 && $num_ltlg==$num_addr){
632
-
633
- for ($i = 0; $i < $num_ltlg; $i ++){
634
- $post_points[$i] = array('point'=>$points_ltlg[$i],'address'=>$points_addr[$i]);
635
- }
636
-
637
- } else {
638
-
639
- for ($i = 0; $i < $num_ltlg; $i ++){
640
- if($point = gmshc_point ('',$points_ltlg[$i])){
641
- $address = $point['address'];
642
- $post_points[$i] = array('point'=>$points_ltlg[$i],'address'=>$address);
643
- }
644
- }
645
-
646
- }
647
-
648
-
649
- if(count($post_points) > 0) return $post_points;
650
- else return false;
651
-
652
- }
653
-
654
 
655
  /**
656
  * Settings
@@ -659,18 +439,30 @@ function gmshc_retrive_point($post) {
659
  add_action('admin_menu', 'gmshc_set');
660
 
661
  function gmshc_set() {
662
- add_options_page('Google Map Shortcode', 'Google Map Shortcode', 'administrator', 'google-map-shortcode', 'gmshc_options_page');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
  }
664
 
665
  function gmshc_options_page() {
666
 
667
  $options = get_gmshc_options();
668
- $gmshc_key = get_option('gmshc_key');
669
- $icon_path = GMSC_PLUGIN_URL.'/images/icons/';
670
- $icon_dir = GMSC_PLUGIN_DIR.'/images/icons/';
671
-
672
- ?>
673
 
 
 
674
  <div class="wrap">
675
 
676
  <h2><?php _e("Google Map Shortcode Settings") ?></h2>
@@ -679,40 +471,21 @@ function gmshc_options_page() {
679
 
680
  if(isset($_POST['Submit'])){
681
 
682
- if ($_POST['use_icon'] == "custom" && $_POST['custom_icon'] == "") {
683
-
684
- echo "<div class='error'><p>".__("Please upload a custom icon.")."</p></div>";
685
-
686
- } else {
687
 
688
- $new_gmshc_key = $_POST['gmshc_key'];
689
- $newoptions['width'] = $_POST['width'];
690
- $newoptions['height'] = $_POST['height'];
691
- $newoptions['zoom'] = $_POST['zoom'];
692
- $newoptions['number'] = $_POST['number'];
693
- $newoptions['language'] = $_POST['language'];
694
- $newoptions['windowhtml'] = $_POST['windowhtml'];
695
-
696
- $newoptions['use_icon'] = $_POST['use_icon'];
697
- $newoptions['default_icon'] = $_POST['default_icon'];
698
- $newoptions['custom_icon'] = $_POST['custom_icon'];
699
-
700
- if ($_POST['use_icon'] == 'default')
701
- $newoptions['icon'] = $icon_path .$_POST['default_icon'];
702
- else $newoptions['icon'] = $_POST['custom_icon'];
703
-
704
- $newoptions['version'] = GMSHC_VERSION;
705
 
706
  if ( $options != $newoptions ) {
707
  $options = $newoptions;
708
  update_option('gmshc_op', $options);
709
  }
710
- if ( $gmshc_key != $new_gmshc_key ) {
711
- $gmshc_key = $new_gmshc_key;
712
- update_option('gmshc_key', $options);
713
- }
714
-
715
- }
716
 
717
  }
718
 
@@ -722,36 +495,37 @@ function gmshc_options_page() {
722
  update_option('gmshc_op', $options);
723
 
724
  }
 
 
725
 
726
- if(isset($_POST['upload']) && isset($_FILES) ){
727
-
728
- $filename = $_FILES["datafile"]["name"];
729
-
730
- $upload = wp_upload_bits($filename, NULL, file_get_contents($_FILES["datafile"]["tmp_name"]));
731
 
732
- if ( ! empty($upload['error']) ) {
733
- $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $filename, $upload['error']);
734
- echo "<div class='error'><p><strong>".$errorString."</strong></p></div>";
735
- } else {
736
-
737
- $options['custom_icon'] = $upload['url'];
738
- update_option('gmshc_op', $options);
 
 
 
 
 
739
 
 
 
740
  }
741
-
742
- }
743
-
744
- $width = isset ($_POST['width'])? $_POST['width']: $options['width'];
745
- $height = isset ($_POST['height'])? $_POST['height'] : $options['height'];
746
- $zoom = isset ($_POST['zoom'])? $_POST['zoom']: $options['zoom'];
747
- $number = isset ($_POST['number'])? $_POST['number']: $options['number'];
748
- $language = isset ($_POST['language'])? $_POST['language']: $options['language'];
749
- $windowhtml = $options['windowhtml'];
750
- $icon = $options['width'];
751
- $use_icon = isset ($_POST['use_icon'])? $_POST['use_icon']: $options['use_icon'];
752
- $default_icon = isset ($_POST['default_icon'])? $_POST['default_icon']: $options['default_icon'];
753
- $custom_icon = $options['custom_icon'];
754
 
 
 
 
 
 
 
 
755
  ?>
756
 
757
  <form method="POST" name="options" target="_self" enctype="multipart/form-data">
@@ -760,32 +534,12 @@ function gmshc_options_page() {
760
 
761
  <p><?php _e("The shortcode attributes overwrite these options.") ?></p>
762
 
763
- <?php
764
-
765
- $icons_array = array();
766
- if ($handle = opendir($icon_dir)) {
767
- $i = 0;
768
- while (false !== ($file = readdir($handle))) {
769
-
770
- $file_type = wp_check_filetype($file);
771
-
772
- $file_ext = $file_type['ext'];
773
-
774
- if ($file != "." && $file != ".." && ($file_ext == 'gif' || $file_ext == 'jpg' || $file_ext == 'png') ) {
775
- $icons_array[$i] = $file;
776
- $i ++;
777
- }
778
- }
779
- }
780
-
781
- ?>
782
-
783
  <table width="80%%" border="0" cellspacing="10" cellpadding="0">
784
  <tr>
785
  <td colspan="2"><strong><?php _e("Dimensions") ?></strong></td>
786
  </tr>
787
  <tr>
788
- <td width="150" align="right" height="40"><?php _e("Width") ?></td>
789
  <td><input name="width" type="text" size="6" value="<?php echo $width ?>" /></td>
790
  </tr>
791
  <tr>
@@ -795,45 +549,21 @@ function gmshc_options_page() {
795
  <tr>
796
  <td align="right"><?php _e("Zoom") ?></td>
797
  <td><input name="zoom" type="text" size="6" value="<?php echo $zoom ?>" /></td>
798
- </tr>
799
- <tr>
800
- <td align="right"><?php _e("Maximum number of point in a single map") ?></td>
801
- <td><input name="number" type="text" size="6" value="<?php echo $number ?>" /></td>
802
- </tr>
803
  <tr>
804
- <td colspan="2"><strong><?php _e("Select Icon") ?></strong></td>
805
  </tr>
806
  <tr>
807
- <td width="150" align="right" height="40">
808
- <input name="use_icon" type="radio" value="default" style="margin-right:10px;" <?php echo ($use_icon == "default" ? "checked=\"checked\"" : "") ?>/><?php _e("Use default icons") ?>
809
- </td>
810
- <td>
811
- <div style="width:30px; height:30px; float:left; margin:0 15px">
812
- <img src="<?php echo $icon_path.$default_icon ?>" alt="icon" id="icon_img" />
813
- </div>
814
- <select name="default_icon" id = "default_icon">
815
- <?php foreach ($icons_array as $icon){ ?>
816
- <option value="<?php echo $icon ?>" <?php echo ($icon == $default_icon ? "selected" : "") ?>><?php echo $icon ?></option>
817
- <?php } ?>
818
- </select>
819
-
820
  </td>
821
  </tr>
822
  <tr>
823
- <td align="right" valign="top"><input name="use_icon" type="radio" value="custom" style="margin-right:10px;" <?php echo ($use_icon == "custom" ? "checked=\"checked\"" : "") ?> /><?php _e("Use custom icons") ?>
824
- </td>
825
- <td>
826
- <div style="width:30px; height:30px; float:left; margin:0 15px">
827
- <?php if ($custom_icon != "") { ?>
828
- <img src="<?php echo $custom_icon ?>" alt="icon" id="icon_img" />
829
- <?php } ?>
830
- </div>
831
- <?php _e("Please specify a file:") ?><br />
832
- <input type="file" name="datafile" size="40" />
833
- <p>
834
- <input type="submit" name="upload" value="Upload" class="button" style="margin-left:50px" />
835
- </p>
836
- <input name="custom_icon" type="hidden" size="18" value="<?php echo $custom_icon ?>" />
837
  </td>
838
  </tr>
839
  <tr>
@@ -875,11 +605,27 @@ function gmshc_options_page() {
875
 
876
  <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;"><?php _e("Info Windows") ?></h3>
877
 
878
- <p><?php _e("This is the html inside of the Map Info Window opened after clicking on the markers, you can include the following tags.") ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
879
 
 
880
  <table width="80%%" border="0" cellspacing="10" cellpadding="0">
881
  <tr>
882
- <td width="150" align="right"><strong>%title%</strong></td>
883
  <td><?php _e("The title of your post") ?></td>
884
  </tr>
885
  <tr>
@@ -890,6 +636,10 @@ function gmshc_options_page() {
890
  <td align="right"><strong>%thubnail%</strong></td>
891
  <td><?php _e("The thubnail of the last image attached to your post") ?></td>
892
  </tr>
 
 
 
 
893
  <tr>
894
  <td align="right"><strong>%excerpt%</strong></td>
895
  <td><?php _e("The excerpt of your post") ?></td>
@@ -907,316 +657,29 @@ function gmshc_options_page() {
907
  <td><?php _e("Info Html width") ?></td>
908
  </tr>
909
  </table>
910
- <br />
911
-
912
- <textarea name="windowhtml" cols="110" rows="12" id="windowhtml">
913
- <?php
914
- if (empty($windowhtml)) echo gmshc_defaul_windowhtml();
915
- else echo str_replace("\\", "",$windowhtml);
916
- ?>
917
- </textarea>
918
-
919
- <p align="right" style="width:800px; padding:0">
920
- <input type="submit" name="Use_Default" value="Restore Default"/>
921
- </p>
922
-
923
- <p class="submit">
924
- <input type="submit" name="Submit" value="Update" class="button-primary" />
925
- </p>
926
-
927
- <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;"><?php _e("Google Map Api Key") ?></h3>
928
-
929
- <p><?php _e("Enter your Google Map Api Key. You can get it <a href='http://code.google.com/apis/maps/signup.html' target='_blank'>here</a>. This is not required. Google Maps JavaScript API V3 no longer needs API keys!") ?></p>
930
- <p><input name="gmshc_key" type="text" value="<?php echo $gmshc_key ?>" size="105"/>
931
-
932
  <p class="submit">
933
- <input type="submit" name="Submit" value="Update" class="button-primary" />
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">
981
- <input type="submit" name="Submit" value="Update" class="button-primary" />
982
  </p>
983
  </form>
984
  </div>
985
 
986
- <script type="text/javascript">
987
-
988
- (function ($) {
989
-
990
- $(document).ready(function(){
991
-
992
- $("#default_icon").click(function(){
993
- switchImg(this);
994
- });
995
-
996
- var iconSelect = "";
997
- function switchImg (obj) {
998
- var iconName = $(obj).val();
999
- var imgUrl = '<?php echo $icon_path ?>'+iconName;
1000
- $("#icon_img").attr('src',imgUrl);
1001
- }
1002
-
1003
- });
1004
-
1005
- })(jQuery);
1006
-
1007
- </script>
1008
-
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
- {
1085
- $contents = "";
1086
- if (!function_exists('xml_parser_create'))
1087
- {
1088
- return array ();
1089
- }
1090
- $parser = xml_parser_create('');
1091
- if (!($fp = @ fopen($url, 'rb')))
1092
- {
1093
- return array ();
1094
- }
1095
- while (!feof($fp))
1096
- {
1097
- $contents .= fread($fp, 8192);
1098
- }
1099
- fclose($fp);
1100
- xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
1101
- xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
1102
- xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
1103
- xml_parse_into_struct($parser, trim($contents), $xml_values);
1104
- xml_parser_free($parser);
1105
- if (!$xml_values)
1106
- return; //Hmm...
1107
- $xml_array = array ();
1108
- $parents = array ();
1109
- $opened_tags = array ();
1110
- $arr = array ();
1111
- $current = & $xml_array;
1112
- $repeated_tag_index = array ();
1113
- foreach ($xml_values as $data)
1114
- {
1115
- unset ($attributes, $value);
1116
- extract($data);
1117
- $result = array ();
1118
- $attributes_data = array ();
1119
- if (isset ($value))
1120
- {
1121
- if ($priority == 'tag')
1122
- $result = $value;
1123
- else
1124
- $result['value'] = $value;
1125
- }
1126
- if (isset ($attributes) and $get_attributes)
1127
- {
1128
- foreach ($attributes as $attr => $val)
1129
- {
1130
- if ($priority == 'tag')
1131
- $attributes_data[$attr] = $val;
1132
- else
1133
- $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
1134
- }
1135
- }
1136
- if ($type == "open")
1137
- {
1138
- $parent[$level -1] = & $current;
1139
- if (!is_array($current) or (!in_array($tag, array_keys($current))))
1140
- {
1141
- $current[$tag] = $result;
1142
- if ($attributes_data)
1143
- $current[$tag . '_attr'] = $attributes_data;
1144
- $repeated_tag_index[$tag . '_' . $level] = 1;
1145
- $current = & $current[$tag];
1146
- }
1147
- else
1148
- {
1149
- if (isset ($current[$tag][0]))
1150
- {
1151
- $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
1152
- $repeated_tag_index[$tag . '_' . $level]++;
1153
- }
1154
- else
1155
- {
1156
- $current[$tag] = array (
1157
- $current[$tag],
1158
- $result
1159
- );
1160
- $repeated_tag_index[$tag . '_' . $level] = 2;
1161
- if (isset ($current[$tag . '_attr']))
1162
- {
1163
- $current[$tag]['0_attr'] = $current[$tag . '_attr'];
1164
- unset ($current[$tag . '_attr']);
1165
- }
1166
- }
1167
- $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
1168
- $current = & $current[$tag][$last_item_index];
1169
- }
1170
- }
1171
- elseif ($type == "complete")
1172
- {
1173
- if (!isset ($current[$tag]))
1174
- {
1175
- $current[$tag] = $result;
1176
- $repeated_tag_index[$tag . '_' . $level] = 1;
1177
- if ($priority == 'tag' and $attributes_data)
1178
- $current[$tag . '_attr'] = $attributes_data;
1179
- }
1180
- else
1181
- {
1182
- if (isset ($current[$tag][0]) and is_array($current[$tag]))
1183
- {
1184
- $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
1185
- if ($priority == 'tag' and $get_attributes and $attributes_data)
1186
- {
1187
- $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
1188
- }
1189
- $repeated_tag_index[$tag . '_' . $level]++;
1190
- }
1191
- else
1192
- {
1193
- $current[$tag] = array (
1194
- $current[$tag],
1195
- $result
1196
- );
1197
- $repeated_tag_index[$tag . '_' . $level] = 1;
1198
- if ($priority == 'tag' and $get_attributes)
1199
- {
1200
- if (isset ($current[$tag . '_attr']))
1201
- {
1202
- $current[$tag]['0_attr'] = $current[$tag . '_attr'];
1203
- unset ($current[$tag . '_attr']);
1204
- }
1205
- if ($attributes_data)
1206
- {
1207
- $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
1208
- }
1209
- }
1210
- $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken
1211
- }
1212
- }
1213
- }
1214
- elseif ($type == 'close')
1215
- {
1216
- $current = & $parent[$level -1];
1217
- }
1218
- }
1219
- return ($xml_array);
1220
- }
1221
 
1222
- ?>
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.1
7
  Author: Alain Gonzalez
8
  Author URI: http://web-argument.com/
9
  */
10
 
11
  define('GMSC_PLUGIN_DIR', WP_PLUGIN_DIR."/".dirname(plugin_basename(__FILE__)));
12
  define('GMSC_PLUGIN_URL', WP_PLUGIN_URL."/".dirname(plugin_basename(__FILE__)));
13
+ define('GMSHC_VERSION_CHECK','2.1');
14
+
15
+ require(GMSC_PLUGIN_DIR."/include/functions.php");
16
+ require(GMSC_PLUGIN_DIR."/include/class.gmshc_point.php");
17
+ require(GMSC_PLUGIN_DIR."/include/class.gmshc_post_points.php");
18
 
19
  /**
20
  * Default Options
24
 
25
  $gmshc_default = array(
26
  'zoom' => '10',
27
+ 'width' => '450',
28
+ 'height' => '450',
 
29
  'language' => 'en',
30
  'windowhtml' => gmshc_defaul_windowhtml(),
31
+ 'icons' => array(),
32
+ 'default_icon' => GMSC_PLUGIN_URL.'/images/icons/marker.png',
33
+ 'version' => '2.1'
 
 
34
  );
35
+
36
 
37
  if ($default) {
38
  update_option('gmshc_op', $gmshc_default);
42
  $options = get_option('gmshc_op');
43
  if (isset($options)){
44
  if (isset($options['version'])) {
45
+ $chk_version = version_compare(GMSHC_VERSION_CHECK,$options['version']);
46
  if ($chk_version == 0) return $options;
47
  else if ($chk_version > 0) $options = $gmshc_default;
48
  } else {
61
 
62
  $options = get_gmshc_options();
63
  $language = $options['language'];
 
64
 
65
+ $gmshc_header = "\n<!-- Google Map Shortcode Version ".GMSHC_VERSION_CHECK."-->\n";
66
  $gmshc_header .= "<script src=\"http://maps.google.com/maps/api/js?sensor=false";
 
 
67
  if(isset($language))
68
  $gmshc_header .= "&language=".$language;
69
  $gmshc_header .="\" type=\"text/javascript\"></script>\n";
70
+ $gmshc_header .= "<script type=\"text/javascript\" src=\"".GMSC_PLUGIN_URL."/js/gmshc-render.js\"></script>\n";
71
+ $gmshc_header .= "\n<!-- /Google Map Shortcode Version ".$options['version']."-->\n";
72
 
73
  print($gmshc_header);
74
 
76
 
77
  add_action('wp_head', 'gmshc_head');
78
 
 
79
  /**
80
  * Google Map SC Editor Button
81
  */
103
  $options = get_gmshc_options();
104
 
105
  $post_id = $_REQUEST["post_id"];
106
+ $custom_fieds = get_post_custom($post_id);
107
+
108
+ $address = isset($_REQUEST['new_address'])?$_REQUEST['new_address'] : "";
109
+ $ltlg = isset($_REQUEST['new_ltlg'])?$_REQUEST['new_ltlg'] : "";
110
+ $title = isset($_REQUEST['new_title'])?$_REQUEST['new_title'] : get_the_title($post_id);
111
+ $description = isset($_REQUEST['new_description'])?$_REQUEST['new_description'] : "";
112
+ $icon = isset($_REQUEST['default_icon'])?$_REQUEST['default_icon'] : "";
113
+ $selected_thumbnail = isset($_REQUEST['selected_thumbnail'])?$_REQUEST['selected_thumbnail'] : "";
114
+
115
  $add_point = isset($_REQUEST['add_point']) ? $_REQUEST['add_point'] : '';
116
  $del_point = isset($_REQUEST['delp']) ? $_REQUEST['delp'] : '';
117
  $update_point = isset($_REQUEST['update']) ? $_REQUEST['update'] : '';
119
  $height = isset($_REQUEST['height']) ? $_REQUEST['height'] : $options['height'];
120
  $zoom = isset($_REQUEST['zoom']) ? $_REQUEST['zoom'] : $options['zoom'];
121
 
122
+ $address_list = isset($_REQUEST['addr']) ? $_REQUEST['addr'] : "";
123
+ $title_list = isset($_REQUEST['title']) ? $_REQUEST['title'] : "";
124
+ $desc_list = isset($_REQUEST['desc']) ? $_REQUEST['desc'] : "";
125
+ $ltlg_list = isset($_REQUEST['ltlg']) ? $_REQUEST['ltlg'] : "";
126
+ $icon_list = isset($_REQUEST['icon']) ? $_REQUEST['icon'] : "";
127
+ $thumb_list = isset($_REQUEST['thumb']) ? $_REQUEST['thumb'] : "";
128
 
129
+ $post_points = new GMSHC_Post_Map();
130
+ $post_points -> create_post_map($post_id);
131
+
132
+ if (!empty($add_point)) {
133
+ $new_point = new GMSHC_Point();
134
+ if($new_point -> create_point($address,"",$title,$description,$icon,$selected_thumbnail,$post_id)){
135
+ $post_points -> add_point($new_point);
 
 
 
136
  }
137
+ else
138
+ echo "<div class='error'><p>".__("The Address can't be located.")."</p></div>";
139
  }
140
 
141
+ else if (!empty($update_point)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
142
 
143
+ if ( $post_points -> update_points($address_list,$ltlg_list,$title_list,$desc_list,$icon_list,$thumb_list,$post_id))
144
+ echo "<div class='updated'><p>".__("The Point was updated.")."</p></div>";
145
+ else echo "<div class='error'><p>".__("The Points can't be updated.")."</p></div>";
146
  }
 
 
147
 
148
+ else if ($del_point != "") {
149
+ if($post_points -> delete_point($del_point))
150
+ echo "<div class='updated'><p>".__("The Point was deleted.")."</p></div>";
151
+ }
 
 
 
 
 
 
 
 
 
152
 
 
 
 
 
153
  ?>
154
+
155
+ <script type="text/javascript" src="<?php echo GMSC_PLUGIN_URL ?>/js/gmshc-admin.js"></script>
156
+ <link href="<?php echo GMSC_PLUGIN_URL ?>/styles/gmshc-admin-styles.css" rel="stylesheet" type="text/css"/>
157
+
158
+ <div style="width:620px; margin:10px auto">
159
 
160
  <form action="#" method="post">
161
+ <textarea name = "post_data" id="post_data" style="display:none"><?php echo $post_points->post_data ?></textarea>
162
  <table width="620" border="0" cellspacing="10" cellpadding="10">
163
  <tr>
164
  <td colspan="2">
181
  <td colspan="2">
182
  <h3><?php _e("Add New Point"); ?></h3>
183
  </td>
184
+ </tr>
185
  <tr>
186
  <td align="right" valign="top">
187
+ <strong><?php _e("Title"); ?></strong>
188
  </td>
189
+ <td valign="top">
190
+ <input name="new_title" size="55" id="new_title" value="<?php echo $title ?>" />
191
+ </td>
192
+ </tr>
193
+ <tr>
194
+ <td align="right" valign="top">
195
+ <strong><?php _e("Description"); ?></strong>
196
+ </td>
197
+ <td valign="top">
198
+ <textarea name="new_description" cols="50" rows="2" id="new_description"></textarea>
199
+ </td>
200
+ </tr>
201
+ <tr>
202
+ <td align="right" valign="top">
203
+ <strong><?php _e("Full Address"); ?></strong>
204
+ </td>
205
+ <td valign="top">
206
+ <textarea name="new_address" cols="50" rows="2" id="new_address"></textarea>
207
+ </td>
208
+ </tr>
209
+ <tr>
210
+ <td align="right" valign="top" colspan="2">
211
+ <?php gmshc_deploy_icons() ?>
212
+ </td>
213
+ </tr>
214
+ <tr>
215
+ <td align="center" valign="top" colspan="2">
216
+ <?php
217
+ $thumbnail_list = gmshc_all_post_thumb($post_id);
218
+ if (count($thumbnail_list) > 0) {
219
+ ?>
220
+ <div class="gmshc_label">
221
+ <strong><?php _e("Thumbnail: "); ?></strong><?php _e("Select by clicking on the images"); ?>
222
+ </div>
223
+ <div id="gmshc_thumb_cont">
224
+ <input type="hidden" name="selected_thumbnail" value="<?php echo $default_icon ?>" id="selected_thumbnail" />
225
+ <?php foreach ($thumbnail_list as $thumbnail) { ?>
226
+ <div class="gmshc_thumb">
227
+ <img src="<?php echo $thumbnail ?>" width="40" height="40" />
228
+ </div>
229
+ <?php } ?>
230
+ </div>
231
+ <?php } else { ?>
232
+ <div class="gmshc_label">
233
+ <strong><?php _e("Thumbnail: "); ?></strong><?php _e("If you want to attach an image to the point you need to upload it first to the post gallery"); ?>
234
+ </div>
235
+ <?php } ?>
236
+ </td>
237
+ </tr>
238
+ </table>
239
+
240
  <p><input class="button" value="<?php _e("Add Point") ?>" name="add_point" type="submit"></p>
241
 
242
  <?php
243
+ if ( count($post_points -> points) > 0 ){
244
  ?>
245
+
246
  <table class="widefat" cellspacing="0">
247
  <thead>
248
  <tr>
249
+ <th><?php _e("Marker"); ?></th>
250
+ <th><?php _e("Thumbnail"); ?></th>
251
+ <th><?php _e("Title/Description"); ?></th>
252
+ <th><?php _e("Address/LtLg"); ?></th>
253
  </tr>
254
  </thead>
255
+ <tbody class="media-item-info">
256
+
257
+ <?php
258
+ $i = 0;
259
+ foreach ($post_points->points as $point ) {
260
+ ?>
 
 
 
 
 
 
 
 
 
261
  <tr>
262
+ <td>
263
+ <img src="<?php echo $point->icon ?>" atl="<?php _e("Icon") ?>" />
264
+ <input name="icon[]" type="hidden" id="icon_<?php echo $i ?>" size="30" value = "<?php echo $point->icon ?>"/>
265
+ </td>
266
+ <td>
267
+ <div class="gmshc_thumb gmshc_selected">
268
+ <?php if ($point->thumbnail != "") { ?>
269
+ <img src="<?php echo $point->thumbnail ?>" atl="<?php _e("Thumbnail") ?>" width = "40" height="40" />
270
+ <input name="thumb[]" type="hidden" id="thumb_<?php echo $i ?>" size="30" value = "<?php echo $point->thumbnail ?>"/>
271
+ <?php } ?>
272
+ </div>
273
+ </td>
274
+ <td>
275
+ <input name="title[]" type="text" id="title_<?php echo $i ?>" size="40" value = "<?php echo $point->title ?>"/>
276
+ <textarea name="desc[]" cols="40" rows="2" id="desc_<?php echo $i ?>"><?php echo $point->description ?></textarea>
277
+ </td>
278
+ <td>
279
+ <input name="ltlg[]" type="hidden" id="ltlg_<?php echo $i ?>" size="30" value = "<?php echo $point->ltlg ?>"/>
280
+ <textarea name="addr[]" cols="30" rows="2" id="addr_<?php echo $i ?>" style="display:none"><?php echo $point->address ?></textarea>
281
+ <p><?php echo $point->address ?></p>
282
+ <div>
283
  <input class="button" value="<?php _e("Update"); ?>" name="update" type="submit">
284
+ <a href="?post_id=<?php echo $post_id ?>&tab=gmshc&delp=<?php echo $i ?>" class="delete_point" onclick="if(confirm('<?php _e("You will not be able to roll back deletion. Are you sure?") ?>')) return true; else return false"><?php _e("Delete"); ?></a>
285
  </div>
286
+ </td>
287
+ </tr>
288
+ <?php
289
+ $i++;
290
+ }
291
+ ?>
292
  </tbody>
293
  </table>
294
 
295
+ <p><input class="button-primary" value="<?php _e("Insert Map"); ?>" type="button" id="insert_map"></p>
296
 
297
+ <?php } ?>
298
  </form>
299
  </div>
300
 
301
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  <?php
303
  }
304
 
 
305
  /**
306
  * Default Open Window Html
307
+ *
308
+ * Allows a plugin to replace the html that would otherwise be returned. The
309
+ * filter is 'gmshc_get_windowhtml' and passes the point.
310
+
311
+ * add_filter('gmshc_defaul_windowhtml','default_html',1,2);
312
+ *
313
+ * function default_html($windowhtml,$point){
314
+ * return "this is the address".$point->address;
315
+ * }
316
  */
317
  function gmshc_defaul_windowhtml(){
318
+
319
+ $defaul_gmshc_windowhtml = "";
320
+ $output = apply_filters('gmshc_defaul_windowhtml',$defaul_gmshc_windowhtml);
321
+
322
+ if ( $output != '' )
323
+ return $output;
324
 
325
+ $defaul_gmshc_windowhtml = "<div style='margin:0; padding:0px; height:110px; width:%width%; overflow:hidden; font-size:11px; clear:both; line-height:13px;'>\n";
326
  $defaul_gmshc_windowhtml .= "<div style='float:left; width:200px'>\n";
327
  $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";
328
+ $defaul_gmshc_windowhtml .= "<div><strong style='font-size:9px'>%address%</strong></div>\n";
329
+ $defaul_gmshc_windowhtml .= "<div style='font-size:10px'>%description%</div>\n";
330
  $defaul_gmshc_windowhtml .= "<a href='%link%' style='font-size:11px; float:left; display:block'>more &raquo;</a>\n";
331
+ $defaul_gmshc_windowhtml .= "<img src='".GMSC_PLUGIN_URL."/images/open.jpg' style='float: right; margin-right:5px'/> \n";
332
  $defaul_gmshc_windowhtml .= "<a href='%open_map%' target='_blank' style='font-size:11px; float: right; display:block;'>Open Map</a>\n";
333
  $defaul_gmshc_windowhtml .= "</div>\n";
334
  $defaul_gmshc_windowhtml .= "<div style='float:left'>%thubnail%</div>\n";
338
 
339
  }
340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  /**
342
  * The Sortcode
343
  */
352
  $width = $options['width'];
353
  $height = $options['height'];
354
  $zoom = $options['zoom'];
355
+ $icon = $options['default_icon'];
 
356
  $language = $options['language'];
357
 
358
  // First Point in the post
361
 
362
  $the_address = isset($address_meta[0]) ? $address_meta[0] : '';
363
  $point = isset($point_meta[0]) ? $point_meta[0] : '';
364
+ $the_items = array();
365
 
366
  extract(shortcode_atts(array(
367
+ 'address' => '',
368
+ 'title' =>'',
369
+ 'description' => '',
370
+ 'icon' => $icon,
371
+ 'thumbnail' => '',
372
  'id' => '',
373
  'cat' => '',
 
374
  'zoom' => $zoom,
375
  'width' => $width,
376
+ 'height' => $height,
 
377
  'language' => $language
378
  ), $atts));
379
 
380
+ $map_points = array();
381
 
382
+ // When address is set
383
+ if (!empty($address)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
 
385
+ //create single point object id = -1
386
+ $new_point = new GMSHC_Point();
387
+ if($new_point -> create_point($address,"",$title,$description,$icon,$thumbnail,-1)) $map_points[0]=$new_point;
388
+
389
+ // When id is set
390
+ } else if (!empty($id)) {
391
+ $post_points = new GMSHC_Post_Map();
392
+ $post_points -> create_post_map($id);
393
+ if (count($post_points -> points) > 0) $map_points = $post_points->points;
394
+
395
+ } else if ($cat != '') {
396
+
397
+ $categories = split (",",$cat);
398
+ $j = 0;
399
+
400
+ $post_obj = get_posts(array('category__in'=>$categories,'numberposts'=>-1));
401
+ foreach ($post_obj as $post_item) {
402
+ //create points object by cat
403
+ $post_points = new GMSHC_Post_Map();
404
+ $post_points -> create_post_map($post_item->ID);
405
+ if (count($post_points->points) >0) {
406
+ foreach ($post_points->points as $point) {
407
+ if (count($post_points -> points) > 0) array_push($map_points,$point);
 
 
 
 
 
 
 
 
408
  }
409
+ }
410
+ }
 
 
411
 
412
+ } else {
 
 
 
 
 
413
 
414
+ //create points for the current post_id
415
+
416
+ $post_points = new GMSHC_Post_Map();
417
+ $post_points -> create_post_map($post->ID);
418
+ $map_points = $post_points->points;
 
 
 
 
419
 
420
  }
421
 
422
+ //Map Point array filled
 
423
 
424
+ if ( count($map_points) > 0 ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
 
426
+ //Generate Map form points, width, height, zoom
427
+
428
+ return gmshc_generate_map($map_points, $width, $height, $zoom);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  }
 
430
  else return __("There is not points to locate on the map");
 
 
431
  }
432
 
433
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
434
 
435
  /**
436
  * Settings
439
  add_action('admin_menu', 'gmshc_set');
440
 
441
  function gmshc_set() {
442
+ $plugin_page = add_options_page('Google Map Shortcode', 'Google Map Shortcode', 'administrator', 'google-map-shortcode', 'gmshc_options_page');
443
+ add_action( 'admin_head-'.$plugin_page, 'gmshc_admin_script' );
444
+ }
445
+
446
+ /**
447
+ * Inserting files on the admin header
448
+ */
449
+ function gmshc_admin_script() {
450
+
451
+ $gmshc_admin_header = "\n<!-- Google Map Shortcode -->\n";
452
+ $gmshc_admin_header .= "<script type=\"text/javascript\" src=\"".GMSC_PLUGIN_URL."/js/gmshc-admin.js\"></script>\n";
453
+ $gmshc_admin_header .= "<link href=\"".GMSC_PLUGIN_URL."/styles/gmshc-admin-styles.css\" rel=\"stylesheet\" type=\"text/css\"/>\n";
454
+ $gmshc_admin_header .= "\n<!-- /Google Map Shortcode -->\n";
455
+
456
+ print($gmshc_admin_header);
457
+
458
  }
459
 
460
  function gmshc_options_page() {
461
 
462
  $options = get_gmshc_options();
 
 
 
 
 
463
 
464
+ if(isset($_POST['Restore_Default'])) $options = get_gmshc_options(true); ?>
465
+
466
  <div class="wrap">
467
 
468
  <h2><?php _e("Google Map Shortcode Settings") ?></h2>
471
 
472
  if(isset($_POST['Submit'])){
473
 
474
+ $newoptions['width'] = isset($_POST['width'])?$_POST['width']:$options['width'];
475
+ $newoptions['height'] = isset($_POST['height'])?$_POST['height']:$options['height'];
476
+ $newoptions['zoom'] = isset($_POST['zoom'])?$_POST['zoom']:$options['zoom'];
477
+ $newoptions['language'] = isset($_POST['language'])?$_POST['language']:$options['language'];
478
+ $newoptions['windowhtml'] = isset($_POST['windowhtml'])?$_POST['windowhtml']:$options['windowhtml'];
479
 
480
+ $newoptions['default_icon'] = isset($_POST['default_icon'])?$_POST['default_icon']:$options['default_icon'];
481
+ $newoptions['icons'] = $options['icons'];
482
+
483
+ $newoptions['version'] = GMSHC_VERSION_CHECK;
 
 
 
 
 
 
 
 
 
 
 
 
 
484
 
485
  if ( $options != $newoptions ) {
486
  $options = $newoptions;
487
  update_option('gmshc_op', $options);
488
  }
 
 
 
 
 
 
489
 
490
  }
491
 
495
  update_option('gmshc_op', $options);
496
 
497
  }
498
+
499
+ $upload_icons = $options['icons'];
500
 
501
+ if(isset($_POST['upload'])) {
502
+ if ($_FILES['datafile']['error'] == 0){
 
 
 
503
 
504
+ $filename = $_FILES["datafile"]["name"];
505
+
506
+ $upload = wp_upload_bits($filename, NULL, file_get_contents($_FILES["datafile"]["tmp_name"]));
507
+
508
+ if ( ! empty($upload['error']) ) {
509
+ $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $filename, $upload['error']);
510
+ echo "<div class='error'><p><strong>".$errorString."</strong></p></div>";
511
+ } else {
512
+ array_unshift($upload_icons,$upload['url']);
513
+ $options['icons'] = $upload_icons;
514
+ update_option('gmshc_op', $options);
515
+ }
516
 
517
+ } else {
518
+ echo "<div class='error'><p><strong>".__("Please upload a valid file")."</strong></p></div>";
519
  }
520
+ }
 
 
 
 
 
 
 
 
 
 
 
 
521
 
522
+ $width = $options['width'];
523
+ $height = $options['height'];
524
+ $zoom = $options['zoom'];
525
+ $language = $options['language'];
526
+ $windowhtml = $options['windowhtml'];
527
+ $default_icon = $options['default_icon'];
528
+
529
  ?>
530
 
531
  <form method="POST" name="options" target="_self" enctype="multipart/form-data">
534
 
535
  <p><?php _e("The shortcode attributes overwrite these options.") ?></p>
536
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
537
  <table width="80%%" border="0" cellspacing="10" cellpadding="0">
538
  <tr>
539
  <td colspan="2"><strong><?php _e("Dimensions") ?></strong></td>
540
  </tr>
541
  <tr>
542
+ <td width="60" align="right" height="40"><?php _e("Width") ?></td>
543
  <td><input name="width" type="text" size="6" value="<?php echo $width ?>" /></td>
544
  </tr>
545
  <tr>
549
  <tr>
550
  <td align="right"><?php _e("Zoom") ?></td>
551
  <td><input name="zoom" type="text" size="6" value="<?php echo $zoom ?>" /></td>
552
+ </tr>
 
 
 
 
553
  <tr>
554
+ <td colspan="2"><strong><?php _e("Select Default Icon") ?></strong></td>
555
  </tr>
556
  <tr>
557
+ <td align="right" valign="top" colspan="2">
558
+
559
+ <?php gmshc_deploy_icons(); ?>
560
+
 
 
 
 
 
 
 
 
 
561
  </td>
562
  </tr>
563
  <tr>
564
+ <td align="left" valign="top" colspan="2">
565
+ <?php _e("To include new icons just specify the file location:") ?><br />
566
+ <input type="file" name="datafile" size="40" /> <input type="submit" name="upload" value="Upload" class="button" />
 
 
 
 
 
 
 
 
 
 
 
567
  </td>
568
  </tr>
569
  <tr>
605
 
606
  <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;"><?php _e("Info Windows") ?></h3>
607
 
608
+ <p><?php _e("This is the html inside of the Map Info Window opened after clicking on the markers.") ?></p>
609
+
610
+ <div id="gmshc_html">
611
+ <textarea name="windowhtml" cols="50" rows="12" id="windowhtml">
612
+ <?php
613
+ if (empty($windowhtml)) echo gmshc_defaul_windowhtml();
614
+ else echo str_replace("\\", "",$windowhtml);
615
+ ?>
616
+ </textarea>
617
+ <div id="gmshc_previews">
618
+ <strong><?php _e("Previews") ?></strong>
619
+ <div id="gmshc_html_previews">
620
+ <?php echo gmshc_defaul_windowhtml(); ?>
621
+ </div>
622
+ </div>
623
+ </div>
624
 
625
+ <p><?php _e("You can include the following tags.") ?></p>
626
  <table width="80%%" border="0" cellspacing="10" cellpadding="0">
627
  <tr>
628
+ <td width="60" align="right"><strong>%title%</strong></td>
629
  <td><?php _e("The title of your post") ?></td>
630
  </tr>
631
  <tr>
636
  <td align="right"><strong>%thubnail%</strong></td>
637
  <td><?php _e("The thubnail of the last image attached to your post") ?></td>
638
  </tr>
639
+ <tr>
640
+ <td align="right"><strong>%description%</strong></td>
641
+ <td><?php _e("The excerpt of your post") ?></td>
642
+ </tr>
643
  <tr>
644
  <td align="right"><strong>%excerpt%</strong></td>
645
  <td><?php _e("The excerpt of your post") ?></td>
657
  <td><?php _e("Info Html width") ?></td>
658
  </tr>
659
  </table>
660
+
661
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
  <p class="submit">
663
+ <input type="submit" name="Submit" value="Update" class="button-primary" /><input type="submit" name="Use_Default" value="<?php _e("Restore Default Html") ?>"/>
664
  </p>
665
 
666
+ <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;"><?php _e("How to Use") ?></h3>
667
  <p><?php _e("You can include a Google Map Shortcode everywhere") ?></p>
668
 
669
  <p><?php _e("In your post using: ") ?><strong>[google-map-sc option = "option value"]</strong></p>
670
  <p><?php _e("In your theme files using: ") ?><strong> echo do_shortcode ('[google-map-sc option = "option value"]') </strong></p>
671
+
672
 
673
+ <h3 style="padding-top:30px; margin-top:30px; border-top:1px solid #CCCCCC;"><?php _e("Feedback") ?></h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
674
 
675
+ <p><?php _e('For more details and examples visite the <a http://web-argument.com/2011/07/18/google-map-shortcode-plugin-version-2-1">Plugin Page</a>. All the comments are welcome.') ?></p>
676
 
677
 
678
  <p class="submit">
679
+ <input type="submit" name="Submit" value="Update" class="button-primary" /><input type="submit" name="Restore_Default" value="<?php _e("Restore Default") ?>" class="button" />
680
  </p>
681
  </form>
682
  </div>
683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
684
 
685
+ <?php } ?>
images/Thumbs.db DELETED
Binary file
images/icons/Thumbs.db DELETED
Binary file
include/class.gmshc_point.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Google Map Shortcode
4
+ * Version: 2.1
5
+ * Author: Alain Gonzalez
6
+ * Author URI: http://web-argument.com/
7
+ */
8
+
9
+ class GMSHC_Point {
10
+
11
+ var $address;
12
+ var $ltlg;
13
+ var $title;
14
+ var $description;
15
+ var $icon;
16
+ var $thumbnail;
17
+ var $post_id;
18
+
19
+ function create_point($address,$ltlg,$title,$description,$icon,$thumbnail,$post_id,$check = true){
20
+
21
+ if(empty($address)) return false;
22
+ if ($check) {
23
+ $temp_point = gmshc_point($address,$ltlg);
24
+ if (count($temp_point) > 0) {
25
+ $temp_address = $temp_point['address'];
26
+ $temp_ltlg = $temp_point['point'];
27
+ } else return false;
28
+ }
29
+ else {
30
+ $temp_address = $address;
31
+ $temp_ltlg = $ltlg;
32
+ }
33
+ $this->address = $temp_address;
34
+ $this->ltlg = $temp_ltlg;
35
+ $this->title = $title;
36
+ $this->description = $description;
37
+ $this->icon = $icon;
38
+ $this->thumbnail = $thumbnail;
39
+ $this->post_id = $post_id;
40
+ return true;
41
+ }
42
+
43
+ }
44
+
45
+ ?>
include/class.gmshc_post_points.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Google Map Shortcode
4
+ * Version: 2.1
5
+ * Author: Alain Gonzalez
6
+ * Author URI: http://web-argument.com/
7
+ */
8
+
9
+ class GMSHC_Post_Map
10
+ {
11
+ var $post_id;
12
+ var $points = array();
13
+ var $post_data;
14
+
15
+ function create_post_map($id) {
16
+ $this->post_id = $id;
17
+ $this->load_data();
18
+ }
19
+
20
+ function add_point($single_point){
21
+ array_unshift($this -> points,$single_point);
22
+ $saved = gmshc_save_points($this->post_id,$this -> points);
23
+ if($saved) {
24
+ $this->load_data();
25
+ }
26
+ return $saved;
27
+ }
28
+
29
+
30
+ function delete_point($point_id){
31
+
32
+ unset($this->points[$point_id]);
33
+ $saved = gmshc_save_points($this->post_id,$this->points);
34
+ if($saved) {
35
+ $this->load_data();
36
+ }
37
+ return $saved;
38
+ }
39
+
40
+ function update_points($address_list,$ltlg_list,$title_list,$desc_list,$icon_list,$thumb_list){
41
+ $new_points_array = array();
42
+ $point = array();
43
+ foreach ($address_list as $id => $address){
44
+ $new_point = new GMSHC_Point();
45
+ if($new_point->create_point($address[$id],$ltlg_list[$id],$title_list[$id],$desc_list[$id],$icon_list[$id],$thumb_list[$id],$this->post_id,false)) {
46
+ array_push($new_points_array,$new_point);
47
+ }
48
+ else return false;
49
+ }
50
+
51
+
52
+ $saved = gmshc_save_points($this->post_id,$new_points_array);
53
+ if($saved) {
54
+ $this->load_data();
55
+ }
56
+ return $saved;
57
+ }
58
+
59
+
60
+
61
+ function load_data(){
62
+ $this->points = gmshc_get_points($this->post_id);
63
+ $this->post_data = get_post_meta($this->post_id,'google-map-sc',true);
64
+ }
65
+
66
+ }
67
+ ?>
include/functions.php ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Google Map Shortcode
4
+ * Version: 2.1
5
+ * Author: Alain Gonzalez
6
+ * Author URI: http://web-argument.com/
7
+ */
8
+
9
+ function gmshc_generate_map($map_points, $width, $height, $zoom) {
10
+
11
+ $canvas = "canvas_".wp_generate_password(4, false);
12
+
13
+ $output ='<div id="'.$canvas.'" class = "gmsc" style="width:'.$width.'px; height:'.$height.'px; margin:10px auto"></div>';
14
+ $output .= "<script type=\"text/javascript\">\n";
15
+
16
+ $output .= "var map_".$canvas.";\n";
17
+ $output .= "var map_points_".$canvas." = new Array();\n";
18
+
19
+ $i = 0;
20
+
21
+ foreach ($map_points as $point){
22
+
23
+ list($lat,$long) = explode(",",$point->ltlg);
24
+ $output .= "map_points_".$canvas."[".$i."] = \n";
25
+ $output .= "{\"address\":\"".$point->address."\",\n";
26
+ $output .= "\"lat\":\"".$lat."\",\n";
27
+ $output .= "\"long\":\"".$long."\",\n";
28
+ $output .= "\"info\":\"".gmshc_get_windowhtml($point)."\",\n";
29
+ $output .= "\"icon\":\"".$point->icon."\"};\n";
30
+ $i ++;
31
+
32
+ }
33
+ $output .= "addLoadEvent(function(){\n";
34
+ $output .= "gmshc_render(\"".$canvas."\",map_points_".$canvas.", ".$zoom.");\n";
35
+ $output .= "});\n";
36
+ $output .= "</script>\n";
37
+
38
+ return $output;
39
+ }
40
+
41
+
42
+ /**
43
+ * Get the html info
44
+ *
45
+ * Allows a plugin to replace the html that would otherwise be returned. The
46
+ * filter is 'gmshc_get_windowhtml' and passes the point.
47
+
48
+ * add_filter('gmshc_get_windowhtml','default_html',1,2);
49
+ *
50
+ * function default_html($windowhtml,$point){
51
+ * return "this is the address".$point->address;
52
+ * }
53
+ */
54
+
55
+ function gmshc_get_windowhtml(&$point) {
56
+
57
+ $windowhtml = "";
58
+ $output = apply_filters('gmshc_get_windowhtml',$windowhtml,$point);
59
+
60
+ if ( $output != '' )
61
+ return $output;
62
+
63
+ $options = get_gmshc_options();
64
+ $windowhtml_frame = $options['windowhtml'];
65
+
66
+ $open_map_url = "http://maps.google.com/?q=".urlencode($point->address);
67
+ $point_title = $point->title;
68
+ if (($point->post_id) > 0) $point_link = get_permalink($point->post_id);
69
+ else $point_link = "";
70
+ $point_img_url = ($point->thumbnail != "")? $point->thumbnail : gmshc_post_thumb($point->post_id);
71
+ $point_excerpt = gmshc_get_excerpt($post_id);
72
+ $point_description = ($point->description != "") ? $point->description : $point_excerpt;
73
+ $point_address = $point->address;
74
+
75
+ if(isset($point_img_url)) {
76
+ $point_img = "<img src='".$point_img_url."' style='margin:8px 0 0 8px; width:90px; height:90px'/>";
77
+ $html_width = "310px";
78
+ } else {
79
+ $point_img = "";
80
+ $html_width = "auto";
81
+ }
82
+
83
+ $find = array("%title%","%link%","%thubnail%", "%excerpt%","%description%","%address%","%open_map%","%width%","\f","\v","\t","\r","\n","\\","\"");
84
+ $replace = array($point_title,$point_link,$point_img,$point_excerpt,$point_description,$point_address,$open_map_url,$html_width,"","","","","","","'");
85
+
86
+ $windowhtml = str_replace( $find,$replace, $windowhtml_frame);
87
+
88
+ return $windowhtml;
89
+
90
+ }
91
+
92
+ /**
93
+ * Get all the thumbnails from post
94
+ */
95
+ function gmshc_all_post_thumb($the_parent){
96
+
97
+ $images_url = array();
98
+ $attachments = get_children( array(
99
+ 'post_parent' => $the_parent,
100
+ 'post_type' => 'attachment',
101
+ 'post_mime_type' => 'image',
102
+ 'orderby' => 'menu_order',
103
+ 'order' => 'ASC',
104
+ 'numberposts' => 10) );
105
+
106
+ if($attachments == true) :
107
+ foreach($attachments as $id => $attachment) :
108
+ $img = wp_get_attachment_image_src($id, 'thumbnail');
109
+ array_push($images_url,$img[0]);
110
+ endforeach;
111
+ endif;
112
+
113
+ return $images_url;
114
+
115
+ }
116
+
117
+
118
+
119
+ /**
120
+ * Get the thumbnail from post
121
+ */
122
+ function gmshc_post_thumb($the_parent){
123
+
124
+ if( function_exists('has_post_thumbnail') && has_post_thumbnail($the_parent)) {
125
+ $thumbnail_id = get_post_thumbnail_id( $the_parent );
126
+ if(!empty($thumbnail_id))
127
+ $img = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail' );
128
+ } else {
129
+ $attachments = get_children( array(
130
+ 'post_parent' => $the_parent,
131
+ 'post_type' => 'attachment',
132
+ 'post_mime_type' => 'image',
133
+ 'orderby' => 'menu_order',
134
+ 'order' => 'ASC',
135
+ 'numberposts' => 1) );
136
+ if($attachments == true) :
137
+ foreach($attachments as $id => $attachment) :
138
+ $img = wp_get_attachment_image_src($id, 'thumbnail');
139
+ endforeach;
140
+ endif;
141
+ }
142
+ if (isset($img[0])) return $img[0];
143
+
144
+ }
145
+
146
+ /**
147
+ * Get the excerpt from content
148
+ */
149
+ function gmshc_get_excerpt($post_id) { // Fakes an excerpt if needed
150
+
151
+ $content_post = get_post($post_id);
152
+ $content = $content_post->post_content;
153
+
154
+ if ( '' != $content ) {
155
+
156
+ $content = strip_shortcodes( $content );
157
+
158
+ $content = apply_filters('the_content', $content);
159
+ $content = str_replace(']]>', ']]&gt;', $content);
160
+ $content = strip_tags($content);
161
+ $excerpt_length = 10;
162
+ $words = explode(' ', $content, $excerpt_length + 1);
163
+ if (count($words) > $excerpt_length) {
164
+ array_pop($words);
165
+ array_push($words, '[...]');
166
+ $content = implode(' ', $words);
167
+ }
168
+ }
169
+ return $content;
170
+ }
171
+
172
+ /**
173
+ * Deploy the icons list to select one
174
+ */
175
+ function gmshc_deploy_icons(){
176
+
177
+ $options = get_gmshc_options();
178
+ $icon_path = GMSC_PLUGIN_URL.'/images/icons/';
179
+ $icon_dir = GMSC_PLUGIN_DIR.'/images/icons/';
180
+
181
+ $icons_array = $options['icons'];
182
+ $default_icon = $options['default_icon'];
183
+
184
+ if ($handle = opendir($icon_dir)) {
185
+
186
+ while (false !== ($file = readdir($handle))) {
187
+
188
+ $file_type = wp_check_filetype($file);
189
+
190
+ $file_ext = $file_type['ext'];
191
+
192
+ if ($file != "." && $file != ".." && ($file_ext == 'gif' || $file_ext == 'jpg' || $file_ext == 'png') ) {
193
+ array_push($icons_array,$icon_path.$file);
194
+ }
195
+ }
196
+ }
197
+ ?>
198
+ <div class="gmshc_label">
199
+ <strong><?php _e("Marker: "); ?></strong><?php _e("Select by clicking on the images"); ?>
200
+ </div>
201
+ <div id="gmshc_icon_cont">
202
+ <input type="hidden" name="default_icon" value="<?php echo $default_icon ?>" id="default_icon" />
203
+ <?php foreach ($icons_array as $icon){ ?>
204
+ <div class="gmshc_icon <?php if ($default_icon == $icon) echo "gmshc_selected" ?>">
205
+ <img src="<?php echo $icon ?>" />
206
+ </div>
207
+ <?php } ?>
208
+ </div>
209
+ <?php
210
+ }
211
+
212
+
213
+ /**
214
+ * Get post points form the post custom field 'google-map-sc'
215
+ */
216
+ function gmshc_get_points($post_id) {
217
+
218
+ $post_data = get_post_meta($post_id,'google-map-sc',true);
219
+
220
+ $post_points = array();
221
+ if($post_data != ""){
222
+ $points = json_decode($post_data, true);
223
+ if(is_array($points)){
224
+ foreach($points as $point){
225
+ $point_obj = new GMSHC_Point();
226
+ if ($point_obj -> create_point($point['address'],$point['ltlg'],$point['title'],$point['description'],$point['icon'],$point['thumbnail'],$post_id))
227
+ array_push($post_points,$point_obj);
228
+ }
229
+ }
230
+
231
+ } else {
232
+
233
+ /** checking for old custom fields **/
234
+ $post_data_address = get_post_meta($post_id,'google-map-sc-address');
235
+
236
+ if (count($post_data_address) > 0) {
237
+ $options = get_gmshc_options();
238
+ $default_icon = $options['default_icon'];
239
+ $post_title = get_the_title($post_id);
240
+ foreach ($post_data_address as $point_address){
241
+ $point_obj = new GMSHC_Point();
242
+ if ($point_obj -> create_point($point_address,"",$post_title,"",$default_icon,"",$post_id)){
243
+
244
+ array_push($post_points,$point_obj);
245
+ }
246
+ }
247
+ if (count($post_points) > 0)
248
+ gmshc_save_points($post_id,$post_points);
249
+ }
250
+
251
+ }
252
+
253
+ return $post_points;
254
+ }
255
+
256
+
257
+ /**
258
+ * Save the json data into the post custom field 'google-map-sc'
259
+ */
260
+ function gmshc_save_points($post_id,$points) {
261
+
262
+ $post_data = get_post_meta($post_id,'google-map-sc',true);
263
+
264
+ $new_post_data = json_encode($points);
265
+
266
+ if ($post_data == "null") return add_post_meta($post_id, 'google-map-sc', $new_post_data, true);
267
+ else return update_post_meta($post_id,'google-map-sc',$new_post_data, $post_data);
268
+
269
+ }
270
+
271
+
272
+ /**
273
+ * Get the point from geocoding from address or latitude,longitude
274
+ * http://code.google.com/apis/maps/documentation/geocoding/
275
+ */
276
+
277
+ function gmshc_point ($address,$ltlg){
278
+
279
+ $formatted_address = "";
280
+ $point = "";
281
+ $response = false;
282
+
283
+ if (!empty($ltlg)) {
284
+ $query = $ltlg;
285
+ $type = "latlng";
286
+ } else if (!empty($address)) {
287
+
288
+ $find = array("\n","\r"," ");
289
+ $replace = array("","","+");
290
+ $address = str_replace( $find,$replace, $address);
291
+
292
+ $query = $address;
293
+ $type = "address";
294
+ }
295
+
296
+ else return false;
297
+
298
+ $options = get_gmshc_options();
299
+ $api_url = "http://maps.googleapis.com/maps/api/geocode/json?".$type."=".$query."&sensor=false&language=".$options['language'];
300
+
301
+ $json_answ = file_get_contents($api_url);
302
+ $answ_arr = json_decode($json_answ,true);
303
+
304
+ if (isset($answ_arr["status"]) && $answ_arr["status"] == "OK"){
305
+ $formatted_address = $answ_arr["results"]["0"]["formatted_address"];
306
+ $point = $answ_arr["results"]["0"]["geometry"]["location"]["lat"].",".$answ_arr["results"]["0"]["geometry"]["location"]["lng"];
307
+ }
308
+
309
+ if (!empty($point) && !empty($formatted_address)){
310
+
311
+ $response = array('point'=>$point,'address'=>$formatted_address);
312
+
313
+ }
314
+
315
+ return $response;
316
+
317
+ }
318
+
319
+ ?>
js/gmshc-admin.js ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Google Map Shortcode
3
+ * Version: 2.1
4
+ * Author: Alain Gonzalez
5
+ * Author URI: http://web-argument.com/
6
+ */
7
+
8
+ (function ($) {
9
+
10
+ $(window).load(function(){
11
+
12
+ var iconSelect = "";
13
+
14
+ $(".gmshc_icon,.gmshc_thumb").click(function(){
15
+ gmshc_switchImg($(this));
16
+ }).mouseover(function(){
17
+ $(this).css({"border":"solid #cccccc 1px"})
18
+ }).mouseout(function(){
19
+ $(this).css({"border":"solid #ffffff 1px"})
20
+ });
21
+
22
+ $("#insert_map").click(function(){
23
+
24
+ gmshc_add_map();
25
+ parent.tb_remove();
26
+
27
+ });
28
+
29
+ $("#new_title").click(function(){
30
+ $(this).val("");
31
+ });
32
+
33
+ gmshc_update_editor_custom_field();
34
+
35
+ });
36
+
37
+ function gmshc_switchImg(obj) {
38
+ var iconSrc = obj.children("img").attr("src");
39
+ obj.siblings().removeClass('gmshc_selected');
40
+ obj.addClass('gmshc_selected');
41
+ obj.siblings("input").val(iconSrc);
42
+ //$("#default_icon").val(iconSrc);
43
+ }
44
+
45
+ function gmshc_add_map(){
46
+ var width = $("#width").val();
47
+ var height = $("#height").val();
48
+ var zoom = $("#zoom").val();
49
+
50
+ str = "[google-map-sc";
51
+ if (width != '')
52
+ str += " width="+width;
53
+ if (height != '')
54
+ str += " height="+height;
55
+ if (zoom != '')
56
+ str += " zoom="+zoom;
57
+ str +="]";
58
+
59
+ var win = window.dialogArguments || opener || parent || top;
60
+ win.send_to_editor(str);
61
+
62
+ }
63
+
64
+ function gmshc_update_editor_custom_field(){
65
+ var mapData = $("#post_data").val();
66
+ jQueryParent = parent.jQuery;
67
+ var gmshcDivPostCustomStuff = jQueryParent("#postcustom input:[value=google-map-sc]").parents("tr");
68
+ if (gmshcDivPostCustomStuff.length > 0) jQueryParent("textarea",gmshcDivPostCustomStuff).val(mapData);
69
+ }
70
+
71
+ function gmshc_delete_point(id,msg){
72
+ var answer = confirm(msg);
73
+ alert(answer);
74
+ if (answer) {
75
+ var width = $("#width").val();
76
+ var height = $("#height").val();
77
+ var zoom = $("#zoom").val();
78
+ var url = "?post_id=<?php echo $post_id ?>&tab=gmshc&delp="+id+"&width="+width+"&height="+height+"&zoom="+zoom;
79
+ window.location = url;
80
+ } else {
81
+ return false;
82
+ }
83
+ }
84
+
85
+
86
+
87
+ })(jQuery);
88
+
89
+
90
+
google-map-sc-v3.js → js/gmshc-render.js RENAMED
@@ -1,6 +1,6 @@
1
  /**
2
  * Google Map Shortcode
3
- * Version: 2.0
4
  * Author: Alain Gonzalez
5
  * Author URI: http://web-argument.com/
6
  */
@@ -9,7 +9,7 @@ function gmshc_render(id,GMpointsArray,zoom) {
9
 
10
  var myOptions = {
11
  zoom: zoom,
12
- center: new google.maps.LatLng(GMpointsArray[0].point.lat,GMpointsArray[0].point.long),
13
  mapTypeId: google.maps.MapTypeId.ROADMAP
14
  }
15
  var map = new google.maps.Map(document.getElementById(id),myOptions);
@@ -20,17 +20,17 @@ function gmshc_render(id,GMpointsArray,zoom) {
20
 
21
  function gmshc_placing (map, locations){
22
 
23
- var infowindow;
24
 
25
  for (var i = 0; i < locations.length; i++){
26
 
27
  var location = locations[i];
28
 
29
  var marker = new google.maps.Marker({
30
- position: new google.maps.LatLng(location.point.lat, location.point.long),
31
- map: map,
32
- icon: new google.maps.MarkerImage(location.icon),
33
- title:location.address
34
  });
35
 
36
 
1
  /**
2
  * Google Map Shortcode
3
+ * Version: 2.1
4
  * Author: Alain Gonzalez
5
  * Author URI: http://web-argument.com/
6
  */
9
 
10
  var myOptions = {
11
  zoom: zoom,
12
+ center: new google.maps.LatLng(GMpointsArray[0].lat,GMpointsArray[0].long),
13
  mapTypeId: google.maps.MapTypeId.ROADMAP
14
  }
15
  var map = new google.maps.Map(document.getElementById(id),myOptions);
20
 
21
  function gmshc_placing (map, locations){
22
 
23
+ //var infowindow;
24
 
25
  for (var i = 0; i < locations.length; i++){
26
 
27
  var location = locations[i];
28
 
29
  var marker = new google.maps.Marker({
30
+ position: new google.maps.LatLng(location.lat, location.long),
31
+ map: map,
32
+ icon: new google.maps.MarkerImage(location.icon),
33
+ title:location.address
34
  });
35
 
36
 
readme.txt CHANGED
@@ -1,36 +1,36 @@
1
  === Google Map Shortcode ===
2
  Contributors: Alaingg
3
- 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.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
 
13
- This plugin allows you to include instances of Google Map in your blogs using shortcodes. You can insert maps everywhere: in your theme files, posts and pages. An editor button allows to insert address and map to your posts/pages with a single click.
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.
24
  * API key not required.
25
  * Multiples points in a single map.
26
  * Multiples maps in a single page.
27
- * Adding posts in the mas under categories.
28
  * Inserting maps everywhere.
29
- * When you click on a point in the map the window box opened shows part of the content of your posts (post title, thumbnails, excerpt)
30
- * You can customize the html of the info window box on your maps
31
- * The shortcode allows different options to customize your maps like: inicial zoom, width, height, under categories, post ID, number of points, specific address, icon
32
 
33
- For more details and examples visit the <a href="http://web-argument.com/google-map-shortcode-2-0-total-solution/">plugin page</a>.
34
 
35
  == Installation ==
36
 
@@ -39,18 +39,24 @@ For more details and examples visit the <a href="http://web-argument.com/google-
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 ==
44
 
45
  1. Custom Marker
46
- 2. Editor Button
47
- 3. Custom Field
48
- 4. Custom Html por window box
49
- 5. Shortcode example
50
 
51
 
52
  == Changelog ==
53
 
 
 
 
 
 
 
54
  = 2.0.1 =
55
  * Geocoding API request changed.
56
  * Html width parameter included.
@@ -60,7 +66,7 @@ For more details and examples visit the <a href="http://web-argument.com/google-
60
  * Google Map Javascript v3 integrated.
61
  * Editor button added.
62
  * Ready for translation.
63
- * Maps in different languages allows.
64
 
65
  = 1.1 =
66
  * Loops related bugs fixed.
@@ -69,5 +75,5 @@ For more details and examples visit the <a href="http://web-argument.com/google-
69
  * More than one point per post fixed.
70
 
71
  = 1.0.0 =
72
- * Inicial release.
73
 
1
  === Google Map Shortcode ===
2
  Contributors: Alaingg
3
+ Donate link: http://web-argument.com/2011/07/18/google-map-shortcode-plugin-version-2-1/
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.2.1
7
+ Stable tag: 2.1
8
 
9
+ Friendly integration of Google Map instances into your blogs. Allows displaying multiple maps on your pages. Insert points into maps easily.
10
 
11
  == Description ==
12
 
13
+ This plugin allows you to include instances of Google Map in your blogs using shortcodes. You can insert maps everywhere: in your theme files, posts and pages. An editor button allows inserting points and maps into your posts/pages with a single click. The points can include custom title, description, marker and thumbnail.
14
 
15
  Special Features:
16
 
17
  * Editor button added, to include the points to the map easily.
18
+ * Custom markers allowed.
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.
24
  * API key not required.
25
  * Multiples points in a single map.
26
  * Multiples maps in a single page.
27
+ * Show post under categories.
28
  * Inserting maps everywhere.
29
+ * When you click on a point the window box opened can shows part of the content of your posts (post title, thumbnails and excerpt) or a custom title description and thumbnail.
30
+ * You can customize the html of the info window box on your maps.
31
+ * The shortcode allows different options to customize your maps like: initial zoom, width, height, under categories, post ID, number of points, specific address, icon and thumbnail.
32
 
33
+ For more details and examples visit the <a href="http://web-argument.com/2011/07/18/google-map-shortcode-plugin-version-2-1/">plugin page</a>.
34
 
35
  == Installation ==
36
 
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
+ == How to use ==
43
+ Visit <a href="http://web-argument.com/2011/07/20/google-map-shortcode-how-to-use/">Google Map Shortcode - How to use</a>
44
 
45
  == Screenshots ==
46
 
47
  1. Custom Marker
48
+ 2. Google Map Shortcode Button
49
+ 3. Google Map Shortcode editor panel
 
 
50
 
51
 
52
  == Changelog ==
53
 
54
+ = 2.1 =
55
+ * Allows selecting single point icon, title and description.
56
+ * Html filters added.
57
+ * Just one custom field by post to include all the points.
58
+ * Icon selection improved.
59
+
60
  = 2.0.1 =
61
  * Geocoding API request changed.
62
  * Html width parameter included.
66
  * Google Map Javascript v3 integrated.
67
  * Editor button added.
68
  * Ready for translation.
69
+ * Maps in different languages allowed.
70
 
71
  = 1.1 =
72
  * Loops related bugs fixed.
75
  * More than one point per post fixed.
76
 
77
  = 1.0.0 =
78
+ * Initial release.
79
 
screenshot-1.jpg CHANGED
Binary file
screenshot-3.jpg CHANGED
Binary file
screenshot-4.jpg DELETED
Binary file
screenshot-5.jpg DELETED
Binary file
styles/gmshc-admin-styles.css ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Google Map Shortcode
3
+ * Version: 2.1
4
+ * Author: Alain Gonzalez
5
+ * Author URI: http://web-argument.com/
6
+ */
7
+
8
+ #gmshc_icon_cont {
9
+ width:560px;
10
+ height:88px;
11
+ float:left;
12
+ overflow:auto;
13
+ padding:5px
14
+ }
15
+
16
+ #gmshc_thumb_cont {
17
+ clear:both;
18
+ overflow:hidden;
19
+ width:590px;
20
+ height:65px;
21
+ }
22
+
23
+ .gmshc_icon, .gmshc_thumb {
24
+ float:left;
25
+ cursor:pointer;
26
+ margin:1px;
27
+ padding:1px;
28
+ border:solid 1px #ffffff;
29
+ cursor:pointer;
30
+ text-align:center;
31
+ }
32
+
33
+ .gmshc_icon {
34
+ width:37px;
35
+ height:37px;
36
+ }
37
+
38
+ .gmshc_thumb {
39
+ padding:4px;
40
+ width:40px;
41
+ height:40px;
42
+ }
43
+
44
+ .gmshc_selected {
45
+ border:solid #CCC 1px !important;
46
+ background-color:#EEE;
47
+ }
48
+
49
+ .gmshc_label {
50
+ padding:5px;
51
+ text-align:left;
52
+ }
53
+
54
+ #gmshc_html {
55
+ clear:both;
56
+ overflow:hidden;
57
+ }
58
+
59
+ #gmshc_html textarea {
60
+ float:left;
61
+ }
62
+
63
+ #gmshc_previews {
64
+ float:left;
65
+ width:300px;
66
+ margin-left:20px;
67
+ }
68
+
69
+ #gmshc_html_previews {
70
+ border:solid 1px #CCC;
71
+ padding:10px;
72
+ }