MailChimp for WordPress - Version 1.2.4

Version Description

  • Improved: code performance improvements
  • Improved: added mc4wp_get_form() for an easier shortcode callback. Useful to add a sign-up form to the end of your posts.
  • Improved default CSS
  • Improved: checkbox debug message only shows to WP Administrators when JavaScript is disabled
  • Added: form nonce for better security
  • Fix: CSS issue where the form caused a huge sidebar gap in some themes.
Download this release

Release Info

Developer DvanKooten
Plugin Icon 128x128 MailChimp for WordPress
Version 1.2.4
Comparing to
See all releases

Code changes from version 1.2.3 to 1.2.4

assets/css/admin.css CHANGED
@@ -2,7 +2,7 @@
2
  #mc4wp-sidebar{ float:right; width:32%; margin:0; padding:9px 0 0; }
3
  #mc4wp-sidebar .mc4wp-box{ margin-bottom:20px; }
4
 
5
- #mc4wp-upgrade-box { background:#efefef; border:1px solid #cecece; padding:20px; }
6
  #mc4wp-upgrade-box h3{ margin:0; }
7
 
8
  #mc4wp-fw h4{ margin-top:0; }
@@ -11,8 +11,9 @@
11
  #mc4wp-lists{ margin:0; }
12
  #mc4wp-lists input{ margin-right:5px; }
13
 
