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
+