WP Google Maps - Version 8.0.20

Version Description

  • Re-factored store locator into new class
  • Removed hard coded zoom level when editing marker
  • Improved OpenLayers gesture handling UX to prevent browser zooming when Ctrl is pressed over map viewport when the gesture notice is visible
  • WPGMZA.Distance.between now accepts latlng literals
  • Updated bundled OpenLayers library to 6.2.1
  • Fixed old marker not removed after editing location
  • Fixed OpenLayers longitude not wrapping properly causing markers to disappear when moving outside -180 to +180
  • Fixed UI style setting not changing
Download this release

Release Info

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

Code changes from version 8.0.19 to 8.0.20

base/includes/wp-google-maps-polygons.php CHANGED
@@ -6,12 +6,6 @@ Polygon functionality for WP Google Maps
6
  if(!defined('ABSPATH'))
7
  exit;
8
 
9
- add_action('wp_enqueue_scripts', function() {
10
-
11
- wpgmza_enqueue_fontawesome();
12
-
13
- });
14
-
15
  /**
16
  * Render polygon editor HTML
17
  * @param integer $mid Map ID
6
  if(!defined('ABSPATH'))
7
  exit;
8
 
 
 
 
 
 
 
9
  /**
10
  * Render polygon editor HTML
11
  * @param integer $mid Map ID
constants.php CHANGED
@@ -5,6 +5,9 @@ if(!defined('ABSPATH'))
5
 
6
  global $wpdb;
7
 
 
 
 
8
  global $WPGMZA_TABLE_NAME_MARKERS;
9
  global $WPGMZA_TABLE_NAME_MAPS;
10
  global $WPGMZA_TABLE_NAME_POLYGONS;
@@ -18,5 +21,3 @@ $WPGMZA_TABLE_NAME_POLYGONS = $wpdb->prefix . 'wpgmza_polygon';
18
  $WPGMZA_TABLE_NAME_POLYLINES = $wpdb->prefix . 'wpgmza_polylines';
19
  $WPGMZA_TABLE_NAME_CIRCLES = $wpdb->prefix . 'wpgmza_circles';
20
  $WPGMZA_TABLE_NAME_RECTANGLES = $wpdb->prefix . 'wpgmza_rectangles';
21
-
22
- define('WPGMZA_PLUGIN_DIR_URL', plugin_dir_url(__FILE__));
5
 
6
  global $wpdb;
7
 
8
+ define('WPGMZA_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__));
9
+ define('WPGMZA_PLUGIN_DIR_URL', plugin_dir_url(__FILE__));
10
+
11
  global $WPGMZA_TABLE_NAME_MARKERS;
12
  global $WPGMZA_TABLE_NAME_MAPS;
13
  global $WPGMZA_TABLE_NAME_POLYGONS;
21
  $WPGMZA_TABLE_NAME_POLYLINES = $wpdb->prefix . 'wpgmza_polylines';
22
  $WPGMZA_TABLE_NAME_CIRCLES = $wpdb->prefix . 'wpgmza_circles';
23
  $WPGMZA_TABLE_NAME_RECTANGLES = $wpdb->prefix . 'wpgmza_rectangles';
 
 
css/common.css CHANGED
@@ -501,11 +501,6 @@ form.wpgmza-form .wpgmza-fancy-toggle-button + label
501
  padding: 1em 1em;
502
  }
503
 
504
- input.wpgmza-address
505
- {
506
- width: 320px;
507
- }
508
-
509
  .wpgmza-upgrade-tab, .wpgmza-upgrade-tab a,
510
  .update-att,
511
  .update-att a
@@ -556,4 +551,5 @@ input[name='wpgmza_developer_mode']:checked + .notice-warning
556
  z-index: 999;
557
  text-align: center;
558
  line-height: 400px;
 
559
  }
501
  padding: 1em 1em;
502
  }
503
 
 
 
 
 
 
504
  .wpgmza-upgrade-tab, .wpgmza-upgrade-tab a,
505
  .update-att,
506
  .update-att a
551
  z-index: 999;
552
  text-align: center;
553
  line-height: 400px;
554
+ pointer-events: none;
555
  }
css/styles/default.css CHANGED
@@ -1,5 +1,4 @@
1
- .wpgmza-store-locator > div > *,
2
- .wpgmza-directions-box-inner > div > *
3
  {
4
  display: inline-block;
5
  /* vertical-align: top; */
@@ -11,11 +10,11 @@
11
  width: 180px;
12
  }
13
 
14
- .wpgmza-store-locator input[type="button"],
15
  .wpgmza-not-found-msg,
16
  div.wpgmza-waypoint-via,
17
  .wpgmza-add-waypoint,
18
- input.wpgmza-get-directions
19
  {
20
  margin-left: 180px;
21
  }
@@ -23,5 +22,6 @@
23
  input.wpgmza-directions-from,
24
  input.wpgmza-directions-to
25
  {
26
- width: calc(80% - 180px);
 
27
  }
1
+ .wpgmza-store-locator > div > *
 
2
  {
3
  display: inline-block;
4
  /* vertical-align: top; */
10
  width: 180px;
11
  }
12
 
13
+ .wpgmza-store-locator input[type="button"]/*,
14
  .wpgmza-not-found-msg,
15
  div.wpgmza-waypoint-via,
16
  .wpgmza-add-waypoint,
17
+ input.wpgmza-get-directions*/
18
  {
19
  margin-left: 180px;
20
  }
22
  input.wpgmza-directions-from,
23
  input.wpgmza-directions-to
24
  {
25
+ display: inline-block;
26
+ width: calc(100% - 72px);
27
  }
html/settings-page.html.php CHANGED
@@ -366,7 +366,7 @@
366
  </div>
367
 
368
  <div id="marker-listing">
369
- <div class="update-nag update-att">
370
  <i class="fa fa-arrow-circle-right"></i>
371
  <a target="_blank"
372
  href="<?php
366
  </div>
367
 
368
  <div id="marker-listing">
369
+ <div class="update-nag update-att wpgmza-upsell">
370
  <i class="fa fa-arrow-circle-right"></i>
371
  <a target="_blank"
372
  href="<?php
html/store-locator.html.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wpgmza-store-locator">
2
+ <div class="wpgmza-address-container">
3
+ <label
4
+ class="wpgmza-address"
5
+ data-name="addressLabel"></label>
6
+ <input
7
+ class="wpgmza-address"
8
+ type="text"
9
+ placeholder="<?php esc_attr_e('Enter a location', 'wp-google-maps'); ?>"
10
+ autocomplete="off"
11
+ data-name="defaultAddress"
12
+ />
13
+ </div>
14
+
15
+ <div class="wpgmza-radius-container">
16
+ <label class="wpgmza-radius">
17
+ <?php _e('Radius:', 'wp-google-maps'); ?>
18
+ </label>
19
+ <select class="wpgmza-radius"></select>
20
+ </div>
21
+
22
+ <input
23
+ class="wpgmza-search"
24
+ value="<?php esc_attr_e('Search', 'wp-google-maps'); ?>"
25
+ type="button"/>
26
+
27
+ <div class="wpgmza-no-results" style="display: none;">
28
+ <p data-name="notFoundMessage"></p>
29
+ </div>
30
+ </div>
includes/class.crud.php CHANGED
@@ -35,6 +35,9 @@ class Crud extends Factory implements \IteratorAggregate, \JsonSerializable
35
  {
36
  global $wpdb;
37
 
 
 
 
38
  $this->fields = array();
39
  $this->overrides = array();
40
 
@@ -71,12 +74,8 @@ class Crud extends Factory implements \IteratorAggregate, \JsonSerializable
71
  else
72
  throw new \Exception('Invalid ID');
73
 
74
- $this->table_name = $table_name;
75
-
76
  $this->id = $id;
77
 
78
- Crud::cacheColumnsByTableName($table_name);
79
-
80
  if($read_mode != Crud::BULK_READ)
81
  {
82
  if($this->id == -1)
@@ -91,6 +90,13 @@ class Crud extends Factory implements \IteratorAggregate, \JsonSerializable
91
  if(!empty($arbitraryDataColumnName) && !empty($this->fields[$arbitraryDataColumnName]))
92
  $this->parse_arbitrary_data($this->fields[$arbitraryDataColumnName]);
93
  }
 
 
 
 
 
 
 
94
  }