14
- .mc4wp-settings tr.pro-feature th, .mc4wp-settings tr.pro-feature td{ color:#999; }
15
 
 
16
  .mc4wp-settings span.status{ display:inline-block; padding:3px 6px; color:white; font-size:12px; font-weight:bold; }
17
  .mc4wp-settings span.positive{ background-color:green; }
18
  .mc4wp-settings span.negative{ background-color:lightGrey; }
2
  #mc4wp-sidebar{ float:right; width:32%; margin:0; padding:9px 0 0; }
3
  #mc4wp-sidebar .mc4wp-box{ margin-bottom:20px; }
4
 
5
+ #mc4wp-upgrade-box { background:#222; color:#ddd; padding:20px; }
6
  #mc4wp-upgrade-box h3{ margin:0; }
7
 
8
  #mc4wp-fw h4{ margin-top:0; }
11
  #mc4wp-lists{ margin:0; }
12
  #mc4wp-lists input{ margin-right:5px; }
13
 
14
+ .mc4wp-settings tr.pro-feature th, .mc4wp-settings tr.pro-feature td{ color:#aaa; }
15
 
16
+ .mc4wp-settings h3{ margin-top:2em;}
17
  .mc4wp-settings span.status{ display:inline-block; padding:3px 6px; color:white; font-size:12px; font-weight:bold; }
18
  .mc4wp-settings span.positive{ background-color:green; }
19
  .mc4wp-settings span.negative{ background-color:lightGrey; }
assets/css/checkbox.css CHANGED
@@ -1,5 +1,5 @@
1
- p#mc4wp-checkbox{ clear:both; display:block; }
2
- p#mc4wp-checkbox input{ margin:0 5px 0 0; display:inline-block !important; width:13px; height:13px; }
3
- p#mc4wp-checkbox label{ display:inline-block !important; }
4
 
5
- #registerform p#mc4wp-checkbox{ margin-bottom:10px; }
1
+ #mc4wp-checkbox{ clear:both; display:block; }
2
+ #mc4wp-checkbox input{ margin:0 5px 0 0; display:inline-block !important; width:13px; height:13px; }
3
+ #mc4wp-checkbox label{ display:inline-block !important; }
4
 
5
+ #registerform #mc4wp-checkbox{ margin-bottom:10px; }
assets/css/form.css CHANGED
@@ -1,23 +1,21 @@
1
- form.mc4wp-form{ clear:both; margin:15px 0; }
2
- form.mc4wp-form p{ clear:both; }
3
- form.mc4wp-form label{ display:block; font-weight:bold; margin-bottom: 3px; }
 
4
 
5
- form.mc4wp-form ul li label{ font-weight:normal; }
 
 
 
6
 
7
- form.mc4wp-form input[type="text"],
8
- form.mc4wp-form input[type="email"],
9
- form.mc4wp-form input[type="tel"],
10
- form.mc4wp-form input[type="url"] { display:block; width:100%;
11
- box-sizing:border-box; box-sizing: border-box; -moz-box-sizing: border-box; }
 
12
 
13
- form.mc4wp-form form input[type="checkbox"] { margin:0 10px 0 0; padding:0; height:13px; width:13px;
14
- display:inline-block; -webkit-appearance: checkbox; }
15
- form.mc4wp-form form input[type="radio"] { margin:0 10px 0 0; padding:0; height:13px; width:13px;
16
- display:inline-block; -webkit-appearance: radio; }
17
- form.mc4wp-form select, div.mc4wp-form input[type="date"] { min-width:35%; }
18
- form.mc4wp-form input[type="submit"], div.mc4wp-form button[type="submit"]{ display:inline-block; }
19
-
20
- form.mc4wp-form .mc4wp-alert{ margin-top:1em; margin-bottom:1em; padding: 10px 35px 10px 15px; color: #c09853; background-color: #fcf8e3; border: 1px solid #fbeed5; border-radius: 4px; display:block; position:relative;}
21
- form.mc4wp-form .mc4wp-success { color: #468847; background-color: #dff0d8; border-color: #d6e9c6; }
22
- form.mc4wp-form .mc4wp-notice { color: #3a87ad; background-color: #d9edf7; border-color: #bce8f1; }
23
- form.mc4wp-form .mc4wp-error { color: #b94a48; background-color: #f2dede; border-color: #eed3d7;; }
1
+ .mc4wp-form{ margin:1em 0; }
2
+ .mc4wp-form p{ text-align:left; }
3
+ .mc4wp-form label{ display:block; font-weight:bold; margin-bottom:3px; text-align:left; }
4
+ .mc4wp-form label span, .mc4wp-form li label{ font-weight: normal; }
5
 
6
+ .mc4wp-form input[type="text"],
7
+ .mc4wp-form input[type="email"],
8
+ .mc4wp-form input[type="tel"],
9
+ .mc4wp-form input[type="url"] { display:inline-block; width:100%; box-sizing:border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; }
10
 
11
+ .mc4wp-form input[type="checkbox"] { margin:0 10px 0 0; padding:0; height:13px; width:13px;
12
+ display:inline-block; -webkit-appearance: checkbox; border:0; }
13
+ .mc4wp-form input[type="radio"] { margin:0 10px 0 0; padding:0; height:13px; width:13px;
14
+ display:inline-block; -webkit-appearance: radio; border:0; }
15
+ .mc4wp-form select, .mc4wp-form input[type="date"] { min-width:35%; }
16
+ .mc4wp-form input[type="submit"], .mc4wp-form button{ display:inline-block; }
17
 
18
+ .mc4wp-alert{ margin:1em 0; padding: 10px 15px; color: #c09853; background-color: #fcf8e3; border: 1px solid #fbeed5; border-radius: 4px; display:block; position:relative;}
19
+ .mc4wp-success { color: #468847; background-color: #dff0d8; border-color: #d6e9c6; }
20
+ .mc4wp-notice { color: #3a87ad; background-color: #d9edf7; border-color: #bce8f1; }
21
+ .mc4wp-error { color: #b94a48; background-color: #f2dede; border-color: #eed3d7;; }
 
 
 
 
 
 
 
assets/js/admin.js CHANGED
@@ -16,7 +16,7 @@
16
  */
17
  (function() {
18
  // setup variables
19
- var $lists = $("#mc4wp-lists input");
20
  var $mailchimpFields = $("#mc4wp-fw-mailchimp-fields");
21
  var $mailchimpMergeFields = $("#mc4wp-fw-mailchimp-fields .merge-fields");
22
  var $mailchimpGroupings = $("#mc4wp-fw-mailchimp-fields .groupings");
@@ -47,7 +47,7 @@
47
  var groupings = $(this).data('groupings');
48
 
49
  // loop through merge fields from this list
50
- for(var i = 0, fieldCount = fields.length; i < fieldCount; i++) {
51
  var f = fields[i];
52
 
53
  // add field to select if no similar option exists yet
@@ -59,7 +59,7 @@
59
  var include = false;
60
  var triggers = [ 'name', 'email', 'website' ];
61
  for(var j = 0; j < triggers.length; j++) {
62
- if(f.tag.toLowerCase().indexOf(triggers[i]) !== -1) {
63
  include = true;
64
  break;
65
  }
@@ -68,7 +68,7 @@
68
  if(include) {
69
  var $option = $("<option />").text(text).val(f.tag).data('field', f);
70
  } else {
71
- var $option = $("<option />").text(text + " (Pro only)").val(f.tag).attr('disabled', 'disabled');
72
  }
73
 
74
  $mailchimpMergeFields.append($option);
@@ -82,7 +82,7 @@
82
  // add field to select if no similar option exists yet
83
  if($mailchimpGroupings.find("option[value='"+ grouping.id +"']").length == 0) {
84
  var text = (grouping.name.length > 40) ? grouping.name.substring(0, 40) + '..' : grouping.name;
85
- var $option = $("<option />").text(text + " (Pro only)").val(grouping.id).attr('disabled', 'disabled');
86
  $mailchimpGroupings.append($option);
87
  }
88
  }
@@ -254,7 +254,7 @@
254
  $("#mc4wp-fw-add-to-form").click(addCodeToFormMarkup);
255
 
256
  // init
257
- $lists.change();
258
 
259
  })();
260
 
16
  */
17
  (function() {
18
  // setup variables
19
+ var $lists = $("#mc4wp-lists :input");
20
  var $mailchimpFields = $("#mc4wp-fw-mailchimp-fields");
21
  var $mailchimpMergeFields = $("#mc4wp-fw-mailchimp-fields .merge-fields");
22
  var $mailchimpGroupings = $("#mc4wp-fw-mailchimp-fields .groupings");
47
  var groupings = $(this).data('groupings');
48
 
49
  // loop through merge fields from this list
50
+ for(var i = 0; i < fields.length; i++) {
51
  var f = fields[i];
52
 
53
  // add field to select if no similar option exists yet
59
  var include = false;
60
  var triggers = [ 'name', 'email', 'website' ];
61
  for(var j = 0; j < triggers.length; j++) {
62
+ if(f.tag.toLowerCase().indexOf(triggers[j]) !== -1) {
63
  include = true;
64
  break;
65
  }
68
  if(include) {
69
  var $option = $("<option />").text(text).val(f.tag).data('field', f);
70
  } else {
71
+ var $option = $("<option />").text("(PRO ONLY) " + text).val(f.tag).attr('disabled', 'disabled');
72
  }
73
 
74
  $mailchimpMergeFields.append($option);
82
  // add field to select if no similar option exists yet
83
  if($mailchimpGroupings.find("option[value='"+ grouping.id +"']").length == 0) {
84
  var text = (grouping.name.length > 40) ? grouping.name.substring(0, 40) + '..' : grouping.name;
85
+ var $option = $("<option />").text("(PRO ONLY) " + text).val(grouping.id).attr('disabled', 'disabled');
86
  $mailchimpGroupings.append($option);
87
  }
88
  }
254
  $("#mc4wp-fw-add-to-form").click(addCodeToFormMarkup);
255
 
256
  // init
257
+ setFields();
258
 
259
  })();
260
 
includes/MC4WP_Lite.php CHANGED
@@ -1,53 +1,46 @@
1
  <?php
2
 
3
- class MC4WP_Lite
4
- {
5
  private $options = array();
6
  private static $instance, $checkbox = null, $form = null, $api = null, $admin = null;
7
 
8
- public static function instance()
9
- {
10
  return self::$instance;
11
  }
12
 
13
- public static function checkbox()
14
- {
15
- if(!self::$checkbox) {
16
- require 'MC4WP_Lite_Checkbox.php';
17
- self::$checkbox = new MC4WP_Lite_Checkbox();
18
  }
19
  return self::$checkbox;
20
  }
21
 
22
- public static function form()
23
- {
24
- if(!self::$form) {
25
- require 'MC4WP_Lite_Form.php';
26
- self::$form = new MC4WP_Lite_Form();
27
  }
28
  return self::$form;
29
  }
30
 
31
- public static function api()
32
- {
33
- if(!self::$api) {
34
- require 'MC4WP_Lite_API.php';
35
  $opts = self::instance()->get_options();
36
- self::$api = new MC4WP_Lite_API($opts['general']['api_key']);
37
  }
38
  return self::$api;
39
  }
40
 
41
- public static function admin()
42
- {
43
- if(!self::$admin) {
44
- require_once 'MC4WP_Lite_Admin.php';
45
  self::$admin = new MC4WP_Lite_Admin();
46
  }
47
  return self::$admin;
48
  }
49
- public function __construct()
50
- {
51
  self::$instance = $this;
52
 
53
  $this->backwards_compatibility();
@@ -57,123 +50,116 @@ class MC4WP_Lite
57
  self::checkbox();
58
  self::form();
59
 
60
- if(!defined('DOING_AJAX') || !DOING_AJAX) {
61
  // non-ajax only
62
- if(is_admin()) {
63
- // backend non-ajax only
64
  self::admin();
65
  } else {
66
- // frontend non-ajax only
67
- require 'functions.php';
68
  }
69
  }
70
  }
71
 
72
- private function get_default_options()
73
- {
74
  return array(
75
- 'general' => array(
76
- 'api_key' => ''
77
  ),
78
- 'checkbox' => array(
79
- 'label' => 'Sign me up for the newsletter!',
80
- 'precheck' => 1,
81
- 'css' => 1,
82
- 'show_at_comment_form' => 0,
83
- 'show_at_registration_form' => 0,
84
- 'show_at_multisite_form' => 0,
85
- 'show_at_buddypress_form' => 0,
86
- 'show_at_bbpress_forms' => 0,
87
- 'show_at_other_forms' => 0,
88
- 'lists' => array(),
89
- 'double_optin' => 1
90
  ),
91
- 'form' => array(
92
- 'css' => 1,
93
- 'markup' => "<p>\n\t<label for=\"mc4wp_email\">Email address: </label>\n\t<input type=\"email\" id=\"mc4wp_email\" name=\"EMAIL\" required placeholder=\"Your email address\" />\n</p>\n\n<p>\n\t<input type=\"submit\" value=\"Sign up\" />\n</p>",
94
- 'text_success' => 'Thank you, your sign-up request was successful! Please check your e-mail inbox.',
95
- 'text_error' => 'Oops. Something went wrong. Please try again later.',
96
- 'text_invalid_email' => 'Please provide a valid email address.',
97
- 'text_already_subscribed' => "Given email address is already subscribed, thank you!",
98
- 'redirect' => '',
99
- 'lists' => array(),
100
- 'double_optin' => 1,
101
- 'hide_after_success' => 0
102
  )
103
  );
104
  }
105
 
106
- public function get_options()
107
- {
108
- if(empty($this->options)) {
109
 
110
  $defaults = $this->get_default_options();
111
  $db_keys_option_keys = array(
112
  'mc4wp_lite' => 'general',
113
  'mc4wp_lite_checkbox' => 'checkbox',
114
  'mc4wp_lite_form' => 'form'
115
- );
116
 
117
- foreach($db_keys_option_keys as $db_key => $option_key) {
118
- $option = get_option($db_key);
119
 
120
- // add option to database to prevent query on every pageload
121
- if($option == false) { add_option($db_key, $defaults[$option_key]); }
122
 
123
- $this->options[$option_key] = array_merge($defaults[$option_key], (array) $option);
124
  }
125
  }
126
 
127
  return $this->options;
128
  }
129
 
130
- private function backwards_compatibility()
131
- {
132
- $options = get_option('mc4wp_lite');
133
-
134
- // transfer old options to new option system
135
- if(isset($options['mailchimp_api_key'])) {
136
-
137
- // delete transients
138
- delete_transient('mc4wp_mailchimp_lists');
139
- delete_transient('mc4wp_mailchimp_lists_fallback');
140
 
141
- $new_options = array(
142
- 'general' => array(),
143
- 'checkbox' => array(),
144
- 'form' => array()
145
- );
146
 
147
- $new_options['general']['api_key'] = $options['mailchimp_api_key'];
 
 
 
 
 
148
 
149
- foreach($options as $key => $value) {
150
- $_pos = strpos($key, '_');
151
 
152
- $first_key = substr($key, 0, $_pos);
153
- $second_key = substr($key, $_pos + 1);
154
 
155
- if(isset($new_options[$first_key])) {
 
156
 
157
- // change option name
158
- if($second_key == 'show_at_bp_form') {
159
- $second_key = 'show_at_buddypress_form';
160
- }
161
 
162
- // change option name
163
- if($second_key == 'show_at_ms_form') {
164
- $second_key = 'show_at_multisite_form';
165
- }
166
 
167
- // set value into new option name
168
- $new_options[$first_key][$second_key] = $value;
 
169
  }
170
-
 
 
171
  }
172
 
173
- update_option('mc4wp_lite', $new_options['general']);
174
- update_option('mc4wp_lite_checkbox', $new_options['checkbox']);
175
- update_option('mc4wp_lite_form', $new_options['form']);
176
  }
 
 
 
 
 
177
  }
178
 
179
- }
1
  <?php
2
 
3
+ class MC4WP_Lite {
 
4
  private $options = array();
5
  private static $instance, $checkbox = null, $form = null, $api = null, $admin = null;
6
 
7
+ public static function instance() {
 
8
  return self::$instance;
9
  }
10
 
11
+ public static function checkbox() {
12
+ if ( !self::$checkbox ) {
13
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite_Checkbox.php';
14
+ self::$checkbox = new MC4WP_Lite_Checkbox();
 
15
  }
16
  return self::$checkbox;
17
  }
18
 
19
+ public static function form() {
20
+ if ( !self::$form ) {
21
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite_Form.php';
22
+ self::$form = new MC4WP_Lite_Form();
 
23
  }
24
  return self::$form;
25
  }
26
 
27
+ public static function api() {
28
+ if ( !self::$api ) {
29
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite_API.php';
 
30
  $opts = self::instance()->get_options();
31
+ self::$api = new MC4WP_Lite_API( $opts['general']['api_key'] );
32
  }
33
  return self::$api;
34
  }
35
 
36
+ public static function admin() {
37
+ if ( !self::$admin ) {
38
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite_Admin.php';
 
39
  self::$admin = new MC4WP_Lite_Admin();
40
  }
41
  return self::$admin;
42
  }
43
+ public function __construct() {
 
44
  self::$instance = $this;
45
 
46
  $this->backwards_compatibility();
50
  self::checkbox();
51
  self::form();
52
 
53
+ if ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) {
54
  // non-ajax only
55
+ if ( is_admin() ) {
56
+ // backend non-ajax only
57
  self::admin();
58
  } else {
59
+ // frontend non-ajax only
60
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
61
  }
62
  }
63
  }
64
 
65
+ private function get_default_options() {
 
66
  return array(
67
+ 'general' => array(
68
+ 'api_key' => ''
69
  ),
70
+ 'checkbox' => array(
71
+ 'label' => 'Sign me up for the newsletter!',
72
+ 'precheck' => 1,
73
+ 'css' => 1,
74
+ 'show_at_comment_form' => 0,
75
+ 'show_at_registration_form' => 0,
76
+ 'show_at_multisite_form' => 0,
77
+ 'show_at_buddypress_form' => 0,
78
+ 'show_at_bbpress_forms' => 0,
79
+ 'show_at_other_forms' => 0,
80
+ 'lists' => array(),
81
+ 'double_optin' => 1
82
  ),
83
+ 'form' => array(
84
+ 'css' => 1,
85
+ 'markup' => "<p>\n\t<label for=\"mc4wp_email\">Email address: </label>\n\t<input type=\"email\" id=\"mc4wp_email\" name=\"EMAIL\" required placeholder=\"Your email address\" />\n</p>\n\n<p>\n\t<input type=\"submit\" value=\"Sign up\" />\n</p>",
86
+ 'text_success' => 'Thank you, your sign-up request was successful! Please check your e-mail inbox.',
87
+ 'text_error' => 'Oops. Something went wrong. Please try again later.',
88
+ 'text_invalid_email' => 'Please provide a valid email address.',
89
+ 'text_already_subscribed' => "Given email address is already subscribed, thank you!",
90
+ 'redirect' => '',
91
+ 'lists' => array(),
92
+ 'double_optin' => 1,
93
+ 'hide_after_success' => 0
94
  )
95
  );
96
  }
97
 
98
+ public function get_options() {
99
+ if ( empty( $this->options ) ) {
 
100
 
101
  $defaults = $this->get_default_options();
102
  $db_keys_option_keys = array(
103
  'mc4wp_lite' => 'general',
104
  'mc4wp_lite_checkbox' => 'checkbox',
105
  'mc4wp_lite_form' => 'form'
106
+ );
107
 
108
+ foreach ( $db_keys_option_keys as $db_key => $option_key ) {
109
+ $option = get_option( $db_key );
110
 
111
+ // add option to database to prevent query on every pageload
112
+ if ( $option == false ) { add_option( $db_key, $defaults[$option_key] ); }
113
 
114
+ $this->options[$option_key] = array_merge( $defaults[$option_key], (array) $option );
115
  }
116
  }
117
 
118
  return $this->options;
119
  }
120
 
121
+ private function backwards_compatibility() {
122
+ $options = get_option( 'mc4wp_lite' );
 
 
 
 
 
 
 
 
123
 
124
+ if ( !isset( $options['mailchimp_api_key'] ) ) { return; }
 
 
 
 
125
 
126
+ // transfer old options to new option system
127
+ $new_options = array(
128
+ 'general' => array(),
129
+ 'checkbox' => array(),
130
+ 'form' => array()
131
+ );
132
 
133
+ $new_options['general']['api_key'] = $options['mailchimp_api_key'];
 
134
 
135
+ foreach ( $options as $key => $value ) {
136
+ $_pos = strpos( $key, '_' );
137
 
138
+ $first_key = substr( $key, 0, $_pos );
139
+ $second_key = substr( $key, $_pos + 1 );
140
 
141
+ if ( isset( $new_options[$first_key] ) ) {
 
 
 
142
 
143
+ // change option name
144
+ if ( $second_key == 'show_at_bp_form' ) {
145
+ $second_key = 'show_at_buddypress_form';
146
+ }
147
 
148
+ // change option name
149
+ if ( $second_key == 'show_at_ms_form' ) {
150
+ $second_key = 'show_at_multisite_form';
151
  }
152
+
153
+ // set value into new option name
154
+ $new_options[$first_key][$second_key] = $value;
155
  }
156
 
 
 
 
157
  }
158
+
159
+ update_option( 'mc4wp_lite', $new_options['general'] );
160
+ update_option( 'mc4wp_lite_checkbox', $new_options['checkbox'] );
161
+ update_option( 'mc4wp_lite_form', $new_options['form'] );
162
+
163
  }
164
 
165
+ }
includes/MC4WP_Lite_API.php CHANGED
@@ -92,7 +92,9 @@ class MC4WP_Lite_API {
92
  }
93
 
94
  private function call($method, array $data = array())
95
- {
 
 
96
 
97
  $data['apikey'] = $this->api_key;
98
 
92
  }
93
 
94
  private function call($method, array $data = array())
95
+ {
96
+ // do not make request when no api key was provided.
97
+ if(empty($this->api_key)) { return false; }
98
 
99
  $data['apikey'] = $this->api_key;
100
 
includes/MC4WP_Lite_Admin.php CHANGED
@@ -103,7 +103,7 @@ class MC4WP_Lite_Admin
103
  }
104
 
105
  $lists = $this->get_mailchimp_lists();
106
- require 'views/api-settings.php';
107
  }
108
 
109
  public function show_checkbox_settings()
@@ -111,7 +111,7 @@ class MC4WP_Lite_Admin
111
  $opts = $this->options['checkbox'];
112
  $lists = $this->get_mailchimp_lists();
113
  $tab = 'checkbox-settings';
114
- require 'views/checkbox-settings.php';
115
  }
116
 
117
  public function show_form_settings()
@@ -119,7 +119,7 @@ class MC4WP_Lite_Admin
119
  $opts = $this->options['form'];
120
  $lists = $this->get_mailchimp_lists();
121
  $tab = 'form-settings';
122
- require 'views/form-settings.php';
123
  }
124
 
125
  /**
@@ -139,34 +139,41 @@ class MC4WP_Lite_Admin
139
  if($refresh_cache || !$cached_lists) {
140
  // make api request for lists
141
  $api = MC4WP_Lite::api();
142
- $lists = $api->get_lists();
 
143
 
144
- if($lists) {
145
 
146
  $list_ids = array();
147
- foreach($lists as $key => $list) {
148
  $list_ids[] = $list->id;
149
- $lists[$key]->merge_vars = array();
150
- $lists[$key]->interest_groupings = array();
151
- }
152
-
153
- // get lists including merge vars
154
- $lists = $api->get_lists_with_merge_vars($list_ids);
155
 
156
- // get interest groupings for each list
157
- if($lists) {
158
- foreach($lists as $key => $list) {
159
- $lists[$key]->interest_groupings = array();
 
 
 
 
 
 
 
 
 
 
160
 
161
- $result = $api->get_list_groupings($list->id);
162
- if($result) {
163
- $lists[$key]->interest_groupings = $result;
164
- }
 
 
165
  }
166
  }
167
 
168
  // cache renewal triggered manually?
169
- if(isset($_REQUEST['renew-cached-data'])) {
170
  if($lists) {
171
  add_settings_error("mc4wp", "cache-renewed", 'Renewed MailChimp cache.', 'updated' );
172
  } else {
@@ -189,4 +196,40 @@ class MC4WP_Lite_Admin
189
  return $cached_lists;
190
  }
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  }
103
  }
104
 
105
  $lists = $this->get_mailchimp_lists();
106
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/api-settings.php';
107
  }
108
 
109
  public function show_checkbox_settings()
111
  $opts = $this->options['checkbox'];
112
  $lists = $this->get_mailchimp_lists();
113
  $tab = 'checkbox-settings';
114
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/checkbox-settings.php';
115
  }
116
 
117
  public function show_form_settings()
119
  $opts = $this->options['form'];
120
  $lists = $this->get_mailchimp_lists();
121
  $tab = 'form-settings';
122
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/form-settings.php';
123
  }
124
 
125
  /**
139
  if($refresh_cache || !$cached_lists) {
140
  // make api request for lists
141
  $api = MC4WP_Lite::api();
142
+ $lists = array();
143
+ $lists_data = $api->get_lists();
144
 
145
+ if($lists_data) {
146
 
147
  $list_ids = array();
148
+ foreach($lists_data as $list) {
149
  $list_ids[] = $list->id;
 
 
 
 
 
 
150
 
151
+ $lists["{$list->id}"] = (object) array(
152
+ 'id' => $list->id,
153
+ 'name' => $list->name,
154
+ 'subscriber_count' => $list->stats->member_count,
155
+ 'merge_vars' => array(),
156
+ 'interest_groupings' => array()
157
+ );
158
+
159
+ // get interest groupings
160
+ $groupings_data = $api->get_list_groupings($list->id);
161
+ if($groupings_data) {
162
+ $lists["{$list->id}"]->interest_groupings = array_map(array($this, 'strip_unnecessary_grouping_properties'), $groupings_data);
163
+ }
164
+ }
165
 
166
+ // get merge vars for all lists at once
167
+ $merge_vars_data = $api->get_lists_with_merge_vars($list_ids);
168
+ if($merge_vars_data) {
169
+ foreach($merge_vars_data as $list) {
170
+ // add merge vars to list
171
+ $lists["{$list->id}"]->merge_vars = array_map(array($this, 'strip_unnecessary_merge_vars_properties'), $list->merge_vars);
172
  }
173
  }
174
 
175
  // cache renewal triggered manually?
176
+ if(isset($_POST['renew-cached-data'])) {
177
  if($lists) {
178
  add_settings_error("mc4wp", "cache-renewed", 'Renewed MailChimp cache.', 'updated' );
179
  } else {
196
  return $cached_lists;
197
  }
198
 
199
+ /**
200
+ * Build the group array object which will be stored in cache
201
+ */
202
+ public function strip_unnecessary_group_properties($group) {
203
+ return (object) array(
204
+ 'name' => $group->name
205
+ );
206
+ }
207
+
208
+ /**
209
+ * Build the groupings array object which will be stored in cache
210
+ */
211
+ public function strip_unnecessary_grouping_properties($grouping)
212
+ {
213
+ return (object) array(
214
+ 'id' => $grouping->id,
215
+ 'name' => $grouping->name,
216
+ 'groups' => array_map(array($this, 'strip_unnecessary_group_properties'), $grouping->groups),
217
+ 'form_field' => $grouping->form_field
218
+ );
219
+ }
220
+
221
+ /**
222
+ * Build the merge_var array object which will be stored in cache
223
+ */
224
+ public function strip_unnecessary_merge_vars_properties($merge_var)
225
+ {
226
+ return (object) array(
227
+ 'name' => $merge_var->name,
228
+ 'field_type' => $merge_var->field_type,
229
+ 'req' => $merge_var->req,
230
+ 'tag' => $merge_var->tag
231
+ );
232
+
233
+ }
234
+
235
  }
includes/MC4WP_Lite_Checkbox.php CHANGED
@@ -329,7 +329,7 @@ class MC4WP_Lite_Checkbox
329
  }
330
 
331
  // check if result succeeded, show debug message to administrators
332
- if($result !== true && $api->has_error() && current_user_can('manage_options'))
333
  {
334
  wp_die("
335
  <h3>MailChimp for WP - Error</h3>
329
  }
330
 
331
  // check if result succeeded, show debug message to administrators
332
+ if($result !== true && $api->has_error() && current_user_can('manage_options') && !defined("DOING_AJAX"))
333
  {
334
  wp_die("
335
  <h3>MailChimp for WP - Error</h3>
includes/MC4WP_Lite_Form.php CHANGED
@@ -1,98 +1,96 @@
1
  <?php
2
 
3
- class MC4WP_Lite_Form
4
- {
5
  private $form_instance_number = 1;
6
  private $error = null;
7
  private $success = false;
8
  private $submitted_form_instance = 0;
9
 
10
- public function __construct()
11
- {
12
  $opts = $this->get_options();
13
 
14
- if($opts['css']) {
15
- add_action( 'wp_enqueue_scripts', array($this, 'load_stylesheet') );
16
  }
17
-
18
- add_shortcode('mc4wp-form', array($this, 'output_form'));
19
 
20
  // enable shortcodes in text widgets
21
- add_filter( 'widget_text', 'shortcode_unautop');
22
- add_filter( 'widget_text', 'do_shortcode', 11);
23
 
24
- if(isset($_POST['mc4wp_form_submit'])) {
25
  $this->ensure_backwards_compatibility();
26
- add_action('init', array($this, 'submit'));
27
  }
 
 
28
  }
29
 
30
- public function get_options()
31
- {
32
  $options = MC4WP_Lite::instance()->get_options();
33
  return $options['form'];
34
  }
35
 
36
- public function load_stylesheet()
37
- {
38
- wp_enqueue_style( 'mc4wp-form-reset', plugins_url('mailchimp-for-wp/assets/css/form.css') );
39
  }
40
 
41
- public function output_form($atts, $content = null)
42
- {
43
  $opts = $this->get_options();
44
 
45
  // add some useful css classes
46
  $css_classes = ' ';
47
- if($this->error) $css_classes .= 'mc4wp-form-error ';
48
- if($this->success) $css_classes .= 'mc4wp-form-success ';
49
 
50
  $content = "\n<!-- Form by MailChimp for WP plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/ -->\n";
51
- $content .= '<form method="post" action="'. $this->get_current_url() .'#mc4wp-form-'. $this->form_instance_number .'" id="mc4wp-form-'.$this->form_instance_number.'" class="mc4wp-form form'.$css_classes.'">';
52
 
53
  // maybe hide the form
54
- if(!($this->success && $opts['hide_after_success'])) {
55
- $form_markup = __($opts['markup']);
56
- // replace special values
57
- $form_markup = $this->replace_form_variables($form_markup);
58
 
 
 
 
59
  $content .= $form_markup;
60
 
61
  // hidden fields
62
  $content .= '<textarea name="mc4wp_required_but_not_really" style="display: none;"></textarea>';
63
  $content .= '<input type="hidden" name="mc4wp_form_submit" value="1" />';
64
  $content .= '<input type="hidden" name="mc4wp_form_instance" value="'. $this->form_instance_number .'" />';
65
- }
 
66
 
67
- if($this->form_instance_number == $this->submitted_form_instance) {
68
-
69
- if($this->success) {
70
- $content .= '<div class="mc4wp-alert mc4wp-success">' . __($opts['text_success']) . '</div>';
71
- } elseif($this->error) {
72
 
73
  $api = MC4WP_Lite::api();
74
  $e = $this->error;
75
 
76
- if($e == 'already_subscribed') {
77
- $text = (empty($opts['text_already_subscribed'])) ? $api->get_error_message() : $opts['text_already_subscribed'];
78
- $content .= '<div class="mc4wp-alert mc4wp-notice">'. __($text) .'</div>';
79
- } elseif(isset($opts['text_' . $e]) && !empty($opts['text_'. $e] )) {
80
- $content .= '<div class="mc4wp-alert mc4wp-error">' . __($opts['text_' . $e]) . '</div>';
81
  }
82
 
83
- if(current_user_can('manage_options')) {
84
 
85
- if($api->has_error()) {
86
  $content .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> '. $api->get_error_message() . '</div>';
87
- }
88
- }
89
 
90
  }
91
  // endif
92
  }
93
 
94
- if(current_user_can('manage_options') && empty($opts['lists'])) {
95
- $content .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> you have not selected a MailChimp list for this sign-up form to subscribe to yet. <a href="'. admin_url('admin.php?page=mc4wp-lite-form-settings') .'">Edit your form settings</a> and select at least 1 list.</div>';
96
  }
97
 
98
  $content .= "</form>";
@@ -104,19 +102,22 @@ class MC4WP_Lite_Form
104
  return $content;
105
  }
106
 
107
- public function submit()
108
- {
109
- $opts = $this->get_options();
110
  $this->submitted_form_instance = (int) $_POST['mc4wp_form_instance'];
111
 
112
- if(!isset($_POST['EMAIL']) || !is_email($_POST['EMAIL'])) {
113
- // no (valid) e-mail address has been given
 
 
114
 
 
 
115
  $this->error = 'invalid_email';
116
  return false;
117
  }
118
 
119
- if(isset($_POST['mc4wp_required_but_not_really']) && !empty($_POST['mc4wp_required_but_not_really'])) {
120
  // spam bot filled the honeypot field
121
  return false;
122
  }
@@ -126,42 +127,42 @@ class MC4WP_Lite_Form
126
  // setup merge vars
127
  $merge_vars = array();
128
 
129
- foreach($_POST as $name => $value) {
130
 
131
  // only add uppercases fields to merge variables array
132
- if(!empty($name) && $name == 'EMAIL' || $name !== strtoupper($name)) { continue; }
133
 
134
- if($name === 'GROUPINGS') {
135
 
136
  $groupings = $value;
137
 
138
  // malformed
139
- if(!is_array($groupings)) { continue; }
140
 
141
  // setup groupings array
142
  $merge_vars['GROUPINGS'] = array();
143
 
144
- foreach($groupings as $grouping_id_or_name => $groups) {
145
 
146
- $grouping = array();
147
 
148
- if(is_numeric($grouping_id_or_name)) {
149
- $grouping['id'] = $grouping_id_or_name;
150
- } else {
151
- $grouping['name'] = $grouping_id_or_name;
152
- }
153
 
154
- if(is_array($groups)) {
155
- $grouping['groups'] = implode(',', $groups);
156
- } else {
157
- $grouping['groups'] = $groups;
158
- }
159
 
160
- // add grouping to array
161
- $merge_vars['GROUPINGS'][] = $grouping;
162
  }
163
 
164
- if(empty($merge_vars['GROUPINGS'])) { unset($merge_vars['GROUPINGS']); }
165
 
166
  } else {
167
  $merge_vars[$name] = $value;
@@ -169,14 +170,14 @@ class MC4WP_Lite_Form
169
 
170
  }
171
 
172
- $result = $this->subscribe($email, $merge_vars);
173
 
174
- if($result === true) {
175
  $this->success = true;
176
 
177
  // check if we want to redirect the visitor
178
- if(!empty($opts['redirect'])) {
179
- wp_redirect($opts['redirect']);
180
  exit;
181
  }
182
 
@@ -190,148 +191,89 @@ class MC4WP_Lite_Form
190
  }
191
  }
192
 
193
- private function get_ip_address()
194
- {
195
- if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
196
- $ip = $_SERVER['HTTP_CLIENT_IP'];
197
- } elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
198
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
199
- } else {
200
- $ip = $_SERVER['REMOTE_ADDR'];
201
- }
202
-
203
- return $ip;
204
- }
205
-
206
- private function get_current_url() {
207
- $page_url = 'http';
208
-
209
- if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { $page_url .= 's'; }
210
-
211
- $page_url .= '://';
212
-
213
- if (!isset($_SERVER['REQUEST_URI'])) {
214
- $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 1);
215
- if (isset($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] .='?'.$_SERVER['QUERY_STRING']; }
216
- }
217
-
218
- if($_SERVER['SERVER_PORT'] != '80') {
219
- $page_url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
220
- } else {
221
- $page_url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
222
- }
223
-
224
- return $page_url;
225
- }
226
-
227
  /*
228
  Ensure backwards compatibility so sign-up forms that contain old form mark-up rules don't break
229
  - Uppercase $_POST variables that should be sent to MailChimp
230
- - Format GROUPINGS in one of the following formats.
231
  $_POST[GROUPINGS][$group_id] = "Group 1, Group 2"
232
  $_POST[GROUPINGS][$group_name] = array("Group 1", "Group 2")
233
  */
234
- public function ensure_backwards_compatibility()
235
- {
236
 
237
  // upercase $_POST variables
238
- foreach($_POST as $name => $value) {
239
-
240
  // only uppercase variables which are not already uppercased, skip mc4wp internal vars
241
- if($name === strtoupper($name) || in_array($name, array('mc4wp_form_instance', 'mc4wp_required_but_not_really', 'mc4wp_form_submit'))) continue;
242
- $uppercased_name = strtoupper($name);
243
 
244
  // set new (uppercased) $_POST variable, unset old one.
245
  $_POST[$uppercased_name] = $value;
246
- unset($_POST[$name]);
247
  }
248
 
249
  // detect old style GROUPINGS, then fix it.
250
- if(isset($_POST['GROUPINGS']) && is_array($_POST['GROUPINGS']) && isset($_POST['GROUPINGS'][0])) {
251
 
252
  $old_groupings = $_POST['GROUPINGS'];
253
- unset($_POST['GROUPINGS']);
254
  $new_groupings = array();
255
 
256
- foreach($old_groupings as $grouping) {
257
 
258
- if(!isset($grouping['id']) && !isset($grouping['name'])) { continue; }
259
 
260
- $key = (isset($grouping['id'])) ? $grouping['id'] : $grouping['name'];
261
 
262
  $new_groupings[$key] = $grouping['groups'];
263
 
264
  }
265
 
266
  // re-fill $_POST array with new groupings
267
- if(!empty($new_groupings)) { $_POST['GROUPINGS'] = $new_groupings; }
268
 
269
  }
270
 
271
  return;
272
  }
273
 
274
- public function subscribe($email, array $merge_vars = array())
275
- {
276
  $api = MC4WP_Lite::api();
277
  $opts = $this->get_options();
278
 
279
  $lists = $opts['lists'];
280
-
281
- if(empty($lists)) {
282
  return 'no_lists_selected';
283
  }
284
 
285
  // guess FNAME and LNAME
286
- if(isset($merge_vars['NAME']) && !isset($merge_vars['FNAME']) && !isset($merge_vars['LNAME'])) {
287
-
288
- $strpos = strpos($name, ' ');
289
 
290
- if($strpos) {
291
- $merge_vars['FNAME'] = substr($name, 0, $strpos);
292
- $merge_vars['LNAME'] = substr($name, $strpos);
293
  } else {
294
  $merge_vars['FNAME'] = $name;
295
  }
296
  }
297
-
298
- foreach($lists as $list) {
299
- $result = $api->subscribe($list, $email, $merge_vars, 'html', $opts['double_optin']);
300
  }
301
 
302
- if($result === true) {
303
  $this->success = true;
304
  } else {
305
  $this->success = false;
306
  $this->error = $result;
307
  }
308
-
309
  // flawed
310
  // this will only return the result of the last list a subscribe attempt has been sent to
311
  return $result;
312
  }
313
 
314
- private function replace_form_variables($markup)
315
- {
316
-
317
- $markup = str_replace(array('%N%', '{n}'), $this->form_instance_number, $markup);
318
- $markup = str_replace(array('%IP_ADDRESS%', '{ip}'), $this->get_ip_address(), $markup);
319
- $markup = str_replace(array('%DATE%', '{date}'), date('Y/m/d'), $markup);
320
- $markup = str_replace('{time}', date("H:i:s"), $markup);
321
- $markup = str_replace('{current_url}', $this->get_current_url(), $markup);
322
-
323
- $needles = array('{user_email}', '{user_firstname}', '{user_lastname}', '{user_name}', '{user_id}');
324
- if(is_user_logged_in()) {
325
- // logged in user, replace vars by user vars
326
- $user = wp_get_current_user();
327
- $replacements = array($user->user_email, $user->user_firstname, $user->user_lastname, $user->display_name, $user->ID);
328
- $markup = str_replace($needles, $replacements, $markup);
329
- } else {
330
- // no logged in user, remove vars
331
- $markup = str_replace($needles, '', $markup);
332
- }
333
-
334
- return $markup;
335
- }
336
-
337
- }
1
  <?php
2
 
3
+ class MC4WP_Lite_Form {
 
4
  private $form_instance_number = 1;
5
  private $error = null;
6
  private $success = false;
7
  private $submitted_form_instance = 0;
8
 
9
+ public function __construct() {
 
10
  $opts = $this->get_options();
11
 
12
+ if ( $opts['css'] ) {
13
+ add_action( 'wp_enqueue_scripts', array( $this, 'load_stylesheet' ) );
14
  }
15
+
16
+ add_shortcode( 'mc4wp-form', array( $this, 'output_form' ) );
17
 
18
  // enable shortcodes in text widgets
19
+ add_filter( 'widget_text', 'shortcode_unautop' );
20
+ add_filter( 'widget_text', 'do_shortcode', 11 );
21
 
22
+ if ( isset( $_POST['mc4wp_form_submit'] ) ) {
23
  $this->ensure_backwards_compatibility();
24
+ add_action( 'init', array( $this, 'submit' ) );
25
  }
26
+
27
+
28
  }
29
 
30
+ public function get_options() {
 
31
  $options = MC4WP_Lite::instance()->get_options();
32
  return $options['form'];
33
  }
34
 
35
+ public function load_stylesheet() {
36
+ wp_enqueue_style( 'mc4wp-form-reset', plugins_url( 'mailchimp-for-wp/assets/css/form.css' ) );
 
37
  }
38
 
39
+ public function output_form( $atts, $content = null ) {
 
40
  $opts = $this->get_options();
41
 
42
  // add some useful css classes
43
  $css_classes = ' ';
44
+ if ( $this->error ) $css_classes .= 'mc4wp-form-error ';
45
+ if ( $this->success ) $css_classes .= 'mc4wp-form-success ';
46
 
47
  $content = "\n<!-- Form by MailChimp for WP plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/ -->\n";
48
+ $content .= '<form method="post" action="#mc4wp-form-'. $this->form_instance_number .'" id="mc4wp-form-'.$this->form_instance_number.'" class="mc4wp-form form'.$css_classes.'">';
49
 
50
  // maybe hide the form
51
+ if ( !( $this->success && $opts['hide_after_success'] ) ) {
52
+ $form_markup = __( $opts['markup'] );
 
 
53
 
54
+ // replace special values
55
+ $form_markup = str_replace( array( '%N%', '{n}' ), $this->form_instance_number, $form_markup );
56
+ $form_markup = mc4wp_replace_variables( $form_markup, array_values( $opts['lists'] ) );
57
  $content .= $form_markup;
58
 
59
  // hidden fields
60
  $content .= '<textarea name="mc4wp_required_but_not_really" style="display: none;"></textarea>';
61
  $content .= '<input type="hidden" name="mc4wp_form_submit" value="1" />';
62
  $content .= '<input type="hidden" name="mc4wp_form_instance" value="'. $this->form_instance_number .'" />';
63
+ $content .= '<input type="hidden" name="mc4wp_form_nonce" value="'. wp_create_nonce( '_mc4wp_form_nonce' ) .'" />';
64
+ }
65
 
66
+ if ( $this->form_instance_number == $this->submitted_form_instance ) {
67
+ if ( $this->success ) {
68
+ $content .= '<div class="mc4wp-alert mc4wp-success">' . __( $opts['text_success'] ) . '</div>';
69
+ } elseif ( $this->error ) {
 
70
 
71
  $api = MC4WP_Lite::api();
72
  $e = $this->error;
73
 
74
+ if ( $e == 'already_subscribed' ) {
75
+ $text = ( empty( $opts['text_already_subscribed'] ) ) ? $api->get_error_message() : $opts['text_already_subscribed'];
76
+ $content .= '<div class="mc4wp-alert mc4wp-notice">'. __( $text ) .'</div>';
77
+ } elseif ( isset( $opts['text_' . $e] ) && !empty( $opts['text_'. $e] ) ) {
78
+ $content .= '<div class="mc4wp-alert mc4wp-error">' . __( $opts['text_' . $e] ) . '</div>';
79
  }
80
 
81
+ if ( current_user_can( 'manage_options' ) ) {
82
 
83
+ if ( $api->has_error() ) {
84
  $content .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> '. $api->get_error_message() . '</div>';
85
+ }
86
+ }
87
 
88
  }
89
  // endif
90
  }
91
 
92
+ if ( current_user_can( 'manage_options' ) && empty( $opts['lists'] ) ) {
93
+ $content .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> you have not selected a MailChimp list for this sign-up form to subscribe to yet. <a href="'. admin_url( 'admin.php?page=mc4wp-lite-form-settings' ) .'">Edit your form settings</a> and select at least 1 list.</div>';
94
  }
95
 
96
  $content .= "</form>";
102
  return $content;
103
  }
104
 
105
+ public function submit() {
106
+ $opts = $this->get_options();
 
107
  $this->submitted_form_instance = (int) $_POST['mc4wp_form_instance'];
108
 
109
+ if ( !isset( $_POST['mc4wp_form_nonce'] ) || !wp_verify_nonce( $_POST['mc4wp_form_nonce'], '_mc4wp_form_nonce' ) ) {
110
+ $this->error = 'invalid_nonce';
111
+ return false;
112
+ }
113
 
114
+ if ( !isset( $_POST['EMAIL'] ) || !is_email( $_POST['EMAIL'] ) ) {
115
+ // no (valid) e-mail address has been given
116
  $this->error = 'invalid_email';
117
  return false;
118
  }
119
 
120
+ if ( isset( $_POST['mc4wp_required_but_not_really'] ) && !empty( $_POST['mc4wp_required_but_not_really'] ) ) {
121
  // spam bot filled the honeypot field
122
  return false;
123
  }
127
  // setup merge vars
128
  $merge_vars = array();
129
 
130
+ foreach ( $_POST as $name => $value ) {
131
 
132
  // only add uppercases fields to merge variables array
133
+ if ( !empty( $name ) && $name == 'EMAIL' || $name !== strtoupper( $name ) ) { continue; }
134
 
135
+ if ( $name === 'GROUPINGS' ) {
136
 
137
  $groupings = $value;
138
 
139
  // malformed
140
+ if ( !is_array( $groupings ) ) { continue; }
141
 
142
  // setup groupings array
143
  $merge_vars['GROUPINGS'] = array();
144
 
145
+ foreach ( $groupings as $grouping_id_or_name => $groups ) {
146
 
147
+ $grouping = array();
148
 
149
+ if ( is_numeric( $grouping_id_or_name ) ) {
150
+ $grouping['id'] = $grouping_id_or_name;
151
+ } else {
152
+ $grouping['name'] = $grouping_id_or_name;
153
+ }
154
 
155
+ if ( is_array( $groups ) ) {
156
+ $grouping['groups'] = implode( ',', $groups );
157
+ } else {
158
+ $grouping['groups'] = $groups;
159
+ }
160
 
161
+ // add grouping to array
162
+ $merge_vars['GROUPINGS'][] = $grouping;
163
  }
164
 
165
+ if ( empty( $merge_vars['GROUPINGS'] ) ) { unset( $merge_vars['GROUPINGS'] ); }
166
 
167
  } else {
168
  $merge_vars[$name] = $value;
170
 
171
  }
172
 
173
+ $result = $this->subscribe( $email, $merge_vars );
174
 
175
+ if ( $result === true ) {
176
  $this->success = true;
177
 
178
  // check if we want to redirect the visitor
179
+ if ( !empty( $opts['redirect'] ) ) {
180
+ wp_redirect( $opts['redirect'] );
181
  exit;
182
  }
183
 
191
  }
192
  }
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  /*
195
  Ensure backwards compatibility so sign-up forms that contain old form mark-up rules don't break
196
  - Uppercase $_POST variables that should be sent to MailChimp
197
+ - Format GROUPINGS in one of the following formats.
198
  $_POST[GROUPINGS][$group_id] = "Group 1, Group 2"
199
  $_POST[GROUPINGS][$group_name] = array("Group 1", "Group 2")
200
  */
201
+ public function ensure_backwards_compatibility() {
 
202
 
203
  // upercase $_POST variables
204
+ foreach ( $_POST as $name => $value ) {
205
+
206
  // only uppercase variables which are not already uppercased, skip mc4wp internal vars
207
+ if ( $name === strtoupper( $name ) || in_array( $name, array( 'mc4wp_form_instance', 'mc4wp_form_nonce', 'mc4wp_required_but_not_really', 'mc4wp_form_submit' ) ) ) continue;
208
+ $uppercased_name = strtoupper( $name );
209
 
210
  // set new (uppercased) $_POST variable, unset old one.
211
  $_POST[$uppercased_name] = $value;
212
+ unset( $_POST[$name] );
213
  }
214
 
215
  // detect old style GROUPINGS, then fix it.
216
+ if ( isset( $_POST['GROUPINGS'] ) && is_array( $_POST['GROUPINGS'] ) && isset( $_POST['GROUPINGS'][0] ) ) {
217
 
218
  $old_groupings = $_POST['GROUPINGS'];
219
+ unset( $_POST['GROUPINGS'] );
220
  $new_groupings = array();
221
 
222
+ foreach ( $old_groupings as $grouping ) {
223
 
224
+ if ( !isset( $grouping['id'] ) && !isset( $grouping['name'] ) ) { continue; }
225
 
226
+ $key = ( isset( $grouping['id'] ) ) ? $grouping['id'] : $grouping['name'];
227
 
228
  $new_groupings[$key] = $grouping['groups'];
229
 
230
  }
231
 
232
  // re-fill $_POST array with new groupings
233
+ if ( !empty( $new_groupings ) ) { $_POST['GROUPINGS'] = $new_groupings; }
234
 
235
  }
236
 
237
  return;
238
  }
239
 
240
+ public function subscribe( $email, array $merge_vars = array() ) {
 
241
  $api = MC4WP_Lite::api();
242
  $opts = $this->get_options();
243
 
244
  $lists = $opts['lists'];
245
+
246
+ if ( empty( $lists ) ) {
247
  return 'no_lists_selected';
248
  }
249
 
250
  // guess FNAME and LNAME
251
+ if ( isset( $merge_vars['NAME'] ) && !isset( $merge_vars['FNAME'] ) && !isset( $merge_vars['LNAME'] ) ) {
252
+
253
+ $strpos = strpos( $name, ' ' );
254
 
255
+ if ( $strpos ) {
256
+ $merge_vars['FNAME'] = substr( $name, 0, $strpos );
257
+ $merge_vars['LNAME'] = substr( $name, $strpos );
258
  } else {
259
  $merge_vars['FNAME'] = $name;
260
  }
261
  }
262
+
263
+ foreach ( $lists as $list ) {
264
+ $result = $api->subscribe( $list, $email, $merge_vars, 'html', $opts['double_optin'] );
265
  }
266
 
267
+ if ( $result === true ) {
268
  $this->success = true;
269
  } else {
270
  $this->success = false;
271
  $this->error = $result;
272
  }
273
+
274
  // flawed
275
  // this will only return the result of the last list a subscribe attempt has been sent to
276
  return $result;
277
  }
278
 
279
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/functions.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- if(!function_exists('mc4wp_show_checkbox')) {
4
- function mc4wp_show_checkbox()
5
- {
6
- MC4WP_Lite::checkbox()->output_checkbox();
7
- }
8
- }
9
-
10
- if(!function_exists('mc4wp_show_form')) {
11
- function mc4wp_show_form()
12
- {
13
- echo do_shortcode('[mc4wp-form]');
14
- }
15
- }
16
-
17
-
18
- // end of file
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/template-functions.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!function_exists('mc4wp_show_checkbox')) {
4
+ function mc4wp_show_checkbox()
5
+ {
6
+ MC4WP_Lite::checkbox()->output_checkbox();
7
+ }
8
+ }
9
+
10
+ if(!function_exists('mc4wp_show_form')) {
11
+ function mc4wp_show_form($id = 0)
12
+ {
13
+ echo mc4wp_get_form($id);
14
+ }
15
+ }
16
+
17
+ if(!function_exists('mc4wp_get_form')) {
18
+ function mc4wp_get_form($id = 0)
19
+ {
20
+ return MC4WP_Lite::form()->output_form(array('id' => $id));
21
+ }
22
+ }
23
+
24
+ /* Variables */
25
+ if(!function_exists('mc4wp_replace_variables')) {
26
+ function mc4wp_replace_variables($text, $list_ids = array())
27
+ {
28
+ $needles = array('{ip}', '{current_url}', '{date}', '{time}');
29
+ $replacements = array($_SERVER['REMOTE_ADDR'], mc4wp_get_current_url(), date("m/d/Y"), date("H:i:s"));
30
+ $text = str_replace($needles, $replacements, $text);
31
+
32
+ // subscriber count?
33
+ if(strstr($text, '{subscriber_count}') != false) {
34
+ $subscriber_count = mc4wp_get_subscriber_count($list_ids);
35
+ $text = str_replace('{subscriber_count}', $subscriber_count, $text);
36
+ }
37
+
38
+ $needles = array('{user_email}', '{user_firstname}', '{user_lastname}', '{user_name}', '{user_id}');
39
+ if(is_user_logged_in() && ($user = wp_get_current_user()) && ($user instanceof WP_User)) {
40
+ // logged in user, replace vars by user vars
41
+ $user = wp_get_current_user();
42
+ $replacements = array($user->user_email, $user->user_firstname, $user->user_lastname, $user->display_name, $user->ID);
43
+ $text = str_replace($needles, $replacements, $text);
44
+ } else {
45
+ // no logged in user, remove vars
46
+ $text = str_replace($needles, '', $text);
47
+ }
48
+
49
+ return $text;
50
+ }
51
+ }
52
+
53
+ /* helper functions */
54
+ if(!function_exists('mc4wp_get_subscriber_count')) {
55
+ function mc4wp_get_subscriber_count($list_ids)
56
+ {
57
+ $list_counts = get_transient('mc4wp_list_counts');
58
+
59
+ if(!$list_counts) {
60
+ // make api call
61
+ $api = MC4WP_Lite::api();
62
+ $lists = $api->get_lists();
63
+ $list_counts = array();
64
+
65
+ if($lists) {
66
+
67
+ foreach($lists as $list) {
68
+ $list_counts["{$list->id}"] = $list->stats->member_count;
69
+ }
70
+
71
+ $transient_lifetime = apply_filters('mc4wp_lists_count_cache_time', 1200); // 20 mins by default
72
+
73
+ set_transient('mc4wp_list_counts', $list_counts, $transient_lifetime);
74
+ set_transient('mc4wp_list_counts_fallback', $list_counts, 3600 * 24); // 1 day
75
+ } else {
76
+ // use fallback transient
77
+ $list_counts = get_transient('mc4wp_list_counts_fallback');
78
+ if(!$list_counts) { return 0; }
79
+ }
80
+ }
81
+
82
+ // start calculating subscribers count for all list combined
83
+ $count = 0;
84
+ foreach($list_ids as $id) {
85
+ $count += $list_counts[$id];
86
+ }
87
+
88
+ return apply_filters('mc4wp_subscriber_count', $count);
89
+ }
90
+ }
91
+
92
+ if(!function_exists('mc4wp_get_current_url')) {
93
+ function mc4wp_get_current_url()
94
+ {
95
+ global $wp;
96
+ return add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
97
+ }
98
+ }
includes/views/checkbox-settings.php CHANGED
@@ -80,7 +80,7 @@
80
  <div class="mc4wp-box">
81
  <h3>Styling the Sign-Up Checkbox</h3>
82
  <p>Custom or additional styling can be done by applying CSS rules to <b>#mc4wp-checkbox</b> or its child elements.</p>
83
- <p>You should add the CSS rules to your theme stylesheet using <strong>Appearance > Editor</strong> or by editing <em><?php echo get_stylesheet_directory(); ?>/style.css</em> over FTP.</p>
84
  </div>
85
 
86
  <?php include 'parts/admin-need-support.php'; ?>
80
  <div class="mc4wp-box">
81
  <h3>Styling the Sign-Up Checkbox</h3>
82
  <p>Custom or additional styling can be done by applying CSS rules to <b>#mc4wp-checkbox</b> or its child elements.</p>
83
+ <p>You should add the CSS rules to your theme stylesheet using the <a href="<?php echo admin_url('theme-editor.php?file=style.css'); ?>">Theme Editor</a> or by editing <em><?php echo get_stylesheet_directory(); ?>/style.css</em> over FTP.</p>
84
  </div>
85
 
86
  <?php include 'parts/admin-need-support.php'; ?>
includes/views/form-settings.php CHANGED
@@ -161,7 +161,7 @@
161
 
162
  <p><strong>Styling</strong><br />
163
  Alter the visual appearance of the form by applying CSS rules to <b>.mc4wp-form</b> and its child elements.</p>
164
- <p>You should add the CSS rules to your theme stylesheet using <strong>Appearance > Editor</strong> or by editing <em><?php echo get_stylesheet_directory(); ?>/style.css</em> over FTP.</p>
165
 
166
 
167
  <p>The <a href="http://wordpress.org/plugins/mailchimp-for-wp/faq/" target="_blank">MailChimp for WP FAQ</a> lists the various CSS selectors you can use to target the different elements.</p>
@@ -173,8 +173,8 @@
173
 
174
  <table class="mc4wp-help">
175
  <tr>
176
- <th>{n}</th>
177
- <td>Replaced with a unique number for this form.</td>
178
  </tr>
179
  <tr>
180
  <th>{ip}</th>
161
 
162
  <p><strong>Styling</strong><br />
163
  Alter the visual appearance of the form by applying CSS rules to <b>.mc4wp-form</b> and its child elements.</p>
164
+ <p>You should add the CSS rules to your theme stylesheet using the <a href="<?php echo admin_url('theme-editor.php?file=style.css'); ?>">Theme Editor</a> or by editing <em><?php echo get_stylesheet_directory(); ?>/style.css</em> over FTP.</p>
165
 
166
 
167
  <p>The <a href="http://wordpress.org/plugins/mailchimp-for-wp/faq/" target="_blank">MailChimp for WP FAQ</a> lists the various CSS selectors you can use to target the different elements.</p>
173
 
174
  <table class="mc4wp-help">
175
  <tr>
176
+ <th>{subscriber_count}</th>
177
+ <td>Replaced with the number of subscribers on the selected list(s).</td>
178
  </tr>
179
  <tr>
180
  <th>{ip}</th>
includes/views/parts/admin-upgrade-to-pro.php CHANGED
@@ -10,8 +10,8 @@
10
  <p>Some alternative ways to show your appreciation:</p>
11
  <ul class="ul-square">
12
  <li><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform">Give a &#9733;&#9733;&#9733;&#9733;&#9733; review on WordPress.org</a></li>
13
- <li><a target="_blank" href="http://twitter.com/?status=I%20manage%20my%20%23WordPress%20sign-up%20forms%20using%20MailChimp%20for%20WP%20and%20I%20love%20it%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fmailchimp-for-wp%2F">Tweet about MailChimp for WP</a></li>
14
- <li>Write about the plugin on your blog and link to <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">the plugin page</a>.</li>
15
  <li><a target="_blank" href="http://wordpress.org/plugins/mailchimp-for-wp/">Vote "works" on the WordPress.org plugin page</a></li>
16
  </ul>
17
  </div>
10
  <p>Some alternative ways to show your appreciation:</p>
11
  <ul class="ul-square">
12
  <li><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform">Give a &#9733;&#9733;&#9733;&#9733;&#9733; review on WordPress.org</a></li>
13
+ <li><a target="_blank" href="http://twitter.com/?status=Showing%20my%20appreciation%20to%20%40DannyvanKooten%20for%20his%20WordPress%20plugin%3A%20MailChimp%20for%20WP%20%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fmailchimp-for-wp%2F">Tweet about MailChimp for WP</a></li>
14
+ <li>Review the plugin on your blog and link to <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">the plugin page</a>.</li>
15
  <li><a target="_blank" href="http://wordpress.org/plugins/mailchimp-for-wp/">Vote "works" on the WordPress.org plugin page</a></li>
16
  </ul>
17
  </div>
mailchimp-for-wp.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: MailChimp for WP Lite
4
  Plugin URI: http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/
5
- Description: MailChimp integration for WordPress, Lite. Add newsletter subscribe checkboxes to various forms. Create sign-up forms and show them in your posts, pages or widgets. <strong>Pro features:</strong> AJAX forms, easy merge var fields, subscriber logging and way more. <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to Pro now &raquo;</a>
6
- Version: 1.2.3
7
  Author: Danny van Kooten
8
  Author URI: http://dannyvanKooten.com
9
  License: GPL v3
@@ -25,8 +25,9 @@ You should have received a copy of the GNU General Public License
25
  along with this program. If not, see <http://www.gnu.org/licenses/>.
26
  */
27
 
28
- define("MC4WP_LITE_VERSION", "1.2.3");
 
29
 
30
  // frontend AND backend
31
- require 'includes/MC4WP_Lite.php';
32
  new MC4WP_Lite();
2
  /*
3
  Plugin Name: MailChimp for WP Lite
4
  Plugin URI: http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/
5
+ Description: Lite version of MailChimp for WordPress. Add various sign-up methods to your WordPress website. Show a sign-up form in your posts, pages or text widgets. Add a sign-up checkbox to various forms, like your comment form. <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Premium features include (multiple) AJAX powered forms, a form designer, an unlocked field wizard and much more.</a>
6
+ Version: 1.2.4
7
  Author: Danny van Kooten
8
  Author URI: http://dannyvanKooten.com
9
  License: GPL v3
25
  along with this program. If not, see <http://www.gnu.org/licenses/>.
26
  */
27
 
28
+ define("MC4WP_LITE_VERSION", "1.2.4");
29
+ define("MC4WP_LITE_PLUGIN_DIR", plugin_dir_path(__FILE__));
30
 
31
  // frontend AND backend
32
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/MC4WP_Lite.php';
33
  new MC4WP_Lite();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://dannyvankooten.com/donate/
4
  Tags: mailchimp, newsletter, mailinglist, email, email list, form, widget form, sign-up form, subscribe form, comments, comment form, mailchimp widget, buddypress, multisite
5
  Requires at least: 3.1
6
  Tested up to: 3.6.1
7
- Stable tag: 1.2.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -14,35 +14,30 @@ The best MailChimp plugin to get more email subscribers. Easily add sign-up form
14
 
15
  = MailChimp for WordPress =
16
 
17
- Want to get more email subscribers for your MailChimp lists? This plugin will be a BIG help by showing sign-up forms and sign-up checkboxes on your WordPress website.
18
 
19
  Easily build sign-up forms and then add them to your posts, pages and widget areas by using a simple shortcode `[mc4wp-form]`.
20
 
21
  Add "sign up to our newsletter" checkboxes to your comment form, registration form or other forms, making subscribing to your list(s) effortless for your visitors.
22
 
23
- *This plugin has a premium version: [upgrade to MailChimp for WordPress Pro now >>](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)*
24
-
25
  **Plugin Features**
26
 
27
- * Create a highly customizable sign-up form and show it in your posts, pages and widgets by using a simple shortcode `[mc4wp-form]`
28
  * Add a "sign-up to our newsletter" checkbox to ANY form you like, like your comment form.
29
  * Built-in integration with [BuddyPress](http://buddypress.org/) and WordPress MultiSite registration forms, [bbPress](http://bbpress.org/) new topic and new reply forms and [Contact Form 7](http://contactform7.com/) forms. You can add sign-up checkboxes to these forms with 1 simple click.
30
- * Create sign-up forms in an easy but higly customizable way.
31
- * SPAM protection, no "fake" subscribers will be added to your lists.
32
  * Uses the MailChimp API, superfast and reliable. Also, visitors never have to leave your website to subscribe.
33
  * Configuring is easy, all you need is your MailChimp API key.
34
 
35
  **Premium Plugin Features**
36
 
37
- * Form CSS designer, design beautiful sign-up forms from your admin panel. Absolutely no CSS knowledge required.
38
- * AJAX powered sign-up forms, so the page doesn't have to reload after submitting.
39
- * Multiple sign-up forms, for multiple lists.
40
- * All MailChimp list fields or interest groupings can be added to your forms using the field wizard.
41
  * Reports. Gain insights in when, where and how your visitors subscribe with the subscribers log and beautiful statistical charts.
42
- * Built-in integration with [WooCommerce](http://www.woocommerce.com/) and [Easy Digital Downloads](https://easydigitaldownloads.com?ref=2123) for adding sign-up checkboxes to your checkout forms.
43
- * Premium support
44
 
45
- [Upgrade to MailChimp for WordPress Pro now >>](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
46
 
47
  = MailChimp Sign-Up Form =
48
  The plugin comes with an easy to way to build sign-up forms for your MailChimp lists. Add as many fields as you like and customize labels, placeholders, initial values etcetera in a simple way. Visitors never have to leave your website to subscribe to your MailChimp lists. Big plus!
@@ -68,7 +63,7 @@ Check out more [WordPress plugins](http://dannyvankooten.com/wordpress-plugins/)
68
  1. Select at least one list to subscribe visitors to.
69
  1. (Optional) Select to which forms the sign-up checkbox should be added.
70
  1. (Optional) Create a form and show it in your posts, pages or text widgets using the shortcode `[mc4wp-form]`.
71
- 1. (Optional) If you like the plugin, upgrade to [MailChimp for WordPress Pro](dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/) for an even better plugin or donate a beer. Much appreciated!
72
 
73
  == Frequently Asked Questions ==
74
 
@@ -76,39 +71,39 @@ Check out more [WordPress plugins](http://dannyvankooten.com/wordpress-plugins/)
76
  Yes, there is and it is awesome. Pro features include:
77
 
78
  1. (Multiple) AJAX Sign-up Forms (so the page doesn't reload after clicking the submit button)
79
- 1. Create beautiful forms from your admin panel with the Form CSS Designer.
80
  1. Reports, learn when, where and how your visitors subscribed.
81
  1. The form field wizard makes it easy to add your MailChimp list fields to your sign-up forms.
82
  1. Sign-up checkbox integration with WooCommerce and Easy Digital Downloads
83
  1. Custom checkbox labels
84
- 1. Premium support
85
 
86
  [More information about MailChimp for WordPress Pro](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
87
 
88
  = The form shows a success message but subscribers are not added to my list(s)? =
89
- If the form shows a success message, it means the sign-up succeeded. 100%. MailChimp could have a slight delay sending the confirmation email though, just be patient.
90
 
91
  = How can I style the sign-up form? =
92
- You can use CSS to style the sign-up form. Use the following CSS selectors.
93
 
94
  `
95
- form.mc4wp-form{ ... } /* the form element */
96
- form.mc4wp-form p { ... } /* form paragraphs */
97
- form.mc4wp-form label { ... } /* labels */
98
- form.mc4wp-form input { ... } /* input fields */
99
- form.mc4wp-form input[type="checkbox"] { ... } /* checkboxes */
100
- form.mc4wp-form input[type="submit"] { ... } /* submit button */
101
- form.mc4wp-form .mc4wp-alert { ... } /* success & error messages */
102
- form.mc4wp-form .mc4wp-success { ... } /* success message */
103
- form.mc4wp-form .mc4wp-error { ... } /* error messages */
104
  `
105
 
106
- Just add your CSS rules to the end of your theme stylesheet, **/wp-content/themes/your-theme-name/style.css**.
107
 
108
- [Upgrade to MailChimp for WordPress Pro to use the form CSS designer to create beautiful sign-up forms >>](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
109
 
110
  = Where can I find my MailChimp API key? =
111
- [http://kb.mailchimp.com/article/where-can-i-find-my-api-key](http://kb.mailchimp.com/article/where-can-i-find-my-api-key)
112
 
113
  = How to add a sign-up checkbox to my Contact Form 7 forms? =
114
  Use the following shortcode to render a sign-up checkbox in your CF7 forms.
@@ -167,8 +162,17 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
167
 
168
 
169
  == Changelog ==
 
 
 
 
 
 
 
 
 
170
  = 1.2.3 =
171
- * Fixed: certain MailChimp fields not showing up in "Add field" dropdown.
172
 
173
  = 1.2.2 =
174
  * Fixed sending extra list fields when integrating with third-party forms like Contact Form 7
@@ -327,8 +331,8 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
327
 
328
  == Upgrade Notice ==
329
 
330
- = 1.2.3 =
331
- Bugfix. Fixes the absence of certain fields from the "Add field" dropdown when building your sign-up form.
332
 
333
  = 1.1.1 =
334
  Bugfix for BuddyPress sites
4
  Tags: mailchimp, newsletter, mailinglist, email, email list, form, widget form, sign-up form, subscribe form, comments, comment form, mailchimp widget, buddypress, multisite
5
  Requires at least: 3.1
6
  Tested up to: 3.6.1
7
+ Stable tag: 1.2.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
14
 
15
  = MailChimp for WordPress =
16
 
17
+ Want to get more email subscribers for your MailChimp lists? This plugin will be a BIG help by adding sign-up forms and sign-up checkboxes to your WordPress website.
18
 
19
  Easily build sign-up forms and then add them to your posts, pages and widget areas by using a simple shortcode `[mc4wp-form]`.
20
 
21
  Add "sign up to our newsletter" checkboxes to your comment form, registration form or other forms, making subscribing to your list(s) effortless for your visitors.
22
 
 
 
23
  **Plugin Features**
24
 
25
+ * Easily create a highly customizable sign-up form and show it in your posts, pages and widgets by using a simple shortcode `[mc4wp-form]`
26
  * Add a "sign-up to our newsletter" checkbox to ANY form you like, like your comment form.
27
  * Built-in integration with [BuddyPress](http://buddypress.org/) and WordPress MultiSite registration forms, [bbPress](http://bbpress.org/) new topic and new reply forms and [Contact Form 7](http://contactform7.com/) forms. You can add sign-up checkboxes to these forms with 1 simple click.
 
 
28
  * Uses the MailChimp API, superfast and reliable. Also, visitors never have to leave your website to subscribe.
29
  * Configuring is easy, all you need is your MailChimp API key.
30
 
31
  **Premium Plugin Features**
32
 
33
+ * Form designer, design beautiful sign-up forms from your admin panel. No CSS knowledge required.
34
+ * (Multiple) AJAX powered sign-up forms, so the page doesn't have to reload after submitting.
35
+ * All MailChimp list fields or interest groupings can be added to your forms using the field wizard. No HTML knowledge required.
 
36
  * Reports. Gain insights in when, where and how your visitors subscribe with the subscribers log and beautiful statistical charts.
37
+ * Built-in integration with WooCommerce and Easy Digital Downloads for adding sign-up checkboxes to your checkout forms.
38
+ * Priority support
39
 
40
+ [More information about MailChimp for WordPress Pro >>](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
41
 
42
  = MailChimp Sign-Up Form =
43
  The plugin comes with an easy to way to build sign-up forms for your MailChimp lists. Add as many fields as you like and customize labels, placeholders, initial values etcetera in a simple way. Visitors never have to leave your website to subscribe to your MailChimp lists. Big plus!
63
  1. Select at least one list to subscribe visitors to.
64
  1. (Optional) Select to which forms the sign-up checkbox should be added.
65
  1. (Optional) Create a form and show it in your posts, pages or text widgets using the shortcode `[mc4wp-form]`.
66
+ 1. (Optional) If you like the plugin, upgrade to [MailChimp for WordPress Pro](dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/) for an even better plugin.
67
 
68
  == Frequently Asked Questions ==
69
 
71
  Yes, there is and it is awesome. Pro features include:
72
 
73
  1. (Multiple) AJAX Sign-up Forms (so the page doesn't reload after clicking the submit button)
74
+ 1. Create beautiful forms from your admin panel with the Form Designer. No CSS knowledge required!
75
  1. Reports, learn when, where and how your visitors subscribed.
76
  1. The form field wizard makes it easy to add your MailChimp list fields to your sign-up forms.
77
  1. Sign-up checkbox integration with WooCommerce and Easy Digital Downloads
78
  1. Custom checkbox labels
79
+ 1. Priority support
80
 
81
  [More information about MailChimp for WordPress Pro](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
82
 
83
  = The form shows a success message but subscribers are not added to my list(s)? =
84
+ If the form shows a success message, it means the sign-up succeeded. Always. MailChimp could have a slight delay sending the confirmation email though, just be patient.
85
 
86
  = How can I style the sign-up form? =
87
+ You can use CSS rules to style the sign-up form, use the following CSS selectors to target the various form elements.
88
 
89
  `
90
+ .mc4wp-form { ... } /* the form element */
91
+ .mc4wp-form p { ... } /* form paragraphs */
92
+ .mc4wp-form label { ... } /* labels */
93
+ .mc4wp-form input { ... } /* input fields */
94
+ .mc4wp-form input[type="checkbox"] { ... } /* checkboxes */
95
+ .mc4wp-form input[type="submit"] { ... } /* submit button */
96
+ .mc4wp-alert { ... } /* success & error messages */
97
+ .mc4wp-success { ... } /* success message */
98
+ .mc4wp-error { ... } /* error messages */
99
  `
100
 
101
+ Add your custom CSS rules to the end of your theme stylesheet, **/wp-content/themes/your-theme-name/style.css**. Do not add them to the plugin stylesheet as they will be automatically overwritten on the next plugin update.
102
 
103
+ [PS: The form designer in Pro creates the CSS rules for you >>](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
104
 
105
  = Where can I find my MailChimp API key? =
106
+ [Here](http://kb.mailchimp.com/article/where-can-i-find-my-api-key)
107
 
108
  = How to add a sign-up checkbox to my Contact Form 7 forms? =
109
  Use the following shortcode to render a sign-up checkbox in your CF7 forms.
162
 
163
 
164
  == Changelog ==
165
+
166
+ = 1.2.4 =
167
+ * Improved: code performance improvements
168
+ * Improved: added `mc4wp_get_form()` for an easier shortcode callback. Useful to [add a sign-up form to the end of your posts](http://dannyvankooten.com/2577/add-mailchimp-sign-up-form-end-of-posts/).
169
+ * Improved default CSS
170
+ * Improved: checkbox debug message only shows to WP Administrators when JavaScript is disabled
171
+ * Added: form nonce for better security
172
+ * Fix: CSS issue where the form caused a huge sidebar gap in some themes.
173
+
174
  = 1.2.3 =
175
+ * Fixed: bug where some MailChimp fields were not showing in the field wizard / add field tool.
176
 
177
  = 1.2.2 =
178
  * Fixed sending extra list fields when integrating with third-party forms like Contact Form 7
331
 
332
  == Upgrade Notice ==
333
 
334
+ = 1.2.5 =
335
+ Fixed CSS issue where the form caused a hue gap in the sidebar for some themes.
336
 
337
  = 1.1.1 =
338
  Bugfix for BuddyPress sites