Google Maps Widget – Ultimate Google Maps Plugin - Version 2.35

Version Description

  • 2015/04/27
  • few small bugs fixed
  • WP v4.2 compatibility checked
  • remove_query_arg() security issue fixed
  • we broke 500,000 downloads ;)
Download this release

Release Info

Developer WebFactory
Plugin Icon 128x128 Google Maps Widget – Ultimate Google Maps Plugin
Version 2.35
Comparing to
See all releases

Code changes from version 2.30 to 2.35

Files changed (5) hide show
  1. gmw-tracking.php +26 -18
  2. gmw-widget.php +3 -3
  3. google-maps-widget.php +71 -7
  4. js/gmw-admin.js +9 -1
  5. readme.txt +9 -3
gmw-tracking.php CHANGED
@@ -68,12 +68,12 @@ class GMW_tracking {
68
  $options['allow_tracking'] = true;
69
  update_option(GMW_OPTIONS, $options);
70
  self::send_data(true);
71
- wp_redirect(remove_query_arg('gmw_tracking'));
72
  die();
73
  } else if (isset($_GET['gmw_tracking']) && $_GET['gmw_tracking'] == 'opt_out') {
74
  $options['allow_tracking'] = false;
75
  update_option(GMW_OPTIONS, $options);
76
- wp_redirect(remove_query_arg('gmw_tracking'));
77
  die();
78
  }
79
  } // check_opt_in_out
@@ -86,7 +86,7 @@ class GMW_tracking {
86
 
87
  echo '<div class="updated"><p>';
88
  echo __('Please help us improve <strong>Google Maps Widget</strong> by allowing us to track anonymous usage data. Absolutely <strong>no sensitive data is tracked</strong> (<a href="http://www.googlemapswidget.com/plugin-tracking-info/" target="_blank">complete disclosure &amp; details of our tracking policy</a>).', 'google-maps-widget');
89
- echo '<br /><a href="' . esc_url($optin_url) . '" style="vertical-align: baseline;" class="button-primary">' . __('Allow', 'google-maps-widget') . '</a>';
90
  echo '&nbsp;&nbsp;<a href="' . esc_url($optout_url) . '" class="">' . __('Do not allow tracking', 'google-maps-widget') . '</a>';
91
  echo '</p></div>';
92
  } // tracking_notice
@@ -135,21 +135,7 @@ class GMW_tracking {
135
  $data['gmw_first_install'] = $options['first_install'];
136
  $data['gmw_activated'] = GMW::is_activated();
137
  $data['ioncube'] = extension_loaded('IonCube Loader');
138
-
139
- $data['gmw_count'] = 0;
140
- $sidebars = get_option('sidebars_widgets', array());
141
- foreach ($sidebars as $sidebar_name => $widgets) {
142
- if (strpos($sidebar_name, 'inactive') !== false || strpos($sidebar_name, 'orphaned') !== false) {
143
- continue;
144
- }
145
- if (is_array($widgets)) {
146
- foreach ($widgets as $widget_name) {
147
- if (strpos($widget_name, 'googlemapswidget') !== false) {
148
- $data['gmw_count']++;
149
- }
150
- }
151
- }
152
- } // foreach sidebar
153
 
154
  if (get_bloginfo('version') < '3.4') {
155
  $theme = get_theme_data(get_stylesheet_directory() . '/style.css');
@@ -175,4 +161,26 @@ class GMW_tracking {
175
 
176
  return $data;
177
  } // prepare_data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  } // class GMW_tracking
68
  $options['allow_tracking'] = true;
69
  update_option(GMW_OPTIONS, $options);
70
  self::send_data(true);
71
+ wp_redirect(esc_url_raw(remove_query_arg('gmw_tracking')));
72
  die();
73
  } else if (isset($_GET['gmw_tracking']) && $_GET['gmw_tracking'] == 'opt_out') {
74
  $options['allow_tracking'] = false;
75
  update_option(GMW_OPTIONS, $options);
76
+ wp_redirect(esc_url_raw(remove_query_arg('gmw_tracking')));
77
  die();
78
  }
79
  } // check_opt_in_out