95
 
96
  private static function cacheColumnsByTableName($table_name)
@@ -508,6 +514,33 @@ class Crud extends Factory implements \IteratorAggregate, \JsonSerializable
508
  $this->trashed = true;
509
  }
510
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  /**
512
  * Set variables in bulk, this reduces the number of database calls
513
  * @param string|array|object Either a string naming the property to be set (with a second argument which is the value), or an array or object of key and value pairs to be set on this object
35
  {
36
  global $wpdb;
37
 
38
+ $this->table_name = $table_name;
39
+ Crud::cacheColumnsByTableName($table_name);
40
+
41
  $this->fields = array();
42
  $this->overrides = array();
43
 
74
  else
75
  throw new \Exception('Invalid ID');
76
 
 
 
77
  $this->id = $id;
78
 
 
 
79
  if($read_mode != Crud::BULK_READ)
80
  {
81
  if($this->id == -1)
90
  if(!empty($arbitraryDataColumnName) && !empty($this->fields[$arbitraryDataColumnName]))
91
  $this->parse_arbitrary_data($this->fields[$arbitraryDataColumnName]);
92
  }
93
+
94
+ $this->onCrudInitialized();
95
+ }
96
+
97
+ protected function onCrudInitialized()
98
+ {
99
+
100
  }
101
 
102
  private static function cacheColumnsByTableName($table_name)
514
  $this->trashed = true;
515
  }
516
 
517
+ public function duplicate()
518
+ {
519
+ global $wpdb;
520
+
521
+ $columns = array();
522
+
523
+ foreach($wpdb->get_col("SHOW COLUMNS FROM `{$this->table_name}`") as $name)
524
+ {
525
+ if($name == 'id')
526
+ continue;
527
+
528
+ $columns []= $name;
529
+ }
530
+
531
+ $imploded = implode(',', $columns);
532
+
533
+ $query = "INSERT INTO {$this->table_name} ($imploded) SELECT $imploded FROM {$this->table_name} WHERE id=%d";
534
+
535
+ $stmt = $wpdb->prepare($query, $this->id);
536
+
537
+ $wpdb->query($stmt);
538
+
539
+ $class = get_class($this);
540
+
541
+ return $class::createInstance($wpdb->insert_id);
542
+ }
543
+
544
  /**
545
  * Set variables in bulk, this reduces the number of database calls
546
  * @param string|array|object Either a string naming the property to be set (with a second argument which is the value), or an array or object of key and value pairs to be set on this object
includes/class.database.php CHANGED
@@ -130,10 +130,15 @@ class Database extends Factory
130
  sticky tinyint(1) DEFAULT '0',
131
  other_data LONGTEXT NOT NULL,
132
  latlng POINT,
 
133
  PRIMARY KEY (id)
134
  ) AUTO_INCREMENT=1 " . Database::getCharsetAndCollate();
135
 
136
  dbDelta($sql);
 
 
 
 
137
  }
138
 
139
  protected function installPolygonTable()
130
  sticky tinyint(1) DEFAULT '0',
131
  other_data LONGTEXT NOT NULL,
132
  latlng POINT,
133
+ lnglat POINT NOT NULL,
134
  PRIMARY KEY (id)
135
  ) AUTO_INCREMENT=1 " . Database::getCharsetAndCollate();
136
 
137
  dbDelta($sql);
138
+
139
+ // TODO: Create marker first
140
+
141
+ // $wpdb->query("ALTER TABLE `$WPGMZA_TABLE_NAME_MARKERS` ADD SPATIAL INDEX(lnglat)");
142
  }
143
 
144
  protected function installPolygonTable()
includes/class.dom-document.php CHANGED
@@ -73,6 +73,68 @@ class DOMDocument extends \DOMDocument
73
  return $result;
74
  }
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  /**
77
  * Loads the specified file and parses any PHP
78
  * @param string $src The file you want to load
73
  return $result;
74
  }
75
 
76
+ private function translateLineNumber($htmlLineNumber, $src)
77
+ {
78
+
79
+ }
80
+
81
+ public function onError($severity, $message, $file, $unused)
82
+ {
83
+ if(!preg_match('/DOMDocument::loadHTML.+line: (\d+)/', $message, $m))
84
+ {
85
+ trigger_error($message, E_USER_WARNING);
86
+ return;
87
+ }
88
+
89
+ $htmlLineNumber = $m[1];
90
+ $lines = file($this->src_file);
91
+
92
+ $totalPhpLines = count($lines);
93
+ $lineCounter = 1;
94
+
95
+ $allowShortTags = ini_get('short_open_tag') == "1";
96
+ $regexOpenTag = ($allowShortTags ? '/<\?(php)?/' : '/<\?php/');
97
+ $regexCloseTag = "/\?>/";
98
+
99
+ $inPhp = false;
100
+
101
+ for($phpLineNumber = 1; $phpLineNumber <= $totalPhpLines; $phpLineNumber++)
102
+ {
103
+ if($lineCounter == $htmlLineNumber)
104
+ {
105
+ $message = preg_replace(
106
+ array('/loadHTML/', '/line: \d+/'),
107
+ array('loadPHPFile', "line: $phpLineNumber"),
108
+ $message
109
+ );
110
+ trigger_error($message, E_USER_WARNING);
111
+
112
+ return;
113
+ }
114
+
115
+ $line = $lines[$phpLineNumber - 1];
116
+
117
+ $numOpenTags = preg_match_all($regexOpenTag, $line);
118
+ $numCloseTags = preg_match_all($regexCloseTag, $line);
119
+
120
+ if($numOpenTags > $numCloseTags)
121
+ {
122
+ $inPhp = true;
123
+ }
124
+ else if($numCloseTags > 0)
125
+ {
126
+ $inPhp = false;
127
+ $lineCounter--; // NB: I don't understand why a close tag swallows the newline, but it does appear to
128
+ }
129
+
130
+ if(!$inPhp)
131
+ $lineCounter++;
132
+ }
133
+
134
+ trigger_error("Failed to translate line number", E_USER_WARNING);
135
+ trigger_error($message, E_USER_WARNING);
136
+ }
137
+
138
  /**
139
  * Loads the specified file and parses any PHP
140
  * @param string $src The file you want to load
includes/class.dom-element.php CHANGED
@@ -38,8 +38,10 @@ class DOMElement extends \DOMElement
38
  public function querySelector($query)
39
  {
40
  $results = $this->querySelectorAll($query);
 
41
  if(empty($results))
42
  return null;
 
43
  return $results[0];
44
  }
45
 
@@ -66,7 +68,7 @@ class DOMElement extends \DOMElement
66
  if($sort)
67
  usort($results, array('WPGMZA\DOMElement', 'sortByDOMPosition'));
68
 
69
- return $results;
70
  }
71
 
72
  /**
@@ -124,6 +126,16 @@ class DOMElement extends \DOMElement
124
  return null;
125
  }
126
 
 
 
 
 
 
 
 
 
 
 
127
  /**
128
  * Test if this element comes before the other element in the DOM tree
129
  * @return boolean TRUE if this element comes before the other, FALSE if not
@@ -293,14 +305,21 @@ class DOMElement extends \DOMElement
293
 
294
  if($body = $node->querySelector("body"))
295
  {
296
- // TODO: I don't think a query selector is necessary here. Iterating over the bodies children should be more optimal.
297
- foreach($node->querySelectorAll("body>*") as $child)
 
 
298
  $this->appendChild($child);
 
 
299
  }
300
  else
 
301
  $this->appendChild($node);
 
 
302
 
303
- return $this;
304
  }
305
 
306
  /**
@@ -530,6 +549,9 @@ class DOMElement extends \DOMElement
530
  if(!$name)
531
  continue;
532
 
 
 
 
533
  switch($input->getAttribute('type'))
534
  {
535
  case 'checkbox':
@@ -716,4 +738,3 @@ class DOMElement extends \DOMElement
716
  }
717
  }
718
 
719
- ?>
38
  public function querySelector($query)
39
  {
40
  $results = $this->querySelectorAll($query);
41
+
42
  if(empty($results))
43
  return null;
44
+
45
  return $results[0];
46
  }
47
 
68
  if($sort)
69
  usort($results, array('WPGMZA\DOMElement', 'sortByDOMPosition'));
70
 
71
+ return new DOMQueryResults($results);
72
  }
73
 
74
  /**
126
  return null;
127
  }
128
 
129
+ /**
130
+ * Wraps this element in the element passed in, then replaces this nodes original position
131
+ * @param DOMElement The element to wrap this element in
132
+ */
133
+ public function wrap($wrapper)
134
+ {
135
+ $this->parentNode->replaceChild($wrapper, $this);
136
+ $wrapper->appendChild($this);
137
+ }
138
+
139
  /**
140
  * Test if this element comes before the other element in the DOM tree
141
  * @return boolean TRUE if this element comes before the other, FALSE if not
305
 
306
  if($body = $node->querySelector("body"))
307
  {
308
+ // TODO: I don't think a query selector is necessary here. Iterating over the bodies children should be more optimal
309
+ $results = $node->querySelectorAll("body>*");
310
+
311
+ foreach($results as $child)
312
  $this->appendChild($child);
313
+
314
+ return $results;
315
  }
316
  else
317
+ {
318
  $this->appendChild($node);
319
+ return $node;
320
+ }
321
 
322
+ return null;
323
  }
324
 
325
  /**
549
  if(!$name)
550
  continue;
551
 
552
+ if(preg_match('/nonce/i', $name))
553
+ continue; // NB: Do not serialize nonce values
554
+
555
  switch($input->getAttribute('type'))
556
  {
557
  case 'checkbox':
738
  }
739
  }
740
 
 
includes/class.dom-query-results.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGMZA;
4
+
5
+ class DOMQueryResults implements \ArrayAccess, \Countable, \Iterator
6
+ {
7
+ private $index = 0;
8
+ private $container;
9
+
10
+ public function __construct(array $arr = null)
11
+ {
12
+ if(!empty($arr))
13
+ $this->container = $arr;
14
+ else
15
+ $this->container = array();
16
+ }
17
+
18
+ public function __call($name, $arguments)
19
+ {
20
+ foreach($this->container as $element)
21
+ {
22
+ if(!method_exists($element, $name))
23
+ throw new \Exception("No such method '$name' on " . get_class($element));
24
+
25
+ call_user_func_array(
26
+ array($element, $name),
27
+ $arguments
28
+ );
29
+ }
30
+
31
+ return $this;
32
+ }
33
+
34
+ public function offsetExists($offset)
35
+ {
36
+ return isset($this->container[$offset]);
37
+ }
38
+
39
+ public function offsetGet($offset)
40
+ {
41
+ return isset($this->container[$offset]) ? $this->container[$offset] : null;
42
+ }
43
+
44
+ public function offsetSet($offset, $value)
45
+ {
46
+ if(!($value instanceof DOMElement))
47
+ throw new \Exception("Only DOMElement is permitted in query results");
48
+
49
+ if(is_null($offset))
50
+ $this->container[] = $value;
51
+ else
52
+ $this->container[$offset] = $value;
53
+ }
54
+
55
+ public function offsetUnset($offset)
56
+ {
57
+ unset($this->container[$offset]);
58
+ }
59
+
60
+ public function count()
61
+ {
62
+ return count($this->container);
63
+ }
64
+
65
+ public function current()
66
+ {
67
+ return $this->container[$this->index];
68
+ }
69
+
70
+ public function next()
71
+ {
72
+ $this->index++;
73
+ }
74
+
75
+ public function key()
76
+ {
77
+ return $this->index;
78
+ }
79
+
80
+ public function valid()
81
+ {
82
+ return isset($this->container[$this->key()]);
83
+ }
84
+
85
+ public function rewind()
86
+ {
87
+ $this->index = 0;
88
+ }
89
+
90
+ public function reverse()
91
+ {
92
+ $this->container = array_reverse($this->container);
93
+ $this->rewind();
94
+ }
95
+ }
includes/class.elias-fano.php CHANGED
@@ -121,3 +121,4 @@ class EliasFano
121
  return $list;
122
  }
123
  }
 
121
  return $list;
122
  }
123
  }
124
+
includes/class.factory.php CHANGED
@@ -44,6 +44,10 @@ class Factory
44
 
45
  $override = call_user_func_array('apply_filters', $filter_args);
46
 
 
 
 
 
47
  if($override instanceof \WPGMZA\Factory)
48
  return $override;
49
 
44
 
45
  $override = call_user_func_array('apply_filters', $filter_args);
46
 
47
+ // NB: This stops override being the same as the first argument, which is needed for example when passing a Map as the first argument of StoreLocator
48
+ if(count($args) && $args[0] === $override)
49
+ $override = null;
50
+
51
  if($override instanceof \WPGMZA\Factory)
52
  return $override;
53
 
includes/class.google-maps-api-loader.php CHANGED
@@ -129,13 +129,17 @@ class GoogleMapsAPILoader
129
  // API Key
130
  $key = get_option('wpgmza_google_maps_api_key');
131
 
132
- if($key)
133
  $params['key'] = $key;
134
  else if(is_admin())
135
  $params['key'] = get_option('wpgmza_temp_api');
136
 
137
  // Libraries
138
  $libraries = array('geometry', 'places', 'visualization');
 
 
 
 
139
  $params['libraries'] = implode(',', $libraries);
140
 
141
  $params = apply_filters( 'wpgmza_google_maps_api_params', $params );
129
  // API Key
130
  $key = get_option('wpgmza_google_maps_api_key');
131
 
132
+ if(!empty($key))
133
  $params['key'] = $key;
134
  else if(is_admin())
135
  $params['key'] = get_option('wpgmza_temp_api');
136
 
137
  // Libraries
138
  $libraries = array('geometry', 'places', 'visualization');
139
+
140
+ if($wpgmza->getCurrentPage() == Plugin::PAGE_MAP_EDIT)
141
+ $libraries[] = 'drawing';
142
+
143
  $params['libraries'] = implode(',', $libraries);
144
 
145
  $params = apply_filters( 'wpgmza_google_maps_api_params', $params );
includes/class.map.php CHANGED
@@ -18,6 +18,8 @@ class Map extends Crud
18
  protected $_overrides;
19
  protected $_element;
20
 
 
 
21
  /**
22
  * Constructor
23
  * @param int|array|object $id_or_fields The ID to read an existing map, or an object or array to create a new one.
@@ -25,6 +27,7 @@ class Map extends Crud
25
  public function __construct($id_or_fields=-1, $overrides=null)
26
  {
27
  global $wpdb;
 
28
 
29
  Crud::__construct("{$wpdb->prefix}wpgmza_maps", $id_or_fields);
30
 
@@ -38,6 +41,15 @@ class Map extends Crud
38
 
39
  $this->_element = $document->querySelector("div");
40
  $this->_element->setAttribute('data-settings', json_encode($this));
 
 
 
 
 
 
 
 
 
41
  }
42
 
43
  public function __get($name)
@@ -45,7 +57,8 @@ class Map extends Crud
45
  switch($name)
46
  {
47
  case 'overrides':
48
- return $this->_overrides;
 
49
  break;
50
 
51
  case "storeLocatorDistanceUnits":
18
  protected $_overrides;
19
  protected $_element;
20
 
21
+ protected $_storeLocator;
22
+
23
  /**
24
  * Constructor
25
  * @param int|array|object $id_or_fields The ID to read an existing map, or an object or array to create a new one.
27
  public function __construct($id_or_fields=-1, $overrides=null)
28
  {
29
  global $wpdb;
30
+ global $wpgmza;
31
 
32
  Crud::__construct("{$wpdb->prefix}wpgmza_maps", $id_or_fields);
33
 
41
 
42
  $this->_element = $document->querySelector("div");
43
  $this->_element->setAttribute('data-settings', json_encode($this));
44
+
45
+ if(!$wpgmza->isProVersion())
46
+ $this->onInit();
47
+ }
48
+
49
+ protected function onInit()
50
+ {
51
+ if($this->store_locator_enabled == 1)
52
+ $this->_storeLocator = StoreLocator::createInstance($this);
53
  }
54
 
55
  public function __get($name)
57
  switch($name)
58
  {
59
  case 'overrides':
60
+ case 'storeLocator':
61
+ return $this->{"_$name"};
62
  break;
63
 
64
  case "storeLocatorDistanceUnits":
includes/class.marker-filter.php CHANGED
@@ -134,6 +134,14 @@ class MarkerFilter extends Factory
134
  $query->params[] = $radius;
135
  }
136
 
 
 
 
 
 
 
 
 
137
  protected function applyLimit($query)
138
  {
139
  if(empty($this->_limit))
@@ -159,6 +167,7 @@ class MarkerFilter extends Factory
159
  $query->table = $WPGMZA_TABLE_NAME_MARKERS;
160
 
161
  $this->applyRadiusClause($query);
 
162
  $this->applyLimit($query);
163
 
164
  return $query;
@@ -199,7 +208,7 @@ class MarkerFilter extends Factory
199
  $markers[] = Marker::createInstance($data, Crud::BULK_READ);
200
  }
201
 
202
- return $markers;
203
  }
204
 
205
  public function getFilteredIDs()
134
  $query->params[] = $radius;
135
  }
136
 
137
+ protected function applyIDsClause($set)
138
+ {
139
+ if(empty($this->ids))
140
+ return;
141
+
142
+ $query->in('id', $set);
143
+ }
144
+
145
  protected function applyLimit($query)
146
  {
147
  if(empty($this->_limit))
167
  $query->table = $WPGMZA_TABLE_NAME_MARKERS;
168
 
169
  $this->applyRadiusClause($query);
170
+ $this->applyIDsClause($query);
171
  $this->applyLimit($query);
172
 
173
  return $query;
208
  $markers[] = Marker::createInstance($data, Crud::BULK_READ);
209
  }
210
 
211
+ return apply_filters('wpgmza_fetch_integrated_markers', $markers, $this);
212
  }
213
 
214
  public function getFilteredIDs()
includes/class.marker.php CHANGED
@@ -70,6 +70,7 @@ class Marker extends Crud implements \JsonSerializable
70
  $json = Crud::jsonSerialize();
71
 
72
  unset($json['latlng']);
 
73
 
74
  return $json;
75
  }
@@ -99,6 +100,9 @@ class Marker extends Crud implements \JsonSerializable
99
  if($name == 'latlng')
100
  return "POINT(" . floatval($this->lat) . " " . floatval($this->lng) . ")";
101
 
 
 
 
102
  return Crud::get_column_parameter($name);
103
  }
104
 
@@ -132,10 +136,16 @@ class Marker extends Crud implements \JsonSerializable
132
  $this->lat,
133
  $this->lng,
134
  $this->get_column_parameter('latlng'),
 
135
  $this->id
136
  );
137
 
138
- $stmt = $wpdb->prepare("UPDATE " . $this->get_table_name() . " SET lat=%s, lng=%s, latlng={$wpgmza->spatialFunctionPrefix}GeomFromText(%s) WHERE id=%d", $params);
 
 
 
 
 
139
 
140
  $wpdb->query($stmt);
141
  }
70
  $json = Crud::jsonSerialize();
71
 
72
  unset($json['latlng']);
73
+ unset($json['lnglat']);
74
 
75
  return $json;
76
  }
100
  if($name == 'latlng')
101
  return "POINT(" . floatval($this->lat) . " " . floatval($this->lng) . ")";
102
 
103
+ if($name == 'lnglat')
104
+ return "POINT(" . floatval($this->lat) . " " . floatval($this->lng) . ")";
105
+
106
  return Crud::get_column_parameter($name);
107
  }
108
 
136
  $this->lat,
137
  $this->lng,
138
  $this->get_column_parameter('latlng'),
139
+ $this->get_column_parameter('lnglat'),
140
  $this->id
141
  );
142
 
143
+ $stmt = $wpdb->prepare("UPDATE " . $this->get_table_name() . "
144
+ SET lat=%s,
145
+ lng=%s,
146
+ latlng={$wpgmza->spatialFunctionPrefix}GeomFromText(%s),
147
+ lnglat={$wpgmza->spatialFunctionPrefix}GeomFromText(%s)
148
+ WHERE id=%d", $params);
149
 
150
  $wpdb->query($stmt);
151
  }
includes/class.plugin.php CHANGED
@@ -260,6 +260,8 @@ class Plugin extends Factory
260
  'googleMapsAPIErrorDialog' => $googleMapsAPIErrorDialogHTML
261
  ),
262
 
 
 
263
  'resturl' => preg_replace('#/$#', '', get_rest_url(null, 'wpgmza/v1')),
264
  'restnonce' => wp_create_nonce('wp_rest'),
265
  'restnoncetable' => $this->restAPI->getNonceTable(),
260
  'googleMapsAPIErrorDialog' => $googleMapsAPIErrorDialogHTML
261
  ),
262
 
263
+ 'imageFolderURL' => plugin_dir_url(WPGMZA_FILE) . 'images/',
264
+
265
  'resturl' => preg_replace('#/$#', '', get_rest_url(null, 'wpgmza/v1')),
266
  'restnonce' => wp_create_nonce('wp_rest'),
267
  'restnoncetable' => $this->restAPI->getNonceTable(),
includes/class.store-locator.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WPGMZA;
4
+
5
+ class StoreLocator extends Factory implements \IteratorAggregate
6
+ {
7
+ private $_document;
8
+ private $_map;
9
+
10
+ public function __construct(Map $map)
11
+ {
12
+ global $wpgmza;
13
+
14
+ $this->_map = $map;
15
+
16
+ $this->_document = new DOMDocument();
17
+ $this->_document->loadPHPFile(plugin_dir_path(WPGMZA_FILE) . 'html/store-locator.html.php');
18
+
19
+ $this->_document->populate($this);
20
+
21
+ $this->populateRadiusSelect();
22
+
23
+ if($wpgmza->settings->useLegacyHTML)
24
+ {
25
+ $document = $this->_document;
26
+
27
+ $document
28
+ ->querySelectorAll(".wpgmza-store-locator")
29
+ ->addClass("wpgmza_sl_main_div");
30
+
31
+ $document
32
+ ->querySelectorAll(".wpgmza-address-container")
33
+ ->addClass("wpgmza-form-field wpgmza_sl_query_div wpgmza-clearfix");
34
+
35
+ $document
36
+ ->querySelectorAll("label.wpgmza-address")
37
+ ->setAttribute("for", "addressInput")
38
+ ->addClass("wpgmza-form-field__label wpgmza-form-field__label--float");
39
+
40
+ $document
41
+ ->querySelectorAll("input.wpgmza-address")
42
+ ->setAttribute("id", "addressInput")
43
+ ->setAttribute("size", 20);
44
+
45
+ $document
46
+ ->querySelectorAll(".wpgmza-radius-container")
47
+ ->addClass("wpgmza-form-field wpgmza_sl_radius_div wpgmza-clearfix");
48
+
49
+ $document
50
+ ->querySelectorAll("label.wpgmza-radius")
51
+ ->setAttribute("for", "radiusSelect")
52
+ ->addClass("wpgmza-form-field__label wpgmza-form-field__label--float");
53
+
54
+ $document
55
+ ->querySelectorAll("select.wpgmza-radius")
56
+ ->setAttribute("id", "radiusSelect")
57
+ ->addClass("wpgmza-form-field__input wpgmza_sl_radius_select");
58
+
59
+ $document
60
+ ->querySelectorAll("input.wpgmza-search")
61
+ ->addClass("wpgmza_sl_search_button")
62
+ ->setAttribute("onclick", "searchLocations({$this->map->id})");
63
+
64
+ $document
65
+ ->querySelectorAll("div.wpgmza-no-results")
66
+ ->addClass("wpgmza-not-found-msg js-not-found-msg");
67
+ }
68
+ }
69
+
70
+ public function __get($name)
71
+ {
72
+ if(isset($this->{"_$name"}))
73
+ return $this->{"_$name"};
74
+
75
+ switch($name)
76
+ {
77
+ case "addressLabel":
78
+ case "defaultAddress":
79
+ case "notFoundMessage":
80
+ case "defaultRadius":
81
+
82
+ $defaults = array(
83
+ "addressLabel" => __('ZIP / Address:', 'wp-google-maps'),
84
+ "defaultAddress" => '',
85
+ "notFoundMessage" => __('No results found in this location. Please try again.', 'wp-google-maps'),
86
+ "defaultRadius" => '10'
87
+ );
88
+
89
+ $snakeCase = strtolower( preg_replace('/(\b[a-z]+|\G(?!^))((?:[A-Z]|\d+)[a-z]*)/', '\1_\2', $name) );
90
+
91
+ if(!empty($this->map->{"store_locator_$snakeCase"}))
92
+ return $this->map->{"store_locator_$snakeCase"};
93
+
94
+ return $defaults[$name];
95
+ break;
96
+
97
+ case "html":
98
+ return $this->_document->html;
99
+ break;
100
+ }
101
+ }
102
+
103
+ public function getIterator()
104
+ {
105
+ $reflection = new \ReflectionObject($this);
106
+ $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
107
+
108
+ $arr = array();
109
+ foreach($properties as $prop)
110
+ $arr[$prop->name] = $this->{$prop->name};
111
+
112
+ $iterator = new \ArrayIterator(
113
+ array_merge(
114
+ $arr,
115
+ array(
116
+ 'addressLabel' => $this->addressLabel,
117
+ 'defaultAddress' => $this->defaultAddress,
118
+ 'notFoundMessage' => $this->notFoundMessage,
119
+ 'defaultRadius' => $this->defaultRadius
120
+ )
121
+ )
122
+ );
123
+
124
+ return $iterator;
125
+ }
126
+
127
+ protected function populateRadiusSelect()
128
+ {
129
+ global $wpgmza;
130
+
131
+ $document = $this->_document;
132
+ $radii = array(1, 5, 10, 25, 50, 75, 100, 150, 200, 300);
133
+ $suffix = __('km', 'wp-google-maps');
134
+ $select = $document->querySelector("select.wpgmza-radius");
135
+
136
+ if(!empty($wpgmza->settings->wpgmza_store_locator_radii))
137
+ $radii = preg_split('/\s*,\s*/', $wpgmza->settings->wpgmza_store_locator_radii);
138
+
139
+ if(!empty($this->map->store_locator_distance) && $this->map->store_locator_distance == 1)
140
+ $suffix = __('mi', 'wp-google-maps');
141
+
142
+ foreach($radii as $radius)
143
+ {
144
+ $option = $document->createElement('option');
145
+
146
+ $option->addClass("wpgmza-radius");
147
+ $option->setAttribute("value", $radius);
148
+
149
+ if($radius == $this->defaultRadius)
150
+ $option->setAttribute("selected", "selected");
151
+
152
+ if($wpgmza->settings->useLegacyHTML)
153
+ $option->addClass("wpgmza_sl_select_option");
154
+
155
+ $option->appendText($radius . $suffix);
156
+
157
+ $select->appendChild($option);
158
+ }
159
+ }
160
+ }
includes/class.strings.php CHANGED
@@ -83,7 +83,10 @@ class Strings
83
  'use_two_fingers' => __('Use two fingers to move the map', 'wp-google-maps'),
