MailChimp List Subscribe Form - Version 1.3

Version Description

Now using OAuth flow within plugin for user authentication

Admin UI refresh

Download this release

Release Info

Developer crowdfavorite
Plugin Icon wp plugin MailChimp List Subscribe Form
Version 1.3
Comparing to
See all releases

Code changes from version 1.2.14 to 1.3

css/admin.css CHANGED
@@ -1,10 +1,355 @@
 
 
 
 
 
 
 
1
  .error_msg {
2
- color: red;
3
- margin: 0px;
4
- font-weight: bold;
5
- }
6
- .success_msg {
7
- color: green;
8
- margin: 0px;
9
- font-weight: bold;
10
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Logged Out
2
+ --------------------------------------------------------------- */
3
+
4
+
5
+ /* Errors
6
+ --------------------------------------------------------------- */
7
+
8
  .error_msg {
9
+ background: #fadbd5;
10
+ border: 1px solid #db3a1b;
11
+ -webkit-border-radius: 6px;
12
+ -moz-border-radius: 6px;
13
+ border-radius: 6px;
14
+ box-sizing: border-box;
15
+ color: #373737;
16
+ font-size: 12px;
17
+ line-height: 16px;
18
+ margin: 12px 0;
19
+ padding: 9px;
20
+ width: 900px;
21
+ }
22
+ .success_msg,
23
+ .notes_msg {
24
+ background: #fff3d4;
25
+ border: 1px solid #febe12;
26
+ -webkit-border-radius: 6px;
27
+ -moz-border-radius: 6px;
28
+ border-radius: 6px;
29
+ box-sizing: border-box;
30
+ color: #373737;
31
+ font-size: 12px;
32
+ line-height: 16px;
33
+ margin: 12px 0;
34
+ padding: 9px;
35
+ width: 900px;
36
+ }
37
+
38
+ /* User
39
+ --------------------------------------------------------------- */
40
+
41
+ table.mc-user {
42
+ width: 900px;
43
+ margin-top: 19px;
44
+ }
45
+ table.mc-user tr {
46
+ float: right;
47
+ }
48
+ .mc-user td:first-of-type {
49
+ border-top: 1px solid #6dc5dc;
50
+ border-bottom: 1px solid #6dc5dc;
51
+ border-left: 1px solid #6dc5dc;
52
+ -webkit-border-top-left-radius: 6px;
53
+ -webkit-border-bottom-left-radius: 6px;
54
+ -moz-border-radius-topleft: 6px;
55
+ -moz-border-radius-bottomleft: 6px;
56
+ border-top-left-radius: 6px;
57
+ border-bottom-left-radius: 6px;
58
+ min-width: 200px;
59
+ font-weight: normal !important;
60
+ }
61
+ .mc-user td:last-of-type {
62
+ border-top: 1px solid #6dc5dc;
63
+ border-right: 1px solid #6dc5dc;
64
+ border-bottom: 1px solid #6dc5dc;
65
+ -webkit-border-top-right-radius: 6px;
66
+ -webkit-border-bottom-right-radius: 6px;
67
+ -moz-border-radius-topright: 6px;
68
+ -moz-border-radius-bottomright: 6px;
69
+ border-top-right-radius: 6px;
70
+ border-bottom-right-radius: 6px;
71
+ min-width: 75px;
72
+ }
73
+
74
+ .mc-user h3 {
75
+ font-weight: normal;
76
+ text-indent: 9px;
77
+ font-family: "HelveticaNeue-Regular", "Helvetica Neue Regular", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
78
+ }
79
+
80
+
81
+
82
+ /* List Selection
83
+ --------------------------------------------------------------- */
84
+
85
+ .mc-list-row {
86
+ width: 900px;
87
+ margin-bottom: 12px;
88
+ }
89
+
90
+ .mc-list-row td:first-of-type {
91
+ min-width: 200px;
92
+ padding: 12px 12px 12px 0;
93
+ }
94
+ .mc-list-row td:last-of-type {
95
+ width: 80px;
96
+ padding: 12px 12px 12px 0;
97
+ }
98
+
99
+ .mc-list-note {
100
+ color: #5D5C5D;
101
+ font-size: 13px;
102
+ font-family: "HelveticaNeue-Regular", "Helvetica Neue Regular", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
103
+ font-weight: normal;
104
+ padding: 0 0 18px;
105
+ margin-bottom: 8px;
106
+ margin-top: 7px;
107
+ border-bottom: 2px solid #95D1C4;
108
+ width: 900px;
109
+ }
110
+ table.mc-list-select {
111
+ margin-bottom: -40px;
112
+ }
113
+
114
+ /* Headings
115
+ --------------------------------------------------------------- */
116
+
117
+ .mc-h2 {
118
+ color: #373737;
119
+ font-size: 26px;
120
+ margin-bottom: 0;
121
+ }
122
+
123
+ .mc-h3 {
124
+ color: #52BAD5;
125
+ font-size: 18px;
126
+ margin-bottom: 12px;
127
+ border-bottom: 2px solid #6DC5DC;
128
+ padding-bottom: 12px;
129
+ margin-top: 36px;
130
+ }
131
+
132
+ .mc-p {
133
+ color: #373737;
134
+ font-size: 16px;
135
+ font-family: "HelveticaNeue-Regular", "Helvetica Neue Regular", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
136
+ font-weight: normal;
137
+ margin-bottom: 0;
138
+ }
139
+
140
+ .mc-a {
141
+ color: #5D5C5D;
142
+ font-size: 14px;
143
+ font-family: "HelveticaNeue-Regular", "Helvetica Neue Regular", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
144
+ font-weight: normal;
145
+ margin-bottom: 0;
146
+ }
147
+
148
+ /* Header
149
+ --------------------------------------------------------------- */
150
+
151
+ .mailchimp-header {
152
+ background: url(images/mailchimp-header.png) no-repeat;
153
+ background-size: 900px 96px;
154
+ height: 96px;
155
+ width: 900px;
156
+ margin-top: 19px;
157
+ }
158
+
159
+ .mailchimp-header h2 {
160
+ float: right;
161
+ margin-top: 24px;
162
+ margin-right: 12px;
163
+ font-family: "HelveticaNeue-Bold", "Helvetica Neue Bold", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
164
+ font-weight: 700;
165
+ color: #fff !important;
166
+ text-shadow: none;
167
+ font-size: 26px !important;
168
+ }
169
+
170
+
171
+ /* Table
172
+ --------------------------------------------------------------- */
173
+
174
+ table.mc-widefat {
175
+ background: #fff !important;
176
+ border: 2px solid #95D1C4 !important;
177
+ -webkit-border-radius: 6px !important;
178
+ -moz-border-radius: 6px !important;
179
+ border-radius: 6px !important;
180
+ margin: 44px 0 36px;
181
+ }
182
+ table.mc-widefat td,
183
+ table.mc-widefat th {
184
+ border-bottom: 1px solid #C5E5DE !important;
185
+ border-top: none !important;
186
+ padding: 18px;
187
+ text-align: left;
188
+ text-shadow: none;
189
+ }
190
+
191
+ table.mc-widefat .last-row td,
192
+ table.mc-widefat .last-row th {
193
+ border-bottom: none !important;
194
+ }
195
+
196
+ table.mc-widefat th {
197
+ color: #373737 !important;
198
+ font-family: "HelveticaNeue-Bold", "Helvetica Neue Bold", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
199
+ font-weight: 700;
200
+ width: 130px;
201
+ }
202
+
203
+ table.mc-widefat td label {
204
+ padding-left: 24px;
205
+ display: block;
206
+ margin-top: -17px;
207
+ font-style: normal;
208
+ font-size: 12px;
209
+ }
210
+
211
+ table.mc-widefat td {
212
+ color: #5D5C5D !important;
213
+ font-size: 12px;
214
+ line-height: 18px !important;
215
+ }
216
+
217
+ table.mc-widefat td input {
218
+ display: inline-block;
219
+ font-style: normal;
220
+ }
221
+
222
+
223
+ table.mc-widefat tr:first-child {
224
+ background: #95D1C4 !important;
225
+ }
226
+ table.mc-widefat tr:first-child th {
227
+ color: #fff !important;
228
+ font-family: "HelveticaNeue-Bold", "Helvetica Neue Bold", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
229
+ font-size: 16px;
230
+ margin-left: 9px;
231
+ text-shadow: none;
232
+ border-bottom: none !important;
233
+ }
234
+
235
+
236
+ .mc-internal-heading {
237
+ background: rgba(197,229,222,0.25) !important;
238
+ }
239
+ table.mc-widefat tr.mc-internal-heading th {
240
+ text-shadow: none !important;
241
+ color: #449A88 !important;
242
+ }
243
+
244
+ tr.mc-turned-on th {
245
+ color: #449A88 !important;
246
+ }
247
+ .mc-custom-styling em,
248
+ .mc-custom-styling td {
249
+ font-style: normal;
250
+ font-size: 13px;
251
+ }
252
+
253
+ .mc-custom-styling td span.mc-pre-input {
254
+ width: 14px;
255
+ display: inline-block;
256
+ }
257
+
258
+ .mc-custom-styling td input {
259
+ width: 70px;
260
+ margin-right: 7px;
261
+ }
262
+
263
+
264
+
265
+
266
+ .mc-widefat.mc-blue {
267
+ background: #fff !important;
268
+ border: 2px solid #6DC5DC !important;
269
+ }
270
+
271
+ table.mc-widefat.mc-blue td,
272
+ table.mc-widefat.mc-blue th {
273
+ border-bottom: 1px solid #B1E0EC !important;
274
+ }
275
+ table.mc-widefat.mc-blue tr:first-child {
276
+ background: #6DC5DC !important;
277
+ }
278
+
279
+ .mc-widefat.mc-yellow {
280
+ background: #fff !important;
281
+ border: 2px solid #FEDE88 !important;
282
+ }
283
+
284
+ table.mc-widefat.mc-yellow td,
285
+ table.mc-widefat.mc-yellow th {
286
+ border-bottom: 1px solid #FFE8AA !important;
287
+ }
288
+ table.mc-widefat.mc-yellow tr:first-child {
289
+ background: #FEDE88 !important;
290
+ }
291
+
292
+
293
+
294
+ .mc-widefat.mc-api {
295
+ border: 2px solid #95D1C4 !important;
296
+ }
297
+
298
+ table.mc-widefat.mc-api {
299
+ margin-bottom: 19px;
300
+ margin-top: 19px;
301
+ }
302
+ table.mc-widefat.mc-api td,
303
+ table.mc-widefat.mc-api th {
304
+ border-bottom: none !important;
305
+ }
306
+ table.mc-widefat.mc-api tr:first-child {
307
+ background: #95D1C4 !important;
308
+ }
309
+
310
+ a.mc-api-key {
311
+ color: #fff;
312
+ display: block;
313
+ margin-top: 3px;
314
+ }
315
+ a.mc-api-key:hover {
316
+ color: #fff;
317
+ text-decoration: underline;
318
+ }
319
+
320
+ .mc-api-submit {
321
+ margin-bottom: 19px;
322
+ }
323
+
324
+
325
+ .mc-submit {
326
+ float: right;
327
+ clear: both;
328
+ }
329
+
330
+
331
+ .mailchimp-login {
332
+ background: #449A88;
333
+ color: #fff;
334
+ text-transform: capitalize;
335
+ padding: 8px 72px;
336
+ border-radius: 4px;
337
+ font-weight: 600;
338
+ font-size: 14px;
339
+ border-bottom: 2px solid #72C1B0;
340
+ margin-top: 2px;
341
+ position: relative;
342
+ box-sizing: border-box;
343
+ }
344
+ .mailchimp-login:hover {
345
+ background: #72C1B0;
346
+ border-color: #449A88;
347
+ color: #fff;
348
+ }
349
+ th.mailchimp-connect {
350
+ width: 100% !important;
351
+ }
352
+
353
+ #wpfooter {
354
+ margin-left: 0 !important;
355
+ }
css/images/mailchimp-header.png ADDED
Binary file
js/admin.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($) {
2
+ $('.mailchimp-login').click(function(e) {
3
+ e.preventDefault();
4
+
5
+ var login_window = window.open($(this).attr('href'), "ServiceAssociate", 'width=500,height=550'),
6
+ auth_poll = null;
7
+
8
+ auth_poll = setInterval(function() {
9
+ if (login_window.closed) {
10
+ clearInterval(auth_poll);
11
+ window.location.reload();
12
+ }
13
+ }, 100);
14
+ });
15
+ });
lib/sopresto/sopresto.php ADDED
@@ -0,0 +1,355 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Sopresto_MailChimp {
4
+ const DEFAULT_VERSION = '2.0';
5
+ var $errorMessage = '';
6
+ var $errorCode = 0;
7
+
8
+ var $apiUrl;
9
+ var $version;
10
+ var $public;
11
+ var $secret;
12
+ var $timeout = 300;
13
+ var $chunkSize = 8192;
14
+ var $secure = false;
15
+
16
+ function __construct($public, $secret, $version = self::DEFAULT_VERSION) {
17
+ $this->public = $public;
18
+ $this->secret = $secret;
19
+ $this->apiUrl = parse_url('https://sopresto.socialize-this.com/mailchimp/');
20
+ $this->setVersion($version);
21
+ }
22
+
23
+ function getApiUrl($uri = '') {
24
+ return $this->apiUrl['scheme'].'://'.$this->apiUrl['host'].$this->apiUrl['path'] . '/' . $uri;
25
+ }
26
+
27
+ function setVersion($version = self::DEFAULT_VERSION) {
28
+ if ( !in_array($version, array('1.3', '2.0') ) ) $version = self::DEFAULT_VERSION;
29
+ $this->version = $version;
30
+ }
31
+
32
+ function __call($method, $params) {
33
+ if ( $this->version == '2.0' ) {
34
+ list($module, $method) = explode('_', $method, 2);
35
+ $method = str_replace('_','-',$method);
36
+
37
+ $method = "$module/$method";
38
+ }
39
+
40
+ $this->errorMessage = '';
41
+ $this->errorCode = 0;
42
+
43
+ $public = $this->public;
44
+ $secret = $this->secret;
45
+
46
+ //some distribs change this to &amp; by default
47
+ $sep_changed = false;
48
+ if (ini_get("arg_separator.output") != "&"){
49
+ $sep_changed = true;
50
+ $orig_sep = ini_get("arg_separator.output");
51
+ ini_set("arg_separator.output", "&");
52
+ }
53
+
54
+ //mutate params
55
+ $mutate = array();
56
+ foreach($params as $k=>$v){
57
+ $mutate[$this->function_map[$this->version][$method][$k]] = $v;
58
+ }
59
+ if ( $this->version != self::DEFAULT_VERSION) $method = $this->version . "/$method";
60
+
61
+ $post_vars = array();
62
+ $post_vars['api'] = $method;
63
+ $post_vars['public_key'] = $public;
64
+ $post_vars['hash'] = sha1($public.$secret);
65
+ $post_vars['params'] = $mutate;
66
+ //return $post_vars;
67
+ $post_vars = http_build_query($post_vars);
68
+
69
+ if ($sep_changed) ini_set("arg_separator.output", $orig_sep);
70
+
71
+
72
+ $payload = "POST " . $this->apiUrl["path"] . " HTTP/1.0\r\n";
73
+ $payload .= "Host: " . $this->apiUrl["host"] . "\r\n";
74
+ $payload .= "User-Agent: Sopresto_MailChimp/1.0\r\n";
75
+ $payload .= "Content-type: application/x-www-form-urlencoded\r\n";
76
+ $payload .= "Content-length: " . strlen($post_vars) . "\r\n";
77
+ $payload .= "Connection: close \r\n\r\n";
78
+ $payload .= $post_vars;
79
+
80
+ ob_start();
81
+ if ($this->secure){
82
+ $sock = fsockopen("ssl://".$host, 443, $errno, $errstr, 30);
83
+ } else {
84
+ $sock = fsockopen($this->apiUrl["host"], 80, $errno, $errstr, 30);
85
+ }
86
+ if(!$sock) {
87
+ $this->errorMessage = "Could not connect (ERR $errno: $errstr)";
88
+ $this->errorCode = "-99";
89
+ ob_end_clean();
90
+ return false;
91
+ }
92
+
93
+ $response = "";
94
+ fwrite($sock, $payload);
95
+ stream_set_timeout($sock, $this->timeout);
96
+ $info = stream_get_meta_data($sock);
97
+ while ((!feof($sock)) && (!$info["timed_out"])) {
98
+ $response .= fread($sock, $this->chunkSize);
99
+ $info = stream_get_meta_data($sock);
100
+ }
101
+ fclose($sock);
102
+ ob_end_clean();
103
+
104
+ if ($info["timed_out"]) {
105
+ $this->errorMessage = "Could not read response (timed out)";
106
+ $this->errorCode = -98;
107
+ return false;
108
+ }
109
+
110
+ list($headers, $response) = explode("\r\n\r\n", $response, 2);
111
+ $headers = explode("\r\n", $headers);
112
+
113
+ if(ini_get("magic_quotes_runtime")) $response = stripslashes($response);
114
+
115
+ $serial = json_decode($response,true);
116
+ if($response && $serial === false) {
117
+ $response = array("error" => "Bad Response. Got This: " . $response, "code" => "-99");
118
+ } else {
119
+ $response = $serial;
120
+ }
121
+
122
+ if ( $this->version == '2.0' ) {
123
+ if ( is_array($response) && isset($response['response']['errors'][0]['code']) && $response['response']['errors'][0]['code'] ) {
124
+ $this->errorMessage = $response['response']['errors'][0]['error'];
125
+ $this->errorCode = $response['response']['errors'][0]['code'];
126
+ return false;
127
+ }
128
+ } else {
129
+ if (is_array($response) && isset($response["result"]) && $response["result"] == 'error') {
130
+ list($code, $message) = explode('||',$response['response'],2);
131
+ $this->errorMessage = $message;
132
+ $this->errorCode = $code;
133
+ return false;
134
+ }
135
+ }
136
+ return $response['response'];
137
+ }
138
+
139
+ protected $function_map = array(
140
+ '2.0' => array(
141
+ 'campaigns/content'=>array('cid', 'options'),
142
+ 'campaigns/create'=>array('type', 'options', 'content', 'segment_opts', 'type_opts'),
143
+ 'campaigns/delete'=>array('cid'),
144
+ 'campaigns/list'=>array('filters', 'start', 'limit', 'sort_field', 'sort_dir'),
145
+ 'campaigns/pause'=>array('cid'),
146
+ 'campaigns/ready'=>array('cid'),
147
+ 'campaigns/replicate'=>array('cid'),
148
+ 'campaigns/resume'=>array('cid'),
149
+ 'campaigns/schedule-batch'=>array('cid', 'schedule_time', 'num_batches', 'stagger_mins'),
150
+ 'campaigns/schedule'=>array('cid', 'schedule_time', 'schedule_time_b'),
151
+ 'campaigns/segment-test'=>array('list_id', 'options'),
152
+ 'campaigns/send'=>array('cid'),
153
+ 'campaigns/send-test'=>array('cid', 'test_emails', 'send_type'),
154
+ 'campaigns/template-content'=>array('cid'),
155
+ 'campaigns/unschedule'=>array('cid'),
156
+ 'campaigns/update'=>array('cid', 'name', 'value'),
157
+ 'ecomm/order-add'=>array('order'),
158
+ 'ecomm/order-del'=>array('store_id', 'order_id'),
159
+ 'ecomm/orders'=>array('cid', 'start', 'limit', 'since'),
160
+ 'folders/add'=>array('name', 'type'),
161
+ 'folders/del'=>array('fid', 'type'),
162
+ 'folders/list'=>array('type'),
163
+ 'folders/update'=>array('fid', 'name', 'type'),
164
+ 'gallery/list'=>array('opts'),
165
+ 'lists/abuse-reports'=>array('id', 'start', 'limit', 'since'),
166
+ 'lists/activity'=>array('id'),
167
+ 'lists/batch-subscribe'=>array('id', 'batch', 'double_optin', 'update_existing', 'replace_interests'),
168
+ 'lists/batch-unsubscribe'=>array('id', 'batch', 'delete_member', 'send_goodbye', 'send_notify'),
169
+ 'lists/clients'=>array('id'),
170
+ 'lists/growth-history'=>array('id'),
171
+ 'lists/interest-group-add'=>array('id', 'group_name', 'grouping_id'),
172
+ 'lists/interest-group-del'=>array('id', 'group_name', 'grouping_id'),
173
+ 'lists/interest-group-update'=>array('id', 'old_name', 'new_name', 'grouping_id'),
174
+ 'lists/interest-grouping-add'=>array('id', 'name', 'type', 'groups'),
175
+ 'lists/interest-grouping-del'=>array('grouping_id'),
176
+ 'lists/interest-grouping-update'=>array('grouping_id', 'name', 'value'),
177
+ 'lists/interest-groupings'=>array('id', 'counts'),
178
+ 'lists/list'=>array('filters', 'start', 'limit', 'sort_field', 'sort_dir'),
179
+ 'lists/locations'=>array('id'),
180
+ 'lists/member-activity'=>array('id', 'emails'),
181
+ 'lists/member-info'=>array('id', 'emails'),
182
+ 'lists/members'=>array('id', 'status', 'opts'),
183
+ 'lists/merge-var-add'=>array('id', 'tag', 'name', 'options'),
184
+ 'lists/merge-var-del'=>array('id', 'tag'),
185
+ 'lists/merge-var-reset'=>array('id', 'tag'),
186
+ 'lists/merge-var-set'=>array('id', 'tag', 'value'),
187
+ 'lists/merge-var-update'=>array('id', 'tag', 'options'),
188
+ 'lists/merge-vars'=>array('id'),
189
+ 'lists/static-segment-add'=>array('id', 'name'),
190
+ 'lists/static-segment-del'=>array('id', 'seg_id'),
191
+ 'lists/static-segment-members-add'=>array('id', 'seg_id', 'batch'),
192
+ 'lists/static-segment-members-del'=>array('id', 'seg_id', 'batch'),
193
+ 'lists/static-segment-reset'=>array('id', 'seg_id'),
194
+ 'lists/static-segments'=>array('id'),
195
+ 'lists/subscribe'=>array('id', 'email', 'merge_vars', 'email_type', 'double_optin', 'update_existing', 'replace_interests', 'send_welcome'),
196
+ 'lists/unsubscribe'=>array('id', 'email', 'delete_member', 'send_goodbye', 'send_notify'),
197
+ 'lists/update-member'=>array('id', 'email', 'merge_vars', 'email_type', 'replace_interests'),
198
+ 'lists/webhook-add'=>array('id', 'url', 'actions', 'sources'),
199
+ 'lists/webhook-del'=>array('id', 'url'),
200
+ 'lists/webhooks'=>array('id'),
201
+ 'helper/account-details'=>array('exclude'),
202
+ 'helper/campaigns-for-email'=>array('email', 'options'),
203
+ 'helper/chimp-chatter'=>array(),
204
+ 'helper/generate-text'=>array('type', 'content'),
205
+ 'helper/inline-css'=>array('html', 'strip_css'),
206
+ 'helper/lists-for-email'=>array('email'),
207
+ 'helper/ping'=>array(),
208
+ 'helper/search-campaigns'=>array('query', 'offset', 'snip_start', 'snip_end'),
209
+ 'helper/search-members'=>array('query', 'id', 'offset'),
210
+ 'helper/verified-domains'=>array(),
211
+ 'reports/abuse'=>array('cid', 'opts'),
212
+ 'reports/advice'=>array('cid'),
213
+ 'reports/bounce-message'=>array('cid', 'email'),
214
+ 'reports/bounce-messages'=>array('cid', 'opts'),
215
+ 'reports/click-detail'=>array('cid', 'tid', 'opts'),
216
+ 'reports/clicks'=>array('cid'),
217
+ 'reports/domain-performance'=>array('cid'),
218
+ 'reports/ecomm-orders'=>array('cid', 'opts'),
219
+ 'reports/eepurl'=>array('cid'),
220
+ 'reports/geo-opens'=>array('cid'),
221
+ 'reports/google-analytics'=>array('cid'),
222
+ 'reports/member-activity'=>array('cid', 'emails'),
223
+ 'reports/not-opened'=>array('cid', 'opts'),
224
+ 'reports/opened'=>array('cid', 'opts'),
225
+ 'reports/sent-to'=>array('cid', 'opts'),
226
+ 'reports/share'=>array('cid', 'opts'),
227
+ 'reports/summary'=>array('cid'),
228
+ 'reports/unsubscribes'=>array('cid', 'opts'),
229
+ 'templates/add'=>array('name', 'html', 'folder_id'),
230
+ 'templates/del'=>array('template_id'),
231
+ 'templates/info'=>array('template_id', 'type'),
232
+ 'templates/list'=>array('types', 'filters'),
233
+ 'templates/undel'=>array('template_id'),
234
+ 'templates/update'=>array('template_id', 'values'),
235
+ 'users/invite'=>array('email', 'role', 'msg'),
236
+ 'users/invite-resend'=>array('email'),
237
+ 'users/invite-revoke'=>array('email'),
238
+ 'users/invites'=>array(),
239
+ 'users/login-revoke'=>array('username'),
240
+ 'users/logins'=>array(),
241
+ 'vip/activity'=>array(),
242
+ 'vip/add'=>array('id', 'emails'),
243
+ 'vip/del'=>array('id', 'emails'),
244
+ 'vip/members'=>array()
245
+ ),
246
+ '1.3' => array(
247
+ 'campaignUnschedule'=>array("cid"),
248
+ 'campaignSchedule'=>array("cid","schedule_time","schedule_time_b"),
249
+ 'campaignScheduleBatch'=>array("cid","schedule_time","num_batches","stagger_mins"),
250
+ 'campaignResume'=>array("cid"),
251
+ 'campaignPause'=>array("cid"),
252
+ 'campaignSendNow'=>array("cid"),
253
+ 'campaignSendTest'=>array("cid","test_emails","send_type"),
254
+ 'campaignSegmentTest'=>array("list_id","options"),
255
+ 'campaignCreate'=>array("type","options","content","segment_opts","type_opts"),
256
+ 'campaignUpdate'=>array("cid","name","value"),
257
+ 'campaignReplicate'=>array("cid"),
258
+ 'campaignDelete'=>array("cid"),
259
+ 'campaigns'=>array("filters","start","limit","sort_field","sort_dir"),
260
+ 'campaignStats'=>array("cid"),
261
+ 'campaignClickStats'=>array("cid"),
262
+ 'campaignEmailDomainPerformance'=>array("cid"),
263
+ 'campaignMembers'=>array("cid","status","start","limit"),
264
+ 'campaignHardBounces'=>array("cid","start","limit"),
265
+ 'campaignSoftBounces'=>array("cid","start","limit"),
266
+ 'campaignUnsubscribes'=>array("cid","start","limit"),
267
+ 'campaignAbuseReports'=>array("cid","since","start","limit"),
268
+ 'campaignAdvice'=>array("cid"),
269
+ 'campaignAnalytics'=>array("cid"),
270
+ 'campaignGeoOpens'=>array("cid"),
271
+ 'campaignGeoOpensForCountry'=>array("cid","code"),
272
+ 'campaignEepUrlStats'=>array("cid"),
273
+ 'campaignBounceMessage'=>array("cid","email"),
274
+ 'campaignBounceMessages'=>array("cid","start","limit","since"),
275
+ 'campaignEcommOrders'=>array("cid","start","limit","since"),
276
+ 'campaignShareReport'=>array("cid","opts"),
277
+ 'campaignContent'=>array("cid","for_archive"),
278
+ 'campaignTemplateContent'=>array("cid"),
279
+ 'campaignOpenedAIM'=>array("cid","start","limit"),
280
+ 'campaignNotOpenedAIM'=>array("cid","start","limit"),
281
+ 'campaignClickDetailAIM'=>array("cid","url","start","limit"),
282
+ 'campaignEmailStatsAIM'=>array("cid","email_address"),
283
+ 'campaignEmailStatsAIMAll'=>array("cid","start","limit"),
284
+ 'campaignEcommOrderAdd'=>array("order"),
285
+ 'lists'=>array("filters","start","limit","sort_field","sort_dir"),
286
+ 'listMergeVars'=>array("id"),
287
+ 'listMergeVarAdd'=>array("id","tag","name","options"),
288
+ 'listMergeVarUpdate'=>array("id","tag","options"),
289
+ 'listMergeVarDel'=>array("id","tag"),
290
+ 'listMergeVarReset'=>array("id","tag"),
291
+ 'listInterestGroupings'=>array("id"),
292
+ 'listInterestGroupAdd'=>array("id","group_name","grouping_id"),
293
+ 'listInterestGroupDel'=>array("id","group_name","grouping_id"),
294
+ 'listInterestGroupUpdate'=>array("id","old_name","new_name","grouping_id"),
295
+ 'listInterestGroupingAdd'=>array("id","name","type","groups"),
296
+ 'listInterestGroupingUpdate'=>array("grouping_id","name","value"),
297
+ 'listInterestGroupingDel'=>array("grouping_id"),
298
+ 'listWebhooks'=>array("id"),
299
+ 'listWebhookAdd'=>array("id","url","actions","sources"),
300
+ 'listWebhookDel'=>array("id","url"),
301
+ 'listStaticSegments'=>array("id"),
302
+ 'listStaticSegmentAdd'=>array("id","name"),
303
+ 'listStaticSegmentReset'=>array("id","seg_id"),
304
+ 'listStaticSegmentDel'=>array("id","seg_id"),
305
+ 'listStaticSegmentMembersAdd'=>array("id","seg_id","batch"),
306
+ 'listStaticSegmentMembersDel'=>array("id","seg_id","batch"),
307
+ 'listSubscribe'=>array("id","email_address","merge_vars","email_type","double_optin","update_existing","replace_interests","send_welcome"),
308
+ 'listUnsubscribe'=>array("id","email_address","delete_member","send_goodbye","send_notify"),
309
+ 'listUpdateMember'=>array("id","email_address","merge_vars","email_type","replace_interests"),
310
+ 'listBatchSubscribe'=>array("id","batch","double_optin","update_existing","replace_interests"),
311
+ 'listBatchUnsubscribe'=>array("id","emails","delete_member","send_goodbye","send_notify"),
312
+ 'listMembers'=>array("id","status","since","start","limit","sort_dir"),
313
+ 'listMemberInfo'=>array("id","email_address"),
314
+ 'listMemberActivity'=>array("id","email_address"),
315
+ 'listAbuseReports'=>array("id","start","limit","since"),
316
+ 'listGrowthHistory'=>array("id"),
317
+ 'listActivity'=>array("id"),
318
+ 'listLocations'=>array("id"),
319
+ 'listClients'=>array("id"),
320
+ 'templates'=>array("types","category","inactives"),
321
+ 'templateInfo'=>array("tid","type"),
322
+ 'templateAdd'=>array("name","html"),
323
+ 'templateUpdate'=>array("id","values"),
324
+ 'templateDel'=>array("id"),
325
+ 'templateUndel'=>array("id"),
326
+ 'getAccountDetails'=>array("exclude"),
327
+ 'getVerifiedDomains'=>array(),
328
+ 'generateText'=>array("type","content"),
329
+ 'inlineCss'=>array("html","strip_css"),
330
+ 'folders'=>array("type"),
331
+ 'folderAdd'=>array("name","type"),
332
+ 'folderUpdate'=>array("fid","name","type"),
333
+ 'folderDel'=>array("fid","type"),
334
+ 'ecommOrders'=>array("start","limit","since"),
335
+ 'ecommOrderAdd'=>array("order"),
336
+ 'ecommOrderDel'=>array("store_id","order_id"),
337
+ 'listsForEmail'=>array("email_address"),
338
+ 'campaignsForEmail'=>array("email_address","options"),
339
+ 'chimpChatter'=>array(),
340
+ 'searchMembers'=>array("query","id","offset"),
341
+ 'searchCampaigns'=>array("query","offset","snip_start","snip_end"),
342
+ 'apikeys'=>array("username","password","expired"),
343
+ 'apikeyAdd'=>array("username","password"),
344
+ 'apikeyExpire'=>array("username","password"),
345
+ 'ping'=>array(),
346
+ 'deviceRegister'=>array("mobile_key","details"),
347
+ 'deviceUnregister'=>array("mobile_key","device_id"),
348
+ 'gmonkeyAdd'=>array("id","email_address"),
349
+ 'gmonkeyDel'=>array("id","email_address"),
350
+ 'gmonkeyMembers'=>array(),
351
+ 'gmonkeyActivity'=>array()
352
+ )
353
+ );
354
+ }
355
+
lib/sopresto/test.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require('sopresto.php');
3
+ $public = 'XXX';
4
+ $secret = 'YYY';
5
+ $version = '1.3'; // or '2.0'
6
+
7
+ $sopresto = new Sopresto_MailChimp($public, $secret, $version);
8
+
9
+ if ( $version == '2.0' ) {
10
+ // First underscore will be changed for a slash.
11
+ // Remaning underscores will be changed by a dash
12
+ // Ie.- to call 'helper/search-members' you should use $sopresto->helper_search_members()
13
+
14
+ $response = $sopresto->campaigns_list(array(), 0, 2);
15
+ } else {
16
+ $response = $sopresto->campaigns(array(), 0, 2);
17
+ }
18
+
19
+ print_r($response);
20
+
mailchimp.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MailChimp
4
  Plugin URI: http://www.mailchimp.com/plugins/mailchimp-wordpress-plugin/
