Official MailerLite Sign Up Forms - Version 1.5.3

Version Description

  • Update - API update
  • Tested up to latest WP version
Download this release

Release Info

Developer mailerlite
Plugin Icon 128x128 Official MailerLite Sign Up Forms
Version 1.5.3
Comparing to
See all releases

Code changes from version 1.5.2 to 1.5.3

assets/css/mailerlite.css CHANGED
@@ -117,4 +117,12 @@ p.success {
117
  flex-basis: 0;
118
  flex-grow: 1;
119
  }
 
 
 
 
 
 
 
 
120
  }
117
  flex-basis: 0;
118
  flex-grow: 1;
119
  }
120
+ }
121
+
122
+ .ml_unavailable, .ml_unavailable input {
123
+ cursor: default;
124
+ }
125
+
126
+ .ml_unavailable img {
127
+ opacity: 0.5;
128
  }
assets/js/mailerlite_block.js CHANGED
@@ -38,7 +38,7 @@
38
 
39
  blocks.registerBlockType( 'mailerlite/form-block', {
40
 
41
- title: __('MailerLite sign up form', 'mailerlite'),
42
  icon: icon,
43
  category: 'widgets',
44
  attributes: {
@@ -194,7 +194,7 @@
194
  label: element.createElement(
195
  'h3',
196
  null,
197
- __('MailerLite sign up form', 'mailerlite')
198
  )
199
  },
200
  ! loaded ? showSpinner() : forms.length !== 0 ? renderEditWithForms() : renderEditWithoutForms()
38
 
39
  blocks.registerBlockType( 'mailerlite/form-block', {
40
 
41
+ title: __('MailerLite signup form', 'mailerlite'),
42
  icon: icon,
43
  category: 'widgets',
44
  attributes: {
194
  label: element.createElement(
195
  'h3',
196
  null,
197
+ __('MailerLite signup form', 'mailerlite')
198
  )
199
  },
200
  ! loaded ? showSpinner() : forms.length !== 0 ? renderEditWithForms() : renderEditWithoutForms()
languages/mailerlite-en_US.po CHANGED
@@ -31,13 +31,13 @@ msgstr "Wrong data provided"
31
 
32
  # @ mailerlite
33
  #: include/mailerlite-widget.php:16
34
- msgid "Mailerlite sign up form"
35
- msgstr "Mailerlite sign up form"
36
 
37
  # @ mailerlite
38
  #: include/mailerlite-widget.php:18
39
- msgid "MailerLite sign up form Widget"
40
- msgstr "MailerLite sign up form Widget"
41
 
42
  # @ mailerlite
43
  #: include/mailerlite-widget.php:85
31
 
32
  # @ mailerlite
33
  #: include/mailerlite-widget.php:16
34
+ msgid "Mailerlite signup form"
35
+ msgstr "Mailerlite signup form"
36
 
37
  # @ mailerlite
38
  #: include/mailerlite-widget.php:18
39
+ msgid "MailerLite signup form Widget"
40
+ msgstr "MailerLite signup form Widget"
41
 
42
  # @ mailerlite
43
  #: include/mailerlite-widget.php:85
languages/mailerlite-lt_LT.po CHANGED
@@ -1,6 +1,6 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: Official MailerLite sign up forms v1.0\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2019-01-28 10:27+0000\n"
6
  "PO-Revision-Date: 2019-01-28 10:28+0000\n"
@@ -50,12 +50,12 @@ msgid "Wrong data provided"
50
  msgstr "Neteisinga informacija"
51
 
52
  #: include/mailerlite-widget.php:16
53
- msgid "MailerLite sign up form"
54
  msgstr "MailerLite prenumeratos forma"
55
 
56
  # @ mailerlite
57
  #: include/mailerlite-widget.php:18
58
- msgid "MailerLite sign up form Widget"
59
  msgstr "MailerLite naujienlaiškio formos skydelis"
60
 
61
  # @ mailerlite
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: Official MailerLite signup forms v1.0\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: 2019-01-28 10:27+0000\n"
6
  "PO-Revision-Date: 2019-01-28 10:28+0000\n"
50
  msgstr "Neteisinga informacija"
51
 
52
  #: include/mailerlite-widget.php:16
53
+ msgid "MailerLite signup form"
54
  msgstr "MailerLite prenumeratos forma"
55
 
56
  # @ mailerlite
57
  #: include/mailerlite-widget.php:18
58
+ msgid "MailerLite signup form Widget"
59
  msgstr "MailerLite naujienlaiškio formos skydelis"
60
 
61
  # @ mailerlite
languages/mailerlite-ru_RU.po CHANGED
@@ -45,12 +45,12 @@ msgid "Wrong data provided"
45
  msgstr "Предоставлены некорректные данные"
46
 
47
  #: include/mailerlite-widget.php:16
48
- msgid "MailerLite sign up form"
49
  msgstr "Форма підписки Mailerlite"
50
 
51
  #. mailerlite
52
  #: include/mailerlite-widget.php:18
53
- msgid "MailerLite sign up form Widget"
54
  msgstr "Виджет формы подписки Mailerlite"
55
 
56
  #. mailerlite
45
  msgstr "Предоставлены некорректные данные"
46
 
47
  #: include/mailerlite-widget.php:16
48
+ msgid "MailerLite signup form"
49
  msgstr "Форма підписки Mailerlite"
50
 
51
  #. mailerlite
52
  #: include/mailerlite-widget.php:18
53
+ msgid "MailerLite signup form Widget"
54
  msgstr "Виджет формы подписки Mailerlite"
55
 
56
  #. mailerlite
languages/mailerlite-uk_UA.po CHANGED
@@ -45,12 +45,12 @@ msgid "Wrong data provided"
45
  msgstr "Надані некоректні дані"
46
 
47
  #: include/mailerlite-widget.php:16
48
- msgid "MailerLite sign up form"
49
  msgstr "Форма підписки MailerLite"
50
 
51
  #. mailerlite
52
  #: include/mailerlite-widget.php:18
53
- msgid "MailerLite sign up form Widget"
54
  msgstr "Віджет форми підписки Mailerlite"
55
 
56
  #. mailerlite
45
  msgstr "Надані некоректні дані"
46
 
47
  #: include/mailerlite-widget.php:16
48
+ msgid "MailerLite signup form"
49
  msgstr "Форма підписки MailerLite"
50
 
51
  #. mailerlite
52
  #: include/mailerlite-widget.php:18
53
+ msgid "MailerLite signup form Widget"
54
  msgstr "Віджет форми підписки Mailerlite"
55
 
56
  #. mailerlite
languages/mailerlite.pot CHANGED
@@ -1,7 +1,7 @@
1
  #, fuzzy
2
  msgid ""
3
  msgstr ""
4
- "Project-Id-Version: Official MailerLite Sign Up Forms\n"
5
  "Report-Msgid-Bugs-To: \n"
6
  "POT-Creation-Date: 2019-01-28 10:27+0000\n"
7
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
@@ -42,11 +42,11 @@ msgid "Wrong data provided"
42
  msgstr ""
43
 
44
  #: include/mailerlite-widget.php:16
45
- msgid "MailerLite sign up form"
46
  msgstr ""
47
 
48
  #: include/mailerlite-widget.php:18
49
- msgid "MailerLite sign up form Widget"
50
  msgstr ""
51
 
52
  #: include/mailerlite-widget.php:83
1
  #, fuzzy
2
  msgid ""
3
  msgstr ""
4
+ "Project-Id-Version: Official MailerLite Signup Forms\n"
5
  "Report-Msgid-Bugs-To: \n"
6
  "POT-Creation-Date: 2019-01-28 10:27+0000\n"
7
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
42
  msgstr ""
43
 
44
  #: include/mailerlite-widget.php:16
45
+ msgid "MailerLite signup form"
46
  msgstr ""
47
 
48
  #: include/mailerlite-widget.php:18
49
+ msgid "MailerLite signup form Widget"
50
  msgstr ""
51
 
52
  #: include/mailerlite-widget.php:83
mailerlite.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: MailerLite - Signup forms (official)
4
  * Description: Official MailerLite Signup forms plugin for WordPress. Ability to embed MailerLite webforms and create custom ones just with few clicks.
5
- * Version: 1.5.2
6
  * Author: MailerLite
7
  * Author URI: https://www.mailerlite.com
8
  * License: GPLv2 or later
@@ -33,7 +33,7 @@ define( 'MAILERLITE_PLUGIN_URL', plugins_url( '', __FILE__ ) );
33
  // Plugin basename
34
  define( 'MAILERLITE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
35
 
36
- define( 'MAILERLITE_VERSION', '1.5.2' );
37
 
38
  define( 'MAILERLITE_PHP_VERSION', '7.2.5' );
39
  define( 'MAILERLITE_WP_VERSION', '3.0.1' );
2
  /**
3
  * Plugin Name: MailerLite - Signup forms (official)
4
  * Description: Official MailerLite Signup forms plugin for WordPress. Ability to embed MailerLite webforms and create custom ones just with few clicks.
5
+ * Version: 1.5.3
6
  * Author: MailerLite
7
  * Author URI: https://www.mailerlite.com
8
  * License: GPLv2 or later
33
  // Plugin basename
34
  define( 'MAILERLITE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
35
 
36
+ define( 'MAILERLITE_VERSION', '1.5.3' );
37
 
38
  define( 'MAILERLITE_PHP_VERSION', '7.2.5' );
39
  define( 'MAILERLITE_WP_VERSION', '3.0.1' );
readme.txt CHANGED
@@ -3,13 +3,13 @@ Contributors: mailerlite
3
  Donate link: https://www.mailerlite.com/
4
  Tags: mailerlite, newsletter, subscribe, form, webform
5
  Requires at least: 3.0.1
6
- Tested up to: 5.8.3
7
  Requires PHP: 7.2.5
8
- Stable tag: 1.5.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
- Add newsletter sign up forms to your WordPress site. Subscribers will be saved directly to your MailerLite account. Super easy to set up!
13
 
14
  == Description ==
15
 
@@ -53,9 +53,9 @@ Plugin features include:
53
  1. After successful installation you will see MailerLite icon on the left sidebar. Click it.
54
  2. Enter your MailerLite account API key. You can find it in your MailerLite account by clicking "Developer API" link in the bottom of the page.
55
  3. Click "Add New Signup Form" .
56
- 4. Choose "Webforms created using MailerLite" if you wan't to use a sign up form that you already created in your MailerLite account or "Custom sign up form" if you want to create it now.
57
- 5. If you want to include sign up form in the sidebar of your blog or website, go to Appearance > Widgets and drag "MailerLite sign up form" to the sidebar. Choose which signup form to display.
58
- 6. If you want to include sign up form inside your post or page, use shortcodes. You will see MailerLite icon in your content editor, click it and choose which form to display. It will put a shortcode (for example [mailerlite_form form_id=1]) and your visitors will see signup form in that place.
59
 
60
 
61
  == Frequently Asked Questions ==
@@ -78,7 +78,7 @@ Yes, you can easily register at www.mailerlite.com
78
  Use shortcode with form id which you created [mailerlite_form form_id=1].
79
 
80
  = How to display a form in widget areas like a sidebar? =
81
- Just add "MailerLite sign up form widget" and select form you have created
82
 
83
  = How to display a form in my template files? =
84
 
@@ -130,6 +130,10 @@ Add your custom CSS rules to the end of your theme stylesheet, /wp-content/theme
130
 
131
  == Changelog ==
132
 
 
 
 
 
133
  = 1.5.2 =
134
  * Fix - Include Universal js
135
 
3
  Donate link: https://www.mailerlite.com/
4
  Tags: mailerlite, newsletter, subscribe, form, webform
5
  Requires at least: 3.0.1
6
+ Tested up to: 5.9.2
7
  Requires PHP: 7.2.5
8
+ Stable tag: 1.5.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
+ Add newsletter signup forms to your WordPress site. Subscribers will be saved directly to your MailerLite account. Super easy to set up!
13
 
14
  == Description ==
15
 
53
  1. After successful installation you will see MailerLite icon on the left sidebar. Click it.
54
  2. Enter your MailerLite account API key. You can find it in your MailerLite account by clicking "Developer API" link in the bottom of the page.
55
  3. Click "Add New Signup Form" .
56
+ 4. Choose "Webforms created using MailerLite" if you wan't to use a signup form that you already created in your MailerLite account or "Custom signup form" if you want to create it now.
57
+ 5. If you want to include signup form in the sidebar of your blog or website, go to Appearance > Widgets and drag "MailerLite signup form" to the sidebar. Choose which signup form to display.
58
+ 6. If you want to include signup form inside your post or page, use shortcodes. You will see MailerLite icon in your content editor, click it and choose which form to display. It will put a shortcode (for example [mailerlite_form form_id=1]) and your visitors will see signup form in that place.
59
 
60
 
61
  == Frequently Asked Questions ==
78
  Use shortcode with form id which you created [mailerlite_form form_id=1].
79
 
80
  = How to display a form in widget areas like a sidebar? =
81
+ Just add "MailerLite signup form widget" and select form you have created
82
 
83
  = How to display a form in my template files? =
84
 
130
 
131
  == Changelog ==
132
 
133
+ = 1.5.3 =
134
+ * Update - API update
135
+ * Tested up to latest WP version
136
+
137
  = 1.5.2 =
138
  * Fix - Include Universal js
139
 
src/Admin/Views/CreateView.php CHANGED
@@ -83,7 +83,7 @@ class CreateView
83
  }
84
  }
85
  ?>
86
- <label for="form_type_webform" class="selectit">
87
  <input id="form_type_webform" type="radio" name="form_type"
88
  onclick="jQuery('#expl').removeClass('hidden')"
89
  value="2"<?php echo count( $embed_button_webforms ) == 0 ? ' disabled="disabled"' : ''; ?>>
83
  }
84
  }
85
  ?>
86
+ <label for="form_type_webform" class="selectit<?php echo count( $embed_button_webforms ) == 0 ? ' ml_unavailable' : '' ?>">
87
  <input id="form_type_webform" type="radio" name="form_type"
88
  onclick="jQuery('#expl').removeClass('hidden')"
89
  value="2"<?php echo count( $embed_button_webforms ) == 0 ? ' disabled="disabled"' : ''; ?>>
src/Admin/Views/EditEmbeddedView.php CHANGED
@@ -76,9 +76,7 @@ class EditEmbeddedView
76
  </option>
77
  <?php endforeach; ?>
78
  </select>
79
-
80
- <a href="<?php echo admin_url( 'admin-ajax.php' ) . '?action=mailerlite_redirect_to_form_edit&ml_nonce='.wp_create_nonce('mailerlite_redirect').'&form_id=' . $form->id . '&platform=' . $apiType; ?>"
81
- target="_blank" class="button button-primary">
82
  <?php _e( 'Edit form', 'mailerlite' ); ?>
83
  </a>
84
  </td>
@@ -129,16 +127,30 @@ class EditEmbeddedView
129
  <?php
130
  switch($apiType) {
131
  case ApiType::CURRENT:
132
- ?>loadIframe(jQuery("option:selected", this).attr('data-code'));<?php
 
 
 
133
  break;
134
  case ApiType::REWRITE:
135
- ?>loadIframe(jQuery("option:selected", this).val());<?php
136
- break;
 
 
 
137
  default: break;
138
  }
139
  ?>
140
 
141
  });
 
 
 
 
 
 
 
 
142
  });
143
 
144
  function loadIframe(code) {
@@ -153,7 +165,7 @@ class EditEmbeddedView
153
 
154
  switch($apiType) {
155
  case ApiType::CURRENT: echo "https://static.mailerlite.com/webforms/submit/"; break;
156
- case ApiType::REWRITE: echo "https://dashboard.mailerlite.com/forms/"; break;
157
  default: break;
158
  }
159
 
@@ -161,12 +173,11 @@ class EditEmbeddedView
161
 
162
  switch($apiType) {
163
  case ApiType::CURRENT: echo "/"; break;
164
- case ApiType::REWRITE: echo "/share"; break;
165
  default: break;
166
  }
167
 
168
  ?>',
169
- style: 'width:100%;height:400px;'
170
  }));
171
  }
172
  </script>
76
  </option>
77
  <?php endforeach; ?>
78
  </select>
79
+ <a href="#" target="_blank" class="button button-primary btn-unsaved-edit-form">
 
 
80
  <?php _e( 'Edit form', 'mailerlite' ); ?>
81
  </a>
82
  </td>
127
  <?php
128
  switch($apiType) {
129
  case ApiType::CURRENT:
130
+ ?>
131
+ loadIframe(jQuery("option:selected", this).attr('data-code'));
132
+ jQuery(".btn-unsaved-edit-form").attr('href', 'https://app.mailerlite.com/webforms/new/content/' + select.val());
133
+ <?php
134
  break;
135
  case ApiType::REWRITE:
136
+ ?>
137
+ loadIframe(jQuery("option:selected", this).val());
138
+ jQuery(".btn-unsaved-edit-form").attr('href', 'https://dashboard.mailerlite.com/forms/' + select.val() + '/content');
139
+ <?php
140
+ break;
141
  default: break;
142
  }
143
  ?>
144
 
145
  });
146
+
147
+ <?php if ($apiType === ApiType::CURRENT) { ?>
148
+ jQuery(".btn-unsaved-edit-form").attr('href', 'https://app.mailerlite.com/webforms/new/content/' + select.val());
149
+ <?php } ?>
150
+
151
+ <?php if ($apiType === ApiType::REWRITE) { ?>
152
+ jQuery(".btn-unsaved-edit-form").attr('href', 'https://dashboard.mailerlite.com/forms/' + select.val() + '/content');
153
+ <?php } ?>
154
  });
155
 
156
  function loadIframe(code) {
165
 
166
  switch($apiType) {
167
  case ApiType::CURRENT: echo "https://static.mailerlite.com/webforms/submit/"; break;
168
+ case ApiType::REWRITE: echo "https://preview.mailerlite.io/preview/" . get_option('account_id', '0'). "/forms/"; break;
169
  default: break;
170
  }
171
 
173
 
174
  switch($apiType) {
175
  case ApiType::CURRENT: echo "/"; break;
 
176
  default: break;
177
  }
178
 
179
  ?>',
180
+ style: 'width:100%;min-height:400px;'
181
  }));
182
  }
183
  </script>
src/Admin/Views/SettingsView.php CHANGED
@@ -54,7 +54,7 @@ class SettingsView
54
  value="<?php if ( $api_key != "") { echo "....".substr($api_key, -4); } ?>" id="mailerlite-api-key"/>
55
 
56
  <input type="submit" name="submit" id="submit" class="button button-primary"
57
- value="<?php echo __( 'Save this key', 'mailerlite' ); ?>">
58
  <input type="hidden" name="action" value="enter-mailerlite-key">
59
 
60
  </form>
@@ -73,7 +73,7 @@ class SettingsView
73
  echo __( "Don't know where to find it?", 'mailerlite' );
74
  ?>
75
  <a
76
- href="https://kb.mailerlite.com/does-mailerlite-offer-an-api/"
77
  target="_blank"><?php echo __( "Check it here!", 'mailerlite' ); ?></a>
78
  <?php
79
  break;
54
  value="<?php if ( $api_key != "") { echo "....".substr($api_key, -4); } ?>" id="mailerlite-api-key"/>
55
 
56
  <input type="submit" name="submit" id="submit" class="button button-primary"
57
+ value="<?php if ( $api_key != "") { echo __( 'Update this key', 'mailerlite' ); } else { echo __( 'Save this key', 'mailerlite' ); } ?>">
58
  <input type="hidden" name="action" value="enter-mailerlite-key">
59
 
60
  </form>
73
  echo __( "Don't know where to find it?", 'mailerlite' );
74
  ?>
75
  <a
76
+ href="https://www.mailerlite.com/help/where-to-find-the-mailerlite-api-key-and-documentation"
77
  target="_blank"><?php echo __( "Check it here!", 'mailerlite' ); ?></a>
78
  <?php
79
  break;
src/Api/PlatformAPI.php CHANGED
@@ -18,8 +18,17 @@ class PlatformAPI
18
 
19
  $this->api_key = $api_key;
20
 
21
- if ( $api_key !== '' )
22
- $this->api = new MailerLiteAPI($api_key);
 
 
 
 
 
 
 
 
 
23
 
24
  }
25
 
18
 
19
  $this->api_key = $api_key;
20
 
21
+ switch ( $this->getApiType() ) {
22
+ case ApiType::CURRENT:
23
+ $this->api = new MailerLiteAPI($api_key);
24
+ break;
25
+ case ApiType::REWRITE:
26
+ $this->api = new RewriteAPI($api_key);
27
+ break;
28
+ default:
29
+ $this->api_key = '';
30
+ break;
31
+ }
32
 
33
  }
34
 
src/Api/RewriteAPI.php CHANGED
@@ -43,10 +43,12 @@ class RewriteAPI
43
  $response = self::parseResponse($response);
44
 
45
  $account = new MailerLiteAccount();
46
- $account->id = $response->data->id;
47
 
48
- // Will need to verify this
49
- $account->subdomain = '';
 
 
 
50
 
51
  return $account;
52
  }
@@ -70,7 +72,7 @@ class RewriteAPI
70
  $group = new MailerLiteGroup();
71
  $group->id = $record->id;
72
  $group->name = $record->name;
73
- $group->total = $record->total;
74
  $group->opened = $record->open_rate->float;
75
  $group->clicked = $record->click_rate->float;
76
  $group->date_created = $record->created_at;
@@ -147,7 +149,8 @@ class RewriteAPI
147
 
148
  $response = $this->client->remote_post('/subscribers', [
149
  'email' => $subscriber,
150
- 'resubscribe' => $resubscribe
 
151
  ]);
152
 
153
  return self::parseResponse($response);
@@ -164,6 +167,7 @@ class RewriteAPI
164
  {
165
 
166
  $subscriber['groups'] = [ $group_id ];
 
167
 
168
  $response = $this->client->remote_post('/subscribers', $subscriber);
169
  $response = self::parseResponse($response);
@@ -311,6 +315,15 @@ class RewriteAPI
311
  return $response;
312
  }
313
  }
 
 
 
 
 
 
 
 
 
314
  }
315
 
316
  return false;
43
  $response = self::parseResponse($response);
44
 
45
  $account = new MailerLiteAccount();
 
46
 
47
+ if ( isset($response->data) ) {
48
+
49
+ $account->id = $response->data->id;
50
+ $account->subdomain = '';
51
+ }
52
 
53
  return $account;
54
  }
72
  $group = new MailerLiteGroup();
73
  $group->id = $record->id;
74
  $group->name = $record->name;
75
+ $group->total = $record->active_count;
76
  $group->opened = $record->open_rate->float;
77
  $group->clicked = $record->click_rate->float;
78
  $group->date_created = $record->created_at;
149
 
150
  $response = $this->client->remote_post('/subscribers', [
151
  'email' => $subscriber,
152
+ 'resubscribe' => $resubscribe,
153
+ 'ip_address' => $_SERVER["REMOTE_ADDR"]
154
  ]);
155
 
156
  return self::parseResponse($response);
167
  {
168
 
169
  $subscriber['groups'] = [ $group_id ];
170
+ $subscriber['ip_address'] = $_SERVER['REMOTE_ADDR'];
171
 
172
  $response = $this->client->remote_post('/subscribers', $subscriber);
173
  $response = self::parseResponse($response);
315
  return $response;
316
  }
317
  }
318
+ } else {
319
+
320
+ $errors = $this->response->get_error_messages();
321
+ $this->response = 'WP Error: ';
322
+
323
+ foreach ( $errors as $code => $msg ) {
324
+
325
+ $this->response .= $code . ': ' . $msg . '. ';
326
+ }
327
  }
328
 
329
  return false;
src/Controllers/AdminController.php CHANGED
@@ -46,11 +46,13 @@ class AdminController
46
  // show settings if API key is not set
47
  if ( $api_key == "" ) {
48
 
49
- exit( wp_redirect( admin_url( '/admin.php?page=mailerlite_settings' ) ) );
 
50
  }
51
 
52
  // Create new signup form view
53
  if ( isset( $_GET['view'] ) && $_GET['view'] == 'create' ) {
 
54
  if ( isset( $_POST['create_signup_form'] ) ) {
55
 
56
  ( new Form() )->create_new_form( $_POST );
46
  // show settings if API key is not set
47
  if ( $api_key == "" ) {
48
 
49
+ wp_redirect( admin_url( '/admin.php?page=mailerlite_settings' ) );
50
+ exit;
51
  }
52
 
53
  // Create new signup form view
54
  if ( isset( $_GET['view'] ) && $_GET['view'] == 'create' ) {
55
+
56
  if ( isset( $_POST['create_signup_form'] ) ) {
57
 
58
  ( new Form() )->create_new_form( $_POST );
src/Helper.php CHANGED
@@ -119,6 +119,35 @@ class Helper
119
  <?php
120
  }
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  /**
123
  * Helper to reuse input field with default data
124
  *
119
  <?php
120
  }
121
 
122
+ /**
123
+ * Universal tracking tag for Rewrite
124
+ *
125
+ * @access public
126
+ * @return void
127
+ */
128
+ public static function mailerlite_universal_rw()
129
+ {
130
+
131
+ $mailerlite_popups = ! ((get_option('mailerlite_popups_disabled') == '1'));
132
+
133
+ if ( is_admin() ) {
134
+
135
+ $mailerlite_popups = false;
136
+ }
137
+ ?>
138
+ <!-- MailerLite Universal -->
139
+ <script>
140
+ (function(w,d,e,u,f,l,n){w[f]=w[f]||function(){(w[f].q=w[f].q||[])
141
+ .push(arguments);},l=d.createElement(e),l.async=1,l.src=u,
142
+ n=d.getElementsByTagName(e)[0],n.parentNode.insertBefore(l,n);})
143
+ (window,document,'script','https://assets.mailerlite.com/js/universal.js','ml');
144
+ ml('account', '<?php echo get_option('account_id'); ?>');
145
+ ml('enablePopups', <?php echo $mailerlite_popups ? 'true' : 'false'; ?>);
146
+ </script>
147
+ <!-- End MailerLite Universal -->
148
+ <?php
149
+ }
150
+
151
  /**
152
  * Helper to reuse input field with default data
153
  *
src/Hooks.php CHANGED
@@ -1,6 +1,8 @@
1
  <?php
2
  namespace MailerLiteForms;
3
 
 
 
4
  class Hooks
5
  {
6
 
@@ -60,8 +62,9 @@ class Hooks
60
  $account_id = get_option( 'account_id' );
61
  $account_subdomain = get_option( 'account_subdomain' );
62
  $mailerlite_popups_disabled = get_option( 'mailerlite_popups_disabled' );
 
63
 
64
- if ( ! $mailerlite_popups_disabled && $mailerlite_api_key && $account_id && $account_subdomain ) {
65
 
66
  add_action( 'wp_head', [
67
  '\MailerLiteForms\Helper',
@@ -69,6 +72,14 @@ class Hooks
69
  ] );
70
  }
71
 
 
 
 
 
 
 
 
 
72
  add_action(
73
  'init', [
74
  '\MailerLiteForms\Hooks',
1
  <?php
2
  namespace MailerLiteForms;
3
 
4
+ use MailerLiteForms\Api\ApiType;
5
+
6
  class Hooks
7
  {
8
 
62
  $account_id = get_option( 'account_id' );
63
  $account_subdomain = get_option( 'account_subdomain' );
64
  $mailerlite_popups_disabled = get_option( 'mailerlite_popups_disabled' );
65
+ $platform = intval(get_option( 'mailerlite_platform', 1));
66
 
67
+ if ( ! $mailerlite_popups_disabled && $mailerlite_api_key && $account_id && $account_subdomain && $platform == ApiType::CURRENT ) {
68
 
69
  add_action( 'wp_head', [
70
  '\MailerLiteForms\Helper',
72
  ] );
73
  }
74
 
75
+ if ( $mailerlite_api_key && $account_id && $platform == ApiType::REWRITE ) {
76
+
77
+ add_action( 'wp_head', [
78
+ '\MailerLiteForms\Helper',
79
+ 'mailerlite_universal_rw'
80
+ ] );
81
+ }
82
+
83
  add_action(
84
  'init', [
85
  '\MailerLiteForms\Hooks',
src/Modules/Gutenberg.php CHANGED
@@ -28,7 +28,7 @@ class Gutenberg
28
  'wp-util',
29
  'jquery',
30
  ],
31
- MAILERLITE_VERSION.time()
32
  );
33
 
34
 
@@ -87,6 +87,16 @@ class Gutenberg
87
  ";
88
  $forms_data = $wpdb->get_results($query);
89
 
 
 
 
 
 
 
 
 
 
 
90
  $forms_data = array_map( function ( $form ) {
91
  return [
92
  'label' => $form->name,
28
  'wp-util',
29
  'jquery',
30
  ],
31
+ MAILERLITE_VERSION
32
  );
33
 
34
 
87
  ";
88
  $forms_data = $wpdb->get_results($query);
89
 
90
+ $forms_data = array_values( array_filter( $forms_data, function ( $form ) {
91
+
92
+ $data = unserialize( $form->data );
93
+
94
+ if ( isset($data['title']) || ( isset($data['id']) && $data['id'] !== 0 ) ) {
95
+
96
+ return $form;
97
+ }
98
+ }));
99
+
100
  $forms_data = array_map( function ( $form ) {
101
  return [
102
  'label' => $form->name,
src/Modules/Widget.php CHANGED
@@ -14,9 +14,9 @@ class Widget extends WP_Widget
14
 
15
  parent::__construct(
16
  'mailerlite_widget',
17
- __( 'MailerLite sign up form', 'mailerlite' ),
18
  [
19
- 'description' => __( 'MailerLite sign up form Widget', 'mailerlite' ),
20
  ]
21
  );
22
  }
14
 
15
  parent::__construct(
16
  'mailerlite_widget',
17
+ __( 'MailerLite signup form', 'mailerlite' ),
18
  [
19
+ 'description' => __( 'MailerLite signup form Widget', 'mailerlite' ),
20
  ]
21
  );
22
  }
src/Views/EmbeddedForm.php CHANGED
@@ -41,17 +41,6 @@ class EmbeddedForm
41
 
42
  if (get_option('account_id') && $platform == ApiType::REWRITE) {
43
  ?>
44
-
45
- <!-- MailerLite Universal -->
46
- <script>
47
- (function(w,d,e,u,f,l,n){w[f]=w[f]||function(){(w[f].q=w[f].q||[])
48
- .push(arguments);},l=d.createElement(e),l.async=1,l.src=u,
49
- n=d.getElementsByTagName(e)[0],n.parentNode.insertBefore(l,n);})
50
- (window,document,'script','https://dashboard.mailerlite.com/js/universal.js','ml');
51
- ml('account', '<?php echo get_option('account_id'); ?>');
52
- </script>
53
- <!-- End MailerLite Universal -->
54
-
55
  <div class="ml-embedded" data-form="<?php echo $form_data['code']; ?>"></div>
56
  <?php
57
  }
41
 
42
  if (get_option('account_id') && $platform == ApiType::REWRITE) {
43
  ?>
 
 
 
 
 
 
 
 
 
 
 
44
  <div class="ml-embedded" data-form="<?php echo $form_data['code']; ?>"></div>
45
  <?php
46
  }