86
 
87
  echo '<div class="updated"><p>';
88
  echo __('Please help us improve <strong>Google Maps Widget</strong> by allowing us to track anonymous usage data. Absolutely <strong>no sensitive data is tracked</strong> (<a href="http://www.googlemapswidget.com/plugin-tracking-info/" target="_blank">complete disclosure &amp; details of our tracking policy</a>).', 'google-maps-widget');
89
+ echo '<br /><a href="' . esc_url($optin_url) . '" style="vertical-align: baseline; margin-top: 15px;" class="button-primary">' . __('Allow', 'google-maps-widget') . '</a>';
90
  echo '&nbsp;&nbsp;<a href="' . esc_url($optout_url) . '" class="">' . __('Do not allow tracking', 'google-maps-widget') . '</a>';
91
  echo '</p></div>';
92
  } // tracking_notice
135
  $data['gmw_first_install'] = $options['first_install'];
136
  $data['gmw_activated'] = GMW::is_activated();
137
  $data['ioncube'] = extension_loaded('IonCube Loader');
138
+ $data['gmw_count'] = self::count_active_widgets();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
  if (get_bloginfo('version') < '3.4') {
141
  $theme = get_theme_data(get_stylesheet_directory() . '/style.css');
161
 
162
  return $data;
163
  } // prepare_data
164
+
165
+
166
+ // counts the number of active GMW widgets in sidebars
167
+ static function count_active_widgets() {
168
+ $count = 0;
169
+
170
+ $sidebars = get_option('sidebars_widgets', array());
171
+ foreach ($sidebars as $sidebar_name => $widgets) {
172
+ if (strpos($sidebar_name, 'inactive') !== false || strpos($sidebar_name, 'orphaned') !== false) {
173
+ continue;
174
+ }
175
+ if (is_array($widgets)) {
176
+ foreach ($widgets as $widget_name) {
177
+ if (strpos($widget_name, 'googlemapswidget') !== false) {
178
+ $count++;
179
+ }
180
+ }
181
+ }
182
+ } // foreach sidebar
183
+
184
+ return $count;
185
+ } // count_active_widgets
186
  } // class GMW_tracking