5
  Description: The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list.
6
- Version: 1.2.14
7
  Author: MailChimp and Crowd Favorite
8
  Author URI: http://mailchimp.com/api/
9
  */
@@ -25,7 +25,7 @@ Author URI: http://mailchimp.com/api/
25
  */
26
 
27
  // Version constant for easy CSS refreshes
28
- define('MCSF_VER', '1.2.14');
29
 
30
  // What's our permission (capability) threshold
31
  define('MCSF_CAP_THRESHOLD', 'manage_options');
@@ -34,8 +34,8 @@ define('MCSF_CAP_THRESHOLD', 'manage_options');
34
  mailchimpSF_where_am_i();
35
 
36
  // Get our MailChimp API class in scope
37
- if (!class_exists('mailchimpSF_MCAPI')) {
38
- require_once('miniMCAPI.class.php');
39
  }
40
 
41
  // includes the widget code so it can be easily called either normally or via ajax
@@ -119,6 +119,7 @@ function mailchimpSF_load_resources() {
119
  */
120
  function mc_admin_page_load_resources() {
121
  wp_enqueue_style('mailchimpSF_admin_css', MCSF_URL.'css/admin.css');
 
122
  }
123
  add_action('load-settings_page_mailchimpSF_options', 'mc_admin_page_load_resources');
124
 
@@ -130,27 +131,34 @@ function mc_datepicker_load() {
130
  ?>
131
  <script type="text/javascript">
132
  jQuery(function($) {
133
- $('.date-pick').datepicker({
134
- autoFocusNextInput: true,
135
- constrainInput: false,
136
- changeMonth: true,
137
- changeYear: true,
138
- beforeShow: function(input, inst) { $('#ui-datepicker-div').addClass('show'); },
139
- dateFormat: 'yy/mm/dd',
 
 
 
 
140
  });
141
-
142
  d = new Date();
143
- $('.birthdate-pick').datepicker({
144
- autoFocusNextInput: true,
145
- constrainInput: false,
146
- changeMonth: true,
147
- changeYear: false,
148
- minDate: new Date(d.getFullYear(), 1-1, 1),
149
- maxDate: new Date(d.getFullYear(), 12-1, 31),
150
- beforeShow: function(input, inst) { $('#ui-datepicker-div').removeClass('show'); },
151
- dateFormat: 'mm/dd',
152
- });
 
 
 
153
 
 
154
 
155
  });
156
  </script>
@@ -171,6 +179,12 @@ function mailchimpSF_early_request_handler() {
171
  header("Content-type: text/css");
172
  mailchimpSF_main_css();
173
  exit;
 
 
 
 
 
 
174
  }
175
  }
176
  }
