MailChimp for WordPress - Version 1.5.1

Version Description

  • January 5, 2013 =
  • Fixed: Having to submit form twice for some www-hosts.
  • Improved: Scroll to form now waits until page has completely loaded
Download this release

Release Info

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

Code changes from version 1.5 to 1.5.1

Files changed (48) hide show
  1. assets/js/forms.js +23 -11
  2. includes/class-admin.php +1 -1
  3. includes/class-api.php +1 -1
  4. includes/template-functions.php +11 -13
  5. mailchimp-for-wp.php +2 -2
  6. readme.txt +7 -3
  7. trunk/assets/css/admin.css +82 -0
  8. trunk/assets/css/checkbox.css +24 -0
  9. trunk/assets/css/css.php +32 -0
  10. trunk/assets/css/form-reset.css +76 -0
  11. trunk/assets/css/form-theme-base.css +95 -0
  12. trunk/assets/css/form-theme-blue.css +23 -0
  13. trunk/assets/css/form-theme-dark.css +23 -0
  14. trunk/assets/css/form-theme-green.css +23 -0
  15. trunk/assets/css/form-theme-light.css +13 -0
  16. trunk/assets/css/form-theme-red.css +23 -0
  17. trunk/assets/css/form.css +23 -0
  18. trunk/assets/css/index.php +6 -0
  19. trunk/assets/img/index.php +6 -0
  20. trunk/assets/img/menu-icon.png +0 -0
  21. trunk/assets/index.php +6 -0
  22. trunk/assets/js/admin.js +373 -0
  23. trunk/assets/js/forms.js +136 -0
  24. trunk/assets/js/index.php +6 -0
  25. trunk/assets/js/placeholders.min.js +2 -0
  26. trunk/includes/class-admin.php +275 -0
  27. trunk/includes/class-api.php +133 -0
  28. trunk/includes/class-checkbox.php +424 -0
  29. trunk/includes/class-form.php +383 -0
  30. trunk/includes/class-plugin.php +129 -0
  31. trunk/includes/class-widget.php +73 -0
  32. trunk/includes/functions.php +71 -0
  33. trunk/includes/index.php +6 -0
  34. trunk/includes/template-functions.php +146 -0
  35. trunk/includes/views/api-settings.php +80 -0
  36. trunk/includes/views/checkbox-settings.php +98 -0
  37. trunk/includes/views/form-settings.php +234 -0
  38. trunk/includes/views/index.php +6 -0
  39. trunk/includes/views/parts/admin-field-wizard.php +62 -0
  40. trunk/includes/views/parts/admin-footer.php +5 -0
  41. trunk/includes/views/parts/admin-need-support.php +23 -0
  42. trunk/includes/views/parts/admin-upgrade-to-pro.php +10 -0
  43. trunk/includes/views/parts/index.php +6 -0
  44. trunk/index.php +6 -0
  45. trunk/license.txt +621 -0
  46. trunk/mailchimp-for-wp.php +57 -0
  47. trunk/readme.txt +457 -0
  48. trunk/uninstall.php +14 -0
assets/js/forms.js CHANGED
@@ -1,5 +1,16 @@
1
- (function() {
 
 
 
 
 
 
 
 
2
 
 
 
 
3
  function populateFields(container, data, basename) {
4
 
5
  for(var key in data) {
@@ -44,6 +55,8 @@
44
  case 'date':
45
  case 'tel':
46
  element.value = value;
 
 
47
  element.className = element.className.replace('placeholdersjs','');
48
  break;
49
 
@@ -88,10 +101,12 @@
88
  return;
89
  }
90
 
 
91
  if(mc4wp.success == false) {
92
  populateFields(formElement, mc4wp.postData);
93
  }
94
 
 
95
  var scrollToHeight = 0;
96
  var obj = formElement;
97
  var windowHeight = window.innerHeight;
@@ -104,21 +119,18 @@
104
  scrollToHeight = formElement.offsetTop;
105
  }
106
 
107
- if((windowHeight - 100) > formElement.clientHeight) {
108
- // vertically center the form
109
  scrollToHeight = scrollToHeight - ((windowHeight - formElement.clientHeight) / 2);
110
  } else {
111
- // scroll a little above the form
112
- scrollToHeight = scrollToHeight - 100;
113
  }
114
 
 
115
  if(window.jQuery !== undefined) {
116
- var animationTime = (500 + (scrollToHeight / 2));
117
- jQuery('html, body').animate({ scrollTop: scrollToHeight }, animationTime);
118
  } else {
119
  window.scrollTo(0, scrollToHeight);
120
  }
121
-
122
-
123
-
124
- })();
1
+ function mc4wpAddEvent(element, eventName, callback) {
2
+ if (element.addEventListener) {
3
+ element.addEventListener(eventName, callback, false);
4
+ } else {
5
+ element.attachEvent("on" + eventName, callback);
6
+ }
7
+ }
8
+
9
+ mc4wpAddEvent(window, "load", function() {
10
 
11
+ /**
12
+ * Populate the form elements in a given container from a JSON object
13
+ */
14
  function populateFields(container, data, basename) {
15
 
16
  for(var key in data) {
55
  case 'date':
56
  case 'tel':
57
  element.value = value;
58
+
59
+ // remove IE placeholder fallback class
60
  element.className = element.className.replace('placeholdersjs','');
61
  break;
62
 
101
  return;
102
  }
103
 
104
+ // only populate fields on error
105
  if(mc4wp.success == false) {
106
  populateFields(formElement, mc4wp.postData);
107
  }
108
 
109
+ // calculate window height to scroll to
110
  var scrollToHeight = 0;
111
  var obj = formElement;
112
  var windowHeight = window.innerHeight;
119
  scrollToHeight = formElement.offsetTop;
120
  }
121
 
122
+ if((windowHeight - 80) > formElement.clientHeight) {
123
+ // vertically center the form, but only if there's enough space for a decent margin
124
  scrollToHeight = scrollToHeight - ((windowHeight - formElement.clientHeight) / 2);
125
  } else {
126
+ // the form doesn't fit, scroll a little above the form
127
+ scrollToHeight = scrollToHeight - 80;
128
  }
129
 
130
+ // scroll there. if jQuery is loaded, do it with an animation.
131
  if(window.jQuery !== undefined) {
132
+ jQuery('html, body').animate({ scrollTop: scrollToHeight }, 800);
 
133
  } else {
134
  window.scrollTo(0, scrollToHeight);
135
  }
136
+ });
 
 
 
includes/class-admin.php CHANGED
@@ -160,7 +160,7 @@ class MC4WP_Lite_Admin
160
  $cached_lists = get_transient( 'mc4wp_mailchimp_lists' );
161
  $refresh_cache = (isset($_REQUEST['renew-cached-data']));
162
 
