Simple Google Map - Version 3.2.1

Version Description

  • Revert arrays to long syntax for compatibility with PHP 5.3.
  • Move strip_last_chars function to base class.
Download this release

Release Info

Developer gwelser
Plugin Icon wp plugin Simple Google Map
Version 3.2.1
Comparing to
See all releases

Code changes from version 3.2 to 3.2.1

README.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: taylor_cnp, gwelser
3
  Donate link: http://clarknikdelpowell.com/pay
4
  Tags: google, google map, google maps, simple google map, no api key
5
- Requires at least: 3.0.1
6
  Tested up to: 4.5.3
7
- Stable tag: 3.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -48,9 +48,14 @@ The shortcode name is SGM and here are the options..
48
 
49
  == Changelog ==
50
 
 
 
 
 
51
  = 3.2 =
52
  * Code cleanup per [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards).
53
  * Return rendered shortcode instead of echoing.
 
54
 
55
  = 3.1 =
56
  * Add directions form to info bubble when directionsto is provided.
2
  Contributors: taylor_cnp, gwelser
3
  Donate link: http://clarknikdelpowell.com/pay
4
  Tags: google, google map, google maps, simple google map, no api key
5
+ Requires at least: 3.2
6
  Tested up to: 4.5.3
7
+ Stable tag: 3.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
48
 
49
  == Changelog ==
50
 
51
+ = 3.2.1 =
52
+ * Revert arrays to long syntax for compatibility with PHP 5.3.
53
+ * Move strip_last_chars function to base class.
54
+
55
  = 3.2 =
56
  * Code cleanup per [WordPress Coding Standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards).
57
  * Return rendered shortcode instead of echoing.
58
+ * Convert arrays to short syntax.
59
 
60
  = 3.1 =
61
  * Add directions form to info bubble when directionsto is provided.
admin/class-simple-google-map-admin.php CHANGED
@@ -61,12 +61,12 @@ class Simple_Google_Map_Admin {
61
 
62
  $this->plugin_name = $plugin_name;
63
  $this->version = $version;
64
- $this->default_options = [
65
  'zoom' => '12',
66
  'type' => 'ROADMAP',
67
  'directionsto' => '',
68
  'content' => '',
69
- ];
70
 
71
  }
72
 
