WP Google Maps - Version 7.10.21

Version Description

:- 2018-07-09 :- Medium priority = * Added MySQL version check and dropped ST_ function prefixes for versions < 8.0 * Fixed markers not appearing front end and back end marker table empty for servers running old MySQL versions

Download this release

Release Info

Developer perryrylance
Plugin Icon 128x128 WP Google Maps
Version 7.10.21
Comparing to
See all releases

Code changes from version 7.10.20 to 7.10.21

includes/class.marker.php CHANGED
@@ -25,8 +25,10 @@ class Marker extends Crud
25
 
26
  protected function get_placeholder_by_type($type)
27
  {
 
 
28
  if($type == 'point')
29
- return "ST_GeomFromText(%s)";
30
 
31
  return Crud::get_placeholder_by_type($type);
32
  }
25
 
26
  protected function get_placeholder_by_type($type)
27
  {
28
+ global $wpgmza;
29
+
30
  if($type == 'point')
31
+ return "{$wpgmza->spatialFunctionPrefix}GeomFromText(%s)";
32
 
33
  return Crud::get_placeholder_by_type($type);
34
  }
includes/class.plugin.php CHANGED
@@ -35,11 +35,16 @@ class Plugin
35
 
36
  protected $scriptLoader;
37
 
 
38
  private $cachedVersion = null;
39
  private $legacySettings;
40
 
41
  public function __construct()
42
  {
 
 
 
 
43
  $this->legacySettings = get_option('WPGMZA_OTHER_SETTINGS');
44
  if(!$this->legacySettings)
45
  $this->legacySettings = array();
@@ -87,6 +92,27 @@ class Plugin
87
  require_once(plugin_dir_path(__FILE__) . 'open-layers/class.nominatim-geocode-cache.php');
88
  }
