Official MailerLite Sign Up Forms - Version 1.1.6

Version Description

  • popup webforms added
Download this release

Release Info

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

Code changes from version 1.1.5 to 1.1.6

include/mailerlite-admin.php CHANGED
@@ -21,6 +21,13 @@ class MailerLite_Admin
21
 
22
  self::$api_key = get_option('mailerlite_api_key');
23
 
 
 
 
 
 
 
 
24
  if (!self::$initiated) {
25
  self::init_hooks();
26
  }
@@ -373,11 +380,32 @@ class MailerLite_Admin
373
  $mailerlite_error = __('Wrong MailerLite API key', 'mailerlite');
374
  } else {
375
  update_option('mailerlite_api_key', $key);
 
 
 
376
  update_option('mailerlite_enabled', true);
377
  self::$api_key = $key;
378
  }
379
  }
380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  /**
382
  * Create new signup form
383
  *
21
 
22
  self::$api_key = get_option('mailerlite_api_key');
23
 
24
+ $account_id = get_option('account_id');
25
+ $account_subdomain = get_option('account_subdomain');
26
+
27
+ if (self::$api_key && (!$account_id || !$account_subdomain)) {
28
+ self::update_account_info();
29
+ }
30
+
31
  if (!self::$initiated) {
32
  self::init_hooks();
33
  }
380
  $mailerlite_error = __('Wrong MailerLite API key', 'mailerlite');
381
  } else {
382
  update_option('mailerlite_api_key', $key);
383
+
384
+ self::update_account_info();
385
+
386
  update_option('mailerlite_enabled', true);
387
  self::$api_key = $key;
388
  }
389
  }
390
 
391
+ public static function update_account_info() {
392
+ // request to mailerlite api
393
+ $opts = array(
394
+ 'http' => array(
395
+ 'method' => "GET",
396
+ 'header' => "X-MailerLite-ApiKey: " . self::$api_key . "\r\n"
397
+ )
398
+ );
399
+ $context = stream_context_create($opts);
400
+ $response = file_get_contents('https://api.mailerlite.com/api/v2', false, $context);
401
+ $response = json_decode($response);
402
+
403
+ if (!empty($response->account)) {
404
+ update_option('account_id', $response->account->id);
405
+ update_option('account_subdomain', $response->account->subdomain);
406
+ }
407
+ }
408
+
409
  /**
410
  * Create new signup form
411
  *
include/mailerlite-form.php CHANGED
@@ -211,4 +211,27 @@ function load_mailerlite_form($form_id)
211
  $form_id, $form->type, $form->name, $form_data
212
  );
213
  }
214
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  $form_id, $form->type, $form->name, $form_data
212
  );
213
  }
214
+ }
215
+
216
+ function mailerlite_universal() { ?>
217
+ <!-- MailerLite Universal -->
218
+ <script>
219
+ (function(m,a,i,l,e,r){m['MailerLiteObject']=e;function f(){
220
+ var c={a:arguments,q:[]};var r=this.push(c);return "number"!=typeof r?r:f.bind(c.q);}
221
+ f.q=f.q||[];m[e]=m[e]||f.bind(f.q);m[e].q=f.q;r=a.createElement(i);
222
+ var _=a.getElementsByTagName(i)[0];r.async=1;r.src=l;_.parentNode.insertBefore(r,_);
223
+ })(window, document, 'script', 'https://app.mailerlite.com/js/universal.js', 'ml');
224
+
225
+ ml('host', 'https://app.mailerlite.com/');
226
+ ml('accounts', '<?php echo get_option('account_id'); ?>', '<?php echo get_option('account_subdomain'); ?>', 'load');
227
+ </script>
228
+ <!-- End MailerLite Universal -->
229
+ <?php }
230
+
231
+ $mailerlite_api_key = get_option('mailerlite_api_key');
232
+ $account_id = get_option('account_id');
233
+ $account_subdomain = get_option('account_subdomain');
234
+
235
+ if ($mailerlite_api_key && $account_id && $account_subdomain) {
236
+ add_action('wp_head', 'mailerlite_universal');
237
+ }
mailerlite.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Official MailerLite Sign Up Forms
5
  * Description: Official MailerLite Sign Up Forms plugin for WordPress. Ability
6
  * to embed MailerLite webforms and create custom ones just with few clicks.
7
- * Version: 1.1.5
8
  * Author: MailerGroup
9
  * Author URI: https://www.mailerlite.com
10
  * License: GPLv2 or later
@@ -28,7 +28,7 @@
28
  define('MAILERLITE_PLUGIN_DIR', plugin_dir_path(__FILE__));
29
  define('MAILERLITE_PLUGIN_URL', plugins_url('', __FILE__));
30
 
31
- define('MAILERLITE_VERSION', '1.1.5');
32
 
33
  define('MAILERLITE_PHP_VERSION', '5.0.1');
34
  define('MAILERLITE_WP_VERSION', '3.0.1');
4
  * Plugin Name: Official MailerLite Sign Up Forms
5
  * Description: Official MailerLite Sign Up Forms plugin for WordPress. Ability
6
  * to embed MailerLite webforms and create custom ones just with few clicks.
7
+ * Version: 1.1.6
8
  * Author: MailerGroup
9
  * Author URI: https://www.mailerlite.com
10
  * License: GPLv2 or later
28
  define('MAILERLITE_PLUGIN_DIR', plugin_dir_path(__FILE__));
29
  define('MAILERLITE_PLUGIN_URL', plugins_url('', __FILE__));
30
 
31
+ define('MAILERLITE_VERSION', '1.1.6');
32
 
33
  define('MAILERLITE_PHP_VERSION', '5.0.1');
34
  define('MAILERLITE_WP_VERSION', '3.0.1');
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.5.1
7
- Stable tag: 1.1.5
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.5 =
131
  * php notice fix
132
  = 1.1.4 =
@@ -180,6 +182,8 @@ Add your custom CSS rules to the end of your theme stylesheet, /wp-content/theme
180
 
181
  == Upgrade Notice ==
182
 
 
 
183
  = 1.1.5 =
184
  * php notice fix
185
  = 1.1.4 =
4
  Tags: mailerlite, newsletter, subscribe, form, webform
5
  Requires at least: 3.0.1
6
  Tested up to: 4.5.1
7
+ Stable tag: 1.1.6
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.6 =
131
+ * popup webforms added
132
  = 1.1.5 =
133
  * php notice fix
134
  = 1.1.4 =
182
 
183
  == Upgrade Notice ==
184
 
185
+ = 1.1.6 =
186
+ * popup webforms added
187
  = 1.1.5 =
188
  * php notice fix
189
  = 1.1.4 =