MailChimp Forms by MailMunch - Version 1.0.1

Version Description

  • The first version of MailChimp Forms WordPress plugin by MailMunch
Download this release

Release Info

Developer mailmunch
Plugin Icon 128x128 MailChimp Forms by MailMunch
Version 1.0.1
Comparing to
See all releases

Version 1.0.1

Files changed (7) hide show
  1. css/admin.css +779 -0
  2. img/icon.png +0 -0
  3. inc/common.php +73 -0
  4. inc/mailmunchapi.php +158 -0
  5. js/admin.js +47 -0
  6. mailchimp-mailmunch.php +418 -0
  7. readme.txt +147 -0
css/admin.css ADDED
@@ -0,0 +1,779 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #sign-in-form, #sign-up-form {
2
+ display: none;
3
+ }
4
+
5
+ #sign-in-form.active, #sign-up-form.active {
6
+ display: block;
7
+ }
8
+
9
+ #show-sign-in, #show-sign-up {
10
+ cursor: pointer;
11
+ text-decoration: underline;
12
+ }
13
+
14
+ #why-account-btn {
15
+ cursor: pointer;
16
+ }
17
+
18
+ #why-account h4 {
19
+ margin-top: 0px;
20
+ margin-bottom: 0px;
21
+ }
22
+
23
+ #why-account p {
24
+ margin-top: 0px;
25
+ }
26
+
27
+ .create-account-btn {
28
+ cursor: pointer;
29
+ }
30
+
31
+ #mailmunch_frame {
32
+ width: 720px;
33
+ height: 650px;
34
+ margin: 15px 15px 0 5px;
35
+ }
36
+
37
+ #mailmuch-designer-ui {
38
+ background: rgba(255, 255, 255, 0.9);
39
+ z-index: 500000;
40
+ position: fixed;
41
+ overflow: visible;
42
+ top: 0;
43
+ bottom: 0;
44
+ left: 0;
45
+ right: 0;
46
+ height: 100%;
47
+ width: 100%;
48
+ min-width: 0;
49
+ cursor: default;
50
+ display: none;
51
+ }
52
+
53
+ #mailmuch-designer-ui #mailmunch_designer_frame {
54
+ width: 100%;
55
+ height: 100%;
56
+ }
57
+
58
+ .container {
59
+ max-width: 700px;
60
+ padding: 0px 10px;
61
+ }
62
+
63
+ .page-header {
64
+ margin: 20px 0;
65
+ border-bottom: 1px solid #CCC;
66
+ padding-bottom: 5px;
67
+ }
68
+
69
+ .action-btns {
70
+ width: 220px;
71
+ }
72
+
73
+ #unlink-account {
74
+ margin-top: 20px;
75
+ }
76
+
77
+ .unlink-btn {
78
+ background:none!important;
79
+ border:none;
80
+ padding:0!important;
81
+ border-bottom:1px solid #0074a2;
82
+ cursor: pointer;
83
+ color: #0074a2;
84
+ font-size: 12px;
85
+ }
86
+
87
+ .new-optin-btn {
88
+ margin-left: 20px;
89
+ margin-top: 16px;
90
+ display: inline-block;
91
+ }
92
+
93
+
94
+ /* Style Guide */
95
+
96
+ .alert {
97
+ padding: 15px;
98
+ margin-bottom: 20px;
99
+ border: 1px solid transparent;
100
+ border-radius: 4px;
101
+ }
102
+ .alert h4, .alert h3 {
103
+ margin-top: 0;
104
+ color: inherit;
105
+ }
106
+ .alert .alert-link {
107
+ font-weight: bold;
108
+ }
109
+ .alert > p,
110
+ .alert > ul {
111
+ margin-bottom: 0;
112
+ }
113
+ .alert > p + p {
114
+ margin-top: 5px;
115
+ }
116
+ .alert-dismissable {
117
+ padding-right: 35px;
118
+ }
119
+ .alert-dismissable .close {
120
+ position: relative;
121
+ top: -2px;
122
+ right: -21px;
123
+ color: inherit;
124
+ }
125
+ .alert-success {
126
+ color: #3c763d;
127
+ background-color: #dff0d8;
128
+ border-color: #d6e9c6;
129
+ }
130
+ .alert-success hr {
131
+ border-top-color: #c9e2b3;
132
+ }
133
+ .alert-success .alert-link {
134
+ color: #2b542c;
135
+ }
136
+ .alert-info {
137
+ color: #31708f;
138
+ background-color: #d9edf7;
139
+ border-color: #bce8f1;
140
+ }
141
+ .alert-info hr {
142
+ border-top-color: #a6e1ec;
143
+ }
144
+ .alert-info .alert-link {
145
+ color: #245269;
146
+ }
147
+ .alert-warning {
148
+ color: #8a6d3b;
149
+ background-color: #fcf8e3;
150
+ border-color: #faebcc;
151
+ }
152
+ .alert-warning hr {
153
+ border-top-color: #f7e1b5;
154
+ }
155
+ .alert-warning .alert-link {
156
+ color: #66512c;
157
+ }
158
+ .alert-danger {
159
+ color: #a94442;
160
+ background-color: #f2dede;
161
+ border-color: #ebccd1;
162
+ }
163
+ .alert-danger hr {
164
+ border-top-color: #e4b9c0;
165
+ }
166
+ .alert-danger .alert-link {
167
+ color: #843534;
168
+ }
169
+
170
+ label {
171
+ display: inline-block;
172
+ margin-bottom: 5px;
173
+ font-weight: bold;
174
+ }
175
+ input[type="search"] {
176
+ -webkit-box-sizing: border-box;
177
+ -moz-box-sizing: border-box;
178
+ box-sizing: border-box;
179
+ }
180
+ input[type="radio"],
181
+ input[type="checkbox"] {
182
+ margin: 4px 0 0;
183
+ margin-top: 1px \9;
184
+ /* IE8-9 */
185
+ line-height: normal;
186
+ }
187
+ input[type="file"] {
188
+ display: block;
189
+ }
190
+ input[type="range"] {
191
+ display: block;
192
+ width: 100%;
193
+ }
194
+ select[multiple],
195
+ select[size] {
196
+ height: auto;
197
+ }
198
+ input[type="file"]:focus,
199
+ input[type="radio"]:focus,
200
+ input[type="checkbox"]:focus {
201
+ outline: thin dotted;
202
+ outline: 5px auto -webkit-focus-ring-color;
203
+ outline-offset: -2px;
204
+ }
205
+ output {
206
+ display: block;
207
+ padding-top: 7px;
208
+ font-size: 14px;
209
+ line-height: 1.42857143;
210
+ color: #555;
211
+ }
212
+ .form-control {
213
+ display: block;
214
+ width: 400px;
215
+ height: 34px;
216
+ padding: 6px 12px;
217
+ font-size: 14px;
218
+ line-height: 1.42857143;
219
+ color: #555;
220
+ background-color: #fff;
221
+ background-image: none;
222
+ border: 1px solid #ccc;
223
+ border-radius: 4px;
224
+ -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
225
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
226
+ -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
227
+ transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
228
+ }
229
+ .form-control:focus {
230
+ border-color: #66afe9;
231
+ outline: 0;
232
+ -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
233
+ box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);
234
+ }
235
+ .form-control::-moz-placeholder {
236
+ color: #999;
237
+ opacity: 1;
238
+ }
239
+ .form-control:-ms-input-placeholder {
240
+ color: #999;
241
+ }
242
+ .form-control::-webkit-input-placeholder {
243
+ color: #999;
244
+ }
245
+ .form-control[disabled],
246
+ .form-control[readonly],
247
+ fieldset[disabled] .form-control {
248
+ cursor: not-allowed;
249
+ background-color: #eee;
250
+ opacity: 1;
251
+ }
252
+ textarea.form-control {
253
+ height: auto;
254
+ }
255
+ input[type="search"] {
256
+ -webkit-appearance: none;
257
+ }
258
+ input[type="date"] {
259
+ line-height: 34px;
260
+ }
261
+ .form-group {
262
+ margin-bottom: 15px;
263
+ }
264
+ .radio,
265
+ .checkbox {
266
+ display: block;
267
+ min-height: 20px;
268
+ padding-left: 20px;
269
+ margin-top: 10px;
270
+ margin-bottom: 10px;
271
+ }
272
+ .radio label,
273
+ .checkbox label {
274
+ display: inline;
275
+ font-weight: normal;
276
+ cursor: pointer;
277
+ }
278
+ .radio input[type="radio"],
279
+ .radio-inline input[type="radio"],
280
+ .checkbox input[type="checkbox"],
281
+ .checkbox-inline input[type="checkbox"] {
282
+ float: left;
283
+ margin-left: -20px;
284
+ }
285
+ .radio + .radio,
286
+ .checkbox + .checkbox {
287
+ margin-top: -5px;
288
+ }
289
+ .radio-inline,
290
+ .checkbox-inline {
291
+ display: inline-block;
292
+ padding-left: 20px;
293
+ margin-bottom: 0;
294
+ font-weight: normal;
295
+ vertical-align: middle;
296
+ cursor: pointer;
297
+ }
298
+ .radio-inline + .radio-inline,
299
+ .checkbox-inline + .checkbox-inline {
300
+ margin-top: 0;
301
+ margin-left: 10px;
302
+ }
303
+ input[type="radio"][disabled],
304
+ input[type="checkbox"][disabled],
305
+ .radio[disabled],
306
+ .radio-inline[disabled],
307
+ .checkbox[disabled],
308
+ .checkbox-inline[disabled],
309
+ fieldset[disabled] input[type="radio"],
310
+ fieldset[disabled] input[type="checkbox"],
311
+ fieldset[disabled] .radio,
312
+ fieldset[disabled] .radio-inline,
313
+ fieldset[disabled] .checkbox,
314
+ fieldset[disabled] .checkbox-inline {
315
+ cursor: not-allowed;
316
+ }
317
+ .input-sm {
318
+ height: 30px;
319
+ padding: 5px 10px;
320
+ font-size: 12px;
321
+ line-height: 1.5;
322
+ border-radius: 3px;
323
+ }
324
+ select.input-sm {
325
+ height: 30px;
326
+ line-height: 30px;
327
+ }
328
+ textarea.input-sm,
329
+ select[multiple].input-sm {
330
+ height: auto;
331
+ }
332
+ .input-lg {
333
+ height: 46px;
334
+ padding: 10px 16px;
335
+ font-size: 18px;
336
+ line-height: 1.33;
337
+ border-radius: 6px;
338
+ }
339
+ select.input-lg {
340
+ height: 46px;
341
+ line-height: 46px;
342
+ }
343
+ textarea.input-lg,
344
+ select[multiple].input-lg {
345
+ height: auto;
346
+ }
347
+
348
+
349
+ }
350
+ .btn {
351
+ display: inline-block;
352
+ padding: 6px 12px;
353
+ margin-bottom: 0;
354
+ font-size: 14px;
355
+ font-weight: normal;
356
+ line-height: 1.42857143;
357
+ text-align: center;
358
+ white-space: nowrap;
359
+ vertical-align: middle;
360
+ cursor: pointer;
361
+ -webkit-user-select: none;
362
+ -moz-user-select: none;
363
+ -ms-user-select: none;
364
+ user-select: none;
365
+ background-image: none;
366
+ border: 1px solid transparent;
367
+ border-radius: 4px;
368
+ text-decoration: none;
369
+ }
370
+ .btn:focus,
371
+ .btn:active:focus,
372
+ .btn.active:focus {
373
+ outline: thin dotted;
374
+ outline: 5px auto -webkit-focus-ring-color;
375
+ outline-offset: -2px;
376
+ }
377
+ .btn:hover,
378
+ .btn:focus {
379
+ color: #333;
380
+ text-decoration: none;
381
+ }
382
+ .btn:active,
383
+ .btn.active {
384
+ background-image: none;
385
+ outline: 0;
386
+ -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
387
+ box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
388
+ }
389
+ .btn.disabled,
390
+ .btn[disabled],
391
+ fieldset[disabled] .btn {
392
+ pointer-events: none;
393
+ cursor: not-allowed;
394
+ filter: alpha(opacity=65);
395
+ -webkit-box-shadow: none;
396
+ box-shadow: none;
397
+ opacity: .65;
398
+ }
399
+ .btn-default {
400
+ color: #333;
401
+ background-color: #fff;
402
+ border-color: #ccc;
403
+ }
404
+ .btn-default:hover,
405
+ .btn-default:focus,
406
+ .btn-default:active,
407
+ .btn-default.active,
408
+ .open .dropdown-toggle.btn-default {
409
+ color: #333;
410
+ background-color: #ebebeb;
411
+ border-color: #adadad;
412
+ }
413
+ .btn-default:active,
414
+ .btn-default.active,
415
+ .open .dropdown-toggle.btn-default {
416
+ background-image: none;
417
+ }
418
+ .btn-default.disabled,
419
+ .btn-default[disabled],
420
+ fieldset[disabled] .btn-default,
421
+ .btn-default.disabled:hover,
422
+ .btn-default[disabled]:hover,
423
+ fieldset[disabled] .btn-default:hover,
424
+ .btn-default.disabled:focus,
425
+ .btn-default[disabled]:focus,
426
+ fieldset[disabled] .btn-default:focus,
427
+ .btn-default.disabled:active,
428
+ .btn-default[disabled]:active,
429
+ fieldset[disabled] .btn-default:active,
430
+ .btn-default.disabled.active,
431
+ .btn-default[disabled].active,
432
+ fieldset[disabled] .btn-default.active {
433
+ background-color: #fff;
434
+ border-color: #ccc;
435
+ }
436
+ .btn-default .badge {
437
+ color: #fff;
438
+ background-color: #333;
439
+ }
440
+ .btn-primary {
441
+ color: #fff;
442
+ background-color: #428bca;
443
+ border-color: #357ebd;
444
+ }
445
+ .btn-primary:hover,
446
+ .btn-primary:focus,
447
+ .btn-primary:active,
448
+ .btn-primary.active,
449
+ .open .dropdown-toggle.btn-primary {
450
+ color: #fff;
451
+ background-color: #3276b1;
452
+ border-color: #285e8e;
453
+ }
454
+ .btn-primary:active,
455
+ .btn-primary.active,
456
+ .open .dropdown-toggle.btn-primary {
457
+ background-image: none;
458
+ }
459
+ .btn-primary.disabled,
460
+ .btn-primary[disabled],
461
+ fieldset[disabled] .btn-primary,
462
+ .btn-primary.disabled:hover,
463
+ .btn-primary[disabled]:hover,
464
+ fieldset[disabled] .btn-primary:hover,
465
+ .btn-primary.disabled:focus,
466
+ .btn-primary[disabled]:focus,
467
+ fieldset[disabled] .btn-primary:focus,
468
+ .btn-primary.disabled:active,
469
+ .btn-primary[disabled]:active,
470
+ fieldset[disabled] .btn-primary:active,
471
+ .btn-primary.disabled.active,
472
+ .btn-primary[disabled].active,
473
+ fieldset[disabled] .btn-primary.active {
474
+ background-color: #428bca;
475
+ border-color: #357ebd;
476
+ }
477
+ .btn-primary .badge {
478
+ color: #428bca;
479
+ background-color: #fff;
480
+ }
481
+ .btn-success {
482
+ color: #fff;
483
+ background-color: #5cb85c;
484
+ border-color: #4cae4c;
485
+ }
486
+ .btn-success:hover,
487
+ .btn-success:focus,
488
+ .btn-success:active,
489
+ .btn-success.active,
490
+ .open .dropdown-toggle.btn-success {
491
+ color: #fff;
492
+ background-color: #47a447;
493
+ border-color: #398439;
494
+ }
495
+ .btn-success:active,
496
+ .btn-success.active,
497
+ .open .dropdown-toggle.btn-success {
498
+ background-image: none;
499
+ }
500
+ .btn-success.disabled,
501
+ .btn-success[disabled],
502
+ fieldset[disabled] .btn-success,
503
+ .btn-success.disabled:hover,
504
+ .btn-success[disabled]:hover,
505
+ fieldset[disabled] .btn-success:hover,
506
+ .btn-success.disabled:focus,
507
+ .btn-success[disabled]:focus,
508
+ fieldset[disabled] .btn-success:focus,
509
+ .btn-success.disabled:active,
510
+ .btn-success[disabled]:active,
511
+ fieldset[disabled] .btn-success:active,
512
+ .btn-success.disabled.active,
513
+ .btn-success[disabled].active,
514
+ fieldset[disabled] .btn-success.active {
515
+ background-color: #5cb85c;
516
+ border-color: #4cae4c;
517
+ }
518
+ .btn-success .badge {
519
+ color: #5cb85c;
520
+ background-color: #fff;
521
+ }
522
+ .btn-info {
523
+ color: #fff;
524
+ background-color: #5bc0de;
525
+ border-color: #46b8da;
526
+ }
527
+ .btn-info:hover,
528
+ .btn-info:focus,
529
+ .btn-info:active,
530
+ .btn-info.active,
531
+ .open .dropdown-toggle.btn-info {
532
+ color: #fff;
533
+ background-color: #39b3d7;
534
+ border-color: #269abc;
535
+ }
536
+ .btn-info:active,
537
+ .btn-info.active,
538
+ .open .dropdown-toggle.btn-info {
539
+ background-image: none;
540
+ }
541
+ .btn-info.disabled,
542
+ .btn-info[disabled],
543
+ fieldset[disabled] .btn-info,
544
+ .btn-info.disabled:hover,
545
+ .btn-info[disabled]:hover,
546
+ fieldset[disabled] .btn-info:hover,
547
+ .btn-info.disabled:focus,
548
+ .btn-info[disabled]:focus,
549
+ fieldset[disabled] .btn-info:focus,
550
+ .btn-info.disabled:active,
551
+ .btn-info[disabled]:active,
552
+ fieldset[disabled] .btn-info:active,
553
+ .btn-info.disabled.active,
554
+ .btn-info[disabled].active,
555
+ fieldset[disabled] .btn-info.active {
556
+ background-color: #5bc0de;
557
+ border-color: #46b8da;
558
+ }
559
+ .btn-info .badge {
560
+ color: #5bc0de;
561
+ background-color: #fff;
562
+ }
563
+ .btn-warning {
564
+ color: #fff;
565
+ background-color: #f0ad4e;
566
+ border-color: #eea236;
567
+ }
568
+ .btn-warning:hover,
569
+ .btn-warning:focus,
570
+ .btn-warning:active,
571
+ .btn-warning.active,
572
+ .open .dropdown-toggle.btn-warning {
573
+ color: #fff;
574
+ background-color: #ed9c28;
575
+ border-color: #d58512;
576
+ }
577
+ .btn-warning:active,
578
+ .btn-warning.active,
579
+ .open .dropdown-toggle.btn-warning {
580
+ background-image: none;
581
+ }
582
+ .btn-warning.disabled,
583
+ .btn-warning[disabled],
584
+ fieldset[disabled] .btn-warning,
585
+ .btn-warning.disabled:hover,
586
+ .btn-warning[disabled]:hover,
587
+ fieldset[disabled] .btn-warning:hover,
588
+ .btn-warning.disabled:focus,
589
+ .btn-warning[disabled]:focus,
590
+ fieldset[disabled] .btn-warning:focus,
591
+ .btn-warning.disabled:active,
592
+ .btn-warning[disabled]:active,
593
+ fieldset[disabled] .btn-warning:active,
594
+ .btn-warning.disabled.active,
595
+ .btn-warning[disabled].active,
596
+ fieldset[disabled] .btn-warning.active {
597
+ background-color: #f0ad4e;
598
+ border-color: #eea236;
599
+ }
600
+ .btn-warning .badge {
601
+ color: #f0ad4e;
602
+ background-color: #fff;
603
+ }
604
+ .btn-danger {
605
+ color: #fff;
606
+ background-color: #d9534f;
607
+ border-color: #d43f3a;
608
+ }
609
+ .btn-danger:hover,
610
+ .btn-danger:focus,
611
+ .btn-danger:active,
612
+ .btn-danger.active,
613
+ .open .dropdown-toggle.btn-danger {
614
+ color: #fff;
615
+ background-color: #d2322d;
616
+ border-color: #ac2925;
617
+ }
618
+ .btn-danger:active,
619
+ .btn-danger.active,
620
+ .open .dropdown-toggle.btn-danger {
621
+ background-image: none;
622
+ }
623
+ .btn-danger.disabled,
624
+ .btn-danger[disabled],
625
+ fieldset[disabled] .btn-danger,
626
+ .btn-danger.disabled:hover,
627
+ .btn-danger[disabled]:hover,
628
+ fieldset[disabled] .btn-danger:hover,
629
+ .btn-danger.disabled:focus,
630
+ .btn-danger[disabled]:focus,
631
+ fieldset[disabled] .btn-danger:focus,
632
+ .btn-danger.disabled:active,
633
+ .btn-danger[disabled]:active,
634
+ fieldset[disabled] .btn-danger:active,
635
+ .btn-danger.disabled.active,
636
+ .btn-danger[disabled].active,
637
+ fieldset[disabled] .btn-danger.active {
638
+ background-color: #d9534f;
639
+ border-color: #d43f3a;
640
+ }
641
+ .btn-danger .badge {
642
+ color: #d9534f;
643
+ background-color: #fff;
644
+ }
645
+ .btn-link {
646
+ font-weight: normal;
647
+ color: #428bca;
648
+ cursor: pointer;
649
+ border-radius: 0;
650
+ }
651
+ .btn-link,
652
+ .btn-link:active,
653
+ .btn-link[disabled],
654
+ fieldset[disabled] .btn-link {
655
+ background-color: transparent;
656
+ -webkit-box-shadow: none;
657
+ box-shadow: none;
658
+ }
659
+ .btn-link,
660
+ .btn-link:hover,
661
+ .btn-link:focus,
662
+ .btn-link:active {
663
+ border-color: transparent;
664
+ }
665
+ .btn-link:hover,
666
+ .btn-link:focus {
667
+ color: #2a6496;
668
+ text-decoration: underline;
669
+ background-color: transparent;
670
+ }
671
+ .btn-link[disabled]:hover,
672
+ fieldset[disabled] .btn-link:hover,
673
+ .btn-link[disabled]:focus,
674
+ fieldset[disabled] .btn-link:focus {
675
+ color: #999;
676
+ text-decoration: none;
677
+ }
678
+ .btn-lg,
679
+ .btn-group-lg > .btn {
680
+ padding: 10px 16px;
681
+ font-size: 18px;
682
+ line-height: 1.33;
683
+ border-radius: 6px;
684
+ text-decoration: none;
685
+ }
686
+ .btn-sm,
687
+ .btn-group-sm > .btn {
688
+ padding: 5px 10px;
689
+ font-size: 12px;
690
+ line-height: 1.5;
691
+ border-radius: 3px;
692
+ text-decoration: none;
693
+ }
694
+ .btn-xs,
695
+ .btn-group-xs > .btn {
696
+ padding: 1px 5px;
697
+ font-size: 12px;
698
+ line-height: 1.5;
699
+ border-radius: 3px;
700
+ }
701
+ .btn-block {
702
+ display: block;
703
+ width: 100%;
704
+ padding-right: 0;
705
+ padding-left: 0;
706
+ }
707
+ .btn-block + .btn-block {
708
+ margin-top: 5px;
709
+ }
710
+ input[type="submit"].btn-block,
711
+ input[type="reset"].btn-block,
712
+ input[type="button"].btn-block {
713
+ width: 100%;
714
+ }
715
+
716
+ .text-left {
717
+ text-align: left;
718
+ }
719
+ .text-right {
720
+ text-align: right;
721
+ }
722
+ .text-center {
723
+ text-align: center;
724
+ }
725
+
726
+
727
+ .table {
728
+ width: 100%;
729
+ margin-bottom: 20px;
730
+ }
731
+ .table > thead > tr > th,
732
+ .table > tbody > tr > th,
733
+ .table > tfoot > tr > th,
734
+ .table > thead > tr > td,
735
+ .table > tbody > tr > td,
736
+ .table > tfoot > tr > td {
737
+ padding: 8px;
738
+ line-height: 1.42857143;
739
+ vertical-align: top;
740
+ border-top: 1px solid #ddd;
741
+ }
742
+ .table > thead > tr > th {
743
+ vertical-align: bottom;
744
+ border-bottom: 0px solid #ddd;
745
+ text-align: left;
746
+ }
747
+ .table > caption + thead > tr:first-child > th,
748
+ .table > colgroup + thead > tr:first-child > th,
749
+ .table > thead:first-child > tr:first-child > th,
750
+ .table > caption + thead > tr:first-child > td,
751
+ .table > colgroup + thead > tr:first-child > td,
752
+ .table > thead:first-child > tr:first-child > td {
753
+ border-top: 0;
754
+ }
755
+ .table > tbody + tbody {
756
+ border-top: 2px solid #ddd;
757
+ }
758
+ .table .table {
759
+ background-color: #fff;
760
+ }
761
+ .table-condensed > thead > tr > th,
762
+ .table-condensed > tbody > tr > th,
763
+ .table-condensed > tfoot > tr > th,
764
+ .table-condensed > thead > tr > td,
765
+ .table-condensed > tbody > tr > td,
766
+ .table-condensed > tfoot > tr > td {
767
+ padding: 5px;
768
+ }
769
+
770
+
771
+ .pull-right {
772
+ float: right !important;
773
+ }
774
+ .pull-left {
775
+ float: left !important;
776
+ }
777
+ .clearfix {
778
+ clear: both;
779
+ }
img/icon.png ADDED
Binary file
inc/common.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MailchimpMailmunchHelpers {
3
+ function __construct() {
4
+ }
5
+
6
+ function getEmailPassword() {
7
+ $mc_mm_email = get_option("mc_mm_user_email");
8
+ $mc_mm_password = get_option("mc_mm_user_password");
9
+
10
+ if (empty($mc_mm_email)) {
11
+ $current_user = wp_get_current_user();
12
+ update_option("mc_mm_user_email", $current_user->user_email);
13
+ }
14
+
15
+ if (empty($mc_mm_password)) {
16
+ update_option("mc_mm_user_password", uniqid());
17
+ }
18
+
19
+ $mc_mm_email = get_option("mc_mm_user_email");
20
+ $mc_mm_password = get_option("mc_mm_user_password");
21
+
22
+ return array('email' => $mc_mm_email, 'password' => $mc_mm_password);
23
+ }
24
+
25
+ function getSite($sites, $site_id) {
26
+ foreach ($sites as $s) {
27
+ if ($s->id == intval($site_id)) {
28
+ $site = $s;
29
+ break;
30
+ }
31
+ }
32
+
33
+ return $site;
34
+ }
35
+
36
+ function createAndGetSites($mm) {
37
+ $site_url = home_url();
38
+ $site_name = get_bloginfo();
39
+
40
+ if (!$mm->hasSite()) {
41
+ $mm->createSite($site_name, $site_url);
42
+ }
43
+ $request = $mm->sites();
44
+ if ($request['response']['code'] == 200){
45
+ $sites = $request['body'];
46
+
47
+ return json_decode($sites);
48
+ }
49
+ else {
50
+ return array();
51
+ }
52
+ }
53
+
54
+ function createAndGetGuestSites($mm) {
55
+ // This is for GUEST users. Do NOT collect any user data.
56
+ $site_url = "";
57
+ $site_name = "WordPress";
58
+
59
+ if (!$mm->hasSite()) {
60
+ $mm->createSite($site_name, $site_url);
61
+ }
62
+ $request = $mm->sites();
63
+ if ($request['response']['code'] == 200){
64
+ $sites = $request['body'];
65
+
66
+ return json_decode($sites);
67
+ }
68
+ else {
69
+ return array();
70
+ }
71
+ }
72
+ }
73
+ ?>
inc/mailmunchapi.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MailchimpMailmunchApi {
3
+ protected $base_url = '';
4
+ protected $email = '';
5
+ protected $password = '';
6
+ protected $headers = array('Accept' => 'application/json');
7
+ protected $requestType = 'get';
8
+
9
+ function __construct($email, $password, $url) {
10
+ $this->email = $email;
11
+ $this->password = $password;
12
+ $this->base_url = $url;
13
+ }
14
+
15
+ function sites() {
16
+ $this->requestType = 'get';
17
+ return $this->ping('/sites');
18
+ }
19
+
20
+ function widgets($site_id) {
21
+ $this->requestType = 'get';
22
+ return $this->ping('/sites/'.$site_id.'/widgets');
23
+ }
24
+
25
+ function getWidgetsHtml($site_id) {
26
+ $this->requestType = 'get';
27
+ return $this->ping('/sites/'.$site_id.'/widgets/wordpress?plugin=mailchimp');
28
+ }
29
+
30
+ function deleteWidget($site_id, $widget_id) {
31
+ $this->requestType = 'post';
32
+ return $this->ping('/sites/'.$site_id.'/widgets/'.$widget_id.'/delete');
33
+ }
34
+
35
+ function importWidgets($new_user_email, $new_user_password) {
36
+ $this->requestType = 'post';
37
+ return $this->ping('/wordpress/import_widgets', array(
38
+ 'external_id' => get_option("mc_mm_wordpress_instance_id"),
39
+ 'new_user_email' => $new_user_email,
40
+ 'new_user_password' => $new_user_password,
41
+ 'site_url' => home_url(),
42
+ 'site_name' => get_bloginfo()
43
+ ));
44
+ }
45
+
46
+ function hasSite() {
47
+ $request = $this->sites();
48
+ $sites = $request['body'];
49
+ $result = json_decode($sites);
50
+
51
+ return (sizeof($result) > 0);
52
+ }
53
+
54
+ function createSite($sitename, $domain) {
55
+ $this->requestType = 'post';
56
+ return $this->ping('/sites', array(
57
+ 'site' => array(
58
+ 'name' => $sitename,
59
+ 'domain' => $domain,
60
+ 'wordpress' => true,
61
+ 'external_id' => get_option("mc_mm_wordpress_instance_id")
62
+ )
63
+ ));
64
+ }
65
+
66
+ function updateSite($sitename, $domain) {
67
+ $this->requestType = 'post';
68
+ return $this->ping('/wordpress/update_site', array(
69
+ 'external_id' => get_option("mc_mm_wordpress_instance_id"),
70
+ 'site' => array(
71
+ 'name' => $sitename,
72
+ 'domain' => $domain
73
+ )
74
+ ));
75
+ }
76
+
77
+ function createGuestUser() {
78
+ $this->requestType = 'post';
79
+ return $this->ping('/users', array(
80
+ 'user' => array(
81
+ 'email' => $this->email,
82
+ 'password' => $this->password,
83
+ 'guest_user' => true,
84
+ 'referral' => "mailchimp-wordpress-plugin"
85
+ )
86
+ ), true);
87
+ }
88
+
89
+ function signUp() {
90
+ $this->requestType = 'post';
91
+ return $this->ping('/users', array(
92
+ 'user' => array(
93
+ 'email' => $this->email,
94
+ 'password' => $this->password,
95
+ 'referral' => "mailchimp-wordpress-plugin"
96
+ )
97
+ ), true);
98
+ }
99
+
100
+ function updateGuest($new_email) {
101
+ $this->requestType = 'post';
102
+ return $this->ping('/wordpress/update_guest', array(
103
+ 'user' => array(
104
+ 'email' => $new_email,
105
+ 'guest_user' => false
106
+ )
107
+ ), true);
108
+ }
109
+
110
+ function signIn() {
111
+ $this->requestType = 'post';
112
+ return $this->ping('/users/sign_in');
113
+ }
114
+
115
+ function validPassword() {
116
+ $this->requestType = 'get';
117
+ $request = $this->ping('/sites');
118
+
119
+ if ($request['response']['code'] == 200){
120
+ return true;
121
+ }
122
+ else {
123
+ return false;
124
+ }
125
+ }
126
+
127
+ function isNewUser($email) {
128
+ if (empty($email)) {
129
+ $email = $this->email;
130
+ }
131
+ $this->requestType = 'get';
132
+ $result = $this->ping('/users/exists?user[email]='. $email, array(), true);
133
+ return $result['body'] == 'false';
134
+ }
135
+
136
+ function ping($path, $options=array(), $skipAuth=false) {
137
+ $auth = array('auth' => array($this->email, $this->password));
138
+ $type = $this->requestType;
139
+ $url = $this->base_url. $path;
140
+ $args = array(
141
+ 'headers' => array_merge($this->headers, array(
142
+ 'Authorization' => 'Basic ' . base64_encode( $this->email . ':' . $this->password )
143
+ )
144
+ ),
145
+ 'timeout' => 120
146
+ );
147
+
148
+ if ($type != 'post') {
149
+ $request = wp_remote_get($url, $args);
150
+ }
151
+ else {
152
+ $args = array_merge($args, array('method' => 'POST', 'body' => $options));
153
+ $request = wp_remote_post($url, $args);
154
+ }
155
+ return $request;
156
+ }
157
+ }
158
+ ?>
js/admin.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery.unparam = function (value) {
2
+ var
3
+ // Object that holds names => values.
4
+ params = {},
5
+ // Get query string pieces (separated by &)
6
+ pieces = value.split('&'),
7
+ // Temporary variables used in loop.
8
+ pair, i, l;
9
+
10
+ // Loop through query string pieces and assign params.
11
+ for (i = 0, l = pieces.length; i < l; i++) {
12
+ pair = pieces[i].split('=', 2);
13
+ // Repeated parameters with the same name are overwritten. Parameters
14
+ // with no value get set to boolean true.
15
+ params[decodeURIComponent(pair[0])] = (pair.length == 2 ?
16
+ decodeURIComponent(pair[1].replace(/\+/g, ' ')) : true);
17
+ }
18
+
19
+ return params;
20
+ };
21
+
22
+ window.onmessage = function (e) {
23
+ if (e.data === 'refresh') {
24
+ top.location.reload();
25
+ }
26
+ };
27
+
28
+ function showSignInForm() {
29
+ document.getElementById("sign-up-form").style.display = 'none';
30
+ document.getElementById("sign-in-form").style.display = 'block';
31
+ }
32
+
33
+ function showSignUpForm() {
34
+ document.getElementById("sign-in-form").style.display = 'none';
35
+ document.getElementById("sign-up-form").style.display = 'block';
36
+ }
37
+
38
+ function showSignupBox() {
39
+ document.getElementById('why-account').style.display = 'none';
40
+ tb_show("Create Account","#TB_inline?width=550&height=450&inlineId=signup-signin-box",null);
41
+ return false;
42
+ }
43
+
44
+ function showWhyAccount() {
45
+ document.getElementById('why-account').style.display = 'block';
46
+ tb_show("Create Account","#TB_inline?width=550&height=500&inlineId=signup-signin-box",null);
47
+ }
mailchimp-mailmunch.php ADDED
@@ -0,0 +1,418 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: MailChimp Forms by MailMunch
4
+ Plugin URI: http://connect.mailchimp.com/integrations/mailmunch-email-list-builder
5
+ Description: The MailChimp plugin allows you to quickly and easily add signup forms for your MailChimp lists. Popup, Embedded, Top Bar and a variety of different options available.
6
+ Version: 1.0.1
7
+ Author: MailMunch
8
+ Author URI: http://www.mailmunch.co
9
+ License: GPL2
10
+ */
11
+
12
+ require_once( plugin_dir_path( __FILE__ ) . 'inc/mailmunchapi.php' );
13
+ require_once( plugin_dir_path( __FILE__ ) . 'inc/common.php' );
14
+
15
+ define( 'MAILCHIMP_MAILMUNCH_SLUG', "mailchimp-mailmunch");
16
+ define( 'MAILCHIMP_MAILMUNCH_VER', "1.0.1");
17
+ define( 'MAILCHIMP_MAILMUNCH_URL', "www.mailmunch.co");
18
+
19
+ // Create unique WordPress instance ID
20
+ if (get_option("mc_mm_wordpress_instance_id") == "") {
21
+ update_option("mc_mm_wordpress_instance_id", uniqid());
22
+ }
23
+
24
+ // Adding Admin Menu
25
+ add_action( 'admin_menu', 'mc_mm_register_page' );
26
+
27
+ function mc_mm_register_page(){
28
+ $menu_page = add_menu_page( 'MailChimp Settings', 'MailChimp', 'manage_options', MAILCHIMP_MAILMUNCH_SLUG, 'mc_mm_setup', plugins_url( 'img/icon.png', __FILE__ ), 103.786 );
29
+ // If successful, load admin assets only on that page.
30
+ if ($menu_page) add_action('load-' . $menu_page, 'mc_mm_load_plugin_assets');
31
+ }
32
+
33
+ function mc_mm_load_plugin_assets() {
34
+ add_action( 'admin_enqueue_scripts', 'mc_mm_enqueue_admin_styles' );
35
+ add_action( 'admin_enqueue_scripts', 'mc_mm_enqueue_admin_scripts' );
36
+ }
37
+
38
+ function mc_mm_enqueue_admin_styles() {
39
+ wp_enqueue_style(MAILCHIMP_MAILMUNCH_SLUG . '-admin-styles', plugins_url( 'css/admin.css', __FILE__ ), array(), MAILCHIMP_MAILMUNCH_VER );
40
+ }
41
+
42
+ function mc_mm_enqueue_admin_scripts() {
43
+ wp_enqueue_script(MAILCHIMP_MAILMUNCH_SLUG . '-admin-script', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), MAILCHIMP_MAILMUNCH_VER );
44
+ }
45
+
46
+ // Adding MailMunch Asset Files (JS + CSS)
47
+ function mc_mm_load_asset_code() {
48
+ $mc_mm_data = unserialize(get_option("mc_mm_data"));
49
+ if (!$mc_mm_data["script_src"]) return;
50
+
51
+ if (is_single() || is_page()) {
52
+ $post = get_post();
53
+ $post_data = array("ID" => $post->ID, "post_name" => $post->post_name, "post_title" => $post->post_title, "post_type" => $post->post_type, "post_author" => $post->post_author, "post_status" => $post->post_status);
54
+ }
55
+
56
+ echo "<script type='text/javascript'>";
57
+ echo "var _mmunch = {'front': false, 'page': false, 'post': false, 'category': false, 'author': false, 'search': false, 'attachment': false, 'tag': false};";
58
+ if (is_front_page() || is_home()) { echo "_mmunch['front'] = true;"; }
59
+ if (is_page()) { echo "_mmunch['page'] = true; _mmunch['pageData'] = ".json_encode($post_data).";"; }
60
+ if (is_single()) { echo "_mmunch['post'] = true; _mmunch['postData'] = ".json_encode($post_data)."; _mmunch['postCategories'] = ".json_encode(get_the_category())."; _mmunch['postTags'] = ".json_encode(get_the_tags())."; _mmunch['postAuthor'] = ".json_encode(array("name" => get_the_author_meta("display_name"), "ID" => get_the_author_meta("ID"))).";"; }
61
+ if (is_category()) { echo "_mmunch['category'] = true; _mmunch['categoryData'] = ".json_encode(get_category(get_query_var('cat'))).";"; }
62
+ if (is_search()) { echo "_mmunch['search'] = true;"; }
63
+ if (is_author()) { echo "_mmunch['author'] = true;"; }
64
+ if (is_tag()) { echo "_mmunch['tag'] = true;"; }
65
+ if (is_attachment()) { echo "_mmunch['attachment'] = true;"; }
66
+
67
+ echo "(function(){ setTimeout(function(){ var d = document, f = d.getElementsByTagName('script')[0], s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = '".$mc_mm_data["script_src"]."'; f.parentNode.insertBefore(s, f); }, 1); })();";
68
+ echo "</script>";
69
+ }
70
+
71
+ add_action('init', 'mc_mm_assets');
72
+
73
+ function mc_mm_assets() {
74
+ $mc_mm_data = unserialize(get_option("mc_mm_data"));
75
+ if (count($mc_mm_data) == 0) return;
76
+
77
+ if (function_exists('wp_footer')) {
78
+ if (!$_POST['mc_mm_data']) {
79
+ add_action( 'wp_footer', 'mc_mm_load_asset_code' );
80
+ }
81
+ }
82
+ elseif (function_exists('wp_head')) {
83
+ if (!$_POST['mc_mm_data']) {
84
+ add_action( 'wp_head', 'mc_mm_load_asset_code' );
85
+ }
86
+ }
87
+ }
88
+
89
+ function mc_mm_add_post_containers($content) {
90
+ if (is_single() || is_page()) {
91
+ $content = mc_mm_insert_form_after_paragraph("<div class='mailmunch-forms-in-post-middle' style='display: none !important;'></div>", "middle", $content);
92
+ $content = "<div class='mailmunch-forms-before-post' style='display: none !important;'></div>" . $content . "<div class='mailmunch-forms-after-post' style='display: none !important;'></div>";
93
+ }
94
+
95
+ return $content;
96
+ }
97
+
98
+ function mc_mm_insert_form_after_paragraph($insertion, $paragraph_id, $content) {
99
+ $closing_p = '</p>';
100
+ $paragraphs = explode($closing_p, $content);
101
+ if ($paragraph_id == "middle") {
102
+ $paragraph_id = round(sizeof($paragraphs)/2);
103
+ }
104
+
105
+ foreach ($paragraphs as $index => $paragraph) {
106
+ if (trim($paragraph)) {
107
+ $paragraphs[$index] .= $closing_p;
108
+ }
109
+
110
+ if ($paragraph_id == $index + 1) {
111
+ $paragraphs[$index] .= $insertion;
112
+ }
113
+ }
114
+ return implode('', $paragraphs);
115
+ }
116
+
117
+ add_filter( 'the_content', 'mc_mm_add_post_containers' );
118
+
119
+ function mc_mm_shortcode_form($atts) {
120
+ return "<div class='mailmunch-forms-short-code mailmunch-forms-widget-".$atts['id']."' style='display: none !important;'></div>";
121
+ }
122
+
123
+ add_shortcode('mailmunch-form', 'mc_mm_shortcode_form');
124
+
125
+ function mc_mm_setup() {
126
+ $mm_helpers = new MailchimpMailmunchHelpers();
127
+ $mc_mm_data = unserialize(get_option("mc_mm_data"));
128
+ $mc_mm_data["site_url"] = home_url();
129
+ $mc_mm_data["site_name"] = get_bloginfo();
130
+ update_option("mc_mm_data", serialize($mc_mm_data));
131
+
132
+ // This is a POST request. Let's save data first.
133
+ if ($_POST) {
134
+ $post_data = $_POST["mc_mm_data"];
135
+ $post_action = $_POST["action"];
136
+
137
+ if ($post_action == "save_settings") {
138
+
139
+ $mc_mm_data = array_merge(unserialize(get_option('mc_mm_data')), $post_data);
140
+ update_option("mc_mm_data", serialize($mc_mm_data));
141
+
142
+ } else if ($post_action == "sign_in") {
143
+
144
+ $mm = new MailchimpMailmunchApi($_POST["email"], $_POST["password"], "http://".MAILCHIMP_MAILMUNCH_URL);
145
+ if ($mm->validPassword()) {
146
+ if (get_option("mc_mm_guest_user")) {
147
+ // User exists and credentials are correct
148
+ // Let's move optin forms from guest user to real user
149
+ $account_info = $mm_helpers->getEmailPassword();
150
+ $mc_mm_email = $account_info['email'];
151
+ $mc_mm_password = $account_info['password'];
152
+ $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
153
+ $result = $mm->importWidgets($_POST["email"], $_POST["password"]);
154
+ }
155
+
156
+ update_option("mc_mm_user_email", $_POST["email"]);
157
+ update_option("mc_mm_user_password", $_POST["password"]);
158
+ delete_option("mc_mm_guest_user");
159
+ }
160
+
161
+ } else if ($post_action == "sign_up") {
162
+
163
+ if (empty($_POST["email"])) {
164
+ $invalid_email = true;
165
+ } else {
166
+ $account_info = $mm_helpers->getEmailPassword();
167
+ $mc_mm_email = $account_info['email'];
168
+ $mc_mm_password = $account_info['password'];
169
+
170
+ $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
171
+ if ($mm->isNewUser($_POST['email'])) {
172
+ $update_result = $mm->updateGuest($_POST['email']);
173
+ $result = json_decode($update_result['body']);
174
+ update_option("mc_mm_user_email", $result->email);
175
+ if (!$result->guest_user) { delete_option("mc_mm_guest_user"); }
176
+ $mc_mm_email = $result->email;
177
+
178
+ // We have update the guest with real email address, let's create a site now
179
+ $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
180
+
181
+ $update_result = $mm->updateSite($mc_mm_data["site_name"], $mc_mm_data["site_url"]);
182
+ $result = json_decode($update_result['body']);
183
+ $mc_mm_data = unserialize(get_option("mc_mm_data"));
184
+ $mc_mm_data["site_url"] = $result->domain;
185
+ $mc_mm_data["site_name"] = $result->name;
186
+ update_option("mc_mm_data", serialize($mc_mm_data));
187
+ } else {
188
+ $user_exists = true;
189
+ }
190
+ }
191
+
192
+ } else if ($post_action == "unlink_account") {
193
+
194
+ $mc_mm_data = array();
195
+ $mc_mm_data["site_url"] = home_url();
196
+ $mc_mm_data["site_name"] = get_bloginfo();
197
+ update_option("mc_mm_data", serialize($mc_mm_data));
198
+ delete_option("mc_mm_user_email");
199
+ delete_option("mc_mm_user_password");
200
+
201
+ } else if ($post_action == "delete_widget") {
202
+
203
+ if ($_POST["site_id"] && $_POST["widget_id"]) {
204
+ $account_info = $mm_helpers->getEmailPassword();
205
+ $mc_mm_email = $account_info['email'];
206
+ $mc_mm_password = $account_info['password'];
207
+ $mm = new MailchimpMailmunchApi($account_info['email'], $account_info["password"], "http://".MAILCHIMP_MAILMUNCH_URL);
208
+ $request = $mm->deleteWidget($_POST["site_id"], $_POST["widget_id"]);
209
+ }
210
+
211
+ }
212
+ }
213
+
214
+ // If the user does not exists, create a GUEST user
215
+ if (get_option("mc_mm_user_email") == "") {
216
+ $mc_mm_email = "guest_".uniqid()."@mailmunch.co";
217
+ $mc_mm_password = uniqid();
218
+ $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
219
+ $mm->createGuestUser();
220
+ update_option("mc_mm_user_email", $mc_mm_email);
221
+ update_option("mc_mm_user_password", $mc_mm_password);
222
+ update_option("mc_mm_guest_user", true);
223
+ }
224
+
225
+ // If we already have the user's email stored, let's create the API instance
226
+ // If we don't have it yet, make sure NOT to phone home any user data
227
+ if (get_option("mc_mm_user_email") != "") {
228
+ $account_info = $mm_helpers->getEmailPassword();
229
+ $mc_mm_email = $account_info['email'];
230
+ $mc_mm_password = $account_info['password'];
231
+
232
+ $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
233
+ if (!$mm->validPassword()) {
234
+ // Invalid user, create a GUEST user
235
+ $mc_mm_email = "guest_".uniqid()."@mailmunch.co";
236
+ $mc_mm_password = uniqid();
237
+ $mm = new MailchimpMailmunchApi($mc_mm_email, $mc_mm_password, "http://".MAILCHIMP_MAILMUNCH_URL);
238
+ $mm->createGuestUser();
239
+ update_option("mc_mm_user_email", $mc_mm_email);
240
+ update_option("mc_mm_user_password", $mc_mm_password);
241
+ update_option("mc_mm_guest_user", true);
242
+ }
243
+ }
244
+
245
+ $mc_mm_guest_user = get_option("mc_mm_guest_user");
246
+
247
+
248
+ if ($mc_mm_guest_user) {
249
+ // This is a Guest USER. Do not collect any user data.
250
+ $sites = $mm_helpers->createAndGetGuestSites($mm);
251
+ } else {
252
+ $sites = $mm_helpers->createAndGetSites($mm);
253
+ }
254
+
255
+ if ($mc_mm_data["site_id"]) {
256
+ // If there's a site already chosen, we need to get and save it's script_src in WordPress
257
+ $site = $mm_helpers->getSite($sites, $mc_mm_data["site_id"]);
258
+
259
+ if ($site) {
260
+ $mc_mm_data = array_merge(unserialize(get_option('mc_mm_data')), array("script_src" => $site->javascript_url));
261
+ update_option("mc_mm_data", serialize($mc_mm_data));
262
+ } else {
263
+ // The chosen site does not exist in the mailmunch account any more, remove it locally
264
+ $site_not_found = true;
265
+ $mc_mm_data = unserialize(get_option('mc_mm_data'));
266
+ unset($mc_mm_data["site_id"]);
267
+ unset($mc_mm_data["script_src"]);
268
+ update_option("mc_mm_data", serialize($mc_mm_data));
269
+ }
270
+ }
271
+
272
+ if (!$mc_mm_data["site_id"]) {
273
+ // If there's NO chosen site yet
274
+
275
+ if (sizeof($sites) == 1 && ($sites[0]->name == get_bloginfo() || $sites[0]->name == "WordPress")) {
276
+ // If this mailmunch account only has 1 site and its name matches this WordPress blogs
277
+
278
+ $site = $sites[0];
279
+
280
+ if ($site) {
281
+ $mc_mm_data = array_merge(unserialize(get_option('mc_mm_data')), array("site_id" => $site->id, "script_src" => $site->javascript_url));
282
+ update_option("mc_mm_data", serialize($mc_mm_data));
283
+ }
284
+ } else if (sizeof($sites) > 0) {
285
+ // If this mailmunch account has one or more sites, let the user choose one
286
+ ?>
287
+ <div class="container">
288
+ <div class="page-header">
289
+ <h1>Choose Your Site</h1>
290
+ </div>
291
+
292
+ <p>Choose the site that you would like to link with your WordPress.</p>
293
+
294
+ <form action="" method="POST">
295
+ <div class="form-group">
296
+ <input type="hidden" name="action" value="save_settings" />
297
+
298
+ <select name="mc_mm_data[site_id]">
299
+ <?php foreach ($sites as $site) { ?>
300
+ <option value="<?php echo $site->id ?>"><?php echo $site->name ?></option>
301
+ <?php } ?>
302
+ </select>
303
+ </div>
304
+
305
+ <div class="form-group">
306
+ <input type="submit" value="Save Settings" />
307
+ </div>
308
+ </form>
309
+ </div>
310
+ <?php
311
+ return;
312
+ }
313
+ }
314
+
315
+ $request = $mm->getWidgetsHtml($mc_mm_data["site_id"]);
316
+ $widgets = $request['body'];
317
+ $widgets = str_replace("{{EMAIL}}", $mc_mm_email, $widgets);
318
+ $widgets = str_replace("{{PASSWORD}}", $mc_mm_password, $widgets);
319
+ echo $widgets;
320
+
321
+ if ($mc_mm_guest_user) {
322
+ $current_user = wp_get_current_user();
323
+ ?>
324
+
325
+ <?php add_thickbox(); ?>
326
+
327
+ <a id="signup-box-btn" href="#TB_inline?width=450&height=450&inlineId=signup-signin-box" title="Create Account" class="thickbox" style="display: none;">Sign Up</a>
328
+
329
+ <div id="signup-signin-box" style="display:none;">
330
+ <div id="sign-up-form" class="<?php if (!$_POST || ($_POST["action"] != "sign_in" && $_POST["action"] != "unlink_account")) { ?> active<?php } ?>">
331
+ <div class="form-container">
332
+ <p style="margin-bottom: 0px;">To activate your MailChimp forms, we will now create your account on MailMunch (<a onclick="showWhyAccount();" id="why-account-btn">Why?</a>).</p>
333
+
334
+ <div id="why-account" class="alert alert-warning" style="display: none;">
335
+ <h4>Why do I need a MailMunch account?</h4>
336
+
337
+ <p>
338
+ MailMunch is a not just a WordPress plugin but a standalone service. An account is required to identify your WordPress and serve your MailChimp forms.
339
+ </p>
340
+ </div>
341
+
342
+ <?php if ($user_exists) { ?>
343
+ <div id="invalid-alert" class="alert alert-danger" role="alert">Account with this email already exists. Please sign in using your password.</div>
344
+ <?php } else if ($invalid_email) { ?>
345
+ <div id="invalid-alert" class="alert alert-danger" role="alert">Invalid email. Please enter a valid email below.</div>
346
+ <?php } ?>
347
+
348
+ <form action="" method="POST">
349
+ <input type="hidden" name="action" value="sign_up" />
350
+
351
+ <div class="form-group">
352
+ <label>Wordpress Name</label>
353
+ <input type="text" placeholder="Site Name" name="site_name" value="<?php echo $mc_mm_data["site_name"] ?>" class="form-control">
354
+ </div>
355
+
356
+ <div class="form-group">
357
+ <label>Wordpress URL</label>
358
+ <input type="text" placeholder="Site URL" name="site_url" value="<?php echo $mc_mm_data["site_url"] ?>" class="form-control">
359
+ </div>
360
+
361
+ <div class="form-group">
362
+ <label>Email Address</label>
363
+ <input type="email" placeholder="Email Address" name="email" value="<?php echo $current_user->user_email ?>" class="form-control">
364
+ </div>
365
+
366
+ <div class="form-group">
367
+ <input type="submit" value="Sign Up &raquo;" class="btn btn-success btn-lg" />
368
+ </div>
369
+ </form>
370
+ </div>
371
+
372
+ <p>Already have an account? <a id="show-sign-in" onclick="showSignInForm();">Sign In</a></p>
373
+ </div>
374
+
375
+ <div id="sign-in-form" class="<?php if ($_POST && ($_POST["action"] == "sign_in" || $_POST["action"] == "unlink_account")) { ?> active<?php } ?>">
376
+ <p>Sign in using your email and password below.</p>
377
+
378
+ <?php if ($_POST && $_POST["action"] == "sign_in") { ?>
379
+ <div id="invalid-alert" class="alert alert-danger" role="alert">Invalid Email or Password. Please try again.</div>
380
+ <?php } ?>
381
+
382
+ <div class="form-container">
383
+ <form action="" method="POST">
384
+ <input type="hidden" name="action" value="sign_in" />
385
+
386
+ <div class="form-group">
387
+ <label>Email Address</label>
388
+ <input type="email" placeholder="Email Address" name="email" class="form-control" value="<?php echo $_POST["email"] ?>" />
389
+ </div>
390
+ <div class="form-group">
391
+ <label>Password</label>
392
+ <input type="password" placeholder="Password" name="password" class="form-control" />
393
+ </div>
394
+
395
+ <div class="form-group">
396
+ <input type="submit" value="Sign In &raquo;" class="btn btn-success btn-lg" />
397
+ </div>
398
+ </form>
399
+ </div>
400
+
401
+ <p>Forgot your password? <a href="http://<?php echo MAILCHIMP_MAILMUNCH_URL; ?>/users/password/new" target="_blank">Click here</a> to retrieve it.</p>
402
+ <p>Don't have an account? <a id="show-sign-up" onclick="showSignUpForm();">Sign Up</a></p>
403
+ </div>
404
+ </div>
405
+
406
+ <?php
407
+ if ($_POST) {
408
+ ?>
409
+ <script>
410
+ jQuery(window).load(function() {
411
+ showSignupBox();
412
+ });
413
+ </script>
414
+ <?php
415
+ }
416
+ }
417
+ }
418
+ ?>
readme.txt ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === MailChimp Forms by MailMunch ===
2
+ Contributors: mailmunch
3
+ Tags: mailchimp, MailChimp form, MailChimp Newsletter form, MailChimp plugin, newsletter, newsletter form, newsletter form plugin, optin form, form, signup, signup forms, signup form, widget, email form, leads
4
+ Requires at least: 3.0.1
5
+ Tested up to: 4.0
6
+ Stable tag: 1.0.1
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ MailChimp Forms by MailMunch allows you to painlessly add MailChimp sign up forms to your WordPress site as a popup, embedded widget or sticky top bar.
11
+
12
+ == Description ==
13
+
14
+ > MailChimp Forms by MailMunch allows you to painlessly add MailChimp sign up forms to your WordPress site. The form captures the lead and sends it to specific MailChimp lists automatically. You can set it to no op-in, opt-in, or double opt-in. You can add forms to posts, pages or sidebar, and also open it as a popup or top bar. Simply sign up and connect your MailChimp account into the plugin admin settings and it will pull in all your MailChimp lists. From there you can choose the lists you want to make forms for.
15
+
16
+ What is [MailChimp](http://www.mailchimp.com/)? MailChimp is one of the best email marketing tools. Signup up for a [FREE Trial Account](http://www.mailchimp.com/signup/) and see for yourself!
17
+
18
+ We have put together our version of an improved signup plugin for MailChimp users to proactively sign-up new subscribers to their newsletter list. Our form offers the same basic features that MailChimp's official plugin offers, but also much more. In addition to the form, analytics will help you track the number of form views and subscriptions.
19
+
20
+ Our templates have been carefully designed, so they can be customer-friendly and easy to set-up. You'll have some basic customizations available from within the plugin.
21
+
22
+ **Features**
23
+
24
+ * Mobile optimized form
25
+ * Easier sign-ups to your MailChimp newsletter
26
+ * Automatic synching with your MailChimp account
27
+ * Beautiful templates for your Mailchimp newsletter sign-up form
28
+ * Complete Integration of MailChimp into WordPress
29
+ * Easily import MailChimp forms from an active MailChimp account
30
+ * Monitor MailChimp account activity
31
+ * Use MailChimp Interest Group/Segments
32
+ * Add MailChimp forms to posts, pages, or categories
33
+ * Set forms to single or double opt-in
34
+ * Customize the success message
35
+ * Customize the submit button text
36
+ * Redirect users to a page on submission
37
+ * Un-subscribe users from MailChimp lists
38
+ * View subscriber MailChimp profiles
39
+ * View individual form subscriber count
40
+ * Display multiple forms on a single page
41
+ * Easily add forms to pages and posts with a button in the page/post editor
42
+
43
+ After installation and creating your account, the plugin will guide you through connecting with MailChimp, selecting your List from our service, and then adding the form to your site. The time from starting installation to have the form on your site should be less than 5 minutes - absolutely everything can be done via our user friendly GUI - no file editing at all!
44
+
45
+ == Installation ==
46
+
47
+ This section describes how to install the plugin and get started using it.
48
+
49
+ = Version 2.8+ =
50
+ 1. Unzip our archive and upload the entire `mailchimp-mailmunch` directory to your `/wp-content/plugins/` directory
51
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
52
+ 3. Look for "MailChimp" in the WordPress admin menu and click it
53
+ 4. Sign up and create your first optin form
54
+ 5. Choose the optin form type: Popover, Embedded or Top Bar
55
+ 6. Connect MailChimp and choose a list
56
+ 7. Start collecting user emails and growing your subscriber list!
57
+
58
+ = Advanced =
59
+ If you are using Wordpress v3.0 or higher, you can use the short-code given during the optin form creation. It will look something like this:
60
+ ` [mailmunch-XYZ] `
61
+
62
+ == Frequently Asked Questions ==
63
+
64
+ = Do I need to have a MailChimp Account? =
65
+ Yes, you can register for one for free at [MailChimp](https://mailchimp.com/sign up/ "MailChimp Signup").
66
+
67
+ = Do I need to have lists already set up in MailChimp? =
68
+ Yes, you have to have at least 1 list set up in MailChimp.
69
+
70
+ For more help, visit the MailChimp Support article [How do I create a new list?](http://kb.mailchimp.com/article/where-can-i-find-my-api-key "How do I create a new list?")
71
+
72
+ = What do I do first? =
73
+ The first step is to activate the plugin and sign up. Then we will guide you through the process of connecting your MailChimp account and choosing the list. This is done on the WordPress admin "MailChimp" menu page.
74
+
75
+ = Do I need MailChimp's API Key? =
76
+ You don't have to worry about that. We will guide you through the process.
77
+
78
+ = How do I add my MailChimp lists? =
79
+ After you connect your MailChimp account, the plugin will fetch all of your MailChimp list information and load it into the plugin admin. You can simply choose the lists you want to make forms for.
80
+
81
+ = How do I add the MailChimp sign up forms to my site? =
82
+ We offer a variety of forms: Popups, Embedded, Top Bar, etc. You can choose which pages, posts or categories to show it on. You can also use a shortcode to add a form to a specific area in a page or post. Everything is done visually.
83
+
84
+ = How can I translate this plugin? =
85
+ Easy MailChimp Forms is now translated into multiple languages:
86
+
87
+ * Arabic
88
+ * Chinese
89
+ * English
90
+ * French
91
+ * German
92
+ * Greek
93
+ * Hebrew
94
+ * Hindi
95
+ * Hong Kong
96
+ * Italian
97
+ * Japanese
98
+ * Korean
99
+ * Persian
100
+ * Portuguese (Brazilian)
101
+ * Portuguese (European)
102
+ * Romanian
103
+ * Russian
104
+ * Spanish
105
+ * Swedish
106
+ * Taiwanese
107
+ * Tamil
108
+ * Urdu
109
+ * Vietnamese
110
+ * Welsh
111
+
112
+ Read the Codex article [Installing WordPress in Your Language](http://codex.wordpress.org/Installing_WordPress_in_Your_Language) for more information.
113
+
114
+ = Does this plugin slow down my site? =
115
+ Absolutely not. MailMunch is designed with high performance and scalability in mind. It's completely asynchronous and hosted on Amazon's highly scalable infrastructure. Some of our customers have very high traffic websites.
116
+
117
+ = How many more emails will list builder help me get? =
118
+ Most people see a 100% to 500% growth in their email subscribers.
119
+
120
+ == Other Notes ==
121
+
122
+ Our MailChimp email newsletter list builder helps WordPress users build their audiences online.
123
+
124
+ Why people use MailChimp
125
+
126
+ * MailChimp has free plans
127
+ * MailChimp automatically integrates with our plugin
128
+ * MailChimp easily sends newsletters
129
+ * MailChimp handles lists of all sizes
130
+ * MailChimp can send automated drip campaigns (scheduled emails)
131
+ * MailChimp has better list management
132
+ * MailChimp has great error messaging
133
+
134
+ == Screenshots ==
135
+
136
+ 1. This is the MailChimp optin form designer by MailMunch where you can customize your optin form
137
+ 2. The second step is configuring your optin form for things like when to show it, how often to show it, and where to go after they subscribe
138
+ 3. This is the integration step where you can connect your MailChimp account
139
+ 4. This is the final step where you can publish your optin form to all or selected posts, categories or pages
140
+ 5. And finally, we have the optin form working live on your blog - increasing your subscribers :)
141
+ 6. An example from a user site
142
+ 7. Another example from a user site
143
+
144
+ == Changelog ==
145
+
146
+ = 1.0.1 =
147
+ * The first version of MailChimp Forms WordPress plugin by MailMunch