89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  public function loadScripts()
91
  {
92
  if(!$this->scriptLoader)
35
 
36
  protected $scriptLoader;
37
 
38
+ private $mysqlVersion = null;
39
  private $cachedVersion = null;
40
  private $legacySettings;
41
 
42
  public function __construct()
43
  {
44
+ global $wpdb;
45
+
46
+ $this->mysqlVersion = $wpdb->get_var('SELECT VERSION()');
47
+
48
  $this->legacySettings = get_option('WPGMZA_OTHER_SETTINGS');
49
  if(!$this->legacySettings)
50
  $this->legacySettings = array();
92
  require_once(plugin_dir_path(__FILE__) . 'open-layers/class.nominatim-geocode-cache.php');
93
  }
94
 
95
+ public function __get($name)
96
+ {
97
+ switch($name)
98
+ {
99
+ case "spatialFunctionPrefix":
100
+ $result = '';
101
+
102
+ if(!empty($this->mysqlVersion))
103
+ {
104
+ $majorVersion = (int)preg_match('/^\d+/', $this->mysqlVersion);
105
+ if($majorVersion >= 8)
106
+ $result = 'ST_';
107
+ }
108
+
109
+ return $result;
110
+ break;
111
+ }
112
+
113
+ return $this->{$name};
114
+ }
115
+
116
  public function loadScripts()
117
  {
118
  if(!$this->scriptLoader)
includes/compat/backwards_compat_v6.php CHANGED
@@ -96,8 +96,9 @@ function wpgmza_check_pro_compat_required_v6(){
96
  function wpgmza_backwards_compat_get_all_circle_data(){
97
  global $wpdb;
98
  global $wpgmza_tblname_circles;
 
99
 
100
- $stmt = "SELECT *, ST_AsText(center) AS center FROM $wpgmza_tblname_circles";
101
  $results = $wpdb->get_results($stmt);
102
 
103
  $circles = array();
@@ -110,8 +111,9 @@ function wpgmza_backwards_compat_get_all_circle_data(){
110
  function wpgmza_backwards_compat_get_all_rectangle_data(){
111
  global $wpdb;
112
  global $wpgmza_tblname_rectangles;
 
113
 
114
- $stmt = "SELECT *, ST_AsText(cornerA) AS cornerA, ST_AsText(cornerB) AS cornerB FROM $wpgmza_tblname_rectangles";
115
  $results = $wpdb->get_results($stmt);
116
 
117
  $rectangles = array();
96
  function wpgmza_backwards_compat_get_all_circle_data(){
97
  global $wpdb;
98
  global $wpgmza_tblname_circles;
99
+ global $wpgmza;
100
 
101
+ $stmt = "SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(center) AS center FROM $wpgmza_tblname_circles";
102
  $results = $wpdb->get_results($stmt);
103
 
104
  $circles = array();
111
  function wpgmza_backwards_compat_get_all_rectangle_data(){
112
  global $wpdb;
113
  global $wpgmza_tblname_rectangles;
114
+ global $wpgmza;
115
 
116
+ $stmt = "SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(cornerA) AS cornerA, {$wpgmza->spatialFunctionPrefix}AsText(cornerB) AS cornerB FROM $wpgmza_tblname_rectangles";
117
  $results = $wpdb->get_results($stmt);
118
 
119
  $rectangles = array();
readme.txt CHANGED
@@ -215,6 +215,10 @@ Please upgrade your version of WP Google Maps to version 6.0.27 as it includes m
215
 
216
  == Changelog ==
217
 
 
 
 
 
218
  = 7.10.20 :- 2018-07-05 :- Low priority =
219
  * Added hook for new GDPR tab content
220
  * Added JavaScript for VGM GDPR controls
215
 
216
  == Changelog ==
217
 
218
+ = 7.10.21 :- 2018-07-09 :- Medium priority =
219
+ * Added MySQL version check and dropped ST_ function prefixes for versions < 8.0
220
+ * Fixed markers not appearing front end and back end marker table empty for servers running old MySQL versions
221
+
222
  = 7.10.20 :- 2018-07-05 :- Low priority =
223
  * Added hook for new GDPR tab content
224
  * Added JavaScript for VGM GDPR controls
wpGoogleMaps.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Google Maps
4
  Plugin URI: https://www.wpgmaps.com
5
  Description: The easiest to use Google Maps plugin! Create custom Google Maps with high quality markers containing locations, descriptions, images and links. Add your customized map to your WordPress posts and/or pages quickly and easily with the supplied shortcode. No fuss.
6
- Version: 7.10.20
7
  Author: WP Google Maps
8
  Author URI: https://www.wpgmaps.com
9
  Text Domain: wp-google-maps
@@ -11,6 +11,10 @@ Domain Path: /languages
11
  */
12
 
13
  /*
 
 
 
 
14
  * 7.10.20 :- 2018-07-05 :- Low priority
15
  * Added hook for new GDPR tab content
16
  * Added JavaScript for VGM GDPR controls
@@ -603,6 +607,8 @@ $debug_start = (float) array_sum(explode(' ',microtime()));
603
  function wpgmaps_activate() {
604
  global $wpdb;
605
  global $wpgmza_version;
 
 
606
  $table_name = $wpdb->prefix . "wpgmza";
607
  $table_name_maps = $wpdb->prefix . "wpgmza_maps";
608
 
@@ -700,7 +706,7 @@ function wpgmaps_activate() {
700
 
701
  VALUES
702
 
703
- (%d, %s, %s, %s, ST_GeomFromText(%s), %s, %s, %s, %d, %s, %s, %s, %s, %d)", array(
704
 
705
  1,
706
  'California',
@@ -2231,6 +2237,7 @@ function wpgmaps_return_markers($mapid = false,$marker_id = false) {
2231
  } else {
2232
  $results = $wpdb->get_results($wpdb->prepare("SELECT $columns FROM $table_name WHERE `map_id` = %d AND `approved` = 1",intval($mapid)) );
2233
  }
 
2234
  $m_array = array();
2235
  $cnt = 0;
2236
  foreach ( $results as $result ) {
@@ -2522,6 +2529,7 @@ function wpgmaps_update_all_xml_file() {
2522
  */
2523
  function wpgmaps_action_callback_basic() {
2524
  global $wpdb;
 
2525
  global $wpgmza_tblname;
2526
  global $wpgmza_p;
2527
  global $wpgmza_tblname_poly;
@@ -2538,7 +2546,7 @@ function wpgmaps_action_callback_basic() {
2538
  'address' => '%s',
2539
  'lat' => '%f',
2540
  'lng' => '%f',
2541
- 'latlng' => 'ST_GeomFromText(%s)',
2542
  'infoopen' => '%d',
2543
  'description' => '%s',
2544
  'title' => '%s',
@@ -2592,7 +2600,7 @@ function wpgmaps_action_callback_basic() {
2592
  address = %s,
2593
  lat = %f,
2594
  lng = %f,
2595
- latlng = ST_GeomFromText(%s),
2596
  anim = %d,
2597
  infoopen = %d
2598
  WHERE
@@ -3168,6 +3176,7 @@ function wpgmza_settings_page_post()
3168
  */
3169
  function wpgmaps_head() {
3170
 
 
3171
  global $wpgmza_tblname_maps;
3172
  global $wpgmza_version;
3173
 
@@ -3329,7 +3338,7 @@ function wpgmaps_head() {
3329
  "UPDATE $wpgmza_tblname SET
3330
  lat = %s,
3331
  lng = %s,
3332
- latlng = ST_GeomFromText('POINT(%f %f)')
3333
  WHERE id = %d",
3334
 
3335
  $wpgmaps_marker_lat,
@@ -3563,7 +3572,7 @@ function wpgmaps_head() {
3563
  {
3564
  $stmt = $wpdb->prepare("
3565
  UPDATE $wpgmza_tblname_circles SET
3566
- center = ST_GeomFromText(%s),
3567
  name = %s,
3568
  color = %s,
3569
  opacity = %f,
@@ -3584,7 +3593,7 @@ function wpgmaps_head() {
3584
  INSERT INTO $wpgmza_tblname_circles
3585
  (center, map_id, name, color, opacity, radius)
3586
  VALUES
3587
- (ST_GeomFromText(%s), %d, %s, %s, %f, %f)
3588
  ", array(
3589
  "POINT($center)",
3590
  $_POST['wpgmaps_map_id'],
@@ -3630,8 +3639,8 @@ function wpgmaps_head() {
3630
  name = %s,
3631
  color = %s,
3632
  opacity = %f,
3633
- cornerA = ST_GeomFromText(%s),
3634
- cornerB = ST_GeomFromText(%s)
3635
  WHERE id = %d
3636
  ", array(
3637
  $_POST['rectangle_name'],
@@ -3648,7 +3657,7 @@ function wpgmaps_head() {
3648
  INSERT INTO $wpgmza_tblname_rectangles
3649
  (map_id, name, color, opacity, cornerA, cornerB)
3650
  VALUES
3651
- (%d, %s, %s, %f, ST_GeomFromText(%s), ST_GeomFromText(%s))
3652
  ", array(
3653
  $_POST['wpgmaps_map_id'],
3654
  $_POST['rectangle_name'],
@@ -3887,7 +3896,7 @@ function wpgmaps_head_old() {
3887
  "UPDATE $wpgmza_tblname SET
3888
  lat = %s,
3889
  lng = %s,
3890
- latlng = ST_GeomFromText('POINT(%f %f)')
3891
  WHERE id = %d",
3892
 
3893
  $wpgmaps_marker_lat,
@@ -6413,6 +6422,7 @@ if(!function_exists('wpgmza_get_marker_columns'))
6413
  function wpgmza_get_marker_columns()
6414
  {
6415
  global $wpdb;
 
6416
  global $wpgmza_tblname;
6417
  global $wpgmza_pro_version;
6418
 
@@ -6433,8 +6443,8 @@ if(!function_exists('wpgmza_get_marker_columns'))
6433
 
6434
  if($useSpatialData)
6435
  {
6436
- $columns[] = 'ST_X(latlng) AS lat';
6437
- $columns[] = 'ST_Y(latlng) AS lng';
6438
  }
6439
 
6440
  return $columns;
@@ -8071,6 +8081,7 @@ function wpgmza_b_add_circle($mid)
8071
 
8072
  function wpgmza_b_edit_circle($mid)
8073
  {
 
8074
  global $wpgmza_tblname_maps;
8075
  global $wpgmza_tblname_circles;
8076
  global $wpdb;
@@ -8083,7 +8094,7 @@ function wpgmza_b_edit_circle($mid)
8083
  $res = wpgmza_get_map_data($mid);
8084
  $circle_id = (int)$_GET['circle_id'];
8085
 
8086
- $results = $wpdb->get_results("SELECT *, ST_AsText(center) AS center FROM $wpgmza_tblname_circles WHERE id = $circle_id");
8087
 
8088
  if(empty($results))
8089
  {
@@ -8416,6 +8427,7 @@ function wpgmza_b_add_rectangle($mid)
8416
 
8417
  function wpgmza_b_edit_rectangle($mid)
8418
  {
 
8419
  global $wpgmza_tblname_maps;
8420
  global $wpgmza_tblname_rectangles;
8421
  global $wpdb;
@@ -8426,7 +8438,7 @@ function wpgmza_b_edit_rectangle($mid)
8426
  $res = wpgmza_get_map_data($mid);
8427
  $rectangle_id = (int)$_GET['rectangle_id'];
8428
 
8429
- $results = $wpdb->get_results("SELECT *, ST_AsText(cornerA) AS cornerA, ST_AsText(cornerB) AS cornerB FROM $wpgmza_tblname_rectangles WHERE id = $rectangle_id");
8430
 
8431
  if(empty($results))
8432
  {
@@ -8525,10 +8537,11 @@ if(!function_exists('wpgmza_get_circle_data'))
8525
  {
8526
  function wpgmza_get_circle_data($map_id)
8527
  {
 
8528
  global $wpdb;
8529
  global $wpgmza_tblname_circles;
8530
 
8531
- $stmt = $wpdb->prepare("SELECT *, ST_AsText(center) AS center FROM $wpgmza_tblname_circles WHERE map_id=%d", array($map_id));
8532
  $results = $wpdb->get_results($stmt);
8533
 
8534
  $circles = array();
@@ -8543,10 +8556,11 @@ if(!function_exists('wpgmza_get_rectangle_data'))
8543
  {
8544
  function wpgmza_get_rectangle_data($map_id)
8545
  {
 
8546
  global $wpdb;
8547
  global $wpgmza_tblname_rectangles;
8548
 
8549
- $stmt = $wpdb->prepare("SELECT *, ST_AsText(cornerA) AS cornerA, ST_AsText(cornerB) AS cornerB FROM $wpgmza_tblname_rectangles WHERE map_id=%d", array($map_id));
8550
  $results = $wpdb->get_results($stmt);
8551
 
8552
  $rectangles = array();
3
  Plugin Name: WP Google Maps
4
  Plugin URI: https://www.wpgmaps.com
5
  Description: The easiest to use Google Maps plugin! Create custom Google Maps with high quality markers containing locations, descriptions, images and links. Add your customized map to your WordPress posts and/or pages quickly and easily with the supplied shortcode. No fuss.
6
+ Version: 7.10.21
7
  Author: WP Google Maps
8
  Author URI: https://www.wpgmaps.com
9
  Text Domain: wp-google-maps
11
  */
12
 
13
  /*
14
+ * 7.10.21 :- 2018-07-09 :- Medium priority
15
+ * Added MySQL version check and dropped ST_ function prefixes for versions < 8.0
16
+ * Fixed markers not appearing front end and back end marker table empty for servers running old MySQL versions
17
+ *
18
  * 7.10.20 :- 2018-07-05 :- Low priority
19
  * Added hook for new GDPR tab content
20
  * Added JavaScript for VGM GDPR controls
607
  function wpgmaps_activate() {
608
  global $wpdb;
609
  global $wpgmza_version;
610
+ global $wpgmza;
611
+
612
  $table_name = $wpdb->prefix . "wpgmza";
613
  $table_name_maps = $wpdb->prefix . "wpgmza_maps";
614
 
706
 
707
  VALUES
708
 
709
+ (%d, %s, %s, %s, {$wpgmza->spatialFunctionPrefix}GeomFromText(%s), %s, %s, %s, %d, %s, %s, %s, %s, %d)", array(
710
 
711
  1,
712
  'California',
2237
  } else {
2238
  $results = $wpdb->get_results($wpdb->prepare("SELECT $columns FROM $table_name WHERE `map_id` = %d AND `approved` = 1",intval($mapid)) );
2239
  }
2240
+
2241
  $m_array = array();
2242
  $cnt = 0;
2243
  foreach ( $results as $result ) {
2529
  */
2530
  function wpgmaps_action_callback_basic() {
2531
  global $wpdb;
2532
+ global $wpgmza;
2533
  global $wpgmza_tblname;
2534
  global $wpgmza_p;
2535
  global $wpgmza_tblname_poly;
2546
  'address' => '%s',
2547
  'lat' => '%f',
2548
  'lng' => '%f',
2549
+ 'latlng' => "{$wpgmza->spatialFunctionPrefix}GeomFromText(%s)",
2550
  'infoopen' => '%d',
2551
  'description' => '%s',
2552
  'title' => '%s',
2600
  address = %s,
2601
  lat = %f,
2602
  lng = %f,
2603
+ latlng = {$wpgmza->spatialFunctionPrefix}GeomFromText(%s),
2604
  anim = %d,
2605
  infoopen = %d
2606
  WHERE
3176
  */
3177
  function wpgmaps_head() {
3178
 
3179
+ global $wpgmza;
3180
  global $wpgmza_tblname_maps;
3181
  global $wpgmza_version;
3182
 
3338
  "UPDATE $wpgmza_tblname SET
3339
  lat = %s,
3340
  lng = %s,
3341
+ latlng = {$wpgmza->spatialFunctionPrefix}GeomFromText('POINT(%f %f)')
3342
  WHERE id = %d",
3343
 
3344
  $wpgmaps_marker_lat,
3572
  {
3573
  $stmt = $wpdb->prepare("
3574
  UPDATE $wpgmza_tblname_circles SET
3575
+ center = {$wpgmza->spatialFunctionPrefix}GeomFromText(%s),
3576
  name = %s,
3577
  color = %s,
3578
  opacity = %f,
3593
  INSERT INTO $wpgmza_tblname_circles
3594
  (center, map_id, name, color, opacity, radius)
3595
  VALUES
3596
+ ({$wpgmza->spatialFunctionPrefix}GeomFromText(%s), %d, %s, %s, %f, %f)
3597
  ", array(
3598
  "POINT($center)",
3599
  $_POST['wpgmaps_map_id'],
3639
  name = %s,
3640
  color = %s,
3641
  opacity = %f,
3642
+ cornerA = {$wpgmza->spatialFunctionPrefix}GeomFromText(%s),
3643
+ cornerB = {$wpgmza->spatialFunctionPrefix}GeomFromText(%s)
3644
  WHERE id = %d
3645
  ", array(
3646
  $_POST['rectangle_name'],
3657
  INSERT INTO $wpgmza_tblname_rectangles
3658
  (map_id, name, color, opacity, cornerA, cornerB)
3659
  VALUES
3660
+ (%d, %s, %s, %f, {$wpgmza->spatialFunctionPrefix}GeomFromText(%s), {$wpgmza->spatialFunctionPrefix}GeomFromText(%s))
3661
  ", array(
3662
  $_POST['wpgmaps_map_id'],
3663
  $_POST['rectangle_name'],
3896
  "UPDATE $wpgmza_tblname SET
3897
  lat = %s,
3898
  lng = %s,
3899
+ latlng = {$wpgmza->spatialFunctionPrefix}GeomFromText('POINT(%f %f)')
3900
  WHERE id = %d",
3901
 
3902
  $wpgmaps_marker_lat,
6422
  function wpgmza_get_marker_columns()
6423
  {
6424
  global $wpdb;
6425
+ global $wpgmza;
6426
  global $wpgmza_tblname;
6427
  global $wpgmza_pro_version;
6428
 
6443
 
6444
  if($useSpatialData)
6445
  {
6446
+ $columns[] = "{$wpgmza->spatialFunctionPrefix}X(latlng) AS lat";
6447
+ $columns[] = "{$wpgmza->spatialFunctionPrefix}Y(latlng) AS lng";
6448
  }
6449
 
6450
  return $columns;
8081
 
8082
  function wpgmza_b_edit_circle($mid)
8083
  {
8084
+ global $wpgmza;
8085
  global $wpgmza_tblname_maps;
8086
  global $wpgmza_tblname_circles;
8087
  global $wpdb;
8094
  $res = wpgmza_get_map_data($mid);
8095
  $circle_id = (int)$_GET['circle_id'];
8096
 
8097
+ $results = $wpdb->get_results("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(center) AS center FROM $wpgmza_tblname_circles WHERE id = $circle_id");
8098
 
8099
  if(empty($results))
8100
  {
8427
 
8428
  function wpgmza_b_edit_rectangle($mid)
8429
  {
8430
+ global $wpgmza;
8431
  global $wpgmza_tblname_maps;
8432
  global $wpgmza_tblname_rectangles;
8433
  global $wpdb;
8438
  $res = wpgmza_get_map_data($mid);
8439
  $rectangle_id = (int)$_GET['rectangle_id'];
8440
 
8441
+ $results = $wpdb->get_results("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(cornerA) AS cornerA, {$wpgmza->spatialFunctionPrefix}AsText(cornerB) AS cornerB FROM $wpgmza_tblname_rectangles WHERE id = $rectangle_id");
8442
 
8443
  if(empty($results))
8444
  {
8537
  {
8538
  function wpgmza_get_circle_data($map_id)
8539
  {
8540
+ global $wpgmza;
8541
  global $wpdb;
8542
  global $wpgmza_tblname_circles;
8543
 
8544
+ $stmt = $wpdb->prepare("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(center) AS center FROM $wpgmza_tblname_circles WHERE map_id=%d", array($map_id));
8545
  $results = $wpdb->get_results($stmt);
8546
 
8547
  $circles = array();
8556
  {
8557
  function wpgmza_get_rectangle_data($map_id)
8558
  {
8559
+ global $wpgmza;
8560
  global $wpdb;
8561
  global $wpgmza_tblname_rectangles;
8562
 
8563
+ $stmt = $wpdb->prepare("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(cornerA) AS cornerA, {$wpgmza->spatialFunctionPrefix}AsText(cornerB) AS cornerB FROM $wpgmza_tblname_rectangles WHERE map_id=%d", array($map_id));
8564
  $results = $wpdb->get_results($stmt);
8565
 
8566
  $rectangles = array();