84
  'use_ctrl_scroll_to_zoom' => __('Use ctrl + scroll to zoom the map', 'wp-google-maps'),
85
  'geocode_was_not_successful' => __('Geocode was not successful for the following reason: ', 'wp-google-maps'),
86
- 'geocoding_library_notice' => __('Geocoding this address failed. Please check you have enabled the Geocoding API for your Google Maps API project.', 'wp-google-maps')
 
 
 
87
  ));
88
  }
89
 
83
  'use_two_fingers' => __('Use two fingers to move the map', 'wp-google-maps'),
84
  'use_ctrl_scroll_to_zoom' => __('Use ctrl + scroll to zoom the map', 'wp-google-maps'),
85
  'geocode_was_not_successful' => __('Geocode was not successful for the following reason: ', 'wp-google-maps'),
86
+ 'geocoding_library_notice' => __('Geocoding this address failed. Please check you have enabled the Geocoding API for your Google Maps API project.', 'wp-google-maps'),
87
+
88
+ 'map_delete_prompt_text' => __('Are you sure you want to delete this map?', 'wp-google-maps'),
89
+ 'map_bulk_delete_prompt_text' => __('Are you sure you want to delete these maps?', 'wp-google-maps')
90
  ));
91
  }
92
 
includes/class.upgrader.php CHANGED
@@ -19,5 +19,15 @@ class Upgrader
19
  global $wpgmza;
