MailChimp Forms by MailMunch - Version 1.0.6

Version Description

Download this release

Release Info

Developer mailmunch
Plugin Icon 128x128 MailChimp Forms by MailMunch
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

css/admin.css CHANGED
@@ -776,4 +776,4 @@ input[type="button"].btn-block {
776
  }
777
  .clearfix {
778
  clear: both;
779
- }
776
  }
777
  .clearfix {
778
  clear: both;
779
+ }
inc/common.php CHANGED
@@ -13,7 +13,7 @@ class MailchimpMailmunchHelpers {
13
  }
14
 
15
  if (empty($mc_mm_password)) {
16
- update_option("mc_mm_user_password", uniqid());
17
  }
18
 
19
  $mc_mm_email = get_option("mc_mm_user_email");
@@ -70,4 +70,4 @@ class MailchimpMailmunchHelpers {
70
  }
71
  }
72
  }
73
- ?>
13
  }
14
 
15
  if (empty($mc_mm_password)) {
16
+ update_option("mc_mm_user_password", base64_encode(uniqid()));
17
  }
18
 
19
  $mc_mm_email = get_option("mc_mm_user_email");
70
  }
71
  }
72
  }
73
+ ?>
inc/mailmunchapi.php CHANGED
@@ -36,17 +36,6 @@
36
  return $this->ping('/sites/'.$site_id.'/widgets/'.$widget_id.'/delete');
37
  }
38
 
39
- function importWidgets($new_user_email, $new_user_password) {
40
- $this->requestType = 'post';
41
- return $this->ping('/wordpress/import_widgets', array(
42
- 'external_id' => get_option("mc_mm_wordpress_instance_id"),
43
- 'new_user_email' => $new_user_email,
44
- 'new_user_password' => $new_user_password,
45
- 'site_url' => home_url(),
46
- 'site_name' => get_bloginfo()
47
- ));
48
- }
49
-
50
  function hasSite() {
51
  $request = $this->sites();
52
  $sites = $request['body'];
@@ -101,11 +90,12 @@
101
  ), true);
102
  }
103
 
104
- function updateGuest($new_email) {
105
  $this->requestType = 'post';
106
  return $this->ping('/wordpress/update_guest', array(
107
  'user' => array(
108
  'email' => $new_email,
 
109
  'guest_user' => false
110
  )
111
  ), true);
@@ -167,4 +157,4 @@
167
  return $request;
168
  }
169
  }
170
- ?>
36
  return $this->ping('/sites/'.$site_id.'/widgets/'.$widget_id.'/delete');
37
  }
38
 
 
 
 
 
 
 
 
 
 
 
 
39
  function hasSite() {
40
  $request = $this->sites();
41
  $sites = $request['body'];
90
  ), true);
91
  }
92
 
93
+ function updateGuest($new_email, $new_password) {
94
  $this->requestType = 'post';
95
  return $this->ping('/wordpress/update_guest', array(
96
  'user' => array(
97
  'email' => $new_email,
98
+ 'password' => $new_password,
99
  'guest_user' => false
100
  )
101
  ), true);
157
  return $request;
158
  }
159
  }
160
+ ?>
inc/sidebar_widget.php CHANGED
@@ -128,4 +128,4 @@ class MC_MM_Sidebar_Widget extends WP_Widget {
128
  return $instance;
129
  }
130
 
131
- }
128
  return $instance;
129
  }
130
 