@@ -77,7 +77,7 @@ class Simple_Google_Map_Admin {
77
  */
78
  public function enqueue_styles() {
79
 
80
- wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/simple-google-map-admin.css', [], $this->version, 'all' );
81
 
82
  }
83
 
@@ -88,16 +88,16 @@ class Simple_Google_Map_Admin {
88
  */
89
  public function enqueue_scripts() {
90
 
91
- wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/simple-google-map-admin.js', [ 'jquery' ], $this->version, false );
92
 
93
  }
94
 
95
  public function plugin_menu() {
96
 
97
- add_options_page( 'Simple Google Map', 'Simple Google Map', 'activate_plugins', 'simple-google-map', [
98
  $this,
99
  'plugin_options',
100
- ] );
101
 
102
  }
103
 
61
 
62
  $this->plugin_name = $plugin_name;
63
  $this->version = $version;
64
+ $this->default_options = array(
65
  'zoom' => '12',
66
  'type' => 'ROADMAP',
67
  'directionsto' => '',
68
  'content' => '',
69
+ );
70
 
71
  }
72
 
77
  */
78
  public function enqueue_styles() {
79
 
80
+ wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/simple-google-map-admin.css', array(), $this->version, 'all' );
81
 
82
  }
83
 
88
  */
89
  public function enqueue_scripts() {
90
 
91
+ wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/simple-google-map-admin.js', array( 'jquery' ), $this->version, false );
92
 
93
  }
94
 
95
  public function plugin_menu() {
96
 
97
+ add_options_page( 'Simple Google Map', 'Simple Google Map', 'activate_plugins', 'simple-google-map', array(
98
  $this,
99
  'plugin_options',
100
+ ) );
101
 
102
  }
103
 
includes/class-simple-google-map-activator.php CHANGED
@@ -31,12 +31,12 @@ class Simple_Google_Map_Activator {
31
  */
32
  public static function activate() {
33
 
34
- $sgm_defaults = [
35
  'zoom' => '12',
36
  'type' => 'ROADMAP',
37
  'directionsto' => '',
38
  'content' => '',
39
- ];
40
  update_option( 'SGMoptions', $sgm_defaults );
41
 
42
  $sgm_css = '#SGM {width:100%; height:300px;}#SGM .infoWindow {line-height:13px; font-size:10px;}#SGM input {margin:4px 4px 0 0; font-size:10px;}#SGM input.text {border:solid 1px #ccc; background-color:#fff; padding:2px;}';
31
  */
32
  public static function activate() {
33
 
34
+ $sgm_defaults = array(
35
  'zoom' => '12',
36
  'type' => 'ROADMAP',
37
  'directionsto' => '',
38
  'content' => '',
39
+ );
40
  update_option( 'SGMoptions', $sgm_defaults );
41
 
42
  $sgm_css = '#SGM {width:100%; height:300px;}#SGM .infoWindow {line-height:13px; font-size:10px;}#SGM input {margin:4px 4px 0 0; font-size:10px;}#SGM input.text {border:solid 1px #ccc; background-color:#fff; padding:2px;}';
includes/class-simple-google-map-loader.php CHANGED
@@ -127,13 +127,13 @@ class Simple_Google_Map_Loader {
127
  */
128
  private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
129
 
130
- $hooks[] = [
131
  'hook' => $hook,
132
  'component' => $component,
133
  'callback' => $callback,
134
  'priority' => $priority,
135
  'accepted_args' => $accepted_args,
136
- ];
137
 
138
  return $hooks;
139
  }
@@ -146,21 +146,21 @@ class Simple_Google_Map_Loader {
146
  public function run() {
147
 
148
  foreach ( $this->filters as $hook ) {
149
- add_filter( $hook['hook'], [
150
  $hook['component'],
151
  $hook['callback'],
152
- ], $hook['priority'], $hook['accepted_args'] );
153
  }
154
 
155
  foreach ( $this->actions as $hook ) {
156
- add_action( $hook['hook'], [
157
  $hook['component'],
158
  $hook['callback'],
159
- ], $hook['priority'], $hook['accepted_args'] );
160
  }
161
 
162
  foreach ( $this->shortcodes as $hook ) {
163
- add_shortcode( $hook['hook'], [ $hook['component'], $hook['callback'] ] );
164
  }
165
  }
166
  }
127
  */
128
  private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
129
 
130
+ $hooks[] = array(
131
  'hook' => $hook,
132
  'component' => $component,
133
  'callback' => $callback,
134
  'priority' => $priority,
135
  'accepted_args' => $accepted_args,
136
+ );
137
 
138
  return $hooks;
139
  }
146
  public function run() {
147
 
148
  foreach ( $this->filters as $hook ) {
149
+ add_filter( $hook['hook'], array(
150
  $hook['component'],
151
  $hook['callback'],
152
+ ), $hook['priority'], $hook['accepted_args'] );
153
  }
154
 
155
  foreach ( $this->actions as $hook ) {
156
+ add_action( $hook['hook'], array(
157
  $hook['component'],
158
  $hook['callback'],
159
+ ), $hook['priority'], $hook['accepted_args'] );
160
  }
161
 
162
  foreach ( $this->shortcodes as $hook ) {
163
+ add_shortcode( $hook['hook'], array( $hook['component'], $hook['callback'] ) );
164
  }
165
  }
166
  }
includes/class-simple-google-map.php CHANGED
@@ -43,7 +43,7 @@ class Simple_Google_Map {
43
  *
44
  * @since 3.0.0
45
  * @access protected
46
- * @var Simple_Google_Map_Loader $loader Maintains and registers all hooks for the plugin.
47
  */
48
  protected $loader;
49
 
@@ -52,7 +52,7 @@ class Simple_Google_Map {
52
  *
53
  * @since 3.0.0
54
  * @access protected
55
- * @var string $plugin_name The string used to uniquely identify this plugin.
56
  */
57
  protected $plugin_name;
58
 
@@ -61,7 +61,7 @@ class Simple_Google_Map {
61
  *
62
  * @since 3.0.0
63
  * @access protected
64
- * @var string $plugin_path The string path of this plugin.
65
  */
66
  protected $plugin_path;
67
 
@@ -70,7 +70,7 @@ class Simple_Google_Map {
70
  *
71
  * @since 3.0.0
72
  * @access protected
73
- * @var string $version The current version of the plugin.
74
  */
75
  protected $version;
76
 
@@ -86,7 +86,7 @@ class Simple_Google_Map {
86
  public function __construct() {
87
 
88
  $this->plugin_name = 'simple-google-map';
89
- $this->version = '3.0.0';
90
 
91
  $this->load_dependencies();
92
  $this->set_locale();
@@ -208,6 +208,7 @@ class Simple_Google_Map {
208
  * @since 3.0.0
209
  */
210
  public function run() {
 
211
  $this->loader->run();
212
  }
213
 
@@ -219,6 +220,7 @@ class Simple_Google_Map {
219
  * @return string The name of the plugin.
220
  */
221
  public function get_plugin_name() {
 
222
  return $this->plugin_name;
223
  }
224
 
@@ -229,6 +231,7 @@ class Simple_Google_Map {
229
  * @return Simple_Google_Map_Loader Orchestrates the hooks of the plugin.
230
  */
231
  public function get_loader() {
 
232
  return $this->loader;
233
  }
234
 
@@ -239,6 +242,7 @@ class Simple_Google_Map {
239
  * @return string The version number of the plugin.
240
  */
241
  public function get_version() {
 
242
  return $this->version;
243
  }
244
 
@@ -249,6 +253,41 @@ class Simple_Google_Map {
249
  * @return string The path of the plugin.
250
  */
251
  public function get_plugin_path() {
 
252
  return $this->plugin_path;
253
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
43
  *
44
  * @since 3.0.0
45
  * @access protected
46
+ * @var Simple_Google_Map_Loader $loader Maintains and registers all hooks for the plugin.
47
  */
48
  protected $loader;
49
 
52
  *
53
  * @since 3.0.0
54
  * @access protected
55
+ * @var string $plugin_name The string used to uniquely identify this plugin.
56
  */
57
  protected $plugin_name;
58
 
61
  *
62
  * @since 3.0.0
63
  * @access protected
64
+ * @var string $plugin_path The string path of this plugin.
65
  */
66
  protected $plugin_path;
67
 
70
  *
71
  * @since 3.0.0
72
  * @access protected
73
+ * @var string $version The current version of the plugin.
74
  */
75
  protected $version;
76
 
86
  public function __construct() {
87
 
88
  $this->plugin_name = 'simple-google-map';
89
+ $this->version = '3.0.0';
90
 
91
  $this->load_dependencies();
92
  $this->set_locale();
208
  * @since 3.0.0
209
  */
210
  public function run() {
211
+
212
  $this->loader->run();
213
  }
214
 
220
  * @return string The name of the plugin.
221
  */
222
  public function get_plugin_name() {
223
+
224
  return $this->plugin_name;
225
  }
226
 
231
  * @return Simple_Google_Map_Loader Orchestrates the hooks of the plugin.
232
  */
233
  public function get_loader() {
234
+
235
  return $this->loader;
236
  }
237
 
242
  * @return string The version number of the plugin.
243
  */
244
  public function get_version() {
245
+
246
  return $this->version;
247
  }
248
 
253
  * @return string The path of the plugin.
254
  */
255
  public function get_plugin_path() {
256
+
257
  return $this->plugin_path;
258
  }
259
+
260
+ /**
261
+ * Removes the specified string from the end of the target string.
262
+ *
263
+ * @since 3.2
264
+ *
265
+ * @param string $haystack
266
+ * @param string|Array $needles
267
+ *
268
+ * @return string
269
+ */
270
+ public static function strip_last_chars( $haystack, $needles ) {
271
+
272
+ if ( empty( $haystack ) ) {
273
+ return $haystack;
274
+ }
275
+
276
+ if ( ! is_array( $needles ) ) {
277
+ if ( substr( $haystack, strlen( $needles ) * - 1 ) === $needles ) {
278
+ $haystack = substr( $haystack, 0, strlen( $haystack ) - strlen( $needles ) );
279
+ }
280
+ }
281
+
282
+ if ( is_array( $needles ) ) {
283
+ foreach ( $needles as $needle ) {
284
+ if ( substr( $haystack, strlen( $needle ) * - 1 ) === $needle ) {
285
+ $haystack = substr( $haystack, 0, strlen( $haystack ) - strlen( $needle ) );
286
+ break;
287
+ }
288
+ }
289
+ }
290
+
291
+ return $haystack;
292
+ }
293
  }
public/class-simple-google-map-public.php CHANGED
@@ -112,18 +112,18 @@ class Simple_Google_Map_Public {
112
  $content = isset( $atts['content'] ) ? $atts['content'] : $sgm_options['content'];
113
  $directions_to = isset( $atts['directionsto'] ) ? $atts['directionsto'] : '';
114
 
115
- $content = $this->strip_last_chars( htmlspecialchars_decode( $content ), [
116
  '<br>',
117
  '<br/>',
118
  '<br />',
119
- ] );
120
 
121
  $directions_form = '';
122
  if ( $directions_to ) {
123
  $directions_form = '<form method="get" action="//maps.google.com/maps"><input type="hidden" name="daddr" value="' . $directions_to . '" /><input type="text" class="text" name="saddr" /><input type="submit" class="submit" value="Directions" /></form>';
124
  }
125
 
126
- $infowindow_arr = [ $content, $directions_to, $directions_form ];
127
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
128
 
129
  $map = '<script type="text/javascript">';
@@ -158,28 +158,4 @@ class Simple_Google_Map_Public {
158
 
159
  return $map;
160
  }
161
-
162
- public function strip_last_chars( $haystack, $needles ) {
163
-
164
- if ( empty( $haystack ) ) {
165
- return $haystack;
166
- }
167
-
168
- if ( ! is_array( $needles ) ) {
169
- if ( substr( $haystack, strlen( $needles ) * - 1 ) === $needles ) {
170
- $haystack = substr( $haystack, 0, strlen( $haystack ) - strlen( $needles ) );
171
- }
172
- }
173
-
174
- if ( is_array( $needles ) ) {
175
- foreach ( $needles as $needle ) {
176
- if ( substr( $haystack, strlen( $needle ) * - 1 ) === $needle ) {
177
- $haystack = substr( $haystack, 0, strlen( $haystack ) - strlen( $needle ) );
178
- break;
179
- }
180
- }
181
- }
182
-
183
- return $haystack;
184
- }
185
  }
112
  $content = isset( $atts['content'] ) ? $atts['content'] : $sgm_options['content'];
113
  $directions_to = isset( $atts['directionsto'] ) ? $atts['directionsto'] : '';
114
 
115
+ $content = Simple_Google_Map::strip_last_chars( htmlspecialchars_decode( $content ), array(
116
  '<br>',
117
  '<br/>',
118
  '<br />',
119
+ ) );
120
 
121
  $directions_form = '';
122
  if ( $directions_to ) {
123
  $directions_form = '<form method="get" action="//maps.google.com/maps"><input type="hidden" name="daddr" value="' . $directions_to . '" /><input type="text" class="text" name="saddr" /><input type="submit" class="submit" value="Directions" /></form>';
124
  }
125
 
126
+ $infowindow_arr = array( $content, $directions_to, $directions_form );
127
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
128
 
129
  $map = '<script type="text/javascript">';
158
 
159
  return $map;
160
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  }
simple-google-map.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: Simple Google Map
17
  * Plugin URI: http://clarknikdelpowell.com/wordpress/simple-google-map
18
  * Description: Embed a google map using shortcode or as a widget.
19
- * Version: 3.2
20
  * Author: Taylor Gorman, Glenn Welser
21
  * Author URI: http://clarknikdelpowell.com
22
  * License: GPL-2.0+
16
  * Plugin Name: Simple Google Map
17
  * Plugin URI: http://clarknikdelpowell.com/wordpress/simple-google-map
18
  * Description: Embed a google map using shortcode or as a widget.
19
+ * Version: 3.2.1
20
  * Author: Taylor Gorman, Glenn Welser
21
  * Author URI: http://clarknikdelpowell.com
22
  * License: GPL-2.0+
widgets/simple-google-map-widget.php CHANGED
@@ -20,9 +20,9 @@ class Simple_Google_Map_Widget extends WP_Widget {
20
  parent::__construct(
21
  'simple-google-map-widget',
22
  'Simple Google Map',
23
- [
24
  'description' => 'Add a google map to your blog or site',
25
- ]
26
  );
27
 
28
  }
@@ -138,18 +138,18 @@ class Simple_Google_Map_Widget extends WP_Widget {
138
  $directions_to = $directionsto;
139
  }
140
 
141
- $content = $this->strip_last_chars( htmlspecialchars_decode( $content ), [
142
  '<br>',
143
  '<br/>',
144
  '<br />',
145
- ] );
146
 
147
  $directions_form = '';
148
  if ( $directions_to ) {
149
  $directions_form = '<form method="get" action="//maps.google.com/maps"><input type="hidden" name="daddr" value="' . $directions_to . '" /><input type="text" class="text" name="saddr" /><input type="submit" class="submit" value="Directions" /></form>';
150
  }
151
 
152
- $infowindow_arr = [ $content, $directions_to, $directions_form ];
153
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
154
 
155
  extract( $args );
@@ -192,28 +192,4 @@ class Simple_Google_Map_Widget extends WP_Widget {
192
 
193
  echo $after_widget;
194
  }
195
-
196
- public function strip_last_chars( $haystack, $needles ) {
197
-
198
- if ( empty( $haystack ) ) {
199
- return $haystack;
200
- }
201
-
202
- if ( ! is_array( $needles ) ) {
203
- if ( substr( $haystack, strlen( $needles ) * - 1 ) === $needles ) {
204
- $haystack = substr( $haystack, 0, strlen( $haystack ) - strlen( $needles ) );
205
- }
206
- }
207
-
208
- if ( is_array( $needles ) ) {
209
- foreach ( $needles as $needle ) {
210
- if ( substr( $haystack, strlen( $needle ) * - 1 ) === $needle ) {
211
- $haystack = substr( $haystack, 0, strlen( $haystack ) - strlen( $needle ) );
212
- break;
213
- }
214
- }
215
- }
216
-
217
- return $haystack;
218
- }
219
  }
20
  parent::__construct(
21
  'simple-google-map-widget',
22
  'Simple Google Map',
23
+ array(
24
  'description' => 'Add a google map to your blog or site',
25
+ )
26
  );
27
 
28
  }
138
  $directions_to = $directionsto;
139
  }
140
 
141
+ $content = Simple_Google_Map::strip_last_chars( htmlspecialchars_decode( $content ), array(
142
  '<br>',
143
  '<br/>',
144
  '<br />',
145
+ ) );
146
 
147
  $directions_form = '';
148
  if ( $directions_to ) {
149
  $directions_form = '<form method="get" action="//maps.google.com/maps"><input type="hidden" name="daddr" value="' . $directions_to . '" /><input type="text" class="text" name="saddr" /><input type="submit" class="submit" value="Directions" /></form>';
150
  }
151
 
152
+ $infowindow_arr = array( $content, $directions_to, $directions_form );
153
  $infowindow_content = implode( '<br>', array_filter( $infowindow_arr ) );
154
 
155
  extract( $args );
192
 
193
  echo $after_widget;
194
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  }