20
  $wpgmza->updateAllMarkerXMLFiles();
21
  });
 
 
 
 
 
 
 
 
 
 
22
  }
23
  }
19
  global $wpgmza;
20
  $wpgmza->updateAllMarkerXMLFiles();
21
  });
22
+
23
+ $this->upgradeLngLat();
24
+ }
25
+
26
+ protected function upgradeLngLat()
27
+ {
28
+ /*global $wpdb;
29
+ global $WPGMZA_TABLE_NAME_MARKERS;
30
+
31
+ $wpdb->query("UPDATE `$WPGMZA_TABLE_NAME_MARKERS` SET lnglat = POINT(Y(latlng), X(latlng))");*/
32
  }
33
  }
includes/google-maps/class.google-maps-loader.php CHANGED
@@ -99,6 +99,8 @@ class GoogleMapsLoader
99
  $key = get_option('wpgmza_google_maps_api_key');
100
  if(!empty($key))
101
  $params['key'] = $key;
 
 
102
 
103
  $params = apply_filters( 'wpgmza_google_maps_api_params', $params );
104
 
99
  $key = get_option('wpgmza_google_maps_api_key');
100
  if(!empty($key))
101
  $params['key'] = $key;
102
+ else if(is_admin())
103
+ $params['key'] = get_option('wpgmza_temp_api');
104
 