131
+ }
js/admin.js CHANGED
@@ -28,20 +28,25 @@ window.onmessage = function (e) {
28
  function showSignInForm() {
29
  document.getElementById("sign-up-form").style.display = 'none';
30
  document.getElementById("sign-in-form").style.display = 'block';
 
 
31
  }
32
 
33
  function showSignUpForm() {
34
  document.getElementById("sign-in-form").style.display = 'none';
35
  document.getElementById("sign-up-form").style.display = 'block';
 
 
36
  }
37
 
38
- function showSignupBox() {
39
- document.getElementById('why-account').style.display = 'none';
40
- tb_show("Create Account","#TB_inline?width=550&height=450&inlineId=signup-signin-box",null);
 
41
  return false;
42
  }
43
 
44
  function showWhyAccount() {
45
  document.getElementById('why-account').style.display = 'block';
46
- tb_show("Create Account","#TB_inline?width=550&height=500&inlineId=signup-signin-box",null);
47
- }
28
  function showSignInForm() {
29
  document.getElementById("sign-up-form").style.display = 'none';
30
  document.getElementById("sign-in-form").style.display = 'block';
31
+ document.getElementById('why-account').style.display = 'none';
32
+ showSignupBox(500, 450);
33
  }
34
 
35
  function showSignUpForm() {
36
  document.getElementById("sign-in-form").style.display = 'none';
37
  document.getElementById("sign-up-form").style.display = 'block';
38
+ document.getElementById('why-account').style.display = 'none';
39
+ showSignupBox(600, 500);
40
  }
41
 
42
+ function showSignupBox(width, height) {
43
+ if (!width) width = 600;
44
+ if (!height) height = 500;
45
+ tb_show("Create Account","#TB_inline?width="+width+"&height="+height+"&inlineId=signup-signin-box",null);
46
  return false;
47
  }
48
 
49
  function showWhyAccount() {
50
  document.getElementById('why-account').style.display = 'block';
51
+ showSignupBox(600, 600);
52
+ }
mailchimp-mailmunch.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MailChimp Forms by MailMunch
4
  Plugin URI: http://connect.mailchimp.com/integrations/mailmunch-email-list-builder
5
  Description: The MailChimp plugin allows you to quickly and easily add signup forms for your MailChimp lists. Popup, Embedded, Top Bar and a variety of different options available.
6
- Version: 1.0.5
7
  Author: MailMunch
8
  Author URI: http://www.mailmunch.co
9
  License: GPL2
@@ -14,7 +14,7 @@
14
  require_once( plugin_dir_path( __FILE__ ) . 'inc/sidebar_widget.php' );
15
 
16
  define( 'MAILCHIMP_MAILMUNCH_SLUG', "mailchimp-mailmunch");
17
- define( 'MAILCHIMP_MAILMUNCH_VER', "1.0.5");
18
  define( 'MAILCHIMP_MAILMUNCH_URL', "www.mailmunch.co");
19
 
20
  // Create unique WordPress instance ID
@@ -155,25 +155,15 @@
155
 
156
  $mm = new MailchimpMailmunchApi($_POST["email"], $_POST["password"], "http://".MAILCHIMP_MAILMUNCH_URL);
157
  if ($mm->validPassword()) {
158
- if (get_option("mc_mm_guest_user")) {
159
- // User exists and credentials are correct
160
- // Let's move optin forms from guest user to real user
161
- $account_info = $mm_helpers->getEmailPassword();
162
- $mc_mm_email = $account_info['email'];
163
- $mc_mm_password = $account_info['password'];
164
- $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
165
- $result = $mm->importWidgets($_POST["email"], $_POST["password"]);
166
- }
167
-
168
  update_option("mc_mm_user_email", $_POST["email"]);
169
- update_option("mc_mm_user_password", $_POST["password"]);
170
  delete_option("mc_mm_guest_user");
171
  }
172
 
173
  } else if ($post_action == "sign_up") {
174
 
175
- if (empty($_POST["email"])) {
176
- $invalid_email = true;
177
  } else {
178
  $account_info = $mm_helpers->getEmailPassword();
179
  $mc_mm_email = $account_info['email'];
@@ -181,11 +171,13 @@
181
 
182
  $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
183
  if ($mm->isNewUser($_POST['email'])) {
184
- $update_result = $mm->updateGuest($_POST['email']);
185
  $result = json_decode($update_result['body']);
186
  update_option("mc_mm_user_email", $result->email);
 
187
  if (!$result->guest_user) { delete_option("mc_mm_guest_user"); }
188
  $mc_mm_email = $result->email;
 
189
 
190
  // We have update the guest with real email address, let's create a site now
191
  $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
@@ -220,6 +212,21 @@
220
  $request = $mm->deleteWidget($_POST["site_id"], $_POST["widget_id"]);
221
  }
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  }
224
  }
225
 
@@ -230,7 +237,7 @@
230
  $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
231
  $mm->createGuestUser();
232
  update_option("mc_mm_user_email", $mc_mm_email);
