Version Description
Minor improvements and small bug fixes.
Download this release
Release Info
Developer | DvanKooten |
Plugin | MailChimp for WordPress |
Version | 1.5.7 |
Comparing to | |
See all releases |
Code changes from version 1.5.6 to 1.5.7
- assets/css/admin.css +138 -27
- assets/css/form-reset.css +4 -0
- assets/css/form-theme-base.css +47 -22
- assets/js/placeholders.min.js +2 -2
- includes/class-admin.php +2 -11
- includes/class-api.php +4 -5
- includes/class-checkbox.php +11 -18
- includes/class-form.php +235 -90
- includes/class-plugin.php +67 -21
- includes/class-widget.php +7 -3
- includes/functions.php +4 -10
- includes/template-functions.php +20 -10
- includes/views/api-settings.php +74 -32
- includes/views/parts/admin-need-support.php +7 -7
- mailchimp-for-wp.php +17 -10
- readme.txt +19 -2
assets/css/admin.css
CHANGED
@@ -1,10 +1,17 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
2 |
#mc4wp-sidebar{
|
3 |
float:left;
|
4 |
width:33%;
|
5 |
margin-left:2%;
|
6 |
border-left:1px solid #ccc;
|
7 |
padding:0 0 0 2%;
|
|
|
|
|
8 |
box-sizing: border-box;
|
9 |
}
|
10 |
|
@@ -15,29 +22,91 @@
|
|
15 |
border-color: #bce8f1;
|
16 |
}
|
17 |
|
18 |
-
.valigntop{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
.mc4wp-
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
#mc4wp-lists{ margin:0; }
|
30 |
-
#mc4wp-lists input{ margin-right:5px; }
|
31 |
|
32 |
-
.
|
|
|
|
|
33 |
|
34 |
-
.mc4wp-settings
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
.mc4wp-settings table.form-table tr td:first-child, .mc4wp-settings table.form-table tr th:first-child{ padding-left:0; }
|
39 |
-
.mc4wp-settings td.nowrap{ white-space: nowrap }
|
40 |
-
.mc4wp-settings td.desc{ font-style:italic; font-size:11px; }
|
41 |
|
42 |
.mc4wp-notice{
|
43 |
padding:5px;
|
@@ -49,14 +118,19 @@
|
|
49 |
.mc4wp-col {
|
50 |
float:left;
|
51 |
-webkit-box-sizing: border-box;
|
52 |
-
box-sizing: border-box;
|
53 |
-moz-box-sizing:border-box;
|
|
|
54 |
width:50%;
|
55 |
padding:0 5px;
|
56 |
}
|
57 |
|
58 |
-
.mc4wp-first{
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
.mc4wp-well{
|
62 |
background:white;
|
@@ -72,11 +146,48 @@
|
|
72 |
}
|
73 |
|
74 |
|
75 |
-
table.mc4wp-help,
|
76 |
-
table.mc4wp-help th,
|
77 |
-
table.mc4wp-help
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
@media(max-width: 1279px) {
|
80 |
-
|
81 |
-
#mc4wp-sidebar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
1 |
+
|
2 |
+
#mc4wp-content{
|
3 |
+
float:left;
|
4 |
+
width:65%;
|
5 |
+
}
|
6 |
+
|
7 |
#mc4wp-sidebar{
|
8 |
float:left;
|
9 |
width:33%;
|
10 |
margin-left:2%;
|
11 |
border-left:1px solid #ccc;
|
12 |
padding:0 0 0 2%;
|
13 |
+
-moz-box-sizing: border-box;
|
14 |
+
-webkit-box-sizing: border-box;
|
15 |
box-sizing: border-box;
|
16 |
}
|
17 |
|
22 |
border-color: #bce8f1;
|
23 |
}
|
24 |
|
25 |
+
.valigntop{
|
26 |
+
vertical-align: top !important;
|
27 |
+
}
|
28 |
+
|
29 |
+
.mc4wp-box{
|
30 |
+
margin-bottom:20px;
|
31 |
+
}
|
32 |
+
|
33 |
+
#mc4wp-upgrade-box {
|
34 |
+
background:#222;
|
35 |
+
color:#ddd;
|
36 |
+
padding:20px;
|
37 |
+
}
|
38 |
+
|
39 |
+
#mc4wp-upgrade-box h3{
|
40 |
+
margin:0;
|
41 |
+
color:white;
|
42 |
+
}
|
43 |
+
|
44 |
+
#mc4wp-fw h4{
|
45 |
+
margin-top: 0;
|
46 |
+
}
|
47 |
+
#mc4wp-fw p{
|
48 |
+
margin-bottom: 1em;
|
49 |
+
}
|
50 |
+
|
51 |
+
#mc4wp-fw-fields {
|
52 |
+
display:none;
|
53 |
+
}
|
54 |
+
|
55 |
+
#mc4wp-fw-preview {
|
56 |
+
font-family: "Courier New", Courier, monospace;
|
57 |
+
min-height:200px;
|
58 |
+
font-size:11px;
|
59 |
+
background:white;
|
60 |
+
z-index:99;
|
61 |
+
}
|
62 |
+
|
63 |
+
#mc4wp-lists{
|
64 |
+
margin:0;
|
65 |
+
}
|
66 |
+
|
67 |
+
#mc4wp-lists input{
|
68 |
+
margin-right:5px;
|
69 |
+
}
|
70 |
+
|
71 |
+
.pro-feature,
|
72 |
+
.mc4wp-settings tr.pro-feature th,
|
73 |
+
.mc4wp-settings tr.pro-feature td{
|
74 |
+
color:#aaa;
|
75 |
+
}
|
76 |
+
|
77 |
+
.mc4wp-settings span.status{
|
78 |
+
display:inline-block;
|
79 |
+
padding:3px 6px;
|
80 |
+
color:white;
|
81 |
+
font-size:12px;
|
82 |
+
font-weight:bold;
|
83 |
+
}
|
84 |
+
|
85 |
+
.mc4wp-settings span.positive{
|
86 |
+
background-color:green;
|
87 |
+
}
|
88 |
|
89 |
+
.mc4wp-settings span.negative{
|
90 |
+
background-color:lightGrey;
|
91 |
+
}
|
92 |
|
93 |
+
.mc4wp-settings table th{
|
94 |
+
text-align:left;
|
95 |
+
}
|
96 |
|
97 |
+
.mc4wp-settings table.form-table tr td:first-child,
|
98 |
+
.mc4wp-settings table.form-table tr th:first-child{
|
99 |
+
padding-left:0;
|
100 |
+
}
|
|
|
|
|
101 |
|
102 |
+
.mc4wp-settings td.nowrap{
|
103 |
+
white-space: nowrap
|
104 |
+
}
|
105 |
|
106 |
+
.mc4wp-settings td.desc{
|
107 |
+
font-style:italic;
|
108 |
+
font-size:11px;
|
109 |
+
}
|
|
|
|
|
|
|
110 |
|
111 |
.mc4wp-notice{
|
112 |
padding:5px;
|
118 |
.mc4wp-col {
|
119 |
float:left;
|
120 |
-webkit-box-sizing: border-box;
|
|
|
121 |
-moz-box-sizing:border-box;
|
122 |
+
box-sizing: border-box;
|
123 |
width:50%;
|
124 |
padding:0 5px;
|
125 |
}
|
126 |
|
127 |
+
.mc4wp-first{
|
128 |
+
padding-left:0;
|
129 |
+
}
|
130 |
+
|
131 |
+
.mc4wp-last{
|
132 |
+
padding-right:0;
|
133 |
+
}
|
134 |
|
135 |
.mc4wp-well{
|
136 |
background:white;
|
146 |
}
|
147 |
|
148 |
|
149 |
+
table.mc4wp-help,
|
150 |
+
table.mc4wp-help th,
|
151 |
+
table.mc4wp-help td {
|
152 |
+
border: 1px solid #ddd;
|
153 |
+
border-collapse: collapse;
|
154 |
+
font-size: 12px;
|
155 |
+
}
|
156 |
+
|
157 |
+
table.mc4wp-help th,
|
158 |
+
table.mc4wp-help td {
|
159 |
+
vertical-align: text-top;
|
160 |
+
text-align: left;
|
161 |
+
padding: 5px 10px;
|
162 |
+
}
|
163 |
+
|
164 |
+
table.mc4wp-help tr:hover {
|
165 |
+
background-color: #ddd;
|
166 |
+
}
|
167 |
|
168 |
@media(max-width: 1279px) {
|
169 |
+
|
170 |
+
#mc4wp-sidebar,
|
171 |
+
#mc4wp-content{
|
172 |
+
float: none;
|
173 |
+
width: 100%;
|
174 |
+
padding:0;
|
175 |
+
margin:0;
|
176 |
+
}
|
177 |
+
|
178 |
+
#mc4wp-sidebar{
|
179 |
+
border-left:0;
|
180 |
+
border-top: 1px solid #ccc;
|
181 |
+
margin-top:25px;
|
182 |
+
padding-top: 25px;
|
183 |
+
}
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
@media(max-width: 719px) {
|
188 |
+
|
189 |
+
.mc4wp-hide-smallscreens{
|
190 |
+
display: none;
|
191 |
+
}
|
192 |
+
|
193 |
}
|
assets/css/form-reset.css
CHANGED
@@ -26,6 +26,10 @@
|
|
26 |
margin-top: 10px;
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
29 |
.mc4wp-form input.placeholdersjs {
|
30 |
color: #aaa !important;
|
31 |
}
|
26 |
margin-top: 10px;
|
27 |
}
|
28 |
|
29 |
+
.mc4wp-form input {
|
30 |
+
vertical-align: baseline;
|
31 |
+
}
|
32 |
+
|
33 |
.mc4wp-form input.placeholdersjs {
|
34 |
color: #aaa !important;
|
35 |
}
|
assets/css/form-theme-base.css
CHANGED
@@ -1,8 +1,20 @@
|
|
1 |
|
2 |
/* Form base theme */
|
3 |
-
.mc4wp-form {
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
.mc4wp-form input[type="text"],
|
8 |
.mc4wp-form input[type="email"],
|
@@ -13,7 +25,7 @@
|
|
13 |
.mc4wp-form select {
|
14 |
width: 100%;
|
15 |
height: 34px;
|
16 |
-
margin:0;
|
17 |
padding: 6px 12px;
|
18 |
font-size: 14px;
|
19 |
line-height: 1.428571429;
|
@@ -21,14 +33,17 @@
|
|
21 |
vertical-align: middle;
|
22 |
background-color: #ffffff;
|
23 |
border: 1px solid #cccccc;
|
|
|
|
|
24 |
border-radius: 2px;
|
|
|
25 |
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
26 |
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
|
|
27 |
-webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
|
28 |
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
|
29 |
background-image: none;
|
30 |
text-shadow: none;
|
31 |
-
|
32 |
}
|
33 |
|
34 |
.mc4wp-form input[type="text"]:focus,
|
@@ -39,20 +54,25 @@
|
|
39 |
.mc4wp-form select:focus {
|
40 |
border-color: #66afe9;
|
41 |
outline: 0;
|
|
|
42 |
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
|
43 |
-
|
44 |
}
|
45 |
|
46 |
-
.mc4wp-form textarea{
|
|
|
|
|
47 |
|
48 |
-
.mc4wp-form input[readonly],
|
|
|
49 |
background-color: #eeeeee;
|
50 |
}
|
51 |
|
52 |
-
.mc4wp-form input[type="submit"],
|
|
|
53 |
display: inline-block;
|
54 |
padding: 6px 12px;
|
55 |
-
margin:0;
|
56 |
font-size: 14px;
|
57 |
font-weight: normal;
|
58 |
line-height: 1.428571429;
|
@@ -63,33 +83,38 @@
|
|
63 |
border: 1px solid transparent;
|
64 |
border-radius: 2px;
|
65 |
-webkit-user-select: none;
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
box-shadow:none;
|
71 |
-
background:none;
|
72 |
-
text-shadow:none;
|
73 |
filter: none;
|
74 |
height: auto;
|
75 |
width: auto;
|
76 |
}
|
77 |
|
78 |
-
.mc4wp-form input[type="submit"]:focus,
|
|
|
79 |
outline: thin dotted #333;
|
80 |
outline: 5px auto -webkit-focus-ring-color;
|
81 |
outline-offset: -2px;
|
82 |
}
|
83 |
|
84 |
-
.mc4wp-form input[type="submit"]:hover,
|
85 |
-
.mc4wp-form
|
|
|
|
|
86 |
color: #333333;
|
87 |
text-decoration: none;
|
88 |
}
|
89 |
|
90 |
-
.mc4wp-form input[type="submit"]:active,
|
|
|
91 |
background-image: none;
|
92 |
outline: 0;
|
|
|
93 |
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
94 |
-
|
95 |
}
|
1 |
|
2 |
/* Form base theme */
|
3 |
+
.mc4wp-form {
|
4 |
+
box-shadow: none !important;
|
5 |
+
-webkit-box-shadow: none;
|
6 |
+
-moz-box-shadow: none;
|
7 |
+
}
|
8 |
+
|
9 |
+
.mc4wp-form p {
|
10 |
+
margin: 0 0 15px !important;
|
11 |
+
padding: 0;
|
12 |
+
}
|
13 |
+
|
14 |
+
.mc4wp-form label{
|
15 |
+
font-size:1em;
|
16 |
+
margin:6px 0;
|
17 |
+
}
|
18 |
|
19 |
.mc4wp-form input[type="text"],
|
20 |
.mc4wp-form input[type="email"],
|
25 |
.mc4wp-form select {
|
26 |
width: 100%;
|
27 |
height: 34px;
|
28 |
+
margin: 0;
|
29 |
padding: 6px 12px;
|
30 |
font-size: 14px;
|
31 |
line-height: 1.428571429;
|
33 |
vertical-align: middle;
|
34 |
background-color: #ffffff;
|
35 |
border: 1px solid #cccccc;
|
36 |
+
-moz-border-radius: 2px;
|
37 |
+
-webkit-border-radius: 2px;
|
38 |
border-radius: 2px;
|
39 |
+
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
40 |
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
41 |
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
|
42 |
+
-moz-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
|
43 |
-webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
|
44 |
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
|
45 |
background-image: none;
|
46 |
text-shadow: none;
|
|
|
47 |
}
|
48 |
|
49 |
.mc4wp-form input[type="text"]:focus,
|
54 |
.mc4wp-form select:focus {
|
55 |
border-color: #66afe9;
|
56 |
outline: 0;
|
57 |
+
-moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
|
58 |
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
|
59 |
+
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
|
60 |
}
|
61 |
|
62 |
+
.mc4wp-form textarea{
|
63 |
+
height: auto;
|
64 |
+
}
|
65 |
|
66 |
+
.mc4wp-form input[readonly],
|
67 |
+
.mc4wp-form input[disabled] {
|
68 |
background-color: #eeeeee;
|
69 |
}
|
70 |
|
71 |
+
.mc4wp-form input[type="submit"],
|
72 |
+
.mc4wp-form button {
|
73 |
display: inline-block;
|
74 |
padding: 6px 12px;
|
75 |
+
margin: 0;
|
76 |
font-size: 14px;
|
77 |
font-weight: normal;
|
78 |
line-height: 1.428571429;
|
83 |
border: 1px solid transparent;
|
84 |
border-radius: 2px;
|
85 |
-webkit-user-select: none;
|
86 |
+
-moz-user-select: none;
|
87 |
+
-ms-user-select: none;
|
88 |
+
-o-user-select: none;
|
89 |
+
user-select: none;
|
90 |
+
box-shadow: none;
|
91 |
+
background: none;
|
92 |
+
text-shadow: none;
|
93 |
filter: none;
|
94 |
height: auto;
|
95 |
width: auto;
|
96 |
}
|
97 |
|
98 |
+
.mc4wp-form input[type="submit"]:focus,
|
99 |
+
.mc4wp-form button:focus {
|
100 |
outline: thin dotted #333;
|
101 |
outline: 5px auto -webkit-focus-ring-color;
|
102 |
outline-offset: -2px;
|
103 |
}
|
104 |
|
105 |
+
.mc4wp-form input[type="submit"]:hover,
|
106 |
+
.mc4wp-form button:hover,
|
107 |
+
.mc4wp-form input[type="submit"]:focus,
|
108 |
+
.mc4wp-form button:focus {
|
109 |
color: #333333;
|
110 |
text-decoration: none;
|
111 |
}
|
112 |
|
113 |
+
.mc4wp-form input[type="submit"]:active,
|
114 |
+
.mc4wp-form button:active {
|
115 |
background-image: none;
|
116 |
outline: 0;
|
117 |
+
-moz-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
118 |
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
119 |
+
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
120 |
}
|
assets/js/placeholders.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
/* Placeholders.js v3.0.
|
2 |
-
(function(t){"use strict";function e(t,e,r){return t.addEventListener?t.addEventListener(e,r,!1):t.attachEvent?t.attachEvent("on"+e,r):void 0}function r(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(t[r]===e)return!0;return!1}function n(t,e){var r;t.createTextRange?(r=t.createTextRange(),r.move("character",e),r.select()):t.selectionStart&&(t.focus(),t.setSelectionRange(e,e))}function a(t,e){try{return t.type=e,!0}catch(r){return!1}}t.Placeholders={Utils:{addEventListener:e,inArray:r,moveCaret:n,changeType:a}}})(this),function(t){"use strict";function e(){}function r(){try{return document.activeElement}catch(t){}}function n(t,e){var r,n,a=!!e&&t.value!==e,u=t.value===t.getAttribute(
|
1 |
+
/* Placeholders.js v3.0.2 */
|
2 |
+
(function(t){"use strict";function e(t,e,r){return t.addEventListener?t.addEventListener(e,r,!1):t.attachEvent?t.attachEvent("on"+e,r):void 0}function r(t,e){var r,n;for(r=0,n=t.length;n>r;r++)if(t[r]===e)return!0;return!1}function n(t,e){var r;t.createTextRange?(r=t.createTextRange(),r.move("character",e),r.select()):t.selectionStart&&(t.focus(),t.setSelectionRange(e,e))}function a(t,e){try{return t.type=e,!0}catch(r){return!1}}t.Placeholders={Utils:{addEventListener:e,inArray:r,moveCaret:n,changeType:a}}})(this),function(t){"use strict";function e(){}function r(){try{return document.activeElement}catch(t){}}function n(t,e){var r,n,a=!!e&&t.value!==e,u=t.value===t.getAttribute(V);return(a||u)&&"true"===t.getAttribute(D)?(t.removeAttribute(D),t.value=t.value.replace(t.getAttribute(V),""),t.className=t.className.replace(R,""),n=t.getAttribute(F),parseInt(n,10)>=0&&(t.setAttribute("maxLength",n),t.removeAttribute(F)),r=t.getAttribute(P),r&&(t.type=r),!0):!1}function a(t){var e,r,n=t.getAttribute(V);return""===t.value&&n?(t.setAttribute(D,"true"),t.value=n,t.className+=" "+I,r=t.getAttribute(F),r||(t.setAttribute(F,t.maxLength),t.removeAttribute("maxLength")),e=t.getAttribute(P),e?t.type="text":"password"===t.type&&M.changeType(t,"text")&&t.setAttribute(P,"password"),!0):!1}function u(t,e){var r,n,a,u,i,l,o;if(t&&t.getAttribute(V))e(t);else for(a=t?t.getElementsByTagName("input"):b,u=t?t.getElementsByTagName("textarea"):f,r=a?a.length:0,n=u?u.length:0,o=0,l=r+n;l>o;o++)i=r>o?a[o]:u[o-r],e(i)}function i(t){u(t,n)}function l(t){u(t,a)}function o(t){return function(){m&&t.value===t.getAttribute(V)&&"true"===t.getAttribute(D)?M.moveCaret(t,0):n(t)}}function c(t){return function(){a(t)}}function s(t){return function(e){return A=t.value,"true"===t.getAttribute(D)&&A===t.getAttribute(V)&&M.inArray(C,e.keyCode)?(e.preventDefault&&e.preventDefault(),!1):void 0}}function d(t){return function(){n(t,A),""===t.value&&(t.blur(),M.moveCaret(t,0))}}function g(t){return function(){t===r()&&t.value===t.getAttribute(V)&&"true"===t.getAttribute(D)&&M.moveCaret(t,0)}}function v(t){return function(){i(t)}}function p(t){t.form&&(T=t.form,"string"==typeof T&&(T=document.getElementById(T)),T.getAttribute(U)||(M.addEventListener(T,"submit",v(T)),T.setAttribute(U,"true"))),M.addEventListener(t,"focus",o(t)),M.addEventListener(t,"blur",c(t)),m&&(M.addEventListener(t,"keydown",s(t)),M.addEventListener(t,"keyup",d(t)),M.addEventListener(t,"click",g(t))),t.setAttribute(j,"true"),t.setAttribute(V,x),(m||t!==r())&&a(t)}var b,f,m,h,A,y,E,x,L,T,N,S,w,B=["text","search","url","tel","email","password","number","textarea"],C=[27,33,34,35,36,37,38,39,40,8,46],k="#ccc",I="placeholdersjs",R=RegExp("(?:^|\\s)"+I+"(?!\\S)"),V="data-placeholder-value",D="data-placeholder-active",P="data-placeholder-type",U="data-placeholder-submit",j="data-placeholder-bound",q="data-placeholder-focus",z="data-placeholder-live",F="data-placeholder-maxlength",G=document.createElement("input"),H=document.getElementsByTagName("head")[0],J=document.documentElement,K=t.Placeholders,M=K.Utils;if(K.nativeSupport=void 0!==G.placeholder,!K.nativeSupport){for(b=document.getElementsByTagName("input"),f=document.getElementsByTagName("textarea"),m="false"===J.getAttribute(q),h="false"!==J.getAttribute(z),y=document.createElement("style"),y.type="text/css",E=document.createTextNode("."+I+" { color:"+k+"; }"),y.styleSheet?y.styleSheet.cssText=E.nodeValue:y.appendChild(E),H.insertBefore(y,H.firstChild),w=0,S=b.length+f.length;S>w;w++)N=b.length>w?b[w]:f[w-b.length],x=N.attributes.placeholder,x&&(x=x.nodeValue,x&&M.inArray(B,N.type)&&p(N));L=setInterval(function(){for(w=0,S=b.length+f.length;S>w;w++)N=b.length>w?b[w]:f[w-b.length],x=N.attributes.placeholder,x?(x=x.nodeValue,x&&M.inArray(B,N.type)&&(N.getAttribute(j)||p(N),(x!==N.getAttribute(V)||"password"===N.type&&!N.getAttribute(P))&&("password"===N.type&&!N.getAttribute(P)&&M.changeType(N,"text")&&N.setAttribute(P,"password"),N.value===N.getAttribute(V)&&(N.value=x),N.setAttribute(V,x)))):N.getAttribute(D)&&(n(N),N.removeAttribute(V));h||clearInterval(L)},100)}M.addEventListener(t,"beforeunload",function(){K.disable()}),K.disable=K.nativeSupport?e:i,K.enable=K.nativeSupport?e:l}(this);
|
includes/class-admin.php
CHANGED
@@ -8,17 +8,8 @@ if( ! defined( "MC4WP_LITE_VERSION" ) ) {
|
|
8 |
|
9 |
class MC4WP_Lite_Admin
|
10 |
{
|
11 |
-
|
12 |
-
|
13 |
-
public static function init() {
|
14 |
-
if( ! self::$instance ) {
|
15 |
-
self::$instance = new self();
|
16 |
-
} else {
|
17 |
-
throw new Exception( "Already initalized." );
|
18 |
-
}
|
19 |
-
}
|
20 |
-
|
21 |
-
private function __construct()
|
22 |
{
|
23 |
add_action('admin_init', array($this, 'register_settings'));
|
24 |
add_action('admin_menu', array($this, 'build_menu'));
|
8 |
|
9 |
class MC4WP_Lite_Admin
|
10 |
{
|
11 |
+
|
12 |
+
public function __construct()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
{
|
14 |
add_action('admin_init', array($this, 'register_settings'));
|
15 |
add_action('admin_menu', array($this, 'build_menu'));
|
includes/class-api.php
CHANGED
@@ -8,6 +8,7 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
8 |
|
9 |
/**
|
10 |
* Takes care of requests to the MailChimp API
|
|
|
11 |
* @uses WP_HTTP
|
12 |
*/
|
13 |
class MC4WP_Lite_API {
|
@@ -18,6 +19,8 @@ class MC4WP_Lite_API {
|
|
18 |
private $connected = null;
|
19 |
|
20 |
/**
|
|
|
|
|
21 |
* @param string $api_key MailChimp API key
|
22 |
*/
|
23 |
public function __construct( $api_key )
|
@@ -239,7 +242,7 @@ class MC4WP_Lite_API {
|
|
239 |
}
|
240 |
|
241 |
// dirty fix for older WP version
|
242 |
-
if($method == 'helper/ping' && isset( $response['headers']['content-length'] ) && (int) $response['headers']['content-length'] ==
|
243 |
return (object) array( 'msg' => "Everything's Chimpy!");
|
244 |
}
|
245 |
|
@@ -247,10 +250,6 @@ class MC4WP_Lite_API {
|
|
247 |
return json_decode( $body );
|
248 |
}
|
249 |
|
250 |
-
public function show_http_error() {
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
/**
|
255 |
* Checks if an error occured in the most recent request
|
256 |
* @return boolean
|
8 |
|
9 |
/**
|
10 |
* Takes care of requests to the MailChimp API
|
11 |
+
*
|
12 |
* @uses WP_HTTP
|
13 |
*/
|
14 |
class MC4WP_Lite_API {
|
19 |
private $connected = null;
|
20 |
|
21 |
/**
|
22 |
+
* Constructor
|
23 |
+
*
|
24 |
* @param string $api_key MailChimp API key
|
25 |
*/
|
26 |
public function __construct( $api_key )
|
242 |
}
|
243 |
|
244 |
// dirty fix for older WP version
|
245 |
+
if($method == 'helper/ping' && isset( $response['headers']['content-length'] ) && (int) $response['headers']['content-length'] == 44 ) {
|
246 |
return (object) array( 'msg' => "Everything's Chimpy!");
|
247 |
}
|
248 |
|
250 |
return json_decode( $body );
|
251 |
}
|
252 |
|
|
|
|
|
|
|
|
|
253 |
/**
|
254 |
* Checks if an error occured in the most recent request
|
255 |
* @return boolean
|
includes/class-checkbox.php
CHANGED
@@ -7,31 +7,24 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
7 |
}
|
8 |
|
9 |
class MC4WP_Lite_Checkbox
|
10 |
-
{
|
|
|
|
|
|
|
11 |
private $showed_checkbox = false;
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
} else {
|
18 |
-
self::$instance = new self;
|
19 |
-
}
|
20 |
-
}
|
21 |
-
|
22 |
-
public static function instance() {
|
23 |
-
return self::$instance;
|
24 |
-
}
|
25 |
-
|
26 |
-
private function __construct()
|
27 |
{
|
28 |
$opts = mc4wp_get_options('checkbox');
|
29 |
|
30 |
-
add_action('init', array($this, 'initialize'));
|
31 |
|
32 |
// load checkbox css if necessary
|
33 |
if ( $opts['css'] ) {
|
34 |
-
add_filter('mc4wp_stylesheets', array($this, 'add_stylesheet'));
|
35 |
}
|
36 |
|
37 |
/* Comment Form Actions */
|
7 |
}
|
8 |
|
9 |
class MC4WP_Lite_Checkbox
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* @var boolean
|
13 |
+
*/
|
14 |
private $showed_checkbox = false;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Constructor
|
18 |
+
*/
|
19 |
+
public function __construct()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
{
|
21 |
$opts = mc4wp_get_options('checkbox');
|
22 |
|
23 |
+
add_action('init', array( $this, 'initialize' ) );
|
24 |
|
25 |
// load checkbox css if necessary
|
26 |
if ( $opts['css'] ) {
|
27 |
+
add_filter( 'mc4wp_stylesheets', array( $this, 'add_stylesheet' ) );
|
28 |
}
|
29 |
|
30 |
/* Comment Form Actions */
|
includes/class-form.php
CHANGED
@@ -6,52 +6,63 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
6 |
exit;
|
7 |
}
|
8 |
|
|
|
|
|
|
|
9 |
class MC4WP_Lite_Form {
|
10 |
-
|
|
|
|
|
|
|
11 |
private $form_instance_number = 1;
|
12 |
-
private $error = null;
|
13 |
-
private $success = false;
|
14 |
-
private $submitted_form_instance = 0;
|
15 |
-
|
16 |
-
public static function init() {
|
17 |
-
if(self::$instance) {
|
18 |
-
throw new Exception("Already initialized");
|
19 |
-
} else {
|
20 |
-
self::$instance = new self;
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
public static function instance() {
|
25 |
-
return self::$instance;
|
26 |
-
}
|
27 |
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
-
|
|
|
|
|
|
|
31 |
|
32 |
-
|
|
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
add_shortcode( 'mc4wp-form', array( $this, 'output_form' ) );
|
42 |
|
43 |
// enable shortcodes in text widgets
|
44 |
add_filter( 'widget_text', 'shortcode_unautop' );
|
45 |
add_filter( 'widget_text', 'do_shortcode', 11 );
|
46 |
|
|
|
|
|
47 |
// has a MC4WP form been submitted?
|
48 |
if ( isset( $_POST['_mc4wp_form_submit'] ) ) {
|
49 |
$this->ensure_backwards_compatibility();
|
50 |
add_action( 'init', array( $this, 'submit' ) );
|
51 |
}
|
52 |
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
55 |
public function initialize()
|
56 |
{
|
57 |
// register placeholder script, which will later be enqueued for IE only
|
@@ -61,39 +72,74 @@ class MC4WP_Lite_Form {
|
|
61 |
wp_register_script( 'mc4wp-forms', MC4WP_LITE_PLUGIN_URL . 'assets/js/forms.js', array(), MC4WP_LITE_VERSION, true );
|
62 |
}
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
$opts = mc4wp_get_options('form');
|
66 |
|
67 |
-
|
|
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
$stylesheets['form-theme'] = $opts['css'];
|
72 |
-
}
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
return $stylesheets;
|
75 |
}
|
76 |
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
83 |
|
84 |
-
|
85 |
-
|
|
|
86 |
|
87 |
-
if
|
88 |
-
$css_classes
|
89 |
}
|
90 |
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
}
|
94 |
|
95 |
// allow developers to add css classes
|
96 |
-
$css_classes =
|
97 |
|
98 |
$form_action = apply_filters( 'mc4wp_form_action', mc4wp_get_current_url() );
|
99 |
|
@@ -128,7 +174,7 @@ class MC4WP_Lite_Form {
|
|
128 |
|
129 |
if ( $this->success ) {
|
130 |
$content .= '<div class="mc4wp-alert mc4wp-success">' . __( $opts['text_success'] ) . '</div>';
|
131 |
-
} elseif ( $this->error ) {
|
132 |
|
133 |
$api = mc4wp_get_api();
|
134 |
$e = $this->error;
|
@@ -177,42 +223,37 @@ class MC4WP_Lite_Form {
|
|
177 |
*/
|
178 |
public function submit() {
|
179 |
// store number of submitted form
|
180 |
-
$this->submitted_form_instance = absint($_POST['_mc4wp_form_instance']);
|
181 |
|
182 |
// validate form nonce
|
183 |
-
if ( !isset( $_POST['_mc4wp_form_nonce'] ) || !wp_verify_nonce( $_POST['_mc4wp_form_nonce'], '_mc4wp_form_nonce' ) ) {
|
184 |
$this->error = 'invalid_nonce';
|
185 |
return false;
|
186 |
}
|
187 |
|
188 |
// ensure honeypot was not filed
|
189 |
-
if ( isset( $_POST['_mc4wp_required_but_not_really'] ) && !empty( $_POST['_mc4wp_required_but_not_really'] ) ) {
|
190 |
$this->error = 'spam';
|
191 |
return false;
|
192 |
}
|
193 |
|
194 |
// allow plugins to add additional validation
|
195 |
-
$valid_form_request = apply_filters('mc4wp_valid_form_request', true);
|
196 |
-
if($valid_form_request !== true) {
|
197 |
$this->error = $valid_form_request;
|
198 |
return false;
|
199 |
}
|
200 |
|
201 |
// setup array of data entered by user
|
202 |
// not manipulating anything yet.
|
203 |
-
$data =
|
204 |
-
foreach($_POST as $name => $value) {
|
205 |
-
if($name[0] !== '_') {
|
206 |
-
$data[$name] = $value;
|
207 |
-
}
|
208 |
-
}
|
209 |
|
210 |
$success = $this->subscribe($data);
|
211 |
|
212 |
// enqueue scripts (in footer)
|
213 |
wp_enqueue_script( 'mc4wp-forms' );
|
214 |
wp_localize_script( 'mc4wp-forms', 'mc4wp', array(
|
215 |
-
'success' => ($success) ? 1 : 0,
|
216 |
'submittedFormId' => $this->submitted_form_instance,
|
217 |
'postData' => $data
|
218 |
)
|
@@ -223,7 +264,7 @@ class MC4WP_Lite_Form {
|
|
223 |
$opts = mc4wp_get_options('form');
|
224 |
|
225 |
// check if we want to redirect the visitor
|
226 |
-
if ( !empty( $opts['redirect'] ) ) {
|
227 |
wp_redirect( $opts['redirect'] );
|
228 |
exit;
|
229 |
}
|
@@ -235,6 +276,29 @@ class MC4WP_Lite_Form {
|
|
235 |
}
|
236 |
}
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
/*
|
239 |
Ensure backwards compatibility so sign-up forms that contain old form mark-up rules don't break
|
240 |
- Uppercase $_POST variables that should be sent to MailChimp
|
@@ -253,11 +317,13 @@ class MC4WP_Lite_Form {
|
|
253 |
|
254 |
foreach ( $old_groupings as $grouping ) {
|
255 |
|
256 |
-
if(!isset($grouping['groups'])) {
|
|
|
|
|
257 |
|
258 |
if ( isset( $grouping['id'] ) ) {
|
259 |
$key = $grouping['id'];
|
260 |
-
}
|
261 |
$key = $grouping['name'];
|
262 |
} else {
|
263 |
continue;
|
@@ -268,13 +334,20 @@ class MC4WP_Lite_Form {
|
|
268 |
}
|
269 |
|
270 |
// re-fill $_POST array with new groupings
|
271 |
-
if ( !empty( $new_groupings ) ) {
|
|
|
|
|
272 |
|
273 |
}
|
274 |
|
275 |
return;
|
276 |
}
|
277 |
|
|
|
|
|
|
|
|
|
|
|
278 |
public function subscribe( array $data ) {
|
279 |
|
280 |
$email = null;
|
@@ -283,8 +356,8 @@ class MC4WP_Lite_Form {
|
|
283 |
foreach ( $data as $name => $value ) {
|
284 |
|
285 |
// uppercase all variables
|
286 |
-
$name = trim(strtoupper($name));
|
287 |
-
$value = (is_scalar($value)) ? trim($value) : $value;
|
288 |
|
289 |
if( $name === 'EMAIL' && is_email($value) ) {
|
290 |
// set the email address
|
@@ -294,7 +367,9 @@ class MC4WP_Lite_Form {
|
|
294 |
$groupings = $value;
|
295 |
|
296 |
// malformed
|
297 |
-
if ( !is_array( $groupings ) ) {
|
|
|
|
|
298 |
|
299 |
// setup groupings array
|
300 |
$merge_vars['GROUPINGS'] = array();
|
@@ -309,26 +384,29 @@ class MC4WP_Lite_Form {
|
|
309 |
$grouping['name'] = $grouping_id_or_name;
|
310 |
}
|
311 |
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
$grouping['groups'] = $groups;
|
316 |
}
|
|
|
|
|
317 |
|
318 |
// add grouping to array
|
319 |
$merge_vars['GROUPINGS'][] = $grouping;
|
320 |
}
|
321 |
|
322 |
-
if ( empty( $merge_vars['GROUPINGS'] ) ) {
|
|
|
|
|
323 |
|
324 |
-
} else if($name === 'BIRTHDAY') {
|
325 |
// format birthdays in the DD/MM format required by MailChimp
|
326 |
-
$merge_vars['BIRTHDAY'] = date('d
|
327 |
-
} else if($name === 'ADDRESS') {
|
328 |
|
329 |
-
if(!isset($value['addr1'])) {
|
330 |
// addr1, addr2, city, state, zip, country
|
331 |
-
$addr_pieces = explode(',', $value);
|
332 |
|
333 |
// try to fill it.... this is a long shot
|
334 |
$merge_vars['ADDRESS'] = array(
|
@@ -350,17 +428,17 @@ class MC4WP_Lite_Form {
|
|
350 |
}
|
351 |
|
352 |
// check if an email address has been found
|
353 |
-
if(
|
354 |
$this->error = 'invalid_email';
|
355 |
return false;
|
356 |
}
|
357 |
|
358 |
// Try to guess FNAME and LNAME if they are not given, but NAME is
|
359 |
-
if(isset($merge_vars['NAME']) && !isset($merge_vars['FNAME']) && !isset($merge_vars['LNAME'])) {
|
360 |
|
361 |
$strpos = strpos($merge_vars['NAME'], ' ');
|
362 |
|
363 |
-
if($strpos) {
|
364 |
$merge_vars['FNAME'] = substr($merge_vars['NAME'], 0, $strpos);
|
365 |
$merge_vars['LNAME'] = substr($merge_vars['NAME'], $strpos);
|
366 |
} else {
|
@@ -371,39 +449,106 @@ class MC4WP_Lite_Form {
|
|
371 |
$api = mc4wp_get_api();
|
372 |
$opts = mc4wp_get_options('form');
|
373 |
|
374 |
-
$lists = $
|
375 |
|
376 |
if ( empty( $lists ) ) {
|
|
|
377 |
return false;
|
378 |
}
|
379 |
|
380 |
-
do_action('mc4wp_before_subscribe', $email, $merge_vars, 0);
|
381 |
|
382 |
$result = false;
|
383 |
-
|
384 |
-
$
|
385 |
|
386 |
foreach ( $lists as $list_id ) {
|
|
|
387 |
$list_merge_vars = apply_filters('mc4wp_merge_vars', $merge_vars, 0, $list_id);
|
|
|
|
|
388 |
$result = $api->subscribe( $list_id, $email, $list_merge_vars, $email_type, $opts['double_optin'] );
|
389 |
}
|
390 |
|
391 |
do_action('mc4wp_after_subscribe', $email, $merge_vars, 0, $result);
|
392 |
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
// do not use... will be removed in 2.0
|
397 |
-
$from_url = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
|
398 |
-
do_action('mc4wp_subscribe_form', $email, $list_id, 0, $merge_vars, $from_url);
|
399 |
-
|
400 |
-
$this->success = true;
|
401 |
-
} else {
|
402 |
$this->success = false;
|
403 |
$this->error = $result;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
404 |
}
|
405 |
|
406 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
}
|
408 |
|
409 |
}
|
6 |
exit;
|
7 |
}
|
8 |
|
9 |
+
/**
|
10 |
+
* This class takes care of all form related functionality
|
11 |
+
*/
|
12 |
class MC4WP_Lite_Form {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var int
|
16 |
+
*/
|
17 |
private $form_instance_number = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
/**
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
private $error = '';
|
23 |
|
24 |
+
/**
|
25 |
+
* @var boolean
|
26 |
+
*/
|
27 |
+
private $success = false;
|
28 |
|
29 |
+
/**
|
30 |
+
* @var int
|
31 |
+
*/
|
32 |
+
private $submitted_form_instance = 0;
|
33 |
|
34 |
+
/**
|
35 |
+
* Constructor
|
36 |
+
*/
|
37 |
+
public function __construct() {
|
38 |
|
39 |
+
add_action( 'init', array( $this, 'initialize' ) );
|
40 |
|
41 |
+
add_shortcode( 'mc4wp_form', array( $this, 'form' ) );
|
|
|
42 |
|
43 |
// enable shortcodes in text widgets
|
44 |
add_filter( 'widget_text', 'shortcode_unautop' );
|
45 |
add_filter( 'widget_text', 'do_shortcode', 11 );
|
46 |
|
47 |
+
add_filter( 'mc4wp_stylesheets', array( $this, 'add_stylesheets' ) );
|
48 |
+
|
49 |
// has a MC4WP form been submitted?
|
50 |
if ( isset( $_POST['_mc4wp_form_submit'] ) ) {
|
51 |
$this->ensure_backwards_compatibility();
|
52 |
add_action( 'init', array( $this, 'submit' ) );
|
53 |
}
|
54 |
|
55 |
+
/**
|
56 |
+
* @deprecated
|
57 |
+
*/
|
58 |
+
add_shortcode( 'mc4wp-form', array( $this, 'form' ) );
|
59 |
}
|
60 |
|
61 |
+
/**
|
62 |
+
* Initializes the Form functionality
|
63 |
+
*
|
64 |
+
* - Registers scripts so developers can override them, should they want to.
|
65 |
+
*/
|
66 |
public function initialize()
|
67 |
{
|
68 |
// register placeholder script, which will later be enqueued for IE only
|
72 |
wp_register_script( 'mc4wp-forms', MC4WP_LITE_PLUGIN_URL . 'assets/js/forms.js', array(), MC4WP_LITE_VERSION, true );
|
73 |
}
|
74 |
|
75 |
+
/**
|
76 |
+
* Adds the form stylesheet to the MailChimp for WP Stylesheets filter
|
77 |
+
*
|
78 |
+
* @param array $stylesheets
|
79 |
+
* @return array
|
80 |
+
*/
|
81 |
+
public function add_stylesheets( $stylesheets ) {
|
82 |
$opts = mc4wp_get_options('form');
|
83 |
|
84 |
+
|
85 |
+
if( $opts['css'] ) {
|
86 |
|
87 |
+
// Load the base form theme
|
88 |
+
$stylesheets['form'] = 1;
|
|
|
|
|
89 |
|
90 |
+
|
91 |
+
// Should we load one of the default form themes?
|
92 |
+
if( $opts['css'] != 1 && $opts['css'] != 'default' ) {
|
93 |
+
$stylesheets['form-theme'] = $opts['css'];
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
return $stylesheets;
|
98 |
}
|
99 |
|
100 |
+
/**
|
101 |
+
* Gets CSS classess to add to the form element
|
102 |
+
*
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
+
private function get_css_classes() {
|
106 |
|
107 |
+
$css_classes = array(
|
108 |
+
'form',
|
109 |
+
'mc4wp-form'
|
110 |
+
);
|
111 |
|
112 |
+
if( $this->error !== '' ) {
|
113 |
+
$css_classes[] = 'mc4wp-form-error';
|
114 |
+
}
|
115 |
|
116 |
+
if( $this->success ) {
|
117 |
+
$css_classes[] = 'mc4wp-form-success';
|
118 |
}
|
119 |
|
120 |
+
// Allow devs to add CSS classes
|
121 |
+
$css_classes = apply_filters( 'mc4wp_form_css_classes', $css_classes );
|
122 |
+
|
123 |
+
return implode( ' ', $css_classes );
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Returns the MailChimp for WP form mark-up
|
128 |
+
*
|
129 |
+
* @param array $atts
|
130 |
+
* @param string $content
|
131 |
+
*
|
132 |
+
* @return string
|
133 |
+
*/
|
134 |
+
public function form( $atts, $content = null ) {
|
135 |
+
$opts = mc4wp_get_options('form');
|
136 |
+
|
137 |
+
if ( ! function_exists( 'mc4wp_replace_variables' ) ) {
|
138 |
+
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
|
139 |
}
|
140 |
|
141 |
// allow developers to add css classes
|
142 |
+
$css_classes = $this->get_css_classes();
|
143 |
|
144 |
$form_action = apply_filters( 'mc4wp_form_action', mc4wp_get_current_url() );
|
145 |
|
174 |
|
175 |
if ( $this->success ) {
|
176 |
$content .= '<div class="mc4wp-alert mc4wp-success">' . __( $opts['text_success'] ) . '</div>';
|
177 |
+
} elseif ( $this->error !== '' ) {
|
178 |
|
179 |
$api = mc4wp_get_api();
|
180 |
$e = $this->error;
|
223 |
*/
|
224 |
public function submit() {
|
225 |
// store number of submitted form
|
226 |
+
$this->submitted_form_instance = absint( $_POST['_mc4wp_form_instance'] );
|
227 |
|
228 |
// validate form nonce
|
229 |
+
if ( ! isset( $_POST['_mc4wp_form_nonce'] ) || ! wp_verify_nonce( $_POST['_mc4wp_form_nonce'], '_mc4wp_form_nonce' ) ) {
|
230 |
$this->error = 'invalid_nonce';
|
231 |
return false;
|
232 |
}
|
233 |
|
234 |
// ensure honeypot was not filed
|
235 |
+
if ( isset( $_POST['_mc4wp_required_but_not_really'] ) && ! empty( $_POST['_mc4wp_required_but_not_really'] ) ) {
|
236 |
$this->error = 'spam';
|
237 |
return false;
|
238 |
}
|
239 |
|
240 |
// allow plugins to add additional validation
|
241 |
+
$valid_form_request = apply_filters( 'mc4wp_valid_form_request', true );
|
242 |
+
if( $valid_form_request !== true ) {
|
243 |
$this->error = $valid_form_request;
|
244 |
return false;
|
245 |
}
|
246 |
|
247 |
// setup array of data entered by user
|
248 |
// not manipulating anything yet.
|
249 |
+
$data = $this->get_posted_form_data();
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
$success = $this->subscribe($data);
|
252 |
|
253 |
// enqueue scripts (in footer)
|
254 |
wp_enqueue_script( 'mc4wp-forms' );
|
255 |
wp_localize_script( 'mc4wp-forms', 'mc4wp', array(
|
256 |
+
'success' => ( $success ) ? 1 : 0,
|
257 |
'submittedFormId' => $this->submitted_form_instance,
|
258 |
'postData' => $data
|
259 |
)
|
264 |
$opts = mc4wp_get_options('form');
|
265 |
|
266 |
// check if we want to redirect the visitor
|
267 |
+
if ( ! empty( $opts['redirect'] ) ) {
|
268 |
wp_redirect( $opts['redirect'] );
|
269 |
exit;
|
270 |
}
|
276 |
}
|
277 |
}
|
278 |
|
279 |
+
/**
|
280 |
+
* Get posted form data
|
281 |
+
*
|
282 |
+
* Strips internal MailChimp for WP variables from the posted data array
|
283 |
+
*
|
284 |
+
* @return array
|
285 |
+
*/
|
286 |
+
public function get_posted_form_data() {
|
287 |
+
|
288 |
+
$data = array();
|
289 |
+
|
290 |
+
foreach( $_POST as $name => $value ) {
|
291 |
+
if( $name[0] !== '_' ) {
|
292 |
+
$data[$name] = $value;
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
// store data somewhere safe
|
297 |
+
$this->posted_data = $data;
|
298 |
+
|
299 |
+
return $data;
|
300 |
+
}
|
301 |
+
|
302 |
/*
|
303 |
Ensure backwards compatibility so sign-up forms that contain old form mark-up rules don't break
|
304 |
- Uppercase $_POST variables that should be sent to MailChimp
|
317 |
|
318 |
foreach ( $old_groupings as $grouping ) {
|
319 |
|
320 |
+
if( ! isset( $grouping['groups'] ) ) {
|
321 |
+
continue;
|
322 |
+
}
|
323 |
|
324 |
if ( isset( $grouping['id'] ) ) {
|
325 |
$key = $grouping['id'];
|
326 |
+
} elseif( isset( $grouping['name'] ) ) {
|
327 |
$key = $grouping['name'];
|
328 |
} else {
|
329 |
continue;
|
334 |
}
|
335 |
|
336 |
// re-fill $_POST array with new groupings
|
337 |
+
if ( ! empty( $new_groupings ) ) {
|
338 |
+
$_POST['GROUPINGS'] = $new_groupings;
|
339 |
+
}
|
340 |
|
341 |
}
|
342 |
|
343 |
return;
|
344 |
}
|
345 |
|
346 |
+
/**
|
347 |
+
* Act on posted data
|
348 |
+
*
|
349 |
+
* @var array $data
|
350 |
+
*/
|
351 |
public function subscribe( array $data ) {
|
352 |
|
353 |
$email = null;
|
356 |
foreach ( $data as $name => $value ) {
|
357 |
|
358 |
// uppercase all variables
|
359 |
+
$name = trim( strtoupper( $name ) );
|
360 |
+
$value = ( is_scalar( $value ) ) ? trim( $value ) : $value;
|
361 |
|
362 |
if( $name === 'EMAIL' && is_email($value) ) {
|
363 |
// set the email address
|
367 |
$groupings = $value;
|
368 |
|
369 |
// malformed
|
370 |
+
if ( ! is_array( $groupings ) ) {
|
371 |
+
continue;
|
372 |
+
}
|
373 |
|
374 |
// setup groupings array
|
375 |
$merge_vars['GROUPINGS'] = array();
|
384 |
$grouping['name'] = $grouping_id_or_name;
|
385 |
}
|
386 |
|
387 |
+
// comma separated list should become an array
|
388 |
+
if( ! is_array( $groups ) ) {
|
389 |
+
$groups = explode( ',', $groups );
|
|
|
390 |
}
|
391 |
+
|
392 |
+
$grouping['groups'] = array_map( 'stripslashes', $groups );
|
393 |
|
394 |
// add grouping to array
|
395 |
$merge_vars['GROUPINGS'][] = $grouping;
|
396 |
}
|
397 |
|
398 |
+
if ( empty( $merge_vars['GROUPINGS'] ) ) {
|
399 |
+
unset( $merge_vars['GROUPINGS'] );
|
400 |
+
}
|
401 |
|
402 |
+
} else if( $name === 'BIRTHDAY' ) {
|
403 |
// format birthdays in the DD/MM format required by MailChimp
|
404 |
+
$merge_vars['BIRTHDAY'] = date( 'm/d', strtotime( $value ) );
|
405 |
+
} else if( $name === 'ADDRESS' ) {
|
406 |
|
407 |
+
if( ! isset( $value['addr1'] ) ) {
|
408 |
// addr1, addr2, city, state, zip, country
|
409 |
+
$addr_pieces = explode( ',', $value );
|
410 |
|
411 |
// try to fill it.... this is a long shot
|
412 |
$merge_vars['ADDRESS'] = array(
|
428 |
}
|
429 |
|
430 |
// check if an email address has been found
|
431 |
+
if( ! $email ) {
|
432 |
$this->error = 'invalid_email';
|
433 |
return false;
|
434 |
}
|
435 |
|
436 |
// Try to guess FNAME and LNAME if they are not given, but NAME is
|
437 |
+
if( isset( $merge_vars['NAME'] ) && !isset( $merge_vars['FNAME'] ) && ! isset( $merge_vars['LNAME'] ) ) {
|
438 |
|
439 |
$strpos = strpos($merge_vars['NAME'], ' ');
|
440 |
|
441 |
+
if( $strpos !== false ) {
|
442 |
$merge_vars['FNAME'] = substr($merge_vars['NAME'], 0, $strpos);
|
443 |
$merge_vars['LNAME'] = substr($merge_vars['NAME'], $strpos);
|
444 |
} else {
|
449 |
$api = mc4wp_get_api();
|
450 |
$opts = mc4wp_get_options('form');
|
451 |
|
452 |
+
$lists = $this->get_lists();
|
453 |
|
454 |
if ( empty( $lists ) ) {
|
455 |
+
$this->error = 'no_lists_selected';
|
456 |
return false;
|
457 |
}
|
458 |
|
459 |
+
do_action( 'mc4wp_before_subscribe', $email, $merge_vars, 0 );
|
460 |
|
461 |
$result = false;
|
462 |
+
|
463 |
+
$email_type = $this->get_email_type();
|
464 |
|
465 |
foreach ( $lists as $list_id ) {
|
466 |
+
// allow plugins to alter merge vars for each individual list
|
467 |
$list_merge_vars = apply_filters('mc4wp_merge_vars', $merge_vars, 0, $list_id);
|
468 |
+
|
469 |
+
// send a subscribe request to MailChimp for each list
|
470 |
$result = $api->subscribe( $list_id, $email, $list_merge_vars, $email_type, $opts['double_optin'] );
|
471 |
}
|
472 |
|
473 |
do_action('mc4wp_after_subscribe', $email, $merge_vars, 0, $result);
|
474 |
|
475 |
+
if ( $result !== true ) {
|
476 |
+
// subscribe request failed, store error.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
477 |
$this->success = false;
|
478 |
$this->error = $result;
|
479 |
+
}
|
480 |
+
|
481 |
+
// store user email in a cookie
|
482 |
+
$this->set_email_cookie( $email );
|
483 |
+
|
484 |
+
/**
|
485 |
+
* @deprecated Don't use, will be removed in v2.0
|
486 |
+
*/
|
487 |
+
$from_url = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
|
488 |
+
do_action('mc4wp_subscribe_form', $email, $list_id, 0, $merge_vars, $from_url);
|
489 |
+
|
490 |
+
// Store success result
|
491 |
+
$this->success = true;
|
492 |
+
|
493 |
+
return true;
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Gets the email_type
|
498 |
+
*
|
499 |
+
* @return string The email type to use for subscription coming from this form
|
500 |
+
*/
|
501 |
+
public function get_email_type( ) {
|
502 |
+
|
503 |
+
$email_type = 'html';
|
504 |
+
|
505 |
+
// get email type from form
|
506 |
+
if( isset( $_POST['_mc4wp_email_type'] ) ) {
|
507 |
+
$email_type = trim( $_POST['_mc4wp_email_type'] );
|
508 |
+
}
|
509 |
+
|
510 |
+
// allow plugins to override this email type
|
511 |
+
$email_type = apply_filters( 'mc4wp_email_type', $email_type );
|
512 |
+
|
513 |
+
return $email_type;
|
514 |
+
}
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Get MailChimp Lists to subscribe to
|
518 |
+
*
|
519 |
+
* @return array Array of selected MailChimp lists
|
520 |
+
*/
|
521 |
+
public function get_lists( ) {
|
522 |
+
|
523 |
+
$opts = mc4wp_get_options('form');
|
524 |
+
|
525 |
+
$lists = $opts['lists'];
|
526 |
+
|
527 |
+
// get lists from form, if set.
|
528 |
+
if( isset( $_POST['_mc4wp_lists'] ) && ! empty( $_POST['_mc4wp_lists'] ) ) {
|
529 |
+
|
530 |
+
$lists = $_POST['_mc4wp_lists'];
|
531 |
+
|
532 |
+
// make sure lists is an array
|
533 |
+
if( ! is_array( $lists ) ) {
|
534 |
+
$lists = array( $lists );
|
535 |
+
}
|
536 |
+
|
537 |
}
|
538 |
|
539 |
+
// allow plugins to alter the lists to subscribe to
|
540 |
+
$lists = apply_filters( 'mc4wp_lists', $lists );
|
541 |
+
|
542 |
+
return $lists;
|
543 |
+
}
|
544 |
+
|
545 |
+
/**
|
546 |
+
* Stores the given email in a cookie for 30 days
|
547 |
+
*
|
548 |
+
* @param string $email
|
549 |
+
*/
|
550 |
+
public function set_email_cookie( $email ) {
|
551 |
+
setcookie( 'mc4wp_email', $email, strtotime( '+30 days' ), '/' );
|
552 |
}
|
553 |
|
554 |
}
|
includes/class-plugin.php
CHANGED
@@ -7,45 +7,88 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
7 |
}
|
8 |
|
9 |
class MC4WP_Lite {
|
10 |
-
private static $instance;
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
-
}
|
23 |
-
|
24 |
-
private function __construct() {
|
25 |
-
$this->backwards_compatibility();
|
26 |
|
27 |
// checkbox
|
28 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-checkbox.php';
|
29 |
-
MC4WP_Lite_Checkbox
|
30 |
|
31 |
// form
|
32 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-form.php';
|
33 |
-
MC4WP_Lite_Form
|
34 |
|
35 |
// widget
|
36 |
-
add_action( 'widgets_init', array($this, 'register_widget') );
|
37 |
|
38 |
-
if (!is_admin()) {
|
39 |
// frontend only
|
40 |
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
|
41 |
|
42 |
// load css
|
43 |
-
add_action( 'wp_enqueue_scripts', array($this, 'load_stylesheets'), 90);
|
44 |
-
add_action( 'login_enqueue_scripts', array($this, 'load_stylesheets') );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
|
|
|
|
46 |
}
|
47 |
|
48 |
-
private function
|
49 |
$options = get_option( 'mc4wp_lite' );
|
50 |
|
51 |
// transfer widget to new id?
|
@@ -114,6 +157,9 @@ class MC4WP_Lite {
|
|
114 |
update_option( 'mc4wp_lite_checkbox', $new_options['checkbox'] );
|
115 |
update_option( 'mc4wp_lite_form', $new_options['form'] );
|
116 |
} // end transfer options
|
|
|
|
|
|
|
117 |
}
|
118 |
|
119 |
public function register_widget()
|
7 |
}
|
8 |
|
9 |
class MC4WP_Lite {
|
|
|
10 |
|
11 |
+
/**
|
12 |
+
* @var MC4WP_Lite_Form
|
13 |
+
*/
|
14 |
+
private $form_manager;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var MC4WP_Lite_Checkbox
|
18 |
+
*/
|
19 |
+
private $checkbox_manager;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @var MC4WP_Lite_API
|
23 |
+
*/
|
24 |
+
private $api = null;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* @var string Code version number
|
28 |
+
*/
|
29 |
+
private $code_version = "1.0";
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Constructor
|
33 |
+
*/
|
34 |
+
public function __construct() {
|
35 |
+
|
36 |
+
// Check whether to run the upgrade routine
|
37 |
+
$db_code_version = get_option( 'mc4wp_code_version', 0 );
|
38 |
+
if( version_compare( $this->code_version, $db_code_version, "<" ) ) {
|
39 |
+
$this->upgrade();
|
40 |
}
|
|
|
|
|
|
|
|
|
41 |
|
42 |
// checkbox
|
43 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-checkbox.php';
|
44 |
+
$this->checkbox_manager = new MC4WP_Lite_Checkbox();
|
45 |
|
46 |
// form
|
47 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-form.php';
|
48 |
+
$this->form_manager = new MC4WP_Lite_Form();
|
49 |
|
50 |
// widget
|
51 |
+
add_action( 'widgets_init', array( $this, 'register_widget' ) );
|
52 |
|
53 |
+
if ( ! is_admin() ) {
|
54 |
// frontend only
|
55 |
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/template-functions.php';
|
56 |
|
57 |
// load css
|
58 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'load_stylesheets' ), 90 );
|
59 |
+
add_action( 'login_enqueue_scripts', array( $this, 'load_stylesheets' ) );
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* @return MC4WP_Lite_Checkbox
|
65 |
+
*/
|
66 |
+
public function get_checkbox_manager() {
|
67 |
+
return $this->checkbox_manager;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @return MC4WP_Lite_Form
|
72 |
+
*/
|
73 |
+
public function get_form_manager() {
|
74 |
+
return $this->form_manager;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @return MC4WP_Lite_API
|
79 |
+
*/
|
80 |
+
public function get_api() {
|
81 |
+
|
82 |
+
if( $this->api === null ) {
|
83 |
+
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-api.php';
|
84 |
+
$opts = mc4wp_get_options();
|
85 |
+
$this->api = new MC4WP_Lite_API( $opts['general']['api_key'] );
|
86 |
}
|
87 |
+
|
88 |
+
return $this->api;
|
89 |
}
|
90 |
|
91 |
+
private function upgrade() {
|
92 |
$options = get_option( 'mc4wp_lite' );
|
93 |
|
94 |
// transfer widget to new id?
|
157 |
update_option( 'mc4wp_lite_checkbox', $new_options['checkbox'] );
|
158 |
update_option( 'mc4wp_lite_form', $new_options['form'] );
|
159 |
} // end transfer options
|
160 |
+
|
161 |
+
// update code version
|
162 |
+
update_option( 'mc4wp_code_version', $this->code_version );
|
163 |
}
|
164 |
|
165 |
public function register_widget()
|
includes/class-widget.php
CHANGED
@@ -17,7 +17,7 @@ class MC4WP_Lite_Widget extends WP_Widget {
|
|
17 |
function __construct() {
|
18 |
parent::__construct(
|
19 |
'MC4WP_Widget', // Base ID
|
20 |
-
__( 'MailChimp
|
21 |
array( 'description' => __( 'Displays your MailChimp for WordPress sign-up form', 'mailchimp-for-wp' ), ) // Args
|
22 |
);
|
23 |
}
|
@@ -34,9 +34,13 @@ class MC4WP_Lite_Widget extends WP_Widget {
|
|
34 |
$title = apply_filters( 'widget_title', $instance['title'] );
|
35 |
|
36 |
echo $args['before_widget'];
|
37 |
-
|
|
|
38 |
echo $args['before_title'] . $title . $args['after_title'];
|
|
|
|
|
39 |
echo mc4wp_get_form(0);
|
|
|
40 |
echo $args['after_widget'];
|
41 |
}
|
42 |
|
@@ -55,7 +59,7 @@ class MC4WP_Lite_Widget extends WP_Widget {
|
|
55 |
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
56 |
</p>
|
57 |
<p class="help">
|
58 |
-
You can edit your form in the <a href="
|
59 |
</p>
|
60 |
<?php
|
61 |
}
|
17 |
function __construct() {
|
18 |
parent::__construct(
|
19 |
'MC4WP_Widget', // Base ID
|
20 |
+
__( 'MailChimp Sign-Up Form', 'mailchimp-for-wp' ), // Name
|
21 |
array( 'description' => __( 'Displays your MailChimp for WordPress sign-up form', 'mailchimp-for-wp' ), ) // Args
|
22 |
);
|
23 |
}
|
34 |
$title = apply_filters( 'widget_title', $instance['title'] );
|
35 |
|
36 |
echo $args['before_widget'];
|
37 |
+
|
38 |
+
if ( ! empty( $title ) ) {
|
39 |
echo $args['before_title'] . $title . $args['after_title'];
|
40 |
+
}
|
41 |
+
|
42 |
echo mc4wp_get_form(0);
|
43 |
+
|
44 |
echo $args['after_widget'];
|
45 |
}
|
46 |
|
59 |
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
60 |
</p>
|
61 |
<p class="help">
|
62 |
+
<?php printf( __( 'You can edit your sign-up form in the %sMailChimp for WordPress form settings%s.', 'mailchimp-for-wp' ), '<a href="' . admin_url('admin.php?page=mc4wp-lite-form-settings') . '">', '</a>' ); ?>
|
63 |
</p>
|
64 |
<?php
|
65 |
}
|
includes/functions.php
CHANGED
@@ -73,16 +73,10 @@ function mc4wp_get_options( $key = null ) {
|
|
73 |
|
74 |
/**
|
75 |
* Gets the MailChimp for WP API class and injects it with the given API key
|
76 |
-
*
|
|
|
77 |
*/
|
78 |
function mc4wp_get_api() {
|
79 |
-
|
80 |
-
|
81 |
-
if( ! $api ) {
|
82 |
-
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-api.php';
|
83 |
-
$opts = mc4wp_get_options();
|
84 |
-
$api = new MC4WP_Lite_API( $opts['general']['api_key'] );
|
85 |
-
}
|
86 |
-
|
87 |
-
return $api;
|
88 |
}
|
73 |
|
74 |
/**
|
75 |
* Gets the MailChimp for WP API class and injects it with the given API key
|
76 |
+
*
|
77 |
+
* @return MC4WP_Lite_API
|
78 |
*/
|
79 |
function mc4wp_get_api() {
|
80 |
+
global $mc4wp;
|
81 |
+
return $mc4wp->get_api();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
includes/template-functions.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if( ! defined("MC4WP_LITE_VERSION") ) {
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
@@ -10,7 +10,8 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
10 |
* Echoes a sign-up checkbox.
|
11 |
*/
|
12 |
function mc4wp_checkbox() {
|
13 |
-
|
|
|
14 |
}
|
15 |
|
16 |
/**
|
@@ -28,7 +29,8 @@ function mc4wp_form( $id = 0 ) {
|
|
28 |
* @return string HTML of given form_id.
|
29 |
*/
|
30 |
function mc4wp_get_form( $id = 0 ) {
|
31 |
-
|
|
|
32 |
}
|
33 |
|
34 |
|
@@ -73,7 +75,7 @@ function mc4wp_replace_variables( $text, $list_ids = array() ) {
|
|
73 |
function mc4wp_get_subscriber_count( $list_ids ) {
|
74 |
$list_counts = get_transient( 'mc4wp_list_counts' );
|
75 |
|
76 |
-
if (
|
77 |
// make api call
|
78 |
$api = mc4wp_get_api();
|
79 |
$lists = $api->get_lists();
|
@@ -92,7 +94,10 @@ function mc4wp_get_subscriber_count( $list_ids ) {
|
|
92 |
} else {
|
93 |
// use fallback transient
|
94 |
$list_counts = get_transient( 'mc4wp_list_counts_fallback' );
|
95 |
-
|
|
|
|
|
|
|
96 |
}
|
97 |
}
|
98 |
|
@@ -113,20 +118,25 @@ function mc4wp_get_subscriber_count( $list_ids ) {
|
|
113 |
function mc4wp_get_current_url() {
|
114 |
$page_url = 'http';
|
115 |
|
116 |
-
if( is_ssl() ) {
|
|
|
|
|
117 |
|
118 |
$page_url .= '://';
|
119 |
|
120 |
-
if (!isset($_SERVER['REQUEST_URI'])) {
|
121 |
-
$request_uri = substr($_SERVER['PHP_SELF'], 1);
|
122 |
-
|
|
|
|
|
|
|
123 |
} else {
|
124 |
$request_uri = $_SERVER['REQUEST_URI'];
|
125 |
}
|
126 |
|
127 |
$page_url .= $_SERVER["HTTP_HOST"] . $request_uri;
|
128 |
|
129 |
-
return esc_url($page_url);
|
130 |
}
|
131 |
|
132 |
|
1 |
<?php
|
2 |
|
3 |
+
if( ! defined( "MC4WP_LITE_VERSION" ) ) {
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
10 |
* Echoes a sign-up checkbox.
|
11 |
*/
|
12 |
function mc4wp_checkbox() {
|
13 |
+
global $mc4wp;
|
14 |
+
$mc4wp->get_checkbox_manager()->output_checkbox();
|
15 |
}
|
16 |
|
17 |
/**
|
29 |
* @return string HTML of given form_id.
|
30 |
*/
|
31 |
function mc4wp_get_form( $id = 0 ) {
|
32 |
+
global $mc4wp;
|
33 |
+
return $mc4wp->get_form_manager()->form( array( 'id' => $id ) );
|
34 |
}
|
35 |
|
36 |
|
75 |
function mc4wp_get_subscriber_count( $list_ids ) {
|
76 |
$list_counts = get_transient( 'mc4wp_list_counts' );
|
77 |
|
78 |
+
if ( ! $list_counts ) {
|
79 |
// make api call
|
80 |
$api = mc4wp_get_api();
|
81 |
$lists = $api->get_lists();
|
94 |
} else {
|
95 |
// use fallback transient
|
96 |
$list_counts = get_transient( 'mc4wp_list_counts_fallback' );
|
97 |
+
|
98 |
+
if ( ! $list_counts ) {
|
99 |
+
return 0;
|
100 |
+
}
|
101 |
}
|
102 |
}
|
103 |
|
118 |
function mc4wp_get_current_url() {
|
119 |
$page_url = 'http';
|
120 |
|
121 |
+
if( is_ssl() ) {
|
122 |
+
$page_url .= 's';
|
123 |
+
}
|
124 |
|
125 |
$page_url .= '://';
|
126 |
|
127 |
+
if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
|
128 |
+
$request_uri = substr( $_SERVER['PHP_SELF'], 1 );
|
129 |
+
|
130 |
+
if ( isset( $_SERVER['QUERY_STRING'] ) ) {
|
131 |
+
$request_uri .='?'.$_SERVER['QUERY_STRING'];
|
132 |
+
}
|
133 |
} else {
|
134 |
$request_uri = $_SERVER['REQUEST_URI'];
|
135 |
}
|
136 |
|
137 |
$page_url .= $_SERVER["HTTP_HOST"] . $request_uri;
|
138 |
|
139 |
+
return esc_url( $page_url );
|
140 |
}
|
141 |
|
142 |
|
includes/views/api-settings.php
CHANGED
@@ -36,42 +36,84 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
36 |
</form>
|
37 |
|
38 |
<?php if($connected) { ?>
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
<tr valign="top">
|
|
|
56 |
<td><?php echo $list->name; ?></td>
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
</td>
|
65 |
-
<td class="pro-feature">Pro Only</td>
|
66 |
</tr>
|
67 |
-
<?php
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
</
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
75 |
<?php } ?>
|
76 |
|
77 |
<?php include 'parts/admin-footer.php'; ?>
|
36 |
</form>
|
37 |
|
38 |
<?php if($connected) { ?>
|
39 |
+
|
40 |
+
<h3 class="mc4wp-title">MailChimp Data</h3>
|
41 |
+
<p>The table below shows your MailChimp lists data. If you applied changes to your MailChimp lists, please use the following button to renew your cached data.</p>
|
42 |
+
|
43 |
+
<form method="post">
|
44 |
+
<p>
|
45 |
+
<input type="submit" name="renew-cached-data" value="Renew cached data" class="button" />
|
46 |
+
</p>
|
47 |
+
</form>
|
48 |
+
|
49 |
+
<table class="wp-list-table widefat">
|
50 |
+
<thead>
|
51 |
+
<tr>
|
52 |
+
<th class="mc4wp-hide-smallscreens" scope="col">List ID</th>
|
53 |
+
<th scope="col">List Name</th>
|
54 |
+
<th scope="col">Merge fields</th>
|
55 |
+
<th scope="col">Groupings</th>
|
56 |
+
<th scope="col">Subscriber Count</th>
|
57 |
+
</tr>
|
58 |
+
</thead>
|
59 |
+
<tbody>
|
60 |
+
<?php
|
61 |
+
if($lists) {
|
62 |
+
foreach($lists as $list) { ?>
|
63 |
+
|
64 |
<tr valign="top">
|
65 |
+
<td class="mc4wp-hide-smallscreens"><?php echo $list->id; ?></td>
|
66 |
<td><?php echo $list->name; ?></td>
|
67 |
+
|
68 |
+
<td>
|
69 |
+
<?php if( ! empty( $list->merge_vars ) ) { ?>
|
70 |
+
<ul class="ul-square" style="margin-top: 0;">
|
71 |
+
<?php foreach( $list->merge_vars as $merge_var ) { ?>
|
72 |
+
<li><?php echo $merge_var->name; ?></li>
|
73 |
+
<?php } ?>
|
74 |
+
</ul>
|
75 |
+
<?php } ?>
|
76 |
+
</td>
|
77 |
+
<td>
|
78 |
+
<?php
|
79 |
+
if( ! empty( $list->interest_groupings ) ) {
|
80 |
+
foreach($list->interest_groupings as $grouping) { ?>
|
81 |
+
<strong><?php echo $grouping->name; ?></strong>
|
82 |
+
|
83 |
+
<?php if( ! empty( $grouping->groups ) ) { ?>
|
84 |
+
<ul class="ul-square">
|
85 |
+
<?php foreach( $grouping->groups as $group ) { ?>
|
86 |
+
<li><?php echo $group->name; ?></li>
|
87 |
+
<?php } ?>
|
88 |
+
</ul>
|
89 |
+
<?php } ?>
|
90 |
+
<?php }
|
91 |
+
} else {
|
92 |
+
?>-<?php
|
93 |
+
} ?>
|
94 |
+
|
95 |
+
</td>
|
96 |
+
<td><?php echo $list->subscriber_count; ?></td>
|
97 |
+
</tr>
|
98 |
+
<?php
|
99 |
+
}
|
100 |
+
} else { ?>
|
101 |
+
<tr>
|
102 |
+
<td colspan="3">
|
103 |
+
<p>No lists were found in your MailChimp account.</p>
|
104 |
</td>
|
|
|
105 |
</tr>
|
106 |
+
<?php
|
107 |
+
}
|
108 |
+
?>
|
109 |
+
</tbody>
|
110 |
+
</table>
|
111 |
+
|
112 |
+
<form method="post">
|
113 |
+
<p>
|
114 |
+
<input type="submit" name="renew-cached-data" value="Renew cached data" class="button" />
|
115 |
+
</p>
|
116 |
+
</form>
|
117 |
<?php } ?>
|
118 |
|
119 |
<?php include 'parts/admin-footer.php'; ?>
|
includes/views/parts/admin-need-support.php
CHANGED
@@ -7,23 +7,23 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
7 |
?>
|
8 |
<div class="mc4wp-box">
|
9 |
<h4 class="mc4wp-title">Looking for support?</h4>
|
10 |
-
<p>
|
11 |
<p>If you need priority support, please <a href="http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=support-link">upgrade to the premium version</a>.</p>
|
12 |
</div>
|
13 |
|
14 |
<div class="mc4wp-box">
|
15 |
<h4 class="mc4wp-title">Show a token of your appreciation</h4>
|
16 |
<ul class="ul-square">
|
17 |
-
<li><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform">Leave a review on WordPress.org</a></li>
|
18 |
-
<li><a target="_blank" href="http://twitter.com/?status=Showing%20my%20appreciation%20to%20%40DannyvanKooten%20for%20his%20WordPress%20plugin%3A%20MailChimp%20for%20WP%20%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fmailchimp-for-wp%2F">Tweet about MailChimp for
|
19 |
-
<li>Review the plugin on your blog and link to <a href="http://dannyvankooten.com/mailchimp-for-wordpress
|
20 |
<li><a target="_blank" href="http://wordpress.org/plugins/mailchimp-for-wp/">Vote "works" on the WordPress.org plugin page</a></li>
|
21 |
</ul>
|
22 |
</div>
|
23 |
<div class="mc4wp-box">
|
24 |
<h4 class="mc4wp-title">About the developer</h4>
|
25 |
-
<p>My name is <a href="http://dannyvankooten.com
|
26 |
-
<p>Take a look at my other <a href="http://dannyvankooten.com/wordpress-plugins
|
27 |
<p><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2FCodeToTheChase&width&layout=standard&action=like&show_faces=true&share=false&appId=225994527565061" scrolling="no" frameborder="0" style="border:none; width: 100%; overflow:hidden; height: 80px;" allowTransparency="true"></iframe></p>
|
28 |
-
<p>You
|
29 |
</div>
|
7 |
?>
|
8 |
<div class="mc4wp-box">
|
9 |
<h4 class="mc4wp-title">Looking for support?</h4>
|
10 |
+
<p>Make sure to look at the <a href="http://wordpress.org/plugins/mailchimp-for-wp/faq/">frequently asked questions</a> or use the <a href="http://wordpress.org/support/plugin/mailchimp-for-wp">support forums</a> on WordPress.org.</p>
|
11 |
<p>If you need priority support, please <a href="http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=support-link">upgrade to the premium version</a>.</p>
|
12 |
</div>
|
13 |
|
14 |
<div class="mc4wp-box">
|
15 |
<h4 class="mc4wp-title">Show a token of your appreciation</h4>
|
16 |
<ul class="ul-square">
|
17 |
+
<li><a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/mailchimp-for-wp?rate=5#postform">Leave a ★★★★★ plugin review on WordPress.org</a></li>
|
18 |
+
<li><a target="_blank" href="http://twitter.com/?status=Showing%20my%20appreciation%20to%20%40DannyvanKooten%20for%20his%20WordPress%20plugin%3A%20MailChimp%20for%20WP%20%20-%20check%20it%20out!%20http%3A%2F%2Fwordpress.org%2Fplugins%2Fmailchimp-for-wp%2F">Tweet about MailChimp for WordPress</a></li>
|
19 |
+
<li>Review the plugin on your blog and link to <a href="http://dannyvankooten.com/mailchimp-for-wordpress/?utm_source=lite-plugin&utm_medium=link&utm_campaign=show-appreciation">the plugin page</a></li>
|
20 |
<li><a target="_blank" href="http://wordpress.org/plugins/mailchimp-for-wp/">Vote "works" on the WordPress.org plugin page</a></li>
|
21 |
</ul>
|
22 |
</div>
|
23 |
<div class="mc4wp-box">
|
24 |
<h4 class="mc4wp-title">About the developer</h4>
|
25 |
+
<p>My name is <a href="http://dannyvankooten.com/?utm_source=lite-plugin&utm_medium=link&utm_campaign=about">Danny van Kooten</a>. I develop WordPress plugins which help you build your websites. I love simplicity, happy customers and clean code.</p>
|
26 |
+
<p>Take a look at my other <a href="http://dannyvankooten.com/wordpress-plugins/?utm_source=lite-plugin&utm_medium=link&utm_campaign=about">plugins for WordPress</a> or <em>like</em> my Facebook page to stay updated.</p>
|
27 |
<p><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2FCodeToTheChase&width&layout=standard&action=like&show_faces=true&share=false&appId=225994527565061" scrolling="no" frameborder="0" style="border:none; width: 100%; overflow:hidden; height: 80px;" allowTransparency="true"></iframe></p>
|
28 |
+
<p>You should follow me on Twitter <a href="http://twitter.com/dannyvankooten">here</a>.</p>
|
29 |
</div>
|
mailchimp-for-wp.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: MailChimp for WordPress Lite
|
4 |
Plugin URI: http://dannyvankooten.com/mailchimp-for-wordpress/
|
5 |
Description: Lite version of MailChimp for WordPress. Adds various sign-up methods to your website.
|
6 |
-
Version: 1.5.
|
7 |
Author: Danny van Kooten
|
8 |
Author URI: http://dannyvanKooten.com
|
9 |
License: GPL v3
|
@@ -25,36 +25,43 @@ You should have received a copy of the GNU General Public License
|
|
25 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
26 |
*/
|
27 |
|
|
|
28 |
if( ! defined( 'ABSPATH' ) ) {
|
29 |
header( 'Status: 403 Forbidden' );
|
30 |
header( 'HTTP/1.1 403 Forbidden' );
|
31 |
exit;
|
32 |
}
|
33 |
|
34 |
-
|
|
|
|
|
|
|
|
|
35 |
function mc4wp_load_plugin() {
|
36 |
|
37 |
// don't load plugin if user has the premium version installed and activated
|
38 |
-
if( defined( "MC4WP_VERSION" )
|
39 |
-
return;
|
40 |
}
|
41 |
|
42 |
// bootstrap the lite plugin
|
43 |
-
define("MC4WP_LITE_VERSION", "1.5.
|
44 |
-
define("MC4WP_LITE_PLUGIN_DIR", plugin_dir_path(__FILE__));
|
45 |
-
define("MC4WP_LITE_PLUGIN_URL", plugins_url( '/' , __FILE__ ) );
|
46 |
|
47 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions.php';
|
48 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-plugin.php';
|
49 |
-
MC4WP_Lite
|
50 |
|
51 |
-
if(is_admin() && (!defined("DOING_AJAX") || !DOING_AJAX)) {
|
52 |
|
53 |
// ADMIN
|
54 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-admin.php';
|
55 |
-
MC4WP_Lite_Admin
|
56 |
|
57 |
}
|
|
|
|
|
58 |
}
|
59 |
|
60 |
add_action( 'plugins_loaded', 'mc4wp_load_plugin', 20 );
|
3 |
Plugin Name: MailChimp for WordPress Lite
|
4 |
Plugin URI: http://dannyvankooten.com/mailchimp-for-wordpress/
|
5 |
Description: Lite version of MailChimp for WordPress. Adds various sign-up methods to your website.
|
6 |
+
Version: 1.5.7
|
7 |
Author: Danny van Kooten
|
8 |
Author URI: http://dannyvanKooten.com
|
9 |
License: GPL v3
|
25 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
26 |
*/
|
27 |
|
28 |
+
// Prevent direct file access
|
29 |
if( ! defined( 'ABSPATH' ) ) {
|
30 |
header( 'Status: 403 Forbidden' );
|
31 |
header( 'HTTP/1.1 403 Forbidden' );
|
32 |
exit;
|
33 |
}
|
34 |
|
35 |
+
/**
|
36 |
+
* Loads the MailChimp for WP plugin files
|
37 |
+
*
|
38 |
+
* @return boolean True if the plugin files were loaded, false otherwise.
|
39 |
+
*/
|
40 |
function mc4wp_load_plugin() {
|
41 |
|
42 |
// don't load plugin if user has the premium version installed and activated
|
43 |
+
if( defined( "MC4WP_VERSION" ) ) {
|
44 |
+
return false;
|
45 |
}
|
46 |
|
47 |
// bootstrap the lite plugin
|
48 |
+
define( "MC4WP_LITE_VERSION", "1.5.7" );
|
49 |
+
define( "MC4WP_LITE_PLUGIN_DIR", plugin_dir_path( __FILE__ ) );
|
50 |
+
define( "MC4WP_LITE_PLUGIN_URL", plugins_url( '/' , __FILE__ ) );
|
51 |
|
52 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions.php';
|
53 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-plugin.php';
|
54 |
+
$GLOBALS['mc4wp'] = new MC4WP_Lite();
|
55 |
|
56 |
+
if( is_admin() && ( ! defined( "DOING_AJAX" ) || ! DOING_AJAX ) ) {
|
57 |
|
58 |
// ADMIN
|
59 |
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/class-admin.php';
|
60 |
+
new MC4WP_Lite_Admin();
|
61 |
|
62 |
}
|
63 |
+
|
64 |
+
return true;
|
65 |
}
|
66 |
|
67 |
add_action( 'plugins_loaded', 'mc4wp_load_plugin', 20 );
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://dannyvankooten.com/donate/
|
|
4 |
Tags: mailchimp,form,shortcode,widget,checkbox,comment,newsletter,buddypress,multisite,bbpress,woocommerce,easy digital downloads,contact form,contact form 7
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.8.1
|
7 |
-
Stable tag: 1.5.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -195,9 +195,23 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
|
|
195 |
7. **Pro only:** Gain valuable insights which method your visitors used to subscribe for any given time period using beautiful line charts.
|
196 |
8. **Pro only:** Create your own CSS styles with the form designer in the Pro version.
|
197 |
|
198 |
-
|
199 |
== Changelog ==
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
= 1.5.6 - March 13, 2014 =
|
202 |
* Fixed: Honeypot textarea showing in some themes
|
203 |
* Improved: Plugin will automatically strip duplicate `<form>` tags from form mark-up
|
@@ -472,6 +486,9 @@ Your theme folder can be found by browsing to `/wp-content/themes/your-theme-nam
|
|
472 |
|
473 |
== Upgrade Notice ==
|
474 |
|
|
|
|
|
|
|
475 |
= 1.5.5 =
|
476 |
Fixed field generator only generating `text` input fields.
|
477 |
|
4 |
Tags: mailchimp,form,shortcode,widget,checkbox,comment,newsletter,buddypress,multisite,bbpress,woocommerce,easy digital downloads,contact form,contact form 7
|
5 |
Requires at least: 3.1
|
6 |
Tested up to: 3.8.1
|
7 |
+
Stable tag: 1.5.7
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
195 |
7. **Pro only:** Gain valuable insights which method your visitors used to subscribe for any given time period using beautiful line charts.
|
196 |
8. **Pro only:** Create your own CSS styles with the form designer in the Pro version.
|
197 |
|
|
|
198 |
== Changelog ==
|
199 |
|
200 |
+
= 1.5.7 - March 18, 2014 =
|
201 |
+
**Fixes**
|
202 |
+
|
203 |
+
- Fixed special characters in group names not working
|
204 |
+
- Fixed BIRTHDAY field format (mm/dd)
|
205 |
+
|
206 |
+
**Improvements**
|
207 |
+
|
208 |
+
- Moved away from Singleton pattern
|
209 |
+
- Added a code version number for upgrade routines
|
210 |
+
- Better class documentation
|
211 |
+
- MailChimp cached data improvements. Now showing subscriber count.
|
212 |
+
- Base form CSS improvements, added vertical-align to field elements and removed padding from paragraph elements.
|
213 |
+
- Updated Placeholders.js for old IE versions
|
214 |
+
|
215 |
= 1.5.6 - March 13, 2014 =
|
216 |
* Fixed: Honeypot textarea showing in some themes
|
217 |
* Improved: Plugin will automatically strip duplicate `<form>` tags from form mark-up
|
486 |
|
487 |
== Upgrade Notice ==
|
488 |
|
489 |
+
= 1.5.7 =
|
490 |
+
Minor improvements and small bug fixes.
|
491 |
+
|
492 |
= 1.5.5 =
|
493 |
Fixed field generator only generating `text` input fields.
|
494 |
|