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>';