gmw-widget.php CHANGED
@@ -175,7 +175,7 @@ class GoogleMapsWidget extends WP_Widget {
175
  echo '<select class="gmw_thumb_color_scheme" id="' . $this->get_field_id('thumb_color_scheme') . '" name="' . $this->get_field_name('thumb_color_scheme') . '">';
176
  GMW::create_select_options($thumb_color_schemes, $thumb_color_scheme);
177
  if (!GMW::is_activated()) {
178
- echo '<option class="promo" value="-1">' . __('Add more schemes for free', 'google-maps-widget') . '</option>';
179
  }
180
  echo '</select></p>';
181
 
@@ -207,7 +207,7 @@ class GoogleMapsWidget extends WP_Widget {
207
  echo '<select class="gmw_lightbox_skin" id="' . $this->get_field_id('lightbox_skin') . '" name="' . $this->get_field_name('lightbox_skin') . '">';
208
  GMW::create_select_options($lightbox_skins, $lightbox_skin);
209
  if (!GMW::is_activated()) {
210
- echo '<option class="promo" value="-1">' . __('Add more skins for free', 'google-maps-widget') . '</option>';
211
  }
212
  echo '</select></p>';
213
 
@@ -263,7 +263,7 @@ class GoogleMapsWidget extends WP_Widget {
263
  echo '</div><p></p>'; // tabs
264
 
265
  if (!GMW::is_activated()) {
266
- echo '<p><i>' . __('Subscribe to our newsletter and <a href="#" class="open_promo_dialog">get extra features</a> <b>for free</b>.', 'google-maps-widget') . '</i></p>';
267
  }
268
  } // form
269
 
175
  echo '<select class="gmw_thumb_color_scheme" id="' . $this->get_field_id('thumb_color_scheme') . '" name="' . $this->get_field_name('thumb_color_scheme') . '">';
176
  GMW::create_select_options($thumb_color_schemes, $thumb_color_scheme);
177
  if (!GMW::is_activated()) {
178
+ echo '<option class="promo" value="-1">' . __('Add more schemes for FREE', 'google-maps-widget') . '</option>';
179
  }
180
  echo '</select></p>';
181
 
207
  echo '<select class="gmw_lightbox_skin" id="' . $this->get_field_id('lightbox_skin') . '" name="' . $this->get_field_name('lightbox_skin') . '">';
208
  GMW::create_select_options($lightbox_skins, $lightbox_skin);
209
  if (!GMW::is_activated()) {
210
+ echo '<option class="promo" value="-1">' . __('Add more skins for FREE', 'google-maps-widget') . '</option>';
211
  }
212
  echo '</select></p>';
213
 
263
  echo '</div><p></p>'; // tabs
264
 
265
  if (!GMW::is_activated()) {
266
+ echo '<p>' . __('Click to <a href="#" class="open_promo_dialog">get extra premium features</a> for Google Maps Widget! For <b><span style="color: #d54e21;">FREE</span></b>.', 'google-maps-widget') . '</p>';
267
  }
268
  } // form
269
 
google-maps-widget.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Google Maps Widget
4
  Plugin URI: http://www.googlemapswidget.com/
5
  Description: Display a single-image super-fast loading Google map in a widget. A larger, full featured map is available on click in a lightbox. Includes shortcode support and numerous options.
6
  Author: Web factory Ltd
7
- Version: 2.30
8
  Author URI: http://www.webfactoryltd.com/
9
  Text Domain: google-maps-widget
10
  Domain Path: lang
@@ -40,7 +40,7 @@ require_once 'gmw-tracking.php';
40
 
41
 
42
  class GMW {
43
- static $version = 2.30;
44
 
45
  // hook everything up
46
  static function init() {
@@ -68,6 +68,12 @@ class GMW {
68
  // register AJAX endpoints
69
  add_action('wp_ajax_gmw_subscribe', array(__CLASS__, 'email_subscribe'));
70
  add_action('wp_ajax_gmw_activate', array(__CLASS__, 'activate_via_code'));
 
 
 
 
 
 
71
  } else {
72
  // enqueue frontend scripts
73
  add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'));
@@ -122,15 +128,15 @@ class GMW {
122
  // check if user has the minimal WP version required by the plugin
123
  static function check_wp_version($min_version) {
124
  if (!version_compare(get_bloginfo('version'), $min_version, '>=')) {
125
- add_action('admin_notices', array(__CLASS__, 'min_version_error'));
126
  }
127
  } // check_wp_version
128
 
129
 
130
  // display error message if WP version is too low
131
- static function min_version_error() {
132
  echo '<div class="error"><p>' . sprintf(__('Google Maps Widget <b>requires WordPress version 3.3</b> or higher to function properly. You are using WordPress version %s. Please <a href="%s">update it</a>.', 'google-maps-widget'), get_bloginfo('version'), admin_url('update-core.php')) . '</p></div>';
133
- } // min_version_error
134
 
135
 
136
  // print dialogs markup in footer
@@ -200,6 +206,64 @@ class GMW {
200
  } // notice_sc_conflict_error
201
 
202
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  // enqueue frontend scripts if necessary
204
  static function enqueue_scripts() {
205
  if (is_active_widget(false, false, 'googlemapswidget', true)) {
@@ -271,10 +335,10 @@ class GMW {
271
  }
272
 
273
  $out = '<div id="gmw_promo_dialog">';
274
- $out .= '<div id="gmw_dialog_subscribe"><div class="content"><h3 class="center">' . __('Subscribe to our newsletter<br>and get extra features &amp; options <b>for FREE</b>!', 'google-maps-widget') . '</h3>';
275
  $out .= '<p class="input_row"><input value="' . $name . '" type="text" id="gmw_name" name="gmw_name" placeholder="Your name"><span class="error name" style="display: none;">Please enter your name.</span></p>';
276
  $out .= '<p class="input_row"><input value="' . $current_user->user_email . '" type="text" name="gmw_email" id="gmw_email" placeholder="Your email address"><span style="display: none;" class="error email">Please double check your email address.</span></p>';
277
- $out .= '<p class="center"><a id="gmw_subscribe" href="#" class="button button-primary big-button">Subscribe &amp; activate extra features</a><br><a href="#" class="" id="gmw_already_subscribed">I\'m already subscribed</a></p></div>';
278
  $out .= '<div class="footer"><p><b>Why subscribe?</b></p><ul><li>We\'ll never share your email address</li><li>We won\'t spam you or overwhelm with emails</li><li>Be the first to get notified about new features</li><li>You\'ll get all future upgrades for free as well</li><li>You\'ll get discounts for our premium WP plugins</li></ul></div>';
279
  $out .= '</div>'; // dialog subscribe
280
  $out .= '<div id="gmw_dialog_activate"><div class="content"><h3 class="center">' . __('Enter your code and activate extra features', 'google-maps-widget') . '</h3>';
4
  Plugin URI: http://www.googlemapswidget.com/
5
  Description: Display a single-image super-fast loading Google map in a widget. A larger, full featured map is available on click in a lightbox. Includes shortcode support and numerous options.
6
  Author: Web factory Ltd
7
+ Version: 2.35
8
  Author URI: http://www.webfactoryltd.com/
9
  Text Domain: google-maps-widget
10
  Domain Path: lang
40
 
41
 
42
  class GMW {
43
+ static $version = 2.35;
44
 
45
  // hook everything up
46
  static function init() {
68
  // register AJAX endpoints
69
  add_action('wp_ajax_gmw_subscribe', array(__CLASS__, 'email_subscribe'));
70
  add_action('wp_ajax_gmw_activate', array(__CLASS__, 'activate_via_code'));
71
+
72
+ // handle dismiss button for all notices
73
+ add_action('admin_action_gmw_dismiss_notice', array(__CLASS__, 'dismiss_notice'));
74
+
75
+ // ask users to upgrade
76
+ self::upgrade_incentive();
77
  } else {
78
  // enqueue frontend scripts
79
  add_action('wp_enqueue_scripts', array(__CLASS__, 'enqueue_scripts'));
128
  // check if user has the minimal WP version required by the plugin
129
  static function check_wp_version($min_version) {
130
  if (!version_compare(get_bloginfo('version'), $min_version, '>=')) {
131
+ add_action('admin_notices', array(__CLASS__, 'notice_min_version_error'));
132
  }
133
  } // check_wp_version
134
 
135
 
136
  // display error message if WP version is too low
137
+ static function notice_min_version_error() {
138
  echo '<div class="error"><p>' . sprintf(__('Google Maps Widget <b>requires WordPress version 3.3</b> or higher to function properly. You are using WordPress version %s. Please <a href="%s">update it</a>.', 'google-maps-widget'), get_bloginfo('version'), admin_url('update-core.php')) . '</p></div>';
139
+ } // notice_min_version_error
140
 
141
 
142
  // print dialogs markup in footer
206
  } // notice_sc_conflict_error
207
 
208
 
209
+ // handle dismiss button for all notices
210
+ // todo - convert all notices
211
+ static function dismiss_notice() {
212
+ $options = get_option(GMW_OPTIONS, array());
213
+
214
+ if (isset($_GET['notice']) && $_GET['notice'] == 'upgrade') {
215
+ $options['dismiss_notice_upgrade'] = true;
216
+ update_option(GMW_OPTIONS, $options);
217
+ }
218
+
219
+ if ($_GET['redirect']) {
220
+ wp_redirect($_GET['redirect']);
221
+ } else {
222
+ wp_redirect(admin_url());
223
+ }
224
+ exit;
225
+ } // dismiss_notice
226
+
227
+
228
+ // maybe show upgrade notice
229
+ static function upgrade_incentive() {
230
+ $options = get_option(GMW_OPTIONS, array());
231
+
232
+ // if notice has already been dismissed - skip
233
+ if (isset($options['dismiss_notice_upgrade']) && $options['dismiss_notice_upgrade'] == true) {
234
+ return;
235
+ }
236
+
237
+ // if extra features are already active - skip
238
+ if (self::is_activated()) {
239
+ return;
240
+ }
241
+
242
+ // if there are no widgets and the plugin is used less than 3 days - skip
243
+ if (GMW_tracking::count_active_widgets() == 0 &&
244
+ (current_time('timestamp') - $options['first_install']) < (DAY_IN_SECONDS * 3)) {
245
+ return;
246
+ }
247
+
248
+ add_action('admin_notices', array(__CLASS__, 'notice_activate_extra_features'));
249
+ } // upgrade_incentive
250
+
251
+
252
+ // display message to get extra features for GMW
253
+ static function notice_activate_extra_features() {
254
+ $activate_url = admin_url('widgets.php?gmw_open_promo_dialog');
255
+ $dismiss_url = add_query_arg(array('action' => 'gmw_dismiss_notice', 'notice' => 'upgrade', 'redirect' => $_SERVER['REQUEST_URI']), admin_url('admin.php'));
256
+
257
+ // todo detect WP version and add support for "notice is-dismissible"
258
+ // todo remove style from HTML
259
+ echo '<div id="gmw_activate_notice" class="updated"><p>' . __('<b>Google Maps Widget</b> has extra premium features you can get for <b style="color: #d54e21;">FREE</b>. This is a limited time offer so act now!', 'google-maps-widget');
260
+
261
+ echo '<br /><a href="' . esc_url($activate_url) . '" style="vertical-align: baseline; margin-top: 15px;" class="button-primary">' . __('Activate premium features for <b>FREE</b>', 'google-maps-widget') . '</a>';
262
+ echo '&nbsp;&nbsp;<a href="' . esc_url($dismiss_url) . '" class="">' . __('Dismiss notice', 'google-maps-widget') . '</a>';
263
+ echo '</p></div>';
264
+ } // notice_activate_extra_features
265
+
266
+
267
  // enqueue frontend scripts if necessary
268
  static function enqueue_scripts() {
269
  if (is_active_widget(false, false, 'googlemapswidget', true)) {
335
  }
336
 
337
  $out = '<div id="gmw_promo_dialog">';
338
+ $out .= '<div id="gmw_dialog_subscribe"><div class="content"><h3 class="center">' . __('Fill out the form and<br>get extra features &amp; options <b>for FREE</b> instantly!', 'google-maps-widget') . '</h3>';
339
  $out .= '<p class="input_row"><input value="' . $name . '" type="text" id="gmw_name" name="gmw_name" placeholder="Your name"><span class="error name" style="display: none;">Please enter your name.</span></p>';
340
  $out .= '<p class="input_row"><input value="' . $current_user->user_email . '" type="text" name="gmw_email" id="gmw_email" placeholder="Your email address"><span style="display: none;" class="error email">Please double check your email address.</span></p>';
341
+ $out .= '<p class="center"><a id="gmw_subscribe" href="#" class="button button-primary big-button">Activate extra features</a><br><a href="#" class="" id="gmw_already_subscribed">I already have an activation code</a></p></div>';
342
  $out .= '<div class="footer"><p><b>Why subscribe?</b></p><ul><li>We\'ll never share your email address</li><li>We won\'t spam you or overwhelm with emails</li><li>Be the first to get notified about new features</li><li>You\'ll get all future upgrades for free as well</li><li>You\'ll get discounts for our premium WP plugins</li></ul></div>';
343
  $out .= '</div>'; // dialog subscribe
344
  $out .= '<div id="gmw_dialog_activate"><div class="content"><h3 class="center">' . __('Enter your code and activate extra features', 'google-maps-widget') . '</h3>';
js/gmw-admin.js CHANGED
@@ -4,6 +4,11 @@
4
  */
5
 
6
  jQuery(function($) {
 
 
 
 
 
7
  $('.gmw-tabs').each(function(i, el) {
8
  change_pin_type(el);
9
  change_link_type(el);
@@ -134,8 +139,11 @@ jQuery(function($) {
134
  alert(gmw.activate_ok);
135
  if ($('#gmw_promo_dialog').data('widget-id')) {
136
  $('#' + $('#gmw_promo_dialog').data('widget-id') + ' .widget-control-save').trigger('click');
 
 
 
 
137
  }
138
- $('#gmw_promo_dialog').dialog('close');
139
  } else {
140
  $('#gmw_promo_dialog span.error.gmw_code').show();
141
  $('#gmw_code').focus().select();
4
  */
5
 
6
  jQuery(function($) {
7
+ // open promo dialog on load
8
+ if (window.location.search.search('gmw_open_promo_dialog') != -1) {
9
+ gmw_open_promo_dialog();
10
+ }
11
+
12
  $('.gmw-tabs').each(function(i, el) {
13
  change_pin_type(el);
14
  change_link_type(el);
139
  alert(gmw.activate_ok);
140
  if ($('#gmw_promo_dialog').data('widget-id')) {
141
  $('#' + $('#gmw_promo_dialog').data('widget-id') + ' .widget-control-save').trigger('click');
142
+ $('#gmw_activate_notice').hide();
143
+ $('#gmw_promo_dialog').dialog('close');
144
+ } else {
145
+ window.location = 'widgets.php';
146
  }
 
147
  } else {
148
  $('#gmw_promo_dialog span.error.gmw_code').show();
149
  $('#gmw_code').focus().select();
readme.txt CHANGED
@@ -1,12 +1,11 @@
1
  === Google Maps Widget ===
2
  Contributors: WebFactory
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=gordan%40webfactoryltd%2ecom&lc=US&item_name=Google%20Maps%20Widget&no_note=0&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest
4
  Tags: google maps, maps, gmaps, widget, lightbox, map, google map, fancybox, fancybox2, multilingual, sidebar, chinese, shortcode, gmw, fast
5
  License: GPLv2 or later
6
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  Requires at least: 3.3
8
- Tested up to: 4.1
9
- Stable tag: 2.30
10
 
11
  Displays a single-image super-fast loading Google map in a widget. A larger map with all the usual features is available on click in a lightbox.
12
 
@@ -120,6 +119,13 @@ If you can't figure it out open a thread in the support forums.
120
  6. Widget options - info & support
121
 
122
  == Changelog ==
 
 
 
 
 
 
 
123
  = 2.30 =
124
  * 2015/03/02
125
  * JS rewrites
1
  === Google Maps Widget ===
2
  Contributors: WebFactory
 
3
  Tags: google maps, maps, gmaps, widget, lightbox, map, google map, fancybox, fancybox2, multilingual, sidebar, chinese, shortcode, gmw, fast
4
  License: GPLv2 or later
5
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
6
  Requires at least: 3.3
7
+ Tested up to: 4.2
8
+ Stable tag: 2.35
9
 
10
  Displays a single-image super-fast loading Google map in a widget. A larger map with all the usual features is available on click in a lightbox.
11
 
119
  6. Widget options - info & support
120
 
121
  == Changelog ==
122
+ = 2.35 =
123
+ * 2015/04/27
124
+ * few small bugs fixed
125
+ * WP v4.2 compatibility checked
126
+ * remove_query_arg() security issue fixed
127
+ * we broke 500,000 downloads ;)
128
+
129
  = 2.30 =
130
  * 2015/03/02
131
  * JS rewrites