@@ -185,9 +199,11 @@ function mailchimpSF_main_css() {
185
  ?>
186
  .mc_error_msg {
187
  color: red;
 
188
  }
189
  .mc_success_msg {
190
  color: green;
 
191
  }
192
  .mc_merge_var{
193
  padding:0;
@@ -213,7 +229,7 @@ if (get_option('mc_custom_style')=='on'){
213
  border-color: #<?php echo get_option('mc_header_border_color'); ?>;
214
  color: #<?php echo get_option('mc_header_text_color'); ?>;
215
  background-color: #<?php echo get_option('mc_header_background'); ?>;
216
- font-size: 1.2em;
217
  padding:5px 10px;
218
  width: 100%;
219
  }
@@ -279,16 +295,10 @@ function mailchimpSF_request_handler() {
279
  wp_die('Cheatin&rsquo; huh?');
280
  }
281
 
282
- // erase API Key
283
- update_option('mc_apikey', '');
284
- break;
285
- case 'update_mc_apikey':
286
- // Check capability & Verify nonce
287
- if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_mc_api_key')) {
288
- wp_die('Cheatin&rsquo; huh?');
289
- }
290
-
291
- mailchimpSF_set_api_key(strip_tags(stripslashes($_POST['mc_apikey'])));
292
  break;
293
  case 'reset_list':
294
  // Check capability & Verify nonce
@@ -333,6 +343,68 @@ function mailchimpSF_request_handler() {
333
  }
334
  add_action('init', 'mailchimpSF_request_handler');
335
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  /**
337
  * Upgrades data if it needs to. Checks on admin_init
338
  *
@@ -348,6 +420,22 @@ function mailchimpSF_upgrade() {
348
  }
349
  add_action('admin_init', 'mailchimpSF_upgrade');
350
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
  /**
352
  * Checks to see if we're storing a password, if so, we need
353
  * to upgrade to the API key
@@ -375,62 +463,7 @@ function mailchimpSF_needs_upgrade() {
375
  * 2011-02-09 - old password upgrade code deleted as 0.5 is way old
376
  */
377
  function mailchimpSF_do_upgrade() {
378
- //left in just for good measure
379
- delete_option('mc_password');
380
- $api = new mailchimpSF_MCAPI(get_option('mc_apikey'));
381
- $igs = $api->listInterestGroupings(get_option('mc_list_id'));
382
-
383
- // If we don't have any interest groups store an empty array, not (bool) false
384
- $igs = !$igs ? array() : $igs;
385
-
386
- update_option('mc_interest_groups', $igs);
387
- }
388
-
389
- /**
390
- * Sets the API Key to whatever value was passed to this func
391
- *
392
- * @return array of vars
393
- **/
394
- function mailchimpSF_set_api_key($api_key = '') {
395
- $delete_setup = false;
396
- $api = new mailchimpSF_MCAPI($api_key);
397
- $api->ping();
398
- if (empty($api->errorCode)) {
399
- $msg = "<p class='success_msg'>".esc_html(__("Success! We were able to verify your API Key! Let's continue, shall we?", 'mailchimp_i18n'))."</p>";
400
- update_option('mc_apikey', $api_key);
401
- $req = $api->getAccountDetails();
402
- update_option('mc_username', $req['username']);
403
- update_option('mc_user_id', $req['user_id']);
404
- $cur_list_id = get_option('mc_list_id');
405
- if (!empty($cur_list_id)) {
406
- //we *could* support paging, but few users have that many lists (and shouldn't)
407
- $lists = $api->lists(array(),0,100);
408
- $lists = $lists['data'];
409
- //but don't delete if the list still exists...
410
- $delete_setup = true;
411
- foreach($lists as $list) {
412
- if ($list['id'] == $cur_list_id) {
413
- $list_id = isset($_POST['mc_list_id']) ? $_POST['mc_list_id'] : '';
414
- $delete_setup = false;
415
- }
416
- }
417
- }
418
- } else {
419
- $msg = "<p class='error_msg'>".esc_html(__('Uh-oh, we were unable to verify your API Key. Please check them and try again!', 'mailchimp_i18n'))."<br/>";
420
- $msg .= __('The server said:', 'mailchimp_i18n')."<em>".esc_html($api->errorMessage)."</em></p>";
421
- $username = get_option('mc_username');
422
- if (empty($username)) {
423
- $delete_setup = true;
424
- }
425
- }
426
-
427
- // Set a global message
428
- mailchimpSF_global_msg($msg);
429
-
430
- // If we need to delete our setup, do it
431
- if ($delete_setup){
432
- mailchimpSF_delete_setup();
433
- }
434
  }
435
 
436
  /**
@@ -438,6 +471,9 @@ function mailchimpSF_set_api_key($api_key = '') {
438
  **/
439
  function mailchimpSF_delete_setup() {
440
  delete_option('mc_user_id');
 
 
 
441
  delete_option('mc_rewards');
442
  delete_option('mc_use_javascript');
443
  delete_option('mc_use_datepicker');
@@ -529,7 +565,7 @@ function mailchimpSF_set_form_defaults($list_name = '') {
529
  update_option('mc_submit_text',__( 'Subscribe', 'mailchimp_i18n' ));
530
 
531
  update_option('mc_use_datepicker', 'on');
532
- update_option('mc_custom_style','on');
533
  update_option('mc_use_javascript','on');
534
  update_option('mc_use_unsub_link','off');
535
  update_option('mc_header_border_width','1');
@@ -538,9 +574,9 @@ function mailchimpSF_set_form_defaults($list_name = '') {
538
  update_option('mc_header_text_color','CC6600');
539
 
540
  update_option('mc_form_border_width','1');
541
- update_option('mc_form_border_color','C4D3EA');
542
- update_option('mc_form_background','EEF3F8');
543
- update_option('mc_form_text_color','555555');
544
  }
545
 
546
  /**
@@ -645,11 +681,13 @@ function mailchimpSF_save_general_form_settings() {
645
  /**
646
  * Sees if the user changed the list, and updates options accordingly
647
  **/
648
- function mailchimpSF_change_list_if_necessary($api_key) {
649
  // Simple permission check before going through all this
650
  if (!current_user_can(MCSF_CAP_THRESHOLD)) { return; }
651
 
652
- $api = new mailchimpSF_MCAPI($api_key);
 
 
653
  //we *could* support paging, but few users have that many lists (and shouldn't)
654
  $lists = $api->lists(array(),0,100);
655
  $lists = $lists['data'];
@@ -709,7 +747,7 @@ function mailchimpSF_change_list_if_necessary($api_key) {
709
 
710
  $msg = '<p class="success_msg">'.
711
  sprintf(
712
- __('Success! Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n').$igs_text,
713
  count($mv)
714
  ).' '.
715
  __('from your list').' "'.$list_name.'"<br/><br/>'.
@@ -719,6 +757,7 @@ function mailchimpSF_change_list_if_necessary($api_key) {
719
  }
720
  }
721
 
 
722
  /**
723
  * Outputs the Settings/Options page
724
  */
@@ -726,19 +765,14 @@ function mailchimpSF_setup_page() {
726
  ?>
727
  <div class="wrap">
728
 
729
- <h2><?php esc_html_e('MailChimp List Setup', 'mailchimp_i18n');?> </h2>
730
-
 
731
  <?php
732
-
733
- $user = get_option('mc_username');
734
- $api_key = get_option('mc_apikey');
735
 
736
  // If we have an API Key, see if we need to change the lists and its options
737
- if (!empty($api_key)){
738
- mailchimpSF_change_list_if_necessary($api_key);
739
- }
740
-
741
-
742
 
743
  // Display our success/error message(s) if have them
744
  if (mailchimpSF_global_msg() != ''){
@@ -750,15 +784,14 @@ if (mailchimpSF_global_msg() != ''){
750
 
751
 
752
  // If we don't have an API Key, do a login form
753
- if (get_option('mc_apikey') == '') {
754
- ?>
755
  <div>
756
- <form method="post" action="options-general.php?page=mailchimpSF_options">
757
- <h3><?php esc_html_e('Login Info', 'mailchimp_i18n');?></h3>
758
- <?php esc_html_e('To start using the MailChimp plugin, we first need to login and get your API Key. Please enter your MailChimp API Key below.', 'mailchimp_i18n'); ?>
759
-
760
- <br/>
761
-
762
  <?php
763
  echo sprintf(
764
  '%1$s <a href="http://www.mailchimp.com/signup/" target="_blank">%2$s</a>',
@@ -766,36 +799,31 @@ if (get_option('mc_apikey') == '') {
766
  esc_html(__('Try one for Free!', 'mailchimp_i18n'))
767
  );
768
  ?>
769
-
770
- <br/>
771
-
772
- <table class="form-table">
773
  <tr valign="top">
774
- <th scope="row"><?php esc_html_e('API Key', 'mailchimp_i18n'); ?>:</th>
775
- <td>
776
- <input name="mc_apikey" type="text" id="mc_apikey" class="code" value="<?php echo esc_attr($api_key); ?>" size="32" />
777
- <br/>
778
- <a href="http://admin.mailchimp.com/account/api-key-popup" target="_blank">get your API Key here</a>
779
- </td>
780
  </tr>
781
  </table>
782
-
783
- <input type="hidden" name="mcsf_action" value="update_mc_apikey"/>
784
- <input type="submit" name="Submit" value="<?php esc_attr_e('Save & Check', 'mailchimp_i18n');?>" class="button" />
785
- <?php wp_nonce_field('update_mc_api_key', '_mcsf_nonce_action'); ?>
786
- </form>
787
  </div>
788
-
 
789
  <?php
790
- if (get_option('mc_username')!=''){
791
  ?>
792
  <strong><?php esc_html_e('Notes', 'mailchimp_i18n'); ?>:</strong>
793
  <ul>
794
- <li><em><?php esc_html_e('Changing your settings at MailChimp.com may cause this to stop working.', 'mailchimp_i18n'); ?></em></li>
795
- <li><em><?php esc_html_e('If you change your login to a different account, the info you have setup below will be erased.', 'mailchimp_i18n'); ?></em></li>
796
- <li><em><?php esc_html_e('If any of that happens, no biggie - just reconfigure your login and the items below...', 'mailchimp_i18n'); ?></em></li>
797
  </ul>
798
- <br/>
799
  <?php
800
  }
801
  } // End of login form
@@ -803,9 +831,9 @@ if (get_option('mc_apikey') == '') {
803
  // Start logout form
804
  else {
805
  ?>
806
- <table style="min-width:400px;">
807
  <tr>
808
- <td><h3><?php esc_html_e('Logged in as', 'mailchimp_i18n');?>: <?php echo esc_html(get_option('mc_username')); ?></h3>
809
  </td>
810
  <td>
811
  <form method="post" action="options-general.php?page=mailchimpSF_options">
@@ -822,19 +850,20 @@ else {
822
 
823
 
824
  //Just get out if nothing else matters...
825
- if (get_option('mc_apikey') == '') return;
 
826
 
827
- if (get_option('mc_apikey')!=''){
828
  ?>
829
- <h3><?php esc_html_e('Your Lists', 'mailchimp_i18n'); ?></h3>
830
 
831
  <div>
832
 
833
- <p><?php esc_html_e('Please select the List you wish to create a Signup Form for.', 'mailchimp_i18n'); ?></p>
 
834
 
835
  <form method="post" action="options-general.php?page=mailchimpSF_options">
836
  <?php
837
- $api = new mailchimpSF_MCAPI(get_option('mc_apikey'));
838
  //we *could* support paging, but few users have that many lists (and shouldn't)
839
  $lists = $api->lists(array(),0,100);
840
  $lists = $lists['data'];
@@ -853,8 +882,8 @@ if (get_option('mc_apikey')!=''){
853
  }
854
  else {
855
  ?>
856
- <table style="min-width:400px">
857
- <tr>
858
  <td>
859
  <select name="mc_list_id" style="min-width:200px;">
860
  <option value=""> &mdash; <?php esc_html_e('Select A List','mailchimp_i18n'); ?> &mdash; </option>
@@ -873,11 +902,6 @@ if (get_option('mc_apikey')!=''){
873
  <input type="submit" name="Submit" value="<?php esc_attr_e('Update List', 'mailchimp_i18n'); ?>" class="button" />
874
  </td>
875
  </tr>
876
- <tr>
877
- <td colspan="2">
878
- <strong><?php esc_html_e('Note:', 'mailchimp_i18n'); ?></strong> <em><?php esc_html_e('Updating your list will not cause settings below to be lost. Changing to a new list will.', 'mailchimp_i18n'); ?></em>
879
- </td>
880
- </tr>
881
  </table>
882
  <?php
883
  } //end select list
@@ -904,6 +928,7 @@ else {
904
  <h4><?php esc_html_e('Selected MailChimp List', 'mailchimp_i18n'); ?>: <?php echo esc_html(get_option('mc_list_name')); ?></h4>
905
  <?php
906
  }
 
907
  //Just get out if nothing else matters...
908
  if (get_option('mc_list_id') == '') return;
909
 
@@ -913,118 +938,119 @@ if (get_option('mc_list_id') == '') return;
913
 
914
  <div>
915
  <form method="post" action="options-general.php?page=mailchimpSF_options">
916
- <div style="width:600px;">
917
  <input type="hidden" name="mcsf_action" value="change_form_settings">
918
  <?php wp_nonce_field('update_general_form_settings', '_mcsf_nonce_action'); ?>
919
- <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button" />
920
- <table class="widefat">
921
- <tr valign="top">
922
- <th scope="row"><?php esc_html_e('Monkey Rewards', 'mailchimp_i18n'); ?>:</th>
923
- <td><input name="mc_rewards" type="checkbox"<?php if (get_option('mc_rewards')=='on' || get_option('mc_rewards')=='' ) { echo ' checked="checked"'; } ?> id="mc_rewards" class="code" />
924
- <em><label for="mc_rewards"><?php esc_html_e('turning this on will place a "powered by MailChimp" link in your form that will earn you credits with us. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em>
925
- </td>
926
- </tr>
927
- <tr valign="top">
928
- <th scope="row"><?php esc_html_e('Use Javascript Support?', 'mailchimp_i18n'); ?>:</th>
929
- <td><input name="mc_use_javascript" type="checkbox" <?php checked(get_option('mc_use_javascript'), 'on'); ?> id="mc_use_javascript" class="code" />
930
- <em><label for="mc_use_javascript"><?php esc_html_e('turning this on will use fancy javascript submission and should degrade gracefully for users not using javascript. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em>
931
- </td>
932
- </tr>
933
- <tr valign="top">
934
- <th scope="row"><?php esc_html_e('Use Javascript Datepicker?', 'mailchimp_i18n'); ?>:</th>
935
- <td><input name="mc_use_datepicker" type="checkbox" <?php checked(get_option('mc_use_datepicker'), 'on'); ?> id="mc_use_datepicker" class="code" />
936
- <em><label for="mc_use_datepicker"><?php esc_html_e('turning this on will use the jQuery UI Datepicker for dates.', 'mailchimp_i18n'); ?></label></em>
937
- </td>
938
- </tr>
939
- <tr valign="top">
940
- <th scope="row"><?php esc_html_e('Include Unsubscribe link?', 'mailchimp_i18n'); ?>:</th>
941
- <td><input name="mc_use_unsub_link" type="checkbox"<?php checked(get_option('mc_use_unsub_link'), 'on'); ?> id="mc_use_unsub_link" class="code" />
942
- <em><label for="mc_use_unsub_link"><?php esc_html_e('turning this on will add a link to your host unsubscribe form', 'mailchimp_i18n'); ?></label></em>
943
- </td>
944
- </tr>
945
  <tr valign="top">
946
- <th scope="row"><?php esc_html_e('Header content', 'mailchimp_i18n'); ?>:</th>
947
- <td>
948
- <textarea name="mc_header_content" rows="2" cols="50"><?php echo esc_html(get_option('mc_header_content')); ?></textarea><br/>
949
- <em><?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?></em>
950
- </td>
951
  </tr>
952
 
953
  <tr valign="top">
954
- <th scope="row"><?php esc_html_e('Sub-header content', 'mailchimp_i18n'); ?>:</th>
955
- <td>
956
- <textarea name="mc_subheader_content" rows="2" cols="50"><?php echo esc_html(get_option('mc_subheader_content')); ?></textarea><br/>
957
- <em><?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?></em>.
958
- <?php esc_html_e('This will be displayed under the heading and above the form.', 'mailchimp_i18n'); ?>
959
- </td>
960
  </tr>
961
 
962
-
963
- <tr valign="top">
964
- <th scope="row"><?php esc_html_e('Submit Button text', 'mailchimp_i18n'); ?>:</th>
965
  <td>
966
- <input type="text" name="mc_submit_text" size="30" value="<?php echo esc_attr(get_option('mc_submit_text')); ?>"/>
967
  </td>
968
  </tr>
 
969
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
970
  <tr valign="top">
971
- <th scope="row"><?php esc_html_e('Custom Styling', 'mailchimp_i18n'); ?>:</th>
972
- <td>
973
- <table class="widefat">
974
-
975
- <tr><th><label for="mc_custom_style"><?php esc_html_e('Turned On?', 'mailchimp_i18n'); ?></label></th><td><input type="checkbox" name="mc_custom_style" id="mc_custom_style"<?php checked(get_option('mc_custom_style'), 'on'); ?> /></td></tr>
976
- <tr><th colspan="2"><?php esc_html_e('Header Settings (only applies if there are no HTML tags in the Header Content area above)', 'mailchimp_i18n'); ?>:</th></tr>
977
- <tr><th><?php esc_html_e('Border Width', 'mailchimp_i18n'); ?>:</th><td><input type="text" name="mc_header_border_width" size="3" maxlength="3" value="<?php echo esc_attr(get_option('mc_header_border_width')); ?>"/> px<br/>
978
- <em><?php esc_html_e('Set to 0 for no border, do not enter', 'mailchimp_i18n'); ?> <strong>px</strong>!</em>
979
- </td></tr>
980
- <tr><th><?php esc_html_e('Border Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_header_border_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_header_border_color')); ?>"/><br/>
981
- <em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
982
- </td></tr>
983
- <tr><th><?php esc_html_e('Text Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_header_text_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_header_text_color')); ?>"/><br/>
984
- <em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
985
- </td></tr>
986
- <tr><th><?php esc_html_e('Background Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_header_background" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_header_background')); ?>"/><br/>
987
- <em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
988
- </td></tr>
989
-
990
- <tr><th colspan="2"><?php esc_html_e('Form Settings', 'mailchimp_i18n'); ?>:</th></tr>
991
- <tr><th><?php esc_html_e('Border Width', 'mailchimp_i18n'); ?>:</th><td><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo esc_attr(get_option('mc_form_border_width')); ?>"/> px<br/>
992
- <em><?php esc_html_e('Set to 0 for no border, do not enter', 'mailchimp_i18n'); ?> <strong>px</strong>!</em>
993
- </td></tr>
994
- <tr><th><?php esc_html_e('Border Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_form_border_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_form_border_color')); ?>"/><br/>
995
- <em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
996
- </td></tr>
997
- <tr><th><?php esc_html_e('Text Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_form_text_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_form_text_color')); ?>"/><br/>
998
- <em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
999
- </td></tr>
1000
- <tr><th><?php esc_html_e('Background Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_form_background" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_form_background')); ?>"/><br/>
1001
- <em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
1002
- </td></tr>
1003
- </table>
1004
- </td>
1005
- </tr>
1006
  </table>
 
1007
  </div>
1008
- <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button" />
 
1009
 
1010
  <?php
1011
  // Merge Variables Table
1012
  ?>
1013
- <div style="width:400px;">
1014
-
1015
- <h4><?php esc_html_e('Merge Variables Included', 'mailchimp_i18n'); ?></h4>
1016
 
1017
- <?php
1018
- $mv = get_option('mc_merge_vars');
1019
 
1020
- if (count($mv) == 0 || !is_array($mv)){
1021
- ?>
1022
- <em><?php esc_html_e('No Merge Variables found.', 'mailchimp_i18n'); ?></em>
1023
- <?php
1024
- } else {
1025
- ?>
1026
 
1027
- <table class='widefat'>
 
 
 
 
 
 
 
 
 
 
1028
  <tr valign="top">
1029
  <th><?php esc_html_e('Name', 'mailchimp_i18n');?></th>
1030
  <th><?php esc_html_e('Tag', 'mailchimp_i18n');?></th>
@@ -1062,12 +1088,13 @@ if (count($mv) == 0 || !is_array($mv)){
1062
 
1063
  ?>
1064
 
1065
- <h4><?php esc_html_e('Interest Groups', 'mailchimp_i18n'); ?></h4>
1066
 
1067
  <?php
1068
  // Interest Groups Table
1069
  $igs = get_option('mc_interest_groups');
1070
- if (is_array($igs) && !isset($igs['id'])) {
 
1071
  // Determines whether or not to continue processing. Only false if there was an error.
1072
  $continue = true;
1073
  foreach ($igs as $ig) {
@@ -1080,9 +1107,12 @@ if (is_array($igs) && !isset($igs['id'])) {
1080
  }
1081
  else {
1082
  ?>
1083
- <table class='widefat'>
1084
  <tr valign="top">
1085
- <th width="75px">
 
 
 
1086
  <label for="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>"><?php esc_html_e('Show?', 'mailchimp_i18n'); ?></label>
1087
  </th>
1088
  <th>
@@ -1090,15 +1120,11 @@ if (is_array($igs) && !isset($igs['id'])) {
1090
  </th>
1091
  </tr>
1092
  <tr valign="top">
1093
- <th><?php esc_html_e('Name', 'mailchimp_i18n'); ?>:</th>
1094
- <th><?php echo esc_html($ig['name']); ?></th>
1095
- </tr>
1096
- <tr valign="top">
1097
- <th><?php esc_html_e('Input Type', 'mailchimp_i18n'); ?>:</th>
1098
  <td><?php echo esc_html($ig['form_field']); ?></td>
1099
  </tr>
1100
- <tr valign="top">
1101
- <th><?php esc_html_e('Options', 'mailchimp_i18n'); ?>:</th>
1102
  <td>
1103
  <ul>
1104
  <?php
@@ -1117,17 +1143,62 @@ if (is_array($igs) && !isset($igs['id'])) {
1117
  }
1118
  }
1119
  }
1120
- else {
1121
- ?>
1122
- <em><?php esc_html_e('Error retrieving interest groups. Please re-import the list.', 'mailchimp_i18n'); ?></em>
1123
- <?php
1124
- }
1125
-
1126
  ?>
1127
- <p class="submit">
1128
- <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button" />
1129
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1130
  </div>
 
 
 
1131
  </form>
1132
  </div>
1133
  </div><!--wrap-->
@@ -1136,7 +1207,9 @@ else {
1136
 
1137
 
1138
  function mailchimpSF_register_widgets() {
1139
- register_widget('mailchimpSF_Widget');
 
 
1140
  }
1141
  add_action('widgets_init', 'mailchimpSF_register_widgets');
1142
 
@@ -1280,11 +1353,13 @@ function mailchimpSF_signup_submit() {
1280
  if ($merge_key !== 'GROUPINGS') {
1281
  switch ($mv_tag_keys[$merge_key]['field_type']) {
1282
  case 'phone':
1283
- $phone = $merge_value;
1284
- if (!empty($phone)) {
1285
- if (!preg_match('/[0-9]{0,3}-[0-9]{0,3}-[0-9]{0,4}/', $phone)) {
1286
- $errs[] = sprintf(__("%s must consist of only numbers", 'mailchimp_i18n'), esc_html($mv_tag_keys[$merge_key]['name']));
1287
- $success = false;
 
 
1288
  }
1289
  }
1290
  break;
@@ -1296,7 +1371,9 @@ function mailchimpSF_signup_submit() {
1296
  }
1297
  }
1298
  if ($success) {
1299
- $api = new mailchimpSF_MCAPI(get_option('mc_apikey'));
 
 
1300
  $retval = $api->listSubscribe( $listId, $email, $merge, $email_type);
1301
  if (!$retval) {
1302
  switch($api->errorCode) {
@@ -1308,9 +1385,9 @@ function mailchimpSF_signup_submit() {
1308
 
1309
  $account = $api->getAccountDetails(array("modules", "orders", "rewards-credits", "rewards-inspections", "rewards-referrals", "rewards-applied"));
1310
  if (!$api->errorCode) {
1311
- list($dummy, $dc) = explode('-',get_option('mc_apikey'));
1312
  $uid = $account['user_id'];
1313
- $username = $account['username'];
1314
  $eid = base64_encode($email);
1315
  $msg .= ' ' . sprintf(__('<a href="%s">Click here to update your profile.</a>', 'mailchimp_i18n'), "http://$username.$dc.list-manage.com/subscribe/send-email?u=$uid&id=$listId&e=$eid");
1316
  }
3
  Plugin Name: MailChimp
4
  Plugin URI: http://www.mailchimp.com/plugins/mailchimp-wordpress-plugin/
5
  Description: The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list.
6
+ Version: 1.3
7
  Author: MailChimp and Crowd Favorite
8
  Author URI: http://mailchimp.com/api/
9
  */
25
  */
26
 
27
  // Version constant for easy CSS refreshes
28
+ define('MCSF_VER', '1.3');
29
 
30
  // What's our permission (capability) threshold
31
  define('MCSF_CAP_THRESHOLD', 'manage_options');
34
  mailchimpSF_where_am_i();
35
 
36
  // Get our MailChimp API class in scope
37
+ if (!class_exists('Sopresto_MailChimp')) {
38
+ require_once(MCSF_DIR.'lib/sopresto/sopresto.php');
39
  }
40
 
41
  // includes the widget code so it can be easily called either normally or via ajax
119
  */
120
  function mc_admin_page_load_resources() {
121
  wp_enqueue_style('mailchimpSF_admin_css', MCSF_URL.'css/admin.css');
122
+ wp_enqueue_script('mailchimpSF_admin_js', MCSF_URL.'js/admin.js');
123
  }
124
  add_action('load-settings_page_mailchimpSF_options', 'mc_admin_page_load_resources');
125
 
131
  ?>
132
  <script type="text/javascript">
133
  jQuery(function($) {
134
+ $('.date-pick').each(function() {
135
+ var format = $(this).data('format') || 'mm/dd/yyyy';
136
+ format = format.replace(/yyyy/i, 'yy');
137
+ $(this).datepicker({
138
+ autoFocusNextInput: true,
139
+ constrainInput: false,
140
+ changeMonth: true,
141
+ changeYear: true,
142
+ beforeShow: function(input, inst) { $('#ui-datepicker-div').addClass('show'); },
143
+ dateFormat: format.toLowerCase(),
144
+ });
145
  });
 
146
  d = new Date();
147
+ $('.birthdate-pick').each(function() {
148
+ var format = $(this).data('format') || 'mm/dd';
149
+ format = format.replace(/yyyy/i, 'yy');
150
+ $(this).datepicker({
151
+ autoFocusNextInput: true,
152
+ constrainInput: false,
153
+ changeMonth: true,
154
+ changeYear: false,
155
+ minDate: new Date(d.getFullYear(), 1-1, 1),
156
+ maxDate: new Date(d.getFullYear(), 12-1, 31),
157
+ beforeShow: function(input, inst) { $('#ui-datepicker-div').removeClass('show'); },
158
+ dateFormat: format.toLowerCase(),
159
+ });
160
 
161
+ });
162
 
163
  });
164
  </script>
179
  header("Content-type: text/css");
180
  mailchimpSF_main_css();
181
  exit;
182
+ case 'authorize':
183
+ mailchimpSF_authorize();
184
+ break;
185
+ case 'authorized':
186
+ mailchimpSF_authorized();
187
+ break;
188
  }
189
  }
190
  }
199
  ?>
200
  .mc_error_msg {
201
  color: red;
202
+ margin-bottom: 1.0em;
203
  }
204
  .mc_success_msg {
205
  color: green;
206
+ margin-bottom: 1.0em;
207
  }
208
  .mc_merge_var{
209
  padding:0;
229
  border-color: #<?php echo get_option('mc_header_border_color'); ?>;
230
  color: #<?php echo get_option('mc_header_text_color'); ?>;
231
  background-color: #<?php echo get_option('mc_header_background'); ?>;
232
+ <!-- font-size: 1.2em;-->
233
  padding:5px 10px;
234
  width: 100%;
235
  }
295
  wp_die('Cheatin&rsquo; huh?');
296
  }
297
 
298
+ // erase auth information
299
+ delete_option('mc_sopresto_user');
300
+ delete_option('mc_sopresto_public_key');
301
+ delete_option('mc_sopresto_secret_key');
 
 
 
 
 
 
302
  break;
303
  case 'reset_list':
304
  // Check capability & Verify nonce
343
  }
344
  add_action('init', 'mailchimpSF_request_handler');
345
 
346
+ function mailchimpSF_auth_nonce_key($salt = null) {
347
+ if (is_null($salt)) {
348
+ $salt = mailchimpSF_auth_nonce_salt();
349
+ }
350
+ return md5('social_authentication'.AUTH_KEY.$salt);
351
+ }
352
+
353
+ function mailchimpSF_auth_nonce_salt() {
354
+ return md5(microtime().$_SERVER['SERVER_ADDR']);
355
+ }
356
+
357
+ function mailchimpSF_authorize() {
358
+ $api = mailchimpSF_get_api(true);
359
+ $proxy = apply_filters('mailchimp_authorize_url', $api->getApiUrl('authorize'));
360
+ if (strpos($proxy, 'socialize-this') !== false) {
361
+ $salt = mailchimpSF_auth_nonce_salt();
362
+ $id = wp_create_nonce(mailchimpSF_auth_nonce_key($salt));
363
+ $url = home_url('index.php');
364
+ $args = array(
365
+ 'mcsf_action' => 'authorized',
366
+ 'salt' => $salt,
367
+ 'user_id' => get_current_user_id(),
368
+ );
369
+
370
+ $proxy = add_query_arg(array(
371
+ 'id' => $id,
372
+ 'response_url' => urlencode(add_query_arg($args, $url))
373
+ ), $proxy);
374
+
375
+ $proxy = apply_filters('mailchimp_proxy_url', $proxy);
376
+ }
377
+
378
+ wp_redirect($proxy);
379
+ exit;
380
+ }
381
+
382
+ function mailchimpSF_authorized() {
383
+ // User ID on the request? Must be set before nonce comparison
384
+ $user_id = stripslashes($_GET['user_id']);
385
+ if ($user_id !== null) {
386
+ wp_set_current_user($user_id);
387
+ }
388
+
389
+ $nonce = stripslashes($_POST['id']);
390
+ $salt = stripslashes($_GET['salt']);
391
+ if (wp_verify_nonce($nonce, mailchimpSF_auth_nonce_key($salt)) === false) {
392
+ wp_die('Cheatin&rsquo; huh?');
393
+ }
394
+
395
+ $response = stripslashes_deep($_POST['response']);
396
+
397
+ if (!isset($response['keys']) || !isset($response['user'])) {
398
+ wp_die('Something went wrong, please try again');
399
+ }
400
+
401
+ update_option('mc_sopresto_user', $response['user']);
402
+ update_option('mc_sopresto_dc', $response['dc']);
403
+ update_option('mc_sopresto_public_key', $response['keys']['public']);
404
+ update_option('mc_sopresto_secret_key', $response['keys']['secret']);
405
+ exit;
406
+ }
407
+
408
  /**
409
  * Upgrades data if it needs to. Checks on admin_init
410
  *
420
  }
421
  add_action('admin_init', 'mailchimpSF_upgrade');
422
 
423
+ /**
424
+ * Creates new Sopresto API object
425
+ *
426
+ * @return Sopresto_MailChimp|false
427
+ */
428
+ function mailchimpSF_get_api($force = false) {
429
+ $public_key = get_option('mc_sopresto_public_key');
430
+ $secret_key = get_option('mc_sopresto_secret_key');
431
+
432
+ if ($public_key && $secret_key || $force) {
433
+ return new Sopresto_MailChimp($public_key, $secret_key, '1.3');
434
+ }
435
+
436
+ return false;
437
+ }
438
+
439
  /**
440
  * Checks to see if we're storing a password, if so, we need
441
  * to upgrade to the API key
463
  * 2011-02-09 - old password upgrade code deleted as 0.5 is way old
464
  */
465
  function mailchimpSF_do_upgrade() {
466
+ # TODO: reload this
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  }
468
 
469
  /**
471
  **/
472
  function mailchimpSF_delete_setup() {
473
  delete_option('mc_user_id');
474
+ delete_option('mc_sopresto_user');
475
+ delete_option('mc_sopresto_public_key');
476
+ delete_option('mc_sopresto_secret_key');
477
  delete_option('mc_rewards');
478
  delete_option('mc_use_javascript');
479
  delete_option('mc_use_datepicker');
565
  update_option('mc_submit_text',__( 'Subscribe', 'mailchimp_i18n' ));
566
 
567
  update_option('mc_use_datepicker', 'on');
568
+ update_option('mc_custom_style','off');
569
  update_option('mc_use_javascript','on');
570
  update_option('mc_use_unsub_link','off');
571
  update_option('mc_header_border_width','1');
574
  update_option('mc_header_text_color','CC6600');
575
 
576
  update_option('mc_form_border_width','1');
577
+ update_option('mc_form_border_color','E0E0E0');
578
+ update_option('mc_form_background','FFFFFF');
579
+ update_option('mc_form_text_color','3F3F3f');
580
  }
581
 
582
  /**
681
  /**
682
  * Sees if the user changed the list, and updates options accordingly
683
  **/
684
+ function mailchimpSF_change_list_if_necessary() {
685
  // Simple permission check before going through all this
686
  if (!current_user_can(MCSF_CAP_THRESHOLD)) { return; }
687
 
688
+ $api = mailchimpSF_get_api();
689
+ if (!$api) { return; }
690
+
691
  //we *could* support paging, but few users have that many lists (and shouldn't)
692
  $lists = $api->lists(array(),0,100);
693
  $lists = $lists['data'];
747
 
748
  $msg = '<p class="success_msg">'.
749
  sprintf(
750
+ __('<b>Success!</b> Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n').$igs_text,
751
  count($mv)
752
  ).' '.
753
  __('from your list').' "'.$list_name.'"<br/><br/>'.
757
  }
758
  }
759
 
760
+
761
  /**
762
  * Outputs the Settings/Options page
763
  */
765
  ?>
766
  <div class="wrap">
767
 
768
+ <div class="mailchimp-header">
769
+ <h2><?php esc_html_e('MailChimp List Setup', 'mailchimp_i18n');?> </h2>
770
+ </div>
771
  <?php
772
+ $user = get_option('mc_sopresto_user');
 
 
773
 
774
  // If we have an API Key, see if we need to change the lists and its options
775
+ mailchimpSF_change_list_if_necessary();
 
 
 
 
776
 
777
  // Display our success/error message(s) if have them
778
  if (mailchimpSF_global_msg() != ''){
784
 
785
 
786
  // If we don't have an API Key, do a login form
787
+ if (!$user) {
788
+ ?>
789
  <div>
790
+ </div>
791
+ <div>
792
+ <h3 class="mc-h2"><?php esc_html_e('Log In', 'mailchimp_i18n');?></h3>
793
+ <p class="mc-p" style="width: 40%;line-height: 21px;"><?php esc_html_e('To start using the MailChimp plugin, we first need to connect your MailChimp account. Click login below to connect.', 'mailchimp_i18n'); ?></p>
794
+ <p class="mc-a">
 
795
  <?php
796
  echo sprintf(
797
  '%1$s <a href="http://www.mailchimp.com/signup/" target="_blank">%2$s</a>',
799
  esc_html(__('Try one for Free!', 'mailchimp_i18n'))
800
  );
801
  ?>
802
+ </p>
803
+
804
+ <div style="width: 900px;">
805
+ <table class="widefat mc-widefat mc-api">
806
  <tr valign="top">
807
+ <th scope="row" class="mailchimp-connect"><?php esc_html_e('Connect to MailChimp', 'mailchimp_i18n'); ?></th>
808
+ <td>
809
+ <a href="<?php echo add_query_arg(array("mcsf_action" => "authorize"), home_url('index.php')) ?>" class="mailchimp-login">Connect</a>
810
+ </td>
 
 
811
  </tr>
812
  </table>
813
+ </div>
 
 
 
 
814
  </div>
815
+ <br/>
816
+ <!--<div class="notes_msg">
817
  <?php
818
+ if ($user && $user['username'] != ''){
819
  ?>
820
  <strong><?php esc_html_e('Notes', 'mailchimp_i18n'); ?>:</strong>
821
  <ul>
822
+ <li><?php esc_html_e('Changing your settings at MailChimp.com may cause this to stop working.', 'mailchimp_i18n'); ?></li>
823
+ <li><?php esc_html_e('If you change your login to a different account, the info you have setup below will be erased.', 'mailchimp_i18n'); ?></li>
824
+ <li><?php esc_html_e('If any of that happens, no biggie - just reconfigure your login and the items below...', 'mailchimp_i18n'); ?></li>
825
  </ul>
826
+ </div>-->
827
  <?php
828
  }
829
  } // End of login form
831
  // Start logout form
832
  else {
833
  ?>
834
+ <table style="min-width:400px;" class="mc-user" cellspacing="0">
835
  <tr>
836
+ <td><h3><?php esc_html_e('Logged in as', 'mailchimp_i18n');?>: <?php echo esc_html($user['username']); ?></h3>
837
  </td>
838
  <td>
839
  <form method="post" action="options-general.php?page=mailchimpSF_options">
850
 
851
 
852
  //Just get out if nothing else matters...
853
+ $api = mailchimpSF_get_api();
854
+ if (!$api) { return; }
855
 
856
+ if ($api){
857
  ?>
858
+ <h3 class="mc-h2"><?php esc_html_e('Your Lists', 'mailchimp_i18n'); ?></h3>
859
 
860
  <div>
861
 
862
+ <p class="mc-p"><?php esc_html_e('Please select the List you wish to create a Signup Form for.', 'mailchimp_i18n'); ?></p>
863
+ <p class="mc-list-note"><strong><?php esc_html_e('Note:', 'mailchimp_i18n'); ?></strong> <?php esc_html_e('Updating your list will not cause settings below to be lost. Changing to a new list will.', 'mailchimp_i18n'); ?></p>
864
 
865
  <form method="post" action="options-general.php?page=mailchimpSF_options">
866
  <?php
 
867
  //we *could* support paging, but few users have that many lists (and shouldn't)
868
  $lists = $api->lists(array(),0,100);
869
  $lists = $lists['data'];
882
  }
883
  else {
884
  ?>
885
+ <table style="min-width:400px" class="mc-list-select" cellspacing="0">
886
+ <tr class="mc-list-row">
887
  <td>
888
  <select name="mc_list_id" style="min-width:200px;">
889
  <option value=""> &mdash; <?php esc_html_e('Select A List','mailchimp_i18n'); ?> &mdash; </option>
902
  <input type="submit" name="Submit" value="<?php esc_attr_e('Update List', 'mailchimp_i18n'); ?>" class="button" />
903
  </td>
904
  </tr>
 
 
 
 
 
905
  </table>
906
  <?php
907
  } //end select list
928
  <h4><?php esc_html_e('Selected MailChimp List', 'mailchimp_i18n'); ?>: <?php echo esc_html(get_option('mc_list_name')); ?></h4>
929
  <?php
930
  }
931
+
932
  //Just get out if nothing else matters...
933
  if (get_option('mc_list_id') == '') return;
934
 
938
 
939
  <div>
940
  <form method="post" action="options-general.php?page=mailchimpSF_options">
941
+ <div style="width:900px;">
942
  <input type="hidden" name="mcsf_action" value="change_form_settings">
943
  <?php wp_nonce_field('update_general_form_settings', '_mcsf_nonce_action'); ?>
944
+ <!--<input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button" />-->
945
+ <table class="widefat mc-widefat mc-label-options">
946
+ <tr><th colspan="2">Content Options</th></tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
947
  <tr valign="top">
948
+ <th scope="row"><?php esc_html_e('Header', 'mailchimp_i18n'); ?></th>
949
+ <td>
950
+ <textarea name="mc_header_content" rows="2" cols="70"><?php echo esc_html(get_option('mc_header_content')); ?></textarea><br/>
951
+ <?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?>
952
+ </td>
953
  </tr>
954
 
955
  <tr valign="top">
956
+ <th scope="row"><?php esc_html_e('Sub-header', 'mailchimp_i18n'); ?></th>
957
+ <td>
958
+ <textarea name="mc_subheader_content" rows="2" cols="70"><?php echo esc_html(get_option('mc_subheader_content')); ?></textarea><br/>
959
+ <?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?>.<br/>
960
+ <?php esc_html_e('This will be displayed under the heading and above the form.', 'mailchimp_i18n'); ?>
961
+ </td>
962
  </tr>
963
 
964
+ <tr valign="top" class="last-row">
965
+ <th scope="row"><?php esc_html_e('Submit Button', 'mailchimp_i18n'); ?></th>
 
966
  <td>
967
+ <input type="text" name="mc_submit_text" size="70" value="<?php echo esc_attr(get_option('mc_submit_text')); ?>"/>
968
  </td>
969
  </tr>
970
+ </table>
971
 
972
+ <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
973
+
974
+ <table class="widefat mc-widefat mc-custom-styling">
975
+ <tr><th colspan="2">Custom Styling</th></tr>
976
+ <tr class="mc-turned-on"><th><label for="mc_custom_style"><?php esc_html_e('Enabled?', 'mailchimp_i18n'); ?></label></th><td><span class="mc-pre-input"></span><input type="checkbox" name="mc_custom_style" id="mc_custom_style"<?php checked(get_option('mc_custom_style'), 'on'); ?> /></td></tr>
977
+
978
+ <tr class="mc-internal-heading"><th colspan="2"><?php esc_html_e('Form Settings', 'mailchimp_i18n'); ?></th></tr>
979
+ <tr><th><?php esc_html_e('Border Width', 'mailchimp_i18n'); ?></th><td><span class="mc-pre-input"></span><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo esc_attr(get_option('mc_form_border_width')); ?>"/>
980
+ <em>px •<?php esc_html_e('Set to 0 for no border, do not enter', 'mailchimp_i18n'); ?> <strong>px</strong>!</em>
981
+ </td></tr>
982
+ <tr><th><?php esc_html_e('Border Color', 'mailchimp_i18n'); ?></th><td><span class="mc-pre-input">#</span><input type="text" name="mc_form_border_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_form_border_color')); ?>"/>
983
+ <em><?php esc_html_e('Do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
984
+ </td></tr>
985
+ <tr><th><?php esc_html_e('Text Color', 'mailchimp_i18n'); ?></th><td><span class="mc-pre-input">#</span><input type="text" name="mc_form_text_color" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_form_text_color')); ?>"/>
986
+ <em><?php esc_html_e('Do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
987
+ </td></tr>
988
+ <tr class="last-row"><th><?php esc_html_e('Background Color', 'mailchimp_i18n'); ?></th><td><span class="mc-pre-input">#</span><input type="text" name="mc_form_background" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_form_background')); ?>"/>
989
+ <em><?php esc_html_e('Do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
990
+ </td></tr>
991
+ </table>
992
+
993
+ <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
994
+
995
+ <table class="widefat mc-widefat">
996
+ <tr><th colspan="2">List Options</th></tr>
997
+ <tr valign="top">
998
+ <th scope="row"><?php esc_html_e('Monkey Rewards', 'mailchimp_i18n'); ?>?</th>
999
+ <td><input name="mc_rewards" type="checkbox"<?php if (get_option('mc_rewards')=='on' || get_option('mc_rewards')=='' ) { echo ' checked="checked"'; } ?> id="mc_rewards" class="code" />
1000
+ <em><label for="mc_rewards"><?php esc_html_e('Turning this on will place a "powered by MailChimp" link in your form that will earn you credits with us. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em>
1001
+ </td>
1002
+ </tr>
1003
+
1004
+ <tr valign="top">
1005
+ <th scope="row"><?php esc_html_e('Use Javascript Support?', 'mailchimp_i18n'); ?></th>
1006
+ <td><input name="mc_use_javascript" type="checkbox" <?php checked(get_option('mc_use_javascript'), 'on'); ?> id="mc_use_javascript" class="code" />
1007
+ <em><label for="mc_use_javascript"><?php esc_html_e('Turning this on will use fancy javascript submission and should degrade gracefully for users not using javascript. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em>
1008
+ </td>
1009
+ </tr>
1010
+
1011
  <tr valign="top">
1012
+ <th scope="row"><?php esc_html_e('Use Javascript Datepicker?', 'mailchimp_i18n'); ?></th>
1013
+ <td><input name="mc_use_datepicker" type="checkbox" <?php checked(get_option('mc_use_datepicker'), 'on'); ?> id="mc_use_datepicker" class="code" />
1014
+ <em><label for="mc_use_datepicker"><?php esc_html_e('Turning this on will use the jQuery UI Datepicker for dates.', 'mailchimp_i18n'); ?></label></em>
1015
+ </td>
1016
+ </tr>
1017
+ <tr valign="top" class="last-row">
1018
+ <th scope="row"><?php esc_html_e('Include Unsubscribe link?', 'mailchimp_i18n'); ?></th>
1019
+ <td><input name="mc_use_unsub_link" type="checkbox"<?php checked(get_option('mc_use_unsub_link'), 'on'); ?> id="mc_use_unsub_link" class="code" />
1020
+ <em><label for="mc_use_unsub_link"><?php esc_html_e('Turning this on will add a link to your host unsubscribe form', 'mailchimp_i18n'); ?></label></em>
1021
+ </td>
1022
+ </tr>
1023
+
1024
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1025
  </table>
1026
+
1027
  </div>
1028
+
1029
+
1030
 
1031
  <?php
1032
  // Merge Variables Table
1033
  ?>
1034
+ <div style="width:900px;">
 
 
1035
 
1036
+ <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
 
1037
 
1038
+ <table class='widefat mc-widefat'>
1039
+ <tr>
1040
+ <th colspan="4">
1041
+ <?php esc_html_e('Merge Variables Included', 'mailchimp_i18n'); ?>
 
 
1042
 
1043
+ <?php
1044
+ $mv = get_option('mc_merge_vars');
1045
+
1046
+ if (count($mv) == 0 || !is_array($mv)){
1047
+ ?>
1048
+ <em><?php esc_html_e('No Merge Variables found.', 'mailchimp_i18n'); ?></em>
1049
+ <?php
1050
+ } else {
1051
+ ?>
1052
+ </th>
1053
+ </tr>
1054
  <tr valign="top">
1055
  <th><?php esc_html_e('Name', 'mailchimp_i18n');?></th>
1056
  <th><?php esc_html_e('Tag', 'mailchimp_i18n');?></th>
1088
 
1089
  ?>
1090
 
1091
+ <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
1092
 
1093
  <?php
1094
  // Interest Groups Table
1095
  $igs = get_option('mc_interest_groups');
1096
+ if (is_array($igs) && !isset($igs['id'])) { ?>
1097
+ <h3 class="mc-h3"><?php esc_html_e('Group Settings', 'mailchimp_i18n'); ?></h3> <?php
1098
  // Determines whether or not to continue processing. Only false if there was an error.
1099
  $continue = true;
1100
  foreach ($igs as $ig) {
1107
  }
1108
  else {
1109
  ?>
1110
+ <table class='mc-widefat mc-blue' width="450px" cellspacing="0">
1111
  <tr valign="top">
1112
+ <th colspan="2"><?php echo esc_html($ig['name']); ?></th>
1113
+ </tr>
1114
+ <tr valign="top">
1115
+ <th>
1116
  <label for="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>"><?php esc_html_e('Show?', 'mailchimp_i18n'); ?></label>
1117
  </th>
1118
  <th>
1120
  </th>
1121
  </tr>
1122
  <tr valign="top">
1123
+ <th><?php esc_html_e('Input Type', 'mailchimp_i18n'); ?></th>
 
 
 
 
1124
  <td><?php echo esc_html($ig['form_field']); ?></td>
1125
  </tr>
1126
+ <tr valign="top" class="last-row">
1127
+ <th><?php esc_html_e('Options', 'mailchimp_i18n'); ?></th>
1128
  <td>
1129
  <ul>
1130
  <?php
1143
  }
1144
  }
1145
  }
 
 
 
 
 
 
1146
  ?>
1147
+
1148
+ <table class="widefat mc-widefat mc-yellow">
1149
+ <tr><th colspan="2">CSS Cheat Sheet</th></tr>
1150
+ <tr valign="top">
1151
+ <th scope="row">.widget_mailchimpsf_widget </th>
1152
+ <td>This targets the entire widget container.</td>
1153
+ </tr>
1154
+ <tr valign="top">
1155
+ <th scope="row">.widget-title</th>
1156
+ <td>This styles the title of your MailChimp widget. <i>Modifying this class will affect your other widget titles.</i></td>
1157
+ </tr>
1158
+ <tr valign="top">
1159
+ <th scope="row">#mc_signup</th>
1160
+ <td>This targets the entirity of the widget beneath the widget title.</td>
1161
+ </tr>
1162
+ <tr valign="top">
1163
+ <th scope="row">#mc_subheader</th>
1164
+ <td>This styles the subheader text.</td>
1165
+ </tr>
1166
+ <tr valign="top">
1167
+ <th scope="row">.mc_form_inside</th>
1168
+ <td>The guts and main container for the all of the form elements (the entirety of the widget minus the header and the sub header).</td>
1169
+ </tr>
1170
+ <tr valign="top">
1171
+ <th scope="row">.mc_header</th>
1172
+ <td>This targets the label above the input fields.</td>
1173
+ </tr>
1174
+ <tr valign="top">
1175
+ <th scope="row">.mc_input</th>
1176
+ <td>This attaches to the input fields.</td>
1177
+ </tr>
1178
+ <tr valign="top">
1179
+ <th scope="row">.mc_header_address</th>
1180
+ <td>This is the label above an address group.</td>
1181
+ </tr>
1182
+ <tr valign="top">
1183
+ <th scope="row">.mc_radio_label</th>
1184
+ <td>These are the labels associated with radio buttons.</td>
1185
+ </tr>
1186
+ <tr valign="top">
1187
+ <th scope="row">#mc-indicates-required</th>
1188
+ <td>This targets the “Indicates Required Field” text.</td>
1189
+ </tr>
1190
+ <tr valign="top">
1191
+ <th scope="row">#mc_signup_submit</th>
1192
+ <td>Use this to style the submit button.</td>
1193
+ </tr>
1194
+
1195
+
1196
+ </table>
1197
+
1198
  </div>
1199
+
1200
+
1201
+
1202
  </form>
1203
  </div>
1204
  </div><!--wrap-->
1207
 
1208
 
1209
  function mailchimpSF_register_widgets() {
1210
+ if (mailchimpSF_get_api()) {
1211
+ register_widget('mailchimpSF_Widget');
1212
+ }
1213
  }
1214
  add_action('widgets_init', 'mailchimpSF_register_widgets');
1215
 
1353
  if ($merge_key !== 'GROUPINGS') {
1354
  switch ($mv_tag_keys[$merge_key]['field_type']) {
1355
  case 'phone':
1356
+ if ($mv_tag_keys[$merge_key]['phoneformat'] == 'US') {
1357
+ $phone = $merge_value;
1358
+ if (!empty($phone)) {
1359
+ if (!preg_match('/[0-9]{0,3}-[0-9]{0,3}-[0-9]{0,4}/', $phone)) {
1360
+ $errs[] = sprintf(__("%s must consist of only numbers", 'mailchimp_i18n'), esc_html($mv_tag_keys[$merge_key]['name']));
1361
+ $success = false;
1362
+ }
1363
  }
1364
  }
1365
  break;
1371
  }
1372
  }
1373
  if ($success) {
1374
+ $api = mailchimpSF_get_api();
1375
+ if (!$api) { return; }
1376
+
1377
  $retval = $api->listSubscribe( $listId, $email, $merge, $email_type);
1378
  if (!$retval) {
1379
  switch($api->errorCode) {
1385
 
1386
  $account = $api->getAccountDetails(array("modules", "orders", "rewards-credits", "rewards-inspections", "rewards-referrals", "rewards-applied"));
1387
  if (!$api->errorCode) {
1388
+ $dc = get_option('mc_sopresto_dc');
1389
  $uid = $account['user_id'];
1390
+ $username = preg_replace('/\s+/', '-', $account['username']);
1391
  $eid = base64_encode($email);
1392
  $msg .= ' ' . sprintf(__('<a href="%s">Click here to update your profile.</a>', 'mailchimp_i18n'), "http://$username.$dc.list-manage.com/subscribe/send-email?u=$uid&id=$listId&e=$eid");
1393
  }
mailchimp_widget.php CHANGED
@@ -20,10 +20,6 @@ function mailchimpSF_signup_form($args = array()) {
20
  return;
21
  }
22
 
23
- // Get some options
24
- $uid = get_option('mc_user_id');
25
- $list_name = get_option('mc_list_name');
26
-
27
  if (!empty($before_widget)) {
28
  echo $before_widget;
29
  }
@@ -44,7 +40,82 @@ function mailchimpSF_signup_form($args = array()) {
44
 
45
  $sub_heading = trim(get_option('mc_subheader_content'));
46
  ?>
47
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  <div id="mc_signup">
49
  <form method="post" action="#mc_signup" id="mc_signup_form">
50
  <input type="hidden" id="mc_submit_type" name="mc_submit_type" value="html" />
@@ -137,12 +208,11 @@ function mailchimpSF_signup_form($args = array()) {
137
  if (get_option('mc_email_type_option')) {
138
  ?>
139
  <div class="mergeRow">
140
- <label><?php _e('Preferred Format', 'mailchimp_i18n'); ?></label>
141
- <div class="field-group groups">
142
  <ul class="mc_list">
143
- <li><input type="radio" name="email_type" id="email_type_html" value="html" checked="checked"><label for="email_type_html"><?php _e('HTML', 'mailchimp_i18n'); ?></label></li>
144
- <li><input type="radio" name="email_type" id="email_type_text" value="text"><label for="email_type_text"><?php _e('Text', 'mailchimp_i18n'); ?></label></li>
145
- <li><input type="radio" name="email_type" id="email_type_mobile" value="mobile"><label for="email_type_mobile"><?php _e('Mobile', 'mailchimp_i18n'); ?></label></li>
146
  </ul>
147
  </div>
148
  </div>
@@ -157,21 +227,21 @@ function mailchimpSF_signup_form($args = array()) {
157
 
158
 
159
  <?php
160
- if ( get_option('mc_use_unsub_link') == 'on') {
161
- list($key, $dc) = explode("-",get_option('mc_apikey'),2);
162
- if (!$dc) $dc = "us1";
163
  $host = 'http://'.$dc.'.list-manage.com';
164
  ?>
165
  <div id="mc_unsub_link" align="center">
166
- <a href="<?php echo esc_url($host.'/unsubscribe/?u='.get_option('mc_user_id').'&amp;id='.get_option('mc_list_id')); ?>" target="_blank"><?php esc_html_e('unsubscribe from list', 'mailchimp_i18n'); ?></a>
167
  </div><!-- /mc_unsub_link -->
168
  <?php
169
  }
170
- if ( get_option('mc_rewards') == 'on') {
171
  ?>
172
  <br/>
173
  <div id="mc_display_rewards" align="center">
174
- <?php esc_html_e('powered by', 'mailchimp_i18n'); ?> <a href="<?php echo esc_url('http://www.mailchimp.com/affiliates/?aid='.get_option('mc_user_id').'&amp;afl=1'); ?>">MailChimp</a>!
175
  </div><!-- /mc_display_rewards -->
176
  <?php
177
  }
@@ -257,7 +327,7 @@ function mailchimp_form_field($var, $num_fields) {
257
  $html = '';
258
  // See if that var is set as required, or turned on (for display)
259
  if ($var['req'] || get_option($opt) == 'on') {
260
- $label = '<label for="'.esc_attr($opt).'" class="mc_var_label">'.esc_html($var['name']);
261
  if ($var['req'] && $num_fields > 1) {
262
  $label .= '<span class="mc_required">*</span>';
263
  }
@@ -266,11 +336,10 @@ function mailchimp_form_field($var, $num_fields) {
266
  $html .= '
267
  <div class="mc_merge_var">
268
  '.$label;
269
-
270
  switch ($var['field_type']) {
271
  case 'date':
272
  $html .= '
273
- <input type="text" size="18" value="'.esc_attr($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="date-pick mc_input"/>';
274
  break;
275
  case 'radio':
276
  if (is_array($var['choices'])) {
@@ -290,7 +359,7 @@ function mailchimp_form_field($var, $num_fields) {
290
  case 'dropdown':
291
  if (is_array($var['choices'])) {
292
  $html .= '
293
- <br /><select id="'.esc_attr($opt).'" name="'.esc_attr($opt).'" class="mc_select">';
294
  foreach ($var['choices'] as $value) {
295
  $html .= '
296
  <option value="'.esc_attr($value).'"'.selected($value, $var['default'], false).'>'.esc_html($value).'</option>';
@@ -301,7 +370,7 @@ function mailchimp_form_field($var, $num_fields) {
301
  break;
302
  case 'birthday':
303
  $html .= '
304
- <input type="text" size="18" value="'.esc_attr($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="birthdate-pick mc_input"/>';
305
  break;
306
  case 'birthday-old':
307
  $days = range(1, 31);
@@ -328,18 +397,18 @@ function mailchimp_form_field($var, $num_fields) {
328
  case 'address':
329
  $countries = mailchimp_country_list();
330
  $html .= '
331
- <br />
332
- <label for="'.esc_attr($opt.'-addr1').'" class="mc_address_label">'.__('Street Address', 'mailchimp_i18n').'</label> <br />
333
- <input type="text" size="18" value="" name="'.esc_attr($opt.'[addr1]').'" id="'.esc_attr($opt.'-addr1').'" class="mc_input" /> <br />
334
- <label for="'.esc_attr($opt.'-addr2').'" class="mc_address_label">'.__('Address Line 2', 'mailchimp_i18n').'</label> <br />
335
- <input type="text" size="18" value="" name="'.esc_attr($opt.'[addr2]').'" id="'.esc_attr($opt.'-addr2').'" class="mc_input" /> <br />
336
- <label for="'.esc_attr($opt.'-city').'" class="mc_address_label">'.__('City', 'mailchimp_i18n').'</label> <br />
337
- <input type="text" size="18" value="" name="'.esc_attr($opt.'[city]').'" id="'.esc_attr($opt.'-city').'" class="mc_input" /> <br />
338
- <label for="'.esc_attr($opt.'-state').'" class="mc_address_label">'.__('State', 'mailchimp_i18n').'</label> <br />
339
- <input type="text" size="18" value="" name="'.esc_attr($opt.'[state]').'" id="'.esc_attr($opt.'-state').'" class="mc_input" /> <br />
340
- <label for="'.esc_attr($opt.'-zip').'" class="mc_address_label">'.__('Zip / Postal', 'mailchimp_i18n').'</label> <br />
341
- <input type="text" size="18" value="" maxlength="5" name="'.esc_attr($opt.'[zip]').'" id="'.esc_attr($opt.'-zip').'" class="mc_input" /> <br />
342
- <label for="'.esc_attr($opt.'-country').'" class="mc_address_label">'.__('Country', 'mailchimp_i18n').'</label> <br />
343
  <select name="'.esc_attr($opt.'[country]').'" id="'.esc_attr($opt.'-country').'">';
344
  foreach ($countries as $country_code => $country_name) {
345
  $html .= '
@@ -353,11 +422,18 @@ function mailchimp_form_field($var, $num_fields) {
353
  <input type="text" size="18" maxlength="5" value="" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input" />';
354
  break;
355
  case 'phone':
356
- $html .= '<br />
357
- &#40; <input type="text" size="3" maxlength="3" value="" name="'.esc_attr($opt.'[area]').'" id="'.esc_attr($opt.'-area').'" class="mc_input mc_phone" /> &#41; &ndash;
358
- <input type="text" size="3" maxlength="3" value="" name="'.esc_attr($opt.'[detail1]').'" id="'.esc_attr($opt.'-detail1').'" class="mc_input mc_phone" /> &ndash;
359
- <input type="text" size="4" maxlength="4" value="" name="'.esc_attr($opt.'[detail2]').'" id="'.esc_attr($opt.'-detail2').'" class="mc_input mc_phone" />
360
- ';
 
 
 
 
 
 
 
361
  break;
362
  case 'email':
363
  case 'url':
@@ -366,7 +442,7 @@ function mailchimp_form_field($var, $num_fields) {
366
  case 'number':
367
  default:
368
  $html .= '
369
- <input type="text" size="18" value="'.esc_html($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input"/>';
370
  break;
371
  }
372
  if (!empty($var['helptext'])) {
@@ -382,6 +458,7 @@ function mailchimp_form_field($var, $num_fields) {
382
  /**
383
  * MailChimp Subscribe Box widget class
384
  */
 
385
  class mailchimpSF_Widget extends WP_Widget {
386
 
387
  function mailchimpSF_Widget() {
@@ -390,13 +467,15 @@ class mailchimpSF_Widget extends WP_Widget {
390
  );
391
  $this->WP_Widget('mailchimpSF_widget', __('MailChimp Widget', 'mailchimp_i18n'), $widget_ops);
392
  }
393
-
394
  function widget( $args, $instance ) {
395
  if (!is_array($instance)) {
396
  $instance = array();
397
  }
398
  mailchimpSF_signup_form(array_merge($args, $instance));
399
  }
 
 
 
400
  }
401
 
402
  function mailchimp_country_list() {
20
  return;
21
  }
22
 
 
 
 
 
23
  if (!empty($before_widget)) {
24
  echo $before_widget;
25
  }
40
 
41
  $sub_heading = trim(get_option('mc_subheader_content'));
42
  ?>
43
+
44
+ <style>
45
+ .widget_mailchimpsf_widget .widget-title {
46
+ line-height: 1.4em;
47
+ margin-bottom: 0.75em;
48
+ }
49
+ #mc_subheader {
50
+ line-height: 1.25em;
51
+ margin-bottom: 18px;
52
+ }
53
+ .mc_merge_var {
54
+ margin-bottom: 1.0em;
55
+ }
56
+ .mc_var_label,
57
+ .mc_interest_label {
58
+ display: block;
59
+ margin-bottom: 0.5em;
60
+ }
61
+ .mc_input {
62
+ -moz-box-sizing: border-box;
63
+ -webkit-box-sizing: border-box;
64
+ box-sizing: border-box;
65
+ width: 100%;
66
+ }
67
+ .mc_input.mc_phone {
68
+ width: auto;
69
+ }
70
+ select.mc_select {
71
+ margin-top: 0.5em;
72
+ width: 100%;
73
+ }
74
+ .mc_address_label {
75
+ margin-top: 1.0em;
76
+ margin-bottom: 0.5em;
77
+ display: block;
78
+ }
79
+ .mc_address_label ~ select {
80
+ width: 100%;
81
+ }
82
+ .mc_list li {
83
+ list-style: none;
84
+ background: none !important;
85
+ }
86
+ .mc_interests_header {
87
+ margin-top: 1.0em;
88
+ margin-bottom: 0.5em;
89
+ }
90
+ .mc_interest label,
91
+ .mc_interest input {
92
+ margin-bottom: 0.4em;
93
+ }
94
+ #mc_signup_submit {
95
+ margin-top: 1.5em;
96
+ width: 80%;
97
+ }
98
+ #mc_unsub_link a {
99
+ font-size: 0.75em;
100
+ }
101
+ #mc_unsub_link {
102
+ margin-top: 1.0em;
103
+ }
104
+ .mc_header_address,
105
+ .mc_email_format {
106
+ display: block;
107
+ font-weight: bold;
108
+ margin-top: 1.0em;
109
+ margin-bottom: 0.5em;
110
+ }
111
+ .mc_email_options {
112
+ margin-top: 0.5em;
113
+ }
114
+ .mc_email_type {
115
+ padding-left: 4px;
116
+ }
117
+ </style>
118
+
119
  <div id="mc_signup">
120
  <form method="post" action="#mc_signup" id="mc_signup_form">
121
  <input type="hidden" id="mc_submit_type" name="mc_submit_type" value="html" />
208
  if (get_option('mc_email_type_option')) {
209
  ?>
210
  <div class="mergeRow">
211
+ <label class="mc_email_format"><?php _e('Preferred Format', 'mailchimp_i18n'); ?></label>
212
+ <div class="field-group groups mc_email_options">
213
  <ul class="mc_list">
214
+ <li><input type="radio" name="email_type" id="email_type_html" value="html" checked="checked"><label for="email_type_html" class="mc_email_type"><?php _e('HTML', 'mailchimp_i18n'); ?></label></li>
215
+ <li><input type="radio" name="email_type" id="email_type_text" value="text"><label for="email_type_text" class="mc_email_type"><?php _e('Text', 'mailchimp_i18n'); ?></label></li>
 
216
  </ul>
217
  </div>
218
  </div>
227
 
228
 
229
  <?php
230
+ $user = get_option('mc_sopresto_user');
231
+ if ($user && get_option('mc_use_unsub_link') == 'on') {
232
+ $dc = get_option('mc_sopresto_dc', 'us1');
233
  $host = 'http://'.$dc.'.list-manage.com';
234
  ?>
235
  <div id="mc_unsub_link" align="center">
236
+ <a href="<?php echo esc_url($host.'/unsubscribe/?u='.$user['user_id'].'&amp;id='.get_option('mc_list_id')); ?>" target="_blank"><?php esc_html_e('unsubscribe from list', 'mailchimp_i18n'); ?></a>
237
  </div><!-- /mc_unsub_link -->
238
  <?php
239
  }
240
+ if ($user && get_option('mc_rewards') == 'on') {
241
  ?>
242
  <br/>
243
  <div id="mc_display_rewards" align="center">
244
+ <?php esc_html_e('powered by', 'mailchimp_i18n'); ?> <a href="<?php echo esc_url('http://www.mailchimp.com/affiliates/?aid='.$user['user_id'].'&amp;afl=1'); ?>">MailChimp</a>!
245
  </div><!-- /mc_display_rewards -->
246
  <?php
247
  }
327
  $html = '';
328
  // See if that var is set as required, or turned on (for display)
329
  if ($var['req'] || get_option($opt) == 'on') {
330
+ $label = '<label for="'.esc_attr($opt).'" class="mc_var_label mc_header mc_header_'.esc_attr($var['field_type']).'">'.esc_html($var['name']);
331
  if ($var['req'] && $num_fields > 1) {
332
  $label .= '<span class="mc_required">*</span>';
333
  }
336
  $html .= '
337
  <div class="mc_merge_var">
338
  '.$label;
 
339
  switch ($var['field_type']) {
340
  case 'date':
341
  $html .= '
342
+ <input type="text" size="18" placeholder="'.esc_attr($var['default']).'" data-format="'.esc_attr($var['dateformat']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="date-pick mc_input"/>';
343
  break;
344
  case 'radio':
345
  if (is_array($var['choices'])) {
359
  case 'dropdown':
360
  if (is_array($var['choices'])) {
361
  $html .= '
362
+ <select id="'.esc_attr($opt).'" name="'.esc_attr($opt).'" class="mc_select">';
363
  foreach ($var['choices'] as $value) {
364
  $html .= '
365
  <option value="'.esc_attr($value).'"'.selected($value, $var['default'], false).'>'.esc_html($value).'</option>';
370
  break;
371
  case 'birthday':
372
  $html .= '
373
+ <input type="text" size="18" placeholder="'.esc_attr($var['default']).'" data-format="'.esc_attr($var['dateformat']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="birthdate-pick mc_input"/>';
374
  break;
375
  case 'birthday-old':
376
  $days = range(1, 31);
397
  case 'address':
398
  $countries = mailchimp_country_list();
399
  $html .= '
400
+
401
+ <label for="'.esc_attr($opt.'-addr1').'" class="mc_address_label">'.__('Street Address', 'mailchimp_i18n').'</label>
402
+ <input type="text" size="18" value="" name="'.esc_attr($opt.'[addr1]').'" id="'.esc_attr($opt.'-addr1').'" class="mc_input" />
403
+ <label for="'.esc_attr($opt.'-addr2').'" class="mc_address_label">'.__('Address Line 2', 'mailchimp_i18n').'</label>
404
+ <input type="text" size="18" value="" name="'.esc_attr($opt.'[addr2]').'" id="'.esc_attr($opt.'-addr2').'" class="mc_input" />
405
+ <label for="'.esc_attr($opt.'-city').'" class="mc_address_label">'.__('City', 'mailchimp_i18n').'</label>
406
+ <input type="text" size="18" value="" name="'.esc_attr($opt.'[city]').'" id="'.esc_attr($opt.'-city').'" class="mc_input" />
407
+ <label for="'.esc_attr($opt.'-state').'" class="mc_address_label">'.__('State', 'mailchimp_i18n').'</label>
408
+ <input type="text" size="18" value="" name="'.esc_attr($opt.'[state]').'" id="'.esc_attr($opt.'-state').'" class="mc_input" />
409
+ <label for="'.esc_attr($opt.'-zip').'" class="mc_address_label">'.__('Zip / Postal', 'mailchimp_i18n').'</label>
410
+ <input type="text" size="18" value="" maxlength="5" name="'.esc_attr($opt.'[zip]').'" id="'.esc_attr($opt.'-zip').'" class="mc_input" />
411
+ <label for="'.esc_attr($opt.'-country').'" class="mc_address_label">'.__('Country', 'mailchimp_i18n').'</label>
412
  <select name="'.esc_attr($opt.'[country]').'" id="'.esc_attr($opt.'-country').'">';
413
  foreach ($countries as $country_code => $country_name) {
414
  $html .= '
422
  <input type="text" size="18" maxlength="5" value="" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input" />';
423
  break;
424
  case 'phone':
425
+ if ($var['phoneformat'] == 'US') {
426
+ $html .= '
427
+ <input type="text" size="2" maxlength="3" value="" name="'.esc_attr($opt.'[area]').'" id="'.esc_attr($opt.'-area').'" class="mc_input mc_phone" />
428
+ <input type="text" size="2" maxlength="3" value="" name="'.esc_attr($opt.'[detail1]').'" id="'.esc_attr($opt.'-detail1').'" class="mc_input mc_phone" />
429
+ <input type="text" size="5" maxlength="4" value="" name="'.esc_attr($opt.'[detail2]').'" id="'.esc_attr($opt.'-detail2').'" class="mc_input mc_phone" />
430
+ ';
431
+ }
432
+ else {
433
+ $html .= '
434
+ <input type="text" size="18" value="" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input" />
435
+ ';
436
+ }
437
  break;
438
  case 'email':
439
  case 'url':
442
  case 'number':
443
  default:
444
  $html .= '
445
+ <input type="text" size="18" placeholder="'.esc_html($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input"/>';
446
  break;
447
  }
448
  if (!empty($var['helptext'])) {
458
  /**
459
  * MailChimp Subscribe Box widget class
460
  */
461
+
462
  class mailchimpSF_Widget extends WP_Widget {
463
 
464
  function mailchimpSF_Widget() {
467
  );
468
  $this->WP_Widget('mailchimpSF_widget', __('MailChimp Widget', 'mailchimp_i18n'), $widget_ops);
469
  }
 
470
  function widget( $args, $instance ) {
471
  if (!is_array($instance)) {
472
  $instance = array();
473
  }
474
  mailchimpSF_signup_form(array_merge($args, $instance));
475
  }
476
+ function form( $instance ) { ?>
477
+ <p>Great work! Your widget is ready to go — just head <a href="<?php echo admin_url('options-general.php?page=mailchimpSF_options') ?>">over here</a> if you’d like to adjust your settings.</p>
478
+ <?php }
479
  }
480
 
481
  function mailchimp_country_list() {
miniMCAPI.class.php DELETED
@@ -1,403 +0,0 @@
1
- <?php
2
- /**
3
- This is a subset of the Actual MCAPI and miniMCAPI classes for v1.3 that includes the list related methods and support for PHP4
4
- DOWNLOAD A NEW VERSION IF YOU WANT THE FULL, CORRECT WRAPPER.
5
- **/
6
- class mailchimpSF_MCAPI {
7
- var $version = "1.3";
8
- var $errorMessage;
9
- var $errorCode;
10
-
11
- /**
12
- * Cache the information on the API location on the server
13
- */
14
- var $apiUrl;
15
-
16
- /**
17
- * Default to a 300 second timeout on server calls
18
- */
19
- var $timeout = 300;
20
-
21
- /**
22
- * Default to a 8K chunk size
23
- */
24
- var $chunkSize = 8192;
25
-
26
- /**
27
- * Cache the user api_key so we only have to log in once per client instantiation
28
- */
29
- var $api_key;
30
-
31
- /**
32
- * Cache the user api_key so we only have to log in once per client instantiation
33
- */
34
- var $secure = false;
35
-
36
- /**
37
- * Connect to the MailChimp API for a given list.
38
- *
39
- * @param string $apikey Your MailChimp apikey
40
- * @param string $secure Whether or not this should use a secure connection
41
- */
42
- function mailchimpSF_MCAPI($apikey, $secure=false) {
43
- $this->secure = $secure;
44
- $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
45
- $this->api_key = $apikey;
46
- }
47
- function setTimeout($seconds){
48
- if (is_int($seconds)){
49
- $this->timeout = $seconds;
50
- return true;
51
- }
52
- }
53
- function getTimeout(){
54
- return $this->timeout;
55
- }
56
- function useSecure($val){
57
- if ($val===true){
58
- $this->secure = true;
59
- } else {
60
- $this->secure = false;
61
- }
62
- }
63
-
64
- function lists($filters=array (
65
- ), $start=0, $limit=25) {
66
- $params = array();
67
- $params["filters"] = $filters;
68
- $params["start"] = $start;
69
- $params["limit"] = $limit;
70
- return $this->callServer("lists", $params);
71
- }
72
-
73
- function listMergeVars($id) {
74
- $params = array();
75
- $params["id"] = $id;
76
- return $this->callServer("listMergeVars", $params);
77
- }
78
-
79
-
80
- function listMergeVarAdd($id, $tag, $name, $options=array (
81
- )) {
82
- $params = array();
83
- $params["id"] = $id;
84
- $params["tag"] = $tag;
85
- $params["name"] = $name;
86
- $params["options"] = $options;
87
- return $this->callServer("listMergeVarAdd", $params);
88
- }
89
-
90
- function listMergeVarUpdate($id, $tag, $options) {
91
- $params = array();
92
- $params["id"] = $id;
93
- $params["tag"] = $tag;
94
- $params["options"] = $options;
95
- return $this->callServer("listMergeVarUpdate", $params);
96
- }
97
-
98
- function listMergeVarDel($id, $tag) {
99
- $params = array();
100
- $params["id"] = $id;
101
- $params["tag"] = $tag;
102
- return $this->callServer("listMergeVarDel", $params);
103
- }
104
-
105
-
106
- function listInterestGroupings($id) {
107
- $params = array();
108
- $params["id"] = $id;
109
- return $this->callServer("listInterestGroupings", $params);
110
- }
111
-
112
- function listInterestGroupAdd($id, $group_name, $grouping_id=NULL) {
113
- $params = array();
114
- $params["id"] = $id;
115
- $params["group_name"] = $group_name;
116
- $params["grouping_id"] = $grouping_id;
117
- return $this->callServer("listInterestGroupAdd", $params);
118
- }
119
-
120
- function listInterestGroupDel($id, $group_name, $grouping_id=NULL) {
121
- $params = array();
122
- $params["id"] = $id;
123
- $params["group_name"] = $group_name;
124
- $params["grouping_id"] = $grouping_id;
125
- return $this->callServer("listInterestGroupDel", $params);
126
- }
127
-
128
- function listInterestGroupUpdate($id, $old_name, $new_name, $grouping_id=NULL) {
129
- $params = array();
130
- $params["id"] = $id;
131
- $params["old_name"] = $old_name;
132
- $params["new_name"] = $new_name;
133
- $params["grouping_id"] = $grouping_id;
134
- return $this->callServer("listInterestGroupUpdate", $params);
135
- }
136
-
137
- function listInterestGroupingAdd($id, $name, $type, $groups) {
138
- $params = array();
139
- $params["id"] = $id;
140
- $params["name"] = $name;
141
- $params["type"] = $type;
142
- $params["groups"] = $groups;
143
- return $this->callServer("listInterestGroupingAdd", $params);
144
- }
145
-
146
- function listInterestGroupingUpdate($grouping_id, $name, $value) {
147
- $params = array();
148
- $params["grouping_id"] = $grouping_id;
149
- $params["name"] = $name;
150
- $params["value"] = $value;
151
- return $this->callServer("listInterestGroupingUpdate", $params);
152
- }
153
-
154
-
155
- function listInterestGroupingDel($grouping_id) {
156
- $params = array();
157
- $params["grouping_id"] = $grouping_id;
158
- return $this->callServer("listInterestGroupingDel", $params);
159
- }
160
-
161
- function listSubscribe($id, $email_address, $merge_vars=NULL, $email_type='html', $double_optin=true, $update_existing=false, $replace_interests=true, $send_welcome=false) {
162
- $params = array();
163
- $params["id"] = $id;
164
- $params["email_address"] = $email_address;
165
- $params["merge_vars"] = $merge_vars;
166
- $params["email_type"] = $email_type;
167
- $params["double_optin"] = $double_optin;
168
- $params["update_existing"] = $update_existing;
169
- $params["replace_interests"] = $replace_interests;
170
- $params["send_welcome"] = $send_welcome;
171
- return $this->callServer("listSubscribe", $params);
172
- }
173
-
174
- function listUnsubscribe($id, $email_address, $delete_member=false, $send_goodbye=true, $send_notify=true) {
175
- $params = array();
176
- $params["id"] = $id;
177
- $params["email_address"] = $email_address;
178
- $params["delete_member"] = $delete_member;
179
- $params["send_goodbye"] = $send_goodbye;
180
- $params["send_notify"] = $send_notify;
181
- return $this->callServer("listUnsubscribe", $params);
182
- }
183
-
184
-
185
- function listUpdateMember($id, $email_address, $merge_vars, $email_type='', $replace_interests=true) {
186
- $params = array();
187
- $params["id"] = $id;
188
- $params["email_address"] = $email_address;
189
- $params["merge_vars"] = $merge_vars;
190
- $params["email_type"] = $email_type;
191
- $params["replace_interests"] = $replace_interests;
192
- return $this->callServer("listUpdateMember", $params);
193
- }
194
-
195
- function listBatchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) {
196
- $params = array();
197
- $params["id"] = $id;
198
- $params["batch"] = $batch;
199
- $params["double_optin"] = $double_optin;
200
- $params["update_existing"] = $update_existing;
201
- $params["replace_interests"] = $replace_interests;
202
- return $this->callServer("listBatchSubscribe", $params);
203
- }
204
-
205
- function listBatchUnsubscribe($id, $emails, $delete_member=false, $send_goodbye=true, $send_notify=false) {
206
- $params = array();
207
- $params["id"] = $id;
208
- $params["emails"] = $emails;
209
- $params["delete_member"] = $delete_member;
210
- $params["send_goodbye"] = $send_goodbye;
211
- $params["send_notify"] = $send_notify;
212
- return $this->callServer("listBatchUnsubscribe", $params);
213
- }
214
-
215
- function listMembers($id, $status='subscribed', $since=NULL, $start=0, $limit=100) {
216
- $params = array();
217
- $params["id"] = $id;
218
- $params["status"] = $status;
219
- $params["since"] = $since;
220
- $params["start"] = $start;
221
- $params["limit"] = $limit;
222
- return $this->callServer("listMembers", $params);
223
- }
224
-
225
-
226
- function listMemberInfo($id, $email_address) {
227
- $params = array();
228
- $params["id"] = $id;
229
- $params["email_address"] = $email_address;
230
- return $this->callServer("listMemberInfo", $params);
231
- }
232
-
233
- function listMemberActivity($id, $email_address) {
234
- $params = array();
235
- $params["id"] = $id;
236
- $params["email_address"] = $email_address;
237
- return $this->callServer("listMemberActivity", $params);
238
- }
239
-
240
- function getAccountDetails() {
241
- $params = array();
242
- return $this->callServer("getAccountDetails", $params);
243
- }
244
-
245
- function listsForEmail($email_address) {
246
- $params = array();
247
- $params["email_address"] = $email_address;
248
- return $this->callServer("listsForEmail", $params);
249
- }
250
-
251
-
252
- function campaignsForEmail($email_address) {
253
- $params = array();
254
- $params["email_address"] = $email_address;
255
- return $this->callServer("campaignsForEmail", $params);
256
- }
257
-
258
-
259
- /**
260
- * "Ping" the MailChimp API - a simple method you can call that will return a constant value as long as everything is good. Note
261
- * than unlike most all of our methods, we don't throw an Exception if we are having issues. You will simply receive a different
262
- * string back that will explain our view on what is going on.
263
- *
264
- * @section Helper
265
- * @example xml-rpc_ping.php
266
- *
267
- * @return string returns "Everything's Chimpy!" if everything is chimpy, otherwise returns an error message
268
- */
269
- function ping() {
270
- $params = array();
271
- return $this->callServer("ping", $params);
272
- }
273
-
274
- /**
275
- * Internal function - proxy method for certain XML-RPC calls | DO NOT CALL
276
- * @param mixed Method to call, with any parameters to pass along
277
- * @return mixed the result of the call
278
- */
279
- function callMethod() {
280
- $params = array();
281
- return $this->callServer("callMethod", $params);
282
- }
283
-
284
- /**
285
- * Actually connect to the server and call the requested methods, parsing the result
286
- * You should never have to call this function manually
287
- */
288
- function callServer($method, $params) {
289
- $dc = "us1";
290
- if (strstr($this->api_key,"-")){
291
- list($key, $dc) = explode("-",$this->api_key,2);
292
- if (!$dc) $dc = "us1";
293
- }
294
- $host = $dc.".".$this->apiUrl["host"];
295
- $params["apikey"] = $this->api_key;
296
-
297
- $this->errorMessage = "";
298
- $this->errorCode = "";
299
- $sep_changed = false;
300
- //sigh, apparently some distribs change this to &amp; by default
301
- if (ini_get("arg_separator.output")!="&"){
302
- $sep_changed = true;
303
- $orig_sep = ini_get("arg_separator.output");
304
- ini_set("arg_separator.output", "&");
305
- }
306
- $post_vars = $this->httpBuildQuery($params);
307
- if ($sep_changed){
308
- ini_set("arg_separator.output", $orig_sep);
309
- }
310
-
311
- $payload = "POST " . $this->apiUrl["path"] . "?" . $this->apiUrl["query"] . "&method=" . $method . " HTTP/1.0\r\n";
312
- $payload .= "Host: " . $host . "\r\n";
313
- $payload .= "User-Agent: MCAPIwp/" . $this->version ."\r\n";
314
- $payload .= "Content-type: application/x-www-form-urlencoded\r\n";
315
- $payload .= "Content-length: " . strlen($post_vars) . "\r\n";
316
- $payload .= "Connection: close \r\n\r\n";
317
- $payload .= $post_vars;
318
-
319
- ob_start();
320
- if ($this->secure){
321
- $sock = @fsockopen("ssl://".$host, 443, $errno, $errstr, 30);
322
- } else {
323
- $sock = @fsockopen($host, 80, $errno, $errstr, 30);
324
- }
325
- if(!$sock) {
326
- $this->errorMessage = "Could not connect (ERR $errno: $errstr)";
327
- $this->errorCode = "-99";
328
- ob_end_clean();
329
- return false;
330
- }
331
-
332
- $response = "";
333
- fwrite($sock, $payload);
334
- stream_set_timeout($sock, $this->timeout);
335
- $info = stream_get_meta_data($sock);
336
- while ((!feof($sock)) && (!$info["timed_out"])) {
337
- $response .= fread($sock, $this->chunkSize);
338
- $info = stream_get_meta_data($sock);
339
- }
340
- fclose($sock);
341
- ob_end_clean();
342
- if ($info["timed_out"]) {
343
- $this->errorMessage = "Could not read response (timed out)";
344
- $this->errorCode = -98;
345
- return false;
346
- }
347
-
348
- list($headers, $response) = explode("\r\n\r\n", $response, 2);
349
- $headers = explode("\r\n", $headers);
350
- $errored = false;
351
- foreach($headers as $h){
352
- if (substr($h,0,26)==="X-MailChimp-API-Error-Code"){
353
- $errored = true;
354
- $error_code = trim(substr($h,27));
355
- break;
356
- }
357
- }
358
-
359
- if(ini_get("magic_quotes_runtime")) $response = stripslashes($response);
360
-
361
- $serial = unserialize($response);
362
- if($response && $serial === false) {
363
- $response = array("error" => "Bad Response. Got This: " . $response, "code" => "-99");
364
- } else {
365
- $response = $serial;
366
- }
367
- if($errored && is_array($response) && isset($response["error"])) {
368
- $this->errorMessage = $response["error"];
369
- $this->errorCode = $response["code"];
370
- return false;
371
- } elseif($errored){
372
- $this->errorMessage = "No error message was found";
373
- $this->errorCode = $error_code;
374
- return false;
375
- }
376
-
377
- return $response;
378
- }
379
-
380
- /**
381
- * Re-implement http_build_query for systems that do not already have it
382
- */
383
- function httpBuildQuery($params, $key=null) {
384
- $ret = array();
385
-
386
- foreach((array) $params as $name => $val) {
387
- $name = urlencode($name);
388
- if($key !== null) {
389
- $name = $key . "[" . $name . "]";
390
- }
391
-
392
- if(is_array($val) || is_object($val)) {
393
- $ret[] = $this->httpBuildQuery($val, $name);
394
- } elseif($val !== null) {
395
- $ret[] = $name . "=" . urlencode($val);
396
- }
397
- }
398
-
399
- return implode("&", $ret);
400
- }
401
-
402
- }
403
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: mc_jesse, crowdfavorite
3
  Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
4
  Requires at least: 2.8
5
- Tested up to: 3.5.1
6
- Stable tag: 1.2.14
7
 
8
  == Description ==
9
 
@@ -42,7 +42,7 @@ Or, if you are dropping it in between a bunch of HTML, use this:
42
 
43
  `<?php mailchimpSF_signup_form(); ?>`
44
 
45
- Where ever you want it to show up.
46
 
47
  Note: in some environments you will need to install the Exec_PHP plugin to use that method of display. It can be found here:
48
  http://wordpress.org/extend/plugins/exec-php/
@@ -124,6 +124,11 @@ Maybe! Look in the /po/ directory in our plugin package and see if your language
124
 
125
  == Upgrade Notice ==
126
 
 
 
 
 
 
127
  = 1.2.11 =
128
  Merged pull request from https://github.com/headshift/wp-mailchimp adding additional translation strings.
129
 
@@ -133,7 +138,7 @@ Fixed submission error when apostrophes are present
133
  = 1.2.8=
134
  Fixes bug where entire phone numbers were only being deposited in the area code portion
135
 
136
- = 1.2.6 =
137
  Fixes major bug with "Settings" link on Plugins screen.
138
 
139
  = 1.2.5 =
@@ -141,6 +146,10 @@ Added support for multiple interest groups, field formatting based on type and d
141
 
142
  == Changelog ==
143
 
 
 
 
 
144
  = 1.2.14 =
145
  * Add link to edit profile within error when duplicate signup occurs
146
 
@@ -154,7 +163,7 @@ Added support for multiple interest groups, field formatting based on type and d
154
  * Fixed bug where multiple checkbox type interest groups were returning an invalid error
155
  * Fixed bug where assets were not enqueueing properly if the plugin directory was not set to 'mailchimp'. Now supports any directory name.
156
 
157
- = 1.2.8 =
158
  * Fixed bug where entire phone numbers were only being deposited in the area code portion
159
 
160
  = 1.2.7 =
@@ -182,10 +191,10 @@ Added support for multiple interest groups, field formatting based on type and d
182
  * Change mailchimpSF_where_am_i() to use plugins_url() in place of WP_PLUGIN_URL to take SSL into account when delivering assets (props John LeBlanc)
183
  * Update MCAPI wrapper to bring back PHP4 support (note: PHP 5.2 to be required starting with WordPress 3.2)
184
 
185
- = 1.2.2 =
186
  * Change MCAPI wrapper to use a more unique class name, v1.3 of the API, and a much lighter client library
187
 
188
- = 1.2.1 =
189
  * Fixed internationalization path bug.
190
  * Fixed instances where i18n functions weren't necessary in admin.
191
  * Added more strings to be translated.
2
  Contributors: mc_jesse, crowdfavorite
3
  Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
4
  Requires at least: 2.8
5
+ Tested up to: 3.6.1
6
+ Stable tag: 1.3
7
 
8
  == Description ==
9
 
42
 
43
  `<?php mailchimpSF_signup_form(); ?>`
44
 
45
+ Where ever you want it to show up.
46
 
47
  Note: in some environments you will need to install the Exec_PHP plugin to use that method of display. It can be found here:
48
  http://wordpress.org/extend/plugins/exec-php/
124
 
125
  == Upgrade Notice ==
126
 
127
+ = 1.3 =
128
+ Now using OAuth flow within plugin for user authentication
129
+
130
+ Admin UI refresh
131
+
132
  = 1.2.11 =
133
  Merged pull request from https://github.com/headshift/wp-mailchimp adding additional translation strings.
134
 
138
  = 1.2.8=
139
  Fixes bug where entire phone numbers were only being deposited in the area code portion
140
 
141
+ = 1.2.6 =
142
  Fixes major bug with "Settings" link on Plugins screen.
143
 
144
  = 1.2.5 =
146
 
147
  == Changelog ==
148
 
149
+ = 1.3 =
150
+ * Now using OAuth flow for user authentication
151
+ * Admin UI refresh
152
+
153
  = 1.2.14 =
154
  * Add link to edit profile within error when duplicate signup occurs
155
 
163
  * Fixed bug where multiple checkbox type interest groups were returning an invalid error
164
  * Fixed bug where assets were not enqueueing properly if the plugin directory was not set to 'mailchimp'. Now supports any directory name.
165
 
166
+ = 1.2.8 =
167
  * Fixed bug where entire phone numbers were only being deposited in the area code portion
168
 
169
  = 1.2.7 =
191
  * Change mailchimpSF_where_am_i() to use plugins_url() in place of WP_PLUGIN_URL to take SSL into account when delivering assets (props John LeBlanc)
192
  * Update MCAPI wrapper to bring back PHP4 support (note: PHP 5.2 to be required starting with WordPress 3.2)
193
 
194
+ = 1.2.2 =
195
  * Change MCAPI wrapper to use a more unique class name, v1.3 of the API, and a much lighter client library
196
 
197
+ = 1.2.1 =
198
  * Fixed internationalization path bug.
199
  * Fixed instances where i18n functions weren't necessary in admin.
200
  * Added more strings to be translated.