233
- update_option("mc_mm_user_password", $mc_mm_password);
234
  update_option("mc_mm_guest_user", true);
235
  }
236
 
@@ -256,7 +263,7 @@
256
  $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
257
  $mm->createGuestUser();
258
  update_option("mc_mm_user_email", $mc_mm_email);
259
- update_option("mc_mm_user_password", $mc_mm_password);
260
  update_option("mc_mm_guest_user", true);
261
  }
262
  }
@@ -310,21 +317,51 @@
310
 
311
  <p>Choose the site that you would like to link with your WordPress.</p>
312
 
313
- <form action="" method="POST">
314
- <div class="form-group">
315
- <input type="hidden" name="action" value="save_settings" />
 
316
 
317
- <select name="mc_mm_data[site_id]">
318
- <?php foreach ($sites as $site) { ?>
319
- <option value="<?php echo $site->id ?>"><?php echo $site->name ?></option>
320
- <?php } ?>
321
- </select>
322
- </div>
323
 
324
- <div class="form-group">
325
- <input type="submit" value="Save Settings" />
326
- </div>
327
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  </div>
329
  <?php
330
  return;
@@ -343,8 +380,6 @@
343
 
344
  <?php add_thickbox(); ?>
345
 
346
- <a id="signup-box-btn" href="#TB_inline?width=450&height=450&inlineId=signup-signin-box" title="Create Account" class="thickbox" style="display: none;">Sign Up</a>
347
-
348
  <div id="signup-signin-box" style="display:none;">
349
  <div id="sign-up-form" class="<?php if (!$_POST || ($_POST["action"] != "sign_in" && $_POST["action"] != "unlink_account")) { ?> active<?php } ?>">
350
  <div class="form-container">
@@ -359,9 +394,9 @@
359
  </div>
360
 
361
  <?php if (isset($user_exists)) { ?>
362
- <div id="invalid-alert" class="alert alert-danger" role="alert">Account with this email already exists. Please sign in using your password.</div>
363
- <?php } else if (isset($invalid_email)) { ?>
364
- <div id="invalid-alert" class="alert alert-danger" role="alert">Invalid email. Please enter a valid email below.</div>
365
  <?php } ?>
366
 
367
  <form action="" method="POST">
@@ -382,6 +417,11 @@
382
  <input type="email" placeholder="Email Address" name="email" value="<?php echo $current_user->user_email ?>" class="form-control">
383
  </div>
384
 
 
 
 
 
 
385
  <div class="form-group">
386
  <input type="submit" value="Sign Up &raquo;" class="btn btn-success btn-lg" />
387
  </div>
@@ -395,7 +435,7 @@
395
  <p>Sign in using your email and password below.</p>
396
 
397
  <?php if ($_POST && $_POST["action"] == "sign_in") { ?>
398
- <div id="invalid-alert" class="alert alert-danger" role="alert">Invalid Email or Password. Please try again.</div>
399
  <?php } ?>
400
 
401
  <div class="form-container">
@@ -427,10 +467,14 @@
427
  ?>
428
  <script>
429
  jQuery(window).load(function() {
430
- showSignupBox();
 
 
 
 
431
  });
432
  </script>
433
  <?php
434
  }
435
  }
436
- }
3
  Plugin Name: MailChimp Forms by MailMunch
4
  Plugin URI: http://connect.mailchimp.com/integrations/mailmunch-email-list-builder
5
  Description: The MailChimp plugin allows you to quickly and easily add signup forms for your MailChimp lists. Popup, Embedded, Top Bar and a variety of different options available.
6
+ Version: 1.0.6
7
  Author: MailMunch
8
  Author URI: http://www.mailmunch.co
9
  License: GPL2
14
  require_once( plugin_dir_path( __FILE__ ) . 'inc/sidebar_widget.php' );
15
 
16
  define( 'MAILCHIMP_MAILMUNCH_SLUG', "mailchimp-mailmunch");
17
+ define( 'MAILCHIMP_MAILMUNCH_VER', "1.0.6");
18
  define( 'MAILCHIMP_MAILMUNCH_URL', "www.mailmunch.co");
19
 
20
  // Create unique WordPress instance ID
155
 