163
- // force cache refresh if merge_vars are not set
164
  if(!$refresh_cache && $cached_lists) {
165
  if(!is_array($cached_lists)) {
166
  $refresh_cache = true;
160
  $cached_lists = get_transient( 'mc4wp_mailchimp_lists' );
161
  $refresh_cache = (isset($_REQUEST['renew-cached-data']));
162
 
163
+ // force cache refresh if merge_vars are not set (deprecated)
164
  if(!$refresh_cache && $cached_lists) {
165
  if(!is_array($cached_lists)) {
166
  $refresh_cache = true;
includes/class-api.php CHANGED
@@ -101,7 +101,7 @@ class MC4WP_Lite_API {
101
 
102
  $response = wp_remote_post($url, array(
103
  'body' => $data,
104
- 'timeout' => 10,
105
  'headers' => array('Accept-Encoding' => ''),
106
  'sslverify' => false
107
  )
101
 
102
  $response = wp_remote_post($url, array(
103
  'body' => $data,
104
+ 'timeout' => 20,
105
  'headers' => array('Accept-Encoding' => ''),
106
  'sslverify' => false
107
  )
includes/template-functions.php CHANGED
@@ -100,29 +100,27 @@ function mc4wp_get_subscriber_count( $list_ids ) {
100
  }
101
 
102
  /**
103
- * Retrieves the URL of the current WordPress page
104
- *
105
- * @return string current URL
106
- */
107
  function mc4wp_get_current_url() {
108
  $page_url = 'http';
109
 
110
- if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { $page_url .= 's'; }
111
 
112
  $page_url .= '://';
113
 
114
  if (!isset($_SERVER['REQUEST_URI'])) {
115
- $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 1);
116
- if (isset($_SERVER['QUERY_STRING'])) { $_SERVER['REQUEST_URI'] .='?'.$_SERVER['QUERY_STRING']; }
117
- }
118
-
119
- if($_SERVER['SERVER_PORT'] != '80') {
120
- $page_url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
121
  } else {
122
- $page_url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
123
  }
124
 
125
- return $page_url;
 
 
126
  }
127
 
128
 
100
  }
101
 
102
  /**
103
+ * Retrieves the URL of the current WordPress page
104
+ *
105
+ * @return string The current URL, escaped for safe usage inside attributes.
106
+ */
107
  function mc4wp_get_current_url() {
108
  $page_url = 'http';
109
 
110
+ if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { $page_url .= 's'; }
111
 
112
  $page_url .= '://';
113
 
114
  if (!isset($_SERVER['REQUEST_URI'])) {
115
+ $request_uri = substr($_SERVER['PHP_SELF'], 1);
116
+ if (isset($_SERVER['QUERY_STRING'])) { $request_uri .='?'.$_SERVER['QUERY_STRING']; }
 
 
 
 
117
  } else {
118
+ $request_uri = $_SERVER['REQUEST_URI'];
119
  }
120
 
121
+ $page_url .= $_SERVER["HTTP_HOST"] . $request_uri;
122
+
123
+ return esc_url($page_url);
124
  }
125
 
126
 
mailchimp-for-wp.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MailChimp for WordPress Lite
4
  Plugin URI: http://dannyvankooten.com/mailchimp-for-wordpress/
5
  Description: Lite version of MailChimp for WordPress. Adds various sign-up methods to your website.
6
- Version: 1.5
7
  Author: Danny van Kooten
8
  Author URI: http://dannyvanKooten.com
9
  License: GPL v3
@@ -39,7 +39,7 @@ if(!function_exists('is_plugin_active')) {
39
  if(!is_plugin_active('mailchimp-for-wp-pro/mailchimp-for-wp-pro.php')
40
  && !(is_admin() && isset($_GET['action']) && $_GET['action'] == 'activate' && isset($_GET['plugin']) && $_GET['plugin'] == 'mailchimp-for-wp-pro/mailchimp-for-wp-pro.php') ) {
41
 
42
- define("MC4WP_LITE_VERSION", "1.5");
43
  define("MC4WP_LITE_PLUGIN_DIR", plugin_dir_path(__FILE__));
44
 
45
  require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions.php';
3
  Plugin Name: MailChimp for WordPress Lite
4
  Plugin URI: http://dannyvankooten.com/mailchimp-for-wordpress/
5
  Description: Lite version of MailChimp for WordPress. Adds various sign-up methods to your website.
6
+ Version: 1.5.1
7
  Author: Danny van Kooten
8
  Author URI: http://dannyvanKooten.com
9
  License: GPL v3
39
  if(!is_plugin_active('mailchimp-for-wp-pro/mailchimp-for-wp-pro.php')
40
  && !(is_admin() && isset($_GET['action']) && $_GET['action'] == 'activate' && isset($_GET['plugin']) && $_GET['plugin'] == 'mailchimp-for-wp-pro/mailchimp-for-wp-pro.php') ) {
41
 
42
+ define("MC4WP_LITE_VERSION", "1.5.1");
43
  define("MC4WP_LITE_PLUGIN_DIR", plugin_dir_path(__FILE__));
44
 
45
  require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions.php';
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://dannyvankooten.com/donate/
4
  Tags: mailchimp,form,shortcode,widget,checkbox,comment,newsletter,buddypress,multisite,bbpress,woocommerce,easy digital downloads,contact form,contact form 7
5
  Requires at least: 3.1
6
  Tested up to: 3.8
7
- Stable tag: 1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -196,7 +196,11 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
196
 
197
  == Changelog ==
198
 
199
- = 1.5 - 18 December 2013 =
 
 
 
 
200
  * Added: BIRTHDAY fields will now be formatted in the DD/MM format automatically
201
  * Added: The plugin will now try to automatically format ADDRESS fields.
202
  * Added: Form fields will now keep their value when a validation error occurs
@@ -206,7 +210,7 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
206
  * Fixed: Error when activating Pro with the Lite plugin still activated.
207
  * Fixed: BuddyPress & MultiSite checkbox not automatically added
208
 
209
- = 1.4.8 - 10 December 2013 =
210
  * Fixed: "bug" that fetched lists again on every plugin settings page - huge performance improvements on the settings pages.
211
  * Improved: Longer cache time for combined CSS file.
212
  * Improved: Prevented indexing of plugin directories
4
  Tags: mailchimp,form,shortcode,widget,checkbox,comment,newsletter,buddypress,multisite,bbpress,woocommerce,easy digital downloads,contact form,contact form 7
5
  Requires at least: 3.1
6
  Tested up to: 3.8
7
+ Stable tag: 1.5.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
196
 
197
  == Changelog ==
198
 
199
+ = 1.5.1 - January 5, 2013 =
200
+ * Fixed: Having to submit form twice for some www-hosts.
201
+ * Improved: Scroll to form now waits until page has completely loaded
202
+
203
+ = 1.5 - December 18, 2013 =
204
  * Added: BIRTHDAY fields will now be formatted in the DD/MM format automatically
205
  * Added: The plugin will now try to automatically format ADDRESS fields.
206
  * Added: Form fields will now keep their value when a validation error occurs
210
  * Fixed: Error when activating Pro with the Lite plugin still activated.
211
  * Fixed: BuddyPress & MultiSite checkbox not automatically added
212
 
213
+ = 1.4.8 - December 10, 2013 =
214
  * Fixed: "bug" that fetched lists again on every plugin settings page - huge performance improvements on the settings pages.
215
  * Improved: Longer cache time for combined CSS file.
216
  * Improved: Prevented indexing of plugin directories
trunk/assets/css/admin.css ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #mc4wp-content{ float:left; width:65%; }
2
+ #mc4wp-sidebar{
3
+ float:left;
4
+ width:33%;
5
+ margin-left:2%;
6
+ border-left:1px solid #ccc;
7
+ padding:0 0 0 2%;
8
+ box-sizing: border-box;
9
+ }
10
+
11
+ .mc4wp-info {
12
+ padding: 5px 15px;
13
+ color: #3a87ad;
14
+ background-color: #d9edf7;
15
+ border-color: #bce8f1;
16
+ }
17
+
18
+ .valigntop{ vertical-align: top !important; }
19
+
20
+ .mc4wp-box{ margin-bottom:20px; }
21
+
22
+ #mc4wp-upgrade-box { background:#222; color:#ddd; padding:20px; }
23
+ #mc4wp-upgrade-box h3{ margin:0; color:white; }
24
+
25
+ #mc4wp-fw h4{ margin-top:0; }
26
+ #mc4wp-fw p{ margin-bottom: 1em; }
27
+ #mc4wp-fw-fields { display:none; }
28
+ #mc4wp-fw-preview { font-family: "Courier New", Courier, monospace; min-height:200px; font-size:11px; background:white; z-index:99; }
29
+ #mc4wp-lists{ margin:0; }
30
+ #mc4wp-lists input{ margin-right:5px; }
31
+
32
+ .pro-feature, .mc4wp-settings tr.pro-feature th, .mc4wp-settings tr.pro-feature td{ color:#aaa; }
33
+
34
+ .mc4wp-settings span.status{ display:inline-block; padding:3px 6px; color:white; font-size:12px; font-weight:bold; }
35
+ .mc4wp-settings span.positive{ background-color:green; }
36
+ .mc4wp-settings span.negative{ background-color:lightGrey; }
37
+ .mc4wp-settings table th{ text-align:left; }
38
+ .mc4wp-settings table.form-table tr td:first-child, .mc4wp-settings table.form-table tr th:first-child{ padding-left:0; }
39
+ .mc4wp-settings td.nowrap{ white-space: nowrap }
40
+ .mc4wp-settings td.desc{ font-style:italic; font-size:11px; }
41
+
42
+ .mc4wp-notice{
43
+ padding:5px;
44
+ color: #31708f;
45
+ background-color: #d9edf7;
46
+ border:1px solid #bce8f1;
47
+ }
48
+
49
+ .mc4wp-col {
50
+ float:left;
51
+ -webkit-box-sizing: border-box;
52
+ box-sizing: border-box;
53
+ -moz-box-sizing:border-box;
54
+ width:50%;
55
+ padding:0 5px;
56
+ }
57
+
58
+ .mc4wp-first{ padding-left:0; }
59
+ .mc4wp-last{ padding-right:0; }
60
+
61
+ .mc4wp-well{
62
+ background:white;
63
+ padding:10px;
64
+ border:1px solid #ccc;
65
+ }
66
+
67
+ .mc4wp-title{
68
+ font-size: 1.4em;
69
+ margin:1.6em 0 1em;
70
+ padding:0 0 6px 0;
71
+ border-bottom:1px solid #ddd;
72
+ }
73
+
74
+
75
+ table.mc4wp-help, table.mc4wp-help th, table.mc4wp-help td { border: 1px solid #ddd; border-collapse: collapse; font-size: 12px; }
76
+ table.mc4wp-help th, table.mc4wp-help td { vertical-align: text-top; text-align: left; padding: 5px 10px; }
77
+ table.mc4wp-help tr:hover { background-color: #ddd; }
78
+
79
+ @media(max-width: 1279px) {
80
+ #mc4wp-sidebar, #mc4wp-content{ float: none; width: 100%; padding:0; margin:0; }
81
+ #mc4wp-sidebar{ border-left:0; border-top: 1px solid #ccc; margin-top:25px; padding-top: 25px; }
82
+ }
trunk/assets/css/checkbox.css ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* MailChimp for WP - Default Checkbox Styles */
2
+ #mc4wp-checkbox{
3
+ clear:both;
4
+ display:block;
5
+ }
6
+
7
+ #mc4wp-checkbox input{
8
+ position:relative;
9
+ margin:0 6px 0 0;
10
+ padding:0;
11
+ vertical-align: middle;
12
+ display:inline-block !important;
13
+ max-width: 20px;
14
+ }
15
+
16
+ #mc4wp-checkbox label{
17
+ display:block;
18
+ cursor:pointer;
19
+ width: auto;
20
+ }
21
+
22
+ #registerform #mc4wp-checkbox{
23
+ margin-bottom:10px;
24
+ }
trunk/assets/css/css.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Set headers to serve CSS and encourage browser caching
3
+ $expires = 31536000; // cache time: 1 year
4
+ header('Content-Type: text/css');
5
+ header("Cache-Control: max-age=" . $expires);
6
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT');
7
+
8
+ if(isset($_GET['checkbox'])) {
9
+ readfile(dirname(__FILE__) . '/checkbox.css');
10
+ }
11
+
12
+ // load form reset
13
+ if(isset($_GET['form'])) {
14
+ readfile(dirname(__FILE__) . '/form-reset.css');
15
+ }
16
+
17
+ // should we load a form theme?
18
+ if(isset($_GET['form-theme'])) {
19
+ $form_theme = strtolower( trim( $_GET['form-theme'] ) );
20
+
21
+ // only load themes we actually have
22
+ if(in_array($form_theme, array('blue', 'green', 'dark', 'light', 'red'))) {
23
+ // load theme base file
24
+ readfile(dirname(__FILE__) . '/form-theme-base.css');
25
+
26
+ // load theme file
27
+ readfile(dirname(__FILE__) . '/form-theme-'. $form_theme .'.css');
28
+ }
29
+
30
+ }
31
+
32
+ exit;
trunk/assets/css/form-reset.css ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* MailChimp for WP - Default Form Styles */
3
+ .mc4wp-form{
4
+ margin:1em 0;
5
+ }
6
+
7
+ .mc4wp-form label{
8
+ display:block;
9
+ font-weight:bold;
10
+ margin-bottom:5px;
11
+ }
12
+
13
+ .mc4wp-form ul,
14
+ .mc4wp-form li {
15
+ list-style:none;
16
+ margin:0;
17
+ padding:0;
18
+ }
19
+
20
+ .mc4wp-form label > span,
21
+ .mc4wp-form li > label {
22
+ font-weight: normal;
23
+ }
24
+
25
+ .mc4wp-form p > label:nth-child(2) {
26
+ margin-top: 10px;
27
+ }
28
+
29
+ .mc4wp-form input.placeholdersjs { color: #aaa !important; }
30
+
31
+ .mc4wp-form input[type="text"],
32
+ .mc4wp-form input[type="email"],
33
+ .mc4wp-form input[type="tel"],
34
+ .mc4wp-form input[type="url"],
35
+ .mc4wp-form input[type="date"],
36
+ .mc4wp-form textarea,
37
+ .mc4wp-form select {
38
+ cursor: auto;
39
+ display:block;
40
+ width:100%;
41
+ height:auto;
42
+ box-sizing:border-box;
43
+ -webkit-box-sizing: border-box;
44
+ -moz-box-sizing: border-box;
45
+ }
46
+
47
+ .mc4wp-form input[type="checkbox"],
48
+ .mc4wp-form input[type="radio"] {
49
+ position:relative;
50
+ margin:0 6px 0 0;
51
+ padding:0;
52
+ height:13px;
53
+ width:13px;
54
+ display:inline-block;
55
+ border:0;
56
+ }
57
+
58
+ .mc4wp-form input[type="checkbox"] {
59
+ -webkit-appearance: checkbox;
60
+ }
61
+
62
+ .mc4wp-form input[type="radio"] {
63
+ -webkit-appearance: radio;
64
+ }
65
+
66
+ .mc4wp-form input[type="submit"],
67
+ .mc4wp-form button,
68
+ .mc4wp-form input[type="button"] {
69
+ cursor: pointer;
70
+ display:inline-block;
71
+ }
72
+
73
+ .mc4wp-alert{ margin:1em 0; padding: 10px 15px; color: #c09853; background-color: #fcf8e3; border: 1px solid #fbeed5; border-radius: 2px; -moz-border-radius:2px; -webkit-border-radius:2px; display:block; position:relative;}
74
+ .mc4wp-success { color: #468847; background-color: #dff0d8; border-color: #d6e9c6; }
75
+ .mc4wp-notice { color: #3a87ad; background-color: #d9edf7; border-color: #bce8f1; }
76
+ .mc4wp-error { color: #b94a48; background-color: #f2dede; border-color: #eed3d7; }
trunk/assets/css/form-theme-base.css ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* Form base theme */
3
+ .mc4wp-form { box-shadow: none !important; -webkit-box-shadow: none; -moz-box-shadow: none; }
4
+ .mc4wp-form p{ margin:0 0 15px; }
5
+ .mc4wp-form label{ font-size:1em; margin:5px 0; }
6
+
7
+ .mc4wp-form input[type="text"],
8
+ .mc4wp-form input[type="email"],
9
+ .mc4wp-form input[type="tel"],
10
+ .mc4wp-form input[type="url"],
11
+ .mc4wp-form input[type="date"],
12
+ .mc4wp-form textarea,
13
+ .mc4wp-form select {
14
+ width: 100%;
15
+ height: 34px;
16
+ margin:0;
17
+ padding: 6px 12px;
18
+ font-size: 14px;
19
+ line-height: 1.428571429;
20
+ color: #555555;
21
+ vertical-align: middle;
22
+ background-color: #ffffff;
23
+ border: 1px solid #cccccc;
24
+ border-radius: 2px;
25
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
26
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
27
+ -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
28
+ transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
29
+ background-image: none;
30
+ text-shadow: none;
31
+
32
+ }
33
+
34
+ .mc4wp-form input[type="text"]:focus,
35
+ .mc4wp-form input[type="email"]:focus,
36
+ .mc4wp-form input[type="tel"]:focus,
37
+ .mc4wp-form input[type="url"]:focus,
38
+ .mc4wp-form textarea:focus,
39
+ .mc4wp-form select:focus {
40
+ border-color: #66afe9;
41
+ outline: 0;
42
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
43
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
44
+ }
45
+
46
+ .mc4wp-form textarea{ height: auto; }
47
+
48
+ .mc4wp-form input[readonly], .mc4wp-form input[disabled] {
49
+ background-color: #eeeeee;
50
+ }
51
+
52
+ .mc4wp-form input[type="submit"], .mc4wp-form button {
53
+ display: inline-block;
54
+ padding: 6px 12px;
55
+ margin:0;
56
+ font-size: 14px;
57
+ font-weight: normal;
58
+ line-height: 1.428571429;
59
+ text-align: center;
60
+ white-space: nowrap;
61
+ vertical-align: middle;
62
+ cursor: pointer;
63
+ border: 1px solid transparent;
64
+ border-radius: 2px;
65
+ -webkit-user-select: none;
66
+ -moz-user-select: none;
67
+ -ms-user-select: none;
68
+ -o-user-select: none;
69
+ user-select: none;
70
+ box-shadow:none;
71
+ background:none;
72
+ text-shadow:none;
73
+ filter: none;
74
+ height: auto;
75
+ width: auto;
76
+ }
77
+
78
+ .mc4wp-form input[type="submit"]:focus, .mc4wp-form button:focus {
79
+ outline: thin dotted #333;
80
+ outline: 5px auto -webkit-focus-ring-color;
81
+ outline-offset: -2px;
82
+ }
83
+
84
+ .mc4wp-form input[type="submit"]:hover, .mc4wp-form button:hover,
85
+ .mc4wp-form input[type="submit"]:focus, .mc4wp-form button:focus {
86
+ color: #333333;
87
+ text-decoration: none;
88
+ }
89
+
90
+ .mc4wp-form input[type="submit"]:active, .mc4wp-form button:active {
91
+ background-image: none;
92
+ outline: 0;
93
+ -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
94
+ box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
95
+ }
trunk/assets/css/form-theme-blue.css ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mc4wp-form input[type="submit"], .mc4wp-form button {
2
+ color: #ffffff !important;
3
+ background-color: #428bca;
4
+ border-color: #357ebd;
5
+ }
6
+
7
+ .mc4wp-form input[type="submit"]:hover, .mc4wp-form button:hover,
8
+ .mc4wp-form input[type="submit"]:active, .mc4wp-form button:active,
9
+ .mc4wp-form input[type="submit"]:focus, .mc4wp-form button:focus {
10
+ color: #ffffff;
11
+ background-color: #3276b1;
12
+ border-color: #285e8e;
13
+ }
14
+
15
+ .mc4wp-form input[type="text"]:focus,
16
+ .mc4wp-form input[type="email"]:focus,
17
+ .mc4wp-form input[type="tel"]:focus,
18
+ .mc4wp-form input[type="url"]:focus,
19
+ .mc4wp-form input[type="date"]:focus,
20
+ .mc4wp-form textarea:focus,
21
+ .mc4wp-form select:focus {
22
+ border-color: #428bca;
23
+ }
trunk/assets/css/form-theme-dark.css ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mc4wp-form input[type="submit"], .mc4wp-form button {
2
+ color: #ffffff !important;
3
+ background-color: #333333;
4
+ border-color: #2E2E2E;
5
+ }
6
+
7
+ .mc4wp-form input[type="submit"]:hover, .mc4wp-form button:hover,
8
+ .mc4wp-form input[type="submit"]:active, .mc4wp-form button:active,
9
+ .mc4wp-form input[type="submit"]:focus, .mc4wp-form button:focus {
10
+ color: #ffffff;
11
+ background-color: #2E2E2E;
12
+ border-color: #292929;
13
+ }
14
+
15
+ .mc4wp-form input[type="text"]:focus,
16
+ .mc4wp-form input[type="email"]:focus,
17
+ .mc4wp-form input[type="tel"]:focus,
18
+ .mc4wp-form input[type="url"]:focus,
19
+ .mc4wp-form input[type="date"]:focus,
20
+ .mc4wp-form textarea:focus,
21
+ .mc4wp-form select:focus {
22
+ border-color: #333333;
23
+ }
trunk/assets/css/form-theme-green.css ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mc4wp-form input[type="submit"], .mc4wp-form button {
2
+ color: #ffffff !important;
3
+ background-color: #5cb85c;
4
+ border-color: #4cae4c;
5
+ }
6
+
7
+ .mc4wp-form input[type="submit"]:hover, .mc4wp-form button:hover,
8
+ .mc4wp-form input[type="submit"]:active, .mc4wp-form button:active,
9
+ .mc4wp-form input[type="submit"]:focus, .mc4wp-form button:focus {
10
+ color: #ffffff;
11
+ background-color: #47a447;
12
+ border-color: #398439;
13
+ }
14
+
15
+ .mc4wp-form input[type="text"]:focus,
16
+ .mc4wp-form input[type="email"]:focus,
17
+ .mc4wp-form input[type="tel"]:focus,
18
+ .mc4wp-form input[type="url"]:focus,
19
+ .mc4wp-form input[type="date"]:focus,
20
+ .mc4wp-form textarea:focus,
21
+ .mc4wp-form select:focus {
22
+ border-color: #5cb85c;
23
+ }
trunk/assets/css/form-theme-light.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mc4wp-form input[type="submit"], .mc4wp-form button {
2
+ color: #333333 !important;
3
+ background-color: #ffffff;
4
+ border-color: #E6E6E6;
5
+ }
6
+
7
+ .mc4wp-form input[type="submit"]:hover, .mc4wp-form button:hover,
8
+ .mc4wp-form input[type="submit"]:active, .mc4wp-form button:active,
9
+ .mc4wp-form input[type="submit"]:focus, .mc4wp-form button:focus {
10
+ color: #E6E6E6;
11
+ background-color: #ebebeb;
12
+ border-color: #CCCCCC;
13
+ }
trunk/assets/css/form-theme-red.css ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mc4wp-form input[type="submit"], .mc4wp-form button {
2
+ color: #ffffff !important;
3
+ background-color: #d9534f;
4
+ border-color: #d43f3a;
5
+ }
6
+
7
+ .mc4wp-form input[type="submit"]:hover, .mc4wp-form button:hover,
8
+ .mc4wp-form input[type="submit"]:active, .mc4wp-form button:active,
9
+ .mc4wp-form input[type="submit"]:focus, .mc4wp-form button:focus {
10
+ color: #ffffff;
11
+ background-color: #d2322d;
12
+ border-color: #ac2925;
13
+ }
14
+
15
+ .mc4wp-form input[type="text"]:focus,
16
+ .mc4wp-form input[type="email"]:focus,
17
+ .mc4wp-form input[type="tel"]:focus,
18
+ .mc4wp-form input[type="url"]:focus,
19
+ .mc4wp-form input[type="date"]:focus,
20
+ .mc4wp-form textarea:focus,
21
+ .mc4wp-form select:focus {
22
+ border-color: #d9534f;
23
+ }
trunk/assets/css/form.css ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* MailChimp for WP - Default Form Styles */
3
+ .mc4wp-form{ margin:1em 0; }
4
+ .mc4wp-form p{ text-align:left; }
5
+ .mc4wp-form label{ display:block; font-weight:bold; margin-bottom:3px; text-align:left; }
6
+ .mc4wp-form label > span, .mc4wp-form li > label{ font-weight: normal; }
7
+
8
+ .mc4wp-form input[type="text"],
9
+ .mc4wp-form input[type="email"],
10
+ .mc4wp-form input[type="tel"],
11
+ .mc4wp-form input[type="url"] { display:inline-block; width:100%; height:auto; box-sizing:border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; }
12
+
13
+ .mc4wp-form input[type="checkbox"] { margin:0 10px 0 0; padding:0; height:13px; width:13px;
14
+ display:inline-block; -webkit-appearance: checkbox; border:0; }
15
+ .mc4wp-form input[type="radio"] { margin:0 10px 0 0; padding:0; height:13px; width:13px;
16
+ display:inline-block; -webkit-appearance: radio; border:0; }
17
+ .mc4wp-form select, .mc4wp-form input[type="date"] { min-width:35%; }
18
+ .mc4wp-form input[type="submit"], .mc4wp-form button{ display:inline-block; }
19
+
20
+ .mc4wp-alert{ margin:1em 0; padding: 10px 15px; color: #c09853; background-color: #fcf8e3; border: 1px solid #fbeed5; border-radius: 2px; -moz-border-radius:2px; -webkit-border-radius:2px; display:block; position:relative;}
21
+ .mc4wp-success { color: #468847; background-color: #dff0d8; border-color: #d6e9c6; }
22
+ .mc4wp-notice { color: #3a87ad; background-color: #d9edf7; border-color: #bce8f1; }
23
+ .mc4wp-error { color: #b94a48; background-color: #f2dede; border-color: #eed3d7;; }
trunk/assets/css/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header('HTTP/1.0 403 Forbidden');
5
+ header("X-Robots-Tag: noindex");
6
+ exit;
trunk/assets/img/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header('HTTP/1.0 403 Forbidden');
5
+ header("X-Robots-Tag: noindex");
6
+ exit;
trunk/assets/img/menu-icon.png ADDED
Binary file
trunk/assets/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header('HTTP/1.0 403 Forbidden');
5
+ header("X-Robots-Tag: noindex");
6
+ exit;
trunk/assets/js/admin.js ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+
3
+ $("tr.pro-feature td :radio").change(function() {
4
+ this.checked = false;
5
+ alert("This option is only available in the premium version of MailChimp for WordPress.");
6
+ });
7
+
8
+ $("tr.pro-feature label").click(function() {
9
+ alert("This option is only available in the premium version of MailChimp for WordPress.");
10
+ });
11
+
12
+
13
+ // Add buttons to QTags editor
14
+ (function() {
15
+ if(window.QTags == undefined) { return; }
16
+
17
+ QTags.addButton( 'mc4wp_paragraph', '<p>', '<p>', '</p>', 'p', 'Paragraph tag', 1 );
18
+ QTags.addButton( 'mc4wp_label', 'label', '<label>', '</label>', 'l', 'Label tag', 2 );
19
+ QTags.addButton( 'mc4wp_subscriber_count', '# of subscribers', '{subscriber_count}', '', 's', 'Shows number of subscribers of selected list(s)' );
20
+ })();
21
+
22
+
23
+ /**
24
+ * MailChimp for WordPress Field Wizard
25
+ * Created by Danny van Kooten
26
+ */
27
+ (function() {
28
+ // setup variables
29
+ var $lists = $("#mc4wp-lists :input");
30
+ var $mailchimpFields = $("#mc4wp-fw-mailchimp-fields");
31
+ var $mailchimpMergeFields = $("#mc4wp-fw-mailchimp-fields .merge-fields");
32
+ var $mailchimpGroupings = $("#mc4wp-fw-mailchimp-fields .groupings");
33
+ var $wizardFields = $("#mc4wp-fw-fields");
34
+ var $value = $("#mc4wp-fw-value");
35
+ var $valueLabel = $("#mc4wp-fw-value-label");
36
+ var $multipleValues = $("#mc4wp-fw-values");
37
+ var $label = $("#mc4wp-fw-label");
38
+ var $placeholder = $("#mc4wp-fw-placeholder");
39
+ var $required = $("#mc4wp-fw-required");
40
+ var $wrapp = $("#mc4wp-fw-wrap-p");
41
+ var field = {
42
+ 'type': 'text',
43
+ 'name': ''
44
+ };
45
+ var $codePreview = $("#mc4wp-fw-preview");
46
+ // functions
47
+
48
+ // set the fields the user can choose from
49
+ function setFields()
50
+ {
51
+ // show notice if no lists selecteed
52
+ var $selectedLists = $lists.filter(':checked');
53
+ $(".no-lists-selected").toggle(($selectedLists.length == 0));
54
+
55
+
56
+ // empty field select
57
+ $mailchimpFields.find('option').not('.default').remove();
58
+
59
+ // loop through checked lists
60
+ $selectedLists.each(function() {
61
+ var fields = $(this).data('fields');
62
+ var groupings = $(this).data('groupings');
63
+
64
+ // loop through merge fields from this list
65
+ for(var i = 0; i < fields.length; i++) {
66
+ var f = fields[i];
67
+
68
+ // add field to select if no similar option exists yet
69
+ if($mailchimpMergeFields.find("option[value='"+ f.tag +"']").length == 0) {
70
+
71
+ var text = (f.name.length > 40) ? f.name.substring(0, 40) + '..' : f.name;
72
+ if(f.req) { text += '*'; }
73
+
74
+ // only show first 4 fields
75
+ if((i <= 3)) {
76
+ var $option = $("<option />").text(text).val(f.tag).data('field', f);
77
+ } else {
78
+ var $option = $("<option />").text("(PRO ONLY) " + text).val(f.tag).attr('disabled', 'disabled');
79
+ }
80
+
81
+ $mailchimpMergeFields.append($option);
82
+ }
83
+ }
84
+
85
+ // loop through interest groupings
86
+ for(var i = 0, groupingsCount = groupings.length; i < groupingsCount; i++) {
87
+ var grouping = groupings[i];
88
+
89
+ // add field to select if no similar option exists yet
90
+ if($mailchimpGroupings.find("option[value='"+ grouping.id +"']").length == 0) {
91
+ var text = (grouping.name.length > 40) ? grouping.name.substring(0, 40) + '..' : grouping.name;
92
+
93
+ // only show 1 grouping
94
+ if(i < 1) {
95
+ var $option = $("<option />").text(text).val(grouping.id).data('grouping', grouping);
96
+ } else {
97
+ var $option = $("<option />").text("(PRO ONLY) " + text).val(grouping.id).attr('disabled', 'disabled');
98
+ }
99
+
100
+ $mailchimpGroupings.append($option);
101
+ }
102
+
103
+
104
+
105
+ }
106
+
107
+
108
+ });
109
+ }
110
+
111
+ function setPresets()
112
+ {
113
+ resetFields();
114
+
115
+ var selected = $(this).find(':selected');
116
+ if(selected.val() == 'submit') {
117
+ // setup values for submit field
118
+ field['type'] = 'submit';
119
+ $valueLabel.text("Button text");
120
+ $wizardFields.find('p.row').filter('.value, .wrap-p').show();
121
+ updateCodePreview();
122
+ } else {
123
+ var data = selected.data('field');
124
+ if(data) { return setPresetsForField(data); }
125
+
126
+ var data = selected.data('grouping');
127
+ if(data) { return setPresetsForGrouping(data); }
128
+ }
129
+ return;
130
+ }
131
+
132
+ function resetFields() {
133
+ $wizardFields.find('.row :input').each(function() {
134
+ if($(this).is(":checkbox")) { this.checked = true; } else { this.value = ''; }
135
+ });
136
+
137
+ $wizardFields.find('p.row').hide();
138
+ $multipleValues.find(':input').remove();
139
+ $wizardFields.show();
140
+
141
+ field['type'] = 'text';
142
+ field['name'] = '';
143
+ $valueLabel.html("Initial value <small>(optional)</small>");
144
+ }
145
+
146
+ function addGroupInputs(groups)
147
+ {
148
+ // add a text input to $multipleValues for each group
149
+ for(var i = 0, groupsCount = groups.length; i < groupsCount; i++) {
150
+ $("<input />").attr('type', 'text').addClass('widefat').data('value', groups[i].name).attr('placeholder', 'Label for "' + groups[i].name + '" (or leave empty)').attr('value', groups[i].name).appendTo($multipleValues);
151
+ }
152
+ }
153
+
154
+ function setPresetsForGrouping(data)
155
+ {
156
+ $wizardFields.find('p.row').filter('.values, .label, .wrap-p').show();
157
+ $label.val(data.name + ":");
158
+ field['name'] = 'GROUPINGS['+ data.id + ']';
159
+ addGroupInputs(data.groups);
160
+
161
+ if(data.form_field == 'radio') {
162
+ field['type'] = 'radio';
163
+ } else if(data.form_field == 'dropdown') {
164
+ field['type'] = 'select';
165
+ } else if(data.form_field == 'hidden') {
166
+ $wizardFields.find('p.row').filter('.values, .label, .wrap-p').hide();
167
+ $wizardFields.find('p.row.value').show();
168
+ field['type'] = 'hidden';
169
+
170
+ for(var i = 0, groupsCount = data.groups.length; i < groupsCount; i++) {
171
+ $value.val($value.val() + data.groups[i].name + ',');
172
+ }
173
+
174
+ } else {
175
+ field['type'] = 'checkbox';
176
+ field['name'] = 'GROUPINGS['+ data.id + '][]';
177
+ }
178
+
179
+ // update code preview
180
+ updateCodePreview();
181
+ }
182
+
183
+
184
+ // show available fields and fill it with some values
185
+ function setPresetsForField(data)
186
+ {
187
+
188
+ // show fields for this field type
189
+ var visibleRowsMap = {
190
+ 'default': [ 'label', 'value', 'placeholder', 'required', 'wrap-p' ],
191
+ 'select': [ 'label', 'required', 'wrap-p', 'values'],
192
+ 'radio': [ 'label', 'required', 'wrap-p', 'values'],
193
+ 'date': [ 'label', 'required', 'wrap-p', 'value']
194
+ }
195
+
196
+ var fieldTypesMap = {
197
+ 'text': 'text', 'email': 'email', 'phone': 'tel', 'address': 'text', 'number': 'number',
198
+ 'dropdown': 'select', 'date': 'date', 'birthday': 'date', 'radio': 'radio', 'checkbox': 'checkbox'
199
+ }
200
+
201
+ if(fieldTypesMap[data.field_type] != undefined) {
202
+ var fieldType = fieldTypesMap[data.field_type];
203
+ } else {
204
+ var fieldType = 'text';
205
+ }
206
+
207
+ if(visibleRowsMap[fieldType] != undefined) {
208
+ var visibleRows = visibleRowsMap[fieldType];
209
+ } else {
210
+ var visibleRows = visibleRowsMap["default"];
211
+ }
212
+
213
+ for(var i = 0, count = visibleRows.length; i < count; i++) {
214
+ $wizardFields.find('p.row.' + visibleRows[i]).show();
215
+ }
216
+
217
+ // populate fields with preset values
218
+ field['type'] = fieldType;
219
+ field['name'] = data.tag;
220
+ $placeholder.val("Your " + data.name.toLowerCase());
221
+ $label.val(data.name + ":");
222
+ $required.attr('checked', data.req);
223
+ if($multipleValues.is(":visible") && data.choices) {
224
+ for(var i = 0, count = data.choices.length; i < count; i++) {
225
+ $("<input />").attr('type', 'text').addClass('widefat').data('value', data.choices[i]).attr('placeholder', 'Label for "' + data.choices[i] + '" (or leave empty)').attr('value', data.choices[i]).appendTo($multipleValues);
226
+ }
227
+ }
228
+
229
+ // update code preview
230
+ updateCodePreview();
231
+ }
232
+
233
+ function updateCodePreview()
234
+ {
235
+ var $code = $("<div></div>");
236
+ var inputs = [];
237
+ var $input;
238
+
239
+ // build input / select / textarea element
240
+ if(field['type'] == 'select') {
241
+ $input = $("<select />");
242
+
243
+ // add options to select
244
+ $multipleValues.find(":input").each(function() {
245
+ if($(this).val().length > 0) {
246
+ $el = $("<option />").val($(this).data("value")).text($(this).val());
247
+ $el.appendTo($input);
248
+ }
249
+ });
250
+
251
+ } else if(field['type'] == 'radio' || field['type'] == 'checkbox') {
252
+
253
+ // build multiple input values
254
+ $multipleValues.find(":input").each(function() {
255
+ if($(this).val().length > 0) {
256
+ $input = $("<input />").attr('type', field['type']).attr('name', field.name).val($(this).data('value'));
257
+
258
+ if($required.is(':visible:checked')) {
259
+ $input.attr('required', 'required');
260
+ }
261
+
262
+ $code.append($input);
263
+
264
+ $input.wrap("<label />");
265
+ $("<span />").text($(this).val() + ' ').insertAfter($input);
266
+ }
267
+ });
268
+
269
+ } else if(field['type'] == 'textarea') {
270
+ $input = $("<textarea />");
271
+ } else {
272
+ $input = $("<input />").attr('type', field['type']);
273
+ }
274
+
275
+ // only do this piece when we're not adding radio inputs
276
+ if(field['type'] != 'radio' && field['type'] != 'checkbox') {
277
+
278
+ // set name attribute
279
+ if(field.name.length > 0) {
280
+ $input.attr('name', field.name);
281
+ }
282
+
283
+ // set value
284
+ if($value.is(":visible") && $value.val().length > 0) {
285
+ if(field['type'] == 'textarea') {
286
+ $input.text($value.val());
287
+ } else {
288
+ $input.attr('value', $value.val());
289
+ }
290
+ }
291
+
292
+ // add placeholder to element
293
+ if($placeholder.is(":visible") && $placeholder.val().length > 0) {
294
+ $input.attr('placeholder', $placeholder.val());
295
+ }
296
+
297
+ // add required attribute
298
+ if($required.is(':visible:checked')) {
299
+ $input.attr('required', 'required');
300
+ }
301
+
302
+ $code.append($input);
303
+
304
+
305
+ }
306
+
307
+ // build label
308
+ if($label.is(":visible") && $label.val().length > 0) {
309
+ $("<label />").text($label.val()).prependTo($code);
310
+ }
311
+
312
+ // start indenting and tabbing of code
313
+ var codePreview = $code.html();
314
+
315
+ if($wrapp.is(':visible:checked')) {
316
+ $code.wrapInner($("<p />"));
317
+
318
+ // indent code inside paragraphs (double tab)
319
+ codePreview = $code.html()
320
+ .replace(/<p>/gi, "<p>\n\t")
321
+ .replace(/<label><input /gi, "\n\t<label><input ")
322
+ .replace(/<\/label><input/gi, "</label> \n\t<input")
323
+ .replace(/<select /gi, "\n\t<select ")
324
+ .replace(/<\/select>/gi, "\n\t</select>")
325
+ .replace(/<\/span><\/label>/gi, "</span>\n\t</label> \n")
326
+ .replace(/<option /gi, "\n\t\t<option ")
327
+ .replace(/<label><input type="radio"/g, "<label>\n\t\t<input type=\"radio\"")
328
+ .replace(/<label><input type="checkbox"/g, "<label>\n\t\t<input type=\"checkbox\"")
329
+ .replace(/<span>/gi, "\n\t\t<span>")
330
+ } else {
331
+ // indent code, single tab
332
+ codePreview = codePreview
333
+ .replace(/<option /gi, "\n\t<option ")
334
+ .replace(/<label><input type="radio"/g, "<label>\n\t<input type=\"radio\"")
335
+ .replace(/<label><input type="checkbox"/g, "<label>\n\t<input type=\"checkbox\"")
336
+ .replace(/<span>/gi, "\n\t<span>");
337
+ }
338
+
339
+ // newline after every closed element
340
+ codePreview = codePreview.replace(/></g, "> \n<");
341
+
342
+ // add code to codePreview textarea
343
+ $codePreview.val(codePreview);
344
+ }
345
+
346
+ function addCodeToFormMarkup() {
347
+
348
+ var result = false;
349
+
350
+ // try to insert in QuickTags editor at cursor position
351
+ if(typeof QTags !='undefined' && QTags.insertContent) {
352
+ result = QTags.insertContent($codePreview.val());
353
+ }
354
+
355
+ // fallback
356
+ if(!result) {
357
+ $("#mc4wpformmarkup").val($("#mc4wpformmarkup").val() + "\n" + $codePreview.val());
358
+ }
359
+ }
360
+
361
+ // setup events
362
+ $lists.change(setFields);
363
+ $mailchimpFields.change(setPresets);
364
+ $wizardFields.change(updateCodePreview);
365
+ $("#mc4wp-fw-add-to-form").click(addCodeToFormMarkup);
366
+
367
+ // init
368
+ setFields();
369
+
370
+ })();
371
+
372
+ })(jQuery);
373
+
trunk/assets/js/forms.js ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function mc4wpAddEvent(element, eventName, callback) {
2
+ if (element.addEventListener) {
3
+ element.addEventListener(eventName, callback, false);
4
+ } else {
5
+ element.attachEvent("on" + eventName, callback);
6
+ }
7
+ }
8
+
9
+ mc4wpAddEvent(window, "load", function() {
10
+
11
+ /**
12
+ * Populate the form elements in a given container from a JSON object
13
+ */
14
+ function populateFields(container, data, basename) {
15
+
16
+ for(var key in data) {
17
+
18
+ var name = key;
19
+ var value = data[key];
20
+
21
+ // no need to set empty values
22
+ if(value == "") {
23
+ continue;
24
+ }
25
+
26
+ // handle array name attributes
27
+ if(typeof(basename) !== "undefined") {
28
+ name = basename + "[" + key + "]";
29
+ }
30
+
31
+ if(value.constructor == Array) {
32
+ name += '[]';
33
+ } else if(typeof value == "object") {
34
+ populateFields(container, value, name);
35
+ continue;
36
+ }
37
+
38
+ // populate field
39
+ var elements = container.querySelectorAll('input[name="'+ name +'"], select[name="'+ name +'"], textarea[name="'+ name +'"]');
40
+
41
+ // Dirty: abandon if we did not find the element
42
+ if(!elements) {
43
+ return;
44
+ }
45
+
46
+ // loop through found elements to set their values
47
+ for(var i = 0; i < elements.length; i++) {
48
+
49
+ var element = elements[i];
50
+
51
+ // check element type
52
+ switch(element.type || element.tagName) {
53
+ case 'text':
54
+ case 'email':
55
+ case 'date':
56
+ case 'tel':
57
+ element.value = value;
58
+
59
+ // remove IE placeholder fallback class
60
+ element.className = element.className.replace('placeholdersjs','');
61
+ break;
62
+
63
+ case 'radio':
64
+ element.checked = (element.value === value);
65
+ break;
66
+
67
+ case 'checkbox':
68
+ for(var j = 0; j < value.length; j++) {
69
+ element.checked = (element.value === value[j]);
70
+ }
71
+ break;
72
+
73
+ case 'select-multiple':
74
+ var values = value.constructor == Array ? value : [value];
75
+
76
+ for(var k = 0; k < element.options.length; k++)
77
+ {
78
+ for(var l = 0; l < values.length; l++)
79
+ {
80
+ element.options[k].selected |= (element.options[k].value == values[l]);
81
+ }
82
+ }
83
+ break;
84
+
85
+ case 'select':
86
+ case 'select-one':
87
+ element.value = value.toString() || value;
88
+ break;
89
+ }
90
+ }
91
+
92
+
93
+ }
94
+
95
+ }
96
+
97
+ // scroll to submitted form element
98
+ var formElement = document.getElementById('mc4wp-form-' + mc4wp.submittedFormId);
99
+
100
+ if(!formElement) {
101
+ return;
102
+ }
103
+
104
+ // only populate fields on error
105
+ if(mc4wp.success == false) {
106
+ populateFields(formElement, mc4wp.postData);
107
+ }
108
+
109
+ // calculate window height to scroll to
110
+ var scrollToHeight = 0;
111
+ var obj = formElement;
112
+ var windowHeight = window.innerHeight;
113
+
114
+ if (obj.offsetParent) {
115
+ do {
116
+ scrollToHeight += obj.offsetTop;
117
+ } while (obj = obj.offsetParent);
118
+ } else {
119
+ scrollToHeight = formElement.offsetTop;
120
+ }
121
+
122
+ if((windowHeight - 80) > formElement.clientHeight) {
123
+ // vertically center the form, but only if there's enough space for a decent margin
124
+ scrollToHeight = scrollToHeight - ((windowHeight - formElement.clientHeight) / 2);
125
+ } else {
126
+ // the form doesn't fit, scroll a little above the form
127
+ scrollToHeight = scrollToHeight - 80;
128
+ }
129
+
130
+ // scroll there. if jQuery is loaded, do it with an animation.
131
+ if(window.jQuery !== undefined) {
132
+ jQuery('html, body').animate({ scrollTop: scrollToHeight }, 800);
133
+ } else {
134
+ window.scrollTo(0, scrollToHeight);
135
+ }
136
+ });
trunk/assets/js/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header('HTTP/1.0 403 Forbidden');
5
+ header("X-Robots-Tag: noindex");
6
+ exit;
trunk/assets/js/placeholders.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* Placeholders.js v3.0.1 */
2
+ (function(t){"use strict";function e(t,e,r){return t.addEventListener?t.addEventListener(e,r,!1):t.attachEvent?t.attachEvent("on"+e,r):void 0}function r(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(t[r]===e)return!0;return!1}function n(t,e){var r;t.createTextRange?(r=t.createTextRange(),r.move("character",e),r.select()):t.selectionStart&&(t.focus(),t.setSelectionRange(e,e))}function a(t,e){try{return t.type=e,!0}catch(r){return!1}}t.Placeholders={Utils:{addEventListener:e,inArray:r,moveCaret:n,changeType:a}}})(this),function(t){"use strict";function e(){}function r(){try{return document.activeElement}catch(t){}}function n(t,e){var r,n,a=!!e&&t.value!==e,u=t.value===t.getAttribute(D);return(a||u)&&"true"===t.getAttribute(I)?(t.removeAttribute(I),t.value=t.value.replace(t.getAttribute(D),""),t.className=t.className.replace(V,""),n=t.getAttribute(F),n&&(t.setAttribute("maxLength",n),t.removeAttribute(F)),r=t.getAttribute(P),r&&(t.type=r),!0):!1}function a(t){var e,r,n=t.getAttribute(D);return""===t.value&&n?(t.setAttribute(I,"true"),t.value=n,t.className+=" "+R,r=t.getAttribute(F),r||(t.setAttribute(F,t.maxLength),t.removeAttribute("maxLength")),e=t.getAttribute(P),e?t.type="text":"password"===t.type&&M.changeType(t,"text")&&t.setAttribute(P,"password"),!0):!1}function u(t,e){var r,n,a,u,i;if(t&&t.getAttribute(D))e(t);else for(r=t?t.getElementsByTagName("input"):b,n=t?t.getElementsByTagName("textarea"):f,i=0,u=r.length+n.length;u>i;i++)a=r.length>i?r[i]:n[i-r.length],e(a)}function i(t){u(t,n)}function l(t){u(t,a)}function o(t){return function(){h&&t.value===t.getAttribute(D)&&"true"===t.getAttribute(I)?M.moveCaret(t,0):n(t)}}function c(t){return function(){a(t)}}function s(t){return function(e){return A=t.value,"true"===t.getAttribute(I)&&A===t.getAttribute(D)&&M.inArray(B,e.keyCode)?(e.preventDefault&&e.preventDefault(),!1):void 0}}function d(t){return function(){n(t,A),""===t.value&&(t.blur(),M.moveCaret(t,0))}}function g(t){return function(){t===r()&&t.value===t.getAttribute(D)&&"true"===t.getAttribute(I)&&M.moveCaret(t,0)}}function v(t){return function(){i(t)}}function p(t){t.form&&(T=t.form,T.getAttribute(U)||(M.addEventListener(T,"submit",v(T)),T.setAttribute(U,"true"))),M.addEventListener(t,"focus",o(t)),M.addEventListener(t,"blur",c(t)),h&&(M.addEventListener(t,"keydown",s(t)),M.addEventListener(t,"keyup",d(t)),M.addEventListener(t,"click",g(t))),t.setAttribute(j,"true"),t.setAttribute(D,x),(h||t!==r())&&a(t)}var b,f,h,m,A,y,E,x,L,T,N,S,w,C=["text","search","url","tel","email","password","number","textarea"],B=[27,33,34,35,36,37,38,39,40,8,46],k="#ccc",R="placeholdersjs",V=RegExp("(?:^|\\s)"+R+"(?!\\S)"),D="data-placeholder-value",I="data-placeholder-active",P="data-placeholder-type",U="data-placeholder-submit",j="data-placeholder-bound",q="data-placeholder-focus",z="data-placeholder-live",F="data-placeholder-maxlength",G=document.createElement("input"),H=document.getElementsByTagName("head")[0],J=document.documentElement,K=t.Placeholders,M=K.Utils;if(K.nativeSupport=void 0!==G.placeholder,!K.nativeSupport){for(b=document.getElementsByTagName("input"),f=document.getElementsByTagName("textarea"),h="false"===J.getAttribute(q),m="false"!==J.getAttribute(z),y=document.createElement("style"),y.type="text/css",E=document.createTextNode("."+R+" { color:"+k+"; }"),y.styleSheet?y.styleSheet.cssText=E.nodeValue:y.appendChild(E),H.insertBefore(y,H.firstChild),w=0,S=b.length+f.length;S>w;w++)N=b.length>w?b[w]:f[w-b.length],x=N.attributes.placeholder,x&&(x=x.nodeValue,x&&M.inArray(C,N.type)&&p(N));L=setInterval(function(){for(w=0,S=b.length+f.length;S>w;w++)N=b.length>w?b[w]:f[w-b.length],x=N.attributes.placeholder,x?(x=x.nodeValue,x&&M.inArray(C,N.type)&&(N.getAttribute(j)||p(N),(x!==N.getAttribute(D)||"password"===N.type&&!N.getAttribute(P))&&("password"===N.type&&!N.getAttribute(P)&&M.changeType(N,"text")&&N.setAttribute(P,"password"),N.value===N.getAttribute(D)&&(N.value=x),N.setAttribute(D,x)))):N.getAttribute(I)&&(n(N),N.removeAttribute(D));m||clearInterval(L)},100)}M.addEventListener(t,"beforeunload",function(){i()}),K.disable=K.nativeSupport?e:i,K.enable=K.nativeSupport?e:l}(this);
trunk/includes/class-admin.php ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MC4WP_Lite_Admin
4
+ {
5
+ private static $instance = null;
6
+
7
+ public static function init() {
8
+ if(!self::$instance) {
9
+ self::$instance = new self();
10
+ } else {
11
+ throw new Exception("Already initalized.");
12
+ }
13
+ }
14
+
15
+ private function __construct()
16
+ {
17
+ add_action('admin_init', array($this, 'register_settings'));
18
+ add_action('admin_menu', array($this, 'build_menu'));
19
+ add_action( 'admin_enqueue_scripts', array($this, 'load_css_and_js') );
20
+
21
+ register_activation_hook( 'mailchimp-for-wp/mailchimp-for-wp.php', array($this, 'delete_transients') );
22
+ register_deactivation_hook( 'mailchimp-for-wp-pro/mailchimp-for-wp-pro.php', array($this, 'delete_transients') );
23
+
24
+ add_filter("plugin_action_links_mailchimp-for-wp/mailchimp-for-wp.php", array($this, 'add_settings_link'));
25
+
26
+ // did the user click on upgrade to pro link?
27
+ if(isset($_GET['page'])) {
28
+
29
+ if($_GET['page'] == 'mc4wp-lite-upgrade' && !headers_sent()) {
30
+ header("Location: http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=menu-upgrade-link");
31
+ exit;
32
+ }
33
+
34
+ if($_GET['page'] == 'mc4wp-lite-form-settings') {
35
+ add_filter('quicktags_settings', array($this, 'set_quicktags_buttons'), 10, 2 );
36
+ }
37
+ }
38
+ }
39
+
40
+ public function delete_transients()
41
+ {
42
+ delete_transient('mc4wp_mailchimp_lists');
43
+ delete_transient('mc4wp_mailchimp_lists_fallback');
44
+ }
45
+
46
+ public function set_quicktags_buttons($settings, $editor_id)
47
+ {
48
+ if($editor_id != 'mc4wpformmarkup') { return $settings; }
49
+
50
+ // strong,em,link,block,del,ins,img,ul,ol,li,code,more,close
51
+ $settings['buttons'] = 'strong,em,link,block,img,ul,ol,li,close';
52
+ return $settings;
53
+ }
54
+
55
+ public function add_settings_link($links)
56
+ {
57
+ $settings_link = '<a href="admin.php?page=mc4wp-lite">'. __('Settings') . '</a>';
58
+ $upgrade_link = '<a href="http://dannyvankooten.com/mailchimp-for-wordpress/">Upgrade to Pro</a>';
59
+ array_unshift($links, $upgrade_link, $settings_link);
60
+ return $links;
61
+ }
62
+
63
+ public function register_settings()
64
+ {
65
+ register_setting('mc4wp_lite_settings', 'mc4wp_lite', array($this, 'validate_settings') );
66
+ register_setting('mc4wp_lite_checkbox_settings', 'mc4wp_lite_checkbox');
67
+ register_setting('mc4wp_lite_form_settings', 'mc4wp_lite_form');
68
+ }
69
+
70
+ public function build_menu()
71
+ {
72
+ add_menu_page('MailChimp for WP Lite', 'MailChimp for WP', 'manage_options', 'mc4wp-lite', array($this, 'show_api_settings'), plugins_url('mailchimp-for-wp/assets/img/menu-icon.png'));
73
+ add_submenu_page('mc4wp-lite', 'API Settings - MailChimp for WP Lite', 'MailChimp Settings', 'manage_options', 'mc4wp-lite', array($this, 'show_api_settings'));
74
+ add_submenu_page('mc4wp-lite', 'Checkbox Settings - MailChimp for WP Lite', 'Checkboxes', 'manage_options', 'mc4wp-lite-checkbox-settings', array($this, 'show_checkbox_settings'));
75
+ add_submenu_page('mc4wp-lite', 'Form Settings - MailChimp for WP Lite', 'Forms', 'manage_options', 'mc4wp-lite-form-settings', array($this, 'show_form_settings'));
76
+ add_submenu_page('mc4wp-lite', 'Upgrade to Pro - MailChimp for WP Lite', 'Upgrade to Pro', 'manage_options', 'mc4wp-lite-upgrade', array($this, 'redirect_to_pro'));
77
+ }
78
+
79
+ public function validate_settings( $settings ) {
80
+
81
+ if( isset( $settings['api_key'] ) ) {
82
+ $settings['api_key'] = trim( $settings['api_key'] );
83
+ }
84
+
85
+ return $settings;
86
+ }
87
+
88
+ public function load_css_and_js($hook)
89
+ {
90
+ if(!isset($_GET['page']) || stristr($_GET['page'], 'mc4wp-lite') == false) { return; }
91
+
92
+ // css
93
+ wp_enqueue_style( 'mc4wp-admin-css', plugins_url('mailchimp-for-wp/assets/css/admin.css') );
94
+
95
+ // js
96
+ wp_register_script('mc4wp-admin-js', plugins_url('mailchimp-for-wp/assets/js/admin.js'), array('jquery'), false, true);
97
+ wp_enqueue_script( array('jquery', 'mc4wp-admin-js') );
98
+ }
99
+
100
+ public function get_checkbox_compatible_plugins()
101
+ {
102
+ $checkbox_plugins = array(
103
+ 'comment_form' => "Comment form",
104
+ "registration_form" => "Registration form"
105
+ );
106
+
107
+ if(is_multisite()) $checkbox_plugins['multisite_form'] = "MultiSite forms";
108
+ if(class_exists("BuddyPress")) $checkbox_plugins['buddypress_form'] = "BuddyPress registration";
109
+ if(class_exists('bbPress')) $checkbox_plugins['bbpress_forms'] = "bbPress";
110
+
111
+ if ( class_exists( 'Easy_Digital_Downloads' ) ) $checkbox_plugins['_edd_checkout'] = "(PRO ONLY) Easy Digital Downloads checkout";
112
+ if ( class_exists( 'Woocommerce' ) ) $checkbox_plugins['_woocommerce_checkout'] = "(PRO ONLY) WooCommerce checkout";
113
+
114
+ return $checkbox_plugins;
115
+ }
116
+
117
+ public function redirect_to_pro()
118
+ {
119
+ ?><script>window.location.replace('http://dannyvankooten.com/mailchimp-for-wordpress/'); </script><?php
120
+ }
121
+
122
+ public function show_api_settings()
123
+ {
124
+ $opts = mc4wp_get_options('general');
125
+ $tab = 'api-settings';
126
+
127
+ if(empty($opts['api_key'])) {
128
+ $connected = false;
129
+ } else {
130
+ $connected = (mc4wp_get_api()->is_connected());
131
+ }
132
+
133
+ $lists = $this->get_mailchimp_lists();
134
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/api-settings.php';
135
+ }
136
+
137
+ public function show_checkbox_settings()
138
+ {
139
+ $opts = mc4wp_get_options('checkbox');
140
+ $lists = $this->get_mailchimp_lists();
141
+
142
+ $tab = 'checkbox-settings';
143
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/checkbox-settings.php';
144
+ }
145
+
146
+ public function show_form_settings()
147
+ {
148
+ $opts = mc4wp_get_options('form');
149
+ $lists = $this->get_mailchimp_lists();
150
+ $tab = 'form-settings';
151
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/views/form-settings.php';
152
+ }
153
+
154
+ /**
155
+ * Get MailChimp lists
156
+ * Try cache first, then try API, then try fallback cache.
157
+ */
158
+ private function get_mailchimp_lists()
159
+ {
160
+ $cached_lists = get_transient( 'mc4wp_mailchimp_lists' );
161
+ $refresh_cache = (isset($_REQUEST['renew-cached-data']));
162
+
163
+ // force cache refresh if merge_vars are not set (deprecated)
164
+ if(!$refresh_cache && $cached_lists) {
165
+ if(!is_array($cached_lists)) {
166
+ $refresh_cache = true;
167
+ } else {
168
+ $first_list = reset($cached_lists);
169
+ $refresh_cache = !isset($first_list->merge_vars);
170
+ }
171
+ }
172
+
173
+ if($refresh_cache || !$cached_lists) {
174
+ // make api request for lists
175
+ $api = mc4wp_get_api();
176
+ $lists = array();
177
+ $lists_data = $api->get_lists();
178
+
179
+ if($lists_data) {
180
+
181
+ $list_ids = array();
182
+ foreach($lists_data as $list) {
183
+ $list_ids[] = $list->id;
184
+
185
+ $lists["{$list->id}"] = (object) array(
186
+ 'id' => $list->id,
187
+ 'name' => $list->name,
188
+ 'subscriber_count' => $list->stats->member_count,
189
+ 'merge_vars' => array(),
190
+ 'interest_groupings' => array()
191
+ );
192
+
193
+ // get interest groupings
194
+ $groupings_data = $api->get_list_groupings($list->id);
195
+ if($groupings_data) {
196
+ $lists["{$list->id}"]->interest_groupings = array_map(array($this, 'strip_unnecessary_grouping_properties'), $groupings_data);
197
+ }
198
+ }
199
+
200
+ // get merge vars for all lists at once
201
+ $merge_vars_data = $api->get_lists_with_merge_vars($list_ids);
202
+ if($merge_vars_data) {
203
+ foreach($merge_vars_data as $list) {
204
+ // add merge vars to list
205
+ $lists["{$list->id}"]->merge_vars = array_map(array($this, 'strip_unnecessary_merge_vars_properties'), $list->merge_vars);
206
+ }
207
+ }
208
+
209
+ // cache renewal triggered manually?
210
+ if(isset($_POST['renew-cached-data'])) {
211
+ if($lists) {
212
+ add_settings_error("mc4wp", "cache-renewed", 'Renewed MailChimp cache.', 'updated' );
213
+ } else {
214
+ add_settings_error("mc4wp", "cache-renew-failed", 'Failed to renew MailChimp cache - please try again later.' );
215
+ }
216
+ }
217
+
218
+ // store lists in transients
219
+ set_transient('mc4wp_mailchimp_lists', $lists, (24 * 3600)); // 1 day
220
+ set_transient('mc4wp_mailchimp_lists_fallback', $lists, 1209600); // 2 weeks
221
+ return $lists;
222
+ } else {
223
+ // api request failed, get fallback data (with longer lifetime)
224
+ $cached_lists = get_transient('mc4wp_mailchimp_lists_fallback');
225
+ if(!$cached_lists) { return array(); }
226
+ }
227
+
228
+ }
229
+
230
+ return $cached_lists;
231
+ }
232
+
233
+ /**
234
+ * Build the group array object which will be stored in cache
235
+ */
236
+ public function strip_unnecessary_group_properties($group) {
237
+ return (object) array(
238
+ 'name' => $group->name
239
+ );
240
+ }
241
+
242
+ /**
243
+ * Build the groupings array object which will be stored in cache
244
+ */
245
+ public function strip_unnecessary_grouping_properties($grouping)
246
+ {
247
+ return (object) array(
248
+ 'id' => $grouping->id,
249
+ 'name' => $grouping->name,
250
+ 'groups' => array_map(array($this, 'strip_unnecessary_group_properties'), $grouping->groups),
251
+ 'form_field' => $grouping->form_field
252
+ );
253
+ }
254
+
255
+ /**
256
+ * Build the merge_var array object which will be stored in cache
257
+ */
258
+ public function strip_unnecessary_merge_vars_properties($merge_var)
259
+ {
260
+ $array = array(
261
+ 'name' => $merge_var->name,
262
+ 'field_type' => $merge_var->field_type,
263
+ 'req' => $merge_var->req,
264
+ 'tag' => $merge_var->tag
265
+ );
266
+
267
+ if ( isset( $merge_var->choices ) ) {
268
+ $array["choices"] = $merge_var->choices;
269
+ }
270
+
271
+ return (object) $array;
272
+
273
+ }
274
+
275
+ }
trunk/includes/class-api.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MC4WP_Lite_API {
4
+
5
+ private $api_url = 'https://api.mailchimp.com/2.0/';
6
+ private $api_key = '';
7
+ private $error_message = '';
8
+ private $connected = null;
9
+
10
+ public function __construct($api_key)
11
+ {
12
+ $this->api_key = $api_key;
13
+
14
+ if(strpos($api_key, '-') !== false) {
15
+ $this->api_url = 'https://' . substr($api_key, -3) . '.api.mailchimp.com/2.0/';
16
+ }
17
+ }
18
+
19
+ public function is_connected()
20
+ {
21
+ if($this->connected === null) {
22
+ $result = $this->call('helper/ping');
23
+ $this->connected = ($result && isset($result->msg) && $result->msg === "Everything's Chimpy!");
24
+ }
25
+
26
+ return $this->connected;
27
+ }
28
+
29
+ public function subscribe($list_id, $email, array $merge_vars = array(), $email_type = 'html', $double_optin = true, $update_existing = false, $replace_interests = true, $send_welcome = false )
30
+ {
31
+ $data = array(
32
+ 'id' => $list_id,
33
+ 'email' => array( 'email' => $email),
34
+ 'merge_vars' => $merge_vars,
35
+ 'email_type' => $email_type,
36
+ 'double_optin' => $double_optin,
37
+ 'update_existing' => $update_existing,
38
+ 'replace_interests' => $replace_interests,
39
+ 'send_welcome' => $send_welcome
40
+ );
41
+
42
+ $result = $this->call('lists/subscribe', $data);
43
+
44
+ if($result) {
45
+
46
+ if(!isset($result->error)) {
47
+ return true;
48
+ } else {
49
+ // check error
50
+ if($result->code == 214) { return 'already_subscribed'; }
51
+
52
+ // store error message
53
+ $this->error_message = $result->error;
54
+ return 'error';
55
+ }
56
+
57
+ } else {
58
+ return 'error';
59
+ }
60
+ }
61
+
62
+ public function get_list_groupings($list_id)
63
+ {
64
+ $result = $this->call('lists/interest-groupings', array('id' => $list_id) );
65
+ if($result && is_array($result)) {
66
+ return $result;
67
+ } else {
68
+ return false;
69
+ }
70
+ }
71
+
72
+ public function get_lists()
73
+ {
74
+ $result = $this->call('lists/list', array('limit' => 100));
75
+
76
+ if($result && isset($result->data)) {
77
+ return $result->data;
78
+ } else {
79
+ return false;
80
+ }
81
+ }
82
+
83
+ public function get_lists_with_merge_vars($list_ids)
84
+ {
85
+ $result = $this->call('lists/merge-vars', array('id' => $list_ids));
86
+
87
+ if($result && isset($result->data)) {
88
+ return $result->data;
89
+ } else {
90
+ return false;
91
+ }
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
+ $url = $this->api_url . $method . '.json';
101
+
102
+ $response = wp_remote_post($url, array(
103
+ 'body' => $data,
104
+ 'timeout' => 20,
105
+ 'headers' => array('Accept-Encoding' => ''),
106
+ 'sslverify' => false
107
+ )
108
+ );
109
+
110
+ if(is_wp_error($response)) {
111
+ return false;
112
+ } else {
113
+ // dirty fix for older WP version
114
+ if($method == 'helper/ping' && isset($response['headers']['content-length']) && (int) $response['headers']['content-length'] == '44') {
115
+ return (object) array( 'msg' => "Everything's Chimpy!");
116
+ }
117
+
118
+ $body = wp_remote_retrieve_body($response);
119
+ return json_decode($body);
120
+ }
121
+ }
122
+
123
+ public function has_error()
124
+ {
125
+ return (!empty($this->error_message));
126
+ }
127
+
128
+ public function get_error_message()
129
+ {
130
+ return $this->error_message;
131
+ }
132
+
133
+ }
trunk/includes/class-checkbox.php ADDED
@@ -0,0 +1,424 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MC4WP_Lite_Checkbox
4
+ {
5
+ private $showed_checkbox = false;
6
+ private static $instance = null;
7
+
8
+ public static function init() {
9
+ if(self::$instance) {
10
+ throw new Exception("Already initialized");
11
+ } else {
12
+ self::$instance = new self;
13
+ }
14
+ }
15
+
16
+ public static function instance() {
17
+ return self::$instance;
18
+ }
19
+
20
+ private function __construct()
21
+ {
22
+ $opts = mc4wp_get_options('checkbox');
23
+
24
+ add_action('init', array($this, 'initialize'));
25
+
26
+ // load checkbox css if necessary
27
+ if ( $opts['css'] ) {
28
+ add_filter('mc4wp_stylesheets', array($this, 'add_stylesheet'));
29
+ }
30
+
31
+ /* Comment Form Actions */
32
+ if($opts['show_at_comment_form']) {
33
+ // hooks for checking if we should subscribe the commenter
34
+ add_action('comment_post', array($this, 'subscribe_from_comment'), 20, 2);
35
+
36
+ // hooks for outputting the checkbox
37
+ add_action('thesis_hook_after_comment_box', array($this,'output_checkbox'), 20);
38
+ add_action('comment_form', array($this,'output_checkbox'), 20);
39
+ }
40
+
41
+ /* Registration Form Actions */
42
+ if($opts['show_at_registration_form']) {
43
+ add_action('register_form',array($this, 'output_checkbox'),20);
44
+ add_action('user_register',array($this, 'subscribe_from_registration'), 80, 1);
45
+ }
46
+
47
+ /* BuddyPress Form Actions */
48
+ if($opts['show_at_buddypress_form']) {
49
+ add_action('bp_before_registration_submit_buttons', array($this, 'output_checkbox'), 20);
50
+ add_action('bp_complete_signup', array($this, 'subscribe_from_buddypress'), 20);
51
+ }
52
+
53
+ /* Multisite Form Actions */
54
+ if($opts['show_at_multisite_form']) {
55
+ add_action('signup_extra_fields', array($this, 'output_checkbox'), 20);
56
+ add_action('signup_blogform', array($this, 'add_multisite_hidden_checkbox'), 20);
57
+ add_action('wpmu_activate_blog', array($this, 'on_multisite_blog_signup'), 20, 5);
58
+ add_action('wpmu_activate_user', array($this, 'on_multisite_user_signup'), 20, 3);
59
+
60
+ add_filter('add_signup_meta', array($this, 'add_multisite_usermeta'));
61
+ }
62
+
63
+ /* bbPress actions */
64
+ if($opts['show_at_bbpress_forms']) {
65
+ add_action('bbp_theme_after_topic_form_subscriptions', array($this, 'output_checkbox'), 10);
66
+ add_action('bbp_theme_after_reply_form_subscription', array($this, 'output_checkbox'), 10);
67
+ add_action('bbp_theme_anonymous_form_extras_bottom', array($this, 'output_checkbox'), 10);
68
+ add_action('bbp_new_topic', array($this, 'subscribe_from_bbpress_new_topic'), 10, 4);
69
+ add_action('bbp_new_reply', array($this, 'subscribe_from_bbpress_new_reply'), 10, 5);
70
+ }
71
+
72
+ }
73
+
74
+ public function initialize()
75
+ {
76
+ if(function_exists("wpcf7_add_shortcode")) {
77
+ wpcf7_add_shortcode('mc4wp_checkbox', array($this, 'get_checkbox'));
78
+ add_action('wpcf7_mail_sent', array($this, 'subscribe_from_cf7'));
79
+ }
80
+
81
+ // catch-all (for manual integrations with third-party forms)
82
+ if(isset($_POST['mc4wp-try-subscribe']) && $_POST['mc4wp-try-subscribe']) {
83
+ $this->subscribe_from_whatever();
84
+ }
85
+ }
86
+
87
+ public function get_checkbox($args = array())
88
+ {
89
+ $opts = mc4wp_get_options('checkbox');
90
+ $label = isset($args['labels'][0]) ? $args['labels'][0] : $opts['label'];
91
+ $checked = $opts['precheck'] ? "checked" : '';
92
+ $content = "\n<!-- Checkbox by MailChimp for WordPress plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/mailchimp-for-wordpress/ -->\n";
93
+ $content .= '<p id="mc4wp-checkbox">';
94
+ $content .= '<label><input type="checkbox" name="mc4wp-do-subscribe" value="1" '. $checked . ' /> ' . __($label) . '</label>';
95
+ $content .= '</p>';
96
+ $content .= "\n<!-- / MailChimp for WP Plugin -->\n";
97
+ return $content;
98
+ }
99
+
100
+ public function output_checkbox()
101
+ {
102
+ if($this->showed_checkbox) return;
103
+ echo $this->get_checkbox();
104
+ $this->showed_checkbox = true;
105
+ }
106
+
107
+ public function add_stylesheet($stylesheets) {
108
+ $stylesheets['checkbox'] = 1;
109
+ return $stylesheets;
110
+ }
111
+
112
+
113
+ /* Start comment form functions */
114
+ public function subscribe_from_comment($cid, $comment_approved = '')
115
+ {
116
+ if(!isset($_POST['mc4wp-do-subscribe']) || $_POST['mc4wp-do-subscribe'] != 1) { return false; }
117
+ if($comment_approved === 'spam') { return false; }
118
+
119
+ $comment = get_comment($cid);
120
+
121
+ $email = $comment->comment_author_email;
122
+ $merge_vars = array(
123
+ 'OPTINIP' => $comment->comment_author_IP,
124
+ 'NAME' => $comment->comment_author
125
+ );
126
+
127
+ return $this->subscribe($email, $merge_vars);
128
+ }
129
+
130
+ public function add_comment_meta($comment_id)
131
+ {
132
+ add_comment_meta($comment_id, 'mc4wp_subscribe', $_POST['mc4wp-do-subscribe'], true );
133
+ }
134
+ /* End comment form functions */
135
+
136
+ /* Start registration form functions */
137
+ public function subscribe_from_registration($user_id)
138
+ {
139
+ if(!isset($_POST['mc4wp-do-subscribe']) || $_POST['mc4wp-do-subscribe'] != 1) { return false; }
140
+
141
+ // gather emailadress from user who WordPress registered
142
+ $user = get_userdata($user_id);
143
+ if(!$user) { return false; }
144
+
145
+ $email = $user->user_email;
146
+ $merge_vars = array(
147
+ 'NAME' => $user->user_login
148
+ );
149
+
150
+ if(isset($user->user_firstname) && !empty($user->user_firstname)) {
151
+ $merge_vars['FNAME'] = $user->user_firstname;
152
+ }
153
+
154
+ if(isset($user->user_lastname) && !empty($user->user_lastname)) {
155
+ $merge_vars['LNAME'] = $user->user_lastname;
156
+ }
157
+
158
+ $result = $this->subscribe($email, $merge_vars);
159
+ }
160
+ /* End registration form functions */
161
+
162
+ /* Start BuddyPress functions */
163
+ public function subscribe_from_buddypress()
164
+ {
165
+ if(!isset($_POST['mc4wp-do-subscribe']) || $_POST['mc4wp-do-subscribe'] != 1) return;
166
+
167
+ // gather emailadress and name from user who BuddyPress registered
168
+ $email = $_POST['signup_email'];
169
+ $merge_vars = array(
170
+ 'NAME' => $_POST['signup_username']
171
+ );
172
+
173
+ $result = $this->subscribe($email, $merge_vars);
174
+ }
175
+ /* End BuddyPress functions */
176
+
177
+ /* Start Multisite functions */
178
+ public function add_multisite_hidden_checkbox()
179
+ {
180
+ ?><input type="hidden" name="mc4wp-do-subscribe" value="<?php echo (isset($_POST['mc4wp-do-subscribe'])) ? 1 : 0; ?>" /><?php
181
+ }
182
+
183
+ public function on_multisite_blog_signup($blog_id, $user_id, $a, $b ,$meta = null)
184
+ {
185
+ if(!isset($meta['mc4wp-do-subscribe']) || $meta['mc4wp-do-subscribe'] != 1) return false;
186
+
187
+ return $this->subscribe_from_multisite($user_id);
188
+ }
189
+
190
+ public function on_multisite_user_signup($user_id, $password = NULL, $meta = NULL)
191
+ {
192
+ if(!isset($meta['mc4wp-do-subscribe']) || $meta['mc4wp-do-subscribe'] != 1) return false;
193
+
194
+ return $this->subscribe_from_multisite($user_id);
195
+ }
196
+
197
+ public function add_multisite_usermeta($meta)
198
+ {
199
+ $meta['mc4wp-do-subscribe'] = (isset($_POST['mc4wp-do-subscribe'])) ? 1 : 0;
200
+ return $meta;
201
+ }
202
+
203
+ public function subscribe_from_multisite($user_id)
204
+ {
205
+ $user = get_userdata($user_id);
206
+
207
+ if(!is_object($user)) return false;
208
+
209
+ $email = $user->user_email;
210
+ $merge_vars = array(
211
+ 'NAME' => $user->first_name . ' ' . $user->last_name
212
+ );
213
+ $result = $this->subscribe($email, $merge_vars);
214
+ }
215
+ /* End Multisite functions */
216
+
217
+ /* Start Contact Form 7 functions */
218
+ public function subscribe_from_cf7($arg = null)
219
+ {
220
+ if(!isset($_POST['mc4wp-do-subscribe']) || !$_POST['mc4wp-do-subscribe']) { return false; }
221
+
222
+ $_POST['mc4wp-try-subscribe'] = 1;
223
+ unset($_POST['mc4wp-do-subscribe']);
224
+
225
+ return $this->subscribe_from_whatever();
226
+ }
227
+ /* End Contact Form 7 functions */
228
+
229
+ /* Start whatever functions */
230
+ public function subscribe_from_whatever()
231
+ {
232
+ if(!isset($_POST['mc4wp-try-subscribe']) || !$_POST['mc4wp-try-subscribe']) { return false; }
233
+
234
+ // start running..
235
+ $email = null;
236
+ $merge_vars = array(
237
+ 'GROUPINGS' => array()
238
+ );
239
+
240
+ foreach($_POST as $key => $value) {
241
+
242
+ if($key == 'mc4wp-try-subscribe') {
243
+ continue;
244
+ } elseif(strtolower(substr($key, 0, 6)) == 'mc4wp-') {
245
+ // find extra fields which should be sent to MailChimp
246
+ $key = strtoupper(substr($key, 6));
247
+
248
+ if($key == 'EMAIL') {
249
+ $email = $value;
250
+ } elseif($key == 'GROUPINGS' && is_array($value)) {
251
+
252
+ $groupings = $value;
253
+
254
+ foreach($groupings as $grouping_id_or_name => $groups) {
255
+
256
+ $grouping = array();
257
+
258
+ // group ID or group name given?
259
+ if(is_numeric($grouping_id_or_name)) {
260
+ $grouping['id'] = $grouping_id_or_name;
261
+ } else {
262
+ $grouping['name'] = $grouping_id_or_name;
263
+ }
264
+
265
+ // comma separated list should become an array
266
+ if(!is_array($groups)) {
267
+ $grouping['groups'] = explode(',', $groups);
268
+ } else {
269
+ $grouping['groups'] = $groups;
270
+ }
271
+
272
+ // add grouping to array
273
+ $merge_vars['GROUPINGS'][] = $grouping;
274
+
275
+ } // end foreach
276
+
277
+ } elseif(!isset($merge_vars[$key])) {
278
+ // if value is array, convert to comma-delimited string
279
+ if(is_array($value)) { $value = implode(',', $value); }
280
+
281
+ $merge_vars[$key] = $value;
282
+ }
283
+
284
+ } elseif(!$email && is_email($value)) {
285
+ // find first email field
286
+ $email = $value;
287
+
288
+ } else {
289
+ $simple_key = str_replace(array('-', '_'), '', strtolower($key));
290
+
291
+ if(!isset($merge_vars['NAME']) && in_array($simple_key, array('name', 'yourname', 'username', 'fullname'))) {
292
+ // find name field
293
+ $merge_vars['NAME'] = $value;
294
+ } elseif(!isset($merge_vars['FNAME']) && in_array($simple_key, array('firstname', 'fname', "givenname", "forename"))) {
295
+ // find first name field
296
+ $merge_vars['FNAME'] = $value;
297
+ } elseif(!isset($merge_vars['LNAME']) && in_array($simple_key, array('lastname', 'lname', 'surname', 'familyname'))) {
298
+ // find last name field
299
+ $merge_vars['LNAME'] = $value;
300
+ }
301
+ }
302
+ } // end foreach $_POST
303
+
304
+
305
+ // unset groupings if not used
306
+ if(empty($merge_vars['GROUPINGS'])) { unset($merge_vars['GROUPINGS']); }
307
+
308
+ // if email has not been found by the smart field guessing, return false.. sorry
309
+ if(!$email) {
310
+ return false;
311
+ }
312
+
313
+ // subscribe
314
+ $result = $this->subscribe($email, $merge_vars);
315
+ return true;
316
+ }
317
+ /* End whatever functions */
318
+
319
+ public function subscribe_from_bbpress($anonymous_data, $user_id)
320
+ {
321
+ if(!isset($_POST['mc4wp-do-subscribe']) || $_POST['mc4wp-do-subscribe'] != 1) { return; }
322
+
323
+ if($anonymous_data) {
324
+
325
+ $email = $anonymous_data['bbp_anonymous_email'];
326
+ $merge_vars = array(
327
+ 'NAME' => $anonymous_data['bbp_anonymous_name']
328
+ );
329
+
330
+ } elseif($user_id) {
331
+
332
+ $user_info = get_userdata($user_id);
333
+ $email = $user_info->user_email;
334
+ $merge_vars = array(
335
+ 'NAME' => $user_info->first_name . ' ' . $user_info->last_name,
336
+ 'FNAME' => $user_info->first_name,
337
+ 'LNAME' => $user_info->last_name
338
+ );
339
+
340
+ } else {
341
+ return false;
342
+ }
343
+
344
+ return $this->subscribe($email, $merge_vars);
345
+ }
346
+
347
+ public function subscribe_from_bbpress_new_topic($topic_id, $forum_id, $anonymous_data, $topic_author)
348
+ {
349
+ return $this->subscribe_from_bbpress($anonymous_data, $topic_author);
350
+ }
351
+
352
+ public function subscribe_from_bbpress_new_reply($reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author)
353
+ {
354
+ return $this->subscribe_from_bbpress($anonymous_data, $reply_author);
355
+ }
356
+
357
+ public function subscribe($email, array $merge_vars = array())
358
+ {
359
+ $api = mc4wp_get_api();
360
+ $opts = mc4wp_get_options('checkbox');
361
+
362
+ $lists = $opts['lists'];
363
+
364
+ if(!$lists || empty($lists)) {
365
+ if( ( !defined("DOING_AJAX") || !DOING_AJAX ) && current_user_can('manage_options')) {
366
+ wp_die('
367
+ <h3>MailChimp for WP - Error</h3>
368
+ <p>Please select a list to subscribe to in the <a href="'. admin_url('admin.php?page=mc4wp-lite-checkbox-settings') .'">checkbox settings</a>.</p>
369
+ <p style="font-style:italic; font-size:12px;">This message is only visible to administrators for debugging purposes.</p>
370
+ ', "Error - MailChimp for WP", array('back_link' => true));
371
+ }
372
+
373
+ return 'no_lists_selected';
374
+ }
375
+
376
+
377
+ // guess FNAME and LNAME
378
+ if ( isset( $merge_vars['NAME'] ) && !isset( $merge_vars['FNAME'] ) && !isset( $merge_vars['LNAME'] ) ) {
379
+
380
+ $strpos = strpos( $merge_vars['NAME'], ' ' );
381
+
382
+ if ( $strpos ) {
383
+ $merge_vars['FNAME'] = trim( substr( $merge_vars['NAME'], 0, $strpos ) );
384
+ $merge_vars['LNAME'] = trim( substr( $merge_vars['NAME'], $strpos ) );
385
+ } else {
386
+ $merge_vars['FNAME'] = $merge_vars['NAME'];
387
+ }
388
+ }
389
+
390
+ $merge_vars = apply_filters('mc4wp_merge_vars', $merge_vars, '');
391
+ $email_type = apply_filters('mc4wp_email_type', 'html');
392
+ $lists = apply_filters('mc4wp_lists', $lists, $merge_vars);
393
+
394
+ foreach($lists as $list) {
395
+ $result = $api->subscribe($list, $email, $merge_vars, $email_type, $opts['double_optin']);
396
+
397
+ if($result === true) {
398
+ $from_url = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
399
+ do_action( 'mc4wp_subscribe_checkbox', $email, $list, $merge_vars );
400
+ }
401
+ }
402
+
403
+ // check if result succeeded, show debug message to administrators
404
+ if($result !== true && $api->has_error() && current_user_can('manage_options') && !defined("DOING_AJAX"))
405
+ {
406
+ wp_die("
407
+ <h3>MailChimp for WP - Error</h3>
408
+ <p>The MailChimp server returned the following error message as a response to our sign-up request:</p>
409
+ <pre>" . $api->get_error_message() . "</pre>
410
+ <p>This is the data that was sent to MailChimp: </p>
411
+ <strong>Email</strong>
412
+ <pre>{$email}</pre>
413
+ <strong>Merge variables</strong>
414
+ <pre>" . print_r($merge_vars, true) . "</pre>
415
+ <p style=\"font-style:italic; font-size:12px; \">This message is only visible to administrators for debugging purposes.</p>
416
+ ", "Error - MailChimp for WP", array('back_link' => true));
417
+ }
418
+
419
+ return $result;
420
+ }
421
+
422
+
423
+
424
+ }
trunk/includes/class-form.php ADDED
@@ -0,0 +1,383 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MC4WP_Lite_Form {
4
+ private static $instance = null;
5
+ private $form_instance_number = 1;
6
+ private $error = null;
7
+ private $success = false;
8
+ private $submitted_form_instance = 0;
9
+
10
+ public static function init() {
11
+ if(self::$instance) {
12
+ throw new Exception("Already initialized");
13
+ } else {
14
+ self::$instance = new self;
15
+ }
16
+ }
17
+
18
+ public static function instance() {
19
+ return self::$instance;
20
+ }
21
+
22
+ private function __construct() {
23
+
24
+ add_action('init', array($this, 'initialize') );
25
+
26
+ $opts = mc4wp_get_options('form');
27
+
28
+ if($opts['css']) {
29
+ add_filter('mc4wp_stylesheets', array($this, 'add_stylesheets'));
30
+ }
31
+
32
+ add_shortcode( 'mc4wp_form', array( $this, 'output_form' ) );
33
+
34
+ // do not use, just here for backwards compatibility. removed in 2.0.
35
+ add_shortcode( 'mc4wp-form', array( $this, 'output_form' ) );
36
+
37
+ // enable shortcodes in text widgets
38
+ add_filter( 'widget_text', 'shortcode_unautop' );
39
+ add_filter( 'widget_text', 'do_shortcode', 11 );
40
+
41
+ // has a MC4WP form been submitted?
42
+ if ( isset( $_POST['_mc4wp_form_submit'] ) ) {
43
+ $this->ensure_backwards_compatibility();
44
+ add_action( 'init', array( $this, 'submit' ) );
45
+ }
46
+
47
+ }
48
+
49
+ public function initialize()
50
+ {
51
+ // register placeholder script, which will later be enqueued for IE only
52
+ wp_register_script( 'mc4wp-placeholders', plugins_url('mailchimp-for-wp/assets/js/placeholders.min.js'), array(), MC4WP_LITE_VERSION, true );
53
+
54
+ // register non-AJAX script (that handles form submissions)
55
+ wp_register_script( 'mc4wp-forms', plugins_url('mailchimp-for-wp/assets/js/forms.js'), array(), MC4WP_LITE_VERSION, true );
56
+ }
57
+
58
+ public function add_stylesheets($stylesheets) {
59
+ $opts = mc4wp_get_options('form');
60
+
61
+ $stylesheets['form'] = 1;
62
+
63
+ // theme?
64
+ if($opts['css'] != 1 && $opts['css'] != 'default') {
65
+ $stylesheets['form-theme'] = $opts['css'];
66
+ }
67
+
68
+ return $stylesheets;
69
+ }
70
+
71
+ public function output_form( $atts, $content = null ) {
72
+ $opts = mc4wp_get_options('form');
73
+
74
+ if ( !function_exists( 'mc4wp_replace_variables' ) ) {
75
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
76
+ }
77
+
78
+ // add some useful css classes
79
+ $css_classes = ' ';
80
+ if ( $this->error ) $css_classes .= 'mc4wp-form-error ';
81
+ if ( $this->success ) $css_classes .= 'mc4wp-form-success ';
82
+
83
+ $content = "\n<!-- Form by MailChimp for WordPress plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/mailchimp-for-wordpress/ -->\n";
84
+ $content .= '<form method="post" action="'. mc4wp_get_current_url() .'" id="mc4wp-form-'.$this->form_instance_number.'" class="mc4wp-form form'.$css_classes.'">';
85
+
86
+ // maybe hide the form
87
+ if ( !( $this->success && $opts['hide_after_success'] ) ) {
88
+ $form_markup = __( $opts['markup'] );
89
+
90
+ // replace special values
91
+ $form_markup = str_replace( array( '%N%', '{n}' ), $this->form_instance_number, $form_markup );
92
+ $form_markup = mc4wp_replace_variables( $form_markup, array_values( $opts['lists'] ) );
93
+
94
+ // allow plugins to alter form content
95
+ $form_markup = apply_filters('mc4wp_form_content', $form_markup);
96
+
97
+ // allow plugins to add form fields
98
+ do_action('mc4wp_before_form_fields', 0);
99
+
100
+ $content .= $form_markup;
101
+
102
+ // allow plugins to add form fields
103
+ do_action('mc4wp_after_form_fields', 0);
104
+
105
+ // hidden fields
106
+ $content .= '<textarea name="_mc4wp_required_but_not_really" style="display: none;"></textarea>';
107
+ $content .= '<input type="hidden" name="_mc4wp_form_submit" value="1" />';
108
+ $content .= '<input type="hidden" name="_mc4wp_form_instance" value="'. $this->form_instance_number .'" />';
109
+ $content .= '<input type="hidden" name="_mc4wp_form_nonce" value="'. wp_create_nonce( '_mc4wp_form_nonce' ) .'" />';
110
+ }
111
+
112
+ if ( $this->form_instance_number === $this->submitted_form_instance ) {
113
+
114
+ if ( $this->success ) {
115
+ $content .= '<div class="mc4wp-alert mc4wp-success">' . __( $opts['text_success'] ) . '</div>';
116
+ } elseif ( $this->error ) {
117
+
118
+ $api = mc4wp_get_api();
119
+ $e = $this->error;
120
+
121
+ $error_type = ($e == 'already_subscribed') ? 'notice' : 'error';
122
+ $error_message = __($opts['text_' . $e], 'mailchimp-for-wp');
123
+ $content .= '<div class="mc4wp-alert mc4wp-'. $error_type .'">'. $error_message . '</div>';
124
+
125
+ // show the eror returned by MailChimp?
126
+ if ( $api->has_error() && current_user_can( 'manage_options' ) ) {
127
+ $content .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> '. $api->get_error_message() . '</div>';
128
+ }
129
+
130
+ }
131
+ // endif
132
+ }
133
+
134
+ if ( current_user_can( 'manage_options' ) && empty( $opts['lists'] ) ) {
135
+ $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>';
136
+ }
137
+
138
+ $content .= "</form>";
139
+ $content .= "\n<!-- / MailChimp for WP Plugin -->\n";
140
+
141
+ // increase form instance number in case there is more than one form on a page
142
+ $this->form_instance_number++;
143
+
144
+ // make sure scripts are enqueued later
145
+ global $is_IE;
146
+ if(isset($is_IE) && $is_IE) {
147
+ wp_enqueue_script('mc4wp-placeholders');
148
+ }
149
+
150
+ return $content;
151
+ }
152
+
153
+ /**
154
+ * Submits the form
155
+ * Creates a subscribe request from the posted data
156
+ *
157
+ * @return boolean
158
+ */
159
+ public function submit() {
160
+ // store number of submitted form
161
+ $this->submitted_form_instance = absint($_POST['_mc4wp_form_instance']);
162
+
163
+ // validate form nonce
164
+ if ( !isset( $_POST['_mc4wp_form_nonce'] ) || !wp_verify_nonce( $_POST['_mc4wp_form_nonce'], '_mc4wp_form_nonce' ) ) {
165
+ $this->error = 'invalid_nonce';
166
+ return false;
167
+ }
168
+
169
+ // ensure honeypot was not filed
170
+ if ( isset( $_POST['_mc4wp_required_but_not_really'] ) && !empty( $_POST['_mc4wp_required_but_not_really'] ) ) {
171
+ $this->error = 'spam';
172
+ return false;
173
+ }
174
+
175
+ // setup array of data entered by user
176
+ // not manipulating anything yet.
177
+ $data = array();
178
+ foreach($_POST as $name => $value) {
179
+ if($name[0] !== '_') {
180
+ $data[$name] = $value;
181
+ }
182
+ }
183
+
184
+ $success = $this->subscribe($data);
185
+
186
+ // enqueue scripts (in footer)
187
+ wp_enqueue_script( 'mc4wp-forms' );
188
+ wp_localize_script( 'mc4wp-forms', 'mc4wp', array(
189
+ 'success' => ($success) ? 1 : 0,
190
+ 'submittedFormId' => $this->submitted_form_instance,
191
+ 'postData' => $data
192
+ )
193
+ );
194
+
195
+ if ($success) {
196
+
197
+ $opts = mc4wp_get_options('form');
198
+
199
+ // check if we want to redirect the visitor
200
+ if ( !empty( $opts['redirect'] ) ) {
201
+ wp_redirect( $opts['redirect'] );
202
+ exit;
203
+ }
204
+
205
+ return true;
206
+ } else {
207
+
208
+ return false;
209
+ }
210
+ }
211
+
212
+ /*
213
+ Ensure backwards compatibility so sign-up forms that contain old form mark-up rules don't break
214
+ - Uppercase $_POST variables that should be sent to MailChimp
215
+ - Format GROUPINGS in one of the following formats.
216
+ $_POST[GROUPINGS][$group_id] = "Group 1, Group 2"
217
+ $_POST[GROUPINGS][$group_name] = array("Group 1", "Group 2")
218
+ */
219
+ public function ensure_backwards_compatibility() {
220
+
221
+ // detect old style GROUPINGS, then fix it.
222
+ if ( isset( $_POST['GROUPINGS'] ) && is_array( $_POST['GROUPINGS'] ) && isset( $_POST['GROUPINGS'][0] ) ) {
223
+
224
+ $old_groupings = $_POST['GROUPINGS'];
225
+ unset( $_POST['GROUPINGS'] );
226
+ $new_groupings = array();
227
+
228
+ foreach ( $old_groupings as $grouping ) {
229
+
230
+ if(!isset($grouping['groups'])) { continue; }
231
+
232
+ if ( isset( $grouping['id'] ) ) {
233
+ $key = $grouping['id'];
234
+ } else if(isset( $grouping['name'] ) ) {
235
+ $key = $grouping['name'];
236
+ } else {
237
+ continue;
238
+ }
239
+
240
+ $new_groupings[$key] = $grouping['groups'];
241
+
242
+ }
243
+
244
+ // re-fill $_POST array with new groupings
245
+ if ( !empty( $new_groupings ) ) { $_POST['GROUPINGS'] = $new_groupings; }
246
+
247
+ }
248
+
249
+ return;
250
+ }
251
+
252
+ public function subscribe( array $data ) {
253
+
254
+ $email = null;
255
+ $merge_vars = array();
256
+
257
+ foreach ( $data as $name => $value ) {
258
+
259
+ // uppercase all variables
260
+ $name = trim(strtoupper($name));
261
+ $value = (is_scalar($value)) ? trim($value) : $value;
262
+
263
+ if( $name === 'EMAIL' && is_email($value) ) {
264
+ // set the email address
265
+ $email = $value;
266
+ } else if ( $name === 'GROUPINGS' ) {
267
+
268
+ $groupings = $value;
269
+
270
+ // malformed
271
+ if ( !is_array( $groupings ) ) { continue; }
272
+
273
+ // setup groupings array
274
+ $merge_vars['GROUPINGS'] = array();
275
+
276
+ foreach ( $groupings as $grouping_id_or_name => $groups ) {
277
+
278
+ $grouping = array();
279
+
280
+ if ( is_numeric( $grouping_id_or_name ) ) {
281
+ $grouping['id'] = $grouping_id_or_name;
282
+ } else {
283
+ $grouping['name'] = $grouping_id_or_name;
284
+ }
285
+
286
+ if ( !is_array( $groups ) ) {
287
+ $grouping['groups'] = explode( ',', $groups );
288
+ } else {
289
+ $grouping['groups'] = $groups;
290
+ }
291
+
292
+ // add grouping to array
293
+ $merge_vars['GROUPINGS'][] = $grouping;
294
+ }
295
+
296
+ if ( empty( $merge_vars['GROUPINGS'] ) ) { unset( $merge_vars['GROUPINGS'] ); }
297
+
298
+ } else if($name === 'BIRTHDAY') {
299
+ // format birthdays in the DD/MM format required by MailChimp
300
+ $merge_vars['BIRTHDAY'] = date('d/m', strtotime( $value ) );
301
+ } else if($name === 'ADDRESS') {
302
+
303
+ if(!isset($value['addr1'])) {
304
+ // addr1, addr2, city, state, zip, country
305
+ $addr_pieces = explode(',', $value);
306
+
307
+ // try to fill it.... this is a long shot
308
+ $merge_vars['ADDRESS'] = array(
309
+ 'addr1' => $addr_pieces[0],
310
+ 'city' => (isset($addr_pieces[1])) ? $addr_pieces[1] : '',
311
+ 'state' => (isset($addr_pieces[2])) ? $addr_pieces[2] : '',
312
+ 'zip' => (isset($addr_pieces[3])) ? $addr_pieces[3] : ''
313
+ );
314
+
315
+ } else {
316
+ // form contains the necessary fields already: perfection
317
+ $merge_vars['ADDRESS'] = $value;
318
+ }
319
+
320
+ } else {
321
+ // just add to merge vars array
322
+ $merge_vars[$name] = $value;
323
+ }
324
+ }
325
+
326
+ // check if an email address has been found
327
+ if( !$email ) {
328
+ $this->error = 'invalid_email';
329
+ return false;
330
+ }
331
+
332
+ // Try to guess FNAME and LNAME if they are not given, but NAME is
333
+ if(isset($merge_vars['NAME']) && !isset($merge_vars['FNAME']) && !isset($merge_vars['LNAME'])) {
334
+
335
+ $strpos = strpos($merge_vars['NAME'], ' ');
336
+
337
+ if($strpos) {
338
+ $merge_vars['FNAME'] = substr($merge_vars['NAME'], 0, $strpos);
339
+ $merge_vars['LNAME'] = substr($merge_vars['NAME'], $strpos);
340
+ } else {
341
+ $merge_vars['FNAME'] = $merge_vars['NAME'];
342
+ }
343
+ }
344
+
345
+ $api = mc4wp_get_api();
346
+ $opts = mc4wp_get_options('form');
347
+
348
+ $lists = $opts['lists'];
349
+
350
+ if ( empty( $lists ) ) {
351
+ return false;
352
+ }
353
+
354
+ do_action('mc4wp_before_subscribe', $email, $merge_vars, 0);
355
+
356
+ $result = false;
357
+ $email_type = apply_filters('mc4wp_email_type', 'html');
358
+ $lists = apply_filters('mc4wp_lists', $lists, $merge_vars);
359
+
360
+ foreach ( $lists as $list_id ) {
361
+ $list_merge_vars = apply_filters('mc4wp_merge_vars', $merge_vars, 0, $list_id);
362
+ $result = $api->subscribe( $list_id, $email, $list_merge_vars, $email_type, $opts['double_optin'] );
363
+ }
364
+
365
+ do_action('mc4wp_after_subscribe', $email, $merge_vars, 0, $result);
366
+
367
+ // flawed, will only check the result of the last list
368
+ if ( $result === true ) {
369
+
370
+ // do not use... will be removed in 2.0
371
+ $from_url = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
372
+ do_action('mc4wp_subscribe_form', $email, $list_id, 0, $merge_vars, $from_url);
373
+
374
+ $this->success = true;
375
+ } else {
376
+ $this->success = false;
377
+ $this->error = $result;
378
+ }
379
+
380
+ return $this->success;
381
+ }
382
+
383
+ }
trunk/includes/class-plugin.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MC4WP_Lite {
4
+ private static $instance;
5
+
6
+ public static function instance() {
7
+ return self::$instance;
8
+ }
9
+
10
+ public static function init() {
11
+ if(self::$instance) {
12
+ throw new Exception("ALready initialized.");
13
+ } else {
14
+ self::$instance = new self;
15
+ }
16
+ }
17
+
18
+ private function __construct() {
19
+ $this->backwards_compatibility();
20
+
21
+ // checkbox
22
+ require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-checkbox.php';
23
+ MC4WP_Lite_Checkbox::init();
24
+
25
+ // form
26
+ require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-form.php';
27
+ MC4WP_Lite_Form::init();
28
+
29
+ // widget
30
+ add_action( 'widgets_init', array($this, 'register_widget') );
31
+
32
+ if (!is_admin()) {
33
+ // frontend only
34
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
35
+
36
+ // load css
37
+ add_action( 'wp_enqueue_scripts', array($this, 'load_stylesheets'), 90);
38
+ add_action( 'login_enqueue_scripts', array($this, 'load_stylesheets') );
39
+ }
40
+ }
41
+
42
+ private function backwards_compatibility() {
43
+ $options = get_option( 'mc4wp_lite' );
44
+
45
+ // transfer widget to new id?
46
+ if(get_option('mc4wp_transfered_old_widgets', false) == false) {
47
+ $sidebars_widgets = get_option('sidebars_widgets');
48
+
49
+ if($sidebars_widgets && is_array($sidebars_widgets)) {
50
+ foreach($sidebars_widgets as $key => $widgets)
51
+ {
52
+ if(!is_array($widgets)) { continue; }
53
+ foreach($widgets as $subkey => $widget_name) {
54
+
55
+ if(substr($widget_name, 0, 17) == 'mc4wp_lite_widget') {
56
+
57
+ $new_widget_name = str_replace('mc4wp_lite_widget', 'mc4wp_widget', $widget_name);
58
+ // active widget found, just change name?
59
+ $sidebars_widgets[$key][$subkey] = $new_widget_name;
60
+ update_option('sidebars_widgets', $sidebars_widgets);
61
+ update_option('widget_mc4wp_widget', get_option('widget_mc4wp_lite_widget') );
62
+ break;
63
+ }
64
+ }
65
+ }
66
+ }
67
+
68
+ update_option('mc4wp_transfered_old_widgets', true);
69
+ }
70
+
71
+
72
+ // transfer old options to new options format
73
+ if (isset( $options['mailchimp_api_key'] )) {
74
+
75
+ $new_options = array(
76
+ 'general' => array(),
77
+ 'checkbox' => array(),
78
+ 'form' => array()
79
+ );
80
+
81
+ $new_options['general']['api_key'] = $options['mailchimp_api_key'];
82
+
83
+ foreach ( $options as $key => $value ) {
84
+ $_pos = strpos( $key, '_' );
85
+
86
+ $first_key = substr( $key, 0, $_pos );
87
+ $second_key = substr( $key, $_pos + 1 );
88
+
89
+ if ( isset( $new_options[$first_key] ) ) {
90
+
91
+ // change option name
92
+ if ( $second_key == 'show_at_bp_form' ) {
93
+ $second_key = 'show_at_buddypress_form';
94
+ }
95
+
96
+ // change option name
97
+ if ( $second_key == 'show_at_ms_form' ) {
98
+ $second_key = 'show_at_multisite_form';
99
+ }
100
+
101
+ // set value into new option name
102
+ $new_options[$first_key][$second_key] = $value;
103
+ }
104
+
105
+ }
106
+
107
+ update_option( 'mc4wp_lite', $new_options['general'] );
108
+ update_option( 'mc4wp_lite_checkbox', $new_options['checkbox'] );
109
+ update_option( 'mc4wp_lite_form', $new_options['form'] );
110
+ } // end transfer options
111
+ }
112
+
113
+ public function register_widget()
114
+ {
115
+ include_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-widget.php';
116
+ register_widget( 'MC4WP_Lite_Widget' );
117
+ }
118
+
119
+ public function load_stylesheets()
120
+ {
121
+ $stylesheets = apply_filters('mc4wp_stylesheets', array());
122
+
123
+ if(!empty($stylesheets)) {
124
+ $stylesheet_url = add_query_arg($stylesheets, plugins_url('mailchimp-for-wp/assets/css/css.php'));
125
+ wp_enqueue_style( 'mailchimp-for-wp', $stylesheet_url, array(), MC4WP_LITE_VERSION);
126
+ }
127
+ }
128
+
129
+ }
trunk/includes/class-widget.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Adds MC4WP_Widget widget.
5
+ */
6
+ class MC4WP_Lite_Widget extends WP_Widget {
7
+
8
+ /**
9
+ * Register widget with WordPress.
10
+ */
11
+ function __construct() {
12
+ parent::__construct(
13
+ 'MC4WP_Widget', // Base ID
14
+ __( 'MailChimp for WP Form', 'mailchimp-for-wp' ), // Name
15
+ array( 'description' => __( 'Displays your MailChimp for WordPress sign-up form', 'mailchimp-for-wp' ), ) // Args
16
+ );
17
+ }
18
+
19
+ /**
20
+ * Front-end display of widget.
21
+ *
22
+ * @see WP_Widget::widget()
23
+ *
24
+ * @param array $args Widget arguments.
25
+ * @param array $instance Saved values from database.
26
+ */
27
+ public function widget( $args, $instance ) {
28
+ $title = apply_filters( 'widget_title', $instance['title'] );
29
+
30
+ echo $args['before_widget'];
31
+ if ( ! empty( $title ) )
32
+ echo $args['before_title'] . $title . $args['after_title'];
33
+ echo mc4wp_get_form(0);
34
+ echo $args['after_widget'];
35
+ }
36
+
37
+ /**
38
+ * Back-end widget form.
39
+ *
40
+ * @see WP_Widget::form()
41
+ *
42
+ * @param array $instance Previously saved values from database.
43
+ */
44
+ public function form( $instance ) {
45
+ $title = isset($instance['title']) ? $instance['title'] : __('Newsletter', 'mailchimp-for-wp');
46
+ ?>
47
+ <p>
48
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
49
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
50
+ </p>
51
+ <p class="help">
52
+ You can edit your form in the <a href="<?php echo admin_url('admin.php?page=mc4wp-lite-form-settings'); ?>">MailChimp for WP Lite form settings.</a>
53
+ </p>
54
+ <?php
55
+ }
56
+
57
+ /**
58
+ * Sanitize widget form values as they are saved.
59
+ *
60
+ * @see WP_Widget::update()
61
+ *
62
+ * @param array $new_instance Values just sent to be saved.
63
+ * @param array $old_instance Previously saved values from database.
64
+ *
65
+ * @return array Updated safe values to be saved.
66
+ */
67
+ public function update( $new_instance, $old_instance ) {
68
+ $instance = array();
69
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
70
+ return $instance;
71
+ }
72
+
73
+ } // class MC4WP_Widget
trunk/includes/functions.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function mc4wp_get_options($key = null) {
4
+ static $options;
5
+
6
+ if(!$options) {
7
+ $defaults = array(
8
+ 'general' => array(
9
+ 'api_key' => ''
10
+ ),
11
+ 'checkbox' => array(
12
+ 'label' => 'Sign me up for the newsletter!',
13
+ 'precheck' => 1,
14
+ 'css' => 1,
15
+ 'show_at_comment_form' => 0,
16
+ 'show_at_registration_form' => 0,
17
+ 'show_at_multisite_form' => 0,
18
+ 'show_at_buddypress_form' => 0,
19
+ 'show_at_bbpress_forms' => 0,
20
+ 'lists' => array(),
21
+ 'double_optin' => 1
22
+ ),
23
+ 'form' => array(
24
+ 'css' => 'default',
25
+ '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>",
26
+ 'text_success' => 'Thank you, your sign-up request was successful! Please check your e-mail inbox.',
27
+ 'text_error' => 'Oops. Something went wrong. Please try again later.',
28
+ 'text_invalid_email' => 'Please provide a valid email address.',
29
+ 'text_already_subscribed' => "Given email address is already subscribed, thank you!",
30
+ 'redirect' => '',
31
+ 'lists' => array(),
32
+ 'double_optin' => 1,
33
+ 'hide_after_success' => 0
34
+ )
35
+ );
36
+
37
+ $db_keys_option_keys = array(
38
+ 'mc4wp_lite' => 'general',
39
+ 'mc4wp_lite_checkbox' => 'checkbox',
40
+ 'mc4wp_lite_form' => 'form'
41
+ );
42
+
43
+ $options = array();
44
+ foreach ( $db_keys_option_keys as $db_key => $option_key ) {
45
+ $option = get_option( $db_key );
46
+
47
+ // add option to database to prevent query on every pageload
48
+ if ( $option == false ) { add_option( $db_key, $defaults[$option_key] ); }
49
+
50
+ $options[$option_key] = array_merge( $defaults[$option_key], (array) $option );
51
+ }
52
+ }
53
+
54
+ if($key) {
55
+ return $options[$key];
56
+ }
57
+
58
+ return $options;
59
+ }
60
+
61
+ function mc4wp_get_api() {
62
+ static $api;
63
+
64
+ if(!$api) {
65
+ require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-api.php';
66
+ $opts = mc4wp_get_options();
67
+ $api = new MC4WP_Lite_API( $opts['general']['api_key'] );
68
+ }
69
+
70
+ return $api;
71
+ }
trunk/includes/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header('HTTP/1.0 403 Forbidden');
5
+ header("X-Robots-Tag: noindex");
6
+ exit;
trunk/includes/template-functions.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Echoes a sign-up checkbox.
5
+ */
6
+ function mc4wp_checkbox() {
7
+ MC4WP_Lite_Checkbox::instance()->output_checkbox();
8
+ }
9
+
10
+ /**
11
+ * Echoes sign-up form with given $form_id.
12
+ * @param int $form_id.
13
+ */
14
+ function mc4wp_form( $id = 0 ) {
15
+ echo mc4wp_get_form( $id );
16
+ }
17
+
18
+ /**
19
+ * Returns HTML for sign-up form with the given $form_id.
20
+ *
21
+ * @param int $form_id.
22
+ * @return string HTML of given form_id.
23
+ */
24
+ function mc4wp_get_form( $id = 0 ) {
25
+ return MC4WP_Lite_Form::instance()->output_form( array( 'id' => $id ) );
26
+ }
27
+
28
+
29
+ /**
30
+ * Returns text with {variables} replaced.
31
+ *
32
+ * @param string $text
33
+ * @param array $list_ids Array of list id's
34
+ * @return string $text with {variables} replaced.
35
+ */
36
+ function mc4wp_replace_variables( $text, $list_ids = array() ) {
37
+ $needles = array( '{ip}', '{current_url}', '{date}', '{time}' );
38
+ $replacements = array( $_SERVER['REMOTE_ADDR'], mc4wp_get_current_url(), date( "m/d/Y" ), date( "H:i:s" ) );
39
+ $text = str_replace( $needles, $replacements, $text );
40
+
41
+ // subscriber count?
42
+ if ( strstr( $text, '{subscriber_count}' ) != false ) {
43
+ $subscriber_count = mc4wp_get_subscriber_count( $list_ids );
44
+ $text = str_replace( '{subscriber_count}', $subscriber_count, $text );
45
+ }
46
+
47
+ $needles = array( '{user_email}', '{user_firstname}', '{user_lastname}', '{user_name}', '{user_id}' );
48
+ if ( is_user_logged_in() && ( $user = wp_get_current_user() ) && ( $user instanceof WP_User ) ) {
49
+ // logged in user, replace vars by user vars
50
+ $user = wp_get_current_user();
51
+ $replacements = array( $user->user_email, $user->user_firstname, $user->user_lastname, $user->display_name, $user->ID );
52
+ $text = str_replace( $needles, $replacements, $text );
53
+ } else {
54
+ // no logged in user, remove vars
55
+ $text = str_replace( $needles, '', $text );
56
+ }
57
+
58
+ return $text;
59
+ }
60
+
61
+ /**
62
+ * Returns number of subscribers on given lists.
63
+ *
64
+ * @param array $list_ids of list id's.
65
+ * @return int Sum of subscribers for given lists.
66
+ */
67
+ function mc4wp_get_subscriber_count( $list_ids ) {
68
+ $list_counts = get_transient( 'mc4wp_list_counts' );
69
+
70
+ if ( !$list_counts ) {
71
+ // make api call
72
+ $api = mc4wp_get_api();
73
+ $lists = $api->get_lists();
74
+ $list_counts = array();
75
+
76
+ if ( $lists ) {
77
+
78
+ foreach ( $lists as $list ) {
79
+ $list_counts["{$list->id}"] = $list->stats->member_count;
80
+ }
81
+
82
+ $transient_lifetime = apply_filters( 'mc4wp_lists_count_cache_time', 1200 ); // 20 mins by default
83
+
84
+ set_transient( 'mc4wp_list_counts', $list_counts, $transient_lifetime );
85
+ set_transient( 'mc4wp_list_counts_fallback', $list_counts, 3600 * 24 ); // 1 day
86
+ } else {
87
+ // use fallback transient
88
+ $list_counts = get_transient( 'mc4wp_list_counts_fallback' );
89
+ if ( !$list_counts ) { return 0; }
90
+ }
91
+ }
92
+
93
+ // start calculating subscribers count for all list combined
94
+ $count = 0;
95
+ foreach ( $list_ids as $id ) {
96
+ $count += ( isset( $list_counts[$id] ) ) ? $list_counts[$id] : 0;
97
+ }
98
+
99
+ return apply_filters( 'mc4wp_subscriber_count', $count );
100
+ }
101
+
102
+ /**
103
+ * Retrieves the URL of the current WordPress page
104
+ *
105
+ * @return string The current URL, escaped for safe usage inside attributes.
106
+ */
107
+ function mc4wp_get_current_url() {
108
+ $page_url = 'http';
109
+
110
+ if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { $page_url .= 's'; }
111
+
112
+ $page_url .= '://';
113
+
114
+ if (!isset($_SERVER['REQUEST_URI'])) {
115
+ $request_uri = substr($_SERVER['PHP_SELF'], 1);
116
+ if (isset($_SERVER['QUERY_STRING'])) { $request_uri .='?'.$_SERVER['QUERY_STRING']; }
117
+ } else {
118
+ $request_uri = $_SERVER['REQUEST_URI'];
119
+ }
120
+
121
+ $page_url .= $_SERVER["HTTP_HOST"] . $request_uri;
122
+
123
+ return esc_url($page_url);
124
+ }
125
+
126
+
127
+
128
+ /**
129
+ * Echoes a sign-up form.
130
+ *
131
+ * @deprecated 1.3.1 Use mc4wp_form() instead.
132
+ * @see mc4wp_form()
133
+ */
134
+ function mc4wp_show_form( $id = 0 ) {
135
+ mc4wp_form( $id );
136
+ }
137
+
138
+ /**
139
+ * Echoes a sign-up checkbox.
140
+ *
141
+ * @deprecated 1.3.1 Use mc4wp_checkbox() instead
142
+ * @see mc4wp_checkbox()
143
+ */
144
+ function mc4wp_show_checkbox() {
145
+ mc4wp_checkbox();
146
+ }
trunk/includes/views/api-settings.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined("ABSPATH") or exit; ?>
2
+ <div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
3
+
4
+ <h2><img src="<?php echo plugins_url('mailchimp-for-wp/assets/img/menu-icon.png'); ?>" /> MailChimp for WordPress: MailChimp Settings</h2>
5
+
6
+ <div id="mc4wp-content">
7
+
8
+ <?php settings_errors(); ?>
9
+
10
+ <form action="options.php" method="post">
11
+ <?php settings_fields( 'mc4wp_lite_settings' ); ?>
12
+
13
+ <h3 class="mc4wp-title">MailChimp API Settings <?php if($connected) { ?><span class="status positive">CONNECTED</span> <?php } else { ?><span class="status negative">NOT CONNECTED</span><?php } ?></h3>
14
+ <table class="form-table">
15
+
16
+ <tr valign="top">
17
+ <th scope="row"><label for="mailchimp_api_key">MailChimp API Key</label></th>
18
+ <td>
19
+ <input type="text" class="widefat" placeholder="Your MailChimp API key" id="mailchimp_api_key" name="mc4wp_lite[api_key]" value="<?php echo $opts['api_key']; ?>" />
20
+ <p class="help"><a target="_blank" href="http://admin.mailchimp.com/account/api">Click here to get your MailChimp API Key.</a></p>
21
+ </td>
22
+
23
+ </tr>
24
+
25
+ </table>
26
+
27
+ <?php submit_button(); ?>
28
+ </form>
29
+
30
+ <?php if($connected) { ?>
31
+ <h3 class="mc4wp-title">Cached MailChimp Settings</h3>
32
+ <p>The table below shows your cached MailChimp lists configuration.</p>
33
+ <p>Made changes to your lists? Please renew the cache manually by hitting the "renew cached data" button.</p>
34
+
35
+ <table class="wp-list-table widefat">
36
+ <thead>
37
+ <tr>
38
+ <th scope="col">List Name</th>
39
+ <th scope="col">Merge fields</th>
40
+ <th scope="col">Interest groupings</th>
41
+ </tr>
42
+ </thead>
43
+ <tbody>
44
+ <?php
45
+ if($lists && is_array($lists)) { ?>
46
+ <?php foreach($lists as $list) { ?>
47
+ <tr valign="top">
48
+ <td><?php echo $list->name; ?></td>
49
+ <td><?php
50
+ $first = true;
51
+ foreach($list->merge_vars as $merge_var) {
52
+ echo ($first) ? $merge_var->name : ', '. $merge_var->name;
53
+ $first = false;
54
+ }
55
+ ?>
56
+ </td>
57
+ <td class="pro-feature">Pro Only</td>
58
+ </tr>
59
+ <?php } // endforeach ?>
60
+ <?php } else { ?>
61
+ <tr><td colspan="4"><p>No lists found, are you connected to MailChimp? If so, try renewing the cache.</p></td></tr>
62
+ <?php } ?>
63
+ </tbody>
64
+ </table>
65
+
66
+ <p><form method="post"><input type="submit" name="renew-cached-data" value="Renew cached data" class="button" /></form></p>
67
+ <?php } ?>
68
+
69
+ <?php include 'parts/admin-footer.php'; ?>
70
+ </div>
71
+
72
+
73
+
74
+ <div id="mc4wp-sidebar">
75
+ <?php include 'parts/admin-upgrade-to-pro.php'; ?>
76
+ <?php include 'parts/admin-need-support.php'; ?>
77
+ </div>
78
+
79
+ </div>
80
+
trunk/includes/views/checkbox-settings.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined("ABSPATH") or exit; ?>
2
+ <div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
3
+
4
+ <h2><img src="<?php echo plugins_url('mailchimp-for-wp/assets/img/menu-icon.png'); ?>" /> MailChimp for WordPress: Checkbox Settings</h2>
5
+
6
+ <div id="mc4wp-content">
7
+
8
+ <?php settings_errors(); ?>
9
+ <p>To use the MailChimp for WP sign-up checkboxes, select at least one list and one form to add the checkbox to.</p>
10
+
11
+ <h3 class="mc4wp-title">MailChimp settings for checkboxes</h3>
12
+ <form action="options.php" method="post">
13
+ <?php settings_fields( 'mc4wp_lite_checkbox_settings' ); ?>
14
+
15
+ <?php if(empty($opts['lists'])) { ?>
16
+ <div class="mc4wp-info">
17
+ <p>If you want to use sign-up checkboxes, select at least one MailChimp list to subscribe people to.</p>
18
+ </div>
19
+ <?php } ?>
20
+
21
+ <table class="form-table">
22
+ <tr valign="top">
23
+ <th scope="row">Lists</th>
24
+
25
+ <?php // loop through lists
26
+ if(empty($lists))
27
+ {
28
+ ?><td colspan="2">No lists found, are you connected to MailChimp?</td><?php
29
+ }
30
+ else
31
+ { ?>
32
+ <td class="nowrap">
33
+ <?php foreach($lists as $list) {
34
+ ?><label><input type="checkbox" name="mc4wp_lite_checkbox[lists][<?php echo $list->id; ?>]" value="<?php echo esc_attr($list->id); ?>" <?php if(array_key_exists($list->id, $opts['lists'])) echo 'checked="checked"'; ?>> <?php echo $list->name; ?></label><br /><?php
35
+ } ?>
36
+ </td>
37
+ <td class="desc">Select the list(s) to which people who tick the checkbox should be subscribed.</td>
38
+ <?php
39
+ }
40
+ ?>
41
+ </tr>
42
+ <tr valign="top">
43
+ <th scope="row">Double opt-in?</th>
44
+ <td class="nowrap"><label><input type="radio" name="mc4wp_lite_checkbox[double_optin]" value="1" <?php checked($opts['double_optin'], 1); ?> /> Yes</label> &nbsp; <label><input type="radio" id="mc4wp_checkbox_double_optin_0" name="mc4wp_lite_checkbox[double_optin]" value="0" <?php checked($opts['double_optin'], 0); ?> /> No</label></td>
45
+ <td class="desc">Select "yes" if you want subscribers to have to confirm their email address (recommended)</td>
46
+ </tr>
47
+ </table>
48
+
49
+ <h3 class="mc4wp-title">Checkbox settings</h3>
50
+ <table class="form-table">
51
+
52
+ <tr valign="top">
53
+ <th scope="row">Add the checkbox to these forms</th>
54
+ <td colspan="2" class="nowrap">
55
+ <?php foreach($this->get_checkbox_compatible_plugins() as $code => $name) {
56
+
57
+ if($code[0] != '_') {
58
+ ?><label><input name="mc4wp_lite_checkbox[show_at_<?php echo $code; ?>]" value="1" type="checkbox" <?php checked($opts['show_at_'.$code], 1); ?>> <?php echo $name; ?></label><br /><?php
59
+ } else {
60
+ ?><label class="pro-feature"><input type="checkbox" disabled> <?php echo $name; ?></label><br /><?php
61
+ }
62
+ } ?>
63
+ </td>
64
+ </tr>
65
+ <tr valign="top">
66
+ <th scope="row"><label for="mc4wp_checkbox_label">Checkbox label text</label></th>
67
+ <td colspan="2">
68
+ <input type="text" class="widefat" id="mc4wp_checkbox_label" name="mc4wp_lite_checkbox[label]" value="<?php echo esc_attr($opts['label']); ?>" required />
69
+ <p class="help">HTML tags like <code>&lt;strong&gt;</code> and <code>&lt;em&gt;</code> are allowed in the label text.</p>
70
+ </td>
71
+ </tr>
72
+ <tr valign="top">
73
+ <th scope="row">Pre-check the checkbox?</th>
74
+ <td class="nowrap"><label><input type="radio" name="mc4wp_lite_checkbox[precheck]" value="1" <?php checked($opts['precheck'], 1); ?> /> Yes</label> &nbsp; <label><input type="radio" name="mc4wp_lite_checkbox[precheck]" value="0" <?php checked($opts['precheck'], 0); ?> /> No</label></td>
75
+ <td class="desc"></td>
76
+ </tr>
77
+ <tr valign="top">
78
+ <th scope="row">Load some default CSS?</th>
79
+ <td class="nowrap"><label><input type="radio" name="mc4wp_lite_checkbox[css]" value="1" <?php checked($opts['css'], 1); ?> /> Yes</label> &nbsp; <label><input type="radio" name="mc4wp_lite_checkbox[css]" value="0" <?php checked($opts['css'], 0); ?> /> No</label></td>
80
+ <td class="desc">Select "yes" if the checkbox appears in a weird place.</td>
81
+ </tr>
82
+
83
+
84
+ </table>
85
+
86
+ <?php submit_button(); ?>
87
+ </form>
88
+
89
+ <?php include 'parts/admin-footer.php'; ?>
90
+
91
+ </div>
92
+ <div id="mc4wp-sidebar">
93
+ <?php include 'parts/admin-upgrade-to-pro.php'; ?>
94
+ <?php include 'parts/admin-need-support.php'; ?>
95
+ </div>
96
+
97
+
98
+ </div>
trunk/includes/views/form-settings.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined("ABSPATH") or exit; ?>
2
+ <div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
3
+
4
+ <h2><img src="<?php echo plugins_url('mailchimp-for-wp/assets/img/menu-icon.png'); ?>" /> MailChimp for WordPress: Form settings</h2>
5
+
6
+ <div id="mc4wp-content">
7
+
8
+ <?php settings_errors(); ?>
9
+
10
+ <p>To use the MailChimp for WP sign-up form, configure the form below and then paste <input size="10" type="text" onfocus="this.select();" readonly="readonly" value="[mc4wp_form]" class="mc4wp-shortcode-example"> in a post, page or text widget.</p>
11
+
12
+ <form action="options.php" method="post">
13
+ <?php settings_fields( 'mc4wp_lite_form_settings' ); ?>
14
+
15
+ <h3 class="mc4wp-title">Required form settings</h3>
16
+ <table class="form-table">
17
+
18
+ <tr valign="top">
19
+ <th scope="row"><label for="mc4wp_load_stylesheet_select">Load styles or theme?</label></th>
20
+ <td class="nowrap valigntop">
21
+ <select name="mc4wp_lite_form[css]" id="mc4wp_load_stylesheet_select">
22
+ <option value="0" <?php selected($opts['css'], 0); ?>>No</option>
23
+ <option value="default" <?php selected($opts['css'], 'default'); ?><?php selected($opts['css'], 1); ?>>Yes, load basic formatting styles</option>
24
+ <option disabled>(PRO ONLY) Yes, load my custom form styles</option>
25
+ <optgroup label="Load a default form theme">
26
+ <option value="light" <?php selected($opts['css'], 'light'); ?>>Light Theme</option>
27
+ <option value="red" <?php selected($opts['css'], 'red'); ?>>Red Theme</option>
28
+ <option value="green" <?php selected($opts['css'], 'green'); ?>>Green Theme</option>
29
+ <option value="blue" <?php selected($opts['css'], 'blue'); ?>>Blue Theme</option>
30
+ <option value="dark" <?php selected($opts['css'], 'dark'); ?>>Dark Theme</option>
31
+ <option disabled>(PRO ONLY) Custom Color Theme</option>
32
+ </optgroup>
33
+ </select>
34
+ </td>
35
+ <td class="desc">
36
+ If you want to load some default styles, select "basic formatting styles" or one of the default themes.
37
+ </td>
38
+ </tr>
39
+ <tr valign="top">
40
+ <th scope="row">MailChimp list(s)</th>
41
+ <?php // loop through lists
42
+ if(empty($lists)) {
43
+ ?><td colspan="2">No lists found, are you connected to MailChimp?</td><?php
44
+ } else { ?>
45
+ <td>
46
+ <ul id="mc4wp-lists">
47
+ <?php foreach($lists as $list) { ?>
48
+ <li><label><input type="checkbox" name="mc4wp_lite_form[lists][<?php echo esc_attr($list->id); ?>]" value="<?php echo esc_attr($list->id); ?>" data-groupings="<?php echo esc_attr(json_encode($list->interest_groupings)); ?>" data-fields="<?php echo esc_attr(json_encode($list->merge_vars)); ?>" <?php if(array_key_exists($list->id, $opts['lists'])) echo 'checked="checked"'; ?>> <?php echo $list->name; ?></label></li>
49
+ <?php } ?>
50
+ </ul>
51
+ </td>
52
+ <td class="desc">Select the list(s) to which people who submit this form should be subscribed.</td>
53
+ <?php } ?>
54
+
55
+ </tr>
56
+ <tr valign="top">
57
+ <td colspan="3">
58
+ <h4>Form mark-up</h4>
59
+ <div class="mc4wp-wrapper">
60
+ <div class="mc4wp-col mc4wp-first">
61
+ <?php
62
+ if(function_exists('wp_editor')) {
63
+ wp_editor( esc_textarea($opts['markup']), 'mc4wpformmarkup', array('tinymce' => false, 'media_buttons' => false, 'textarea_name' => 'mc4wp_lite_form[markup]'));
64
+ } else {
65
+ ?><textarea class="widefat" cols="160" rows="20" id="mc4wpformmarkup" name="mc4wp_lite_form[markup]"><?php echo esc_textarea($opts['markup']); ?></textarea><?php
66
+ } ?>
67
+ <p class="help">Use the shortcode <input type="text" onfocus="this.select();" readonly="readonly" value="[mc4wp_form]" size="12" class="mc4wp-shortcode-example"> inside a post, page or text widget to display your sign-up form. <strong>Do not copy and paste the above form mark-up, that will not work.</strong></p>
68
+
69
+ </div>
70
+
71
+ <div class="mc4wp-col mc4wp-last">
72
+ <?php include('parts/admin-field-wizard.php'); ?>
73
+ </div>
74
+ </div>
75
+ </td>
76
+ </tr>
77
+
78
+ </table>
79
+
80
+ <?php submit_button(); ?>
81
+
82
+ <h3 class="mc4wp-title">MailChimp Settings</h3>
83
+ <table class="form-table">
84
+ <tr valign="top">
85
+ <th scope="row">Double opt-in?</th>
86
+ <td class="nowrap"><input type="radio" id="mc4wp_form_double_optin_1" name="mc4wp_lite_form[double_optin]" value="1" <?php if($opts['double_optin'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_double_optin_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_form_double_optin_0" name="mc4wp_lite_form[double_optin]" value="0" <?php if($opts['double_optin'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_double_optin_0">No</label></td>
87
+ <td class="desc">Select "yes" if you want subscribers to confirm their email address (recommended)</td>
88
+ </tr>
89
+ <tr class="pro-feature" valign="top">
90
+ <th scope="row">Send Welcome Email?</th>
91
+ <td class="nowrap">
92
+ <input type="radio" readonly />
93
+ <label><?php _e("Yes"); ?></label> &nbsp;
94
+ <input type="radio" checked readonly />
95
+ <label><?php _e("No"); ?></label> &nbsp;
96
+ </td>
97
+ <td class="desc">Select "yes" if you want to send your lists Welcome Email if a subscribe succeeds. Only when double opt-in is disabled.</td>
98
+ </tr>
99
+ <tr class="pro-feature" valign="top">
100
+ <th scope="row">Update existing subscribers?</th>
101
+ <td class="nowrap">
102
+ <input type="radio" readonly />
103
+ <label><?php _e("Yes"); ?></label> &nbsp;
104
+ <input type="radio" checked readonly />
105
+ <label><?php _e("No"); ?></label> &nbsp;
106
+ </td>
107
+ <td class="desc">Select "yes" if you want to update existing subscribers instead of showing the "already subscribed" message.</td>
108
+ </tr>
109
+ <tr class="pro-feature" valign="top">
110
+ <th scope="row">Replace interest groups?</th>
111
+ <td class="nowrap">
112
+ <input type="radio" checked readonly />
113
+ <label><?php _e("Yes"); ?></label> &nbsp;
114
+ <input type="radio" readonly />
115
+ <label><?php _e("No"); ?></label> &nbsp;
116
+ </td>
117
+ <td class="desc">Select "yes" if you want to replace the interest groups with the groups provided instead of adding the provided groups to the member's interest groups. Only when updating a subscriber.</td>
118
+ </tr>
119
+ </table>
120
+
121
+ <h3 class="mc4wp-title">Form Settings & Messages</h3>
122
+
123
+ <table class="form-table mc4wp-form-messages">
124
+ <tr valign="top" class="pro-feature">
125
+ <th scope="row">Enable AJAX?</th>
126
+ <td class="nowrap">
127
+ <input type="radio" readonly /> <label><?php _e("Yes"); ?></label> &nbsp;
128
+ <input type="radio" checked readonly /> <label><?php _e("No"); ?></label>
129
+ </td>
130
+ <td class="desc">Select "yes" if you want to use AJAX to submit forms, meaning the page doesn't need to reload so everything happens inline. <a href="http://dannyvankooten.com/mailchimp-for-wordpress/demo/?utm_source=lite-plugin&utm_medium=link&utm_campaign=settings-demo-link">(demo)</a></td>
131
+ </tr>
132
+ <tr valign="top">
133
+ <th scope="row"><label for="mc4wp_form_hide_after_success">Hide form after a successful sign-up?</label></th>
134
+ <td class="nowrap"><input type="radio" id="mc4wp_form_hide_after_success_1" name="mc4wp_lite_form[hide_after_success]" value="1" <?php if($opts['hide_after_success'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_hide_after_success_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_form_hide_after_success_0" name="mc4wp_lite_form[hide_after_success]" value="0" <?php if($opts['hide_after_success'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_hide_after_success_0">No</label></td>
135
+ <td class="desc">Select "yes" to hide the form fields after a successful sign-up.</td>
136
+ </tr>
137
+ <tr valign="top">
138
+ <th scope="row"><label for="mc4wp_form_redirect">Redirect to this URL after a successful sign-up</label></th>
139
+ <td colspan="2">
140
+ <input type="text" class="widefat" name="mc4wp_lite_form[redirect]" id="mc4wp_form_redirect" placeholder="Example: <?php echo esc_attr(site_url('/thank-you/')); ?>"value="<?php echo $opts['redirect']; ?>" />
141
+ <p class="help">Leave empty or enter <strong>0</strong> (zero) for no redirection. Use complete (absolute) URL's, including <code>http://</code></p>
142
+ </td>
143
+ </tr>
144
+ <tr valign="top">
145
+ <th scope="row"><label for="mc4wp_form_text_success">Success message</label></th>
146
+ <td colspan="2" ><input type="text" class="widefat" id="mc4wp_form_text_success" name="mc4wp_lite_form[text_success]" value="<?php echo esc_attr($opts['text_success']); ?>" required /></td>
147
+ </tr>
148
+ <tr valign="top">
149
+ <th scope="row"><label for="mc4wp_form_text_error">General error message</label></th>
150
+ <td colspan="2" ><input type="text" class="widefat" id="mc4wp_form_text_error" name="mc4wp_lite_form[text_error]" value="<?php echo esc_attr($opts['text_error']); ?>" required /></td>
151
+ </tr>
152
+ <tr valign="top">
153
+ <th scope="row"><label for="mc4wp_form_text_invalid_email">Invalid email address message</label></th>
154
+ <td colspan="2" ><input type="text" class="widefat" id="mc4wp_form_text_invalid_email" name="mc4wp_lite_form[text_invalid_email]" value="<?php echo esc_attr($opts['text_invalid_email']); ?>" required /></td>
155
+ </tr>
156
+ <tr valign="top">
157
+ <th scope="row"><label for="mc4wp_form_text_already_subscribed">Email address is already on list message</label></th>
158
+ <td colspan="2" ><input type="text" class="widefat" id="mc4wp_form_text_already_subscribed" name="mc4wp_lite_form[text_already_subscribed]" value="<?php echo esc_attr($opts['text_already_subscribed']); ?>" required /></td>
159
+ </tr>
160
+ <tr>
161
+ <th></th>
162
+ <td colspan="2"><p class="help">HTML tags like <code>&lt;strong&gt;</code> and <code>&lt;em&gt;</code> are allowed in the message fields.</p></td>
163
+ </tr>
164
+ </table>
165
+
166
+ <?php submit_button(); ?>
167
+ </form>
168
+
169
+ <?php include 'parts/admin-footer.php'; ?>
170
+ </div>
171
+ <div id="mc4wp-sidebar">
172
+ <?php include 'parts/admin-upgrade-to-pro.php'; ?>
173
+
174
+ <div class="mc4wp-box" id="mc4wp-info-tabs">
175
+ <h3 class="mc4wp-title">Building your sign-up form</h3>
176
+ <p>At a minimum, your form should include just an <strong>EMAIL</strong> field and a submit button.</p>
177
+ <p>Add more fields to your form if your list requires more fields. Field names should match your MailChimp list field tags. Use the "Add a new field" tool to have the correct HTML generated for you.</p>
178
+
179
+ <h3 class="mc4wp-title">Form Styling</h3>
180
+ <p>Alter the visual appearance of the form by applying CSS rules to <b>.mc4wp-form</b> and its child elements.</p>
181
+ <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>
182
+
183
+ <p>The <a href="http://wordpress.org/plugins/mailchimp-for-wp/faq/" target="_blank">FAQ</a> lists the various CSS selectors you can use to target the different elements.</p>
184
+
185
+ <h3 class="mc4wp-title">Form variables</h3>
186
+ <p>Use the following variables to add some dynamic content to your form.</p>
187
+
188
+ <table class="mc4wp-help">
189
+ <tr>
190
+ <th>{subscriber_count}</th>
191
+ <td>Replaced with the number of subscribers on the selected list(s).</td>
192
+ </tr>
193
+ <tr>
194
+ <th>{ip}</th>
195
+ <td>Replaced with the visitor's IP address.</td>
196
+ </tr>
197
+ <tr>
198
+ <th>{date}</th>
199
+ <td>Replaced with the current date (yyyy/mm/dd eg: <?php echo date("Y/m/d"); ?>)</td>
200
+ </tr>
201
+ <tr>
202
+ <th>{time}</th>
203
+ <td>Replaced with the current time (hh:mm:ss eg: <?php echo date("H:i:s"); ?>)</td>
204
+ </tr>
205
+ <tr>
206
+ <th>{user_email}</th>
207
+ <td>Replaced with the logged in user's email (or nothing, if there is no logged in user).</td>
208
+ </tr>
209
+ <tr>
210
+ <th>{user_name}</th>
211
+ <td>Display name of the current user</td>
212
+ </tr>
213
+ <tr>
214
+ <th>{user_firstname}</th>
215
+ <td>First name of the current user</td>
216
+ </tr>
217
+ <tr>
218
+ <th>{user_lastname}</th>
219
+ <td>Last name of the current user</td>
220
+ </tr>
221
+ <tr>
222
+ <th>{user_id}</th>
223
+ <td>Current user ID</td>
224
+ </tr>
225
+ <tr>
226
+ <th>{current_url}</th>
227
+ <td>Current URL</td>
228
+ </tr>
229
+ </table>
230
+ </div>
231
+
232
+ <?php include 'parts/admin-need-support.php'; ?>
233
+ </div>
234
+ </div>
trunk/includes/views/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header('HTTP/1.0 403 Forbidden');
5
+ header("X-Robots-Tag: noindex");
6
+ exit;
trunk/includes/views/parts/admin-field-wizard.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined("ABSPATH") or exit; ?>
2
+ <div id="mc4wp-fw" class="mc4wp-well">
3
+
4
+ <h4 class="mc4wp-title">Add a new field</h4>
5
+
6
+
7
+ <p class="mc4wp-notice no-lists-selected" <?php if(!empty($opts['lists'])) { ?>style="display: none;" <?php } ?>>Select at least one list first.</p>
8
+
9
+ <p>Use the tool below to generate the HTML for your form fields.</p>
10
+ <p>
11
+ <select class="widefat" id="mc4wp-fw-mailchimp-fields">
12
+ <option class="default" value="" disabled selected>Select MailChimp field..</option>
13
+ <optgroup label="MailChimp merge fields" class="merge-fields"></optgroup>
14
+ <optgroup label="Interest groupings" class="groupings"></optgroup>
15
+ <optgroup label="Other" class="other">
16
+ <option class="default" value="submit">Submit button</option>
17
+ </optgroup>
18
+ </select>
19
+ </p>
20
+
21
+ <div id="mc4wp-fw-fields">
22
+
23
+ <p class="row label">
24
+ <label for="mc4wp-fw-label">Label <small>(optional)</small></label>
25
+ <input class="widefat" type="text" id="mc4wp-fw-label" />
26
+ </p>
27
+
28
+ <p class="row placeholder">
29
+ <label for="mc4wp-fw-placeholder">Placeholder <small>(optional)</small></label>
30
+ <input class="widefat" type="text" id="mc4wp-fw-placeholder" />
31
+ </p>
32
+
33
+ <p class="row value">
34
+ <label for="mc4wp-fw-value"><span id="mc4wp-fw-value-label">Initial value <small>(optional)</small></span></label>
35
+ <input class="widefat" type="text" id="mc4wp-fw-value" />
36
+ </p>
37
+
38
+ <p class="row values" id="mc4wp-fw-values">
39
+ <label for="mc4wp-fw-values">Value labels <small>(leave empty to hide)</small></label>
40
+ </p>
41
+
42
+ <p class="row wrap-p">
43
+ <input type="checkbox" id="mc4wp-fw-wrap-p" value="1" checked />
44
+ <label for="mc4wp-fw-wrap-p">Wrap in paragraph (<code>&lt;p&gt;</code>) tags?</label>
45
+ </p>
46
+
47
+ <p class="row required">
48
+ <input type="checkbox" id="mc4wp-fw-required" value="1" />
49
+ <label for="mc4wp-fw-required">Required field?</label>
50
+ </p>
51
+
52
+ <p>
53
+ <input class="button button-large" type="button" id="mc4wp-fw-add-to-form" value="&laquo; add to form" />
54
+ </p>
55
+
56
+ <p>
57
+ <label for="mc4wp-fw-preview">Generated HTML</label>
58
+ <textarea class="widefat" id="mc4wp-fw-preview" rows="5"></textarea>
59
+ </p>
60
+
61
+ </div>
62
+ </div>
trunk/includes/views/parts/admin-footer.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php defined("ABSPATH") or exit; ?>
2
+ <br style="clear:both;" />
3
+ <p class="help">Enjoying this plugin? <a href="http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=footer-link">Upgrade to MailChimp for WordPress Pro now</a> for an even better plugin, you will love it.</p>
4
+ <p class="help">Submit your feature requests or vote for new features <a href="http://www.google.com/moderator/#15/e=20c6b7&t=20c6b7.40">here</a>.</p>
5
+ <p class="help">This plugin is not developed by or affiliated with MailChimp in any way.</p>
trunk/includes/views/parts/admin-need-support.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined("ABSPATH") or exit; ?>
2
+ <div class="mc4wp-box">
3
+ <h4 class="mc4wp-title">Looking for support?</h4>
4
+ <p>Use the <a href="http://wordpress.org/support/plugin/mailchimp-for-wp">support forums</a> on WordPress.org.</p>
5
+ <p>If you need priority support, please <a href="http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=support-link">upgrade to the premium version</a>.</p>
6
+ </div>
7
+
8
+ <div class="mc4wp-box">
9
+ <h4 class="mc4wp-title">Show a token of your appreciation</h4>
10
+ <ul class="ul-square">
11
+ <li><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform">Leave a review on WordPress.org</a></li>
12
+ <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>
13
+ <li>Review the plugin on your blog and link to <a href="http://dannyvankooten.com/mailchimp-for-wordpress/">the plugin page</a></li>
14
+ <li><a target="_blank" href="http://wordpress.org/plugins/mailchimp-for-wp/">Vote "works" on the WordPress.org plugin page</a></li>
15
+ </ul>
16
+ </div>
17
+ <div class="mc4wp-box">
18
+ <h4 class="mc4wp-title">About the developer</h4>
19
+ <p>My name is <a href="http://dannyvankooten.com/">Danny van Kooten</a>. I develop WordPress plugins which help you build your websites. I love simplicity, happy customers and clean code.</p>
20
+ <p>Take a look at my other <a href="http://dannyvankooten.com/wordpress-plugins/">plugins for WordPress</a> or <em>like</em> my Facebook page to stay updated.</p>
21
+ <p><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2FCodeToTheChase&amp;width&amp;layout=standard&amp;action=like&amp;show_faces=true&amp;share=false&amp;appId=225994527565061" scrolling="no" frameborder="0" style="border:none; width: 100%; overflow:hidden; height: 80px;" allowTransparency="true"></iframe></p>
22
+ <p>You can also follow me on twitter <a href="http://twitter.com/dannyvankooten">here</a>.</p>
23
+ </div>
trunk/includes/views/parts/admin-upgrade-to-pro.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php defined("ABSPATH") or exit; ?>
2
+ <div class="mc4wp-box" id="mc4wp-upgrade-box">
3
+ <h3>MailChimp for WordPress Pro</h3>
4
+
5
+ <p><em>This plugin has an even better premium version, I am sure you will love it.</em></p>
6
+
7
+ <p>Pro features include better and multiple forms, advanced and easy form styling, more default themes, detailed statistics and priority support.</p>
8
+
9
+ <p><a href="http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=upgrade-box">More information about MailChimp for WP Pro &raquo;</a></p>
10
+ </div>
trunk/includes/views/parts/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header('HTTP/1.0 403 Forbidden');
5
+ header("X-Robots-Tag: noindex");
6
+ exit;
trunk/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ // prevent directory listing
3
+
4
+ header( 'HTTP/1.0 403 Forbidden' );
5
+ header( 'X-Robots-Tag: noindex' );
6
+ exit;
trunk/license.txt ADDED
@@ -0,0 +1,621 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
trunk/mailchimp-for-wp.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: MailChimp for WordPress Lite
4
+ Plugin URI: http://dannyvankooten.com/mailchimp-for-wordpress/
5
+ Description: Lite version of MailChimp for WordPress. Adds various sign-up methods to your website.
6
+ Version: 1.5.1
7
+ Author: Danny van Kooten
8
+ Author URI: http://dannyvanKooten.com
9
+ License: GPL v3
10
+
11
+ MailChimp for WordPress
12
+ Copyright (C) 2012-2013, Danny van Kooten, hi@dannyvankooten.com
13
+
14
+ This program is free software: you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation, either version 3 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ 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
+ if( !defined( 'ABSPATH' ) ) {
29
+ header( 'HTTP/1.0 403 Forbidden' );
30
+ header( 'X-Robots-Tag: noindex' );
31
+ exit;
32
+ }
33
+
34
+ if(!function_exists('is_plugin_active')) {
35
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
36
+ }
37
+
38
+ // only load lite version if Pro is not active or being activated
39
+ if(!is_plugin_active('mailchimp-for-wp-pro/mailchimp-for-wp-pro.php')
40
+ && !(is_admin() && isset($_GET['action']) && $_GET['action'] == 'activate' && isset($_GET['plugin']) && $_GET['plugin'] == 'mailchimp-for-wp-pro/mailchimp-for-wp-pro.php') ) {
41
+
42
+ define("MC4WP_LITE_VERSION", "1.5.1");
43
+ define("MC4WP_LITE_PLUGIN_DIR", plugin_dir_path(__FILE__));
44
+
45
+ require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions.php';
46
+ require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-plugin.php';
47
+ MC4WP_Lite::init();
48
+
49
+ if(is_admin() && (!defined("DOING_AJAX") || !DOING_AJAX)) {
50
+
51
+ // ADMIN
52
+ require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-admin.php';
53
+ MC4WP_Lite_Admin::init();
54
+
55
+ }
56
+
57
+ }
trunk/readme.txt ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === MailChimp for WordPress ===
2
+ Contributors: DvanKooten
3
+ Donate link: http://dannyvankooten.com/donate/
4
+ Tags: mailchimp,form,shortcode,widget,checkbox,comment,newsletter,buddypress,multisite,bbpress,woocommerce,easy digital downloads,contact form,contact form 7
5
+ Requires at least: 3.1
6
+ Tested up to: 3.8
7
+ Stable tag: 1.5.1
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ The best MailChimp plugin to get more email subscribers. Easily add sign-up forms and sign-up checkboxes to your WordPress website.
12
+
13
+ == Description ==
14
+
15
+ = MailChimp for WordPress =
16
+
17
+ *Adding sign-up methods for your MailChimp lists to your WordPress site should be easy. With this plugin, it is.*
18
+
19
+ MailChimp for WordPress lets you create a highly customizable sign-up form which you can display wherever you want it to display using a simple shortcode, widget or template function. You can also add sign-up checkboxes to various forms on your site, like your comment or contact forms.
20
+
21
+ = Sign-Up Forms =
22
+ Easily create sign-up forms for your MailChimp list and display it using a simple shortcode, widget or template function.
23
+
24
+ = Sign-Up Checkboxes =
25
+ Add sign-up checkboxes to *any* form on your website. The plugin offers built-in integration with comment forms, registration forms, Contact Form 7, BuddyPress, bbPress and WordPress MultiSite.
26
+
27
+ **MailChimp for WordPress, at a glance..**
28
+
29
+ - Simple. All you need is your MailChimp API key.
30
+ - Customizable. Have the form fields generated for you or write your own HTML.
31
+ - Beautiful. Choose one of the default form themes or write your own CSS.
32
+ - Developer friendly.
33
+
34
+ [Installation](http://wordpress.org/plugins/mailchimp-for-wp/installation/) | [Frequently Asked Questions](http://wordpress.org/plugins/mailchimp-for-wp/faq/) | [Screenshots](http://wordpress.org/plugins/mailchimp-for-wp/screenshots/)
35
+
36
+ > **Premium features**
37
+ >
38
+ > Multiple forms, AJAX, form designer, custom themes, detailed statistics, more built-in checkbox integrations and priority support.
39
+ >
40
+ > [More information](http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=after-features-link) | [Form demo's](http://dannyvankooten.com/mailchimp-for-wordpress/demo/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=after-features-link) | [Upgrade now >>](http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=after-features-link)
41
+
42
+ **More information**
43
+
44
+ Take a look at some other [WordPress plugins](http://dannyvankooten.com/wordpress-plugins/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=more-info-link) by [Danny van Kooten](http://dannyvankooten.com?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=more-info-link) or contact him on Twitter: [@DannyvanKooten](http://twitter.com/dannyvankooten).
45
+
46
+
47
+ == Installation ==
48
+
49
+ = Installing the plugin =
50
+ 1. In your WordPress admin panel, go to *Plugins > New Plugin*, search for *MailChimp for WordPress* and click "Install now"
51
+ 1. Alternatively, download the plugin and upload the contents of `mailchimp-for-wp.zip` to your plugins directory, which usually is `/wp-content/plugins/`.
52
+ 1. Activate the plugin
53
+ 1. Set your MailChimp API key in the plugin settings.
54
+
55
+ = Configuring Sign-Up Checkboxes =
56
+ 1. Go to *MailChimp for WP > Checkboxes*
57
+ 1. Select at least one list to subscribe visitors to.
58
+ 1. Select at least 1 form to add the checkbox to, eg your comment form.
59
+
60
+ = Configuring Sign-Up Form(s) =
61
+ 1. Go to *MailChimp for WP > Forms*
62
+ 1. Select at least one list to subscribe visitors to.
63
+ 1. *(Optional)* Add more fields or dynamic content to your form using the **add field** tool.
64
+ 1. Show the form in pages or posts by using the `[mc4wp_form]` shortcode.
65
+ 1. Show the form in your widget areas using the plugin widget.
66
+ 1. Show the form from your template files by calling `mc4wp_form()`
67
+
68
+ Need help? Please take a look at the [frequently asked questions](http://wordpress.org/plugins/mailchimp-for-wp/faq/) first
69
+
70
+ = Upgrade to Pro =
71
+ If you like the plugin, upgrade to [MailChimp for WordPress Pro](http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=installation-instructions-link) for an even better plugin.
72
+
73
+ == Frequently Asked Questions ==
74
+
75
+ > **Is there a premium version of this plugin?**
76
+ >
77
+ > Yes, you will love it. Some Pro features are:
78
+ >
79
+ > 1. Multiple forms, each subscribing to one or multiple MailChimp list(s).
80
+ > 1. AJAX - no page reload after submitting a sign-up form.
81
+ > 1. Custom color themes and a custom form styles designer.
82
+ > 1. Statistics & log, learn when, where and how your visitors subscribed.
83
+ >
84
+ > [More Pro features](http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=faq-link) | [Demo](http://dannyvankooten.com/mailchimp-for-wordpress/demo/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=faq-link)
85
+
86
+ = How to display a form in posts or pages? =
87
+ Use the `[mc4wp_form]` shortcode.
88
+
89
+ = How to display a form in widget areas like a sidebar? =
90
+ Use the **MailChimp for WP Form** Widget that comes with the plugin.
91
+
92
+ = How to display a form in my template files? =
93
+ Use the `mc4wp_form()` function.
94
+
95
+ `
96
+ if( function_exists( 'mc4wp_form' ) ) {
97
+ mc4wp_form();
98
+ }
99
+ `
100
+
101
+ = Oops. Something went wrong. =
102
+ `Admin notice: FNAME must be provided - Please enter a value`
103
+
104
+ Your selected MailChimp list requires a field named **FNAME**. Either go into your MailChimp list settings and make the FNAME field optional or add it to your form (using the *Add MailChimp field** select box).
105
+
106
+ = The form shows a success message but subscribers are not added to my list(s)? =
107
+ If the form shows a success message, it means MailChimp accepted the sign-up request and will take over from there. MailChimp could have a slight delay sending the confirmation email though, just be patient.
108
+
109
+ = How can I style the sign-up form? =
110
+ You can use CSS rules to style the sign-up form, use the following CSS selectors to target the various form elements.
111
+
112
+ `
113
+ .mc4wp-form { ... } /* the form element */
114
+ .mc4wp-form p { ... } /* form paragraphs */
115
+ .mc4wp-form label { ... } /* labels */
116
+ .mc4wp-form input { ... } /* input fields */
117
+ .mc4wp-form input[type="checkbox"] { ... } /* checkboxes */
118
+ .mc4wp-form input[type="submit"] { ... } /* submit button */
119
+ .mc4wp-alert { ... } /* success & error messages */
120
+ .mc4wp-success { ... } /* success message */
121
+ .mc4wp-error { ... } /* error messages */
122
+ `
123
+
124
+ 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.
125
+
126
+ [PS: With the Pro version, you can design beautiful forms without touching any code >>](http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=wp-plugin-repo&utm_medium=link&utm_campaign=after-css-link)
127
+
128
+ = Where can I find my MailChimp API key? =
129
+ [Here](http://kb.mailchimp.com/article/where-can-i-find-my-api-key)
130
+
131
+ = How to add a sign-up checkbox to my Contact Form 7 forms? =
132
+ Use the following shortcode in your CF7 form mark-up to display a sign-up checkbox.
133
+
134
+ `[mc4wp_checkbox "My custom label text"]`
135
+
136
+ If you need more data for your merge fields, prefix the field name with `mc4wp-`.
137
+
138
+ *Example CF7 template for MailChimp WEBSITE field*
139
+ `
140
+ [text* mc4wp-WEBSITE]
141
+ `
142
+
143
+ = Can I add a checkbox to third-party forms? =
144
+ Yes. Go to *MailChimp for WP > Checkboxes* and tick the "show checkbox at other forms (manual)" checkbox. Then, include a checkbox with name attribute `mc4wp-try-subscribe` and value `1` in your form.
145
+
146
+ *Example HTML*
147
+ `
148
+ <label><input type="checkbox" name="mc4wp-try-subscribe" value="1" /> Subscribe to our newsletter?</label>
149
+ `
150
+
151
+ If you need to send more data to your MailChimp list, prefix the name attribute with `mc4wp-`.
152
+
153
+ *Example HTML code for MailChimp list field called WEBSITE*
154
+ `
155
+ <label>Your website:</label>
156
+ <input type="text" name="mc4wp-WEBSITE" />
157
+ `
158
+
159
+ = How do I add subscribers to certain interest groups? =
160
+ Use the field wizard. Or, if you know more about HTML, the following snippet should get you started. *Replace `###` with your grouping ID or grouping name.*
161
+
162
+ `
163
+ <label><input type="checkbox" name="GROUPINGS[###][]" value="Group 1" /> Group 1</label>
164
+ <label><input type="checkbox" name="GROUPINGS[###][]" value="Group 2" /> Group 2</label>
165
+ `
166
+ Or, if you want to use a hidden field...
167
+
168
+ `
169
+ <input type="hidden" name="GROUPINGS[###]" value="Groupname 1,Groupname 2,Groupname 3" />
170
+ `
171
+
172
+ = I don't see new subscribers but they are still added to my list =
173
+ When you have double opt-in disabled, new subscribers will be seen as *imports* by MailChimp. They will not show up in your daily digest emails or statistics. My recommendation is to leave double opt-in enabled.
174
+
175
+ = Can I add more (hidden) fields to the sign-up checkbox? =
176
+ Not at the moment, but you can add more data using a filter. Here is a code snippet to [add grouping information to comment form sign-ups](https://gist.github.com/dannyvankooten/7120559).
177
+
178
+ = Why does the checkbox not show up at my comment form? =
179
+ Your theme probably does not support the necessary comment hook this plugin uses to add the checkbox to your comment form. You can manually place the checkbox by placing the following code snippet inside the form tags of your theme's comment form.
180
+
181
+ `<?php if(function_exists('mc4wp_checkbox')) { mc4wp_checkbox(); }?>`
182
+
183
+ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-name/`.
184
+
185
+ == Screenshots ==
186
+
187
+ 1. Simple or advanced sign-up forms that blend in with your theme.
188
+ 2. A sign-up checkbox in your comment form is an amazing conversion booster.
189
+ 3. A simple form in the footer of the Twenty Thirteen theme.
190
+ 4. Add sign-up checkboxes to various places on your site. Easy-peasy.
191
+ 5. Creating sign-up forms is easy. The Pro version allows you to create as many form as you like.
192
+ 6. Write your own HTML or have it generated for you. Many (optional) customization settings are availabl.
193
+ 7. **Pro only:** Gain valuable insights which method your visitors used to subscribe for any given time period using beautiful line charts.
194
+ 8. **Pro only:** Create your own CSS styles with the form designer in the Pro version.
195
+
196
+
197
+ == Changelog ==
198
+
199
+ = 1.5.1 - January 5, 2013 =
200
+ * Fixed: Having to submit form twice for some www-hosts.
201
+ * Improved: Scroll to form now waits until page has completely loaded
202
+
203
+ = 1.5 - December 18, 2013 =
204
+ * Added: BIRTHDAY fields will now be formatted in the DD/MM format automatically
205
+ * Added: The plugin will now try to automatically format ADDRESS fields.
206
+ * Added: Form fields will now keep their value when a validation error occurs
207
+ * Improved: Cache headers for CSS file
208
+ * Improved: Added notice when no lists selected and using sign-up checkboxes
209
+ * Improved: Various code improvements
210
+ * Fixed: Error when activating Pro with the Lite plugin still activated.
211
+ * Fixed: BuddyPress & MultiSite checkbox not automatically added
212
+
213
+ = 1.4.8 - December 10, 2013 =
214
+ * Fixed: "bug" that fetched lists again on every plugin settings page - huge performance improvements on the settings pages.
215
+ * Improved: Longer cache time for combined CSS file.
216
+ * Improved: Prevented indexing of plugin directories
217
+ * Improved: Improved default checkbox CSS for themes that have custom checkbox styling.
218
+ * Improved: Better scroll to form element after form submit. Vertically centers form element with and without jQuery now. No ugly page jump.
219
+ * Improved: WP 3.8 Admin CSS compatibility and other improvements to settings pages, especially for small(er) screens.
220
+
221
+ = 1.4.7 - December 4, 2013 =
222
+ * Fixed: Checkbox width not being reset when loading default CSS.
223
+ * Improved: Minor security improvement to prevent some plugin files from being accessed directly.
224
+
225
+ = 1.4.6 - November 27, 2013 =
226
+ * Fixed: Incorrect invalid email address notice showing up every time.
227
+ * Fixed: Incorrect form action url for some servers.
228
+
229
+ = 1.4.4 - November 26, 2013 =
230
+ * Fixed: FNAME and LNAME not being guessed from NAME for form sign-ups.
231
+ * Added: very small JavaScript fallback for placeholders in older browsers (<= IE9)
232
+ * Improved: removed limit from the lists retreived from MailChimp, for users with more than 25 lists.
233
+ * Improved: added current page URL to form action attribute for people using `<base>` url's.
234
+ * Improved: removed the sidebar from the admin pages on small screens
235
+ * Improved: various usability improvements
236
+ * Improved: minor improvements to default CSS styles
237
+ * Improved: added various action and filter hooks to the form sign-up process
238
+
239
+ = 1.4.3 - November 19, 2013 =
240
+ * Improved: added filter hook `mc4wp_lists` to customize lists before sending request to MailChimp.
241
+ * Improved: added empty `index.php` files to directories to prevent directory listings
242
+
243
+ = 1.4.2 - November 11, 2013 =
244
+ * Improved: Minor textual improvements in settings pages
245
+ * Improved: Security improvement, plugin file can't be access directly anymore
246
+ * Added: GPL license to plugin files
247
+
248
+ = 1.4.1 - October 29, 2013 =
249
+ * Fixed: Grouping data not being sent to MailChimp when using sign-up forms.
250
+
251
+ = 1.4 - October 28, 2013 =
252
+ * Added: default form CSS themes, choose between light, red, green, blue or dark form styling.
253
+ * Added: filter to add more variables to Checkbox Sign-Ups.
254
+ * Improved: more fields unlocked in "add field" tool when editing forms.
255
+ * Improved: smarter auto-detection of name fields when integrating with third-party forms like Contact Form 7
256
+ * Changed: links point to new [MailChimp for WordPress](http://dannyvankooten.com/mailchimp-for-wordpress/) page now.
257
+
258
+ = 1.3.1 - October 20, 2013 =
259
+ * Fixed: bug when calling MailChimp API for PHP 5.2
260
+ * Improved: better default form CSS
261
+ * Improved: Combined checkbox and form stylesheets into 1 file and encouraged browser caching.
262
+
263
+ = 1.3 - October 13, 2013 =
264
+ * Added: Form widget
265
+ * Added: Smooth scroll to form element after form submission (if jQuery loaded)
266
+ * Improved: Added and removed some buttons from QTags editor toolbar
267
+ * Improved: Some UI improvements
268
+ * Improved: Optimized integration with third-party forms like Contact Form 7
269
+
270
+ = 1.2.5 - October 8, 2013 =
271
+ * Fixed `undefined function mc4wp_replace_variables` fatal error when using Quick Cache plugin.
272
+
273
+ = 1.2.4 - October 6, 2013 =
274
+ * Improved: code performance improvements
275
+ * 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/).
276
+ * Improved default CSS
277
+ * Improved: checkbox debug message only shows to WP Administrators when JavaScript is disabled
278
+ * Added: form nonce for better security
279
+ * Fix: CSS issue where the form caused a huge sidebar gap in some themes.
280
+
281
+ = 1.2.3 - October 3, 2013 =
282
+ * Fixed: bug where some MailChimp fields were not showing in the field wizard / add field tool.
283
+
284
+ = 1.2.2 - September 30, 2013 =
285
+ * Fixed sending extra list fields when integrating with third-party forms like Contact Form 7
286
+
287
+ = 1.2.1 - September 29, 2013 =
288
+ * Improved: total revamp of the form field wizard, many improvements.
289
+ * Improved: some textual improvements in the setting pages
290
+ * Added: debug message to sign-up checkbox for WP administrators
291
+
292
+ = 1.2 - September 23, 2013 =
293
+ * Improved: updated to MailChimp 2.0 API
294
+ * Improved: now using custom light-weight API class using the WordPress HTTP API.
295
+ * Improved: huge performance improvements on admin settings pages
296
+ * Improved: usability and responsiveness of form settings page
297
+ * Improved: clean-up
298
+
299
+ = 1.1.4 =
300
+ * Fixed: usage of textarea elements in the form mark-up for WP3.3+.
301
+
302
+ = 1.1.3 =
303
+ * Added: first and lastname to registration hook, works with Register Redux Plus for example.
304
+
305
+ = 1.1.2 =
306
+ * Fixed: field wizard initial value not being set in some browsers
307
+ * Fixed: CF7 checkbox subscribing everyone regardless of checkbox setting
308
+ * Added: bbPress compatibility, you can now add a sign-up checkbox to the new topic and new reply forms
309
+ * Improved: various code and debug improvements
310
+ * Improved: field wizard now wraps radio inputs and checkboxes in a label
311
+ * Improved: Usability when using sign-up checkbox with Contact Form 7
312
+ * Removed: form usage option
313
+
314
+ = 1.1.1 =
315
+ * Fixed warning for BuddyPress sites
316
+
317
+ = 1.1 =
318
+ * Fixed: spam comments not being filtered
319
+ * Fixed: Automatic splitting of NAME into FNAME and LNAME
320
+ * Added: HTML 5 url, tel and date fields to field wizard
321
+ * Added: Form variables for usage inside form mark-up.
322
+ * Improved: default form CSS
323
+ * Improved: Contact Form 7 integration
324
+
325
+ = 1.0.3 =
326
+ * Added HTML quicktags to form markup textarea.
327
+ * Added option to set custom label when using Contact Form 7 shortcode `[mc4wp_checkbox "Your checkbox label"]`
328
+ * Added HTML comments
329
+ * Added upgrade link to plugins overview
330
+ * Improved compatibility with third-party plugins when using checkbox, smarter e-mail field guessing
331
+ * Improved: easier copying of the form shortcode from form settings pages
332
+ * Added: uninstall function
333
+
334
+ = 1.0.2 =
335
+ * Improved code, less memory usage
336
+ * Added `mc4wp_form()` function for usage inside template files
337
+
338
+ = 1.0.1 =
339
+ * Changed: format for groups is now somewhat easier. Refer to the FAQ and update your form mark-up please. (Backwards compatibility included)
340
+ * Added: group preset to form field wizard for hidden fields, checkboxes and radio inputs.
341
+ * Added: radio inputs to field wizard
342
+ * Improved: the field wizard will now add labels after the checkbox and radio input elements.
343
+ * Fixed: regular error messages not being shown in some cases.
344
+
345
+ = 1.0 =
346
+ * Added support for group checkboxes
347
+ * Added support for paragraph elements in error and success messages, the messages are now wrapped in `<div>` instead. Update your custom CSS rules
348
+ * Added some translation filters for qTranslate and WPML compatibility.
349
+
350
+ = 0.8.3 =
351
+ * Added: Guess first and last name when only using full name field.
352
+ * Added: Links to [MailChimp for WordPress Pro](http://dannyvankooten.com/mailchimp-for-wordpress/)
353
+ * Fixed: Bug where options could not be saved after adding specific HTML tags to the form mark-up.
354
+
355
+ = 0.8.2 =
356
+ * Improved: Namespaced form CSS classes
357
+ * Improved: Improved error messages
358
+ * Improved: It is now easier to add fields to your form mark-up by using the wizard. You can choose presets etc.
359
+ * Improved: All field names that are of importance for MailChimp should now be uppercased (backwards compatibility is included)
360
+ * Improved: Fields named added through the wizard are now validated and sanitized
361
+ * Improved: Added caching to the backend which makes it way faster
362
+ * Improved: Various usability improvements
363
+
364
+ = 0.8.1 =
365
+ * Fixed: typo in form success message
366
+ * Improved: various little improvements
367
+ * Added: option to hide the form after a successful sign-up
368
+
369
+ = 0.8 =
370
+ * Changed links to show your appreciation for this plugin.
371
+ * Improved: CSS reset now works for registration forms as well.
372
+ * Improved: Code, removed unnecessary code, only load classes when not existing yet, etc.
373
+ * Improved: hooked into user_register to allow third-party registration form plugins.
374
+ * Added: Shortcode for usage inside Contact Form 7 form templates `[mc4wp_checkbox]`
375
+ * Added: Catch-all, hook into ANY form using ANY input field with name attribute `mc4wp-try-subscribe` and value `1`.
376
+ * Fixed: Subscribe from Multisite sign-up
377
+ * Fixed: 404 page when no e-mail given.
378
+
379
+
380
+ = 0.7 =
381
+ * Improved: small backend JavaScript improvements / fixes
382
+ * Improved: configuration tabs on options page now work with JavaScript disabled as well
383
+ * Added: form and checkbox can now subscribe to different lists
384
+ * Added: Error messages for WP Administrators (for debugging)
385
+ * Added: `mc4wp_checkbox()` function to manually add the checkbox to a comment form.
386
+
387
+ = 0.6.2 =
388
+ * Fixed: Double quotes now enabled in text labels and success / error messages (which enables the use of JavaScript)
389
+ * Fixed: Sign-up form failing silently without showing error.
390
+
391
+ = 0.6.1 =
392
+ * Fixed: error notices
393
+ * Added: some default CSS for success and error notices
394
+ * Added: notice when form mark-up does not contain email field
395
+
396
+ = 0.6 =
397
+ * Fixed: cannot redeclare class MCAPI
398
+ * Fixed: scroll to form element
399
+ * Added: notice when copying the form mark-up instead of using `[mc4wp_form]`
400
+ * Added: CSS classes to form success and error message(s).
401
+ * Removed: Static element ID on form success and error message(s) for W3C validity when more than one form on 1 page.
402
+
403
+ = 0.5 =
404
+ * Fixed W3C invalid value "true" for attribute "required"
405
+ * Added scroll to form element after form submit.
406
+ * Added option to redirect visitors after they subscribed using the sign-up form.
407
+
408
+ = 0.4.1 =
409
+ * Fixed correct and more specific error messages
410
+ * Fixed form designer, hidden fields no longer wrapped in paragraph tags
411
+ * Added text fields to form designer
412
+ * Added error message when email address was already on the list
413
+ * Added debug message when there is a problem with one of the (required) merge fields
414
+
415
+ = 0.4 =
416
+ * Improved dashboard, it now has different tabs for the different settings.
417
+ * Improved guessing of first and last name.
418
+ * Fixed debugging statements on settings page
419
+ * Added settings link on plugins overview page
420
+ * Added form functionality
421
+ * Added form shortcode
422
+ * Added necessary filters for shortcodes to work inside text widgets
423
+ * Added spam honeypot to form to ignore bot sign-ups
424
+ * Added error & success messages to form
425
+ * Added Freddy icon to menu
426
+
427
+ = 0.3 =
428
+ * Fixed the missing argument bug when submitting a comment for some users.
429
+ * Added support for regular, BuddyPress and MultiSite registration forms.
430
+
431
+ = 0.2 =
432
+ * Fixed small bug where name of comment author was not correctly assigned
433
+ * Improved CSS reset for checkbox
434
+
435
+ = 0.1 =
436
+ * BETA release
437
+
438
+ == Upgrade Notice ==
439
+
440
+ = 1.4.8 =
441
+ WP 3.8 compatibility, better scroll to form and huge settings page performance improvement
442
+
443
+ = 1.4.5 =
444
+ Bugfix: fixed invalid email address message after updating to 1.4.4
445
+
446
+ = 1.4.1 =
447
+ Fixed grouping information not being sent to MailChimp when using sign-up forms.
448
+
449
+ = 1.4 =
450
+ New: default form themes, more unlocked fields in the "add field" tool and smarter auto-detection of name fields when integrating with Contact Form 7.
451
+
452
+ = 1.2.5 =
453
+ Fixed CSS issue where the form caused a hue gap in the sidebar for some themes.
454
+
455
+ = 1.1.1 =
456
+ Bugfix for BuddyPress sites
457
+
trunk/uninstall.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //if uninstall not called from WordPress exit
4
+ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
5
+ exit();
6
+ }
7
+
8
+
9
+ delete_option('mc4wp_lite');
10
+ delete_option('mc4wp_lite_checkbox');
11
+ delete_option('mc4wp_lite_form');
12
+
13
+ delete_transient('mc4wp_mailchimp_lists');
14
+ delete_transient('mc4wp_mailchimp_lists_fallback');