Official MailerLite Sign Up Forms - Version 1.1.20

Version Description

curl error showing, empty embed form bugfix, other bugfixes

Download this release

Release Info

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

Code changes from version 1.1.19 to 1.1.20

include/mailerlite-admin.php CHANGED
@@ -143,6 +143,12 @@ class MailerLite_Admin
143
 
144
  $ML_Webforms = new ML_Webforms($api_key);
145
  $webforms = $ML_Webforms->getAll();
 
 
 
 
 
 
146
  $webforms = json_decode($webforms);
147
 
148
  include(MAILERLITE_PLUGIN_DIR
@@ -174,12 +180,27 @@ class MailerLite_Admin
174
 
175
  $ML_Lists = new ML_Lists($api_key);
176
  $lists = $ML_Lists->getAll();
 
 
 
 
 
 
177
  $lists = json_decode($lists);
 
178
 
179
  $fields = $ML_Lists->setId($lists->Results[0]->id)
180
  ->getFields();
 
 
 
 
 
 
181
  $fields = json_decode($fields);
182
 
 
 
183
  if (isset($_POST['save_custom_signup_form'])) {
184
  $form_name = isset($_POST['form_name'])
185
  && $_POST['form_name'] != ''
@@ -269,6 +290,7 @@ class MailerLite_Admin
269
  );
270
 
271
  $form->data = $form_data;
 
272
 
273
  $result = 'success';
274
  }
@@ -281,7 +303,14 @@ class MailerLite_Admin
281
  } else if ($form->type == 2) {
282
  $ML_Webforms = new ML_Webforms($api_key);
283
  $webforms = $ML_Webforms->getAll();
 
 
 
 
 
 
284
  $webforms = json_decode($webforms);
 
285
 
286
  $parsed_webforms = array();
287
 
@@ -317,6 +346,7 @@ class MailerLite_Admin
317
  );
318
 
319
  $form->data = $form_data;
 
320
 
321
  $result = 'success';
322
  }
@@ -390,6 +420,9 @@ class MailerLite_Admin
390
 
391
  if ($response['http_code'] == 401) {
392
  $mailerlite_error = __('Wrong MailerLite API key', 'mailerlite');
 
 
 
393
  } else {
394
  update_option('mailerlite_api_key', $key);
395
  update_option('mailerlite_enabled', true);
143
 
144
  $ML_Webforms = new ML_Webforms($api_key);
145
  $webforms = $ML_Webforms->getAll();
146
+
147
+ if ($ML_Webforms->hasCurlError()) {
148
+ $mailerlite_error = '<u>'.__('Send this error to info@mailerlite.com or our chat', 'mailerlite').'</u>: '.$ML_Webforms->getResponseBody();
149
+
150
+ }
151
+
152
  $webforms = json_decode($webforms);
153
 
154
  include(MAILERLITE_PLUGIN_DIR
180
 
181
  $ML_Lists = new ML_Lists($api_key);
182
  $lists = $ML_Lists->getAll();
183
+
184
+ if ($ML_Lists->hasCurlError()) {
185
+ $mailerlite_error = '<u>'.__('Send this error to info@mailerlite.com or our chat', 'mailerlite').'</u>: '.$ML_Lists->getResponseBody();
186
+
187
+ }
188
+
189
  $lists = json_decode($lists);
190
+ if (empty($lists->Results)) $lists->Results = array();
191
 
192
  $fields = $ML_Lists->setId($lists->Results[0]->id)
193
  ->getFields();
194
+
195
+ if ($ML_Lists->hasCurlError()) {
196
+ $mailerlite_error = '<u>'.__('Send this error to info@mailerlite.com or our chat', 'mailerlite').'</u>: '.$ML_Lists->getResponseBody();
197
+
198
+ }
199
+
200
  $fields = json_decode($fields);
201
 
202
+ if (empty($fields->Fields)) $fields->Fields = array();
203
+
204
  if (isset($_POST['save_custom_signup_form'])) {
205
  $form_name = isset($_POST['form_name'])
206
  && $_POST['form_name'] != ''
290
  );
291
 
292
  $form->data = $form_data;
293
+ $form->name = $form_name;
294
 
295
  $result = 'success';
296
  }
303
  } else if ($form->type == 2) {
304
  $ML_Webforms = new ML_Webforms($api_key);
305
  $webforms = $ML_Webforms->getAll();
306
+
307
+ if ($ML_Webforms->hasCurlError()) {
308
+ $mailerlite_error = '<u>'.__('Send this error to info@mailerlite.com or our chat', 'mailerlite').'</u>: '.$ML_Webforms->getResponseBody();
309
+
310
+ }
311
+
312
  $webforms = json_decode($webforms);
313
+ if (empty($webforms->Results)) $webforms->Results = array();
314
 
315
  $parsed_webforms = array();
316
 
346
  );
