Google Maps Widget – Ultimate Google Maps Plugin - Version 4.19

Version Description

  • 2020/10/09
  • minor fixes
  • added promo for WP 301 Redirects
Download this release

Release Info

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

Code changes from version 4.18 to 4.19

css/gmw-admin.css CHANGED
@@ -16,6 +16,18 @@ ul.normal {
16
  margin: 0 0 0 15px;
17
  }
18
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  .wrap.gmw-options .ui-tabs {
20
  margin-top: 30px;
21
  }
16
  margin: 0 0 0 15px;
17
  }
18
 
19
+ ol.normal {
20
+ padding: 5px 0;
21
+ margin: 0 0 0 15px;
22
+ display: inline-block;
23
+ }
24
+ ol.normal li {
25
+ background-color: transparent !important;
26
+ }
27
+ ol.normal li a {
28
+ padding: 0 !important;
29
+ }
30
+
31
  .wrap.gmw-options .ui-tabs {
32
  margin-top: 30px;
33
  }
gmw-widget.php CHANGED
@@ -203,10 +203,13 @@ class GoogleMapsWidget extends WP_Widget {
203
 
204
  // force update if activated
205
  if (GMW::is_activated()) {
206
- $plugin = plugin_basename(GMW_PLUGIN_DIR . GMW_BASE_FILE);
207
- $update_url = wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=' . urlencode($plugin)), 'upgrade-plugin_' . $plugin );
208
- echo '<p>Maps Widget for Google Maps <b class="gmw-pro-red">PRO</b> has been activated! Please <b>click the button below</b> to update plugin files to PRO version. Widget data is not lost and it will not get lost by updating.</p>';
209
- echo '<p><a href="' . esc_url($update_url) . '" class="button button-primary">Update Maps Widget for Google Maps</a></p>';
 
 
 
210
  echo '<style type="text/css"> #widget-' . $this->id . '-savewidget { display: none; } </style>';
211
  echo '<input id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="hidden" value="' . esc_attr($title) . '">';
212
 
203
 
204
  // force update if activated
205
  if (GMW::is_activated()) {
206
+ echo '<p>Maps Widget for Google Maps <b class="gmw-pro-red">PRO</b> has been activated!';
207
+ echo '<ol class="normal">
208
+ <li><a href="https://gmapswidget.com/pro-download/" target="_blank">Download</a> the PRO version ZIP file</li>
209
+ <li>Go to <a href="' . admin_url('plugin-install.php') . '">Plugins - Add New</a> and install the PRO version</li>
210
+ <li>When prompted, overwrite the free version with the PRO one</li>
211
+ <li>Create some maps ;)</li>
212
+ </ol>';
213
  echo '<style type="text/css"> #widget-' . $this->id . '-savewidget { display: none; } </style>';
214
  echo '<input id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="hidden" value="' . esc_attr($title) . '">';
215
 
google-maps-widget.php CHANGED
@@ -4,12 +4,15 @@ Plugin Name: Maps Widget for Google Maps
4
  Plugin URI: https://www.gmapswidget.com/
5
  Description: Display a single image super-fast loading Google Map in a widget. A larger, full featured map is available in a lightbox. Includes a user-friendly interface and numerous appearance options.
6
  Author: WebFactory Ltd
7
- Version: 4.18
8
  Author URI: https://www.gmapswidget.com/
9
  Text Domain: google-maps-widget
10
  Domain Path: lang
 
 
 
11
 
12
- Copyright 2012 - 2020 Web factory Ltd (email : gmw@webfactoryltd.com)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License, version 2, as
@@ -40,6 +43,9 @@ define('GMW_BASE_FILE', basename(__FILE__));
40
 
41
  require_once GMW_PLUGIN_DIR . 'gmw-widget.php';
42
 
 
 
 
43
  class GMW {
44
  static $version;
45
  static $options = 'gmw_options';
@@ -65,8 +71,6 @@ class GMW {
65
 
66
  // check a few variables
67
  GMW::maybe_upgrade();
68
- add_filter('pre_set_site_transient_update_plugins', array('GMW', 'update_filter'));
69
- add_filter('plugins_api', array('GMW', 'update_details'), 100, 3);
70
 
71
  // aditional links in plugin description
72
  add_filter('plugin_action_links_' . basename(dirname(__FILE__)) . '/' . basename(__FILE__),
@@ -880,11 +884,15 @@ class GMW {
880
  } else {
881
  $visible = '';
882
  }
883
- $plugin = plugin_basename(__FILE__);
884
- $update_url = wp_nonce_url(admin_url('update.php?action=upgrade-plugin&amp;plugin=' . urlencode($plugin)), 'upgrade-plugin_' . $plugin );
885
  $out .= '<div class="after_activate" ' . $visible . '>';
886
- $out .= '<p class="center">Thank you for purchasing Maps Widget for Google Maps <b class="gmw-pro-red">PRO</b>! Your license has been verified and activated.</p><p class="center">Please <b>click the button below</b> to update plugin files to PRO version.</p>';
887
- $out .= '<p class="center"><a href="' . esc_url($update_url) . '" class="button button-primary">Update Maps Widget for Google Maps</a></p>';
 
 
 
 
 
888
  $out .= '</div>';
889
 
890
  $out .= '</div>'; // content
@@ -1091,11 +1099,13 @@ class GMW {
1091
 
1092
  echo '<div id="gmw-license" style="display: none;">';
1093
  if (GMW::is_activated()) {
1094
- $plugin = plugin_basename(__FILE__);
1095
- $update_url = wp_nonce_url(admin_url('update.php?action=upgrade-plugin&amp;plugin=' . urlencode($plugin)), 'upgrade-plugin_' . $plugin );
1096
-
1097
- echo '<p>Your <b class="gmw-pro-red">PRO</b> license is validated &amp; active. Please update the plugin to activate PRO features. In case of any problems, contact <a href="mailto:gmw@webfactoryltd.com?subject=Update%20problem" title="Contact Maps Widget for Google Maps PRO support">support</a>.</p>';
1098
- echo '<p><a href="' . esc_url($update_url) . '" class="button button-primary">Update Maps Widget for Google Maps</a></p>';
 
 
1099
  } else {
1100
  echo '<p>If you already bought the <b class="gmw-pro-red">PRO</b> license please <a href="#" data-target-screen="gmw_dialog_activate" class="open_promo_dialog">enter your license key</a> to activate it.</p>';
1101
  echo '<p>Interested in a lifetime <b class="gmw-pro-red">PRO</b> license that offers more than 50 extra fetures?&nbsp;&nbsp; <a href="#" class="open_promo_dialog button button-primary">Upgrade now!</a></p>';
@@ -1124,7 +1134,6 @@ class GMW {
1124
  GMW::set_options(array('activation_code' => $code, 'license_active' => $tmp['license_active'], 'license_type' => $tmp['license_type'], 'license_expires' => $tmp['license_expires']));
1125
  }
1126
  if ($tmp['license_active'] && $tmp['success']) {
1127
- set_site_transient('update_plugins', null);
1128
  wp_send_json_success();
1129
  } else {
1130
  wp_send_json_error($tmp['error']);
@@ -1132,103 +1141,6 @@ class GMW {
1132
  } // activate_license_key_ajax
1133
 
1134
 
1135
- // get info on new plugin version if one exists
1136
- static function update_filter($current) {
1137
- if (!GMW::is_activated()) {
1138
- return $current;
1139
- }
1140
-
1141
- static $response = false;
1142
- $options = GMW::get_options();
1143
- $plugin = plugin_basename(__FILE__);
1144
-
1145
- if(empty($response) || is_wp_error($response)) {
1146
- $request_params = array('sslverify' => false, 'timeout' => 15, 'redirection' => 2);
1147
- $request_args = array('action' => 'update_info',
1148
- 'timestamp' => time(),
1149
- 'codebase' => 'free',
1150
- 'version' => GMW::$version,
1151
- 'code' => $options['activation_code'],
1152
- 'site' => get_home_url());
1153
-
1154
- $url = add_query_arg($request_args, GMW::$licensing_servers[0]);
1155
- $response = wp_remote_get(esc_url_raw($url), $request_params);
1156
-
1157
- if (is_wp_error($response)) {
1158
- $url = add_query_arg($request_args, GMW::$licensing_servers[1]);
1159
- $response = wp_remote_get(esc_url_raw($url), $request_params);
1160
- }
1161
- } // if !$response
1162
-
1163
- if (!is_wp_error($response) && wp_remote_retrieve_body($response)) {
1164
- $data = json_decode(wp_remote_retrieve_body($response), false);
1165
- if (empty($current)) {
1166
- $current = new stdClass();
1167
- }
1168
- if (empty($current->response)) {
1169
- $current->response = array();
1170
- }
1171
- if (!empty($data) && is_object($data)) {
1172
- $data->icons = (array) $data->icons;
1173
- $data->banners = (array) $data->banners;
1174
- $current->response[$plugin] = $data;
1175
- }
1176
- }
1177
-
1178
- return $current;
1179
- } // update_filter
1180
-
1181
-
1182
- // get plugin info for lightbox
1183
- static function update_details($false, $action, $args) {
1184
- if (!GMW::is_activated()) {
1185
- return false;
1186
- }
1187
-
1188
- static $response = false;
1189
- $options = self::get_options();
1190
- $plugin = basename(GMW_PLUGIN_DIR);
1191
-
1192
- if ($action != 'plugin_information' || empty($args->slug) || ($args->slug != $plugin)) {
1193
- return false;
1194
- }
1195
-
1196
- if(empty($response) || is_wp_error($response)) {
1197
- $request_params = array('sslverify' => false, 'timeout' => 15, 'redirection' => 2);
1198
- $request_args = array('action' => 'update_info',
1199
- 'request_details' => serialize($args),
1200
- 'codebase' => 'free',
1201
- 'timestamp' => time(),
1202
- 'version' => GMW::$version,
1203
- 'code' => $options['activation_code'],
1204
- 'site' => get_home_url());
1205
-
1206
- $url = add_query_arg($request_args, GMW::$licensing_servers[0]);
1207
- $response = wp_remote_get(esc_url_raw($url), $request_params);
1208
-
1209
- if (is_wp_error($response) || !wp_remote_retrieve_body($response)) {
1210
- $url = add_query_arg($request_args, GMW::$licensing_servers[1]);
1211
- $response = wp_remote_get(esc_url_raw($url), $request_params);
1212
- }
1213
- } // if !$response
1214
-
1215
- if (is_wp_error($response) || !wp_remote_retrieve_body($response)) {
1216
- $res = new WP_Error('plugins_api_failed', __('An unexpected HTTP error occurred during the API request.', 'google-maps-widget'), $response->get_error_message());
1217
- } else {
1218
- $res = json_decode(wp_remote_retrieve_body($response));
1219
-
1220
- if (!is_object($res)) {
1221
- $res = new WP_Error('plugins_api_failed', __('Invalid API respone.', 'google-maps-widget'), wp_remote_retrieve_body($response));
1222
- } else {
1223
- $res->sections = (array) $res->sections;
1224
- $res->banners = (array) $res->banners;
1225
- }
1226
- }
1227
-
1228
- return $res;
1229
- } // update_details
1230
-
1231
-
1232
  // helper function for creating dropdowns
1233
  static function create_select_options($options, $selected = null, $output = true) {
1234
  $out = "\n";
@@ -1313,12 +1225,6 @@ class GMW {
1313
  $options['first_install'] = current_time('timestamp');
1314
  GMW::set_options($options);
1315
  }
1316
-
1317
- // force plugin update for PRO users
1318
- if (!get_site_transient('gmw_update_plugins') && $options['first_version'] != GMW::$version && GMW::is_activated()) {
1319
- set_site_transient('update_plugins', null);
1320
- set_site_transient('gmw_update_plugins', true, WEEK_IN_SECONDS);
1321
- }
1322
  } // maybe_upgrade
1323
 
1324
 
@@ -1432,7 +1338,7 @@ class GMW {
1432
  static function uninstall() {
1433
  // at the moment, due to lite/pro upgrade we never delete options
1434
  $options = GMW::get_options();
1435
-
1436
  if (isset($options['allow_tracking']) && $options['allow_tracking'] === true) {
1437
  wp_clear_scheduled_hook('gmw_biweekly_cron');
1438
  }
4
  Plugin URI: https://www.gmapswidget.com/
5
  Description: Display a single image super-fast loading Google Map in a widget. A larger, full featured map is available in a lightbox. Includes a user-friendly interface and numerous appearance options.
6
  Author: WebFactory Ltd
7
+ Version: 4.19
8
  Author URI: https://www.gmapswidget.com/
9
  Text Domain: google-maps-widget
10
  Domain Path: lang
11
+ Requires at least: 4.0
12
+ Requires PHP: 5.2
13
+ Tested up to: 5.6
14
 
15
+ Copyright 2012 - 2020 WebFactory Ltd (email : gmw@webfactoryltd.com)
16
 
17
  This program is free software; you can redistribute it and/or modify
18
  it under the terms of the GNU General Public License, version 2, as
43
 
44
  require_once GMW_PLUGIN_DIR . 'gmw-widget.php';
45
 
46
+ require_once GMW_PLUGIN_DIR . 'wp301/wp301.php';
47
+ new wf_wp301(__FILE__, 'settings_page_gmw_options');
48
+
49
  class GMW {
50
  static $version;
51
  static $options = 'gmw_options';
71
 
72
  // check a few variables
73
  GMW::maybe_upgrade();
 
 
74
 
75
  // aditional links in plugin description
76
  add_filter('plugin_action_links_' . basename(dirname(__FILE__)) . '/' . basename(__FILE__),
884
  } else {
885
  $visible = '';
886
  }
887
+
 
888
  $out .= '<div class="after_activate" ' . $visible . '>';
889
+ $out .= '<p class="center">Thank you for purchasing Maps Widget for Google Maps <b class="gmw-pro-red">PRO</b>! Your license has been verified.</p>';
890
+ $out .= '<ol class="gmw-faq-ul">
891
+ <li><a href="https://gmapswidget.com/pro-download/" target="_blank">Download</a> the PRO version ZIP file</li>
892
+ <li>Go to <a href="' . admin_url('plugin-install.php') . '">Plugins - Add New</a> and install the PRO version</li>
893
+ <li>When prompted, overwrite the free version with the PRO one</li>
894
+ <li>Create some maps ;)</li>
895
+ </ol>';
896
  $out .= '</div>';
897
 
898
  $out .= '</div>'; // content
1099
 
1100
  echo '<div id="gmw-license" style="display: none;">';
1101
  if (GMW::is_activated()) {
1102
+ echo '<p>Your <b class="gmw-pro-red">PRO</b> license is validated.';
1103
+ echo '<ol class="normal">
1104
+ <li><a href="https://gmapswidget.com/pro-download/" target="_blank">Download</a> the PRO version ZIP file</li>
1105
+ <li>Go to <a href="' . admin_url('plugin-install.php') . '">Plugins - Add New</a> and install the PRO version</li>
1106
+ <li>When prompted, overwrite the free version with the PRO one</li>
1107
+ <li>Create some maps ;)</li>
1108
+ </ol>';
1109
  } else {
1110
  echo '<p>If you already bought the <b class="gmw-pro-red">PRO</b> license please <a href="#" data-target-screen="gmw_dialog_activate" class="open_promo_dialog">enter your license key</a> to activate it.</p>';
1111
  echo '<p>Interested in a lifetime <b class="gmw-pro-red">PRO</b> license that offers more than 50 extra fetures?&nbsp;&nbsp; <a href="#" class="open_promo_dialog button button-primary">Upgrade now!</a></p>';
1134
  GMW::set_options(array('activation_code' => $code, 'license_active' => $tmp['license_active'], 'license_type' => $tmp['license_type'], 'license_expires' => $tmp['license_expires']));
1135
  }
1136
  if ($tmp['license_active'] && $tmp['success']) {
 
1137
  wp_send_json_success();
1138
  } else {
1139
  wp_send_json_error($tmp['error']);
1141
  } // activate_license_key_ajax
1142
 
1143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1144
  // helper function for creating dropdowns
1145
  static function create_select_options($options, $selected = null, $output = true) {
1146
  $out = "\n";
1225
  $options['first_install'] = current_time('timestamp');
1226
  GMW::set_options($options);
1227
  }
 
 
 
 
 
 
1228
  } // maybe_upgrade
1229
 
1230
 
1338
  static function uninstall() {
1339
  // at the moment, due to lite/pro upgrade we never delete options
1340
  $options = GMW::get_options();
1341
+
1342
  if (isset($options['allow_tracking']) && $options['allow_tracking'] === true) {
1343
  wp_clear_scheduled_hook('gmw_biweekly_cron');
1344
  }
readme.txt CHANGED
@@ -4,8 +4,8 @@ Tags: google maps, maps, map, google map, google maps widget, map markers, wp go
4
  License: GPLv2 or later
5
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
6
  Requires at least: 4.0
7
- Tested up to: 5.5
8
- Stable tag: 4.18
9
  Requires PHP: 5.2
10
 
11
  Are your Google Maps slow? Try Map Widget for Google Maps. You'll have a fast Google Maps widget with a thumbnail & lightbox map in minutes!
@@ -181,6 +181,11 @@ Try <a href="http://www.niftymaps.co">Nifty Maps</a> - a comprehensive Map Build
181
 
182
  == Changelog ==
183
 
 
 
 
 
 
184
  = 4.18 =
185
  * 2020/09/16
186
  * minor fixes
4
  License: GPLv2 or later
5
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
6
  Requires at least: 4.0
7
+ Tested up to: 5.6
8
+ Stable tag: 4.19
9
  Requires PHP: 5.2
10
 
11
  Are your Google Maps slow? Try Map Widget for Google Maps. You'll have a fast Google Maps widget with a thumbnail & lightbox map in minutes!
181
 
182
  == Changelog ==
183
 
184
+ = 4.19 =
185
+ * 2020/10/09
186
+ * minor fixes
187
+ * added promo for WP 301 Redirects
188
+
189
  = 4.18 =
190
  * 2020/09/16
191
  * minor fixes
wp301/wp301-logo.png ADDED
Binary file
wp301/wp301.js ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Campaign for WP 301 Redirects PRO
3
+ * (c) WebFactory Ltd, 2020
4
+ */
5
+
6
+ jQuery(document).ready(function ($) {
7
+ $('#wp301promo_dismiss').on('click', function (e) {
8
+ e.preventDefault();
9
+
10
+ var slug = $(this).data('plugin-slug');
11
+
12
+ $.get({
13
+ url: ajaxurl,
14
+ data: {
15
+ action: 'wp301_promo_dismiss',
16
+ slug: slug,
17
+ _ajax_nonce: wp301_promo.nonce_wp301_promo_dismiss,
18
+ },
19
+ })
20
+ .always(function (data) {})
21
+ .done(function (data) {
22
+ if (data.success) {
23
+ if (slug == 'dashboard') {
24
+ $('#wp301promo_widget').hide();
25
+ } else {
26
+ $('#wp301-dialog').dialog('close');
27
+ }
28
+ } else {
29
+ alert('Sorry, something is not right. Please reload the page and try again.');
30
+ }
31
+ })
32
+ .fail(function (data) {
33
+ alert('Sorry, something is not right. Please reload the page and try again.');
34
+ });
35
+ }); // dismiss
36
+
37
+
38
+ $('#wp301promo_submit').on('click', function (e) {
39
+ e.preventDefault();
40
+
41
+ var btn = $('#wp301promo_submit');
42
+ var name = $('#wp301promo_name').val();
43
+ var email = $('#wp301promo_email').val();
44
+ var plugin = $('#wp301promo_plugin').val();
45
+ var position = $('#wp301promo_position').val();
46
+ var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
47
+
48
+ if (name.length < 2 || name.length > 128) {
49
+ $('#wp301promo_name').focus();
50
+ alert('Please enter your name. Thank you 👍');
51
+ return false;
52
+ }
53
+ if (!regex.test(email) || email.lenght > 128) {
54
+ $('#wp301promo_email').focus();
55
+ alert('Please enter a valid email address. Thank you 👍');
56
+ return false;
57
+ }
58
+
59
+ $(btn).addClass('disabled');
60
+ $.get({
61
+ url: ajaxurl,
62
+ data: {
63
+ action: 'wp301_promo_submit',
64
+ _ajax_nonce: wp301_promo.nonce_wp301_promo_submit,
65
+ name: name,
66
+ email: email,
67
+ position: position,
68
+ plugin: plugin,
69
+ },
70
+ })
71
+ .always(function (data) {
72
+ $(btn).removeClass('disabled');
73
+ })
74
+ .done(function (data) {
75
+ if (data.success) {
76
+ alert(data.data);
77
+
78
+ if (position == 'dashboard') {
79
+ $('#wp301promo_widget').hide();
80
+ } else {
81
+ $('#wp301-dialog').dialog('close');
82
+ }
83
+ } else {
84
+ alert(data.data);
85
+ }
86
+ })
87
+ .fail(function (data) {
88
+ alert('Sorry, something is not right. Please reload the page and try again.');
89
+ });
90
+ });
91
+
92
+
93
+ $('#wp301promo_name, #wp301promo_email').on('keypress', function (e) {
94
+ if (e.which == 13) {
95
+ $('#wp301promo_submit').trigger('click');
96
+ }
97
+ }); // on enter
98
+
99
+
100
+ if (wp301_promo.open_popup && $('#wp301-dialog').length == 1) {
101
+ $('#wp301-dialog').dialog({
102
+ dialogClass: 'wp-dialog wp301-dialog',
103
+ modal: true,
104
+ resizable: false,
105
+ width: 550,
106
+ height: 'auto',
107
+ show: 'fade',
108
+ hide: 'fade',
109
+ close: function (event, ui) {},
110
+ open: function (event, ui) {
111
+ $(this)
112
+ .siblings()
113
+ .find('span.ui-dialog-title')
114
+ .html('Get a WP 301 Redirects PRO license for FREE <del>$158</del>');
115
+ wp301_fix_dialog_close(event, ui);
116
+ },
117
+ autoOpen: true,
118
+ closeOnEscape: false,
119
+ });
120
+ } // open dialog
121
+ }); // jQuery ready
122
+
123
+
124
+ function wp301_fix_dialog_close(event, ui) {
125
+ jQuery('.ui-widget-overlay').bind('click', function () {
126
+ jQuery('#' + event.target.id).dialog('close');
127
+ });
128
+ } // wp301_fix_dialog_close
wp301/wp301.php ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Campaign for WP 301 Redirects PRO
5
+ * (c) WebFactory Ltd, 2020
6
+ */
7
+
8
+
9
+ if (false == class_exists('wf_wp301')) {
10
+ class wf_wp301
11
+ {
12
+ var $plugin_file = '';
13
+ var $plugin_slug = '';
14
+ var $plugin_screen = '';
15
+ var $options = '';
16
+ var $disable_dashboard = false;
17
+
18
+
19
+ function __construct($plugin_file, $plugin_screen)
20
+ {
21
+ $this->plugin_file = $plugin_file;
22
+ $this->plugin_slug = basename(dirname($plugin_file));
23
+ $this->plugin_screen = $plugin_screen;
24
+ $this->options = get_option('wp301promo', array());
25
+
26
+ if (!is_admin() || !empty($this->options['email_submitted']) || date('Y-m-d') > '2020-11-05') {
27
+ return;
28
+ } else {
29
+ add_action('admin_init', array($this, 'init'));
30
+ }
31
+ } // __construct
32
+
33
+
34
+ function init()
35
+ {
36
+ add_action('wp_dashboard_setup', array($this, 'add_widget'));
37
+ add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
38
+ add_action('wp_ajax_wp301_promo_submit', array($this, 'ajax_submit'));
39
+ add_action('wp_ajax_wp301_promo_dismiss', array($this, 'ajax_dismiss'));
40
+ add_action('admin_footer', array($this, 'admin_footer'));
41
+ } // init
42
+
43
+
44
+ function admin_enqueue_scripts()
45
+ {
46
+ $screen = get_current_screen();
47
+
48
+ if ($screen->base != 'dashboard' && $screen->id != $this->plugin_screen) {
49
+ return;
50
+ }
51
+
52
+ if ($screen->base == 'dashboard' && (!empty($this->options['popup_dismissed_dashboard']) || !empty($this->disable_dashboard))) {
53
+ return;
54
+ }
55
+
56
+ if ($screen->id == $this->plugin_screen) {
57
+ wp_enqueue_style('wp-jquery-ui-dialog');
58
+ wp_enqueue_script('jquery-ui-dialog');
59
+ }
60
+
61
+ wp_enqueue_script('wp301_promo', plugin_dir_url($this->plugin_file) . 'wp301/wp301.js');
62
+
63
+ $js_vars = array(
64
+ 'nonce_wp301_promo_submit' => wp_create_nonce('wp301_submit'),
65
+ 'nonce_wp301_promo_dismiss' => wp_create_nonce('wp301_dismiss'),
66
+ );
67
+
68
+ if (empty($this->options['popup_dismissed_' . $this->plugin_slug])) {
69
+ $js_vars['open_popup'] = true;
70
+ }
71
+
72
+ wp_localize_script('wp301_promo', 'wp301_promo', $js_vars);
73
+ } // admin_enqueue_scripts
74
+
75
+
76
+ function ajax_dismiss()
77
+ {
78
+ if (!wp_verify_nonce(@$_GET['_ajax_nonce'], 'wp301_dismiss')) {
79
+ wp_send_json_error('Something is not right. Please reload the page and try again.');
80
+ }
81
+
82
+ $slug = substr(strip_tags(trim(@$_GET['slug'])), 0, 64);
83
+
84
+ $this->options['popup_dismissed_' . $slug] = true;
85
+ $tmp = update_option('wp301promo', $this->options);
86
+
87
+ if ($tmp) {
88
+ wp_send_json_success();
89
+ } else {
90
+ wp_send_json_error();
91
+ }
92
+ } // ajax_dismiss
93
+
94
+
95
+ function ajax_submit()
96
+ {
97
+ if (!wp_verify_nonce(@$_GET['_ajax_nonce'], 'wp301_submit')) {
98
+ wp_send_json_error('Something is not right. Please reload the page and try again.');
99
+ }
100
+
101
+ $email = strip_tags(trim(@$_GET['email']));
102
+ $name = strip_tags(trim(@$_GET['name']));
103
+ $plugin = strip_tags(trim(@$_GET['plugin'])) . '-' . strip_tags(trim(@$_GET['position']));
104
+
105
+ if (!is_email($email)) {
106
+ wp_send_json_error('Please enter a valid email address.');
107
+ }
108
+
109
+ $url = add_query_arg(array('name' => $name, 'email' => $email, 'plugin' => $plugin), 'https://wp301redirects.com/subscribe/');
110
+
111
+ $response = wp_remote_get($url, array('timeout' => 25));
112
+
113
+ if (is_wp_error($response)) {
114
+ wp_send_json_error('Something is not right. Please reload the page and try again.');
115
+ }
116
+
117
+ $body = @json_decode(wp_remote_retrieve_body($response), true);
118
+ if (empty($body['success'])) {
119
+ wp_send_json_error('Something is not right. Please reload the page and try again.');
120
+ }
121
+
122
+ $this->options['email_submitted'] = true;
123
+ update_option('wp301promo', $this->options);
124
+ wp_send_json_success('Thank you for trusting us with your email! You\'ll hear from us soon 🚀');
125
+ } // ajax_submit
126
+
127
+
128
+ function add_widget()
129
+ {
130
+ if (!empty($this->options['popup_dismissed_dashboard']) || !empty($this->disable_dashboard)) {
131
+ return;
132
+ }
133
+
134
+ add_meta_box('wp301promo_widget', 'Get a WP 301 Redirects PRO license for FREE <del>$158</del>', array($this, 'widget_content'), 'dashboard', 'side', 'high');
135
+ } // add_widget
136
+
137
+
138
+ function widget_content()
139
+ {
140
+ $out = '';
141
+
142
+ $out .= '<style>';
143
+ $out .= '#wp301promo_widget .disabled { pointer-events: none; }';
144
+ $out .= '#wp301promo_widget label { font-weight: normal; display: inline-block; width: 15%; margin-bottom: 10px; }';
145
+ $out .= '#wp301promo_widget input { width: 74%; margin-bottom: 10px; }';
146
+ $out .= '#wp301promo_widget .button-primary { padding: 14px 28px; text-decoration: none; line-height: 1; }';
147
+ $out .= '#wp301promo_dismiss { font-style: italic; display: inline-block; color: #444; text-decoration: none; margin: 8px 0 0 0; }';
148
+ $out .= '#wp301promo_dismiss:hover { text-decoration: underline; }';
149
+ $out .= '#wp301promo_widget, #wp301promo_widget p { font-size: 14px; }';
150
+ $out .= '#wp301promo_widget .title301 { font-weight: 600; margin: 10px 0 -10px 0; }';
151
+ $out .= '#wp301promo_widget img { max-width: 50%; max-height: 80px; }';
152
+ $out .= '#wp301promo_widget .center { text-align: center; }';
153
+ $out .= '#wp301promo_email { margin-bottom: 0 !important; }';
154
+ $out .= '#wp301promo_widget { background-color: #fafafa; }';
155
+ $out .= '#wp301promo_widget li a { text-decoration: underline; }';
156
+ $out .= '#wp301promo_widget .wp301inside { padding: 25px 12px 0px 12px; position: relative; }';
157
+ $out .= '#wp301promo_widget p { margin-top: 14px; line-height: 1.5; }';
158
+ $out .= '#wp301promo_widget small { margin-left: 17%; }';
159
+ $out .= '#wp301promo_widget ul { font-size: 14px; margin: 0 0 20px 0; list-style-type: disc; list-style-position: inside; }';
160
+ $out .= '#wp301promo_widget li { margin-bottom: 3px; }';
161
+ $out .= '#wp301promo_submit span { display: none; text-decoration: none; margin-right: 10px; animation: wf-spin-animation 1.5s infinite linear; }';
162
+ $out .= '#wp301promo_submit.disabled span { display: inline-block; }';
163
+ $out .= '@keyframes wf-spin-animation {
164
+ from { transform: rotate(0deg); }
165
+ to { transform: rotate(360deg); }
166
+ }';
167
+ $out .= '#wp301promo_widget .inside { overflow: hidden; margin: 0; }
168
+ #wp301promo_widget .ribbon { margin: 0; padding: 11px 20px 10px 20px; background: #007cba; color: #FFF; font-weight: 800; position: absolute; top: -17px; right: -17px; transform: translateX(30%) translateY(0%) rotate(45deg); transform-origin: top left; letter-spacing: 1px; }
169
+ #wp301promo_widget .ribbon:before, #wp301promo_widget .ribbon:after { content: ""; position: absolute; top:0; margin: 0 -1px; width: 100%; height: 100%; background: #007cba; }
170
+ #wp301promo_widget .ribbon:before { right:100%; }
171
+ #wp301promo_widget .ribbon:after { left:100%; }';
172
+ $out .= '</style>';
173
+
174
+ $plugin_url = plugin_dir_url($this->plugin_file);
175
+
176
+ $out .= '<div class="ribbon">FREE</div>';
177
+ $out .= '<div class="wp301inside">';
178
+
179
+ $out .= '<div class="center"><a href="https://wp301redirects.com/free-license/?ref=free-' . $this->plugin_slug . '-dashboard" target="_blank"><img src="' . $plugin_url . 'wp301/wp301-logo.png' . '" alt="WP 301 Redirects PRO" title="WP 301 Redirects PRO"></a></div>';
180
+
181
+ $out .= '<p>On November 6th <a href="https://www.webfactoryltd.com/" target="_blank">WebFactory Ltd</a> will give away a limited number of lifetime WP 301 Redirect PRO licenses, <b>each for 10 sites</b>. A $158 retail value! 🚀 Leave your email, we\'ll send you a link &amp; download your copy.</p><p style="margin-bottom: 0;"><b>What do I get?</b></p>';
182
+
183
+ $out .= '<ul>';
184
+ $out .= '<li>Automatically fix 404 errors &amp; URL typos</li>';
185
+ $out .= '<li>Create advanced redirect rules &amp; control affiliate links</li>';
186
+ $out .= '<li>Detailed log of all redirects &amp; 404s</li>';
187
+ $out .= '<li>Manage all sites\' licenses from a central Dashboard</li>';
188
+ $out .= '<li>Lifetime license for 10 sites. <a href="https://wp301redirects.com/free-license/?ref=free-' . $this->plugin_slug . '-dashboard" target="_blank">See all features</a></li>';
189
+ $out .= '</ul>';
190
+
191
+ $out .= '
192
+ <div>
193
+ <label for="wp301promo_name">Name:</label>
194
+ <input type="text" name="wp301promo_name" id="wp301promo_name" placeholder="How shall we call you?"><br>
195
+ <label for="wp301promo_email">Email:</label>
196
+ <input type="text" name="wp301promo_email" id="wp301promo_email" placeholder="Your best email address to get the plugin"><br>
197
+ <small>We hate spam as much as you do and never send it!</small>
198
+ <input type="hidden" id="wp301promo_plugin" value="' . $this->plugin_slug . '">
199
+ <input type="hidden" id="wp301promo_position" value="dashboard">
200
+ </div>
201
+
202
+ <p class="center">
203
+ <a id="wp301promo_submit" class="button button-primary" href="#"><span class="dashicons dashicons-update"></span>I Want My FREE License <del>$158</del></a><br>
204
+ <a id="wp301promo_dismiss" class="" href="#" data-plugin-slug="dashboard">I don\'t want a free license; don\'t show this again</a>
205
+ </p>
206
+ </div>';
207
+
208
+ echo $out;
209
+ } // widget_content
210
+
211
+
212
+ function admin_footer()
213
+ {
214
+ $screen = get_current_screen();
215
+ if ($screen->id != $this->plugin_screen) {
216
+ return;
217
+ }
218
+
219
+ $out = '';
220
+
221
+ $out .= '<style>';
222
+ $out .= '#wp301promo_widget .disabled { pointer-events: none; }';
223
+ $out .= '.wp301-dialog .ui-dialog-titlebar-close { visibility: hidden; }';
224
+ $out .= '#wp301-dialog label { font-weight: normal; display: inline-block; width: 15%; margin-bottom: 10px; }';
225
+ $out .= '#wp301-dialog input { width: 74%; margin-bottom: 10px; }';
226
+ $out .= '#wp301-dialog .button-primary { padding: 14px 28px; text-decoration: none; line-height: 1; }';
227
+ $out .= '#wp301-dialog, #wp301-dialog p { font-size: 14px; }';
228
+ $out .= '#wp301-dialog .title301 { font-size: 1.3em; font-weight: 600; margin: 10px 0 -10px 0; }';
229
+ $out .= '#wp301-dialog img { max-width: 60%; }';
230
+ $out .= '#wp301-dialog li a { text-decoration: underline; }';
231
+ $out .= '#wp301-dialog small { margin-left: 16%; }';
232
+ $out .= '#wp301-dialog .center { text-align: center; }';
233
+ $out .= '#wp301-dialog, .wp301-dialog .ui-dialog-titlebar { background-color: #fafafa; }';
234
+ $out .= '#wp301-dialog .wp301inside { padding: 12px 12px 0px 12px; }';
235
+ $out .= '#wp301-dialog p { margin-top: 14px; line-height: 1.5; }';
236
+ $out .= '#wp301-dialog ul { margin: 0 0 20px 0; list-style-type: disc; list-style-position: inside; }';
237
+ $out .= '#wp301-dialog li { margin-bottom: 3px; }';
238
+ $out .= '#wp301promo_dismiss { display: inline-block; color: #444; text-decoration: none; margin: 8px 0 0 0; }';
239
+ $out .= '#wp301promo_dismiss:hover { text-decoration: underline; }';
240
+ $out .= '#wp301promo_submit span { display: none; text-decoration: none; margin-right: 10px; animation: wf-spin-animation 1.5s infinite linear; }';
241
+ $out .= '#wp301promo_submit.disabled span { display: inline-block; }';
242
+ $out .= '@keyframes wf-spin-animation {
243
+ from { transform: rotate(0deg); }
244
+ to { transform: rotate(360deg); }
245
+ }';
246
+ $out .= '#wp301-dialog .inside { overflow: hidden; margin: 0; }
247
+ #wp301-dialog .ribbon { margin: 0; padding: 11px 20px 10px 20px; background: #007cba; color: #FFF; font-weight: 800; position: absolute; top: -17px; right: -17px; transform: translateX(30%) translateY(0%) rotate(45deg); transform-origin: top left; letter-spacing: 1px; }
248
+ #wp301-dialog .ribbon:before, #wp301-dialog .ribbon:after { content: ""; position: absolute; top:0; margin: 0 -1px; width: 100%; height: 100%; background: #007cba; }
249
+ #wp301-dialog .ribbon:before { right:100%; }
250
+ #wp301-dialog .ribbon:after { left:100%; }';
251
+ $out .= '</style>';
252
+
253
+ $out .= '<div id="wp301-dialog" style="display: none;" title="Get a WP 301 Redirects PRO license for FREE"><span class="ui-helper-hidden-accessible"><input type="text"/></span>';
254
+
255
+ $plugin_url = plugin_dir_url($this->plugin_file);
256
+
257
+ $out .= '<div class="wp301inside">';
258
+ $out .= '<div class="ribbon">FREE</div>';
259
+
260
+ $out .= '<div class="center"><a href="https://wp301redirects.com/free-license/?ref=free-' . $this->plugin_slug . '-popup" target="_blank"><img src="' . $plugin_url . 'wp301/wp301-logo.png' . '" alt="WP 301 Redirects PRO" title="WP 301 Redirects PRO"></a></div>';
261
+
262
+ $out .= '<p>On November 6th <a href="https://www.webfactoryltd.com/" target="_blank">WebFactory Ltd</a> will give away a limited number of lifetime WP 301 Redirect PRO licenses, <b>each for 10 sites</b>. A $158 retail value! 🚀 Leave your email, we\'ll send you a link &amp; download your copy.</p><p style="margin-bottom: 0;"><b>What do I get?</b></p>';
263
+
264
+ $out .= '<ul>';
265
+ $out .= '<li>Automatically fix 404 errors &amp; URL typos</li>';
266
+ $out .= '<li>Create advanced redirect rules &amp; control affiliate links</li>';
267
+ $out .= '<li>Detailed log of all redirects &amp; 404s</li>';
268
+ $out .= '<li>Manage all sites\' licenses from a central Dashboard</li>';
269
+ $out .= '<li>Lifetime license for 10 sites. <a href="https://wp301redirects.com/free-license/?ref=free-' . $this->plugin_slug . '-dashboard" target="_blank">See all features</a></li>';
270
+ $out .= '</ul>';
271
+
272
+ $out .= '
273
+ <div>
274
+ <label for="wp301promo_name">Name:</label>
275
+ <input type="text" name="wp301promo_name" id="wp301promo_name" placeholder="How shall we call you?"><br>
276
+ <label for="wp301promo_email">Email:</label>
277
+ <input type="text" name="wp301promo_email" id="wp301promo_email" placeholder="Your best email address to get the plugin"><br>
278
+ <small>We hate spam as much as you do and never send it!</small>
279
+ <input type="hidden" id="wp301promo_plugin" value="' . $this->plugin_slug . '">
280
+ <input type="hidden" id="wp301promo_position" value="popup">
281
+ </div>
282
+
283
+ <p class="center">
284
+ <a id="wp301promo_submit" class="button button-primary" href="#"><span class="dashicons dashicons-update"></span>I Want My FREE License <del>$158</del></a><br>
285
+ <a id="wp301promo_dismiss" class="" href="#" data-plugin-slug="' . $this->plugin_slug . '">I don\'t want a free license; don\'t show this again</a>
286
+ </p>
287
+
288
+ </div>';
289
+
290
+ $out .= '</div>';
291
+
292
+ echo $out;
293
+ } // wp_footer
294
+ } // wf_wp301
295
+ }