156
  $mm = new MailchimpMailmunchApi($_POST["email"], $_POST["password"], "http://".MAILCHIMP_MAILMUNCH_URL);
157
  if ($mm->validPassword()) {
 
 
 
 
 
 
 
 
 
 
158
  update_option("mc_mm_user_email", $_POST["email"]);
159
+ update_option("mc_mm_user_password", base64_encode($_POST["password"]));
160
  delete_option("mc_mm_guest_user");
161
  }
162
 
163
  } else if ($post_action == "sign_up") {
164
 
165
+ if (empty($_POST["email"]) || empty($_POST["password"])) {
166
+ $invalid_email_password = true;
167
  } else {
168
  $account_info = $mm_helpers->getEmailPassword();
169
  $mc_mm_email = $account_info['email'];
171
 
172
  $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
173
  if ($mm->isNewUser($_POST['email'])) {
174
+ $update_result = $mm->updateGuest($_POST['email'], $_POST['password']);
175
  $result = json_decode($update_result['body']);
176
  update_option("mc_mm_user_email", $result->email);
177
+ update_option("mc_mm_user_password", base64_encode($_POST['password']));
178
  if (!$result->guest_user) { delete_option("mc_mm_guest_user"); }
179
  $mc_mm_email = $result->email;
180
+ $mc_mm_password = $_POST['password'];
181
 
182
  // We have update the guest with real email address, let's create a site now
183
  $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
212
  $request = $mm->deleteWidget($_POST["site_id"], $_POST["widget_id"]);
213
  }
214
 
215
+ } else if ($post_action == "create_site") {
216
+ $site_url = (empty($_POST["site_url"]) ? get_bloginfo() : $_POST["site_url"]);
217
+ $site_name = (empty($_POST["site_name"]) ? home_url() : $_POST["site_name"]);
218
+
219
+ $account_info = $mm_helpers->getEmailPassword();
220
+ $mm = new MailchimpMailmunchApi($account_info['email'], $account_info["password"], "http://".MAILCHIMP_MAILMUNCH_URL);
221
+ $request = $mm->createSite($site_name, $site_url);
222
+ $site = json_decode($request['body']);
223
+
224
+ if (!empty($site->id)) {
225
+ $mc_mm_data = unserialize(get_option("mc_mm_data"));
226
+ $mc_mm_data["site_id"] = $site->id;
227
+ $mc_mm_data["script_src"] = $site->javascript_url;
228
+ update_option("mc_mm_data", serialize($mc_mm_data));
229
+ }
230
  }
231
  }
232
 
237
  $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
238
  $mm->createGuestUser();
239
  update_option("mc_mm_user_email", $mc_mm_email);
240
+ update_option("mc_mm_user_password", base64_encode($mc_mm_password));
241
  update_option("mc_mm_guest_user", true);
242
  }
243
 
263
  $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
264
  $mm->createGuestUser();
265
  update_option("mc_mm_user_email", $mc_mm_email);
266
+ update_option("mc_mm_user_password", base64_encode($mc_mm_password));
267
  update_option("mc_mm_guest_user", true);
268
  }
269
  }
317
 
318
  <p>Choose the site that you would like to link with your WordPress.</p>
319
 
320
+ <div id="choose-site-form">
321
+ <form action="" method="POST">
322
+ <div class="form-group">
323
+ <input type="hidden" name="action" value="save_settings" />
324
 
325
+ <select name="mailmunch_data[site_id]">
326
+ <?php foreach ($sites as $site) { ?>
327
+ <option value="<?php echo $site->id ?>"><?php echo $site->name ?></option>
328
+ <?php } ?>
329
+ </select>
330
+ </div>
331
 