347
 
348
  $form->data = $form_data;
349
+ $form->name = $form_name;
350
 
351
  $result = 'success';
352
  }
420
 
421
  if ($response['http_code'] == 401) {
422
  $mailerlite_error = __('Wrong MailerLite API key', 'mailerlite');
423
+ } elseif ($ML_Lists->hasCurlError()) {
424
+ $mailerlite_error = '<u>'.__('Send this error to info@mailerlite.com or our chat', 'mailerlite').'</u>: '.$ML_Lists->getResponseBody();
425
+
426
  } else {
427
  update_option('mailerlite_api_key', $key);
428
  update_option('mailerlite_enabled', true);
include/mailerlite-form.php CHANGED
@@ -31,6 +31,7 @@ class MailerLite_Form
31
  */
32
  public function generate_form($form_id, $form_type, $form_name, $form_data)
33
  {
 
34
 
35
  $this->form_id = $form_id;
36
  $this->form_type = $form_type;
@@ -49,7 +50,7 @@ class MailerLite_Form
49
  */
50
  public static function save_form_data()
51
  {
52
- global $wpdb;
53
 
54
  $form_id = isset($_POST['form_id']) ? absint($_POST['form_id']) : 0;
55
  $form_fields = isset($_POST['form_fields']) ? $_POST['form_fields']
@@ -95,13 +96,13 @@ class MailerLite_Form
95
  } else {
96
  echo json_encode(
97
  array('status' => 'error',
98
- 'message' => __('Form not found', 'mailerlite'))
99
  );
100
  }
101
  } else {
102
  echo json_encode(
103
  array('status' => 'error',
104
- 'message' => __('Wrong data provided', 'mailerlite'))
105
  );
106
  }
107
 
31
  */
32
  public function generate_form($form_id, $form_type, $form_name, $form_data)
33
  {
34
+ global $mailerlite_error;
35
 
36
  $this->form_id = $form_id;
37
  $this->form_type = $form_type;
50
  */
51
  public static function save_form_data()
52
  {
53
+ global $wpdb, $mailerlite_error;
54
 
55
  $form_id = isset($_POST['form_id']) ? absint($_POST['form_id']) : 0;
56
  $form_fields = isset($_POST['form_fields']) ? $_POST['form_fields']
96
  } else {
97
  echo json_encode(
98
  array('status' => 'error',
99
+ 'message' => __('Form not found', 'mailerlite'))
100
  );
101
  }
102
  } else {
103
  echo json_encode(
104
  array('status' => 'error',
105
+ 'message' => __('Wrong data provided', 'mailerlite'))
106
  );
107
  }
108
 
include/templates/admin/api_key.php CHANGED
@@ -6,12 +6,7 @@
6
  <div id="post-body">
7
  <div id="post-body-content">
8
  <p><?php echo __('Hi there! You will be able to create awesome signup forms, but first we need your MailerLite API key!', 'mailerlite'); ?></p>
9
- <?php if ($mailerlite_error): ?>
10
- <div class="error">
11
- <p><?php echo $mailerlite_error; ?></p>
12
- </div>
13
 
14
- <?php endif; ?>
15
  <div class="mailerlite-activate">
16
  <div class="description-block">
17
  <p class="title"><?php echo __('Enter an API key', 'mailerlite'); ?></p>
6
  <div id="post-body">
7
  <div id="post-body-content">
8
  <p><?php echo __('Hi there! You will be able to create awesome signup forms, but first we need your MailerLite API key!', 'mailerlite'); ?></p>
 
 
 
 
9
 
 
10
  <div class="mailerlite-activate">
11
  <div class="description-block">
12
  <p class="title"><?php echo __('Enter an API key', 'mailerlite'); ?></p>
include/templates/admin/create.php CHANGED
@@ -23,9 +23,19 @@
23
  </p>
24
 
25
  <p>
 
 
 
 
 
 
 
 
 
 
26
  <label for="form_type_webform" class="selectit">
27
  <input id="form_type_webform" type="radio" name="form_type"
28
- value="2"<?php echo $webforms->RecordsOnPage == 0 ? ' disabled="disabled"' : ''; ?>>
29
  <?php echo __('Webforms created using MailerLite', 'mailerlite'); ?>
30
  </label>
31
  </p>
23
  </p>
24
 
25
  <p>
26
+ <?php
27
+ $embed_button_webforms = [];
28
+
29
+ foreach ($webforms->Results as $webform) {
30
+ if (!in_array($webform->type, array('embed', 'button'))) { continue; }
31
+
32
+ $embed_button_webforms[] = $webform;
33
+ }
34
+ ?>
35
+
36
  <label for="form_type_webform" class="selectit">
37
  <input id="form_type_webform" type="radio" name="form_type"
38
+ value="2"<?php echo count($embed_button_webforms) == 0 ? ' disabled="disabled"' : ''; ?>>
39
  <?php echo __('Webforms created using MailerLite', 'mailerlite'); ?>
40
  </label>
41
  </p>
include/templates/admin/edit_embedded.php CHANGED
@@ -74,6 +74,10 @@
74
  });
