MailChimp for WordPress - Version 1.2.1

Version Description

  • Improved: total revamp of the form field wizard, many improvements.
  • Improved: some textual improvements in the setting pages
  • Added: debug message to sign-up checkbox for WP administrators
Download this release

Release Info

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

Code changes from version 1.1.5 to 1.2.1

assets/css/admin.css ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #mc4wp-content{ float:left; width:65%; margin-right:0; }
2
+ #mc4wp-sidebar{ float:right; width:32%; margin:0; padding:9px 0 0; }
3
+ #mc4wp-sidebar .mc4wp-box{ margin-bottom:20px; }
4
+
5
+ #mc4wp-upgrade-box { background:#efefef; border:1px solid #cecece; padding:20px; }
6
+ #mc4wp-upgrade-box h3{ margin:0; }
7
+
8
+ #mc4wp-fw h4{ margin-top:0; }
9
+ #mc4wp-fw-fields { display:none; }
10
+ #mc4wp-fw-preview { font-family: "Courier New", Courier, monospace; font-size:11px; }
11
+ #mc4wp-lists{ margin:0; }
12
+ #mc4wp-lists input{ margin-right:5px; }
13
+
14
+ .mc4wp-settings tr.pro-feature th, .mc4wp-settings tr.pro-feature td{ color:#999; }
15
+
16
+ .mc4wp-settings span.status{ display:inline-block; padding:3px 6px; color:white; font-size:12px; font-weight:bold; }
17
+ .mc4wp-settings span.positive{ background-color:green; }
18
+ .mc4wp-settings span.negative{ background-color:lightGrey; }
19
+ .mc4wp-settings table th{ text-align:left; }
20
+ .mc4wp-settings table.form-table tr td:first-child, .mc4wp-settings table.form-table tr th:first-child{ padding-left:0; }
21
+ .mc4wp-settings p.copyright-notice{ font-style:italic; }
22
+ .mc4wp-settings td.nowrap{ white-space: nowrap }
23
+ .mc4wp-settings td.desc{ font-style:italic; font-size:11px; }
24
+
25
+ .mc4wp-settings .mc4wp-wrapper{ clear:both; width:100%; display:block; }
26
+ .mc4wp-settings .mc4wp-col { float:left; margin:0 1%; padding:0; }
27
+ .mc4wp-settings .mc4wp-col-2-3{ width:64%; }
28
+ .mc4wp-settings .mc4wp-col-1-3{ width:34%; }
29
+ .mc4wp-settings .mc4wp-first{ margin-left:0; }
30
+ .mc4wp-settings .mc4wp-last{ margin-right:0; }
31
+ .mc4wp-settings .mc4wp-well{ background:#efefef; padding:10px;
32
+ border:1px solid #ccc;
33
+ -webkit-border-radius: 3px; border-radius: 3px;
34
+ -moz-border-radius: 3px; }
35
+
36
+ table.mc4wp-help, table.mc4wp-help th, table.mc4wp-help td { border: 1px solid #ddd; border-collapse: collapse; font-size: 12px; }
37
+ table.mc4wp-help th, table.mc4wp-help td { vertical-align: text-top; text-align: left; padding: 5px 10px; }
38
+ table.mc4wp-help tr:hover { background-color: #ddd; }
{css → assets/css}/checkbox.css RENAMED
File without changes
{css → assets/css}/form.css RENAMED
File without changes
{img → assets/img}/menu-icon.png RENAMED
File without changes
assets/js/admin.js ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
14
+ * MailChimp for WordPress Field Wizard
15
+ * Created by Danny van Kooten
16
+ */
17
+ (function() {
18
+ // setup variables
19
+ var $lists = $("#mc4wp-lists input");
20
+ var $mailchimpFields = $("#mc4wp-fw-mailchimp-fields");
21
+ var $mailchimpMergeFields = $("#mc4wp-fw-mailchimp-fields .merge-fields");
22
+ var $mailchimpGroupings = $("#mc4wp-fw-mailchimp-fields .groupings");
23
+ var $wizardFields = $("#mc4wp-fw-fields");
24
+ var $value = $("#mc4wp-fw-value");
25
+ var $valueLabel = $("#mc4wp-fw-value-label");
26
+ var $multipleValues = $("#mc4wp-fw-values");
27
+ var $label = $("#mc4wp-fw-label");
28
+ var $placeholder = $("#mc4wp-fw-placeholder");
29
+ var $required = $("#mc4wp-fw-required");
30
+ var $wrapp = $("#mc4wp-fw-wrap-p");
31
+ var field = {
32
+ 'type': 'text',
33
+ 'name': ''
34
+ };
35
+ var $codePreview = $("#mc4wp-fw-preview");
36
+ // functions
37
+
38
+ // set the fields the user can choose from
39
+ function setFields()
40
+ {
41
+ // empty field select
42
+ $mailchimpFields.find('option').not('.default').remove();
43
+
44
+ // loop through checked lists
45
+ $lists.filter(':checked').each(function() {
46
+ var fields = $(this).data('fields');
47
+ var groupings = $(this).data('groupings');
48
+
49
+ // loop through merge fields from this list
50
+ for(var i = 0, fieldCount = fields.length; i < fieldCount; i++) {
51
+ var field = fields[i];
52
+
53
+ // add field to select if no similar option exists yet
54
+ if($mailchimpMergeFields.find("option[value='"+ field.tag +"']").length == 0) {
55
+
56
+ var text = (field.name.length > 40) ? field.name.substring(0, 40) + '..' : field.name;
57
+ if(field.req) { text += '*'; }
58
+
59
+ var include = false;
60
+ var triggers = [ 'name', 'email', 'website' ];
61
+ for(var i = 0; i < triggers.length; i++) {
62
+ if(field.tag.toLowerCase().indexOf(triggers[i]) != -1) {
63
+ include = true;
64
+ break;
65
+ }
66
+ }
67
+
68
+ if(include) {
69
+ var $option = $("<option />").text(text).val(field.tag).data('field', field);
70
+ } else {
71
+ var $option = $("<option />").text(text + " (Pro only)").val(field.tag).attr('disabled', 'disabled');
72
+ }
73
+
74
+ $mailchimpMergeFields.append($option);
75
+ }
76
+ }
77
+
78
+ // loop through interest groupings
79
+ for(var i = 0, groupingsCount = groupings.length; i < groupingsCount; i++) {
80
+ var grouping = groupings[i];
81
+
82
+ // add field to select if no similar option exists yet
83
+ if($mailchimpGroupings.find("option[value='"+ grouping.id +"']").length == 0) {
84
+ var text = (grouping.name.length > 40) ? grouping.name.substring(0, 40) + '..' : grouping.name;
85
+ var $option = $("<option />").text(text + " (Pro only)").val(grouping.id).attr('disabled', 'disabled');
86
+ $mailchimpGroupings.append($option);
87
+ }
88
+ }
89
+
90
+
91
+ });
92
+ }
93
+
94
+ function setPresets()
95
+ {
96
+ resetFields();
97
+
98
+ var selected = $(this).find(':selected');
99
+ if(selected.val() == 'submit') {
100
+ // setup values for submit field
101
+ field['type'] = 'submit';
102
+ $valueLabel.text("Button text");
103
+ $wizardFields.find('p.row').filter('.value, .wrap-p').show();
104
+ updateCodePreview();
105
+ } else {
106
+ var data = selected.data('field');
107
+ if(data) { return setPresetsForField(data); }
108
+ }
109
+
110
+ return;
111
+ }
112
+
113
+ function resetFields() {
114
+ $wizardFields.find('.row :input').each(function() {
115
+ if($(this).is(":checkbox")) { this.checked = false; } else { this.value = ''; }
116
+ });
117
+
118
+ $wizardFields.find('p.row').hide();
119
+ $multipleValues.find(':input').remove();
120
+ $wizardFields.show();
121
+
122
+ field['type'] = 'text';
123
+ field['name'] = '';
124
+ $valueLabel.html("Initial value <small>(optional)</small>");
125
+ }
126
+
127
+ // show available fields and fill it with some values
128
+ function setPresetsForField(data)
129
+ {
130
+
131
+ // show fields for this field type
132
+ var visibleRowsMap = {
133
+ 'default': [ 'label', 'value', 'placeholder', 'required', 'wrap-p' ],
134
+ 'select': [ 'label', 'required', 'wrap-p', 'values'],
135
+ 'radio': [ 'label', 'required', 'wrap-p', 'values'],
136
+ 'date': [ 'label', 'required', 'wrap-p', 'value']
137
+ }
138
+
139
+ var fieldTypesMap = {
140
+ 'text': 'text', 'email': 'email', 'phone': 'tel', 'address': 'text', 'number': 'number', 'url': 'url',
141
+ 'dropdown': 'select', 'date': 'date', 'birthday': 'date', 'radio': 'radio', 'checkbox': 'checkbox'
142
+ }
143
+
144
+ if(fieldTypesMap[data.field_type] != undefined) {
145
+ var fieldType = fieldTypesMap[data.field_type];
146
+ } else {
147
+ var fieldType = 'text';
148
+ }
149
+
150
+ if(visibleRowsMap[fieldType] != undefined) {
151
+ var visibleRows = visibleRowsMap[fieldType];
152
+ } else {
153
+ var visibleRows = visibleRowsMap["default"];
154
+ }
155
+
156
+ for(var i = 0, count = visibleRows.length; i < count; i++) {
157
+ $wizardFields.find('p.row.' + visibleRows[i]).show();
158
+ }
159
+
160
+ // populate fields with preset values
161
+ field['type'] = fieldType;
162
+ field['name'] = data.tag;
163
+ $placeholder.val("Your " + data.name.toLowerCase());
164
+ $label.val(data.name + ":");
165
+ if(data.req) { $required.attr('checked', true); }
166
+
167
+ // update code preview
168
+ updateCodePreview();
169
+ }
170
+
171
+ function updateCodePreview()
172
+ {
173
+ var $code = $("<div></div>");
174
+ var inputs = [];
175
+ var $input;
176
+
177
+ // build input / select / textarea element
178
+ $input = $("<input />").attr('type', field['type']);
179
+
180
+ // set name attribute
181
+ if(field.name.length > 0) {
182
+ $input.attr('name', field.name);
183
+ }
184
+
185
+ // set value
186
+ if($value.is(":visible") && $value.val().length > 0) {
187
+ if(field['type'] == 'textarea') {
188
+ $input.text($value.val());
189
+ } else {
190
+ $input.attr('value', $value.val());
191
+ }
192
+ }
193
+
194
+ // add placeholder to element
195
+ if($placeholder.is(":visible") && $placeholder.val().length > 0) {
196
+ $input.attr('placeholder', $placeholder.val());
197
+ }
198
+
199
+ // add required attribute
200
+ if($required.is(':visible:checked')) {
201
+ $input.attr('required', 'required');
202
+ }
203
+
204
+ $code.append($input);
205
+
206
+
207
+
208
+
209
+ // build label
210
+ if($label.is(":visible") && $label.val().length > 0) {
211
+ var labelTag = (field['type'] == 'radio' || field['type'] == 'checkbox') ? 'h5' : 'label';
212
+ $("<"+ labelTag +" />").text($label.val()).prependTo($code);
213
+ }
214
+
215
+ // start indenting and tabbing of code
216
+ var codePreview = $code.html();
217
+
218
+ if($wrapp.is(':visible:checked')) {
219
+ $code.wrapInner($("<p />"));
220
+
221
+ // indent code inside paragraphs (double tab)
222
+ codePreview = $code.html()
223
+ .replace(/<p>/gi, "<p>\n\t")
224
+ .replace(/<label><input /gi, "\n\t<label><input ")
225
+ .replace(/<\/label><input/gi, "</label> \n\t<input");
226
+ }
227
+
228
+ // newline after every closed element
229
+ codePreview = codePreview.replace(/></g, "> \n<");
230
+
231
+ // add code to codePreview textarea
232
+ $codePreview.val(codePreview);
233
+ }
234
+
235
+ function addCodeToFormMarkup() {
236
+
237
+ var result = false;
238
+
239
+ // try to insert in QuickTags editor at cursor position
240
+ if(typeof QTags !='undefined' && QTags.insertContent) {
241
+ result = QTags.insertContent($codePreview.val());
242
+ }
243
+
244
+ // fallback
245
+ if(!result) {
246
+ $("#mc4wpformmarkup").val($("#mc4wpformmarkup").val() + "\n" + $codePreview.val());
247
+ }
248
+ }
249
+
250
+ // setup events
251
+ $lists.change(setFields);
252
+ $mailchimpFields.change(setPresets);
253
+ $wizardFields.change(updateCodePreview);
254
+ $("#mc4wp-fw-add-to-form").click(addCodeToFormMarkup);
255
+
256
+ // init
257
+ $lists.change();
258
+
259
+ })();
260
+
261
+ })(jQuery);
262
+
css/admin.css DELETED
@@ -1,67 +0,0 @@
1
- #mc4wp_admin hr{ margin:20px 0; background-color:lightGray; border:0; height:1px; }
2
- #mc4wp_admin h2{ padding-bottom: 0; }
3
- #mc4wp_admin span.status{ padding:3px; color:white; font-size:12px; }
4
- #mc4wp_admin span.status.connected{ background-color:green; }
5
- #mc4wp_admin span.status.not_connected{ background-color:lightGrey; }
6
- #mc4wp_admin td.desc{ font-style:italic; font-size:10px; }
7
-
8
- #mc4wp_admin .alert{ border:1px solid black; padding:5px; width:auto; }
9
- #mc4wp_admin .alert.warning{ background:#FCF8E3; color:#C09853; border:1px solid #FBEED5; }
10
-
11
- #mc4wp-main-column{ float:left; width:65%; margin-right:0; }
12
- #mc4wp-secondary-column{ float:right; width:32%; margin-left:2.5%; }
13
- #mc4wp-secondary-column .mc4wp-box{ margin-bottom:20px; }
14
-
15
- /* tabs */
16
- #mc4wp-nav { clear:both; padding:0; margin:20px 0; border-bottom: 1px solid lightGray; }
17
- #mc4wp-nav li { list-style: none; margin: 0; padding:0; display: inline-block; }
18
- #mc4wp-nav li a { font-weight:bold; display:block; padding: 6px 12px; margin:0 10px -1px 0; border:1px solid lightGray; text-decoration: none; font-size:14px; }
19
- #mc4wp-nav li a.active { background: white; border-bottom: 1px solid white; color:black; }
20
- #mc4wp-tabs .mc4wp-tab{ display:none !important; }
21
- #mc4wp-tabs .mc4wp-tab.active{ display:block !important; }
22
- /* end tabs */
23
-
24
- #mc4wp-upgrade-box { border:1px solid black; background:#efefef; padding:20px; -moz-box-shadow: 0 0 5px 5px #888; -webkit-box-shadow: 0 0 5px 5px#888; box-shadow: 0 0 5px 5px #888; }
25
- #mc4wp-upgrade-box h3{ margin:0; }
26
- #mc4wp-upgrade-box ul{ list-style:square; margin-left:25px; }
27
- #mc4wp-upgrade-box li{ margin:0; }
28
-
29
- #mc4wp-fw h4{ margin-top:0; }
30
- #mc4wp-fw .mc4wp-fields { display:none; }
31
- #mc4wp-fw-preview { font-size:11px; }
32
-
33
- #mc4wp_admin table th{ text-align:left; }
34
- #mc4wp_admin table.form-table tr td:first-child, #mc4wp_admin table.form-table tr th:first-child{ padding-left:0; }
35
- #mc4wp_admin p.copyright-notice{ font-style:italic; }
36
-
37
- #mc4wp_admin .mc4wp-wrapper{ clear:both; width:100%; display:block; }
38
- #mc4wp_admin .mc4wp-col { float:left; margin:0 1%; padding:0; }
39
- #mc4wp_admin .mc4wp-col-2-3{ width:64%; }
40
- #mc4wp_admin .mc4wp-col-1-3{ width:34%; }
41
- #mc4wp_admin .mc4wp-first{ margin-left:0; }
42
- #mc4wp_admin .mc4wp-last{ margin-right:0; }
43
- #mc4wp_admin .mc4wp-well{ background:#efefef; padding:10px; border:1px solid #666; }
44
-
45
- #mc4wp_admin .upgrade-button{
46
- border:1px solid #ffad41;-webkit-box-shadow: #999999 1px 1px 1px ;-moz-box-shadow: #999999 1px 1px 1px ; box-shadow: #999999 1px 1px 1px ; -webkit-border-radius: 3px; -moz-border-radius: 3px;border-radius: 3px;padding: 12px 16px; text-decoration:none; display:inline-block;text-shadow: 1px 1px 0 rgba(51,51,51,0.3);font-weight:bold; color: #000000;
47
- background-color: #ffc579; background-image: -webkit-gradient(linear, left top, left bottom, from(#ffc579), to(#fb9d23));
48
- background-image: -webkit-linear-gradient(top, #ffc579, #fb9d23);
49
- background-image: -moz-linear-gradient(top, #ffc579, #fb9d23);
50
- background-image: -ms-linear-gradient(top, #ffc579, #fb9d23);
51
- background-image: -o-linear-gradient(top, #ffc579, #fb9d23);
52
- background-image: linear-gradient(to bottom, #ffc579, #fb9d23);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#ffc579, endColorstr=#fb9d23);
53
- }
54
-
55
- #mc4wp_admin .upgrade-button:hover{
56
- border:1px solid #ff9913;
57
- background-color: #ffaf46; background-image: -webkit-gradient(linear, left top, left bottom, from(#ffaf46), to(#e78404));
58
- background-image: -webkit-linear-gradient(top, #ffaf46, #e78404);
59
- background-image: -moz-linear-gradient(top, #ffaf46, #e78404);
60
- background-image: -ms-linear-gradient(top, #ffaf46, #e78404);
61
- background-image: -o-linear-gradient(top, #ffaf46, #e78404);
62
- background-image: linear-gradient(to bottom, #ffaf46, #e78404);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#ffaf46, endColorstr=#e78404);
63
- }
64
-
65
- table.mc4wp-help, table.mc4wp-help th, table.mc4wp-help td { border: 1px solid #ddd; border-collapse: collapse; font-size: 12px; }
66
- table.mc4wp-help th, table.mc4wp-help td { vertical-align: text-top; text-align: left; padding: 5px 10px; }
67
- table.mc4wp-help tr:hover { background-color: #ddd; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/MC4WP_Lite.php CHANGED
@@ -3,8 +3,7 @@
3
  class MC4WP_Lite
4
  {
5
  private $options = array();
6
- private $mailchimp_api = null;
7
- private static $instance, $checkbox = null, $form = null;
8
 
9
  public static function instance()
10
  {
@@ -29,74 +28,152 @@ class MC4WP_Lite
29
  return self::$form;
30
  }
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  public function __construct()
33
  {
34
  self::$instance = $this;
35
 
 
36
  $opts = $this->get_options();
37
 
 
38
  self::checkbox();
39
  self::form();
40
 
41
- if(defined('DOING_AJAX') && DOING_AJAX) {
42
- // ajax only
43
-
44
- } else {
45
  // non-ajax only
46
-
47
  if(is_admin()) {
48
- // backend non-ajax only
49
- require_once 'MC4WP_Lite_Admin.php';
50
- new MC4WP_Lite_Admin();
51
  } else {
52
- // frontend non-ajax only
53
  require 'functions.php';
54
  }
55
  }
56
  }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  public function get_options()
59
  {
60
  if(empty($this->options)) {
61
- $defaults = array(
62
- 'mailchimp_api_key' => '',
63
- 'checkbox_label' => 'Sign me up for the newsletter!', 'checkbox_precheck' => 1, 'checkbox_css' => 0,
64
- 'checkbox_show_at_comment_form' => 0, 'checkbox_show_at_registration_form' => 0, 'checkbox_show_at_ms_form' => 0, 'checkbox_show_at_bp_form' => 0, 'checkbox_show_at_other_forms' => 0,
65
- 'checkbox_lists' => array(), 'checkbox_double_optin' => 1, 'checkbox_show_at_bbpress_forms' => 0,
66
- 'form_css' => 1, 'form_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>",
67
- 'form_text_success' => 'Thank you, your sign-up request was successful! Please check your e-mail inbox.', 'form_text_error' => 'Oops. Something went wrong. Please try again later.',
68
- 'form_text_invalid_email' => 'Please provide a valid email address.', 'form_text_already_subscribed' => "Given email address is already subscribed, thank you!",
69
- 'form_redirect' => '', 'form_lists' => array(), 'form_double_optin' => 1, 'form_hide_after_success' => 0
70
- );
71
-
72
- $options = get_option('mc4wp_lite');
73
- if(!$options) {
74
- // using old option key?
75
- if(($options = get_option('mc4wp')) != false) {
76
- add_option('mc4wp_lite', $options);
77
- }
78
- }
79
 
80
- $this->options = $opts = array_merge($defaults, (array) $options);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
 
83
  return $this->options;
84
  }
85
 
86
- public function get_mailchimp_api()
87
- {
88
- if(!$this->mailchimp_api) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
- // Only load MailChimp API if it has not been loaded yet
91
- // other plugins may have already at this point.
92
- if(!class_exists("MCAPI")) {
93
- require_once 'MCAPI.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
-
96
- $this->mailchimp_api = new MCAPI($this->options['mailchimp_api_key']);
97
- }
98
 
99
- return $this->mailchimp_api;
 
 
 
100
  }
101
 
102
  }
3
  class MC4WP_Lite
4
  {
5
  private $options = array();
6
+ private static $instance, $checkbox = null, $form = null, $api = null, $admin = null;
 
7
 
8
  public static function instance()
9
  {
28
  return self::$form;
29
  }
30
 
31
+ public static function api()
32
+ {
33
+ if(!self::$api) {
34
+ require 'MC4WP_Lite_API.php';
35
+ $opts = self::instance()->get_options();
36
+ self::$api = new MC4WP_Lite_API($opts['general']['api_key']);
37
+ }
38
+ return self::$api;
39
+ }
40
+
41
+ public static function admin()
42
+ {
43
+ if(!self::$admin) {
44
+ require_once 'MC4WP_Lite_Admin.php';
45
+ self::$admin = new MC4WP_Lite_Admin();
46
+ }
47
+ return self::$admin;
48
+ }
49
  public function __construct()
50
  {
51
  self::$instance = $this;
52
 
53
+ $this->backwards_compatibility();
54
  $opts = $this->get_options();
55
 
56
+ // setup the code
57
  self::checkbox();
58
  self::form();
59
 
60
+ if(!defined('DOING_AJAX') || !DOING_AJAX) {
 
 
 
61
  // non-ajax only
 
62
  if(is_admin()) {
63
+ // backend non-ajax only
64
+ self::admin();
 
65
  } else {
66
+ // frontend non-ajax only
67
  require 'functions.php';
68
  }
69
  }
70
  }
71
 
72
+ private function get_default_options()
73
+ {
74
+ return array(
75
+ 'general' => array(
76
+ 'api_key' => ''
77
+ ),
78
+ 'checkbox' => array(
79
+ 'label' => 'Sign me up for the newsletter!',
80
+ 'precheck' => 1,
81
+ 'css' => 1,
82
+ 'show_at_comment_form' => 0,
83
+ 'show_at_registration_form' => 0,
84
+ 'show_at_multisite_form' => 0,
85
+ 'show_at_buddypress_form' => 0,
86
+ 'show_at_bbpress_forms' => 0,
87
+ 'show_at_other_forms' => 0,
88
+ 'lists' => array(),
89
+ 'double_optin' => 1
90
+ ),
91
+ 'form' => array(
92
+ 'css' => 1,
93
+ 'markup' => "<p>\n\t<label for=\"mc4wp_email\">Email address: </label>\n\t<input type=\"email\" id=\"mc4wp_email\" name=\"EMAIL\" required placeholder=\"Your email address\" />\n</p>\n\n<p>\n\t<input type=\"submit\" value=\"Sign up\" />\n</p>",
94
+ 'text_success' => 'Thank you, your sign-up request was successful! Please check your e-mail inbox.',
95
+ 'text_error' => 'Oops. Something went wrong. Please try again later.',
96
+ 'text_invalid_email' => 'Please provide a valid email address.',
97
+ 'text_already_subscribed' => "Given email address is already subscribed, thank you!",
98
+ 'redirect' => '',
99
+ 'lists' => array(),
100
+ 'double_optin' => 1,
101
+ 'hide_after_success' => 0
102
+ )
103
+ );
104
+ }
105
+
106
  public function get_options()
107
  {
108
  if(empty($this->options)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
+ $defaults = $this->get_default_options();
111
+ $db_keys_option_keys = array(
112
+ 'mc4wp_lite' => 'general',
113
+ 'mc4wp_lite_checkbox' => 'checkbox',
114
+ 'mc4wp_lite_form' => 'form'
115
+ );
116
+
117
+ foreach($db_keys_option_keys as $db_key => $option_key) {
118
+ $option = get_option($db_key);
119
+
120
+ // add option to database to prevent query on every pageload
121
+ if($option == false) { add_option($db_key, $defaults[$option_key]); }
122
+
123
+ $this->options[$option_key] = array_merge($defaults[$option_key], (array) $option);
124
+ }
125
  }
126
 
127
  return $this->options;
128
  }
129
 
130
+ private function backwards_compatibility()
131
+ {
132
+ $options = get_option('mc4wp_lite');
133
+
134
+ // transfer old options to new option system
135
+ if(isset($options['mailchimp_api_key'])) {
136
+
137
+ // delete transients
138
+ delete_transient('mc4wp_mailchimp_lists');
139
+ delete_transient('mc4wp_mailchimp_lists_fallback');
140
+
141
+ $new_options = array(
142
+ 'general' => array(),
143
+ 'checkbox' => array(),
144
+ 'form' => array()
145
+ );
146
+
147
+ $new_options['general']['api_key'] = $options['mailchimp_api_key'];
148
 
149
+ foreach($options as $key => $value) {
150
+ $_pos = strpos($key, '_');
151
+
152
+ $first_key = substr($key, 0, $_pos);
153
+ $second_key = substr($key, $_pos + 1);
154
+
155
+ if(isset($new_options[$first_key])) {
156
+
157
+ // change option name
158
+ if($second_key == 'show_at_bp_form') {
159
+ $second_key = 'show_at_buddypress_form';
160
+ }
161
+
162
+ // change option name
163
+ if($second_key == 'show_at_ms_form') {
164
+ $second_key = 'show_at_multisite_form';
165
+ }
166
+
167
+ // set value into new option name
168
+ $new_options[$first_key][$second_key] = $value;
169
+ }
170
+
171
  }
 
 
 
172
 
173
+ update_option('mc4wp_lite', $new_options['general']);
174
+ update_option('mc4wp_lite_checkbox', $new_options['checkbox']);
175
+ update_option('mc4wp_lite_form', $new_options['form']);
176
+ }
177
  }
178
 
179
  }
includes/MC4WP_Lite_API.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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');
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
+
97
+ $data['apikey'] = $this->api_key;
98
+
99
+ $response = wp_remote_post($this->api_url . $method . '.json', array(
100
+ 'body' => json_encode($data),
101
+ 'timeout' => 10,
102
+ 'headers' => array('Accept-Encoding' => ''),
103
+ 'sslverify' => false
104
+ )
105
+ );
106
+
107
+ if(is_wp_error($response)) {
108
+ return false;
109
+ } else {
110
+ // dirty fix for older WP version
111
+ if($method == 'helper/ping' && isset($response['headers']['content-length']) && (int) $response['headers']['content-length'] == '44') {
112
+ return (object) array( 'msg' => "Everything's Chimpy!");
113
+ }
114
+
115
+ $body = wp_remote_retrieve_body($response);
116
+ return json_decode($body);
117
+ }
118
+ }
119
+
120
+ public function has_error()
121
+ {
122
+ return (!empty($this->error_message));
123
+ }
124
+
125
+ public function get_error_message()
126
+ {
127
+ return $this->error_message;
128
+ }
129
+
130
+ }
includes/MC4WP_Lite_Admin.php CHANGED
@@ -12,12 +12,19 @@ class MC4WP_Lite_Admin
12
  add_action('admin_menu', array($this, 'build_menu'));
13
  add_action( 'admin_enqueue_scripts', array($this, 'load_css_and_js') );
14
 
15
- register_activation_hook( 'mailchimp-for-wp-pro/mailchimp-for-wp-pro.php', array($this, 'on_activation') );
 
16
 
17
  add_filter("plugin_action_links_mailchimp-for-wp/mailchimp-for-wp.php", array($this, 'add_settings_link'));
 
 
 
 
 
 
18
  }
19
 
20
- public function on_activation()
21
  {
22
  delete_transient('mc4wp_mailchimp_lists');
23
  delete_transient('mc4wp_mailchimp_lists_fallback');
@@ -25,7 +32,7 @@ class MC4WP_Lite_Admin
25
 
26
  public function add_settings_link($links)
27
  {
28
- $settings_link = '<a href="admin.php?page=mailchimp-for-wp">Settings</a>';
29
  $upgrade_link = '<a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to Pro</a>';
30
  array_unshift($links, $upgrade_link, $settings_link);
31
  return $links;
@@ -33,7 +40,9 @@ class MC4WP_Lite_Admin
33
 
34
  public function register_settings()
35
  {
36
- register_setting('mc4wp_options_group', 'mc4wp_lite', array($this, 'validate_options'));
 
 
37
  }
38
 
39
  public function validate_options($opts)
@@ -43,22 +52,24 @@ class MC4WP_Lite_Admin
43
 
44
  public function build_menu()
45
  {
46
- $page = add_menu_page('MailChimp for WP Lite', 'MailChimp for WP Lite', 'manage_options', 'mailchimp-for-wp', array($this, 'page_dashboard'), plugins_url('mailchimp-for-wp/img/menu-icon.png'));
 
 
 
 
 
47
  }
48
 
49
  public function load_css_and_js($hook)
50
  {
51
- if($hook != 'toplevel_page_mailchimp-for-wp') { return false; }
52
-
53
- wp_register_script('mc4wp-admin-js', plugins_url('mailchimp-for-wp/js/admin.js'), array('jquery'), false, true);
54
 
55
  // css
56
- wp_enqueue_style( 'mc4wp-admin-css', plugins_url('mailchimp-for-wp/css/admin.css') );
57
 
58
  // js
 
59
  wp_enqueue_script( array('jquery', 'mc4wp-admin-js') );
60
- $translation_array = array( 'admin_page' => get_admin_url(null, 'admin.php?page=mailchimp-for-wp') );
61
- wp_localize_script( 'mc4wp-admin-js', 'mc4wp_urls', $translation_array );
62
  }
63
 
64
  public function get_checkbox_compatible_plugins()
@@ -75,72 +86,107 @@ class MC4WP_Lite_Admin
75
  return $checkbox_plugins;
76
  }
77
 
78
- public function page_dashboard()
79
  {
80
- $opts = $this->options;
81
- $api = $this->get_mailchimp_api();
82
 
83
- if(empty($opts['mailchimp_api_key'])) {
 
 
 
 
 
84
  $connected = false;
85
  } else {
86
- $connected = ($api->ping() === "Everything's Chimpy!");
87
  }
88
 
89
- if($connected) {
90
- $lists = $this->get_mailchimp_lists();
91
- }
92
-
93
- // tab shit
94
- $tabs = array('api-settings', 'checkbox-settings', 'form-settings');
95
- $tab = (isset($_GET['tab'])) ? $_GET['tab'] : 'api-settings';
96
 
97
- require 'views/dashboard.php';
 
 
 
 
 
98
  }
99
 
100
- private function get_mailchimp_api()
101
  {
102
- return MC4WP_Lite::instance()->get_mailchimp_api();
 
 
 
103
  }
104
 
105
- public function get_mailchimp_lists($refresh_cache = false)
 
 
 
 
106
  {
107
- $lists = get_transient( 'mc4wp_mailchimp_lists' );
108
-
109
- $refresh_cache = (isset($_REQUEST['renew-cached-data'])) ? true : $refresh_cache;
110
 
111
- if($refresh_cache || !$lists) {
 
 
 
112
 
 
113
  // make api request for lists
114
- $api = $this->get_mailchimp_api();
115
- $lists_data = $api->lists();
116
- $lists = array();
 
 
 
 
 
 
 
 
 
 
 
117
 
118
- if($lists_data && isset($lists_data['data'])) {
 
 
 
119
 
120
- foreach($lists_data['data'] as $l) {
121
- $lists[$l['id']] = array(
122
- 'id' => $l['id'],
123
- 'name' => $l['name']
124
- );
125
  }
126
 
 
127
  if(isset($_REQUEST['renew-cached-data'])) {
128
- // add notice
129
- add_settings_error("mc4wp", "cache-renewed", 'MailChimp cache renewed.', 'updated' );
 
 
 
130
  }
131
 
132
  // store lists in transients
133
- set_transient('mc4wp_mailchimp_lists', $lists, 3600); // 1 hour
134
  set_transient('mc4wp_mailchimp_lists_fallback', $lists, 1209600); // 2 weeks
 
135
  } else {
136
  // api request failed, get fallback data (with longer lifetime)
137
- $lists = get_transient('mc4wp_mailchimp_lists_fallback');
138
- if(!$lists) { return array(); }
139
  }
140
 
141
  }
142
 
143
- return $lists;
144
  }
145
 
146
  }
12
  add_action('admin_menu', array($this, 'build_menu'));
13
  add_action( 'admin_enqueue_scripts', array($this, 'load_css_and_js') );
14
 
15
+ register_activation_hook( 'mailchimp-for-wp/mailchimp-for-wp.php', array($this, 'delete_transients') );
16
+ register_deactivation_hook( 'mailchimp-for-wp-pro/mailchimp-for-wp-pro.php', array($this, 'delete_transients') );
17
 
18
  add_filter("plugin_action_links_mailchimp-for-wp/mailchimp-for-wp.php", array($this, 'add_settings_link'));
19
+
20
+ // did the user click on upgrade to pro link?
21
+ if(isset($_GET['page']) && $_GET['page'] == 'mc4wp-lite-upgrade' && !headers_sent()) {
22
+ header("Location: http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/");
23
+ exit;
24
+ }
25
  }
26
 
27
+ public function delete_transients()
28
  {
29
  delete_transient('mc4wp_mailchimp_lists');
30
  delete_transient('mc4wp_mailchimp_lists_fallback');
32
 
33
  public function add_settings_link($links)
34
  {
35
+ $settings_link = '<a href="admin.php?page=mc4wp-lite">Settings</a>';
36
  $upgrade_link = '<a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to Pro</a>';
37
  array_unshift($links, $upgrade_link, $settings_link);
38
  return $links;
40
 
41
  public function register_settings()
42
  {
43
+ register_setting('mc4wp_lite_settings', 'mc4wp_lite', array($this, 'validate_options'));
44
+ register_setting('mc4wp_lite_checkbox_settings', 'mc4wp_lite_checkbox', array($this, 'validate_options'));
45
+ register_setting('mc4wp_lite_form_settings', 'mc4wp_lite_form', array($this, 'validate_options'));
46
  }
47
 
48
  public function validate_options($opts)
52
 
53
  public function build_menu()
54
  {
55
+ add_menu_page('MailChimp for WP Lite', 'MailChimp for WP Lite', 'manage_options', 'mc4wp-lite', array($this, 'show_api_settings'), plugins_url('mailchimp-for-wp/assets/img/menu-icon.png'));
56
+ add_submenu_page('mc4wp-lite', 'API Settings - MailChimp for WP Lite', 'MailChimp Settings', 'manage_options', 'mc4wp-lite', array($this, 'show_api_settings'));
57
+ add_submenu_page('mc4wp-lite', 'Checkbox Settings - MailChimp for WP Lite', 'Checkboxes', 'manage_options', 'mc4wp-lite-checkbox-settings', array($this, 'show_checkbox_settings'));
58
+ add_submenu_page('mc4wp-lite', 'Form Settings - MailChimp for WP Lite', 'Forms', 'manage_options', 'mc4wp-lite-form-settings', array($this, 'show_form_settings'));
59
+ 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'));
60
+
61
  }
62
 
63
  public function load_css_and_js($hook)
64
  {
65
+ if(!isset($_GET['page']) || stristr($_GET['page'], 'mc4wp-lite') == false) { return; }
 
 
66
 
67
  // css
68
+ wp_enqueue_style( 'mc4wp-admin-css', plugins_url('mailchimp-for-wp/assets/css/admin.css') );
69
 
70
  // js
71
+ wp_register_script('mc4wp-admin-js', plugins_url('mailchimp-for-wp/assets/js/admin.js'), array('jquery'), false, true);
72
  wp_enqueue_script( array('jquery', 'mc4wp-admin-js') );
 
 
73
  }
74
 
75
  public function get_checkbox_compatible_plugins()
86
  return $checkbox_plugins;
87
  }
88
 
89
+ public function redirect_to_pro()
90
  {
91
+ ?><script>window.location.replace('http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/'); </script><?php
92
+ }
93
 
94
+ public function show_api_settings()
95
+ {
96
+ $opts = $this->options['general'];
97
+ $tab = 'api-settings';
98
+
99
+ if(empty($opts['api_key'])) {
100
  $connected = false;
101
  } else {
102
+ $connected = (MC4WP_Lite::api()->is_connected());
103
  }
104
 
105
+ $lists = $this->get_mailchimp_lists();
106
+ require 'views/api-settings.php';
107
+ }
 
 
 
 
108
 
109
+ public function show_checkbox_settings()
110
+ {
111
+ $opts = $this->options['checkbox'];
112
+ $lists = $this->get_mailchimp_lists();
113
+ $tab = 'checkbox-settings';
114
+ require 'views/checkbox-settings.php';
115
  }
116
 
117
+ public function show_form_settings()
118
  {
119
+ $opts = $this->options['form'];
120
+ $lists = $this->get_mailchimp_lists();
121
+ $tab = 'form-settings';
122
+ require 'views/form-settings.php';
123
  }
124
 
125
+ /**
126
+ * Get MailChimp lists
127
+ * Try cache first, then try API, then try fallback cache.
128
+ */
129
+ private function get_mailchimp_lists()
130
  {
131
+ $cached_lists = get_transient( 'mc4wp_mailchimp_lists' );
132
+ $refresh_cache = (isset($_REQUEST['renew-cached-data']));
 
133
 
134
+ // force cache refresh if merge_vars are not set
135
+ if($cached_lists && !isset($cached_lists[0]->merge_vars)) {
136
+ $refresh_cache = true;
137
+ }
138
 
139
+ if($refresh_cache || !$cached_lists) {
140
  // make api request for lists
141
+ $api = MC4WP_Lite::api();
142
+ $lists = $api->get_lists();
143
+
144
+ if($lists) {
145
+
146
+ $list_ids = array();
147
+ foreach($lists as $key => $list) {
148
+ $list_ids[] = $list->id;
149
+ $lists[$key]->merge_vars = array();
150
+ $lists[$key]->interest_groupings = array();
151
+ }
152
+
153
+ // get lists including merge vars
154
+ $lists = $api->get_lists_with_merge_vars($list_ids);
155
 
156
+ // get interest groupings for each list
157
+ if($lists) {
158
+ foreach($lists as $key => $list) {
159
+ $lists[$key]->interest_groupings = array();
160
 
161
+ $result = $api->get_list_groupings($list->id);
162
+ if($result) {
163
+ $lists[$key]->interest_groupings = $result;
164
+ }
165
+ }
166
  }
167
 
168
+ // cache renewal triggered manually?
169
  if(isset($_REQUEST['renew-cached-data'])) {
170
+ if($lists) {
171
+ add_settings_error("mc4wp", "cache-renewed", 'Renewed MailChimp cache.', 'updated' );
172
+ } else {
173
+ add_settings_error("mc4wp", "cache-renew-failed", 'Failed to renew MailChimp cache - please try again later.' );
174
+ }
175
  }
176
 
177
  // store lists in transients
178
+ set_transient('mc4wp_mailchimp_lists', $lists, (24 * 3600)); // 1 day
179
  set_transient('mc4wp_mailchimp_lists_fallback', $lists, 1209600); // 2 weeks
180
+ return $lists;
181
  } else {
182
  // api request failed, get fallback data (with longer lifetime)
183
+ $cached_lists = get_transient('mc4wp_mailchimp_lists_fallback');
184
+ if(!$cached_lists) { return array(); }
185
  }
186
 
187
  }
188
 
189
+ return $cached_lists;
190
  }
191
 
192
  }
includes/MC4WP_Lite_Checkbox.php CHANGED
@@ -2,23 +2,22 @@
2
 
3
  class MC4WP_Lite_Checkbox
4
  {
5
- private $options = array();
6
  private $showed_checkbox = false;
7
 
8
  public function __construct()
9
  {
10
- $this->options = $opts = MC4WP_Lite::instance()->get_options();
11
 
12
  add_action('init', array($this, 'on_init'));
13
 
14
  // load checkbox css if necessary
15
- if($this->options['checkbox_css'] == 1) {
16
  add_action( 'wp_enqueue_scripts', array($this, 'load_stylesheet') );
17
  add_action( 'login_enqueue_scripts', array($this, 'load_stylesheet') );
18
  }
19
 
20
  /* Comment Form Actions */
21
- if($opts['checkbox_show_at_comment_form']) {
22
  // hooks for checking if we should subscribe the commenter
23
  add_action('comment_post', array($this, 'subscribe_from_comment'), 20, 2);
24
 
@@ -28,19 +27,19 @@ class MC4WP_Lite_Checkbox
28
  }
29
 
30
  /* Registration Form Actions */
31
- if($opts['checkbox_show_at_registration_form']) {
32
  add_action('register_form',array($this, 'output_checkbox'),20);
33
  add_action('user_register',array($this, 'subscribe_from_registration'), 80, 1);
34
  }
35
 
36
  /* BuddyPress Form Actions */
37
- if($opts['checkbox_show_at_bp_form']) {
38
  add_action('bp_before_registration_submit_buttons', array($this, 'output_checkbox'), 20);
39
  add_action('bp_complete_signup', array($this, 'subscribe_from_buddypress'), 20);
40
  }
41
 
42
  /* Multisite Form Actions */
43
- if($opts['checkbox_show_at_ms_form']) {
44
  add_action('signup_extra_fields', array($this, 'output_checkbox'), 20);
45
  add_action('signup_blogform', array($this, 'add_multisite_hidden_checkbox'), 20);
46
  add_action('wpmu_activate_blog', array($this, 'on_multisite_blog_signup'), 20, 5);
@@ -50,7 +49,7 @@ class MC4WP_Lite_Checkbox
50
  }
51
 
52
  /* bbPress actions */
53
- if($opts['checkbox_show_at_bbpress_forms']) {
54
  add_action('bbp_theme_after_topic_form_subscriptions', array($this, 'output_checkbox'), 10);
55
  add_action('bbp_theme_after_reply_form_subscription', array($this, 'output_checkbox'), 10);
56
  add_action('bbp_theme_anonymous_form_extras_bottom', array($this, 'output_checkbox'), 10);
@@ -59,12 +58,18 @@ class MC4WP_Lite_Checkbox
59
  }
60
 
61
  /* Other actions... catch-all */
62
- if($opts['checkbox_show_at_other_forms']) {
63
  add_action('init', array($this, 'subscribe_from_whatever'));
64
  }
65
 
66
  }
67
 
 
 
 
 
 
 
68
  public function on_init()
69
  {
70
  if(function_exists("wpcf7_add_shortcode")) {
@@ -75,9 +80,9 @@ class MC4WP_Lite_Checkbox
75
 
76
  public function get_checkbox($args = array())
77
  {
78
- $opts = $this->options;
79
- $label = isset($args['labels'][0]) ? $args['labels'][0] : $opts['checkbox_label'];
80
- $checked = $opts['checkbox_precheck'] ? "checked" : '';
81
  $content = "\n<!-- Checkbox by MailChimp for WP plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/ -->\n";
82
  $content .= '<p id="mc4wp-checkbox">';
83
  $content .= '<input type="checkbox" name="mc4wp-do-subscribe" id="mc4wp-checkbox-input" value="1" '. $checked . ' />';
@@ -96,7 +101,7 @@ class MC4WP_Lite_Checkbox
96
 
97
  public function load_stylesheet()
98
  {
99
- wp_enqueue_style( 'mc4wp-checkbox-reset', plugins_url('mailchimp-for-wp/css/checkbox.css') );
100
  }
101
 
102
 
@@ -295,10 +300,10 @@ class MC4WP_Lite_Checkbox
295
 
296
  public function subscribe($email, array $merge_vars = array())
297
  {
298
- $api = MC4WP_Lite::instance()->get_mailchimp_api();
299
- $opts = $this->options;
300
 
301
- $lists = $opts['checkbox_lists'];
302
 
303
  if(empty($lists)) {
304
  return 'no_lists_selected';
@@ -318,20 +323,25 @@ class MC4WP_Lite_Checkbox
318
  }
319
 
320
  foreach($lists as $list) {
321
- $result = $api->listSubscribe($list, $email, $merge_vars, 'html', $opts['checkbox_double_optin']);
322
- }
323
-
324
- if($api->errorCode) {
325
-
326
- if($api->errorCode == 214) {
327
- return 'already_subscribed';
328
- }
329
-
330
- return 'error';
331
  }
332
 
333
- // flawed
334
- // this will only return the result of the last list a subscribe attempt has been sent to
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  return $result;
336
  }
337
 
2
 
3
  class MC4WP_Lite_Checkbox
4
  {
 
5
  private $showed_checkbox = false;
6
 
7
  public function __construct()
8
  {
9
+ $opts = $this->get_options();
10
 
11
  add_action('init', array($this, 'on_init'));
12
 
13
  // load checkbox css if necessary
14
+ if($opts['css'] == 1) {
15
  add_action( 'wp_enqueue_scripts', array($this, 'load_stylesheet') );
16
  add_action( 'login_enqueue_scripts', array($this, 'load_stylesheet') );
17
  }
18
 
19
  /* Comment Form Actions */
20
+ if($opts['show_at_comment_form']) {
21
  // hooks for checking if we should subscribe the commenter
22
  add_action('comment_post', array($this, 'subscribe_from_comment'), 20, 2);
23
 
27
  }
28
 
29
  /* Registration Form Actions */
30
+ if($opts['show_at_registration_form']) {
31
  add_action('register_form',array($this, 'output_checkbox'),20);
32
  add_action('user_register',array($this, 'subscribe_from_registration'), 80, 1);
33
  }
34
 
35
  /* BuddyPress Form Actions */
36
+ if($opts['show_at_buddypress_form']) {
37
  add_action('bp_before_registration_submit_buttons', array($this, 'output_checkbox'), 20);
38
  add_action('bp_complete_signup', array($this, 'subscribe_from_buddypress'), 20);
39
  }
40
 
41
  /* Multisite Form Actions */
42
+ if($opts['show_at_multisite_form']) {
43
  add_action('signup_extra_fields', array($this, 'output_checkbox'), 20);
44
  add_action('signup_blogform', array($this, 'add_multisite_hidden_checkbox'), 20);
45
  add_action('wpmu_activate_blog', array($this, 'on_multisite_blog_signup'), 20, 5);
49
  }
50
 
51
  /* bbPress actions */
52
+ if($opts['show_at_bbpress_forms']) {
53
  add_action('bbp_theme_after_topic_form_subscriptions', array($this, 'output_checkbox'), 10);
54
  add_action('bbp_theme_after_reply_form_subscription', array($this, 'output_checkbox'), 10);
55
  add_action('bbp_theme_anonymous_form_extras_bottom', array($this, 'output_checkbox'), 10);
58
  }
59
 
60
  /* Other actions... catch-all */
61
+ if($opts['show_at_other_forms']) {
62
  add_action('init', array($this, 'subscribe_from_whatever'));
63
  }
64
 
65
  }
66
 
67
+ public function get_options()
68
+ {
69
+ $options = MC4WP_Lite::instance()->get_options();
70
+ return $options['checkbox'];
71
+ }
72
+
73
  public function on_init()
74
  {
75
  if(function_exists("wpcf7_add_shortcode")) {
80
 
81
  public function get_checkbox($args = array())
82
  {
83
+ $opts = $this->get_options();
84
+ $label = isset($args['labels'][0]) ? $args['labels'][0] : $opts['label'];
85
+ $checked = $opts['precheck'] ? "checked" : '';
86
  $content = "\n<!-- Checkbox by MailChimp for WP plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/ -->\n";
87
  $content .= '<p id="mc4wp-checkbox">';
88
  $content .= '<input type="checkbox" name="mc4wp-do-subscribe" id="mc4wp-checkbox-input" value="1" '. $checked . ' />';
101
 
102
  public function load_stylesheet()
103
  {
104
+ wp_enqueue_style( 'mc4wp-checkbox-reset', plugins_url('mailchimp-for-wp/assets/css/checkbox.css') );
105
  }
106
 
107
 
300
 
301
  public function subscribe($email, array $merge_vars = array())
302
  {
303
+ $api = MC4WP_Lite::api();
304
+ $opts = $this->get_options();
305
 
306
+ $lists = $opts['lists'];
307
 
308
  if(empty($lists)) {
309
  return 'no_lists_selected';
323
  }
324
 
325
  foreach($lists as $list) {
326
+ $result = $api->subscribe($list, $email, $merge_vars, 'html', $opts['double_optin']);
 
 
 
 
 
 
 
 
 
327
  }
328
 
329
+ // check if result succeeded, show debug message to administrators
330
+ if($result !== true && $api->has_error() && current_user_can('manage_options'))
331
+ {
332
+ wp_die("
333
+ <h3>MailChimp for WP - Error</h3>
334
+ <p>The MailChimp server returned the following error message as a response to our sign-up request:</p>
335
+ <pre>" . $api->get_error_message() . "</pre>
336
+ <p>This is the data that was sent to MailChimp: </p>
337
+ <strong>Email</strong>
338
+ <pre>{$email}</pre>
339
+ <strong>Merge variables</strong>
340
+ <pre>" . print_r($merge_vars, true) . "</pre>
341
+ <p style=\"font-style:italic; font-size:12px; \">This message is only visible to administrators for debugging purposes.</p>
342
+ ", "Error - MailChimp for WP", array('back_link' => true));
343
+ }
344
+
345
  return $result;
346
  }
347
 
includes/MC4WP_Lite_Form.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  class MC4WP_Lite_Form
4
  {
5
- private $options;
6
  private $form_instance_number = 1;
7
  private $error = null;
8
  private $success = false;
@@ -10,9 +9,9 @@ class MC4WP_Lite_Form
10
 
11
  public function __construct()
12
  {
13
- $this->options = $opts = MC4WP_Lite::instance()->get_options();
14
 
15
- if($opts['form_css']) {
16
  add_action( 'wp_enqueue_scripts', array($this, 'load_stylesheet') );
17
  }
18
 
@@ -26,18 +25,22 @@ class MC4WP_Lite_Form
26
  $this->ensure_backwards_compatibility();
27
  add_action('init', array($this, 'submit'));
28
  }
 
29
 
30
-
 
 
 
31
  }
32
 
33
  public function load_stylesheet()
34
  {
35
- wp_enqueue_style( 'mc4wp-form-reset', plugins_url('mailchimp-for-wp/css/form.css') );
36
  }
37
 
38
  public function output_form($atts, $content = null)
39
  {
40
- $opts = $this->options;
41
 
42
  // add some useful css classes
43
  $css_classes = ' ';
@@ -47,10 +50,9 @@ class MC4WP_Lite_Form
47
  $content = "\n<!-- Form by MailChimp for WP plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/ -->\n";
48
  $content .= '<form method="post" action="'. $this->get_current_url() .'#mc4wp-form-'. $this->form_instance_number .'" id="mc4wp-form-'.$this->form_instance_number.'" class="mc4wp-form form'.$css_classes.'">';
49
 
50
-
51
  // maybe hide the form
52
- if(!($this->success && $opts['form_hide_after_success'])) {
53
- $form_markup = __($this->options['form_markup']);
54
  // replace special values
55
  $form_markup = $this->replace_form_variables($form_markup);
56
 
@@ -62,27 +64,26 @@ class MC4WP_Lite_Form
62
  $content .= '<input type="hidden" name="mc4wp_form_instance" value="'. $this->form_instance_number .'" />';
63
  }
64
 
65
-
66
  if($this->form_instance_number == $this->submitted_form_instance) {
67
 
68
  if($this->success) {
69
- $content .= '<div class="mc4wp-alert mc4wp-success">' . __($opts['form_text_success']) . '</div>';
70
  } elseif($this->error) {
71
 
72
- $api = MC4WP_Lite::instance()->get_mailchimp_api();
73
  $e = $this->error;
74
 
75
  if($e == 'already_subscribed') {
76
- $text = (empty($opts['form_text_already_subscribed'])) ? $api->errorMessage : $opts['form_text_already_subscribed'];
77
  $content .= '<div class="mc4wp-alert mc4wp-notice">'. __($text) .'</div>';
78
- } elseif(isset($opts['form_text_' . $e]) && !empty($opts['form_text_'. $e] )) {
79
- $content .= '<div class="mc4wp-alert mc4wp-error">' . __($opts['form_text_' . $e]) . '</div>';
80
  }
81
 
82
  if(current_user_can('manage_options')) {
83
 
84
- if($api->errorCode && !empty($api->errorMessage)) {
85
- $content .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> '. $api->errorMessage . '</div>';
86
  }
87
  }
88
 
@@ -90,8 +91,8 @@ class MC4WP_Lite_Form
90
  // endif
91
  }
92
 
93
- if(current_user_can('manage_options') && empty($opts['form_lists'])) {
94
- $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="'. get_admin_url(null, 'admin.php?page=mailchimp-for-wp&tab=form-settings') .'">Edit your form settings</a> and select at least 1 list.</div>';
95
  }
96
 
97
  $content .= "</form>";
@@ -105,7 +106,7 @@ class MC4WP_Lite_Form
105
 
106
  public function submit()
107
  {
108
- $opts = $this->options;
109
  $this->submitted_form_instance = (int) $_POST['mc4wp_form_instance'];
110
 
111
  if(!isset($_POST['EMAIL']) || !is_email($_POST['EMAIL'])) {
@@ -174,8 +175,8 @@ class MC4WP_Lite_Form
174
  $this->success = true;
175
 
176
  // check if we want to redirect the visitor
177
- if(!empty($opts['form_redirect'])) {
178
- wp_redirect($opts['form_redirect']);
179
  exit;
180
  }
181
 
@@ -272,10 +273,10 @@ class MC4WP_Lite_Form
272
 
273
  public function subscribe($email, array $merge_vars = array())
274
  {
275
- $api = MC4WP_Lite::instance()->get_mailchimp_api();
276
- $opts = $this->options;
277
 
278
- $lists = $opts['form_lists'];
279
 
280
  if(empty($lists)) {
281
  return 'no_lists_selected';
@@ -295,16 +296,14 @@ class MC4WP_Lite_Form
295
  }
296
 
297
  foreach($lists as $list) {
298
- $result = $api->listSubscribe($list, $email, $merge_vars, 'html', $opts['form_double_optin']);
299
  }
300
 
301
- if($api->errorCode) {
302
-
303
- if($api->errorCode == 214) {
304
- return 'already_subscribed';
305
- }
306
-
307
- return 'error';
308
  }
309
 
310
  // flawed
@@ -335,4 +334,4 @@ class MC4WP_Lite_Form
335
  return $markup;
336
  }
337
 
338
- }
2
 
3
  class MC4WP_Lite_Form
4
  {
 
5
  private $form_instance_number = 1;
6
  private $error = null;
7
  private $success = false;
9
 
10
  public function __construct()
11
  {
12
+ $opts = $this->get_options();
13
 
14
+ if($opts['css']) {
15
  add_action( 'wp_enqueue_scripts', array($this, 'load_stylesheet') );
16
  }
17
 
25
  $this->ensure_backwards_compatibility();
26
  add_action('init', array($this, 'submit'));
27
  }
28
+ }
29
 
30
+ public function get_options()
31
+ {
32
+ $options = MC4WP_Lite::instance()->get_options();
33
+ return $options['form'];
34
  }
35
 
36
  public function load_stylesheet()
37
  {
38
+ wp_enqueue_style( 'mc4wp-form-reset', plugins_url('mailchimp-for-wp/assets/css/form.css') );
39
  }
40
 
41
  public function output_form($atts, $content = null)
42
  {
43
+ $opts = $this->get_options();
44
 
45
  // add some useful css classes
46
  $css_classes = ' ';
50
  $content = "\n<!-- Form by MailChimp for WP plugin v". MC4WP_LITE_VERSION ." - http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/ -->\n";
51
  $content .= '<form method="post" action="'. $this->get_current_url() .'#mc4wp-form-'. $this->form_instance_number .'" id="mc4wp-form-'.$this->form_instance_number.'" class="mc4wp-form form'.$css_classes.'">';
52
 
 
53
  // maybe hide the form
54
+ if(!($this->success && $opts['hide_after_success'])) {
55
+ $form_markup = __($opts['markup']);
56
  // replace special values
57
  $form_markup = $this->replace_form_variables($form_markup);
58
 
64
  $content .= '<input type="hidden" name="mc4wp_form_instance" value="'. $this->form_instance_number .'" />';
65
  }
66
 
 
67
  if($this->form_instance_number == $this->submitted_form_instance) {
68
 
69
  if($this->success) {
70
+ $content .= '<div class="mc4wp-alert mc4wp-success">' . __($opts['text_success']) . '</div>';
71
  } elseif($this->error) {
72
 
73
+ $api = MC4WP_Lite::api();
74
  $e = $this->error;
75
 
76
  if($e == 'already_subscribed') {
77
+ $text = (empty($opts['text_already_subscribed'])) ? $api->get_error_message() : $opts['text_already_subscribed'];
78
  $content .= '<div class="mc4wp-alert mc4wp-notice">'. __($text) .'</div>';
79
+ } elseif(isset($opts['text_' . $e]) && !empty($opts['text_'. $e] )) {
80
+ $content .= '<div class="mc4wp-alert mc4wp-error">' . __($opts['text_' . $e]) . '</div>';
81
  }
82
 
83
  if(current_user_can('manage_options')) {
84
 
85
+ if($api->has_error()) {
86
+ $content .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> '. $api->get_error_message() . '</div>';
87
  }
88
  }
89
 
91
  // endif
92
  }
93
 
94
+ if(current_user_can('manage_options') && empty($opts['lists'])) {
95
+ $content .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> you have not selected a MailChimp list for this sign-up form to subscribe to yet. <a href="'. admin_url('admin.php?page=mc4wp-lite-form-settings') .'">Edit your form settings</a> and select at least 1 list.</div>';
96
  }
97
 
98
  $content .= "</form>";
106
 
107
  public function submit()
108
  {
109
+ $opts = $this->get_options();
110
  $this->submitted_form_instance = (int) $_POST['mc4wp_form_instance'];
111
 
112
  if(!isset($_POST['EMAIL']) || !is_email($_POST['EMAIL'])) {
175
  $this->success = true;
176
 
177
  // check if we want to redirect the visitor
178
+ if(!empty($opts['redirect'])) {
179
+ wp_redirect($opts['redirect']);
180
  exit;
181
  }
182
 
273
 
274
  public function subscribe($email, array $merge_vars = array())
275
  {
276
+ $api = MC4WP_Lite::api();
277
+ $opts = $this->get_options();
278
 
279
+ $lists = $opts['lists'];
280
 
281
  if(empty($lists)) {
282
  return 'no_lists_selected';
296
  }
297
 
298
  foreach($lists as $list) {
299
+ $result = $api->subscribe($list, $email, $merge_vars, 'html', $opts['double_optin']);
300
  }
301
 
302
+ if($result === true) {
303
+ $this->success = true;
304
+ } else {
305
+ $this->success = false;
306
+ $this->error = $result;
 
 
307
  }
308
 
309
  // flawed
334
  return $markup;
335
  }
336
 
337
+ }
includes/MCAPI.php DELETED
@@ -1,2485 +0,0 @@
1
- <?php
2
-
3
- class MCAPI {
4
- var $version = "1.3";
5
- var $errorMessage;
6
- var $errorCode;
7
-
8
- /**
9
- * Cache the information on the API location on the server
10
- */
11
- var $apiUrl;
12
-
13
- /**
14
- * Default to a 300 second timeout on server calls
15
- */
16
- var $timeout = 300;
17
-
18
- /**
19
- * Default to a 8K chunk size
20
- */
21
- var $chunkSize = 8192;
22
-
23
- /**
24
- * Cache the user api_key so we only have to log in once per client instantiation
25
- */
26
- var $api_key;
27
-
28
- /**
29
- * Cache the user api_key so we only have to log in once per client instantiation
30
- */
31
- var $secure = false;
32
-
33
- /**
34
- * Connect to the MailChimp API for a given list.
35
- *
36
- * @param string $apikey Your MailChimp apikey
37
- * @param string $secure Whether or not this should use a secure connection
38
- */
39
- function MCAPI($apikey, $secure=false) {
40
- $this->secure = $secure;
41
- $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
42
- $this->api_key = $apikey;
43
- }
44
- function setTimeout($seconds){
45
- if (is_int($seconds)){
46
- $this->timeout = $seconds;
47
- return true;
48
- }
49
- }
50
- function getTimeout(){
51
- return $this->timeout;
52
- }
53
- function useSecure($val){
54
- if ($val===true){
55
- $this->secure = true;
56
- } else {
57
- $this->secure = false;
58
- }
59
- }
60
-
61
- /**
62
- * Unschedule a campaign that is scheduled to be sent in the future
63
- *
64
- * @section Campaign Related
65
- * @example mcapi_campaignUnschedule.php
66
- * @example xml-rpc_campaignUnschedule.php
67
- *
68
- * @param string $cid the id of the campaign to unschedule
69
- * @return boolean true on success
70
- */
71
- function campaignUnschedule($cid) {
72
- $params = array();
73
- $params["cid"] = $cid;
74
- return $this->callServer("campaignUnschedule", $params);
75
- }
76
-
77
- /**
78
- * Schedule a campaign to be sent in the future
79
- *
80
- * @section Campaign Related
81
- * @example mcapi_campaignSchedule.php
82
- * @example xml-rpc_campaignSchedule.php
83
- *
84
- * @param string $cid the id of the campaign to schedule
85
- * @param string $schedule_time the time to schedule the campaign. For A/B Split "schedule" campaigns, the time for Group A - in YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
86
- * @param string $schedule_time_b optional -the time to schedule Group B of an A/B Split "schedule" campaign - in YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
87
- * @return boolean true on success
88
- */
89
- function campaignSchedule($cid, $schedule_time, $schedule_time_b=NULL) {
90
- $params = array();
91
- $params["cid"] = $cid;
92
- $params["schedule_time"] = $schedule_time;
93
- $params["schedule_time_b"] = $schedule_time_b;
94
- return $this->callServer("campaignSchedule", $params);
95
- }
96
-
97
- /**
98
- * Resume sending an AutoResponder or RSS campaign
99
- *
100
- * @section Campaign Related
101
- *
102
- * @param string $cid the id of the campaign to pause
103
- * @return boolean true on success
104
- */
105
- function campaignResume($cid) {
106
- $params = array();
107
- $params["cid"] = $cid;
108
- return $this->callServer("campaignResume", $params);
109
- }
110
-
111
- /**
112
- * Pause an AutoResponder orRSS campaign from sending
113
- *
114
- * @section Campaign Related
115
- *
116
- * @param string $cid the id of the campaign to pause
117
- * @return boolean true on success
118
- */
119
- function campaignPause($cid) {
120
- $params = array();
121
- $params["cid"] = $cid;
122
- return $this->callServer("campaignPause", $params);
123
- }
124
-
125
- /**
126
- * Send a given campaign immediately. For RSS campaigns, this will "start" them.
127
- *
128
- * @section Campaign Related
129
- *
130
- * @example mcapi_campaignSendNow.php
131
- * @example xml-rpc_campaignSendNow.php
132
- *
133
- * @param string $cid the id of the campaign to send
134
- * @return boolean true on success
135
- */
136
- function campaignSendNow($cid) {
137
- $params = array();
138
- $params["cid"] = $cid;
139
- return $this->callServer("campaignSendNow", $params);
140
- }
141
-
142
- /**
143
- * Send a test of this campaign to the provided email address
144
- *
145
- * @section Campaign Related
146
- *
147
- * @example mcapi_campaignSendTest.php
148
- * @example xml-rpc_campaignSendTest.php
149
- *
150
- * @param string $cid the id of the campaign to test
151
- * @param array $test_emails an array of email address to receive the test message
152
- * @param string $send_type optional by default (null) both formats are sent - "html" or "text" send just that format
153
- * @return boolean true on success
154
- */
155
- function campaignSendTest($cid, $test_emails=array (
156
- ), $send_type=NULL) {
157
- $params = array();
158
- $params["cid"] = $cid;
159
- $params["test_emails"] = $test_emails;
160
- $params["send_type"] = $send_type;
161
- return $this->callServer("campaignSendTest", $params);
162
- }
163
-
164
- /**
165
- * Allows one to test their segmentation rules before creating a campaign using them
166
- *
167
- * @section Campaign Related
168
- * @example mcapi_campaignSegmentTest.php
169
- * @example xml-rpc_campaignSegmentTest.php
170
- *
171
- * @param string $list_id the list to test segmentation on - get lists using lists()
172
- * @param array $options with 2 keys:
173
- string "match" controls whether to use AND or OR when applying your options - expects "<strong>any</strong>" (for OR) or "<strong>all</strong>" (for AND)
174
- array "conditions" - up to 10 different criteria to apply while segmenting. Each criteria row must contain 3 keys - "<strong>field</strong>", "<strong>op</strong>", and "<strong>value</strong>" - and possibly a fourth, "<strong>extra</strong>", based on these definitions:
175
-
176
- Field = "<strong>date</strong>" : Select based on signup date
177
- Valid Op(eration): <strong>eq</strong> (is) / <strong>gt</strong> (after) / <strong>lt</strong> (before)
178
- Valid Values:
179
- string last_campaign_sent uses the date of the last campaign sent
180
- string campaign_id - uses the send date of the campaign that carriers the Id submitted - see campaigns()
181
- string YYYY-MM-DD - any date in the form of YYYY-MM-DD - <em>note:</em> anything that appears to start with YYYY will be treated as a date
182
-
183
- Field = "<strong>interests-X</strong>": where X is the Grouping Id from listInterestGroupings()
184
- Valid Op(erations): <strong>one</strong> / <strong>none</strong> / <strong>all</strong>
185
- Valid Values: a comma delimited of interest groups for the list - see listInterestGroupings()
186
-
187
- Field = "<strong>aim</strong>"
188
- Valid Op(erations): <strong>open</strong> / <strong>noopen</strong> / <strong>click</strong> / <strong>noclick</strong>
189
- Valid Values: "<strong>any</strong>" or a valid AIM-enabled Campaign that has been sent
190
-
191
- Field = "<strong>rating</strong>" : allows matching based on list member ratings
192
- Valid Op(erations): <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
193
- Valid Values: a number between 0 and 5
194
-
195
- Field = "<strong>ecomm_prod</strong>" or "<strong>ecomm_prod</strong>": allows matching product and category names from purchases
196
- Valid Op(erations):
197
- <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;) / <strong>like</strong> (like '%blah%') / <strong>nlike</strong> (not like '%blah%') / <strong>starts</strong> (like 'blah%') / <strong>ends</strong> (like '%blah')
198
- Valid Values: any string
199
-
200
- Field = "<strong>ecomm_spent_one</strong>" or "<strong>ecomm_spent_all</strong>" : allows matching purchase amounts on a single order or all orders
201
- Valid Op(erations): <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
202
- Valid Values: a number
203
-
204
- Field = "<strong>ecomm_date</strong>" : allow matching based on order dates
205
- Valid Op(eration): <strong>eq</strong> (is) / <strong>gt</strong> (after) / <strong>lt</strong> (before)
206
- Valid Values:
207
- string YYYY-MM-DD - any date in the form of YYYY-MM-DD
208
-
209
- Field = "<strong>social_gender</strong>" : allows matching against the gender acquired from SocialPro
210
- Valid Op(eration): <strong>eq</strong> (is) / <strong>ne</strong> (is not)
211
- Valid Values: male, female
212
-
213
- Field = "<strong>social_age</strong>" : allows matching against the age acquired from SocialPro
214
- Valid Op(erations): <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
215
- Valid Values: any number
216
-
217
- Field = "<strong>social_influence</strong>" : allows matching against the influence acquired from SocialPro
218
- Valid Op(erations): <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
219
- Valid Values: a number between 0 and 5
220
-
221
- Field = "<strong>social_network</strong>" :
222
- Valid Op(erations): <strong>member</strong> (is a member of) / <strong>notmember</strong> (is not a member of)
223
- Valid Values: twitter, facebook, myspace, linkedin, flickr
224
-
225
- Field = "<strong>static_segment</strong>" :
226
- Valid Op(eration): <strong>eq</strong> (is in) / <strong>ne</strong> (is not in)
227
- Valid Values: an int - get from listStaticSegments()
228
-
229
- Field = An <strong>Address</strong> Merge Var. Use <strong>Merge0-Merge30</strong> or the <strong>Custom Tag</strong> you've setup for your merge field - see listMergeVars(). Note, Address fields can still be used with the default operations below - this section is broken out solely to highlight the differences in using the geolocation routines.
230
- Valid Op(erations): <strong>geoin</strong>
231
- Valid Values: The number of miles an address should be within
232
- Extra Value: The Zip Code to be used as the center point
233
-
234
- Default Field = A Merge Var. Use <strong>Merge0-Merge30</strong> or the <strong>Custom Tag</strong> you've setup for your merge field - see listMergeVars()
235
- Valid Op(erations):
236
- <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;) / <strong>like</strong> (like '%blah%') / <strong>nlike</strong> (not like '%blah%') / <strong>starts</strong> (like 'blah%') / <strong>ends</strong> (like '%blah')
237
- Valid Values: any string
238
- * @return int total The total number of subscribers matching your segmentation options
239
- */
240
- function campaignSegmentTest($list_id, $options) {
241
- $params = array();
242
- $params["list_id"] = $list_id;
243
- $params["options"] = $options;
244
- return $this->callServer("campaignSegmentTest", $params);
245
- }
246
-
247
- /**
248
- * Create a new draft campaign to send. You <strong>can not</strong> have more than 32,000 campaigns in your account.
249
- *
250
- * @section Campaign Related
251
- * @example mcapi_campaignCreate.php
252
- * @example xml-rpc_campaignCreate.php
253
- * @example xml-rpc_campaignCreateABSplit.php
254
- * @example xml-rpc_campaignCreateRss.php
255
- *
256
- * @param string $type the Campaign Type to create - one of "regular", "plaintext", "absplit", "rss", "trans", "auto"
257
- * @param array $options a hash of the standard options for this campaign :
258
- string list_id the list to send this campaign to- get lists using lists()
259
- string subject the subject line for your campaign message
260
- string from_email the From: email address for your campaign message
261
- string from_name the From: name for your campaign message (not an email address)
262
- string to_name the To: name recipients will see (not email address)
263
- int template_id optional - use this user-created template to generate the HTML content of the campaign (takes precendence over other template options)
264
- int gallery_template_id optional - use a template from the public gallery to generate the HTML content of the campaign (takes precendence over base template options)
265
- int base_template_id optional - use this a base/start-from-scratch template to generate the HTML content of the campaign
266
- int folder_id optional - automatically file the new campaign in the folder_id passed. Get using folders() - note that Campaigns and Autoresponders have separate folder setupsn
267
- array tracking optional - set which recipient actions will be tracked, as a struct of boolean values with the following keys: "opens", "html_clicks", and "text_clicks". By default, opens and HTML clicks will be tracked. Click tracking can not be disabled for Free accounts.
268
- string title optional - an internal name to use for this campaign. By default, the campaign subject will be used.
269
- boolean authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false.
270
- array analytics optional - if provided, use a struct with "service type" as a key and the "service tag" as a value. For Google, this should be "google"=>"your_google_analytics_key_here". Note that only "google" is currently supported - a Google Analytics tags will be added to all links in the campaign with this string attached. Others may be added in the future
271
- boolean auto_footer optional Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports
272
- boolean inline_css optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false.
273
- boolean generate_text optional Whether of not to auto-generate your Text content from the HTML content. Note that this will be ignored if the Text part of the content passed is not empty, defaults to false.
274
- boolean auto_tweet optional If set, this campaign will be auto-tweeted when it is sent - defaults to false. Note that if a Twitter account isn't linked, this will be silently ignored.
275
- boolean timewarp optional If set, this campaign must be scheduled 24 hours in advance of sending - default to false. Only valid for "regular" campaigns and "absplit" campaigns that split on schedule_time.
276
- boolean ecomm360 optional If set, our <a href="http://www.mailchimp.com/blog/ecommerce-tracking-plugin/" target="_blank">Ecommerce360 tracking</a> will be enabled for links in the campaign
277
-
278
- * @param array $content the content for this campaign - use a struct with the following keys:
279
- string html for pasted HTML content
280
- string text for the plain-text version
281
- string url to have us pull in content from a URL. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
282
- string archive to send a Base64 encoded archive file for us to import all media from. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
283
- string archive_type optional - only necessary for the "archive" option. Supported formats are: zip, tar.gz, tar.bz2, tar, tgz, tbz . If not included, we will default to zip
284
-
285
- If you chose a template instead of pasting in your HTML content, then use "html_" followed by the template sections as keys - for example, use a key of "html_MAIN" to fill in the "MAIN" section of a template. Supported template sections include: "html_HEADER", "html_MAIN", "html_SIDECOLUMN", and "html_FOOTER"
286
- * @param array $segment_opts optional - if you wish to do Segmentation with this campaign this array should contain: see campaignSegmentTest(). It's suggested that you test your options against campaignSegmentTest(). Also, "trans" campaigns <strong>do not</strong> support segmentation.
287
- * @param array $type_opts optional -
288
- For RSS Campaigns this, array should contain:
289
- string url the URL to pull RSS content from - it will be verified and must exist
290
- string schedule optional one of "daily", "weekly", "monthly" - defaults to "daily"
291
- string schedule_hour optional an hour between 0 and 24 - default to 4 (4am <em>local time</em>) - applies to all schedule types
292
- string schedule_weekday optional for "weekly" only, a number specifying the day of the week to send: 0 (Sunday) - 6 (Saturday) - defaults to 1 (Monday)
293
- string schedule_monthday optional for "monthly" only, a number specifying the day of the month to send (1 - 28) or "last" for the last day of a given month. Defaults to the 1st day of the month
294
-
295
- For A/B Split campaigns, this array should contain:
296
- string split_test The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaignSchedule() separately!
297
- string pick_winner How the winner will be picked, one of: "opens" (by the open_rate), "clicks" (by the click rate), "manual" (you pick manually)
298
- int wait_units optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400.
299
- int wait_time optional the number of units to wait before auto-selecting a winner - defaults to 1, so if not set, a winner will be selected after 1 Day.
300
- int split_size optional this is a percentage of what size the Campaign's List plus any segmentation options results in. "schedule" type forces 50%, all others default to 10%
301
- string from_name_a optional sort of, required when split_test is "from_name"
302
- string from_name_b optional sort of, required when split_test is "from_name"
303
- string from_email_a optional sort of, required when split_test is "from_name"
304
- string from_email_b optional sort of, required when split_test is "from_name"
305
- string subject_a optional sort of, required when split_test is "subject"
306
- string subject_b optional sort of, required when split_test is "subject"
307
-
308
- For AutoResponder campaigns, this array should contain:
309
- string offset-units one of "day", "week", "month", "year" - required
310
- string offset-time optional, sort of - the number of units must be a number greater than 0 for signup based autoresponders
311
- string offset-dir either "before" or "after"
312
- string event optional "signup" (default) to base this on double-optin signup, "date" or "annual" to base this on merge field in the list
313
- string event-datemerge optional sort of, this is required if the event is "date" or "annual"
314
-
315
- *
316
- * @return string the ID for the created campaign
317
- */
318
- function campaignCreate($type, $options, $content, $segment_opts=NULL, $type_opts=NULL) {
319
- $params = array();
320
- $params["type"] = $type;
321
- $params["options"] = $options;
322
- $params["content"] = $content;
323
- $params["segment_opts"] = $segment_opts;
324
- $params["type_opts"] = $type_opts;
325
- return $this->callServer("campaignCreate", $params);
326
- }
327
-
328
- /** Update just about any setting for a campaign that has <em>not</em> been sent. See campaignCreate() for details.
329
- *
330
- *
331
- * Caveats:<br/><ul>
332
- * <li>If you set list_id, all segmentation options will be deleted and must be re-added.</li>
333
- * <li>If you set template_id, you need to follow that up by setting it's 'content'</li>
334
- * <li>If you set segment_opts, you should have tested your options against campaignSegmentTest() as campaignUpdate() will not allow you to set a segment that includes no members.</li></ul>
335
- * @section Campaign Related
336
- *
337
- * @example mcapi_campaignUpdate.php
338
- * @example mcapi_campaignUpdateAB.php
339
- * @example xml-rpc_campaignUpdate.php
340
- * @example xml-rpc_campaignUpdateAB.php
341
- *
342
- * @param string $cid the Campaign Id to update
343
- * @param string $name the parameter name ( see campaignCreate() ). For items in the <strong>options</strong> array, this will be that parameter's name (subject, from_email, etc.). Additional parameters will be that option name (content, segment_opts). "type_opts" will be the name of the type - rss, auto, trans, etc.
344
- * @param mixed $value an appropriate value for the parameter ( see campaignCreate() ). For items in the <strong>options</strong> array, this will be that parameter's value. For additional parameters, this is the same value passed to them.
345
- * @return boolean true if the update succeeds, otherwise an error will be thrown
346
- */
347
- function campaignUpdate($cid, $name, $value) {
348
- $params = array();
349
- $params["cid"] = $cid;
350
- $params["name"] = $name;
351
- $params["value"] = $value;
352
- return $this->callServer("campaignUpdate", $params);
353
- }
354
-
355
- /** Replicate a campaign.
356
- *
357
- * @section Campaign Related
358
- *
359
- * @example mcapi_campaignReplicate.php
360
- *
361
- * @param string $cid the Campaign Id to replicate
362
- * @return string the id of the replicated Campaign created, otherwise an error will be thrown
363
- */
364
- function campaignReplicate($cid) {
365
- $params = array();
366
- $params["cid"] = $cid;
367
- return $this->callServer("campaignReplicate", $params);
368
- }
369
-
370
- /** Delete a campaign. Seriously, "poof, gone!" - be careful!
371
- *
372
- * @section Campaign Related
373
- *
374
- * @example mcapi_campaignDelete.php
375
- *
376
- * @param string $cid the Campaign Id to delete
377
- * @return boolean true if the delete succeeds, otherwise an error will be thrown
378
- */
379
- function campaignDelete($cid) {
380
- $params = array();
381
- $params["cid"] = $cid;
382
- return $this->callServer("campaignDelete", $params);
383
- }
384
-
385
- /**
386
- * Get the list of campaigns and their details matching the specified filters
387
- *
388
- * @section Campaign Related
389
- * @example mcapi_campaigns.php
390
- * @example xml-rpc_campaigns.php
391
- *
392
- * @param array $filters a hash of filters to apply to this query - all are optional:
393
- string campaign_id optional - return a single campaign using a know campaign_id
394
- string list_id optional - the list to send this campaign to- get lists using lists(). Accepts multiples separated by commas when not using exact matching.
395
- int folder_id optional - only show campaigns from this folder id - get folders using campaignFolders(). Accepts multiples separated by commas when not using exact matching.
396
- int template_id optional - only show campaigns using this template id - get templates using templates(). Accepts multiples separated by commas when not using exact matching.
397
- string status optional - return campaigns of a specific status - one of "sent", "save", "paused", "schedule", "sending". Accepts multiples separated by commas when not using exact matching.
398
- string type optional - return campaigns of a specific type - one of "regular", "plaintext", "absplit", "rss", "trans", "auto". Accepts multiples separated by commas when not using exact matching.
399
- string from_name optional - only show campaigns that have this "From Name"
400
- string from_email optional - only show campaigns that have this "Reply-to Email"
401
- string title optional - only show campaigns that have this title
402
- string subject optional - only show campaigns that have this subject
403
- string sendtime_start optional - only show campaigns that have been sent since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
404
- string sendtime_end optional - only show campaigns that have been sent before this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
405
- boolean exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true. Using this disables the use of any filters that accept multiples.
406
- * @param int $start optional - control paging of campaigns, start results at this campaign #, defaults to 1st page of data (page 0)
407
- * @param int $limit optional - control paging of campaigns, number of campaigns to return with each call, defaults to 25 (max=1000)
408
- * @return array an array containing a count of all matching campaigns and the specific ones for the current page (see Returned Fields for description)
409
- * @returnf int total the total number of campaigns matching the filters passed in
410
- * @returnf array data the data for each campaign being returned
411
- string id Campaign Id (used for all other campaign functions)
412
- int web_id The Campaign id used in our web app, allows you to create a link directly to it
413
- string list_id The List used for this campaign
414
- int folder_id The Folder this campaign is in
415
- int template_id The Template this campaign uses
416
- string content_type How the campaign's content is put together - one of 'template', 'html', 'url'
417
- string title Title of the campaign
418
- string type The type of campaign this is (regular,plaintext,absplit,rss,inspection,trans,auto)
419
- string create_time Creation time for the campaign
420
- string send_time Send time for the campaign - also the scheduled time for scheduled campaigns.
421
- int emails_sent Number of emails email was sent to
422
- string status Status of the given campaign (save,paused,schedule,sending,sent)
423
- string from_name From name of the given campaign
424
- string from_email Reply-to email of the given campaign
425
- string subject Subject of the given campaign
426
- string to_name Custom "To:" email string using merge variables
427
- string archive_url Archive link for the given campaign
428
- boolean inline_css Whether or not the campaign content's css was auto-inlined
429
- string analytics Either "google" if enabled or "N" if disabled
430
- string analytics_tag The name/tag the campaign's links were tagged with if analytics were enabled.
431
- boolean authenticate Whether or not the campaign was authenticated
432
- boolean ecomm360 Whether or not ecomm360 tracking was appended to links
433
- boolean auto_tweet Whether or not the campaign was auto tweeted after sending
434
- string auto_fb_post A comma delimited list of Facebook Profile/Page Ids the campaign was posted to after sending. If not used, blank.
435
- boolean auto_footer Whether or not the auto_footer was manually turned on
436
- boolean timewarp Whether or not the campaign used Timewarp
437
- boolean timewarp_schedule The time, in GMT, that the Timewarp campaign is being sent. For A/B Split campaigns, this is blank and is instead in their schedule_a and schedule_b in the type_opts array
438
- array tracking containing "text_clicks", "html_clicks", and "opens" as boolean values representing whether or not they were enabled
439
- string segment_text a string marked-up with HTML explaining the segment used for the campaign in plain English
440
- array segment_opts the segment used for the campaign - can be passed to campaignSegmentTest() or campaignCreate()
441
- array type_opts the type-specific options for the campaign - can be passed to campaignCreate()
442
- */
443
- function campaigns($filters=array (
444
- ), $start=0, $limit=25) {
445
- $params = array();
446
- $params["filters"] = $filters;
447
- $params["start"] = $start;
448
- $params["limit"] = $limit;
449
- return $this->callServer("campaigns", $params);
450
- }
451
-
452
- /**
453
- * Given a list and a campaign, get all the relevant campaign statistics (opens, bounces, clicks, etc.)
454
- *
455
- * @section Campaign Stats
456
- *
457
- * @example mcapi_campaignStats.php
458
- * @example xml-rpc_campaignStats.php
459
- *
460
- * @param string $cid the campaign id to pull stats for (can be gathered using campaigns())
461
- * @return array struct of the statistics for this campaign
462
- * @returnf int syntax_errors Number of email addresses in campaign that had syntactical errors.
463
- * @returnf int hard_bounces Number of email addresses in campaign that hard bounced.
464
- * @returnf int soft_bounces Number of email addresses in campaign that soft bounced.
465
- * @returnf int unsubscribes Number of email addresses in campaign that unsubscribed.
466
- * @returnf int abuse_reports Number of email addresses in campaign that reported campaign for abuse.
467
- * @returnf int forwards Number of times email was forwarded to a friend.
468
- * @returnf int forwards_opens Number of times a forwarded email was opened.
469
- * @returnf int opens Number of times the campaign was opened.
470
- * @returnf date last_open Date of the last time the email was opened.
471
- * @returnf int unique_opens Number of people who opened the campaign.
472
- * @returnf int clicks Number of times a link in the campaign was clicked.
473
- * @returnf int unique_clicks Number of unique recipient/click pairs for the campaign.
474
- * @returnf date last_click Date of the last time a link in the email was clicked.
475
- * @returnf int users_who_clicked Number of unique recipients who clicked on a link in the campaign.
476
- * @returnf int emails_sent Number of email addresses campaign was sent to.
477
- * @returnf array absplit If this was an absplit campaign, stats for the A and B groups will be returned
478
- int bounces_a bounces for the A group
479
- int bounces_b bounces for the B group
480
- int forwards_a forwards for the A group
481
- int forwards_b forwards for the B group
482
- int abuse_reports_a abuse reports for the A group
483
- int abuse_reports_b abuse reports for the B group
484
- int unsubs_a unsubs for the A group
485
- int unsubs_b unsubs for the B group
486
- int recipients_click_a clicks for the A group
487
- int recipients_click_b clicks for the B group
488
- int forwards_opens_a opened forwards for the A group
489
- int forwards_opens_b opened forwards for the A group
490
- * @returnf array timewarp If this campaign was a Timewarp campaign, an array of stats from each timezone for it, with the GMT offset as they key. Each timezone will contain:
491
- int opens opens for this timezone
492
- string last_open the date/time of the last open for this timezone
493
- int unique_opens the unique opens for this timezone
494
- int clicks the total clicks for this timezone
495
- string last_click the date/time of the last click for this timezone
496
- int unique_opens the unique clicks for this timezone
497
- int bounces the total bounces for this timezone
498
- int total the total number of members sent to in this timezone
499
- int sent the total number of members delivered to in this timezone
500
- */
501
- function campaignStats($cid) {
502
- $params = array();
503
- $params["cid"] = $cid;
504
- return $this->callServer("campaignStats", $params);
505
- }
506
-
507
- /**
508
- * Get an array of the urls being tracked, and their click counts for a given campaign
509
- *
510
- * @section Campaign Stats
511
- *
512
- * @example mcapi_campaignClickStats.php
513
- * @example xml-rpc_campaignClickStats.php
514
- *
515
- * @param string $cid the campaign id to pull stats for (can be gathered using campaigns())
516
- * @return struct urls will be keys and contain their associated statistics:
517
- * @returnf int clicks Number of times the specific link was clicked
518
- * @returnf int unique Number of unique people who clicked on the specific link
519
- */
520
- function campaignClickStats($cid) {
521
- $params = array();
522
- $params["cid"] = $cid;
523
- return $this->callServer("campaignClickStats", $params);
524
- }
525
-
526
- /**
527
- * Get the top 5 performing email domains for this campaign. Users want more than 5 should use campaign campaignEmailStatsAIM()
528
- * or campaignEmailStatsAIMAll() and generate any additional stats they require.
529
- *
530
- * @section Campaign Stats
531
- *
532
- * @example mcapi_campaignEmailDomainPerformance.php
533
- *
534
- * @param string $cid the campaign id to pull email domain performance for (can be gathered using campaigns())
535
- * @return array domains email domains and their associated stats
536
- * @returnf string domain Domain name or special "Other" to roll-up stats past 5 domains
537
- * @returnf int total_sent Total Email across all domains - this will be the same in every row
538
- * @returnf int emails Number of emails sent to this domain
539
- * @returnf int bounces Number of bounces
540
- * @returnf int opens Number of opens
541
- * @returnf int clicks Number of clicks
542
- * @returnf int unsubs Number of unsubs
543
- * @returnf int delivered Number of deliveries
544
- * @returnf int emails_pct Percentage of emails that went to this domain (whole number)
545
- * @returnf int bounces_pct Percentage of bounces from this domain (whole number)
546
- * @returnf int opens_pct Percentage of opens from this domain (whole number)
547
- * @returnf int clicks_pct Percentage of clicks from this domain (whole number)
548
- * @returnf int unsubs_pct Percentage of unsubs from this domain (whole number)
549
- */
550
- function campaignEmailDomainPerformance($cid) {
551
- $params = array();
552
- $params["cid"] = $cid;
553
- return $this->callServer("campaignEmailDomainPerformance", $params);
554
- }
555
-
556
- /**
557
- * Get all email addresses the campaign was successfully sent to (ie, no bounces)
558
- *
559
- * @section Campaign Stats
560
- *
561
- * @param string $cid the campaign id to pull members for (can be gathered using campaigns())
562
- * @param string $status optional the status to pull - one of 'sent', 'hard' (bounce), or 'soft' (bounce). By default, all records are returned
563
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
564
- * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
565
- * @return array a total of all matching emails and the specific emails for this page
566
- * @returnf int total the total number of members for the campaign and status
567
- * @returnf array data the full campaign member records
568
- string email the email address sent to
569
- string status the status of the send - one of 'sent', 'hard', 'soft'
570
- string absplit_group if this was an absplit campaign, one of 'a','b', or 'winner'
571
- string tz_group if this was an timewarp campaign the timezone GMT offset the member was included in
572
- */
573
- function campaignMembers($cid, $status=NULL, $start=0, $limit=1000) {
574
- $params = array();
575
- $params["cid"] = $cid;
576
- $params["status"] = $status;
577
- $params["start"] = $start;
578
- $params["limit"] = $limit;
579
- return $this->callServer("campaignMembers", $params);
580
- }
581
-
582
- /**
583
- * <strong>DEPRECATED</strong> Get all email addresses with Hard Bounces for a given campaign
584
- *
585
- * @deprecated See campaignMembers() for a replacement
586
- *
587
- * @section Campaign Stats
588
- *
589
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
590
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
591
- * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
592
- * @return array a total of all hard bounced emails and the specific emails for this page
593
- * @returnf int total the total number of hard bounces for the campaign
594
- * @returnf array data the full email addresses that bounced
595
- string email the email address that bounced
596
- */
597
- function campaignHardBounces($cid, $start=0, $limit=1000) {
598
- $params = array();
599
- $params["cid"] = $cid;
600
- $params["start"] = $start;
601
- $params["limit"] = $limit;
602
- return $this->callServer("campaignHardBounces", $params);
603
- }
604
-
605
- /**
606
- * <strong>DEPRECATED</strong> Get all email addresses with Soft Bounces for a given campaign
607
- *
608
- * @deprecated See campaignMembers() for a replacement
609
- *
610
- * @section Campaign Stats
611
- *
612
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
613
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
614
- * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
615
- * @return array a total of all soft bounced emails and the specific emails for this page
616
- * @returnf int total the total number of soft bounces for the campaign
617
- * @returnf array data the full email addresses that bounced
618
- string email the email address that bounced
619
- */
620
- function campaignSoftBounces($cid, $start=0, $limit=1000) {
621
- $params = array();
622
- $params["cid"] = $cid;
623
- $params["start"] = $start;
624
- $params["limit"] = $limit;
625
- return $this->callServer("campaignSoftBounces", $params);
626
- }
627
-
628
- /**
629
- * Get all unsubscribed email addresses for a given campaign
630
- *
631
- * @section Campaign Stats
632
- *
633
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
634
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
635
- * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
636
- * @return array email addresses that unsubscribed from this campaign along with reasons, if given
637
- * @return array a total of all unsubscribed emails and the specific emails for this page
638
- * @returnf int total the total number of unsubscribes for the campaign
639
- * @returnf array data the full email addresses that unsubscribed
640
- string email the email address that unsubscribed
641
- string reason For unsubscribes only - the reason collected for the unsubscribe. If populated, one of 'NORMAL','NOSIGNUP','INAPPROPRIATE','SPAM','OTHER'
642
- string reason_text For unsubscribes only - if the reason is OTHER, the text entered.
643
- */
644
- function campaignUnsubscribes($cid, $start=0, $limit=1000) {
645
- $params = array();
646
- $params["cid"] = $cid;
647
- $params["start"] = $start;
648
- $params["limit"] = $limit;
649
- return $this->callServer("campaignUnsubscribes", $params);
650
- }
651
-
652
- /**
653
- * Get all email addresses that complained about a given campaign
654
- *
655
- * @section Campaign Stats
656
- *
657
- * @example mcapi_campaignAbuseReports.php
658
- *
659
- * @param string $cid the campaign id to pull abuse reports for (can be gathered using campaigns())
660
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
661
- * @param int $limit optional for large data sets, the number of results to return - defaults to 500, upper limit set at 1000
662
- * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
663
- * @return array reports the abuse reports for this campaign
664
- * @returnf string date date/time the abuse report was received and processed
665
- * @returnf string email the email address that reported abuse
666
- * @returnf string type an internal type generally specifying the orginating mail provider - may not be useful outside of filling report views
667
- */
668
- function campaignAbuseReports($cid, $since=NULL, $start=0, $limit=500) {
669
- $params = array();
670
- $params["cid"] = $cid;
671
- $params["since"] = $since;
672
- $params["start"] = $start;
673
- $params["limit"] = $limit;
674
- return $this->callServer("campaignAbuseReports", $params);
675
- }
676
-
677
- /**
678
- * Retrieve the text presented in our app for how a campaign performed and any advice we may have for you - best
679
- * suited for display in customized reports pages. Note: some messages will contain HTML - clean tags as necessary
680
- *
681
- * @section Campaign Stats
682
- *
683
- * @example mcapi_campaignAdvice.php
684
- *
685
- * @param string $cid the campaign id to pull advice text for (can be gathered using campaigns())
686
- * @return array advice on the campaign's performance
687
- * @returnf msg the advice message
688
- * @returnf type the "type" of the message. one of: negative, positive, or neutral
689
- */
690
- function campaignAdvice($cid) {
691
- $params = array();
692
- $params["cid"] = $cid;
693
- return $this->callServer("campaignAdvice", $params);
694
- }
695
-
696
- /**
697
- * Retrieve the Google Analytics data we've collected for this campaign. Note, requires Google Analytics Add-on to be installed and configured.
698
- *
699
- * @section Campaign Stats
700
- *
701
- * @example mcapi_campaignAnalytics.php
702
- *
703
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
704
- * @return array analytics we've collected for the passed campaign.
705
- * @returnf int visits number of visits
706
- * @returnf int pages number of page views
707
- * @returnf int new_visits new visits recorded
708
- * @returnf int bounces vistors who "bounced" from your site
709
- * @returnf double time_on_site the total time visitors spent on your sites
710
- * @returnf int goal_conversions number of goals converted
711
- * @returnf double goal_value value of conversion in dollars
712
- * @returnf double revenue revenue generated by campaign
713
- * @returnf int transactions number of transactions tracked
714
- * @returnf int ecomm_conversions number Ecommerce transactions tracked
715
- * @returnf array goals an array containing goal names and number of conversions
716
- */
717
- function campaignAnalytics($cid) {
718
- $params = array();
719
- $params["cid"] = $cid;
720
- return $this->callServer("campaignAnalytics", $params);
721
- }
722
-
723
- /**
724
- * Retrieve the countries and number of opens tracked for each. Email address are not returned.
725
- *
726
- * @section Campaign Stats
727
- *
728
- *
729
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
730
- * @return array countries an array of countries where opens occurred
731
- * @returnf string code The ISO3166 2 digit country code
732
- * @returnf string name A version of the country name, if we have it
733
- * @returnf int opens The total number of opens that occurred in the country
734
- * @returnf bool region_detail Whether or not a subsequent call to campaignGeoOpensByCountry() will return anything
735
- */
736
- function campaignGeoOpens($cid) {
737
- $params = array();
738
- $params["cid"] = $cid;
739
- return $this->callServer("campaignGeoOpens", $params);
740
- }
741
-
742
- /**
743
- * Retrieve the regions and number of opens tracked for a certain country. Email address are not returned.
744
- *
745
- * @section Campaign Stats
746
- *
747
- *
748
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
749
- * @param string $code An ISO3166 2 digit country code
750
- * @return array regions an array of regions within the provided country where opens occurred.
751
- * @returnf string code An internal code for the region. When this is blank, it indicates we know the country, but not the region
752
- * @returnf string name The name of the region, if we have one. For blank "code" values, this will be "Rest of Country"
753
- * @returnf int opens The total number of opens that occurred in the country
754
- */
755
- function campaignGeoOpensForCountry($cid, $code) {
756
- $params = array();
757
- $params["cid"] = $cid;
758
- $params["code"] = $code;
759
- return $this->callServer("campaignGeoOpensForCountry", $params);
760
- }
761
-
762
- /**
763
- * Retrieve the tracked eepurl mentions on Twitter
764
- *
765
- * @section Campaign Stats
766
- *
767
- *
768
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
769
- * @return array stats an array containing tweets, retweets, clicks, and referrer related to using the campaign's eepurl
770
- * @returnf array twitter various Twitter related stats
771
- int tweets Total number of tweets seen
772
- string first_tweet date and time of the first tweet seen
773
- string last_tweet date and time of the last tweet seen
774
- int retweets Total number of retweets seen
775
- string first_retweet date and time of the first retweet seen
776
- string last_retweet date and time of the last retweet seen
777
- array statuses an array of statuses recorded inclduing the status, screen_name, status_id, and datetime fields plus an is_retweet flag
778
- * @returnf array clicks stats related to click-throughs on the eepurl
779
- int clicks Total number of clicks seen
780
- string first_click date and time of the first click seen
781
- string last_click date and time of the first click seen
782
- array locations an array of geographic locations including country, region, and total clicks
783
- * @returnf array referrers an array of arrays, each containing
784
- string referrer the referrer, truncated to 100 bytes
785
- int clicks Total number of clicks seen from this referrer
786
- string first_click date and time of the first click seen from this referrer
787
- string last_click date and time of the first click seen from this referrer
788
- */
789
- function campaignEepUrlStats($cid) {
790
- $params = array();
791
- $params["cid"] = $cid;
792
- return $this->callServer("campaignEepUrlStats", $params);
793
- }
794
-
795
- /**
796
- * Retrieve the most recent full bounce message for a specific email address on the given campaign.
797
- * Messages over 30 days old are subject to being removed
798
- *
799
- *
800
- * @section Campaign Stats
801
- *
802
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
803
- * @param string $email the email address or unique id of the member to pull a bounce message for.
804
- * @return array the full bounce message for this email+campaign along with some extra data.
805
- * @returnf string date date/time the bounce was received and processed
806
- * @returnf string email the email address that bounced
807
- * @returnf string message the entire bounce message received
808
- */
809
- function campaignBounceMessage($cid, $email) {
810
- $params = array();
811
- $params["cid"] = $cid;
812
- $params["email"] = $email;
813
- return $this->callServer("campaignBounceMessage", $params);
814
- }
815
-
816
- /**
817
- * Retrieve the full bounce messages for the given campaign. Note that this can return very large amounts
818
- * of data depending on how large the campaign was and how much cruft the bounce provider returned. Also,
819
- * message over 30 days old are subject to being removed
820
- *
821
- * @section Campaign Stats
822
- *
823
- * @example mcapi_campaignBounceMessages.php
824
- *
825
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
826
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
827
- * @param int $limit optional for large data sets, the number of results to return - defaults to 25, upper limit set at 50
828
- * @param string $since optional pull only messages since this time - use YYYY-MM-DD format in <strong>GMT</strong> (we only store the date, not the time)
829
- * @return array bounces the full bounce messages for this campaign
830
- * @returnf int total that total number of bounce messages for the campaign
831
- * @returnf array data an array containing the data for this page
832
- string date date/time the bounce was received and processed
833
- string email the email address that bounced
834
- string message the entire bounce message received
835
- */
836
- function campaignBounceMessages($cid, $start=0, $limit=25, $since=NULL) {
837
- $params = array();
838
- $params["cid"] = $cid;
839
- $params["start"] = $start;
840
- $params["limit"] = $limit;
841
- $params["since"] = $since;
842
- return $this->callServer("campaignBounceMessages", $params);
843
- }
844
-
845
- /**
846
- * Retrieve the Ecommerce Orders tracked by campaignEcommOrderAdd()
847
- *
848
- * @section Campaign Stats
849
- *
850
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
851
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
852
- * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 500
853
- * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
854
- * @return array the total matching orders and the specific orders for the requested page
855
- * @returnf int total the total matching orders
856
- * @returnf array data the actual data for each order being returned
857
- string store_id the store id generated by the plugin used to uniquely identify a store
858
- string store_name the store name collected by the plugin - often the domain name
859
- string order_id the internal order id the store tracked this order by
860
- string email the email address that received this campaign and is associated with this order
861
- double order_total the order total
862
- double tax_total the total tax for the order (if collected)
863
- double ship_total the shipping total for the order (if collected)
864
- string order_date the date the order was tracked - from the store if possible, otherwise the GMT time we recieved it
865
- array lines containing detail of the order - product, category, quantity, item cost
866
- */
867
- function campaignEcommOrders($cid, $start=0, $limit=100, $since=NULL) {
868
- $params = array();
869
- $params["cid"] = $cid;
870
- $params["start"] = $start;
871
- $params["limit"] = $limit;
872
- $params["since"] = $since;
873
- return $this->callServer("campaignEcommOrders", $params);
874
- }
875
-
876
- /**
877
- * Get the URL to a customized <a href="http://eepurl.com/gKmL" target="_blank">VIP Report</a> for the specified campaign and optionally send an email to someone with links to it. Note subsequent calls will overwrite anything already set for the same campign (eg, the password)
878
- *
879
- * @section Campaign Related
880
- *
881
- * @param string $cid the campaign id to share a report for (can be gathered using campaigns())
882
- * @param array $opts optional various parameters which can be used to configure the shared report
883
- string header_type optional - "text" or "image', defaults to "text'
884
- string header_data optional - if "header_type" is text, the text to display. if "header_type" is "image" a valid URL to an image file. Note that images will be resized to be no more than 500x150. Defaults to the Accounts Company Name.
885
- boolean secure optional - whether to require a password for the shared report. defaults to "true"
886
- string password optional - if secure is true and a password is not included, we will generate one. It is always returned.
887
- string to_email optional - optional, email address to share the report with - no value means an email will not be sent
888
- array theme optional - an array containing either 3 or 6 character color code values for: "bg_color", "header_color", "current_tab", "current_tab_text", "normal_tab", "normal_tab_text", "hover_tab", "hover_tab_text"
889
- string css_url optional - a link to an external CSS file to be included after our default CSS (http://vip-reports.net/css/vip.css) <strong>only if</strong> loaded via the "secure_url" - max 255 bytes
890
- * @return struct Struct containing details for the shared report
891
- * @returnf string title The Title of the Campaign being shared
892
- * @returnf string url The URL to the shared report
893
- * @returnf string secure_url The URL to the shared report, including the password (good for loading in an IFRAME). For non-secure reports, this will not be returned
894
- * @returnf string password If secured, the password for the report, otherwise this field will not be returned
895
- */
896
- function campaignShareReport($cid, $opts=array (
897
- )) {
898
- $params = array();
899
- $params["cid"] = $cid;
900
- $params["opts"] = $opts;
901
- return $this->callServer("campaignShareReport", $params);
902
- }
903
-
904
- /**
905
- * Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content
906
- *
907
- * @section Campaign Related
908
- *
909
- * @param string $cid the campaign id to get content for (can be gathered using campaigns())
910
- * @param bool $for_archive optional controls whether we return the Archive version (true) or the Raw version (false), defaults to true
911
- * @return struct Struct containing all content for the campaign (see Returned Fields for details
912
- * @returnf string html The HTML content used for the campgain with merge tags intact
913
- * @returnf string text The Text content used for the campgain with merge tags intact
914
- */
915
- function campaignContent($cid, $for_archive=true) {
916
- $params = array();
917
- $params["cid"] = $cid;
918
- $params["for_archive"] = $for_archive;
919
- return $this->callServer("campaignContent", $params);
920
- }
921
-
922
- /**
923
- * Get the HTML template content sections for a campaign. Note that this <strong>will</strong> return very jagged, non-standard results based on the template
924
- * a campaign is using. You only want to use this if you want to allow editing template sections in your applicaton.
925
- *
926
- * @section Campaign Related
927
- *
928
- * @param string $cid the campaign id to get content for (can be gathered using campaigns())
929
- * @return array array containing all content section for the campaign -
930
- */
931
- function campaignTemplateContent($cid) {
932
- $params = array();
933
- $params["cid"] = $cid;
934
- return $this->callServer("campaignTemplateContent", $params);
935
- }
936
-
937
- /**
938
- * Retrieve the list of email addresses that opened a given campaign with how many times they opened - note: this AIM function is free and does
939
- * not actually require the AIM module to be installed
940
- *
941
- * @section Campaign Report Data
942
- *
943
- * @param string $cid the campaign id to get opens for (can be gathered using campaigns())
944
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
945
- * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
946
- * @return array array containing the total records matched and the specific records for this page
947
- * @returnf int total the total number of records matched
948
- * @returnf array data the actual opens data, including:
949
- string email Email address that opened the campaign
950
- int open_count Total number of times the campaign was opened by this email address
951
- */
952
- function campaignOpenedAIM($cid, $start=0, $limit=1000) {
953
- $params = array();
954
- $params["cid"] = $cid;
955
- $params["start"] = $start;
956
- $params["limit"] = $limit;
957
- return $this->callServer("campaignOpenedAIM", $params);
958
- }
959
-
960
- /**
961
- * Retrieve the list of email addresses that did not open a given campaign
962
- *
963
- * @section Campaign Report Data
964
- *
965
- * @param string $cid the campaign id to get no opens for (can be gathered using campaigns())
966
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
967
- * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
968
- * @return array array containing the total records matched and the specific records for this page
969
- * @returnf int total the total number of records matched
970
- * @returnf array data the email addresses that did not open the campaign
971
- string email Email address that opened the campaign
972
- */
973
- function campaignNotOpenedAIM($cid, $start=0, $limit=1000) {
974
- $params = array();
975
- $params["cid"] = $cid;
976
- $params["start"] = $start;
977
- $params["limit"] = $limit;
978
- return $this->callServer("campaignNotOpenedAIM", $params);
979
- }
980
-
981
- /**
982
- * Return the list of email addresses that clicked on a given url, and how many times they clicked
983
- *
984
- * @section Campaign Report Data
985
- *
986
- * @param string $cid the campaign id to get click stats for (can be gathered using campaigns())
987
- * @param string $url the URL of the link that was clicked on
988
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
989
- * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
990
- * @return array array containing the total records matched and the specific records for this page
991
- * @returnf int total the total number of records matched
992
- * @returnf array data the email addresses that did not open the campaign
993
- string email Email address that opened the campaign
994
- int clicks Total number of times the URL was clicked on by this email address
995
- */
996
- function campaignClickDetailAIM($cid, $url, $start=0, $limit=1000) {
997
- $params = array();
998
- $params["cid"] = $cid;
999
- $params["url"] = $url;
1000
- $params["start"] = $start;
1001
- $params["limit"] = $limit;
1002
- return $this->callServer("campaignClickDetailAIM", $params);
1003
- }
1004
-
1005
- /**
1006
- * Given a campaign and email address, return the entire click and open history with timestamps, ordered by time
1007
- *
1008
- * @section Campaign Report Data
1009
- *
1010
- * @param string $cid the campaign id to get stats for (can be gathered using campaigns())
1011
- * @param array $email_address an array of up to 50 email addresses to check OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns. For backwards compatibility, if a string is passed, it will be treated as an array with a single element (will not work with XML-RPC).
1012
- * @return array an array with the keys listed in Returned Fields below
1013
- * @returnf int success the number of email address records found
1014
- * @returnf int error the number of email address records which could not be found
1015
- * @returnf array data arrays containing the actions (opens and clicks) that the email took, with timestamps
1016
- string action The action taken (open or click)
1017
- string timestamp Time the action occurred
1018
- string url For clicks, the URL that was clicked
1019
- */
1020
- function campaignEmailStatsAIM($cid, $email_address) {
1021
- $params = array();
1022
- $params["cid"] = $cid;
1023
- $params["email_address"] = $email_address;
1024
- return $this->callServer("campaignEmailStatsAIM", $params);
1025
- }
1026
-
1027
- /**
1028
- * Given a campaign and correct paging limits, return the entire click and open history with timestamps, ordered by time,
1029
- * for every user a campaign was delivered to.
1030
- *
1031
- * @section Campaign Report Data
1032
- * @example mcapi_campaignEmailStatsAIMAll.php
1033
- *
1034
- * @param string $cid the campaign id to get stats for (can be gathered using campaigns())
1035
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
1036
- * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 1000
1037
- * @return array Array containing a total record count and data including the actions (opens and clicks) for each email, with timestamps
1038
- * @returnf int total the total number of records
1039
- * @returnf array data each record with their details:
1040
- string action The action taken (open or click)
1041
- string timestamp Time the action occurred
1042
- string url For clicks, the URL that was clicked
1043
- */
1044
- function campaignEmailStatsAIMAll($cid, $start=0, $limit=100) {
1045
- $params = array();
1046
- $params["cid"] = $cid;
1047
- $params["start"] = $start;
1048
- $params["limit"] = $limit;
1049
- return $this->callServer("campaignEmailStatsAIMAll", $params);
1050
- }
1051
-
1052
- /**
1053
- * Attach Ecommerce Order Information to a Campaign. This will generall be used by ecommerce package plugins
1054
- * <a href="/plugins/ecomm360.phtml">that we provide</a> or by 3rd part system developers.
1055
- * @section Campaign Related
1056
- *
1057
- * @param array $order an array of information pertaining to the order that has completed. Use the following keys:
1058
- string id the Order Id
1059
- string campaign_id the Campaign Id to track this order with (see the "mc_cid" query string variable a campaign passes)
1060
- string email_id the Email Id of the subscriber we should attach this order to (see the "mc_eid" query string variable a campaign passes)
1061
- double total The Order Total (ie, the full amount the customer ends up paying)
1062
- string order_date optional the date of the order - if this is not provided, we will default the date to now
1063
- double shipping optional the total paid for Shipping Fees
1064
- double tax optional the total tax paid
1065
- string store_id a unique id for the store sending the order in (20 bytes max)
1066
- string store_name optional a "nice" name for the store - typically the base web address (ie, "store.mailchimp.com"). We will automatically update this if it changes (based on store_id)
1067
- string plugin_id the MailChimp assigned Plugin Id. Get yours by <a href="/register.php">registering here</a>
1068
- array items the individual line items for an order using these keys:
1069
- <div style="padding-left:30px"><table><tr><td colspan=*>
1070
- int line_num optional the line number of the item on the order. We will generate these if they are not passed
1071
- int product_id the store's internal Id for the product. Lines that do no contain this will be skipped
1072
- string product_name the product name for the product_id associated with this item. We will auto update these as they change (based on product_id)
1073
- int category_id the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario
1074
- string category_name the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc.
1075
- double qty the quantity of the item ordered
1076
- double cost the cost of a single item (ie, not the extended cost of the line)
1077
- </td></tr></table></div>
1078
- * @return bool true if the data is saved, otherwise an error is thrown.
1079
- */
1080
- function campaignEcommOrderAdd($order) {
1081
- $params = array();
1082
- $params["order"] = $order;
1083
- return $this->callServer("campaignEcommOrderAdd", $params);
1084
- }
1085
-
1086
- /**
1087
- * Retrieve all of the lists defined for your user account
1088
- *
1089
- * @section List Related
1090
- * @example mcapi_lists.php
1091
- * @example xml-rpc_lists.php
1092
- *
1093
- * @param array $filters a hash of filters to apply to this query - all are optional:
1094
- string list_id optional - return a single list using a known list_id. Accepts multiples separated by commas when not using exact matching
1095
- string list_name optional - only lists that match this name
1096
- string from_name optional - only lists that have a default from name matching this
1097
- string from_email optional - only lists that have a default from email matching this
1098
- string from_subject optional - only lists that have a default from email matching this
1099
- string created_before optional - only show lists that were created before this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
1100
- string created_after optional - only show lists that were created since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
1101
- boolean exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true
1102
- * @param int $start optional - control paging of lists, start results at this list #, defaults to 1st page of data (page 0)
1103
- * @param int $limit optional - control paging of lists, number of lists to return with each call, defaults to 25 (max=100)
1104
- * @return array an array with keys listed in Returned Fields below
1105
- * @returnf int total the total number of lists which matched the provided filters
1106
- * @returnf array data the lists which matched the provided filters, including the following for
1107
- string id The list id for this list. This will be used for all other list management functions.
1108
- int web_id The list id used in our web app, allows you to create a link directly to it
1109
- string name The name of the list.
1110
- string date_created The date that this list was created.
1111
- boolean email_type_option Whether or not the List supports multiple formats for emails or just HTML
1112
- boolean use_awesomebar Whether or not campaigns for this list use the Awesome Bar in archives by default
1113
- string default_from_name Default From Name for campaigns using this list
1114
- string default_from_email Default From Email for campaigns using this list
1115
- string default_subject Default Subject Line for campaigns using this list
1116
- string default_language Default Language for this list's forms
1117
- int list_rating An auto-generated activity score for the list (0 - 5)
1118
- array stats various stats and counts for the list
1119
- int member_count The number of active members in the given list.
1120
- int unsubscribe_count The number of members who have unsubscribed from the given list.
1121
- int cleaned_count The number of members cleaned from the given list.
1122
- int member_count_since_send The number of active members in the given list since the last campaign was sent
1123
- int unsubscribe_count_since_send The number of members who have unsubscribed from the given list since the last campaign was sent
1124
- int cleaned_count_since_send The number of members cleaned from the given list since the last campaign was sent
1125
- int campaign_count The number of campaigns in any status that use this list
1126
- int grouping_count The number of Interest Groupings for this list
1127
- int group_count The number of Interest Groups (regardless of grouping) for this list
1128
- int merge_var_count The number of merge vars for this list (not including the required EMAIL one)
1129
- int avg_sub_rate the average number of subscribe per month for the list (empty value if we haven't calculated this yet)
1130
- int avg_unsub_rate the average number of unsubscribe per month for the list (empty value if we haven't calculated this yet)
1131
- int target_sub_rate the target subscription rate for the list to keep it growing (empty value if we haven't calculated this yet)
1132
- int open_rate the average open rate per campaign for the list (empty value if we haven't calculated this yet)
1133
- int click_rate the average click rate per campaign for the list (empty value if we haven't calculated this yet)
1134
- array modules Any list specific modules installed for this list (example is SocialPro)
1135
- */
1136
- function lists($filters=array (
1137
- ), $start=0, $limit=25) {
1138
- $params = array();
1139
- $params["filters"] = $filters;
1140
- $params["start"] = $start;
1141
- $params["limit"] = $limit;
1142
- return $this->callServer("lists", $params);
1143
- }
1144
-
1145
- /**
1146
- * Get the list of merge tags for a given list, including their name, tag, and required setting
1147
- *
1148
- * @section List Related
1149
- * @example xml-rpc_listMergeVars.php
1150
- *
1151
- * @param string $id the list id to connect to. Get by calling lists()
1152
- * @return array list of merge tags for the list
1153
- * @returnf string name Name of the merge field
1154
- * @returnf bool req Denotes whether the field is required (true) or not (false)
1155
- * @returnf string field_type The "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl
1156
- * @returnf bool public Whether or not this field is visible to list subscribers
1157
- * @returnf bool show Whether the list owner has this field displayed on their list dashboard
1158
- * @returnf string order The order the list owner has set this field to display in
1159
- * @returnf string default The default value the list owner has set for this field
1160
- * @returnf string size The width of the field to be used
1161
- * @returnf string tag The merge tag that's used for forms and listSubscribe() and listUpdateMember()
1162
- * @returnf array choices For radio and dropdown field types, an array of the options available
1163
- */
1164
- function listMergeVars($id) {
1165
- $params = array();
1166
- $params["id"] = $id;
1167
- return $this->callServer("listMergeVars", $params);
1168
- }
1169
-
1170
- /**
1171
- * Add a new merge tag to a given list
1172
- *
1173
- * @section List Related
1174
- * @example xml-rpc_listMergeVarAdd.php
1175
- *
1176
- * @param string $id the list id to connect to. Get by calling lists()
1177
- * @param string $tag The merge tag to add, e.g. FNAME
1178
- * @param string $name The long description of the tag being added, used for user displays
1179
- * @param array $options optional Various options for this merge var. <em>note:</em> for historical purposes this can also take a "boolean"
1180
- string field_type optional one of: text, number, radio, dropdown, date, address, phone, url, imageurl - defaults to text
1181
- boolean req optional indicates whether the field is required - defaults to false
1182
- boolean public optional indicates whether the field is displayed in public - defaults to true
1183
- boolean show optional indicates whether the field is displayed in the app's list member view - defaults to true
1184
- string default_value optional the default value for the field. See listSubscribe() for formatting info. Defaults to blank
1185
- array choices optional kind of - an array of strings to use as the choices for radio and dropdown type fields
1186
-
1187
- * @return bool true if the request succeeds, otherwise an error will be thrown
1188
- */
1189
- function listMergeVarAdd($id, $tag, $name, $options=array (
1190
- )) {
1191
- $params = array();
1192
- $params["id"] = $id;
1193
- $params["tag"] = $tag;
1194
- $params["name"] = $name;
1195
- $params["options"] = $options;
1196
- return $this->callServer("listMergeVarAdd", $params);
1197
- }
1198
-
1199
- /**
1200
- * Update most parameters for a merge tag on a given list. You cannot currently change the merge type
1201
- *
1202
- * @section List Related
1203
- *
1204
- * @param string $id the list id to connect to. Get by calling lists()
1205
- * @param string $tag The merge tag to update
1206
- * @param array $options The options to change for a merge var. See listMergeVarAdd() for valid options
1207
- * @return bool true if the request succeeds, otherwise an error will be thrown
1208
- */
1209
- function listMergeVarUpdate($id, $tag, $options) {
1210
- $params = array();
1211
- $params["id"] = $id;
1212
- $params["tag"] = $tag;
1213
- $params["options"] = $options;
1214
- return $this->callServer("listMergeVarUpdate", $params);
1215
- }
1216
-
1217
- /**
1218
- * Delete a merge tag from a given list and all its members. Seriously - the data is removed from all members as well!
1219
- * Note that on large lists this method may seem a bit slower than calls you typically make.
1220
- *
1221
- * @section List Related
1222
- * @example xml-rpc_listMergeVarDel.php
1223
- *
1224
- * @param string $id the list id to connect to. Get by calling lists()
1225
- * @param string $tag The merge tag to delete
1226
- * @return bool true if the request succeeds, otherwise an error will be thrown
1227
- */
1228
- function listMergeVarDel($id, $tag) {
1229
- $params = array();
1230
- $params["id"] = $id;
1231
- $params["tag"] = $tag;
1232
- return $this->callServer("listMergeVarDel", $params);
1233
- }
1234
-
1235
- /**
1236
- * Get the list of interest groupings for a given list, including the label, form information, and included groups for each
1237
- *
1238
- * @section List Related
1239
- * @example xml-rpc_listInterestGroupings.php
1240
- *
1241
- * @param string $id the list id to connect to. Get by calling lists()
1242
- * @return struct list of interest groups for the list
1243
- * @returnf string id The id for the Grouping
1244
- * @returnf string name Name for the Interest groups
1245
- * @returnf string form_field Gives the type of interest group: checkbox,radio,select
1246
- * @returnf array groups Array of the grouping options including the "bit" value, "name", "display_order", and number of "subscribers" with the option selected.
1247
- */
1248
- function listInterestGroupings($id) {
1249
- $params = array();
1250
- $params["id"] = $id;
1251
- return $this->callServer("listInterestGroupings", $params);
1252
- }
1253
-
1254
- /** Add a single Interest Group - if interest groups for the List are not yet enabled, adding the first
1255
- * group will automatically turn them on.
1256
- *
1257
- * @section List Related
1258
- * @example xml-rpc_listInterestGroupAdd.php
1259
- *
1260
- * @param string $id the list id to connect to. Get by calling lists()
1261
- * @param string $group_name the interest group to add - group names must be unique within a grouping
1262
- * @param int optional $grouping_id The grouping to add the new group to - get using listInterestGrouping() . If not supplied, the first grouping on the list is used.
1263
- * @return bool true if the request succeeds, otherwise an error will be thrown
1264
- */
1265
- function listInterestGroupAdd($id, $group_name, $grouping_id=NULL) {
1266
- $params = array();
1267
- $params["id"] = $id;
1268
- $params["group_name"] = $group_name;
1269
- $params["grouping_id"] = $grouping_id;
1270
- return $this->callServer("listInterestGroupAdd", $params);
1271
- }
1272
-
1273
- /** Delete a single Interest Group - if the last group for a list is deleted, this will also turn groups for the list off.
1274
- *
1275
- * @section List Related
1276
- * @example xml-rpc_listInterestGroupDel.php
1277
- *
1278
- * @param string $id the list id to connect to. Get by calling lists()
1279
- * @param string $group_name the interest group to delete
1280
- * @param int $grouping_id The grouping to delete the group from - get using listInterestGrouping() . If not supplied, the first grouping on the list is used.
1281
- * @return bool true if the request succeeds, otherwise an error will be thrown
1282
- */
1283
- function listInterestGroupDel($id, $group_name, $grouping_id=NULL) {
1284
- $params = array();
1285
- $params["id"] = $id;
1286
- $params["group_name"] = $group_name;
1287
- $params["grouping_id"] = $grouping_id;
1288
- return $this->callServer("listInterestGroupDel", $params);
1289
- }
1290
-
1291
- /** Change the name of an Interest Group
1292
- *
1293
- * @section List Related
1294
- *
1295
- * @param string $id the list id to connect to. Get by calling lists()
1296
- * @param string $old_name the interest group name to be changed
1297
- * @param string $new_name the new interest group name to be set
1298
- * @param int optional $grouping_id The grouping to delete the group from - get using listInterestGrouping() . If not supplied, the first grouping on the list is used.
1299
- * @return bool true if the request succeeds, otherwise an error will be thrown
1300
- */
1301
- function listInterestGroupUpdate($id, $old_name, $new_name, $grouping_id=NULL) {
1302
- $params = array();
1303
- $params["id"] = $id;
1304
- $params["old_name"] = $old_name;
1305
- $params["new_name"] = $new_name;
1306
- $params["grouping_id"] = $grouping_id;
1307
- return $this->callServer("listInterestGroupUpdate", $params);
1308
- }
1309
-
1310
- /** Add a new Interest Grouping - if interest groups for the List are not yet enabled, adding the first
1311
- * grouping will automatically turn them on.
1312
- *
1313
- * @section List Related
1314
- * @example xml-rpc_listInterestGroupingAdd.php
1315
- *
1316
- * @param string $id the list id to connect to. Get by calling lists()
1317
- * @param string $name the interest grouping to add - grouping names must be unique
1318
- * @param string $type The type of the grouping to add - one of "checkboxes", "hidden", "dropdown", "radio"
1319
- * @param array $groups The lists of initial group names to be added - at least 1 is required and the names must be unique within a grouping. If the number takes you over the 60 group limit, an error will be thrown.
1320
- * @return int the new grouping id if the request succeeds, otherwise an error will be thrown
1321
- */
1322
- function listInterestGroupingAdd($id, $name, $type, $groups) {
1323
- $params = array();
1324
- $params["id"] = $id;
1325
- $params["name"] = $name;
1326
- $params["type"] = $type;
1327
- $params["groups"] = $groups;
1328
- return $this->callServer("listInterestGroupingAdd", $params);
1329
- }
1330
-
1331
- /** Update an existing Interest Grouping
1332
- *
1333
- * @section List Related
1334
- * @example xml-rpc_listInterestGroupingUpdate.php
1335
- *
1336
- * @param int $grouping_id the interest grouping id - get from listInterestGroupings()
1337
- * @param string $name The name of the field to update - either "name" or "type". Groups with in the grouping should be manipulated using the standard listInterestGroup* methods
1338
- * @param string $value The new value of the field. Grouping names must be unique - only "hidden" and "checkboxes" grouping types can be converted between each other.
1339
- * @return bool true if the request succeeds, otherwise an error will be thrown
1340
- */
1341
- function listInterestGroupingUpdate($grouping_id, $name, $value) {
1342
- $params = array();
1343
- $params["grouping_id"] = $grouping_id;
1344
- $params["name"] = $name;
1345
- $params["value"] = $value;
1346
- return $this->callServer("listInterestGroupingUpdate", $params);
1347
- }
1348
-
1349
- /** Delete an existing Interest Grouping - this will permanently delete all contained interest groups and will remove those selections from all list members
1350
- *
1351
- * @section List Related
1352
- * @example xml-rpc_listInterestGroupingDel.php
1353
- *
1354
- * @param int $grouping_id the interest grouping id - get from listInterestGroupings()
1355
- * @return bool true if the request succeeds, otherwise an error will be thrown
1356
- */
1357
- function listInterestGroupingDel($grouping_id) {
1358
- $params = array();
1359
- $params["grouping_id"] = $grouping_id;
1360
- return $this->callServer("listInterestGroupingDel", $params);
1361
- }
1362
-
1363
- /** Return the Webhooks configured for the given list
1364
- *
1365
- * @section List Related
1366
- *
1367
- * @param string $id the list id to connect to. Get by calling lists()
1368
- * @return array list of webhooks
1369
- * @returnf string url the URL for this Webhook
1370
- * @returnf array actions the possible actions and whether they are enabled
1371
- * @returnf array sources the possible sources and whether they are enabled
1372
- */
1373
- function listWebhooks($id) {
1374
- $params = array();
1375
- $params["id"] = $id;
1376
- return $this->callServer("listWebhooks", $params);
1377
- }
1378
-
1379
- /** Add a new Webhook URL for the given list
1380
- *
1381
- * @section List Related
1382
- *
1383
- * @param string $id the list id to connect to. Get by calling lists()
1384
- * @param string $url a valid URL for the Webhook - it will be validated. note that a url may only exist on a list once.
1385
- * @param array $actions optional a hash of actions to fire this Webhook for
1386
- boolean subscribe optional as subscribes occur, defaults to true
1387
- boolean unsubscribe optional as subscribes occur, defaults to true
1388
- boolean profile optional as profile updates occur, defaults to true
1389
- boolean cleaned optional as emails are cleaned from the list, defaults to true
1390
- boolean upemail optional when subscribers change their email address, defaults to true
1391
- * @param array $sources optional a hash of sources to fire this Webhook for
1392
- boolean user optional user/subscriber initiated actions, defaults to true
1393
- boolean admin optional admin actions in our web app, defaults to true
1394
- boolean api optional actions that happen via API calls, defaults to false
1395
- * @return bool true if the call succeeds, otherwise an exception will be thrown
1396
- */
1397
- function listWebhookAdd($id, $url, $actions=array (
1398
- ), $sources=array (
1399
- )) {
1400
- $params = array();
1401
- $params["id"] = $id;
1402
- $params["url"] = $url;
1403
- $params["actions"] = $actions;
1404
- $params["sources"] = $sources;
1405
- return $this->callServer("listWebhookAdd", $params);
1406
- }
1407
-
1408
- /** Delete an existing Webhook URL from a given list
1409
- *
1410
- * @section List Related
1411
- *
1412
- * @param string $id the list id to connect to. Get by calling lists()
1413
- * @param string $url the URL of a Webhook on this list
1414
- * @return boolean true if the call succeeds, otherwise an exception will be thrown
1415
- */
1416
- function listWebhookDel($id, $url) {
1417
- $params = array();
1418
- $params["id"] = $id;
1419
- $params["url"] = $url;
1420
- return $this->callServer("listWebhookDel", $params);
1421
- }
1422
-
1423
- /** Retrieve all of the Static Segments for a list.
1424
- *
1425
- * @section List Related
1426
- *
1427
- * @param string $id the list id to connect to. Get by calling lists()
1428
- * @return array an array of parameters for each static segment
1429
- * @returnf int id the id of the segment
1430
- * @returnf string name the name for the segment
1431
- * @returnf int member_count the total number of members currently in a segment
1432
- * @returnf date created_date the date/time the segment was created
1433
- * @returnf date last_update the date/time the segment was last updated (add or del)
1434
- * @returnf date last_reset the date/time the segment was last reset (ie had all members cleared from it)
1435
- */
1436
- function listStaticSegments($id) {
1437
- $params = array();
1438
- $params["id"] = $id;
1439
- return $this->callServer("listStaticSegments", $params);
1440
- }
1441
-
1442
- /** Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments <strong>are not</strong> tied
1443
- * to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance.
1444
- * When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation
1445
- * options), though performance may degrade at that point.
1446
- *
1447
- * @section List Related
1448
- *
1449
- * @param string $id the list id to connect to. Get by calling lists()
1450
- * @param string $name a unique name per list for the segment - 50 byte maximum length, anything longer will throw an error
1451
- * @return int the id of the new segment, otherwise an error will be thrown.
1452
- */
1453
- function listStaticSegmentAdd($id, $name) {
1454
- $params = array();
1455
- $params["id"] = $id;
1456
- $params["name"] = $name;
1457
- return $this->callServer("listStaticSegmentAdd", $params);
1458
- }
1459
-
1460
- /** Resets a static segment - removes <strong>all</strong> members from the static segment. Note: does not actually affect list member data
1461
- *
1462
- * @section List Related
1463
- *
1464
- * @param string $id the list id to connect to. Get by calling lists()
1465
- * @param int $seg_id the id of the static segment to reset - get from listStaticSegments()
1466
- * @return bool true if it worked, otherwise an error is thrown.
1467
- */
1468
- function listStaticSegmentReset($id, $seg_id) {
1469
- $params = array();
1470
- $params["id"] = $id;
1471
- $params["seg_id"] = $seg_id;
1472
- return $this->callServer("listStaticSegmentReset", $params);
1473
- }
1474
-
1475
- /** Delete a static segment. Note that this will, of course, remove any member affiliations with the segment
1476
- *
1477
- * @section List Related
1478
- *
1479
- * @param string $id the list id to connect to. Get by calling lists()
1480
- * @param int $seg_id the id of the static segment to delete - get from listStaticSegments()
1481
- * @return bool true if it worked, otherwise an error is thrown.
1482
- */
1483
- function listStaticSegmentDel($id, $seg_id) {
1484
- $params = array();
1485
- $params["id"] = $id;
1486
- $params["seg_id"] = $seg_id;
1487
- return $this->callServer("listStaticSegmentDel", $params);
1488
- }
1489
-
1490
- /** Add list members to a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
1491
- * in order to be included - this <strong>will not</strong> subscribe them to the list!
1492
- *
1493
- * @section List Related
1494
- *
1495
- * @param string $id the list id to connect to. Get by calling lists()
1496
- * @param int $seg_id the id of the static segment to modify - get from listStaticSegments()
1497
- * @param array $batch an array of email addresses and/or unique_ids to add to the segment
1498
- * @return array an array with the results of the operation
1499
- * @returnf int success the total number of successful updates (will include members already in the segment)
1500
- * @returnf array errors the email address, an error code, and a message explaining why they couldn't be added
1501
- */
1502
- function listStaticSegmentMembersAdd($id, $seg_id, $batch) {
1503
- $params = array();
1504
- $params["id"] = $id;
1505
- $params["seg_id"] = $seg_id;
1506
- $params["batch"] = $batch;
1507
- return $this->callServer("listStaticSegmentMembersAdd", $params);
1508
- }
1509
-
1510
- /** Remove list members from a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
1511
- * in order to be removed - this <strong>will not</strong> unsubscribe them from the list!
1512
- *
1513
- * @section List Related
1514
- *
1515
- * @param string $id the list id to connect to. Get by calling lists()
1516
- * @param int $seg_id the id of the static segment to delete - get from listStaticSegments()
1517
- * @param array $batch an array of email addresses and/or unique_ids to remove from the segment
1518
- * @return array an array with the results of the operation
1519
- * @returnf int success the total number of succesful removals
1520
- * @returnf array errors the email address, an error code, and a message explaining why they couldn't be removed
1521
- */
1522
- function listStaticSegmentMembersDel($id, $seg_id, $batch) {
1523
- $params = array();
1524
- $params["id"] = $id;
1525
- $params["seg_id"] = $seg_id;
1526
- $params["batch"] = $batch;
1527
- return $this->callServer("listStaticSegmentMembersDel", $params);
1528
- }
1529
-
1530
- /**
1531
- * Subscribe the provided email to a list. By default this sends a confirmation email - you will not see new members until the link contained in it is clicked!
1532
- *
1533
- * @section List Related
1534
- *
1535
- * @example mcapi_listSubscribe.php
1536
- * @example json_listSubscribe.php
1537
- * @example xml-rpc_listSubscribe.php
1538
- *
1539
- * @param string $id the list id to connect to. Get by calling lists()
1540
- * @param string $email_address the email address to subscribe
1541
- * @param array $merge_vars optional merges for the email (FNAME, LNAME, etc.) (see examples below for handling "blank" arrays). Note that a merge field can only hold up to 255 bytes. Also, there are a few "special" keys:
1542
- string EMAIL set this to change the email address. This is only respected on calls using update_existing or when passed to listUpdateMember()
1543
- array GROUPINGS Set Interest Groups by Grouping. Each element in this array should be an array containing the "groups" parameter which contains a comma delimited list of Interest Groups to add. Commas in Interest Group names should be escaped with a backslash. ie, "," =&gt; "\," and either an "id" or "name" parameter to specify the Grouping - get from listInterestGroupings()
1544
- string OPTINIP Set the Opt-in IP fields. <em>Abusing this may cause your account to be suspended.</em> We do validate this and it must not be a private IP address.
1545
- array MC_LOCATION Set the members geographic location. By default if this merge field exists, we'll update using the optin_ip if it exists. If the array contains LATITUDE and LONGITUDE keys, they will be used. NOTE - this will slow down each subscribe call a bit, especially for lat/lng pairs in sparsely populated areas. Currently our automated background processes can and will overwrite this based on opens and clicks.
1546
-
1547
- <strong>Handling Field Data Types</strong> - most fields you can just pass a string and all is well. For some, though, that is not the case...
1548
- Field values should be formatted as follows:
1549
- string address For the string version of an Address, the fields should be delimited by <strong>2</strong> spaces. Address 2 can be skipped. The Country should be a 2 character ISO-3166-1 code and will default to your default country if not set
1550
- array address For the array version of an Address, the requirements for Address 2 and Country are the same as with the string version. Then simply pass us an array with the keys <strong>addr1</strong>, <strong>addr2</strong>, <strong>city</strong>, <strong>state</strong>, <strong>zip</strong>, <strong>country</strong> and appropriate values for each
1551
-
1552
- string date use YYYY-MM-DD to be safe. Generally, though, anything strtotime() understands we'll understand - <a href="http://us2.php.net/strtotime" target="_blank">http://us2.php.net/strtotime</a>
1553
- string dropdown can be a normal string - we <em>will</em> validate that the value is a valid option
1554
- string image must be a valid, existing url. we <em>will</em> check its existence
1555
- string multi_choice can be a normal string - we <em>will</em> validate that the value is a valid option
1556
- double number pass in a valid number - anything else will turn in to zero (0). Note, this will be rounded to 2 decimal places
1557
- string phone If your account has the US Phone numbers option set, this <em>must</em> be in the form of NPA-NXX-LINE (404-555-1212). If not, we assume an International number and will simply set the field with what ever number is passed in.
1558
- string website This is a standard string, but we <em>will</em> verify that it looks like a valid URL
1559
-
1560
- * @param string $email_type optional email type preference for the email (html, text, or mobile defaults to html)
1561
- * @param bool $double_optin optional flag to control whether a double opt-in confirmation message is sent, defaults to true. <em>Abusing this may cause your account to be suspended.</em>
1562
- * @param bool $update_existing optional flag to control whether a existing subscribers should be updated instead of throwing and error, defaults to false
1563
- * @param bool $replace_interests optional flag to determine whether we replace the interest groups with the groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true)
1564
- * @param bool $send_welcome optional if your double_optin is false and this is true, we will send your lists Welcome Email if this subscribe succeeds - this will *not* fire if we end up updating an existing subscriber. If double_optin is true, this has no effect. defaults to false.
1565
- * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below)
1566
- */
1567
- function listSubscribe($id, $email_address, $merge_vars=NULL, $email_type='html', $double_optin=true, $update_existing=false, $replace_interests=true, $send_welcome=false) {
1568
- $params = array();
1569
- $params["id"] = $id;
1570
- $params["email_address"] = $email_address;
1571
- $params["merge_vars"] = $merge_vars;
1572
- $params["email_type"] = $email_type;
1573
- $params["double_optin"] = $double_optin;
1574
- $params["update_existing"] = $update_existing;
1575
- $params["replace_interests"] = $replace_interests;
1576
- $params["send_welcome"] = $send_welcome;
1577
- return $this->callServer("listSubscribe", $params);
1578
- }
1579
-
1580
- /**
1581
- * Unsubscribe the given email address from the list
1582
- *
1583
- * @section List Related
1584
- * @example mcapi_listUnsubscribe.php
1585
- * @example xml-rpc_listUnsubscribe.php
1586
- *
1587
- * @param string $id the list id to connect to. Get by calling lists()
1588
- * @param string $email_address the email address to unsubscribe OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns
1589
- * @param boolean $delete_member flag to completely delete the member from your list instead of just unsubscribing, default to false
1590
- * @param boolean $send_goodbye flag to send the goodbye email to the email address, defaults to true
1591
- * @param boolean $send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to true
1592
- * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below)
1593
- */
1594
- function listUnsubscribe($id, $email_address, $delete_member=false, $send_goodbye=true, $send_notify=true) {
1595
- $params = array();
1596
- $params["id"] = $id;
1597
- $params["email_address"] = $email_address;
1598
- $params["delete_member"] = $delete_member;
1599
- $params["send_goodbye"] = $send_goodbye;
1600
- $params["send_notify"] = $send_notify;
1601
- return $this->callServer("listUnsubscribe", $params);
1602
- }
1603
-
1604
- /**
1605
- * Edit the email address, merge fields, and interest groups for a list member. If you are doing a batch update on lots of users,
1606
- * consider using listBatchSubscribe() with the update_existing and possible replace_interests parameter.
1607
- *
1608
- * @section List Related
1609
- * @example mcapi_listUpdateMember.php
1610
- *
1611
- * @param string $id the list id to connect to. Get by calling lists()
1612
- * @param string $email_address the current email address of the member to update OR the "id" for the member returned from listMemberInfo, Webhooks, and Campaigns
1613
- * @param array $merge_vars array of new field values to update the member with. See merge_vars in listSubscribe() for details.
1614
- * @param string $email_type change the email type preference for the member ("html", "text", or "mobile"). Leave blank to keep the existing preference (optional)
1615
- * @param boolean $replace_interests flag to determine whether we replace the interest groups with the updated groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true)
1616
- * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object
1617
- */
1618
- function listUpdateMember($id, $email_address, $merge_vars, $email_type='', $replace_interests=true) {
1619
- $params = array();
1620
- $params["id"] = $id;
1621
- $params["email_address"] = $email_address;
1622
- $params["merge_vars"] = $merge_vars;
1623
- $params["email_type"] = $email_type;
1624
- $params["replace_interests"] = $replace_interests;
1625
- return $this->callServer("listUpdateMember", $params);
1626
- }
1627
-
1628
- /**
1629
- * Subscribe a batch of email addresses to a list at once. If you are using a serialized version of the API, we strongly suggest that you
1630
- * only run this method as a POST request, and <em>not</em> a GET request. Maximum batch sizes vary based on the amount of data in each record,
1631
- * though you should cap them at 5k - 10k records, depending on your experience. These calls are also long, so be sure you increase your timeout values.
1632
- *
1633
- * @section List Related
1634
- *
1635
- * @example mcapi_listBatchSubscribe.php
1636
- * @example xml-rpc_listBatchSubscribe.php
1637
- *
1638
- * @param string $id the list id to connect to. Get by calling lists()
1639
- * @param array $batch an array of structs for each address to import with two special keys: "EMAIL" for the email address, and "EMAIL_TYPE" for the email type option (html, text, or mobile)
1640
- * @param boolean $double_optin flag to control whether to send an opt-in confirmation email - defaults to true
1641
- * @param boolean $update_existing flag to control whether to update members that are already subscribed to the list or to return an error, defaults to false (return error)
1642
- * @param boolean $replace_interests flag to determine whether we replace the interest groups with the updated groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true)
1643
- * @return struct Array of result counts and any errors that occurred
1644
- * @returnf int add_count Number of email addresses that were succesfully added
1645
- * @returnf int update_count Number of email addresses that were succesfully updated
1646
- * @returnf int error_count Number of email addresses that failed during addition/updating
1647
- * @returnf array errors Array of error arrays, each containing:
1648
- string code the error code
1649
- string message the full error message
1650
- string email the email address being processed
1651
- */
1652
- function listBatchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) {
1653
- $params = array();
1654
- $params["id"] = $id;
1655
- $params["batch"] = $batch;
1656
- $params["double_optin"] = $double_optin;
1657
- $params["update_existing"] = $update_existing;
1658
- $params["replace_interests"] = $replace_interests;
1659
- return $this->callServer("listBatchSubscribe", $params);
1660
- }
1661
-
1662
- /**
1663
- * Unsubscribe a batch of email addresses to a list
1664
- *
1665
- * @section List Related
1666
- * @example mcapi_listBatchUnsubscribe.php
1667
- *
1668
- * @param string $id the list id to connect to. Get by calling lists()
1669
- * @param array $emails array of email addresses to unsubscribe
1670
- * @param boolean $delete_member flag to completely delete the member from your list instead of just unsubscribing, default to false
1671
- * @param boolean $send_goodbye flag to send the goodbye email to the email addresses, defaults to true
1672
- * @param boolean $send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to false
1673
- * @return struct Array of result counts and any errors that occurred
1674
- * @returnf int success_count Number of email addresses that were succesfully added/updated
1675
- * @returnf int error_count Number of email addresses that failed during addition/updating
1676
- * @returnf array errors Array of error structs. Each error struct will contain "code", "message", and "email"
1677
- */
1678
- function listBatchUnsubscribe($id, $emails, $delete_member=false, $send_goodbye=true, $send_notify=false) {
1679
- $params = array();
1680
- $params["id"] = $id;
1681
- $params["emails"] = $emails;
1682
- $params["delete_member"] = $delete_member;
1683
- $params["send_goodbye"] = $send_goodbye;
1684
- $params["send_notify"] = $send_notify;
1685
- return $this->callServer("listBatchUnsubscribe", $params);
1686
- }
1687
-
1688
- /**
1689
- * Get all of the list members for a list that are of a particular status. Are you trying to get a dump including lots of merge
1690
- * data or specific members of a list? If so, checkout the <a href="/api/export">Export API</a>
1691
- *
1692
- * @section List Related
1693
- * @example mcapi_listMembers.php
1694
- *
1695
- * @param string $id the list id to connect to. Get by calling lists()
1696
- * @param string $status the status to get members for - one of(subscribed, unsubscribed, <a target="_blank" href="http://eepurl.com/dwk1">cleaned</a>, updated), defaults to subscribed
1697
- * @param string $since optional pull all members whose status (subscribed/unsubscribed/cleaned) has changed or whose profile (updated) has changed since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr)
1698
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
1699
- * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 15000
1700
- * @return array Array of a the total records match and matching list member data for this page (see Returned Fields for details)
1701
- * @returnf int total the total matching records
1702
- * @returnf array data the data for each member, including:
1703
- string email Member email address
1704
- date timestamp timestamp of their associated status date (subscribed, unsubscribed, cleaned, or updated) in GMT
1705
- string reason For unsubscribes only - the reason collected for the unsubscribe. If populated, one of 'NORMAL','NOSIGNUP','INAPPROPRIATE','SPAM','OTHER'
1706
- string reason_text For unsubscribes only - if the reason is OTHER, the text entered.
1707
- */
1708
- function listMembers($id, $status='subscribed', $since=NULL, $start=0, $limit=100) {
1709
- $params = array();
1710
- $params["id"] = $id;
1711
- $params["status"] = $status;
1712
- $params["since"] = $since;
1713
- $params["start"] = $start;
1714
- $params["limit"] = $limit;
1715
- return $this->callServer("listMembers", $params);
1716
- }
1717
-
1718
- /**
1719
- * Get all the information for particular members of a list
1720
- *
1721
- * @section List Related
1722
- * @example mcapi_listMemberInfo.php
1723
- * @example xml-rpc_listMemberInfo.php
1724
- *
1725
- * @param string $id the list id to connect to. Get by calling lists()
1726
- * @param array $email_address an array of up to 50 email addresses to get information for OR the "id"(s) for the member returned from listMembers, Webhooks, and Campaigns. For backwards compatibility, if a string is passed, it will be treated as an array with a single element (will not work with XML-RPC).
1727
- * @return array array of list members with their info in an array (see Returned Fields for details)
1728
- * @returnf int success the number of subscribers successfully found on the list
1729
- * @returnf int errors the number of subscribers who were not found on the list
1730
- * @returnf array data an array of arrays where each one has member info:
1731
- string id The unique id for this email address on an account
1732
- string email The email address associated with this record
1733
- string email_type The type of emails this customer asked to get: html, text, or mobile
1734
- array merges An associative array of all the merge tags and the data for those tags for this email address. <em>Note</em>: Interest Groups are returned as comma delimited strings - if a group name contains a comma, it will be escaped with a backslash. ie, "," =&gt; "\,". Groupings will be returned with their "id" and "name" as well as a "groups" field formatted just like Interest Groups
1735
- string status The subscription status for this email address, either pending, subscribed, unsubscribed, or cleaned
1736
- string ip_opt IP Address this address opted in from.
1737
- string ip_signup IP Address this address signed up from.
1738
- int member_rating the rating of the subscriber. This will be 1 - 5 as described <a href="http://eepurl.com/f-2P" target="_blank">here</a>
1739
- string campaign_id If the user is unsubscribed and they unsubscribed from a specific campaign, that campaign_id will be listed, otherwise this is not returned.
1740
- array lists An associative array of the other lists this member belongs to - the key is the list id and the value is their status in that list.
1741
- date timestamp The time this email address was added to the list
1742
- date info_changed The last time this record was changed. If the record is old enough, this may be blank.
1743
- int web_id The Member id used in our web app, allows you to create a link directly to it
1744
- array clients the various clients we've tracked the address as using - each included array includes client 'name' and 'icon_url'
1745
- array static_segments the 'id', 'name', and date 'added' for any static segment this member is in
1746
- */
1747
- function listMemberInfo($id, $email_address) {
1748
- $params = array();
1749
- $params["id"] = $id;
1750
- $params["email_address"] = $email_address;
1751
- return $this->callServer("listMemberInfo", $params);
1752
- }
1753
-
1754
- /**
1755
- * Get the most recent 100 activities for particular list members (open, click, bounce, unsub, abuse, sent to)
1756
- *
1757
- * @section List Related
1758
- * @example mcapi_listMemberInfo.php
1759
- * @example xml-rpc_listMemberInfo.php
1760
- *
1761
- * @param string $id the list id to connect to. Get by calling lists()
1762
- * @param array $email_address an array of up to 50 email addresses to get information for OR the "id"(s) for the member returned from listMembers, Webhooks, and Campaigns.
1763
- * @return array array of data and success/error counts
1764
- * @returnf int success the number of subscribers successfully found on the list
1765
- * @returnf int errors the number of subscribers who were not found on the list
1766
- * @returnf array data an array of arrays where each activity record has:
1767
- string action The action name, one of: open, click, bounce, unsub, abuse, sent
1768
- string timestamp The date/time of the action
1769
- string url For click actions, the url clicked, otherwise this is empty
1770
- string bounce_type For bounce actions, the bounce type, otherwise this is empty
1771
- string campaign_id The campaign id the action was related to, if it exists - otherwise empty (ie, direct unsub from list)
1772
- */
1773
- function listMemberActivity($id, $email_address) {
1774
- $params = array();
1775
- $params["id"] = $id;
1776
- $params["email_address"] = $email_address;
1777
- return $this->callServer("listMemberActivity", $params);
1778
- }
1779
-
1780
- /**
1781
- * Get all email addresses that complained about a given campaign
1782
- *
1783
- * @section List Related
1784
- *
1785
- * @example mcapi_listAbuseReports.php
1786
- *
1787
- * @param string $id the list id to pull abuse reports for (can be gathered using lists())
1788
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
1789
- * @param int $limit optional for large data sets, the number of results to return - defaults to 500, upper limit set at 1000
1790
- * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
1791
- * @return array the total of all reports and the specific reports reports this page
1792
- * @returnf int total the total number of matching abuse reports
1793
- * @returnf array data the actual data for each reports, including:
1794
- string date date/time the abuse report was received and processed
1795
- string email the email address that reported abuse
1796
- string campaign_id the unique id for the campaign that report was made against
1797
- string type an internal type generally specifying the orginating mail provider - may not be useful outside of filling report views
1798
- */
1799
- function listAbuseReports($id, $start=0, $limit=500, $since=NULL) {
1800
- $params = array();
1801
- $params["id"] = $id;
1802
- $params["start"] = $start;
1803
- $params["limit"] = $limit;
1804
- $params["since"] = $since;
1805
- return $this->callServer("listAbuseReports", $params);
1806
- }
1807
-
1808
- /**
1809
- * Access the Growth History by Month for a given list.
1810
- *
1811
- * @section List Related
1812
- *
1813
- * @example mcapi_listGrowthHistory.php
1814
- *
1815
- * @param string $id the list id to connect to. Get by calling lists()
1816
- * @return array array of months and growth
1817
- * @returnf string month The Year and Month in question using YYYY-MM format
1818
- * @returnf int existing number of existing subscribers to start the month
1819
- * @returnf int imports number of subscribers imported during the month
1820
- * @returnf int optins number of subscribers who opted-in during the month
1821
- */
1822
- function listGrowthHistory($id) {
1823
- $params = array();
1824
- $params["id"] = $id;
1825
- return $this->callServer("listGrowthHistory", $params);
1826
- }
1827
-
1828
- /**
1829
- * Access up to the previous 180 days of daily detailed aggregated activity stats for a given list
1830
- *
1831
- * @section List Related
1832
- *
1833
- *
1834
- * @param string $id the list id to connect to. Get by calling lists()
1835
- * @return array array of array of daily values, each containing:
1836
- * @returnf string day The day in YYYY-MM-DD
1837
- * @returnf int emails_sent number of emails sent to the list
1838
- * @returnf int unique_opens number of unique opens for the list
1839
- * @returnf int recipient_clicks number of clicks for the list
1840
- * @returnf int hard_bounce number of hard bounces for the list
1841
- * @returnf int soft_bounce number of soft bounces for the list
1842
- * @returnf int abuse_reports number of abuse reports for the list
1843
- * @returnf int subs number of double optin subscribes for the list
1844
- * @returnf int unsubs number of manual unsubscribes for the list
1845
- * @returnf int other_adds number of non-double optin subscribes for the list (manual, API, or import)
1846
- * @returnf int other_removes number of non-manual unsubscribes for the list (deletions, empties, soft-bounce removals)
1847
- */
1848
- function listActivity($id) {
1849
- $params = array();
1850
- $params["id"] = $id;
1851
- return $this->callServer("listActivity", $params);
1852
- }
1853
-
1854
- /**
1855
- * Retrieve the locations (countries) that the list's subscribers have been tagged to based on geocoding their IP address
1856
- *
1857
- * @section List Related
1858
- *
1859
- * @param string $id the list id to connect to. Get by calling lists()
1860
- * @return array array of locations
1861
- * @returnf string country the country name
1862
- * @returnf string cc the 2 digit country code
1863
- * @returnf double percent the percent of subscribers in the country
1864
- * @returnf double total the total number of subscribers in the country
1865
- */
1866
- function listLocations($id) {
1867
- $params = array();
1868
- $params["id"] = $id;
1869
- return $this->callServer("listLocations", $params);
1870
- }
1871
-
1872
- /**
1873
- * Retrieve the clients that the list's subscribers have been tagged as being used based on user agents seen. Made possible by <a href="http://user-agent-string.info" target="_blank">user-agent-string.info</a>
1874
- *
1875
- * @section List Related
1876
- *
1877
- * @param string $id the list id to connect to. Get by calling lists()
1878
- * @return array the desktop and mobile user agents in use on the list
1879
- * @returnf array desktop desktop user agents and percentages
1880
- double penetration the percent of desktop clients in use
1881
- array clients a record containing the 'client', an 'icon' image url, the 'percent' using the client, and the total 'members' represented
1882
- * @returnf array mobile mobile user agents and percentages
1883
- double penetration the percent of mobile clients in use
1884
- array clients a record containing the 'client', an 'icon' image url, the 'percent' using the client, and the total 'members' represented
1885
- */
1886
- function listClients($id) {
1887
- $params = array();
1888
- $params["id"] = $id;
1889
- return $this->callServer("listClients", $params);
1890
- }
1891
-
1892
- /**
1893
- * Retrieve various templates available in the system, allowing some thing similar to our template gallery to be created.
1894
- *
1895
- * @section Template Related
1896
- * @example mcapi_templates.php
1897
- * @example xml-rpc_templates.php
1898
- *
1899
- * @param array $types optional the types of templates to return
1900
- boolean user Customer template for this user account. Defaults to true.
1901
- boolean gallery Templates from our Gallery. Note that some templates that require extra configuration are withheld. (eg, the Etsy template). Defaults to false.
1902
- boolean base Our "start from scratch" extremely basic templates
1903
- * @param string $category optional for Gallery templates only, limit to a specific template category
1904
- * @param array $inactives optional options to control how inactive templates are returned, if at all
1905
- boolean include user templates are not deleted, only set inactive. defaults to false.
1906
- boolean only only include inactive templates. defaults to false.
1907
- * @return array An array of structs, one for each template (see Returned Fields for details)
1908
- * @returnf int id Id of the template
1909
- * @returnf string name Name of the template
1910
- * @returnf string layout Layout of the template - "basic", "left_column", "right_column", or "postcard"
1911
- * @returnf string preview_image If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available
1912
- * @returnf string date_created The date/time the template was created
1913
- * @returnf bool edit_source Whether or not you are able to edit the source of a template.
1914
- */
1915
- function templates($types=array (
1916
- ), $category=NULL, $inactives=array (
1917
- )) {
1918
- $params = array();
1919
- $params["types"] = $types;
1920
- $params["category"] = $category;
1921
- $params["inactives"] = $inactives;
1922
- return $this->callServer("templates", $params);
1923
- }
1924
-
1925
- /**
1926
- * Pull details for a specific template to help support editing
1927
- *
1928
- * @section Template Related
1929
- *
1930
- * @param int $tid the template id - get from templates()
1931
- * @param string $type the template type to load - one of 'user', 'gallery', 'base'
1932
- * @return array an array of info to be used when editing
1933
- * @returnf array default_content the default content broken down into the named editable sections for the template
1934
- * @returnf array sections the valid editable section names
1935
- * @returnf string source the full source of the template as if you exported it via our template editor
1936
- * @returnf string preview similar to the source, but the rendered version of the source from our popup preview
1937
- */
1938
- function templateInfo($tid, $type='user') {
1939
- $params = array();
1940
- $params["tid"] = $tid;
1941
- $params["type"] = $type;
1942
- return $this->callServer("templateInfo", $params);
1943
- }
1944
-
1945
- /**
1946
- * Create a new user template, <strong>NOT</strong> campaign content. These templates can then be applied while creating campaigns.
1947
- *
1948
- * @section Template Related
1949
- * @example mcapi_create_template.php
1950
- * @example xml-rpc_create_template.php
1951
- *
1952
- * @param string $name the name for the template - names must be unique and a max of 50 bytes
1953
- * @param string $html a string specifying the entire template to be created. This is <strong>NOT</strong> campaign content. They are intended to utilize our <a href="http://www.mailchimp.com/resources/email-template-language/" target="_blank">template language</a>.
1954
- * @return int the new template id, otherwise an error is thrown.
1955
- */
1956
- function templateAdd($name, $html) {
1957
- $params = array();
1958
- $params["name"] = $name;
1959
- $params["html"] = $html;
1960
- return $this->callServer("templateAdd", $params);
1961
- }
1962
-
1963
- /**
1964
- * Replace the content of a user template, <strong>NOT</strong> campaign content.
1965
- *
1966
- * @section Template Related
1967
- *
1968
- * @param int $id the id of the user template to update
1969
- * @param array $values the values to updates - while both are optional, at least one should be provided. Both can be updated at the same time.
1970
- string name optional the name for the template - names must be unique and a max of 50 bytes
1971
- string html optional a string specifying the entire template to be created. This is <strong>NOT</strong> campaign content. They are intended to utilize our <a href="http://www.mailchimp.com/resources/email-template-language/" target="_blank">template language</a>.
1972
-
1973
- * @return boolean true if the template was updated, otherwise an error will be thrown
1974
- */
1975
- function templateUpdate($id, $values) {
1976
- $params = array();
1977
- $params["id"] = $id;
1978
- $params["values"] = $values;
1979
- return $this->callServer("templateUpdate", $params);
1980
- }
1981
-
1982
- /**
1983
- * Delete (deactivate) a user template
1984
- *
1985
- * @section Template Related
1986
- *
1987
- * @param int $id the id of the user template to delete
1988
- * @return boolean true if the template was deleted, otherwise an error will be thrown
1989
- */
1990
- function templateDel($id) {
1991
- $params = array();
1992
- $params["id"] = $id;
1993
- return $this->callServer("templateDel", $params);
1994
- }
1995
-
1996
- /**
1997
- * Undelete (reactivate) a user template
1998
- *
1999
- * @section Template Related
2000
- *
2001
- * @param int $id the id of the user template to reactivate
2002
- * @return boolean true if the template was deleted, otherwise an error will be thrown
2003
- */
2004
- function templateUndel($id) {
2005
- $params = array();
2006
- $params["id"] = $id;
2007
- return $this->callServer("templateUndel", $params);
2008
- }
2009
-
2010
- /**
2011
- * Retrieve lots of account information including payments made, plan info, some account stats, installed modules,
2012
- * contact info, and more. No private information like Credit Card numbers is available.
2013
- *
2014
- * @section Helper
2015
- *
2016
- * @return array containing the details for the account tied to this API Key
2017
- * @returnf string username The Account username
2018
- * @returnf string user_id The Account user unique id (for building some links)
2019
- * @returnf bool is_trial Whether the Account is in Trial mode (can only send campaigns to less than 100 emails)
2020
- * @returnf string timezone The timezone for the Account - default is "US/Eastern"
2021
- * @returnf string plan_type Plan Type - "monthly", "payasyougo", or "free"
2022
- * @returnf int plan_low <em>only for Monthly plans</em> - the lower tier for list size
2023
- * @returnf int plan_high <em>only for Monthly plans</em> - the upper tier for list size
2024
- * @returnf string plan_start_date <em>only for Monthly plans</em> - the start date for a monthly plan
2025
- * @returnf int emails_left <em>only for Free and Pay-as-you-go plans</em> emails credits left for the account
2026
- * @returnf bool pending_monthly Whether the account is finishing Pay As You Go credits before switching to a Monthly plan
2027
- * @returnf string first_payment date of first payment
2028
- * @returnf string last_payment date of most recent payment
2029
- * @returnf int times_logged_in total number of times the account has been logged into via the web
2030
- * @returnf string last_login date/time of last login via the web
2031
- * @returnf string affiliate_link Monkey Rewards link for our Affiliate program
2032
- * @returnf array contact Contact details for the account
2033
- string fname First Name
2034
- string lname Last Name
2035
- string email Email Address
2036
- string company Company Name
2037
- string address1 Address Line 1
2038
- string address2 Address Line 2
2039
- string city City
2040
- string state State or Province
2041
- string zip Zip or Postal Code
2042
- string country Country name
2043
- string url Website URL
2044
- string phone Phone number
2045
- string fax Fax number
2046
- * @returnf array modules Addons installed in the account
2047
- string name The module name
2048
- string added The date the module was added
2049
- * @returnf array orders Order details for the account
2050
- int order_id The order id
2051
- string type The order type - either "monthly" or "credits"
2052
- double amount The order amount
2053
- string date The order date
2054
- double credits_used The total credits used
2055
- * @returnf array rewards Rewards details for the account including credits & inspections earned, number of referals, referal details, and rewards used
2056
- int referrals_this_month the total number of referrals this month
2057
- string notify_on whether or not we notify the user when rewards are earned
2058
- string notify_email the email address address used for rewards notifications
2059
- array credits Email credits earned "this_month", "total_earned", and "remaining"
2060
- array inspections Inbox Inspections earned "this_month", "total_earned", and "remaining"
2061
- array referrals All referrals, including "name", "email", "signup_date", and "type"
2062
- array applied Applied rewards, including "value", "date", "order_id", and "order_desc"
2063
- */
2064
- function getAccountDetails() {
2065
- $params = array();
2066
- return $this->callServer("getAccountDetails", $params);
2067
- }
2068
-
2069
- /**
2070
- * Have HTML content auto-converted to a text-only format. You can send: plain HTML, an array of Template content, an existing Campaign Id, or an existing Template Id. Note that this will <b>not</b> save anything to or update any of your lists, campaigns, or templates.
2071
- *
2072
- * @section Helper
2073
- * @example xml-rpc_generateText.php
2074
- *
2075
- * @param string $type The type of content to parse. Must be one of: "html", "template", "url", "cid" (Campaign Id), or "tid" (Template Id)
2076
- * @param mixed $content The content to use. For "html" expects a single string value, "template" expects an array like you send to campaignCreate, "url" expects a valid & public URL to pull from, "cid" expects a valid Campaign Id, and "tid" expects a valid Template Id on your account.
2077
- * @return string the content pass in converted to text.
2078
- */
2079
- function generateText($type, $content) {
2080
- $params = array();
2081
- $params["type"] = $type;
2082
- $params["content"] = $content;
2083
- return $this->callServer("generateText", $params);
2084
- }
2085
-
2086
- /**
2087
- * Send your HTML content to have the CSS inlined and optionally remove the original styles.
2088
- *
2089
- * @section Helper
2090
- * @example xml-rpc_inlineCss.php
2091
- *
2092
- * @param string $html Your HTML content
2093
- * @param bool $strip_css optional Whether you want the CSS &lt;style&gt; tags stripped from the returned document. Defaults to false.
2094
- * @return string Your HTML content with all CSS inlined, just like if we sent it.
2095
- */
2096
- function inlineCss($html, $strip_css=false) {
2097
- $params = array();
2098
- $params["html"] = $html;
2099
- $params["strip_css"] = $strip_css;
2100
- return $this->callServer("inlineCss", $params);
2101
- }
2102
-
2103
- /**
2104
- * List all the folders for a user account
2105
- *
2106
- * @section Folder Related
2107
- * @example mcapi_folders.php
2108
- * @example xml-rpc_folders.php
2109
- *
2110
- * @param string $type optional the type of folders to return - either "campaign" or "autoresponder". Defaults to "campaign"
2111
- * @return array Array of folder structs (see Returned Fields for details)
2112
- * @returnf int folder_id Folder Id for the given folder, this can be used in the campaigns() function to filter on.
2113
- * @returnf string name Name of the given folder
2114
- * @returnf string date_created The date/time the folder was created
2115
- * @returnf string type The type of the folders being returned, just to make sure you know.
2116
- */
2117
- function folders($type='campaign') {
2118
- $params = array();
2119
- $params["type"] = $type;
2120
- return $this->callServer("folders", $params);
2121
- }
2122
-
2123
- /**
2124
- * Add a new folder to file campaigns or autoresponders in
2125
- *
2126
- * @section Folder Related
2127
- * @example mcapi_folderAdd.php
2128
- * @example xml-rpc_folderAdd.php
2129
- *
2130
- * @param string $name a unique name for a folder (max 100 bytes)
2131
- * @param string $type optional the type of folder to create - either "campaign" or "autoresponder". Defaults to "campaign"
2132
- * @return int the folder_id of the newly created folder.
2133
- */
2134
- function folderAdd($name, $type='campaign') {
2135
- $params = array();
2136
- $params["name"] = $name;
2137
- $params["type"] = $type;
2138
- return $this->callServer("folderAdd", $params);
2139
- }
2140
-
2141
- /**
2142
- * Update the name of a folder for campaigns or autoresponders
2143
- *
2144
- * @section Folder Related
2145
- *
2146
- * @param int $fid the folder id to update - retrieve from folders()
2147
- * @param string $name a new, unique name for the folder (max 100 bytes)
2148
- * @param string $type optional the type of folder to create - either "campaign" or "autoresponder". Defaults to "campaign"
2149
- * @return bool true if the update worked, otherwise an exception is thrown
2150
- */
2151
- function folderUpdate($fid, $name, $type='campaign') {
2152
- $params = array();
2153
- $params["fid"] = $fid;
2154
- $params["name"] = $name;
2155
- $params["type"] = $type;
2156
- return $this->callServer("folderUpdate", $params);
2157
- }
2158
-
2159
- /**
2160
- * Delete a campaign or autoresponder folder. Note that this will simply make campaigns in the folder appear unfiled, they are not removed.
2161
- *
2162
- * @section Folder Related
2163
- *
2164
- * @param int $fid the folder id to update - retrieve from folders()
2165
- * @param string $type optional the type of folder to create - either "campaign" or "autoresponder". Defaults to "campaign"
2166
- * @return bool true if the delete worked, otherwise an exception is thrown
2167
- */
2168
- function folderDel($fid, $type='campaign') {
2169
- $params = array();
2170
- $params["fid"] = $fid;
2171
- $params["type"] = $type;
2172
- return $this->callServer("folderDel", $params);
2173
- }
2174
-
2175
- /**
2176
- * Retrieve the Ecommerce Orders for an account
2177
- *
2178
- * @section Ecommerce
2179
- *
2180
- * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
2181
- * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 500
2182
- * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
2183
- * @return array the total matching orders and the specific orders for the requested page
2184
- * @returnf int total the total matching orders
2185
- * @returnf array data the actual data for each order being returned
2186
- string store_id the store id generated by the plugin used to uniquely identify a store
2187
- string store_name the store name collected by the plugin - often the domain name
2188
- string order_id the internal order id the store tracked this order by
2189
- string email the email address that received this campaign and is associated with this order
2190
- double order_total the order total
2191
- double tax_total the total tax for the order (if collected)
2192
- double ship_total the shipping total for the order (if collected)
2193
- string order_date the date the order was tracked - from the store if possible, otherwise the GMT time we recieved it
2194
- array lines containing detail of the order - product, category, quantity, item cost
2195
- */
2196
- function ecommOrders($start=0, $limit=100, $since=NULL) {
2197
- $params = array();
2198
- $params["start"] = $start;
2199
- $params["limit"] = $limit;
2200
- $params["since"] = $since;
2201
- return $this->callServer("ecommOrders", $params);
2202
- }
2203
-
2204
- /**
2205
- * Import Ecommerce Order Information to be used for Segmentation. This will generally be used by ecommerce package plugins
2206
- * <a href="/plugins/ecomm360.phtml">that we provide</a> or by 3rd part system developers.
2207
- * @section Ecommerce
2208
- *
2209
- * @param array $order an array of information pertaining to the order that has completed. Use the following keys:
2210
- string id the Order Id
2211
- string email_id optional (kind of) the Email Id of the subscriber we should attach this order to (see the "mc_eid" query string variable a campaign passes) - either this or <strong>email</strong> is required. If both are provided, email_id takes precedence
2212
- string email optional (kind of) the Email Address we should attach this order to - either this or <strong>email_id</strong> is required. If both are provided, email_id takes precedence
2213
- double total The Order Total (ie, the full amount the customer ends up paying)
2214
- string order_date optional the date of the order - if this is not provided, we will default the date to now
2215
- double shipping optional the total paid for Shipping Fees
2216
- double tax optional the total tax paid
2217
- string store_id a unique id for the store sending the order in (20 bytes max)
2218
- string store_name optional a "nice" name for the store - typically the base web address (ie, "store.mailchimp.com"). We will automatically update this if it changes (based on store_id)
2219
- string plugin_id the MailChimp assigned Plugin Id. Get yours by <a href="/api/register.php">registering here</a>
2220
- string campaign_id optional the Campaign Id to track this order with (see the "mc_cid" query string variable a campaign passes)
2221
- array items the individual line items for an order using these keys:
2222
- <div style="padding-left:30px"><table><tr><td colspan=*>
2223
- int line_num optional the line number of the item on the order. We will generate these if they are not passed
2224
- int product_id the store's internal Id for the product. Lines that do no contain this will be skipped
2225
- string product_name the product name for the product_id associated with this item. We will auto update these as they change (based on product_id)
2226
- int category_id the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario
2227
- string category_name the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc.
2228
- double qty the quantity of the item ordered
2229
- double cost the cost of a single item (ie, not the extended cost of the line)
2230
- </td></tr></table></div>
2231
- * @return bool true if the data is saved, otherwise an error is thrown.
2232
- */
2233
- function ecommOrderAdd($order) {
2234
- $params = array();
2235
- $params["order"] = $order;
2236
- return $this->callServer("ecommOrderAdd", $params);
2237
- }
2238
-
2239
- /**
2240
- * Delete Ecommerce Order Information used for segmentation. This will generally be used by ecommerce package plugins
2241
- * <a href="/plugins/ecomm360.phtml">that we provide</a> or by 3rd part system developers.
2242
- * @section Ecommerce
2243
- *
2244
- * @param string $store_id the store id the order belongs to
2245
- * @param string $order_id the order id (generated by the store) to delete
2246
- * @return bool true if an order is deleted, otherwise an error is thrown.
2247
- */
2248
- function ecommOrderDel($store_id, $order_id) {
2249
- $params = array();
2250
- $params["store_id"] = $store_id;
2251
- $params["order_id"] = $order_id;
2252
- return $this->callServer("ecommOrderDel", $params);
2253
- }
2254
-
2255
- /**
2256
- * Retrieve all List Ids a member is subscribed to.
2257
- *
2258
- * @section Helper
2259
- *
2260
- * @param string $email_address the email address to check OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns
2261
- * @return array An array of list_ids the member is subscribed to.
2262
- */
2263
- function listsForEmail($email_address) {
2264
- $params = array();
2265
- $params["email_address"] = $email_address;
2266
- return $this->callServer("listsForEmail", $params);
2267
- }
2268
-
2269
- /**
2270
- * Retrieve all Campaigns Ids a member was sent
2271
- *
2272
- * @section Helper
2273
- *
2274
- * @param string $email_address the email address to unsubscribe OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns
2275
- * @return array An array of campaign_ids the member received
2276
- */
2277
- function campaignsForEmail($email_address) {
2278
- $params = array();
2279
- $params["email_address"] = $email_address;
2280
- return $this->callServer("campaignsForEmail", $params);
2281
- }
2282
-
2283
- /**
2284
- * Return the current Chimp Chatter messages for an account.
2285
- *
2286
- * @section Helper
2287
- *
2288
- * @return array An array of chatter messages and properties
2289
- * @returnf string message The chatter message
2290
- * @returnf string type The type of the message - one of lists:new-subscriber, lists:unsubscribes, lists:profile-updates, campaigns:facebook-likes, campaigns:facebook-comments, campaigns:forward-to-friend, lists:imports, or campaigns:inbox-inspections
2291
- * @returnf string url a url into the web app that the message could link to
2292
- * @returnf string list_id the list_id a message relates to, if applicable
2293
- * @returnf string campaign_id the list_id a message relates to, if applicable
2294
- * @returnf string update_time The date/time the message was last updated
2295
- */
2296
- function chimpChatter() {
2297
- $params = array();
2298
- return $this->callServer("chimpChatter", $params);
2299
- }
2300
-
2301
- /**
2302
- * Retrieve a list of all MailChimp API Keys for this User
2303
- *
2304
- * @section Security Related
2305
- * @example xml-rpc_apikeyAdd.php
2306
- * @example mcapi_apikeyAdd.php
2307
- *
2308
- * @param string $username Your MailChimp user name
2309
- * @param string $password Your MailChimp password
2310
- * @param boolean $expired optional - whether or not to include expired keys, defaults to false
2311
- * @return array an array of API keys including:
2312
- * @returnf string apikey The api key that can be used
2313
- * @returnf string created_at The date the key was created
2314
- * @returnf string expired_at The date the key was expired
2315
- */
2316
- function apikeys($username, $password, $expired=false) {
2317
- $params = array();
2318
- $params["username"] = $username;
2319
- $params["password"] = $password;
2320
- $params["expired"] = $expired;
2321
- return $this->callServer("apikeys", $params);
2322
- }
2323
-
2324
- /**
2325
- * Add an API Key to your account. We will generate a new key for you and return it.
2326
- *
2327
- * @section Security Related
2328
- * @example xml-rpc_apikeyAdd.php
2329
- *
2330
- * @param string $username Your MailChimp user name
2331
- * @param string $password Your MailChimp password
2332
- * @return string a new API Key that can be immediately used.
2333
- */
2334
- function apikeyAdd($username, $password) {
2335
- $params = array();
2336
- $params["username"] = $username;
2337
- $params["password"] = $password;
2338
- return $this->callServer("apikeyAdd", $params);
2339
- }
2340
-
2341
- /**
2342
- * Expire a Specific API Key. Note that if you expire all of your keys, just visit <a href="http://admin.mailchimp.com/account/api" target="_blank">your API dashboard</a>
2343
- * to create a new one. If you are trying to shut off access to your account for an old developer, change your
2344
- * MailChimp password, then expire all of the keys they had access to. Note that this takes effect immediately, so make
2345
- * sure you replace the keys in any working application before expiring them! Consider yourself warned...
2346
- *
2347
- * @section Security Related
2348
- * @example mcapi_apikeyExpire.php
2349
- * @example xml-rpc_apikeyExpire.php
2350
- *
2351
- * @param string $username Your MailChimp user name
2352
- * @param string $password Your MailChimp password
2353
- * @return boolean true if it worked, otherwise an error is thrown.
2354
- */
2355
- function apikeyExpire($username, $password) {
2356
- $params = array();
2357
- $params["username"] = $username;
2358
- $params["password"] = $password;
2359
- return $this->callServer("apikeyExpire", $params);
2360
- }
2361
-
2362
- /**
2363
- * "Ping" the MailChimp API - a simple method you can call that will return a constant value as long as everything is good. Note
2364
- * than unlike most all of our methods, we don't throw an Exception if we are having issues. You will simply receive a different
2365
- * string back that will explain our view on what is going on.
2366
- *
2367
- * @section Helper
2368
- * @example xml-rpc_ping.php
2369
- *
2370
- * @return string returns "Everything's Chimpy!" if everything is chimpy, otherwise returns an error message
2371
- */
2372
- function ping() {
2373
- $params = array();
2374
- return $this->callServer("ping", $params);
2375
- }
2376
-
2377
- /**
2378
- * Internal function - proxy method for certain XML-RPC calls | DO NOT CALL
2379
- * @param mixed Method to call, with any parameters to pass along
2380
- * @return mixed the result of the call
2381
- */
2382
- function callMethod() {
2383
- $params = array();
2384
- return $this->callServer("callMethod", $params);
2385
- }
2386
-
2387
- /**
2388
- * Actually connect to the server and call the requested methods, parsing the result
2389
- * You should never have to call this function manually
2390
- */
2391
- function callServer($method, $params) {
2392
- $dc = "us1";
2393
- if (strstr($this->api_key,"-")){
2394
- list($key, $dc) = explode("-",$this->api_key,2);
2395
- if (!$dc) $dc = "us1";
2396
- }
2397
- $host = $dc.".".$this->apiUrl["host"];
2398
- $params["apikey"] = $this->api_key;
2399
-
2400
- $this->errorMessage = "";
2401
- $this->errorCode = "";
2402
- $sep_changed = false;
2403
- //sigh, apparently some distribs change this to &amp; by default
2404
- if (ini_get("arg_separator.output")!="&"){
2405
- $sep_changed = true;
2406
- $orig_sep = ini_get("arg_separator.output");
2407
- ini_set("arg_separator.output", "&");
2408
- }
2409
- $post_vars = http_build_query($params);
2410
- if ($sep_changed){
2411
- ini_set("arg_separator.output", $orig_sep);
2412
- }
2413
-
2414
- $payload = "POST " . $this->apiUrl["path"] . "?" . $this->apiUrl["query"] . "&method=" . $method . " HTTP/1.0\r\n";
2415
- $payload .= "Host: " . $host . "\r\n";
2416
- $payload .= "User-Agent: MCAPI/" . $this->version ."\r\n";
2417
- $payload .= "Content-type: application/x-www-form-urlencoded\r\n";
2418
- $payload .= "Content-length: " . strlen($post_vars) . "\r\n";
2419
- $payload .= "Connection: close \r\n\r\n";
2420
- $payload .= $post_vars;
2421
-
2422
- ob_start();
2423
- if ($this->secure){
2424
- $sock = fsockopen("ssl://".$host, 443, $errno, $errstr, 30);
2425
- } else {
2426
- $sock = fsockopen($host, 80, $errno, $errstr, 30);
2427
- }
2428
- if(!$sock) {
2429
- $this->errorMessage = "Could not connect (ERR $errno: $errstr)";
2430
- $this->errorCode = "-99";
2431
- ob_end_clean();
2432
- return false;
2433
- }
2434
-
2435
- $response = "";
2436
- fwrite($sock, $payload);
2437
- stream_set_timeout($sock, $this->timeout);
2438
- $info = stream_get_meta_data($sock);
2439
- while ((!feof($sock)) && (!$info["timed_out"])) {
2440
- $response .= fread($sock, $this->chunkSize);
2441
- $info = stream_get_meta_data($sock);
2442
- }
2443
- fclose($sock);
2444
- ob_end_clean();
2445
- if ($info["timed_out"]) {
2446
- $this->errorMessage = "Could not read response (timed out)";
2447
- $this->errorCode = -98;
2448
- return false;
2449
- }
2450
-
2451
- list($headers, $response) = explode("\r\n\r\n", $response, 2);
2452
- $headers = explode("\r\n", $headers);
2453
- $errored = false;
2454
- foreach($headers as $h){
2455
- if (substr($h,0,26)==="X-MailChimp-API-Error-Code"){
2456
- $errored = true;
2457
- $error_code = trim(substr($h,27));
2458
- break;
2459
- }
2460
- }
2461
-
2462
- if(ini_get("magic_quotes_runtime")) $response = stripslashes($response);
2463
-
2464
- $serial = unserialize($response);
2465
- if($response && $serial === false) {
2466
- $response = array("error" => "Bad Response. Got This: " . $response, "code" => "-99");
2467
- } else {
2468
- $response = $serial;
2469
- }
2470
- if($errored && is_array($response) && isset($response["error"])) {
2471
- $this->errorMessage = $response["error"];
2472
- $this->errorCode = $response["code"];
2473
- return false;
2474
- } elseif($errored){
2475
- $this->errorMessage = "No error message was found";
2476
- $this->errorCode = $error_code;
2477
- return false;
2478
- }
2479
-
2480
- return $response;
2481
- }
2482
-
2483
- }
2484
-
2485
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/views/api-settings.php CHANGED
@@ -1,48 +1,70 @@
1
- <div id="mc4wp-tab-api-settings" class="mc4wp-tab <?php if($tab == 'api-settings') { echo 'active'; } ?>">
2
 
3
- <h2>API Settings <?php if($connected) { ?><span class="status connected">CONNECTED</span> <?php } else { ?><span class="status not_connected">NOT CONNECTED</span><?php } ?></h2>
4
- <table class="form-table">
5
 
6
- <tr valign="top">
7
- <th scope="row"><label for="mailchimp_api_key">MailChimp API Key</label> <a target="_blank" href="http://admin.mailchimp.com/account/api">(?)</a></th>
8
- <td><input type="text" size="50" placeholder="Your MailChimp API key" id="mailchimp_api_key" name="mc4wp_lite[mailchimp_api_key]" value="<?php echo $opts['mailchimp_api_key']; ?>" /></td>
9
- </tr>
10
 
11
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- <p class="submit">
14
- <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
15
- </p>
 
16
 
17
  <?php if($connected) { ?>
18
- <h3>MailChimp data</h3>
19
  <p>The table below shows your cached MailChimp lists configuration. If you made any changes in your MailChimp configuration that is not yet represented in the table below, please renew the cache manually by hitting the "renew cached data" button.</p>
20
 
21
  <h4>Lists</h4>
22
  <table class="wp-list-table widefat">
23
  <thead>
24
  <tr>
25
- <th scope="col">ID</th><th scope="col">Name</th><th>Merge fields</th><th>Groupings</th>
26
  </tr>
27
  </thead>
28
  <tbody>
29
- <?php if($lists && is_array($lists)) { ?>
30
- <?php foreach($lists as $l) { if(!is_array($l)) { continue; }?>
31
- <tr valign="top">
32
- <td><?php echo $l['id']; ?></td>
33
- <td><?php echo $l['name']; ?></td>
34
- <td><a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to Pro</a></td>
35
- <td><a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to Pro</a></td>
36
- </tr>
37
- <?php } ?>
38
  <?php } else { ?>
39
- <tr><td colspan="3"><p>No lists...</p></tr></td>
40
  <?php } ?>
41
  </tbody>
42
  </table>
43
 
44
- <p><a href="<?php echo get_admin_url(null, 'admin.php?page=mailchimp-for-wp&renew-cached-data'); ?>" class="button">Renew cached data</a></p>
45
  <?php } ?>
46
 
 
 
 
 
 
 
 
 
 
 
47
  </div>
48
 
1
+ <div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
2
 
3
+ <h2>MailChimp API Settings</h2>
 
4
 
5
+ <div id="mc4wp-content">
 
 
 
6
 
7
+ <?php settings_errors(); ?>
8
+
9
+ <form action="options.php" method="post">
10
+ <?php settings_fields( 'mc4wp_lite_settings' ); ?>
11
+
12
+ <h3>MailChimp API Settings <?php if($connected) { ?><span class="status positive">CONNECTED</span> <?php } else { ?><span class="status negative">NOT CONNECTED</span><?php } ?></h3>
13
+ <table class="form-table">
14
+
15
+ <tr valign="top">
16
+ <th scope="row"><label for="mailchimp_api_key">MailChimp API Key</label></th>
17
+ <td>
18
+ <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']; ?>" />
19
+ <small><a target="_blank" href="http://admin.mailchimp.com/account/api">Get your MailChimp API key here.</a></small>
20
+ </td>
21
+
22
+ </tr>
23
 
24
+ </table>
25
+
26
+ <?php submit_button(); ?>
27
+ </form>
28
 
29
  <?php if($connected) { ?>
30
+ <h3>Cache</h3>
31
  <p>The table below shows your cached MailChimp lists configuration. If you made any changes in your MailChimp configuration that is not yet represented in the table below, please renew the cache manually by hitting the "renew cached data" button.</p>
32
 
33
  <h4>Lists</h4>
34
  <table class="wp-list-table widefat">
35
  <thead>
36
  <tr>
37
+ <th scope="col">ID</th><th scope="col">Name</th><th>Merge fields & Interest groupings</th>
38
  </tr>
39
  </thead>
40
  <tbody>
41
+ <?php
42
+ if($lists && is_array($lists)) { ?>
43
+ <?php foreach($lists as $list) { ?>
44
+ <tr valign="top">
45
+ <td><?php echo $list->id; ?></td>
46
+ <td><?php echo $list->name; ?></td>
47
+ <td><em>Only available in the premium version. <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade now.</a></em></td>
48
+ </tr>
49
+ <?php } // endforeach ?>
50
  <?php } else { ?>
51
+ <tr><td colspan="4"><p>No lists found, are you connected to MailChimp? If so, try renewing the cache.</p></td></tr>
52
  <?php } ?>
53
  </tbody>
54
  </table>
55
 
56
+ <p><form method="post"><input type="submit" name="renew-cached-data" value="Renew cached data" class="button" /></form></p>
57
  <?php } ?>
58
 
59
+ <?php include 'parts/admin-footer.php'; ?>
60
+ </div>
61
+
62
+
63
+
64
+ <div id="mc4wp-sidebar">
65
+ <?php include 'parts/admin-upgrade-to-pro.php'; ?>
66
+ <?php include 'parts/admin-need-support.php'; ?>
67
+ </div>
68
+
69
  </div>
70
 
includes/views/checkbox-settings.php CHANGED
@@ -1,66 +1,90 @@
1
- <div id="mc4wp-tab-checkbox-settings" class="mc4wp-tab <?php if($tab == 'checkbox-settings') { echo 'active'; } ?>">
2
-
3
- <?php if(empty($opts['checkbox_lists'])) { ?>
4
- <div class="updated settings-error">
5
- <p><b>Notice:</b> You must select atleast 1 list to subscribe to.</p>
6
- </diV>
7
- <?php } ?>
8
 
9
- <h2>Checkbox Settings</h2>
10
 
11
- <table class="form-table">
12
- <tr valign="top">
13
- <th scope="row">Lists</th>
14
-
 
 
 
 
 
 
 
 
 
15
  <?php // loop through lists
16
- if(!$connected) {
17
- ?><td colspan="2">Please connect to MailChimp first.</td><?php
18
- } else { ?>
 
 
 
19
  <td>
20
- <?php foreach($lists as $l) { if(!is_array($l)) { continue; }
21
- ?><input type="checkbox" id="mc4wp_checkbox_list_<?php echo $l['id']; ?>_cb" name="mc4wp_lite[checkbox_lists][<?php echo $l['id']; ?>]" value="<?php echo $l['id']; ?>" <?php if(array_key_exists($l['id'], $opts['checkbox_lists'])) echo 'checked="checked"'; ?>> <label for="mc4wp_checkbox_list_<?php echo $l['id']; ?>_cb"><?php echo $l['name']; ?></label><br /><?php
22
- } ?>
23
  </td>
24
- <td class="desc">Select lists to which people should be subscribed</td>
25
- <?php
26
- } ?>
27
-
28
- </tr>
29
- <tr valign="top">
30
- <th scope="row">Double opt-in?</th>
31
- <td><input type="radio" id="mc4wp_checkbox_double_optin_1" name="mc4wp_lite[checkbox_double_optin]" value="1" <?php if($opts['checkbox_double_optin'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_checkbox_double_optin_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_checkbox_double_optin_0" name="mc4wp_lite[checkbox_double_optin]" value="0" <?php if($opts['checkbox_double_optin'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_checkbox_double_optin_0">No</label></td>
32
- <td class="desc"></td>
33
- </tr>
34
- <tr valign="top">
35
- <th scope="row">Add the checkbox to these forms</th>
36
- <td colspan="2">
37
- <?php foreach($this->get_checkbox_compatible_plugins() as $code => $name) { ?>
38
- <label><input name="mc4wp_lite[checkbox_show_at_<?php echo $code; ?>]" value="1" type="checkbox" <?php checked($opts['checkbox_show_at_'.$code], 1); ?>> <?php echo $name; ?></label> &nbsp;
39
- <?php } ?>
40
- <label><input name="mc4wp_lite[checkbox_show_at_other_forms]" value="1" type="checkbox" <?php if($opts['checkbox_show_at_other_forms']) echo 'checked '; ?>> Other forms (manual)</label> &nbsp;
41
- </td>
42
- </tr>
43
- <tr valign="top">
44
- <th scope="row"><label for="mc4wp_checkbox_label">Checkbox label text</label></th>
45
- <td colspan="2"><input type="text" class="widefat" id="mc4wp_checkbox_label" name="mc4wp_lite[checkbox_label]" value="<?php echo esc_attr($opts['checkbox_label']); ?>" /></td>
46
- </tr>
47
- <tr valign="top">
48
- <th scope="row">Pre-check the checkbox?</th>
49
- <td><input type="radio" id="mc4wp_checkbox_precheck_1" name="mc4wp_lite[checkbox_precheck]" value="1" <?php if($opts['checkbox_precheck'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_checkbox_precheck_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_checkbox_precheck_0" name="mc4wp_lite[checkbox_precheck]" value="0" <?php if($opts['checkbox_precheck'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_checkbox_precheck_0">No</label></td>
50
- <td class="desc"></td>
51
- </tr>
52
- <tr valign="top">
53
- <th scope="row">Load some default CSS?</th>
54
- <td><input type="radio" id="mc4wp_checbox_css_1" name="mc4wp_lite[checkbox_css]" value="1" <?php if($opts['checkbox_css'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_checbox_css_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_checbox_css_0" name="mc4wp_lite[checkbox_css]" value="0" <?php if($opts['checkbox_css'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_checbox_css_0">No</label></td>
55
- <td class="desc">Tick "yes" if the checkbox appears in a weird place.</td>
56
- </tr>
57
- <tr valign="top">
58
- <td colspan="3"><p>Custom or additional styling can be applied by styling the paragraph element with ID <b>#mc4wp-checkbox</b> or it's child elements.</p></td>
59
- </tr>
60
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
- <p class="submit">
63
- <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
64
- </p>
65
 
66
- </div>
1
+ <div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
 
 
 
 
 
 
2
 
3
+ <h2>Checkbox Settings</h2>
4
 
5
+ <div id="mc4wp-content">
6
+
7
+ <?php settings_errors(); ?>
8
+ <p>To use the MailChimp for WP sign-up checkboxes, select at least one list and one form to add the checkbox to.</p>
9
+
10
+ <h3>List settings</h3>
11
+ <form action="options.php" method="post">
12
+ <?php settings_fields( 'mc4wp_lite_checkbox_settings' ); ?>
13
+
14
+ <table class="form-table">
15
+ <tr valign="top">
16
+ <th scope="row">Lists</th>
17
+
18
  <?php // loop through lists
19
+ if(empty($lists))
20
+ {
21
+ ?><td colspan="2">No lists found, are you connected to MailChimp?</td><?php
22
+ }
23
+ else
24
+ { ?>
25
  <td>
26
+ <?php foreach($lists as $list) {
27
+ ?><input type="checkbox" id="mc4wp_checkbox_list_<?php echo $list->id; ?>_cb" name="mc4wp_lite_checkbox[lists][<?php echo $list->id; ?>]" value="<?php echo $list->id; ?>" <?php if(array_key_exists($list->id, $opts['lists'])) echo 'checked="checked"'; ?>> <label for="mc4wp_checkbox_list_<?php echo $list->id; ?>_cb"><?php echo $list->name; ?></label><br /><?php
28
+ } ?>
29
  </td>
30
+ <td class="desc" <?php if(empty($opts['lists'])) { ?>style="color:red;"<?php } ?>>Select at least one MailChimp list to which people who tick a checkbox should be subscribed.</td>
31
+ <?php
32
+ }
33
+ ?>
34
+ </tr>
35
+ </table>
36
+
37
+ <h3>Checkbox settings</h3>
38
+ <table class="form-table">
39
+ <tr valign="top">
40
+ <th scope="row">Double opt-in?</th>
41
+ <td class="nowrap"><input type="radio" id="mc4wp_checkbox_double_optin_1" name="mc4wp_lite_checkbox[double_optin]" value="1" <?php if($opts['double_optin'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_checkbox_double_optin_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_checkbox_double_optin_0" name="mc4wp_lite_checkbox[double_optin]" value="0" <?php if($opts['double_optin'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_checkbox_double_optin_0">No</label></td>
42
+ <td class="desc">Tick "yes" if you want subscribers to have to confirm their email address (recommended)</td>
43
+ </tr>
44
+ <tr valign="top">
45
+ <th scope="row">Add the checkbox to these forms</th>
46
+ <td colspan="2">
47
+ <?php foreach($this->get_checkbox_compatible_plugins() as $code => $name) { ?>
48
+ <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> &nbsp;
49
+ <?php } ?>
50
+ <label><input name="mc4wp_lite_checkbox[show_at_other_forms]" value="1" type="checkbox" <?php if($opts['show_at_other_forms']) echo 'checked '; ?>> Other forms (manual)</label> &nbsp;
51
+ </td>
52
+ </tr>
53
+ <tr valign="top">
54
+ <th scope="row"><label for="mc4wp_checkbox_label">Checkbox label text</label></th>
55
+ <td colspan="2"><input type="text" class="widefat" id="mc4wp_checkbox_label" name="mc4wp_lite_checkbox[label]" value="<?php echo esc_attr($opts['label']); ?>" /></td>
56
+ </tr>
57
+ <tr valign="top">
58
+ <th scope="row">Pre-check the checkbox?</th>
59
+ <td class="nowrap"><input type="radio" id="mc4wp_checkbox_precheck_1" name="mc4wp_lite_checkbox[precheck]" value="1" <?php if($opts['precheck'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_checkbox_precheck_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_checkbox_precheck_0" name="mc4wp_lite_checkbox[precheck]" value="0" <?php if($opts['precheck'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_checkbox_precheck_0">No</label></td>
60
+ <td class="desc"></td>
61
+ </tr>
62
+ <tr valign="top">
63
+ <th scope="row">Load some default CSS?</th>
64
+ <td class="nowrap"><input type="radio" id="mc4wp_checbox_css_1" name="mc4wp_lite_checkbox[css]" value="1" <?php if($opts['css'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_checbox_css_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_checbox_css_0" name="mc4wp_lite_checkbox[css]" value="0" <?php if($opts['css'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_checbox_css_0">No</label></td>
65
+ <td class="desc">Tick "yes" if the checkbox appears in a weird place.</td>
66
+ </tr>
67
+
68
+
69
+ </table>
70
+
71
+ <?php submit_button(); ?>
72
+ </form>
73
+
74
+ <?php include 'parts/admin-footer.php'; ?>
75
+
76
+ </div>
77
+ <div id="mc4wp-sidebar">
78
+ <?php include 'parts/admin-upgrade-to-pro.php'; ?>
79
+
80
+ <div class="mc4wp-box">
81
+ <h3>Styling the Sign-Up Checkbox</h3>
82
+ <p>Custom or additional styling can be done by applying CSS rules to <b>#mc4wp-checkbox</b> or its child elements.</p>
83
+ <p>You should add the CSS rules to your theme stylesheet using <strong>Appearance > Editor</strong> or by editing <em><?php echo get_stylesheet_directory(); ?>/style.css</em> over FTP.</p>
84
+ </div>
85
+
86
+ <?php include 'parts/admin-need-support.php'; ?>
87
+ </div>
88
 
 
 
 
89
 
90
+ </div>
includes/views/dashboard.php DELETED
@@ -1,142 +0,0 @@
1
- <div id="mc4wp_admin" class="wrap">
2
-
3
- <h1>MailChimp for WordPress - Configuration</h1>
4
-
5
- <ul id="mc4wp-nav">
6
- <li><a <?php if($tab == 'api-settings') echo 'class="active"'; ?> data-target="api-settings" href="admin.php?page=mailchimp-for-wp&tab=api-settings">API settings</a></li>
7
- <li><a <?php if($tab == 'checkbox-settings') echo 'class="active"'; ?> data-target="checkbox-settings" href="admin.php?page=mailchimp-for-wp&tab=checkbox-settings">Checkbox settings</a></li>
8
- <li><a <?php if($tab == 'form-settings') echo 'class="active"'; ?> data-target="form-settings" href="admin.php?page=mailchimp-for-wp&tab=form-settings">Form settings</a></li>
9
- </ul>
10
-
11
- <h2 style="display:none;"></h2>
12
- <?php settings_errors(); ?>
13
-
14
- <div id="mc4wp-main-column">
15
-
16
- <form method="post" action="options.php">
17
-
18
- <?php settings_fields( 'mc4wp_options_group' ); ?>
19
-
20
- <div id="mc4wp-tabs">
21
-
22
- <?php
23
- // include tab pages
24
- foreach($tabs as $t) {
25
- require "$t.php";
26
- }
27
-
28
- ?>
29
-
30
- </div>
31
-
32
- </form>
33
-
34
- <p class="copyright-notice">I would like to remind you that this plugin is not developed by or affiliated with MailChimp in any way.
35
- My name is <a href="http://dannyvankooten.com/">Danny van Kooten</a> and I am a young Dutch webdeveloper.</p>
36
- <p class="copyright-notice">Enjoying MailChimp for WP Lite? Consider <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">upgrading to the premium version</a>, it's awesome.</p>
37
-
38
- </div>
39
-
40
- <div id="mc4wp-secondary-column">
41
-
42
- <div class="mc4wp-box" id="mc4wp-upgrade-box">
43
- <h3>Get MailChimp for WP Pro</h3>
44
-
45
- <p>Enjoying the "lite" version of MailChimp for WordPress? You will <strong style="font-size:13px">LOVE</strong> MailChimp for WP Pro.</p>
46
-
47
- <p style="text-align: center;"><a target="_blank" class="upgrade-button" href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to MailChimp for WP Pro</a></p>
48
-
49
- <p><strong>Pro features include..</strong>
50
- <ul>
51
- <li>AJAX form submission (no page reload after clicking submit)</li>
52
- <li>Multiple sign-up forms for different lists</li>
53
- <li>Presets for all your merge fields, makes it super easy to add new fields</li>
54
- <li>Subscribers log, keep track of subscribers</li>
55
- <li>Statistical charts, gain valuable insight when and how your visitors subscribed</li>
56
- <li>Premium support</li>
57
- </ul>
58
- </p>
59
-
60
- <p>Alternative ways to show your appreciation:</p>
61
- <ul>
62
- <li><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform">Give a 5&#9733; review on WordPress.org</a></li>
63
- <li><a target="_blank" href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Link to the plugin page on my website</a></li>
64
- <li><a target="_blank" href="http://twitter.com/?status=I%20manage%20my%20%23WordPress%20sign-up%20forms%20using%20MailChimp%20for%20WP%20and%20I%20love%20it%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fmailchimp-for-wp%2F">Tweet about MailChimp for WP</a></li>
65
- </ul>
66
-
67
- <p>Everything is much appreciated. Thanks and enjoy my plugin!</p>
68
- </div>
69
-
70
- <div class="mc4wp-box" id="mc4wp-info-tabs">
71
- <div class="info-tab info-tab-form-settings" <?php if($tab != 'form-settings') { echo 'style="display:none;"'; } ?>>
72
- <h4>Notes regarding the form designer</h4>
73
- <p>At a minimum, your form should include an <strong>EMAIL</strong> field and a submit button.</p>
74
-
75
- <p>Add other fields if you like but keep in mind that...</p>
76
- <ul class="ul-square">
77
- <li>...all field names should be uppercased</li>
78
- <li>... field names should match your MailChimp lists merge tags</li>
79
- </ul>
80
-
81
- <p><strong>Styling</strong></p>
82
- <p>Alter the visual appearance of the form by applying CSS rules to <b>form.mc4wp-form</b>. Add these CSS rules to your theme's stylesheet
83
- which can in most cases be found here: <em><?php echo get_stylesheet_directory(); ?>/style.css</em>.</p>
84
- <p>The <a href="http://wordpress.org/plugins/mailchimp-for-wp/faq/" target="_blank">MailChimp for WP FAQ</a> lists the various CSS selectors you can use to target the different elements.</p>
85
-
86
- <p><strong>Form variables</strong></p>
87
- <table class="mc4wp-help">
88
- <tr>
89
- <th>{n}</th>
90
- <td>Replaced with a unique number for this form.</td>
91
- </tr>
92
- <tr>
93
- <th>{ip}</th>
94
- <td>Replaced with the visitor's IP address.</td>
95
- </tr>
96
- <tr>
97
- <th>{date}</th>
98
- <td>Replaced with the current date (yyyy/mm/dd eg: <?php echo date("Y/m/d"); ?>)</td>
99
- </tr>
100
- <tr>
101
- <th>{time}</th>
102
- <td>Replaced with the current time (hh:mm:ss eg: <?php echo date("H:i:s"); ?>)</td>
103
- </tr>
104
- <tr>
105
- <th>{user_email}</th>
106
- <td>Replaced with the logged in user's email (or nothing, if there is no logged in user).</td>
107
- </tr>
108
- <tr>
109
- <th>{user_name}</th>
110
- <td>Display name of the current user</td>
111
- </tr>
112
- <tr>
113
- <th>{user_firstname}</th>
114
- <td>First name of the current user</td>
115
- </tr>
116
- <tr>
117
- <th>{user_lastname}</th>
118
- <td>Last name of the current user</td>
119
- </tr>
120
- <tr>
121
- <th>{user_id}</th>
122
- <td>Current user ID</td>
123
- </tr>
124
- <tr>
125
- <th>{current_url}</th>
126
- <td>Current URL</td>
127
- </tr>
128
- </table>
129
-
130
- </div>
131
- </div>
132
-
133
- <div class="mc4wp-box">
134
- <h3>Looking for support?</h3>
135
- <p>Having trouble? Please use the <a href="http://wordpress.org/support/plugin/mailchimp-for-wp">support forums</a> on WordPress.org.</p>
136
- </div>
137
-
138
- </div>
139
-
140
-
141
-
142
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/views/form-settings.php CHANGED
@@ -1,117 +1,220 @@
1
- <div id="mc4wp-tab-form-settings" class="mc4wp-tab <?php if($tab == 'form-settings') { echo 'active'; } ?>">
2
-
3
- <?php if(empty($opts['form_lists'])) { ?>
4
- <div class="updated settings-error">
5
- <p><b>Notice:</b> You must select atleast 1 list to subscribe to.</p>
6
- </diV>
7
- <?php } ?>
8
 
9
- <h2>Form Settings</h2>
10
-
11
- <p>MailChimp for WP comes packed with a neat shortcode you can use in your posts, pages or text widgets to display a sign-up form.
12
- Configure the form below, 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 and watch your list(s) grow!</p>
13
 
 
14
 
15
- <table class="form-table">
16
- <tr valign="top">
17
- <th scope="row">Lists</th>
 
 
 
 
 
 
 
 
 
18
  <?php // loop through lists
19
- if(!$connected) {
20
- ?><td colspan="2">Please connect to MailChimp first.</td><?php
21
  } else { ?>
22
  <td>
23
- <?php foreach($lists as $l) { if(!is_array($l)) { continue; }
24
- ?><input type="checkbox" id="mc4wp_form_list_<?php echo $l['id']; ?>_cb" name="mc4wp_lite[form_lists][<?php echo $l['id']; ?>]" value="<?php echo $l['id']; ?>" <?php if(array_key_exists($l['id'], $opts['form_lists'])) echo 'checked="checked"'; ?>> <label for="mc4wp_form_list_<?php echo $l['id']; ?>_cb"><?php echo $l['name']; ?></label><br /><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  } ?>
26
- </td>
27
- <td class="desc">Select MailChimp lists for this form</td>
28
- <?php
29
- } ?>
30
-
31
- </tr>
32
- <tr valign="top">
33
- <th scope="row">Enable AJAX?</th>
34
- <td><a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to Pro to use AJAX forms</a></td>
35
- <td class="desc">Submit forms with AJAX, meaning the page doesn't have to reload.</td>
36
- </tr>
 
 
 
 
 
37
  <tr valign="top">
38
  <th scope="row">Double opt-in?</th>
39
- <td><input type="radio" id="mc4wp_form_double_optin_1" name="mc4wp_lite[form_double_optin]" value="1" <?php if($opts['form_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['form_double_optin'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_double_optin_0">No</label></td>
40
- <td class="desc"></td>
41
  </tr>
42
- <tr valign="top">
43
- <th scope="row">Load some default CSS?</th>
44
- <td><input type="radio" id="mc4wp_form_css_1" name="mc4wp_lite[form_css]" value="1" <?php if($opts['form_css'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_css_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_form_css_0" name="mc4wp_lite[form_css]" value="0" <?php if($opts['form_css'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_css_0">No</label></td>
45
- <td class="desc">Tick "yes" for basic form formatting.</td>
 
 
 
 
 
46
  </tr>
47
- <tr valign="top">
48
- <th scope="row" colspan="3" style="font-weight:bold;">Form mark-up</th>
 
 
 
 
 
 
 
49
  </tr>
50
- <tr valign="top">
51
- <td colspan="3">
52
-
53
- <div class="mc4wp-wrapper">
54
-
55
- <div class="mc4wp-col mc4wp-col-2-3 mc4wp-first">
56
- <?php
57
- if(function_exists('wp_editor')) {
58
- wp_editor( esc_textarea($opts['form_markup']), 'mc4wpformmarkup', array('tinymce' => false, 'media_buttons' => false, 'textarea_name' => 'mc4wp_lite[form_markup]'));
59
- } else {
60
- ?><textarea class="widefat" cols="160" rows="20" id="mc4wpformmarkup" name="mc4wp_lite[form_markup]"><?php echo esc_textarea($opts['form_markup']); ?></textarea><?php
61
- } ?>
62
- <p><small>Use <input type="text" onfocus="this.select();" readonly="readonly" value="[mc4wp-form]" size="10" class="mc4wp-shortcode-example"> to render this form inside a widget, post or page. </small></p>
63
- <p class="submit">
64
- <input type="submit" class="button-primary" value="<?php _e('Save All Changes') ?>" id="mc4wp-submit-form-settings" />
65
- </p> </p>
66
- </div>
67
-
68
- <div class="mc4wp-col mc4wp-col-1-3 mc4wp-last">
69
- <?php include('parts/field-wizard.php'); ?>
70
- </div>
71
- </div>
72
  </td>
 
73
  </tr>
74
- </table>
 
 
75
 
76
- <div>
77
- <h3>Visual feedback to subscriber</h3>
78
  <table class="form-table mc4wp-form-messages">
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  <tr valign="top">
80
  <th scope="row"><label for="mc4wp_form_hide_after_success">Hide form after a successful sign-up?</label></th>
81
- <td><input type="radio" id="mc4wp_form_hide_after_success_1" name="mc4wp_lite[form_hide_after_success]" value="1" <?php if($opts['form_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['form_hide_after_success'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_hide_after_success_0">No</label></td>
82
- <td class="desc">Tick "yes" to only show the success message after a successful sign-up.</td>
83
  </tr>
84
  <tr valign="top">
85
  <th scope="row"><label for="mc4wp_form_redirect">Redirect to this URL after a successful sign-up</label></th>
86
  <td colspan="2">
87
- <input type="text" class="widefat" name="mc4wp_lite[form_redirect]" id="mc4wp_form_redirect" value="<?php echo $opts['form_redirect']; ?>" />
88
  <small>Leave empty or enter <strong>0</strong> (zero) for no redirection.</small>
89
  </td>
90
  </tr>
91
- <tr valign="top">
92
- <th scope="row"><label for="mc4wp_form_text_success">Success message</label></th>
93
- <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['form_text_success']); ?>" /></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  </tr>
95
- <tr valign="top">
96
- <th scope="row"><label for="mc4wp_form_text_error">General error message</label></th>
97
- <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['form_text_error']); ?>" /></td>
98
  </tr>
99
- <tr valign="top">
100
- <th scope="row"><label for="mc4wp_form_text_invalid_email">Invalid email address message</label></th>
101
- <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['form_text_invalid_email']); ?>" /></td>
102
  </tr>
103
- <tr valign="top">
104
- <th scope="row"><label for="mc4wp_form_text_already_subscribed">Email address is already on list message</label></th>
105
- <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['form_text_already_subscribed']); ?>" /></td>
106
  </tr>
107
  <tr>
108
- <th></th>
109
- <td colspan="2"><p><small>HTML tags like &lt;a&gt; and &lt;strong&gt; etc. are allowed in the message fields.</small></p></td>
110
  </tr>
111
  </table>
112
-
113
  </div>
114
 
115
- <?php submit_button("Save All Changes"); ?>
116
-
117
- </div>
1
+ <div id="mc4wp-<?php echo $tab; ?>" class="wrap mc4wp-settings">
 
 
 
 
 
 
2
 
3
+ <h2>Form settings</h2>
 
 
 
4
 
5
+ <div id="mc4wp-content">
6
 
7
+ <?php settings_errors(); ?>
8
+
9
+ <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>
10
+
11
+ <form action="options.php" method="post">
12
+ <?php settings_fields( 'mc4wp_lite_form_settings' ); ?>
13
+
14
+ <h3>Required form settings</h3>
15
+ <table class="form-table">
16
+
17
+ <tr valign="top">
18
+ <th scope="row">MailChimp list(s)</th>
19
  <?php // loop through lists
20
+ if(empty($lists)) {
21
+ ?><td colspan="2">No lists found, are you connected to MailChimp?</td><?php
22
  } else { ?>
23
  <td>
24
+ <ul id="mc4wp-lists">
25
+ <?php foreach($lists as $list) { ?>
26
+ <li><input type="checkbox" id="mc4wp_form_list_<?php echo $list->id; ?>_cb" name="mc4wp_lite_form[lists][<?php echo $list->id; ?>]" value="<?php echo $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"'; ?>> <label for="mc4wp_form_list_<?php echo $list->id; ?>_cb"><?php echo $list->name; ?></label></li>
27
+ <?php } ?>
28
+ </ul>
29
+ </td>
30
+ <td class="desc" <?php if(empty($opts['lists'])) { ?>style="color:red;"<?php } ?>>Select at least one MailChimp list for this form</td>
31
+ <?php
32
+ } ?>
33
+
34
+ </tr>
35
+ <tr valign="top">
36
+ <td colspan="3">
37
+ <h4>Form mark-up</h4>
38
+ <div class="mc4wp-wrapper">
39
+ <div class="mc4wp-col mc4wp-col-2-3 mc4wp-first">
40
+ <?php
41
+ if(function_exists('wp_editor')) {
42
+ wp_editor( esc_textarea($opts['markup']), 'mc4wpformmarkup', array('tinymce' => false, 'media_buttons' => false, 'textarea_name' => 'mc4wp_lite_form[markup]'));
43
+ } else {
44
+ ?><textarea class="widefat" cols="160" rows="20" id="mc4wpformmarkup" name="mc4wp_lite_form[markup]"><?php echo esc_textarea($opts['markup']); ?></textarea><?php
45
  } ?>
46
+ <p><small>Use <input type="text" onfocus="this.select();" readonly="readonly" value="[mc4wp-form]" size="10" class="mc4wp-shortcode-example"> to render this form inside a widget, post or page. <u>Do not just copy the form mark-up as that will not work.</u> </small></p>
47
+ <p class="submit">
48
+ <input type="submit" class="button-primary" value="<?php _e('Save All Changes') ?>" id="mc4wp-submit-form-settings" />
49
+ </p>
50
+ </div>
51
+
52
+ <div class="mc4wp-col mc4wp-col-1-3 mc4wp-last">
53
+ <?php include('parts/admin-field-wizard.php'); ?>
54
+ </div>
55
+ </div>
56
+ </td>
57
+ </tr>
58
+ </table>
59
+
60
+ <h3>MailChimp Settings</h3>
61
+ <table class="form-table">
62
  <tr valign="top">
63
  <th scope="row">Double opt-in?</th>
64
+ <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>
65
+ <td class="desc">Tick "yes" if you want subscribers to confirm their email address (recommended)</td>
66
  </tr>
67
+ <tr class="pro-feature" valign="top">
68
+ <th scope="row">Send Welcome Email?</th>
69
+ <td class="nowrap">
70
+ <input type="radio" readonly />
71
+ <label>Yes</label> &nbsp;
72
+ <input type="radio" checked readonly />
73
+ <label>No</label> &nbsp;
74
+ </td>
75
+ <td class="desc">Tick "yes" if you want to send your lists Welcome Email if a subscribe succeeds. Only when double opt-in is disabled.</td>
76
  </tr>
77
+ <tr class="pro-feature" valign="top">
78
+ <th scope="row">Update existing subscribers?</th>
79
+ <td class="nowrap">
80
+ <input type="radio" readonly />
81
+ <label>Yes</label> &nbsp;
82
+ <input type="radio" checked readonly />
83
+ <label>No</label> &nbsp;
84
+ </td>
85
+ <td class="desc">Tick "yes" if you want to update existing subscribers instead of showing the "already subscribed" message.</td>
86
  </tr>
87
+ <tr class="pro-feature" valign="top">
88
+ <th scope="row">Replace interest groups?</th>
89
+ <td class="nowrap">
90
+ <input type="radio" checked readonly />
91
+ <label>Yes</label> &nbsp;
92
+ <input type="radio" readonly />
93
+ <label>No</label> &nbsp;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  </td>
95
+ <td class="desc">Tick "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>
96
  </tr>
97
+ </table>
98
+
99
+ <h3>Form Settings & Messages</h3>
100
 
 
 
101
  <table class="form-table mc4wp-form-messages">
102
+ <tr valign="top" class="pro-feature">
103
+ <th scope="row">Enable AJAX?</th>
104
+ <td class="nowrap">
105
+ <input type="radio" readonly /> <label>Yes</label> &nbsp;
106
+ <input type="radio" checked readonly /> <label>No</label>
107
+ </td>
108
+ <td class="desc">Tick "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/wordpress-plugins/mailchimp-for-wordpress/demo-sign-up-forms/">(demo)</a></td>
109
+ </tr>
110
+ <tr valign="top">
111
+ <th scope="row">Load some default CSS?</th>
112
+ <td class="nowrap"><input type="radio" id="mc4wp_form_css_1" name="mc4wp_lite_form[css]" value="1" <?php if($opts['css'] == 1) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_css_1">Yes</label> &nbsp; <input type="radio" id="mc4wp_form_css_0" name="mc4wp_lite_form[css]" value="0" <?php if($opts['css'] == 0) echo 'checked="checked"'; ?> /> <label for="mc4wp_form_css_0">No</label></td>
113
+ <td class="desc">Tick "yes" to load some basic form styles.</td>
114
+ </tr>
115
  <tr valign="top">
116
  <th scope="row"><label for="mc4wp_form_hide_after_success">Hide form after a successful sign-up?</label></th>
117
+ <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>
118
+ <td class="desc">Tick "yes" to hide the form fields after a successful sign-up.</td>
119
  </tr>
120
  <tr valign="top">
121
  <th scope="row"><label for="mc4wp_form_redirect">Redirect to this URL after a successful sign-up</label></th>
122
  <td colspan="2">
123
+ <input type="text" class="widefat" name="mc4wp_lite_form[redirect]" id="mc4wp_form_redirect" value="<?php echo $opts['redirect']; ?>" />
124
  <small>Leave empty or enter <strong>0</strong> (zero) for no redirection.</small>
125
  </td>
126
  </tr>
127
+ <tr valign="top">
128
+ <th scope="row"><label for="mc4wp_form_text_success">Success message</label></th>
129
+ <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']); ?>" /></td>
130
+ </tr>
131
+ <tr valign="top">
132
+ <th scope="row"><label for="mc4wp_form_text_error">General error message</label></th>
133
+ <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']); ?>" /></td>
134
+ </tr>
135
+ <tr valign="top">
136
+ <th scope="row"><label for="mc4wp_form_text_invalid_email">Invalid email address message</label></th>
137
+ <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']); ?>" /></td>
138
+ </tr>
139
+ <tr valign="top">
140
+ <th scope="row"><label for="mc4wp_form_text_already_subscribed">Email address is already on list message</label></th>
141
+ <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']); ?>" /></td>
142
+ </tr>
143
+ <tr>
144
+ <th></th>
145
+ <td colspan="2"><p><small>HTML tags like &lt;a&gt; and &lt;strong&gt; etc. are allowed in the message fields.</small></p></td>
146
+ </tr>
147
+ </table>
148
+
149
+ <?php submit_button("Save All Changes"); ?>
150
+ </form>
151
+
152
+ <?php include 'parts/admin-footer.php'; ?>
153
+ </div>
154
+ <div id="mc4wp-sidebar">
155
+ <?php include 'parts/admin-upgrade-to-pro.php'; ?>
156
+
157
+ <div class="mc4wp-box" id="mc4wp-info-tabs">
158
+ <h3>Building your sign-up form</h3>
159
+ <p>At a minimum, your form should include just an <strong>EMAIL</strong> field and a submit button. If your list requires more fields, add those too.
160
+ Field names should be uppercased and match your MailChimp list fields merge tags. The field wizard tool does this automatically.</p>
161
+
162
+ <p><strong>Styling</strong><br />
163
+ Alter the visual appearance of the form by applying CSS rules to <b>.mc4wp-form</b> and its child elements.</p>
164
+ <p>You should add the CSS rules to your theme stylesheet using <strong>Appearance > Editor</strong> or by editing <em><?php echo get_stylesheet_directory(); ?>/style.css</em> over FTP.</p>
165
+
166
+
167
+ <p>The <a href="http://wordpress.org/plugins/mailchimp-for-wp/faq/" target="_blank">MailChimp for WP FAQ</a> lists the various CSS selectors you can use to target the different elements.</p>
168
+
169
+ <p><em>PS: The premium version has a neat CSS builder. <a href="http://dannyvankooten.com/wp-content/uploads/2013/06/form-css-designer.png">Here's a screenshot</a>. Absolutely zero CSS knowledge required to create beautiful forms!</em></p>
170
+
171
+ <h3>Form variables</h3>
172
+ <p>Use the following variables to add some dynamic content to your form.</p>
173
+
174
+ <table class="mc4wp-help">
175
+ <tr>
176
+ <th>{n}</th>
177
+ <td>Replaced with a unique number for this form.</td>
178
+ </tr>
179
+ <tr>
180
+ <th>{ip}</th>
181
+ <td>Replaced with the visitor's IP address.</td>
182
+ </tr>
183
+ <tr>
184
+ <th>{date}</th>
185
+ <td>Replaced with the current date (yyyy/mm/dd eg: <?php echo date("Y/m/d"); ?>)</td>
186
+ </tr>
187
+ <tr>
188
+ <th>{time}</th>
189
+ <td>Replaced with the current time (hh:mm:ss eg: <?php echo date("H:i:s"); ?>)</td>
190
+ </tr>
191
+ <tr>
192
+ <th>{user_email}</th>
193
+ <td>Replaced with the logged in user's email (or nothing, if there is no logged in user).</td>
194
+ </tr>
195
+ <tr>
196
+ <th>{user_name}</th>
197
+ <td>Display name of the current user</td>
198
  </tr>
199
+ <tr>
200
+ <th>{user_firstname}</th>
201
+ <td>First name of the current user</td>
202
  </tr>
203
+ <tr>
204
+ <th>{user_lastname}</th>
205
+ <td>Last name of the current user</td>
206
  </tr>
207
+ <tr>
208
+ <th>{user_id}</th>
209
+ <td>Current user ID</td>
210
  </tr>
211
  <tr>
212
+ <th>{current_url}</th>
213
+ <td>Current URL</td>
214
  </tr>
215
  </table>
 
216
  </div>
217
 
218
+ <?php include 'parts/admin-need-support.php'; ?>
219
+ </div>
220
+ </div>
includes/views/parts/admin-field-wizard.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="mc4wp-fw" class="mc4wp-well">
2
+
3
+ <h4>Add a new field</h4>
4
+ <p>Use the tool below to help you add fields to your form mark-up.</p>
5
+ <p>
6
+ <select class="widefat" id="mc4wp-fw-mailchimp-fields">
7
+ <option class="default" value="" disabled selected>Select MailChimp field..</option>
8
+ <optgroup label="MailChimp merge fields" class="merge-fields"></optgroup>
9
+ <optgroup label="Interest groupings" class="groupings"></optgroup>
10
+ <optgroup label="Other" class="other">
11
+ <option class="default" value="submit">Submit button</option>
12
+ </optgroup>
13
+ </select>
14
+ </p>
15
+
16
+ <div id="mc4wp-fw-fields">
17
+
18
+ <p class="row label">
19
+ <label for="mc4wp-fw-label">Label <small>(optional)</small></label>
20
+ <input class="widefat" type="text" id="mc4wp-fw-label" />
21
+ </p>
22
+
23
+ <p class="row placeholder">
24
+ <label for="mc4wp-fw-placeholder">Placeholder <small>(optional, HTML5)</small></label>
25
+ <input class="widefat" type="text" id="mc4wp-fw-placeholder" />
26
+ </p>
27
+
28
+ <p class="row value">
29
+ <label for="mc4wp-fw-value"><span id="mc4wp-fw-value-label">Initial value <small>(optional)</small></span></label>
30
+ <input class="widefat" type="text" id="mc4wp-fw-value" />
31
+ </p>
32
+
33
+ <p class="row wrap-p">
34
+ <input type="checkbox" id="mc4wp-fw-wrap-p" value="1" checked />
35
+ <label for="mc4wp-fw-wrap-p">Wrap in paragraph (<code>&lt;p&gt;</code>) tags?</label>
36
+ </p>
37
+
38
+ <p class="row required">
39
+ <input type="checkbox" id="mc4wp-fw-required" value="1" />
40
+ <label for="mc4wp-fw-required">Required field? <small>(HTML5)</small></label>
41
+ </p>
42
+
43
+ <p>
44
+ <textarea class="widefat" id="mc4wp-fw-preview" rows="5"></textarea>
45
+ </p>
46
+
47
+ <p>
48
+ <input class="button button-large" type="button" id="mc4wp-fw-add-to-form" value="&laquo; add to form" />
49
+ </p>
50
+
51
+ </div>
52
+ </div>
includes/views/parts/admin-footer.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <br style="clear:both;" />
2
+ <p class="copyright-notice">This plugin is not developed by or affiliated with MailChimp in any way.</p>
3
+ <p class="copyright-notice">Enjoying MailChimp for WP Lite? <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to MailChimp for WordPress Pro now</a>. It's awesome, you'll love it!</p>
includes/views/parts/admin-need-support.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <div class="mc4wp-box">
2
+ <h3>Looking for support?</h3>
3
+ <p>Please use the <a href="http://wordpress.org/support/plugin/mailchimp-for-wp">support forums</a> on WordPress.org. Please do not email me directly as this is reserved for premium users only, I simply won't respond.</p>
4
+ <p>If you need priority support, <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">upgrade to the premium version</a>.</p>
5
+ </div>
includes/views/parts/admin-upgrade-to-pro.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="mc4wp-box" id="mc4wp-upgrade-box">
2
+ <h3>Upgrade to MailChimp for WP Pro</h3>
3
+
4
+ <p><em>Enjoying this free version of MailChimp for WordPress? You'll <strong>love</strong> Pro.</em></p>
5
+
6
+ <p style="text-align: center;"><a target="_blank" class="button button-primary button-hero upgrade-button" href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to MailChimp for WP Pro</a></p>
7
+
8
+ <p><strong>Benefits: </strong>AJAX powered forms (<a target="_blank" href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/demo-sign-up-forms/">demo</a>), form designer (<a href="http://dannyvankooten.com/wp-content/uploads/2013/06/form-css-designer.png">screenshot</a>), reports (line charts and log, <a href="http://dannyvankooten.com/wp-content/uploads/2013/06/mc4wp-statistics.jpg">screenshot</a>), unlocked field wizard, priority support and way more.</strong></p>
9
+
10
+ <p>Some alternative ways to show your appreciation:</p>
11
+ <ul class="ul-square">
12
+ <li><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform">Give a &#9733;&#9733;&#9733;&#9733;&#9733; review on WordPress.org</a></li>
13
+ <li><a target="_blank" href="http://twitter.com/?status=I%20manage%20my%20%23WordPress%20sign-up%20forms%20using%20MailChimp%20for%20WP%20and%20I%20love%20it%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fmailchimp-for-wp%2F">Tweet about MailChimp for WP</a></li>
14
+ <li>Write about the plugin on your blog and link to <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">the plugin page</a>.</li>
15
+ <li><a target="_blank" href="http://wordpress.org/plugins/mailchimp-for-wp/">Vote "works" on the WordPress.org plugin page</a></li>
16
+ </ul>
17
+ </div>
includes/views/parts/field-wizard.php DELETED
@@ -1,80 +0,0 @@
1
- <div id="mc4wp-fw" class="mc4wp-well">
2
-
3
- <h4>Add a new field</h4>
4
-
5
- <p>
6
- <select class="widefat" id="mc4wp-fw-type">
7
- <option value="">Select field type..</option>
8
- <option value="text">Text field</option>
9
- <option value="email">Email field (HTML5)</option>
10
- <option value="checkbox">Checkbox</option>
11
- <option value="radio">Radio button</option>
12
- <option value="hidden">Hidden field</option>
13
- <option value="submit">Submit button</option>
14
- <option value="url">URL field (HTML5)</option>
15
- <option value="date">Date field (HTML5)</option>
16
- <option value="tel">Phone no. field (HTML5)</option>
17
- </select>
18
- </p>
19
-
20
- <div class="mc4wp-fields">
21
-
22
- <p class="field-row row-preset">
23
- <label for="mc4wp-fw-preset">Preset (optional)</label>
24
- <select class="widefat" id="mc4wp-fw-preset">
25
- <option value="" disabled>Choose a preset..</option>
26
- <option value="name">Full name</option>
27
- <option value="fname">First name</option>
28
- <option value="lname">Last name</option>
29
- <option value="email">Email address</option>
30
- <option value="group">Interest group</option>
31
- </select>
32
- <small>Helps by presetting some values.</small>
33
- </p>
34
-
35
- <p class="field-row row-grouping">
36
- <label for="mc4wp-fw-grouping">Grouping ID or Name</label>
37
- <input class="widefat" type="text" id="mc4wp-fw-grouping" />
38
- </p>
39
-
40
- <p class="field-row row-name">
41
- <label for="mc4wp-fw-name">Field name*</label>
42
- <input class="widefat" type="text" id="mc4wp-fw-name" />
43
- <small>Should match your merge field tag</small>
44
- </p>
45
-
46
- <p class="field-row row-value">
47
- <label for="mc4wp-fw-value"><span id="mc4wp-fw-value-label">Initial value (optional)</span></label>
48
- <input class="widefat" type="text" id="mc4wp-fw-value" />
49
- </p>
50
-
51
- <p class="field-row row-placeholder">
52
- <label for="mc4wp-fw-placeholder">Placeholder (HTML5) <small>(optional)</small></label>
53
- <input class="widefat" type="text" id="mc4wp-fw-placeholder" />
54
- </p>
55
-
56
- <p class="field-row row-label">
57
- <label for="mc4wp-fw-label">Label <small>(optional)</small></label>
58
- <input class="widefat" type="text" id="mc4wp-fw-label" />
59
- </p>
60
-
61
- <p class="field-row row-p">
62
- <input type="checkbox" id="mc4wp-fw-p" value="1" checked />
63
- <label for="mc4wp-fw-p">Wrap in paragraph (<code>&lt;p&gt;</code>) tags?</label>
64
- </p>
65
-
66
- <p class="field-row row-req">
67
- <input type="checkbox" id="mc4wp-fw-req" value="1" />
68
- <label for="mc4wp-fw-req">Required field? (HTML5)</label>
69
- </p>
70
-
71
- <p>
72
- <textarea class="widefat" id="mc4wp-fw-preview" rows="5"></textarea>
73
- </p>
74
-
75
- <p>
76
- <input class="button button-large" type="button" id="mc4wp-fw-add-to-form" value="&laquo; add to form" />
77
- </p>
78
-
79
- </div>
80
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/admin.js DELETED
@@ -1,290 +0,0 @@
1
- (function($) {
2
-
3
- // variables
4
- var FieldWizard;
5
- // event bindings
6
- $("#mc4wp-nav a").click(function(e) {
7
- var target, wp_referer;
8
-
9
- target = $(this).attr('data-target');
10
- $("#mc4wp-tabs .mc4wp-tab.active").removeClass('active');
11
- $("#mc4wp-tab-" + target).addClass('active');
12
-
13
- // show info tabs
14
- $("#mc4wp-info-tabs .info-tab").hide();
15
- $("#mc4wp-info-tabs .info-tab-" + target).show();
16
-
17
- $("#mc4wp-nav .active").removeClass('active');
18
- $(this).addClass('active');
19
-
20
- // Change window location to add URL params
21
- if (window.history && history.replaceState) {
22
- // NOTE: doesn't take into account existing params
23
- history.replaceState("", "", $(this).attr('href'));
24
- }
25
-
26
- // update WP hidden input field
27
- $('input[name="_wp_http_referer"]').val(mc4wp_urls.admin_page + "&tab=" + target);
28
-
29
- if($("#mc4wp-tab-" + target).is(":visible")) {
30
- e.preventDefault();
31
- return false;
32
- } else {
33
- return true;
34
- }
35
-
36
- });
37
-
38
- FieldWizard = {
39
- fields: {
40
- $container: $("#mc4wp-fw .mc4wp-fields"),
41
- $fields: $("#mc4wp-fw .mc4wp-fields :input"),
42
- $fieldRows: $("#mc4wp-fw .field-row"),
43
- $textFields: $("#mc4wp-fw .mc4wp-fields :input[type='text']"),
44
- $form: $("#mc4wpformmarkup"),
45
- $grouping: $("#mc4wp-fw-grouping"),
46
- $label: $("#mc4wp-fw-label"),
47
- $name: $("#mc4wp-fw-name"),
48
- $value: $("#mc4wp-fw-value"),
49
- $placeholder: $("#mc4wp-fw-placeholder"),
50
- $type: $("#mc4wp-fw-type"),
51
- $wrapInP: $("#mc4wp-fw-p"),
52
- $preview: $("#mc4wp-fw-preview"),
53
- $required: $("#mc4wp-fw-req"),
54
- $preset: $("#mc4wp-fw-preset"),
55
- $valueLabel: $("#mc4wp-fw-value-label")
56
- },
57
- init: function() {
58
- f = this.fields;
59
-
60
- // Events
61
- f.$type.change(this.setup);
62
- f.$type.change(this.preview);
63
- f.$preset.change(this.preset);
64
- f.$name.change(this.validate.nameField);
65
- f.$grouping.change(this.validate.nameField);
66
- f.$fields.change(this.preview);
67
- $("#mc4wp-fw-add-to-form").click(FieldWizard.publish);
68
- $("#mc4wp-submit-form-settings").click(this.validate.hasEmailField);
69
- },
70
- validate: {
71
- nameField: function() {
72
- var f = FieldWizard.fields, name, arrayCharPos;
73
-
74
- if(f.$preset.val() == 'group') {
75
- if(f.$type.val() == 'checkbox' || f.$type.val() == 'radio') {
76
- f.$name.val('GROUPINGS[' + f.$grouping.val() +'][]');
77
- } else {
78
- f.$name.val('GROUPINGS[' + f.$grouping.val() +']');
79
- }
80
- return;
81
- }
82
-
83
-
84
- name = f.$name.val().trim();
85
- if((arrayCharPos = name.indexOf('[')) != -1) {
86
- name = name.substring(0, arrayCharPos).toUpperCase().replace(/\s+/g,'') + name.substring(arrayCharPos);
87
- } else {
88
- name = name.toUpperCase().replace(/\s+/g,'');
89
- }
90
-
91
- f.$name.val(name);
92
- return true;
93
- },
94
- hasEmailField: function() {
95
- // simple check to see if form mark-up contains the proper e-mail field
96
- if(FieldWizard.fields.$form.val().indexOf('="EMAIL"') == -1) {
97
- return confirm('It seems that your form does not contain an input field for the email address.' + "\n\n"
98
- + 'Please make sure your form contains an input field with a name="EMAIL" attribute.' + "\n\n"
99
- + 'Example: <input type="text" name="EMAIL"....' + "\n\n"
100
- + 'Click OK to save settings nonetheless or cancel to go back and edit the form mark-up.');
101
- }
102
-
103
- return true;
104
- }
105
- },
106
- publish: function() {
107
- var f = FieldWizard.fields, formMarkup;
108
- formMarkup = f.$form.val() + "\n" + f.$preview.val();
109
- f.$form.val(formMarkup);
110
- },
111
- preview: function() {
112
-
113
- var f = FieldWizard.fields, $p, $input, $label, fieldType, fieldId;
114
-
115
- fieldType = f.$type.val();
116
-
117
- $input = $("<input>");
118
- $input.attr('type', fieldType);
119
-
120
- if(fieldType != 'submit') { $input.attr('name', f.$name.val()); }
121
-
122
- // set a default value?
123
- if(f.$value.val().length > 0) {
124
- $input.attr('value', f.$value.val());
125
- }
126
-
127
- // generate field id
128
- if(f.$name.val().length > 0 && fieldType != 'submit' && fieldType != 'hidden') {
129
-
130
- if(fieldType == 'checkbox' || fieldType == 'radio') {
131
- fieldId = "f_" + f.$name.val().toLowerCase().replace(/[^\w-]+/g,'').replace('groupings','') + '_' + f.$value.val().toLowerCase().replace(/[^\w-]+/g,'');
132
- } else {
133
- fieldId = "f_"+ f.$name.val().toLowerCase().replace(/[^\w-]+/g,'');
134
- }
135
-
136
- $input.attr('id', fieldId);
137
- }
138
-
139
- // set placeholder attribute
140
- if(f.$placeholder.val() != '' && f.$placeholder.is(':visible')) {
141
- $input.attr('placeholder', f.$placeholder.val());
142
- }
143
-
144
- // set required attribute
145
- if(f.$required.is(":checked:visible")) {
146
- $input.attr('required', true);
147
- }
148
-
149
- $code = $input.wrap("<p />").parent();
150
-
151
- if(f.$wrapInP.is(":checked:visible")) {
152
- $p = $input.wrap("<p />").parent();
153
- $("<br>").insertBefore($input).clone().insertAfter($input);
154
- }
155
-
156
- if(f.$label.val() != '' && f.$label.is(':visible')) {
157
- $label = $("<label />");
158
- $label.attr('for', fieldId);
159
-
160
- if(fieldType == 'radio' || fieldType == 'checkbox') {
161
- // wrap $input in a <label> tag
162
- $input.wrap($label);
163
- // wrap label text in <span> tags, insert after input
164
- $("<span />").text(f.$label.val()).insertAfter($input);
165
- } else {
166
- // add label before input element
167
- $label.html(f.$label.val());
168
- $label.insertBefore($input);
169
- $("<br>").insertAfter($label);
170
- }
171
- }
172
-
173
- f.$preview.val($code.html().replace(/<br>/gi, "\n"));
174
-
175
- return;
176
- },
177
- setup: function() {
178
- var f, fieldType, visibleRows;
179
-
180
- f = FieldWizard.fields;
181
- fieldType = f.$type.val();
182
-
183
- // reset
184
- f.$container.hide();
185
- f.$fieldRows.hide();
186
- f.$textFields.val('');
187
- f.$wrapInP.attr('checked', true);
188
- f.$required.attr('checked', false);
189
- f.$preset.val('').find('option').attr('disabled', true);
190
- f.$valueLabel.html("Initial value <small>(optional)</small>");
191
-
192
- if(fieldType == '') { return; }
193
-
194
- // show the container
195
- f.$container.show();
196
-
197
- visibleRows = {
198
- text: ['preset', 'name', 'label', 'value', 'req', 'p', 'placeholder'],
199
- hidden: ['preset', 'name', 'value'],
200
- email: ['preset', 'name', 'label', 'value', 'req', 'p', 'placeholder'],
201
- checkbox: ['preset', 'name', 'label', 'value', 'p'],
202
- radio: ['preset', 'name', 'label', 'value', 'p'],
203
- submit: ['value', 'p'],
204
- date: [ 'name', 'label', 'req', 'p'],
205
- tel: [ 'name', 'label', 'req', 'p', 'placeholder'],
206
- url: [ 'name', 'label', 'req', 'p', 'placeholder']
207
- }
208
-
209
- availablePresets = {
210
- text: ['name', 'fname', 'lname', 'email'],
211
- hidden: ['group'],
212
- email: ['email'],
213
- radio: ['group'],
214
- checkbox: ['group'],
215
- submit: [],
216
-
217
- }
218
-
219
- // show field rows for chosen fieldType
220
- for(var i = 0; i < visibleRows[fieldType].length; i++) {
221
- f.$container.children('.row-' + visibleRows[fieldType][i]).show();
222
- }
223
-
224
- numberOfAvailablePresets = availablePresets[fieldType].length;
225
- if(numberOfAvailablePresets == 0) {
226
- f.$container.find('.row-preset').hide();
227
- } else {
228
- for(var i = 0; i < numberOfAvailablePresets; i++) {
229
- f.$preset.find('option[value="'+ availablePresets[fieldType][i] +'"]').removeAttr('disabled');
230
- }
231
- }
232
-
233
- // customize texts
234
- if(fieldType == 'submit') {
235
- f.$valueLabel.html('Button text');
236
- } else if(fieldType == 'checkbox' || fieldType == 'radio') {
237
- f.$valueLabel.html("Value");
238
- }
239
-
240
- return true;
241
- },
242
- preset: function() {
243
- var f = FieldWizard.fields, preset;
244
- preset = f.$preset.val();
245
-
246
- switch(preset) {
247
- case '':
248
- return false;
249
- break;
250
- case 'email':
251
- f.$label.val("Email address");
252
- f.$name.val('EMAIL');
253
- f.$placeholder.val("Your email address");
254
- f.$required.attr('checked', true);
255
- break;
256
- case 'fname':
257
- f.$label.val('First name:');
258
- f.$name.val('FNAME');
259
- f.$placeholder.val("Your first name");
260
- break;
261
- case 'lname':
262
- f.$label.val('Last name:');
263
- f.$name.val('LNAME');
264
- f.$placeholder.val("Your last name");
265
- break;
266
- case 'name':
267
- f.$label.val('Name:');
268
- f.$name.val('NAME');
269
- f.$placeholder.val("Your name");
270
- break;
271
- case 'group':
272
- f.$container.find('.row-grouping').show();
273
- f.$container.find('.row-name').hide();
274
-
275
- if(f.$type.val() == 'checkbox' || f.$type.val() == 'radio') {
276
- f.$valueLabel.html("Group name");
277
- } else {
278
- f.$valueLabel.html("Group names <small>(separated by comma)</small>");
279
- }
280
- break;
281
-
282
- }
283
- }
284
- }
285
-
286
- FieldWizard.init();
287
-
288
-
289
- })(jQuery);
290
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
mailchimp-for-wp.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MailChimp for WP Lite
4
  Plugin URI: http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/
5
  Description: MailChimp integration for WordPress, Lite. Add newsletter subscribe checkboxes to various forms. Create sign-up forms and show them in your posts, pages or widgets. <strong>Pro features:</strong> AJAX forms, easy merge var fields, subscriber logging and way more. <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to Pro now &raquo;</a>
6
- Version: 1.1.5
7
  Author: Danny van Kooten
8
  Author URI: http://dannyvanKooten.com
9
  License: GPL v3
@@ -25,8 +25,8 @@ You should have received a copy of the GNU General Public License
25
  along with this program. If not, see <http://www.gnu.org/licenses/>.
26
  */
27
 
28
- define("MC4WP_LITE_VERSION", "1.1.5");
29
 
30
  // frontend AND backend
31
  require 'includes/MC4WP_Lite.php';
32
- new MC4WP_Lite();
3
  Plugin Name: MailChimp for WP Lite
4
  Plugin URI: http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/
5
  Description: MailChimp integration for WordPress, Lite. Add newsletter subscribe checkboxes to various forms. Create sign-up forms and show them in your posts, pages or widgets. <strong>Pro features:</strong> AJAX forms, easy merge var fields, subscriber logging and way more. <a href="http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/">Upgrade to Pro now &raquo;</a>
6
+ Version: 1.2.1
7
  Author: Danny van Kooten
8
  Author URI: http://dannyvanKooten.com
9
  License: GPL v3
25
  along with this program. If not, see <http://www.gnu.org/licenses/>.
26
  */
27
 
28
+ define("MC4WP_LITE_VERSION", "1.2.1");
29
 
30
  // frontend AND backend
31
  require 'includes/MC4WP_Lite.php';
32
+ new MC4WP_Lite();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://dannyvankooten.com/donate/
4
  Tags: mailchimp, newsletter, mailinglist, email, email list, form, widget form, sign-up form, subscribe form, comments, comment form, mailchimp widget, buddypress, multisite
5
  Requires at least: 3.1
6
  Tested up to: 3.6.1
7
- Stable tag: 1.1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -24,30 +24,28 @@ Add "sign up to our newsletter" checkboxes to your comment form, registration fo
24
 
25
  **Plugin Features**
26
 
27
- * Show sign-up forms in your posts, pages and widgets by using a simple shortcode `[mc4wp-form]`
28
- * Adds a "sign-up to our newsletter" checkbox to ANY form, including your comment and registration forms.
 
 
29
  * SPAM protection, no "fake" subscribers will be added to your lists.
30
- * Create and manage sign-up forms in an easy way. No field limit!
31
- * Uses the MailChimp API, blazingly fast and reliable.
32
  * Configuring is easy, all you need is your MailChimp API key.
33
- * Compatible with [BuddyPress](http://buddypress.org/) and WordPress MultiSite registration forms.
34
- * Compatible with [bbPress](http://bbpress.org/), add a newsletter checkbox to the new topic and new reply forms.
35
- * Compatible with [Contact Form 7](http://contactform7.com/), you can use `[mc4wp_checkbox]` inside your CF7 forms.
36
 
37
- **Premium Features**
38
 
39
- * AJAX sign-up forms, so the page doesn't have to reload when clicking submit.
40
- * Multiple sign-up forms for multiple lists
41
- * Field presets for all your list's merge tags which makes it extremely easy to create sign-up forms.
42
- * Subscribers log, keep track of all sign-ups
43
- * Statistical charts, gain valuable insights when and how your visitors subscribed.
44
  * Built-in integration with [WooCommerce](http://www.woocommerce.com/) and [Easy Digital Downloads](https://easydigitaldownloads.com?ref=2123) for adding sign-up checkboxes to your checkout forms.
45
  * Premium support
46
 
47
  [Upgrade to MailChimp for WordPress Pro now >>](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
48
 
49
  = MailChimp Sign-Up Form =
50
- The plugin comes with an easy to way to build sign-up forms for your MailChimp lists. Add as many fields as you like and customize labels, placeholders, initial value's etc. in a simple way.
51
 
52
  Use the `[mc4wp-form]` shortcode to show a sign-up form in your posts, pages or text widgets.
53
 
@@ -56,8 +54,9 @@ People who comment or register on your website are valuable visitors and most li
56
 
57
  You can add sign-up checkboxes to ANY form you like, including Contact Form 7 forms.
58
 
59
- = Simple but extremely flexible =
60
- Plugins should be flexible but simple. This plugin was developed with that in mind. Most settings are optional, making configuration of the plugin really simple. However, if you are more tech-savvy the plugin has plenty of customization options.
 
61
 
62
 
63
  == Installation ==
@@ -77,14 +76,17 @@ Plugins should be flexible but simple. This plugin was developed with that in mi
77
  Yes, there is and it is awesome. Pro features include:
78
 
79
  1. (Multiple) AJAX Sign-up Forms (so the page doesn't reload after clicking the submit button)
80
- 1. Statistical charts, learn when and how your visitors subscribed.
81
- 1. Subscriber logging, keep track of everyone who subscribes and where they subscribed from.
82
- 1. Easier form creation: presets for all your merge fields
83
  1. Sign-up checkbox integration with WooCommerce and Easy Digital Downloads
84
- 1. Custom individual checkbox labels
85
  1. Premium support
86
 
87
- [Upgrade to MailChimp for WordPress Pro now >>](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
 
 
 
88
 
89
  = How can I style the sign-up form? =
90
  You can use CSS to style the sign-up form. Use the following CSS selectors.
@@ -101,7 +103,9 @@ form.mc4wp-form .mc4wp-success { ... } /* success message */
101
  form.mc4wp-form .mc4wp-error { ... } /* error messages */
102
  `
103
 
104
- Just add your CSS rules to your theme stylesheet, **/wp-content/themes/your-theme-name/style.css**.
 
 
105
 
106
  = Where can I find my MailChimp API key? =
107
  [http://kb.mailchimp.com/article/where-can-i-find-my-api-key](http://kb.mailchimp.com/article/where-can-i-find-my-api-key)
@@ -121,7 +125,6 @@ If you need more data for your merge fields, prefix the field name with `mc4wp-`
121
  = Can I add a checkbox to a third-party form? =
122
  Yes, you can. Go to MailChimp for WP > Checkbox Settings 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.
123
 
124
-
125
  *Example HTML for checkbox in third-party form*
126
  `
127
  <input type="checkbox" name="mc4wp-try-subscribe" value="1" /><label>Subscribe to our newsletter?</label>
@@ -154,18 +157,28 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
154
 
155
  == Screenshots ==
156
 
157
- 1. The MailChimp for WP settings pages.
158
  2. Add a sign-up checkbox to various places on your website.
159
  3. An example sign-up checkbox.
160
  4. An example sign-up form in my footer on dannyvankooten.com. More [MailChimp sign-up form examples](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/demo-sign-up-forms/) are available on my website.
161
- 5. You can create multiple sign-up forms in [MailChimp for WordPress Pro](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
162
- 6. Editing a form got a lot easier in the premium version.
163
- 7. Gain valuable insights which method your visitors used to subscribe for any given time period using beautiful line charts. (Premium version only)
164
 
165
 
166
  == Changelog ==
167
- = 1.1.5 =
168
- * Fixed: Form using checkbox settings for list and double opt-in instead of form settings.
 
 
 
 
 
 
 
 
 
 
169
 
170
  = 1.1.4 =
171
  * Fixed: usage of textarea elements in the form mark-up for WP3.3+.
@@ -309,8 +322,5 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
309
 
310
  == Upgrade Notice ==
311
 
312
- = 1.1.5 =
313
- Bugfix for correct form lists and double opt-in setting
314
-
315
  = 1.1.1 =
316
- Bugfix for BuddyPress sites
4
  Tags: mailchimp, newsletter, mailinglist, email, email list, form, widget form, sign-up form, subscribe form, comments, comment form, mailchimp widget, buddypress, multisite
5
  Requires at least: 3.1
6
  Tested up to: 3.6.1
7
+ Stable tag: 1.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
24
 
25
  **Plugin Features**
26
 
27
+ * Create a highly customizable sign-up form and show it in your posts, pages and widgets by using a simple shortcode `[mc4wp-form]`
28
+ * Add a "sign-up to our newsletter" checkbox to ANY form you like, like your comment form.
29
+ * Built-in integration with [BuddyPress](http://buddypress.org/) and WordPress MultiSite registration forms, [bbPress](http://bbpress.org/) new topic and new reply forms and [Contact Form 7](http://contactform7.com/) forms. You can add sign-up checkboxes to these forms with 1 simple click.
30
+ * Create sign-up forms in an easy but higly customizable way.
31
  * SPAM protection, no "fake" subscribers will be added to your lists.
32
+ * Uses the MailChimp API, superfast and reliable. Also, visitors never have to leave your website to subscribe.
 
33
  * Configuring is easy, all you need is your MailChimp API key.
 
 
 
34
 
35
+ **Premium Plugin Features**
36
 
37
+ * Form CSS designer, design beautiful sign-up forms from your admin panel. Absolutely no CSS knowledge required.
38
+ * AJAX powered sign-up forms, so the page doesn't have to reload after submitting.
39
+ * Multiple sign-up forms, for multiple lists.
40
+ * All MailChimp list fields or interest groupings can be added to your forms using the field wizard.
41
+ * Reports. Gain insights in when, where and how your visitors subscribe with the subscribers log and beautiful statistical charts.
42
  * Built-in integration with [WooCommerce](http://www.woocommerce.com/) and [Easy Digital Downloads](https://easydigitaldownloads.com?ref=2123) for adding sign-up checkboxes to your checkout forms.
43
  * Premium support
44
 
45
  [Upgrade to MailChimp for WordPress Pro now >>](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
46
 
47
  = MailChimp Sign-Up Form =
48
+ The plugin comes with an easy to way to build sign-up forms for your MailChimp lists. Add as many fields as you like and customize labels, placeholders, initial values etcetera in a simple way. Visitors never have to leave your website to subscribe to your MailChimp lists. Big plus!
49
 
50
  Use the `[mc4wp-form]` shortcode to show a sign-up form in your posts, pages or text widgets.
51
 
54
 
55
  You can add sign-up checkboxes to ANY form you like, including Contact Form 7 forms.
56
 
57
+ **More information**
58
+
59
+ Check out more [WordPress plugins](http://dannyvankooten.com/wordpress-plugins/) by [Danny van Kooten](http://dannyvankooten.com) or [contact him on Twitter](http://twitter.com/dannyvankooten).
60
 
61
 
62
  == Installation ==
76
  Yes, there is and it is awesome. Pro features include:
77
 
78
  1. (Multiple) AJAX Sign-up Forms (so the page doesn't reload after clicking the submit button)
79
+ 1. Create beautiful forms from your admin panel with the Form CSS Designer.
80
+ 1. Reports, learn when, where and how your visitors subscribed.
81
+ 1. The form field wizard makes it easy to add your MailChimp list fields to your sign-up forms.
82
  1. Sign-up checkbox integration with WooCommerce and Easy Digital Downloads
83
+ 1. Custom checkbox labels
84
  1. Premium support
85
 
86
+ [More information about MailChimp for WordPress Pro](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
87
+
88
+ = The form shows a success message but subscribers are not added to my list(s)? =
89
+ If the form shows a success message, it means the sign-up succeeded. 100%. MailChimp could have a slight delay sending the confirmation email though, just be patient.
90
 
91
  = How can I style the sign-up form? =
92
  You can use CSS to style the sign-up form. Use the following CSS selectors.
103
  form.mc4wp-form .mc4wp-error { ... } /* error messages */
104
  `
105
 
106
+ Just add your CSS rules to the end of your theme stylesheet, **/wp-content/themes/your-theme-name/style.css**.
107
+
108
+ [Upgrade to MailChimp for WordPress Pro to use the form CSS designer to create beautiful sign-up forms >>](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
109
 
110
  = Where can I find my MailChimp API key? =
111
  [http://kb.mailchimp.com/article/where-can-i-find-my-api-key](http://kb.mailchimp.com/article/where-can-i-find-my-api-key)
125
  = Can I add a checkbox to a third-party form? =
126
  Yes, you can. Go to MailChimp for WP > Checkbox Settings 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.
127
 
 
128
  *Example HTML for checkbox in third-party form*
129
  `
130
  <input type="checkbox" name="mc4wp-try-subscribe" value="1" /><label>Subscribe to our newsletter?</label>
157
 
158
  == Screenshots ==
159
 
160
+ 1. **Premium only:** Design beautiful sign-up forms using the form CSS designer.
161
  2. Add a sign-up checkbox to various places on your website.
162
  3. An example sign-up checkbox.
163
  4. An example sign-up form in my footer on dannyvankooten.com. More [MailChimp sign-up form examples](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/demo-sign-up-forms/) are available on my website.
164
+ 5. **Premium only:** Create multiple AJAX powered sign-up forms.
165
+ 6. **Premium only:** Use the field wizard to easily add advanced fields to your form mark-up. You don't have to write any HTML, if you want.
166
+ 7. **Premium only:** Gain valuable insights which method your visitors used to subscribe for any given time period using beautiful line charts. [Upgrade to the premium version now.](http://dannyvankooten.com/wordpress-plugins/mailchimp-for-wordpress/)
167
 
168
 
169
  == Changelog ==
170
+
171
+ = 1.2.1 =
172
+ * Improved: total revamp of the form field wizard, many improvements.
173
+ * Improved: some textual improvements in the setting pages
174
+ * Added: debug message to sign-up checkbox for WP administrators
175
+
176
+ = 1.2 =
177
+ * Improved: updated to MailChimp 2.0 API
178
+ * Improved: now using custom light-weight API class using the WordPress HTTP API.
179
+ * Improved: huge performance improvements on admin settings pages
180
+ * Improved: usability and responsiveness of form settings page
181
+ * Improved: clean-up
182
 
183
  = 1.1.4 =
184
  * Fixed: usage of textarea elements in the form mark-up for WP3.3+.
322
 
323
  == Upgrade Notice ==
324
 
 
 
 
325
  = 1.1.1 =
326
+ Bugfix for BuddyPress sites
uninstall.php CHANGED
@@ -5,5 +5,8 @@ if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
5
  exit();
6
 
7
  delete_option('mc4wp_lite');
 
 
 
8
  delete_transient('mc4wp_mailchimp_lists');
9
  delete_transient('mc4wp_mailchimp_lists_fallback');
5
  exit();
6
 
7
  delete_option('mc4wp_lite');
8
+ delete_option('mc4wp_lite_checkbox');
9
+ delete_option('mc4wp_lite_form');
10
+
11
  delete_transient('mc4wp_mailchimp_lists');
12
  delete_transient('mc4wp_mailchimp_lists_fallback');