332
+ <div class="form-group">
333
+ <input type="submit" value="Save Settings" class="button-primary" />
334
+ </div>
335
+ </form>
336
+
337
+ <p>
338
+ Don't see this site above? <a href="" onclick="document.getElementById('create-site-form').style.display = 'block'; document.getElementById('choose-site-form').style.display = 'none'; return false;">Create New Site</a>
339
+ </p>
340
+ </div>
341
+
342
+ <div id="create-site-form" style="display: none;">
343
+ <form action="" method="POST">
344
+ <input type="hidden" name="action" value="create_site" />
345
+
346
+ <div class="form-group">
347
+ <label>Site Name</label>
348
+ <input type="text" name="site_name" value="<?php echo get_bloginfo() ?>" />
349
+ </div>
350
+
351
+ <div class="form-group">
352
+ <label>Site URL</label>
353
+ <input type="text" name="site_url" value="<?php echo home_url() ?>" />
354
+ </div>
355
+
356
+ <div class="form-group">
357
+ <input type="submit" value="Create Site" class="button-primary" />
358
+ </div>
359
+ </form>
360
+
361
+ <p>
362
+ Already have a site in your MailMunch account? <a href="" onclick="document.getElementById('create-site-form').style.display = 'none'; document.getElementById('choose-site-form').style.display = 'block'; return false;">Choose Site</a>
363
+ </p>
364
+ </div>
365
  </div>
366
  <?php
367
  return;
380
 
381
  <?php add_thickbox(); ?>
382
 
 
 
383
  <div id="signup-signin-box" style="display:none;">
384
  <div id="sign-up-form" class="<?php if (!$_POST || ($_POST["action"] != "sign_in" && $_POST["action"] != "unlink_account")) { ?> active<?php } ?>">
385
  <div class="form-container">
394
  </div>
395
 
396
  <?php if (isset($user_exists)) { ?>
397
+ <div id="invalid-alert" class="alert alert-danger signup-alert" role="alert">Account with this email already exists. Please sign in using your password.</div>
398
+ <?php } else if (isset($invalid_email_password)) { ?>
399
+ <div id="invalid-alert" class="alert alert-danger signup-alert" role="alert">Invalid email or password. Please enter a valid email and password below.</div>
400
  <?php } ?>
401
 
402
  <form action="" method="POST">
417
  <input type="email" placeholder="Email Address" name="email" value="<?php echo $current_user->user_email ?>" class="form-control">
418
  </div>
419
 
420
+ <div class="form-group">
421
+ <label>Password</label>
422
+ <input type="password" placeholder="Password" name="password" class="form-control" />
423
+ </div>
424
+
425
  <div class="form-group">
426
  <input type="submit" value="Sign Up &raquo;" class="btn btn-success btn-lg" />
427
  </div>
435
  <p>Sign in using your email and password below.</p>
436
 
437
  <?php if ($_POST && $_POST["action"] == "sign_in") { ?>
438
+ <div id="invalid-alert" class="alert alert-danger signin-alert" role="alert">Invalid Email or Password. Please try again.</div>
439
  <?php } ?>
440
 
441
  <div class="form-container">
467
  ?>
468
  <script>
469
  jQuery(window).load(function() {
470
+ <?php if ($_POST && ($_POST["action"] == "sign_in" || $_POST["action"] == "unlink_account")) { ?>
471
+ showSignInForm();
472
+ <?php } else { ?>
473
+ showSignUpForm();
474
+ <?php } ?>
475
  });
476
  </script>
477
  <?php
478
  }
479
  }
480
+ }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: mailmunch
3
  Tags: mailchimp, MailChimp form, MailChimp Newsletter form, MailChimp plugin, newsletter, newsletter form, newsletter form plugin, optin form, form, signup, signup forms, signup form, widget, email form, leads
4
  Requires at least: 3.0.1
5
- Tested up to: 4.0
6
- Stable tag: 1.0.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
2
  Contributors: mailmunch
3
  Tags: mailchimp, MailChimp form, MailChimp Newsletter form, MailChimp plugin, newsletter, newsletter form, newsletter form plugin, optin form, form, signup, signup forms, signup form, widget, email form, leads
4
  Requires at least: 3.0.1
5
+ Tested up to: 4.1
6
+ Stable tag: 1.0.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
uninstall.php CHANGED
@@ -6,4 +6,4 @@ delete_option("mc_mm_data");
6
  delete_option("mc_mm_user_email");
7
  delete_option("mc_mm_user_password");
8
  delete_option("mc_mm_guest_user");
9
- ?>
6
  delete_option("mc_mm_user_email");
7
  delete_option("mc_mm_user_password");
8
  delete_option("mc_mm_guest_user");
9
+ ?>