75
 
76
  function loadIframe(code) {
 
 
 
 
77
  jQuery('#webform_example').html(jQuery('<iframe></iframe>', {
78
  id: 'webform_example_iframe',
79
  src: "https://app.mailerlite.com/webforms/submit/" + code + "/",
74
  });
75
 
76
  function loadIframe(code) {
77
+ if (!code) {
78
+ return;
79
+ }
80
+
81
  jQuery('#webform_example').html(jQuery('<iframe></iframe>', {
82
  id: 'webform_example_iframe',
83
  src: "https://app.mailerlite.com/webforms/submit/" + code + "/",
include/templates/admin/header.php CHANGED
@@ -1,2 +1,9 @@
1
  <?php defined('ABSPATH') or die("No direct access allowed!"); ?>
2
- <div class="mailerlite-header"></div>
 
 
 
 
 
 
 
1
  <?php defined('ABSPATH') or die("No direct access allowed!"); ?>
2
+ <div class="mailerlite-header"></div>
3
+
4
+ <?php if ($mailerlite_error): ?>
5
+ <div class="error">
6
+ <p><?php echo $mailerlite_error; ?></p>
7
+ </div>
8
+
9
+ <?php endif; ?>
include/templates/admin/settings.php CHANGED
@@ -9,12 +9,7 @@
9
  <div id="post-body">
10
  <div id="post-body-content">
11
  <p><?php _e('Here you able to change your API key!', 'mailerlite'); ?></p>
12
- <?php if ($mailerlite_error): ?>
13
- <div class="error">
14
- <p><?php echo $mailerlite_error; ?></p>
15
- </div>
16
 
17
- <?php endif; ?>
18
  <div class="mailerlite-activate">
19
  <div class="description-block">
20
  <p class="title"><?php _e('Enter an API key', 'mailerlite'); ?></p>
9
  <div id="post-body">
10
  <div id="post-body-content">
11
  <p><?php _e('Here you able to change your API key!', 'mailerlite'); ?></p>
 
 
 
 
12
 
 
13
  <div class="mailerlite-activate">
14
  <div class="description-block">
15
  <p class="title"><?php _e('Enter an API key', 'mailerlite'); ?></p>
languages/mailerlite-fi_FI.po CHANGED
@@ -399,3 +399,8 @@ msgstr "Ole hyvä ja odota..."
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Kiitos tilauksestasi!"
 
 
 
 
 
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Kiitos tilauksestasi!"
402
+
403
+ # @ mailerlite
404
+ #: include/mailerlite_admin.php:395
405
+ msgid "Send this error to info@mailerlite.com or our chat"
406
+ msgstr "Lähetä tämä virhe info@mailerlite.com tai meidän chat"
languages/mailerlite-it_IT.mo CHANGED
Binary file
languages/mailerlite-it_IT.po CHANGED
@@ -399,3 +399,8 @@ msgstr "Aspetta..."
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Grazie per la tua iscrizione!"
 
 
 
 
 
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Grazie per la tua iscrizione!"
402
+
403
+ # @ mailerlite
404
+ #: include/mailerlite_admin.php:395
405
+ msgid "Send this error to info@mailerlite.com or our chat"
406
+ msgstr "Invia questo errore di info@mailerlite.com o la nostra chat"
languages/mailerlite-lt_LT.mo CHANGED
Binary file
languages/mailerlite-lt_LT.po CHANGED
@@ -406,3 +406,8 @@ msgstr "Dėkojame už prenumeratą!"
406
  #: include/templates/common/tiny_mce.php:24
407
  msgid "Add Shortcode"
408
  msgstr "Pridėti trumpinį"
 
 
 
 
 
406
  #: include/templates/common/tiny_mce.php:24
407
  msgid "Add Shortcode"
408
  msgstr "Pridėti trumpinį"
409
+
410
+ # @ mailerlite
411
+ #: include/mailerlite_admin.php:395
412
+ msgid "Send this error to info@mailerlite.com or our chat"
413
+ msgstr "Atsiųskite šį klaidos pranešimą info@mailerlite.com arba per chat"
languages/mailerlite-ru_RU.mo CHANGED
Binary file
languages/mailerlite-ru_RU.po CHANGED
@@ -399,3 +399,8 @@ msgstr "Пожалуйста, подождите..."
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Спасибо за подписку!"
 
 
 
 
 
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Спасибо за подписку!"
402
+
403
+ # @ mailerlite
404
+ #: include/mailerlite_admin.php:395
405
+ msgid "Send this error to info@mailerlite.com or our chat"
406
+ msgstr "Отправьте эту ошибку на info@mailerlite.com или чат на нашем сайте."
languages/mailerlite-sv_SE.mo CHANGED
Binary file
languages/mailerlite-sv_SE.po CHANGED
@@ -399,3 +399,8 @@ msgstr "Vänligen vänta..."
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Tack för din prenumeration!"
 
 
 
 
 
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Tack för din prenumeration!"
402
+
403
+ # @ mailerlite
404
+ #: include/mailerlite_admin.php:395
405
+ msgid "Send this error to info@mailerlite.com or our chat"
406
+ msgstr "Skicka detta fel att info@mailerlite.com eller vår chatt"
languages/mailerlite-uk_UA.mo CHANGED
Binary file
languages/mailerlite-uk_UA.po CHANGED
@@ -399,3 +399,8 @@ msgstr "Будь ласка, зачекайте..."
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Дякуємо за підписку!"
 
 
 
 
 
399
  #: include/templates/forms/custom_form.php:27
400
  msgid "Thank you for signup!"
401
  msgstr "Дякуємо за підписку!"
402
+
403
+ # @ mailerlite
404
+ #: include/mailerlite_admin.php:395
405
+ msgid "Send this error to info@mailerlite.com or our chat"
406
+ msgstr "Відправте цю помилку на info@mailerlite.com або зв'яжіться з нами через онлайн"
libs/mailerlite_rest/base/ML_Rest_Base.php CHANGED
@@ -15,6 +15,8 @@ class ML_Rest_Base
15
  protected $apiKey = '';
16
  protected $path = '';
17
 
 
 
18
  public function __construct($url = 'https://app.mailerlite.com/api/v1/', $verb = 'GET')
19
  {
20
  $this->url = $url;
@@ -136,6 +138,11 @@ class ML_Rest_Base
136
  $this->setCurlOpts($curlHandle);
137
  $this->responseBody = curl_exec($curlHandle);
138
 
 
 
 
 
 
139
  $this->responseInfo = curl_getinfo($curlHandle);
140
 
141
  curl_close($curlHandle);
@@ -156,6 +163,11 @@ class ML_Rest_Base
156
  }
157
  }
158
 
 
 
 
 
 
159
  protected function setAuth(&$curlHandle)
160
  {
161
  if ($this->username !== null && $this->password !== null) {
15
  protected $apiKey = '';
16
  protected $path = '';
17
 
18
+ private $curlError = false;
19
+
20
  public function __construct($url = 'https://app.mailerlite.com/api/v1/', $verb = 'GET')
21
  {
22
  $this->url = $url;
138
  $this->setCurlOpts($curlHandle);
139
  $this->responseBody = curl_exec($curlHandle);
140
 
141
+ if ($this->responseBody === false) {
142
+ $this->responseBody = 'CURL errno: '.curl_errno($curlHandle).', CURL error: '.curl_error($curlHandle);
143
+ $this->curlError = true;
144
+ }
145
+
146
  $this->responseInfo = curl_getinfo($curlHandle);
147
 
148
  curl_close($curlHandle);
163
  }
164
  }
165
 
166
+ public function hasCurlError()
167
+ {
168
+ return $this->curlError;
169
+ }
170
+
171
  protected function setAuth(&$curlHandle)
172
  {
173
  if ($this->username !== null && $this->password !== null) {
mailerlite.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * Plugin Name: Official MailerLite Sign Up Forms
5
  * Description: Official MailerLite Sign Up Forms plugin for WordPress. Ability to embed MailerLite webforms and create custom ones just with few clicks.
6
- * Version: 1.1.19
7
  * Author: MailerGroup
8
  * Author URI: https://www.mailerlite.com
9
  * License: GPLv2 or later
@@ -27,7 +27,7 @@
27
  define('MAILERLITE_PLUGIN_DIR', plugin_dir_path(__FILE__));
28
  define('MAILERLITE_PLUGIN_URL', plugins_url('', __FILE__));
29
 
30
- define('MAILERLITE_VERSION', '1.1.19');
31
 
32
  define('MAILERLITE_PHP_VERSION', '5.0.1');
33
  define('MAILERLITE_WP_VERSION', '3.0.1');
3
  /**
4
  * Plugin Name: Official MailerLite Sign Up Forms
5
  * Description: Official MailerLite Sign Up Forms plugin for WordPress. Ability to embed MailerLite webforms and create custom ones just with few clicks.
6
+ * Version: 1.1.20
7
  * Author: MailerGroup
8
  * Author URI: https://www.mailerlite.com
9
  * License: GPLv2 or later
27
  define('MAILERLITE_PLUGIN_DIR', plugin_dir_path(__FILE__));
28
  define('MAILERLITE_PLUGIN_URL', plugins_url('', __FILE__));
29
 
30
+ define('MAILERLITE_VERSION', '1.1.20');
31
 
32
  define('MAILERLITE_PHP_VERSION', '5.0.1');
33
  define('MAILERLITE_WP_VERSION', '3.0.1');
readme.txt CHANGED
@@ -3,8 +3,8 @@ 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: 4.6.1
7
- Stable tag: 1.1.19
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -127,6 +127,8 @@ Add your custom CSS rules to the end of your theme stylesheet, /wp-content/theme
127
 
128
  == Changelog ==
129
 
 
 
130
  = 1.1.19 =
131
  translation fixes
132
  = 1.1.18 =
@@ -208,6 +210,8 @@ translation errors for LT language, allowing only embed and button forms
208
 
209
  == Upgrade Notice ==
210
 
 
 
211
  = 1.1.19 =
212
  translation fixes
213
  = 1.1.18 =
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: 4.7
7
+ Stable tag: 1.1.20
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
127
 
128
  == Changelog ==
129
 
130
+ = 1.1.20 =
131
+ curl error showing, empty embed form bugfix, other bugfixes
132
  = 1.1.19 =
133
  translation fixes
134
  = 1.1.18 =
210
 
211
  == Upgrade Notice ==
212
 
213
+ = 1.1.20 =
214
+ curl error showing, empty embed form bugfix, other bugfixes
215
  = 1.1.19 =
216
  translation fixes
217
  = 1.1.18 =