105
  $params = apply_filters( 'wpgmza_google_maps_api_params', $params );
106
 
includes/legacy/functions.circle.php ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!function_exists('wpgmza_get_circle_data'))
4
+ {
5
+ function wpgmza_get_circle_data($map_id)
6
+ {
7
+ global $wpgmza;
8
+ global $wpdb;
9
+ global $wpgmza_tblname_circles;
10
+
11
+ $stmt = $wpdb->prepare("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(center) AS center FROM $wpgmza_tblname_circles WHERE map_id=%d", array($map_id));
12
+ $results = $wpdb->get_results($stmt);
13
+
14
+ $circles = array();
15
+ foreach($results as $obj)
16
+ $circles[$obj->id] = $obj;
17
+
18
+ return $circles;
19
+ }
20
+ }
21
+
22
+ function wpgmza_b_add_circle($mid)
23
+ {
24
+ global $wpgmza_tblname_maps;
25
+ global $wpdb;
26
+
27
+ wpgmaps_b_admin_add_circle_javascript();
28
+
29
+ if ($_GET['action'] == "add_circle" && isset($mid)) {
30
+ $res = wpgmza_get_map_data($mid);
31
+ echo "
32
+
33
+
34
+
35
+
36
+ <div class='wrap'>
37
+ <h1>WP Google Maps</h1>
38
+ <div class='wide'>
39
+
40
+ <h2>".__("Add circle","wp-google-maps")."</h2>
41
+ <form action='?page=wp-google-maps-menu&action=edit&map_id=".$mid."' method='post' id='wpgmaps_add_circle_form'>
42
+ <input type='hidden' name='wpgmaps_map_id' id='wpgmaps_map_id' value='".$mid."' />
43
+ <input type='hidden' name='wpgmaps_circle-nonce' id='wpgmaps_b_nonce' value='".wp_create_nonce( 'wpgmaps_circle-nonce' )."' />
44
+ <input type='hidden' name='center'/>
45
+
46
+ <table class='wpgmza-listing-comp' style='width:30%;float:left;'>
47
+ <tr>
48
+ <td>
49
+ ".__("Name","wp-google-maps")."
50
+ </td>
51
+ <td>
52
+ <input id=\"circle\" name=\"circle_name\" type=\"text\" value=\"\" />
53
+ </td>
54
+ </tr>
55
+ <tr>
56
+ <td>
57
+ ".__("Color","wp-google-maps")."
58
+ </td>
59
+ <td>
60
+ <input id=\"circle_color\" name=\"circle_color\" type=\"color\" value=\"#ff0000\" />
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>
65
+ ".__("Opacity","wp-google-maps")."
66
+ </td>
67
+ <td>
68
+ <input id=\"circle_opacity\" name=\"circle_opacity\" type=\"text\" value=\"0.6\" /> <small class='wpgmza-info__small'>(0 - 1.0) example: 0.6 for 60%</small>
69
+ </td>
70
+ </tr>
71
+ <tr>
72
+ <td>
73
+ ".__("Radius","wp-google-maps")."
74
+ </td>
75
+ <td>
76
+ <input id=\"circle_radius\" name=\"circle_radius\" type=\"text\" value=\"20\" />
77
+ </td>
78
+ </tr>
79
+ <tr>
80
+ <td></td>
81
+ <td>
82
+ <p id='circle-radius-visibility-warning' class='notice notice-warning'>
83
+ " . __('Please note your circle may be too small to be visible at this zoom level', 'wp-google-maps') . "
84
+ </p>
85
+ </td>
86
+ </tr>
87
+ </table>
88
+ <div class='wpgmza_map_seventy'>
89
+ <div id=\"wpgmza_map\">&nbsp;</div>
90
+ <p>
91
+ <ul style=\"list-style:initial; margin-top: -145px !important;\" class='update-nag update-blue update-slim update-map-overlay'>
92
+ <li style=\"margin-left:30px;\">" . __('Click on the map to insert a circle.', 'wp-google-maps') . "</li>
93
+ <li style=\"margin-left:30px;\">" . __('Click or drag the circle to move it.', 'wp-google-maps') . "</li>
94
+ </ul>
95
+ </p>
96
+ </div>
97
+
98
+ <p class='submit'><a href='javascript:history.back();' class='button button-secondary' title='".__("Cancel")."'>".__("Cancel")."</a> <input type='submit' name='wpgmza_save_circle' class='button-primary' value='".__("Save Circle","wp-google-maps")." &raquo;' /></p>
99
+
100
+ </form>
101
+ </div>
102
+
103
+
104
+ </div>
105
+
106
+
107
+
108
+ ";
109
+
110
+ }
111
+ }
112
+
113
+ function wpgmza_b_edit_circle($mid)
114
+ {
115
+ global $wpgmza;
116
+ global $wpgmza_tblname_maps;
117
+ global $wpgmza_tblname_circles;
118
+ global $wpdb;
119
+
120
+ wpgmaps_b_admin_add_circle_javascript();
121
+
122
+ if ($_GET['action'] == "edit_circle" && isset($mid)) {
123
+ $res = wpgmza_get_map_data($mid);
124
+ $circle_id = (int)$_GET['circle_id'];
125
+
126
+ $results = $wpdb->get_results("SELECT *, {$wpgmza->spatialFunctionPrefix}AsText(center) AS center FROM $wpgmza_tblname_circles WHERE id = $circle_id");
127
+
128
+ if(empty($results))
129
+ {
130
+ echo "<p class='notice notice-error'>" . __('Invalid circle ID', 'wp-google-maps') . "</p>";
131
+ return;
132
+ }
133
+
134
+ $circle = $results[0];
135
+
136
+ $name = addcslashes($circle->name, '"');
137
+ $center = preg_replace('/POINT\(|[,)]/', '', $circle->center);
138
+
139
+ echo "
140
+ <div class='wrap'>
141
+ <h1>WP Google Maps</h1>
142
+ <div class='wide'>
143
+
144
+ <h2>".__("Edit circle","wp-google-maps")."</h2>
145
+ <form action='?page=wp-google-maps-menu&action=edit&map_id=".$mid."' method='post' id='wpgmaps_add_circle_form'>
146
+ <input type='hidden' name='wpgmaps_map_id' id='wpgmaps_map_id' value='".$mid."' />
147
+ <input type='hidden' name='circle_id' value='{$circle_id}'/>
148
+ <input type='hidden' name='wpgmaps_circle-nonce' id='wpgmaps_b_nonce' value='".wp_create_nonce( 'wpgmaps_circle-nonce' )."' />
149
+
150
+
151
+ <input type='hidden' name='center' value='{$center}'/>
152
+
153
+ <table class='wpgmza-listing-comp' style='width:30%;float:left;'>
154
+ <tr>
155
+ <td>
156
+ " . __("Name","wp-google-maps") . "
157
+ </td>
158
+ <td>
159
+ <input id=\"circle\" name=\"circle_name\" type=\"text\" value=\"$name\" />
160
+ </td>
161
+ </tr>
162
+ <tr>
163
+ <td>
164
+ " . __('Center', 'wp-google-maps') . "
165
+ </td>
166
+ <td>
167
+ <input name='center' value='" . esc_attr($center) . "'/>
168
+ <button id='fit-bounds-to-shape'
169
+ class='button button-secondary'
170
+ type='button'
171
+ title='" . __('Fit map bounds to shape', 'wp-google-maps') . "'
172
+ data-fit-bounds-to-shape='circle'>
173
+ <i class='fas fa-eye'></i>
174
+ </button>
175
+ </td>
176
+ </tr>
177
+ <tr>
178
+ <td>
179
+ ".__("Color","wp-google-maps")."
180
+ </td>
181
+ <td>
182
+ <input id=\"circle_color\" name=\"circle_color\" type=\"color\" value=\"{$circle->color}\" />
183
+ </td>
184
+ </tr>
185
+ <tr>
186
+ <td>
187
+ ".__("Opacity","wp-google-maps")."
188
+ </td>
189
+ <td>
190
+ <input id=\"circle_opacity\" name=\"circle_opacity\" type=\"text\" value=\"{$circle->opacity}\" type='number' step='any' /> <small class='wpgmza-info__small'>(0 - 1.0) example: 0.6 for 60%</small>
191
+ </td>
192
+ </tr>
193
+ <tr>
194
+ <td>
195
+ ".__("Radius","wp-google-maps")."
196
+ </td>
197
+ <td>
198
+ <input id=\"circle_radius\" name=\"circle_radius\" type=\"text\" value=\"{$circle->radius}\" type='number' step='any' />
199
+ </td>
200
+ </tr>
201
+ <tr>
202
+ <td></td>
203
+ <td>
204
+ <p id='circle-radius-visibility-warning' class='notice notice-warning'>
205
+ " . __('Please note your circle may be too small to be visible at this zoom level', 'wp-google-maps') . "
206
+ </p>
207
+ </td>
208
+ </tr>
209
+ </table>
210
+ <div class='wpgmza_map_seventy'>
211
+ <div id=\"wpgmza_map\">&nbsp;</div>
212
+ <p>
213
+ <ul style=\"list-style:initial; margin-top: -145px !important;\" class='update-nag update-blue update-slim update-map-overlay'>
214
+ <li style=\"margin-left:30px;\">" . __('Click or drag the circle to move it.', 'wp-google-maps') . "</li>
215
+ </ul>
216
+ </p>
217
+ </div>
218
+
219
+ <p class='submit'><a href='javascript:history.back();' class='button button-secondary' title='".__("Cancel")."'>".__("Cancel")."</a> <input type='submit' name='wpgmza_save_circle' class='button-primary' value='".__("Save Circle","wp-google-maps")." &raquo;' /></p>
220
+
221
+ </form>
222
+ </div>
223
+
224
+
225
+ </div>
226
+
227
+
228
+
229
+ ";
230
+
231
+ }
232
+ }
233
+
234
+ function wpgmaps_b_admin_add_circle_javascript()
235
+ {
236
+ $res = wpgmza_get_map_data(sanitize_text_field($_GET['map_id']));
237
+ $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
238
+
239
+ $wpgmza_lat = $res->map_start_lat;
240
+ $wpgmza_lng = $res->map_start_lng;
241
+ $wpgmza_map_type = $res->type;
242
+ $wpgmza_width = $res->map_width;
243
+ $wpgmza_height = $res->map_height;
244
+ $wpgmza_width_type = $res->map_width_type;
245
+ $wpgmza_height_type = $res->map_height_type;
246
+ if (!$wpgmza_map_type || $wpgmza_map_type == "" || $wpgmza_map_type == "1") { $wpgmza_map_type = "ROADMAP"; }
247
+ else if ($wpgmza_map_type == "2") { $wpgmza_map_type = "SATELLITE"; }
248
+ else if ($wpgmza_map_type == "3") { $wpgmza_map_type = "HYBRID"; }
249
+ else if ($wpgmza_map_type == "4") { $wpgmza_map_type = "TERRAIN"; }
250
+ else { $wpgmza_map_type = "ROADMAP"; }
251
+ $start_zoom = $res->map_start_zoom;
252
+ if ($start_zoom < 1 || !$start_zoom) {
253
+ $start_zoom = 5;
254
+ }
255
+
256
+ $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
257
+ global $api_version_string;
258
+
259
+ $localized_data = array(
260
+ 'wpgmza_lat' => $wpgmza_lat,
261
+ 'wpgmza_lng' => $wpgmza_lng,
262
+ 'start_zoom' => $start_zoom,
263
+ 'wpgmza_width' => $wpgmza_width,
264
+ 'wpgmza_width_type' => $wpgmza_width_type,
265
+ 'wpgmza_height' => $wpgmza_height,
266
+ 'wpgmza_height_type' => $wpgmza_height_type,
267
+ 'wpgmza_map_type' => $wpgmza_map_type
268
+ );
269
+
270
+ wp_enqueue_style('wpgooglemaps-css', wpgmaps_get_plugin_url() . 'css/wpgmza_style.css');
271
+ wp_enqueue_script('wpgmza-legacy-circle-panel', plugin_dir_url(__FILE__) . 'js/legacy/legacy-circle-panel.js');
272
+ wp_localize_script('wpgmza-legacy-circle-panel', 'wpgmza_legacy', $localized_data);
273
+ }
274
+
275
+ if(!function_exists('wpgmza_get_circles_table'))
276
+ {
277
+ function wpgmza_get_circles_table($map_id)
278
+ {
279
+ global $wpdb;
280
+ global $wpgmza_tblname_circles;
281
+
282
+ $circles_table = "
283
+ <table>
284
+ <thead>
285
+ <tr>
286
+ <th>" . __('ID', 'wp-google-maps') . "</th>
287
+ <th>" . __('Name', 'wp-google-maps') . "</th>
288
+ <th>" . __('Action', 'wp-google-maps') . "</th>
289
+ </tr>
290
+ </thead>
291
+ <tbody>
292
+ ";
293
+
294
+ $stmt = $wpdb->prepare("SELECT * FROM $wpgmza_tblname_circles WHERE map_id = %d", array($map_id));
295
+ $circles = $wpdb->get_results($stmt);
296
+ foreach($circles as $circle)
297
+ {
298
+ $circles_table .= "
299
+ <tr>
300
+ <td>{$circle->id}</td>
301
+ <td>{$circle->name}</td>
302
+ <td width='170' align='left'>
303
+ <a href='" . get_option('siteurl') . "/wp-admin/admin.php?page=wp-google-maps-menu&amp;action=edit_circle&amp;map_id={$map_id}&amp;circle_id={$circle->id}'
304
+ title='" . __('Edit', 'wp-google-maps') . "'
305
+ class='wpgmza_edit_circle_btn button'
306
+ id='{$circle->id}'>
307
+ <i class='fa fa-edit'> </i>
308
+ </a>
309
+ <a href='javascript:void(0);'
310
+ title='" . __('Delete this circle', 'wp-google-maps') . "' class='wpgmza_circle_del_btn button' id='{$circle->id}'><i class='fa fa-times'> </i>
311
+ </a>
312
+ </td>
313
+ </tr>
314
+ ";
315
+ }
316
+
317
+ $circles_table .= "
318
+ </tbody>
319
+ </table>
320
+ ";
321
+
322
+ return $circles_table;
323
+ }
324
+ }
includes/legacy/functions.rectangle.php ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!function_exists('wpgmza_get_rectangle_data'))
4
+ {
5
+ function wpgmza_get_rectangle_data($map_id)
6
+ {
7
+ global $wpgmza;
8
+ global $wpdb;
9
+ global $wpgmza_tblname_rectangles;
10
+
11
+ $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));
12
+ $results = $wpdb->get_results($stmt);
13
+
14
+ $rectangles = array();
15
+ foreach($results as $obj)
16
+ $rectangles[$obj->id] = $obj;
17
+
18
+ return $rectangles;
19
+ }
20
+ }
21
+
22
+ function wpgmza_b_add_rectangle($mid)
23
+ {
24
+ global $wpgmza_tblname_maps;
25
+ global $wpdb;
26
+
27
+ wpgmaps_b_admin_add_rectangle_javascript();
28
+
29
+ if ($_GET['action'] == "add_rectangle" && isset($mid)) {
30
+ $res = wpgmza_get_map_data($mid);
31
+ echo "
32
+
33
+
34
+
35
+
36
+ <div class='wrap'>
37
+ <h1>WP Google Maps</h1>
38
+ <div class='wide'>
39
+
40
+ <h2>".__("Add rectangle","wp-google-maps")."</h2>
41
+ <form action='?page=wp-google-maps-menu&action=edit&map_id=".$mid."' method='post' id='wpgmaps_add_rectangle_form'>
42
+ <input type='hidden' name='wpgmaps_map_id' id='wpgmaps_map_id' value='".$mid."' />
43
+ <input type='hidden' name='wpgmaps_rectangle-nonce' id='wpgmaps_b_nonce' value='".wp_create_nonce( 'wpgmaps_rectangle-nonce' )."' />
44
+ <input type='hidden' name='bounds'/>
45
+
46
+ <table class='wpgmza-listing-comp' style='width:30%;float:left;'>
47
+ <tr>
48
+ <td>
49
+ ".__("Name","wp-google-maps")."
50
+ </td>
51
+ <td>
52
+ <input id=\"rectangle\" name=\"rectangle_name\" type=\"text\" value=\"\" />
53
+ </td>
54
+ </tr>
55
+ <tr>
56
+ <td>
57
+ ".__("Color","wp-google-maps")."
58
+ </td>
59
+ <td>
60
+ <input id=\"rectangle_color\" name=\"rectangle_color\" type=\"color\" value=\"#ff0000\" />
61
+ </td>
62
+ </tr>
63
+ <tr>
64
+ <td>
65
+ ".__("Opacity","wp-google-maps")."
66
+ </td>
67
+ <td>
68
+ <input id=\"rectangle_opacity\" name=\"rectangle_opacity\" type=\"text\" value=\"0.6\" /> <small class='wpgmza-info__small'>(0 - 1.0) example: 0.6 for 60%</small>
69
+ </td>
70
+ </tr>
71
+
72
+ </table>
73
+ <div class='wpgmza_map_seventy'>
74
+ <div id=\"wpgmza_map\">&nbsp;</div>
75
+ <p>
76
+ <ul style=\"list-style:initial; margin-top: -145px !important;\" class='update-nag update-blue update-slim update-map-overlay'>
77
+ <li style=\"margin-left:30px;\">" . __('Click on the map to insert a rectangle.', 'wp-google-maps') . "</li>
78
+ <li style=\"margin-left:30px;\">" . __('Click or drag the rectangle to move it.', 'wp-google-maps') . "</li>
79
+ </ul>
80
+ </p>
81
+ </div>
82
+
83
+ <p class='submit'><a href='javascript:history.back();' class='button button-secondary' title='".__("Cancel")."'>".__("Cancel")."</a> <input type='submit' name='wpgmza_save_rectangle' class='button-primary' value='".__("Save rectangle","wp-google-maps")." &raquo;' /></p>
84
+
85
+ </form>
86
+ </div>
87
+
88
+
89
+ </div>
90
+
91
+
92
+
93
+ ";
94
+
95
+ }
96
+ }
97
+
98
+ function wpgmza_b_edit_rectangle($mid)
99
+ {
100
+ global $wpgmza;
101
+ global $wpgmza_tblname_maps;
102
+ global $wpgmza_tblname_rectangles;
103
+ global $wpdb;
104
+
105
+ wpgmaps_b_admin_add_rectangle_javascript();
106
+
107
+ if ($_GET['action'] == "edit_rectangle" && isset($mid)) {
108
+ $res = wpgmza_get_map_data($mid);
109
+ $rectangle_id = (int)$_GET['rectangle_id'];
110
+
111
+ $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");
112
+
113
+ if(empty($results))
114
+ {
115
+ echo "<p class='notice notice-error'>" . __('Invalid rectangle ID', 'wp-google-maps') . "</p>";
116
+ return;
117
+ }
118
+
119
+ $rectangle = $results[0];
120
+
121
+ $name = addcslashes($rectangle->name, '"');
122
+ preg_match_all('/-?\d+(\.\d+)?/', $rectangle->cornerA . $rectangle->cornerB, $m);
123
+
124
+ $north = $m[0][0];
125
+ $west = $m[0][1];
126
+ $south = $m[0][2];
127
+ $east = $m[0][3];
128
+
129
+ echo "
130
+ <div class='wrap'>
131
+ <h1>WP Google Maps</h1>
132
+ <div class='wide'>
133
+
134
+ <h2>".__("Edit rectangle","wp-google-maps")."</h2>
135
+ <form action='?page=wp-google-maps-menu&action=edit&map_id=".$mid."' method='post' id='wpgmaps_add_rectangle_form'>
136
+ <input type='hidden' name='wpgmaps_map_id' id='wpgmaps_map_id' value='".$mid."' />
137
+ <input type='hidden' name='rectangle_id' value='{$rectangle_id}'/>
138
+ <input type='hidden' name='wpgmaps_rectangle-nonce' id='wpgmaps_b_nonce' value='".wp_create_nonce( 'wpgmaps_rectangle-nonce' )."' />
139
+ <input type='hidden' name='bounds' value='$north $west $south $east'/>
140
+
141
+ <table class='wpgmza-listing-comp' style='width:30%;float:left;'>
142
+ <tr>
143
+ <td>
144
+ " . __("Name","wp-google-maps") . "
145
+ </td>
146
+ <td>
147
+ <input id=\"rectangle\" name=\"rectangle_name\" type=\"text\" value=\"$name\" />
148
+ </td>
149
+ </tr>
150
+ <tr>
151
+ <td>
152
+ ".__("Color","wp-google-maps")."
153
+ </td>
154
+ <td>
155
+ <input id=\"rectangle_color\" name=\"rectangle_color\" type=\"color\" value=\"{$rectangle->color}\" />
156
+