Version Description
Download this release
Release Info
Developer | anderly |
Plugin | WooCommerce MailChimp |
Version | 2.0.9 |
Comparing to | |
See all releases |
Code changes from version 2.0.8 to 2.0.9
- assets/css/style.css +30 -5
- assets/images/loading.gif +0 -0
- assets/js/woocommerce-mailchimp-admin.js +185 -133
- includes/class-ss-wc-mailchimp-api.php +9 -4
- includes/class-ss-wc-mailchimp-container.php +0 -121
- includes/class-ss-wc-mailchimp-handler.php +51 -50
- includes/class-ss-wc-mailchimp-plugin.php +167 -84
- includes/class-ss-wc-mailchimp.php +32 -0
- includes/class-ss-wc-settings-mailchimp.php +187 -257
- includes/functions.php +0 -76
- includes/migrations/class-ss-wc-migration-from-1.3.X-to-2.0.php +2 -2
- includes/migrations/class-ss-wc-migration.php +2 -2
- languages/woocommerce-mailchimp.pot +83 -83
- readme.txt +24 -9
- woocommerce-mailchimp.php +10 -17
assets/css/style.css
CHANGED
@@ -15,9 +15,34 @@
|
|
15 |
}
|
16 |
|
17 |
.woocommerce-mailchimp-loading-indicator {
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
15 |
}
|
16 |
|
17 |
.woocommerce-mailchimp-loading-indicator {
|
18 |
+
color: #32373c;
|
19 |
+
}
|
20 |
+
|
21 |
+
.woocommerce-mailchimp-loading-indicator:before {
|
22 |
+
font-family: dashicons;
|
23 |
+
line-height: 1.5em;
|
24 |
+
display: inline-block;
|
25 |
+
font-size: 20px;
|
26 |
+
line-height: 1;
|
27 |
+
text-decoration: inherit;
|
28 |
+
font-weight: 400;
|
29 |
+
font-style: normal;
|
30 |
+
vertical-align: top;
|
31 |
+
text-align: center;
|
32 |
+
content: "\f463";
|
33 |
+
}
|
34 |
+
|
35 |
+
.woocommerce-mailchimp-loading-indicator.loading:before {\
|
36 |
+
-webkit-animation: rotation 2s infinite linear;
|
37 |
+
animation: rotation 2s infinite linear;
|
38 |
+
}
|
39 |
+
|
40 |
+
.woocommerce-mailchimp-loading-indicator.success:before {
|
41 |
+
color: #46b450;
|
42 |
+
content: "\f147";
|
43 |
+
}
|
44 |
+
|
45 |
+
.woocommerce-mailchimp-loading-indicator.error:before {
|
46 |
+
color: #dc3232;
|
47 |
+
content: "\f534";
|
48 |
}
|
assets/images/loading.gif
DELETED
Binary file
|
assets/js/woocommerce-mailchimp-admin.js
CHANGED
@@ -5,6 +5,7 @@ var SS_WC_MailChimp = function($) {
|
|
5 |
|
6 |
var $enabled;
|
7 |
var $apiKey;
|
|
|
8 |
var $listsLoadingIndicator;
|
9 |
var $mainList;
|
10 |
var $interestGroupsLoadingIndicator;
|
@@ -20,6 +21,7 @@ var SS_WC_MailChimp = function($) {
|
|
20 |
|
21 |
return {
|
22 |
init: init,
|
|
|
23 |
loadLists: loadLists,
|
24 |
loadGroups: loadGroups,
|
25 |
};
|
@@ -27,6 +29,7 @@ var SS_WC_MailChimp = function($) {
|
|
27 |
function init() {
|
28 |
|
29 |
initHandles();
|
|
|
30 |
initHandlers();
|
31 |
initLists();
|
32 |
initGroups();
|
@@ -48,19 +51,16 @@ var SS_WC_MailChimp = function($) {
|
|
48 |
}
|
49 |
|
50 |
function initHandlers() {
|
51 |
-
//$apiKey.closest('tr').hide();
|
52 |
$mainList.closest('tr').hide();
|
53 |
|
54 |
if ($mainList.val() === '') {
|
55 |
$interestGroups.attr('disabled','disabled');
|
56 |
}
|
|
|
57 |
$apiKey.change(function() {
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
toggleAllSettings('show');
|
62 |
-
}
|
63 |
-
}).change();
|
64 |
|
65 |
$mainList.change(function() {
|
66 |
if ($mainList.val()) {
|
@@ -71,40 +71,28 @@ var SS_WC_MailChimp = function($) {
|
|
71 |
}
|
72 |
});
|
73 |
|
74 |
-
$apiKey.on('blur', function(e) {
|
75 |
-
if ($apiKey.val() === '') {
|
76 |
-
loadLists($apiKey.val());
|
77 |
-
}
|
78 |
-
}).change();
|
79 |
-
|
80 |
$apiKey.on('paste cut', function() {
|
81 |
|
82 |
// Short pause to wait for paste to complete
|
83 |
-
|
84 |
-
loadLists($apiKey.val());
|
85 |
$apiKey.change();
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
if ($mainList.val() !== '') {
|
91 |
loadGroups($apiKey.val(), $mainList.val());
|
92 |
}
|
93 |
});
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
$doubleOptIn.closest('tr').hide();
|
99 |
$displayOptIn.change(function() {
|
|
|
|
|
100 |
switch ($displayOptIn.val()) {
|
101 |
-
// case '0':
|
102 |
-
// $occurs.closest('tr').fadeOut();
|
103 |
-
// $optInLabel.closest('tr').fadeOut();
|
104 |
-
// $optInCheckboxDefault.closest('tr').fadeOut();
|
105 |
-
// $optInCheckboxLocation.closest('tr').fadeOut();
|
106 |
-
// $doubleOptIn.closest('tr').fadeOut();
|
107 |
-
// break;
|
108 |
case 'no':
|
109 |
$optInLabel.closest('tr').fadeOut();
|
110 |
$optInCheckboxDefault.closest('tr').fadeOut();
|
@@ -122,8 +110,14 @@ var SS_WC_MailChimp = function($) {
|
|
122 |
|
123 |
} //end function initHandlers
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
function initLists() {
|
126 |
-
$listsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_lists" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"
|
127 |
$mainList.after($listsLoadingIndicator.hide());
|
128 |
|
129 |
} //end function initLists
|
@@ -136,19 +130,9 @@ var SS_WC_MailChimp = function($) {
|
|
136 |
var lastGroup = '';
|
137 |
var grouping;
|
138 |
var $options = $interestGroups.children('option').clone();
|
|
|
139 |
$interestGroups.attr('data-placeholder', SS_WC_MailChimp_Messages.select_groups_placeholder);
|
140 |
-
|
141 |
-
// for (i = 0; i < $options.length; i++) {
|
142 |
-
// item = $options[i];
|
143 |
-
// currentGroup = item.text.split(':')[0];
|
144 |
-
// if (currentGroup !== lastGroup) {
|
145 |
-
// grouping = $('<optgroup>').attr('label', currentGroup);
|
146 |
-
// $interestGroups.append(grouping);
|
147 |
-
// }
|
148 |
-
// item.text = item.text.split(':')[1];
|
149 |
-
// grouping.append(item);
|
150 |
-
// lastGroup = currentGroup;
|
151 |
-
// }
|
152 |
$interestGroups.select2('destroy').select2();
|
153 |
var groupsMessage = $('#ss-wc-mailchimp-groups-msg').length > 0 ? $('#ss-wc-mailchimp-groups-msg') : $('<div id="ss-wc-mailchimp-groups-msg" style="display: inline-block"/>');
|
154 |
$interestGroups.after(groupsMessage);
|
@@ -162,111 +146,179 @@ var SS_WC_MailChimp = function($) {
|
|
162 |
}
|
163 |
|
164 |
// Add the loading indicator for groups (set to hidden by default)
|
165 |
-
$interestGroupsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_groups" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"
|
166 |
$interestGroups.parent().append($interestGroupsLoadingIndicator.hide());
|
167 |
|
168 |
} //end function initGroups
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
function loadLists(apiKey) {
|
171 |
|
172 |
/**
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
|
|
|
|
|
|
209 |
|
210 |
} //end function loadLists
|
211 |
|
212 |
function loadGroups(apiKey, listId) {
|
213 |
|
214 |
/**
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
|
|
|
|
270 |
|
271 |
} //end function loadGroups
|
272 |
|
5 |
|
6 |
var $enabled;
|
7 |
var $apiKey;
|
8 |
+
var $accountLoadingIndicator;
|
9 |
var $listsLoadingIndicator;
|
10 |
var $mainList;
|
11 |
var $interestGroupsLoadingIndicator;
|
21 |
|
22 |
return {
|
23 |
init: init,
|
24 |
+
checkApiKey: checkApiKey,
|
25 |
loadLists: loadLists,
|
26 |
loadGroups: loadGroups,
|
27 |
};
|
29 |
function init() {
|
30 |
|
31 |
initHandles();
|
32 |
+
initAccount();
|
33 |
initHandlers();
|
34 |
initLists();
|
35 |
initGroups();
|
51 |
}
|
52 |
|
53 |
function initHandlers() {
|
|
|
54 |
$mainList.closest('tr').hide();
|
55 |
|
56 |
if ($mainList.val() === '') {
|
57 |
$interestGroups.attr('disabled','disabled');
|
58 |
}
|
59 |
+
|
60 |
$apiKey.change(function() {
|
61 |
+
checkApiKey($apiKey.val(), true);
|
62 |
+
});
|
63 |
+
checkApiKey($apiKey.val(), false)
|
|
|
|
|
|
|
64 |
|
65 |
$mainList.change(function() {
|
66 |
if ($mainList.val()) {
|
71 |
}
|
72 |
});
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
$apiKey.on('paste cut', function() {
|
75 |
|
76 |
// Short pause to wait for paste to complete
|
77 |
+
setTimeout( function() {
|
|
|
78 |
$apiKey.change();
|
79 |
+
}, 100);
|
80 |
+
});
|
81 |
|
82 |
+
$mainList.on('change', function() {
|
83 |
if ($mainList.val() !== '') {
|
84 |
loadGroups($apiKey.val(), $mainList.val());
|
85 |
}
|
86 |
});
|
87 |
|
88 |
+
$optInLabel.closest('tr').hide();
|
89 |
+
$optInCheckboxDefault.closest('tr').hide();
|
90 |
+
$optInCheckboxLocation.closest('tr').hide();
|
91 |
$doubleOptIn.closest('tr').hide();
|
92 |
$displayOptIn.change(function() {
|
93 |
+
if ($apiKey.val() === '') return;
|
94 |
+
|
95 |
switch ($displayOptIn.val()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
case 'no':
|
97 |
$optInLabel.closest('tr').fadeOut();
|
98 |
$optInCheckboxDefault.closest('tr').fadeOut();
|
110 |
|
111 |
} //end function initHandlers
|
112 |
|
113 |
+
function initAccount() {
|
114 |
+
$accountLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_account" class="woocommerce-mailchimp-loading"><span id="woocommerce_mailchimp_account_indicator" class="woocommerce-mailchimp-loading-indicator"></span></div>');
|
115 |
+
$apiKey.after($accountLoadingIndicator.hide());
|
116 |
+
|
117 |
+
} //end function initAccount
|
118 |
+
|
119 |
function initLists() {
|
120 |
+
$listsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_lists" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"> '+SS_WC_MailChimp_Messages.connecting_to_mailchimp+'</span></div>');
|
121 |
$mainList.after($listsLoadingIndicator.hide());
|
122 |
|
123 |
} //end function initLists
|
130 |
var lastGroup = '';
|
131 |
var grouping;
|
132 |
var $options = $interestGroups.children('option').clone();
|
133 |
+
|
134 |
$interestGroups.attr('data-placeholder', SS_WC_MailChimp_Messages.select_groups_placeholder);
|
135 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
$interestGroups.select2('destroy').select2();
|
137 |
var groupsMessage = $('#ss-wc-mailchimp-groups-msg').length > 0 ? $('#ss-wc-mailchimp-groups-msg') : $('<div id="ss-wc-mailchimp-groups-msg" style="display: inline-block"/>');
|
138 |
$interestGroups.after(groupsMessage);
|
146 |
}
|
147 |
|
148 |
// Add the loading indicator for groups (set to hidden by default)
|
149 |
+
$interestGroupsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_groups" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"> '+SS_WC_MailChimp_Messages.connecting_to_mailchimp+'</span></div>');
|
150 |
$interestGroups.parent().append($interestGroupsLoadingIndicator.hide());
|
151 |
|
152 |
} //end function initGroups
|
153 |
|
154 |
+
function checkApiKey(apiKey, shouldLoadLists = false) {
|
155 |
+
|
156 |
+
if ( $apiKey.val() === '' ) {
|
157 |
+
toggleAllSettings('hide');
|
158 |
+
} else {
|
159 |
+
toggleAllSettings('show');
|
160 |
+
}
|
161 |
+
|
162 |
+
if (apiKey === '') return;
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Load account
|
166 |
+
*/
|
167 |
+
$mainList.attr('disabled','disabled');
|
168 |
+
$accountLoadingIndicator.show();
|
169 |
+
$accountIndicator = $accountLoadingIndicator.children().first();
|
170 |
+
$accountIndicator.removeClass('success').removeClass('error');
|
171 |
+
$accountIndicator.addClass('loading');
|
172 |
+
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.connecting_to_mailchimp);
|
173 |
+
$.post(
|
174 |
+
ajaxurl,
|
175 |
+
{
|
176 |
+
'action': '' + namespace_prefixed('get_account'),
|
177 |
+
'data': { 'api_key': apiKey }
|
178 |
+
},
|
179 |
+
function(response) {
|
180 |
+
console.log(response);
|
181 |
+
$accountIndicator.removeClass('loading');
|
182 |
+
var result = [];
|
183 |
+
|
184 |
+
try {
|
185 |
+
result = $.parseJSON(response);
|
186 |
+
} catch (err) {
|
187 |
+
console.error(err);
|
188 |
+
alert(' '+SS_WC_MailChimp_Messages.error_loading_account);
|
189 |
+
return;
|
190 |
+
}
|
191 |
+
|
192 |
+
if ( result.error ) {
|
193 |
+
$accountIndicator.addClass('error');
|
194 |
+
$accountIndicator.html(result.error);
|
195 |
+
return;
|
196 |
+
}
|
197 |
+
|
198 |
+
if ( ! result.account_id ) {
|
199 |
+
$accountIndicator.addClass('error');
|
200 |
+
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.error_loading_account);
|
201 |
+
return;
|
202 |
+
}
|
203 |
+
|
204 |
+
$accountIndicator.addClass('success');
|
205 |
+
$mainList.removeAttr('disabled');
|
206 |
+
$accountIndicator.html('');
|
207 |
+
|
208 |
+
// API Key looks good. Let's load the lists.
|
209 |
+
if ( shouldLoadLists ) {
|
210 |
+
loadLists( apiKey );
|
211 |
+
}
|
212 |
+
}
|
213 |
+
);
|
214 |
+
|
215 |
+
} //end function checkApiKey
|
216 |
+
|
217 |
function loadLists(apiKey) {
|
218 |
|
219 |
/**
|
220 |
+
* Load lists
|
221 |
+
*/
|
222 |
+
$mainList.attr('disabled','disabled');
|
223 |
+
$listsLoadingIndicator.show();
|
224 |
+
$listsIndicator = $listsLoadingIndicator.children().first();
|
225 |
+
$listsIndicator.addClass('loading');
|
226 |
+
$.post(
|
227 |
+
ajaxurl,
|
228 |
+
{
|
229 |
+
'action': '' + namespace_prefixed('get_lists'),
|
230 |
+
'data': { 'api_key': apiKey }
|
231 |
+
},
|
232 |
+
function(response) {
|
233 |
+
console.log(response);
|
234 |
+
$listsLoadingIndicator.hide();
|
235 |
+
$listsIndicator.removeClass('loading');
|
236 |
+
var result = [];
|
237 |
+
|
238 |
+
try {
|
239 |
+
result = $.parseJSON(response);
|
240 |
+
} catch (err) {
|
241 |
+
console.error(err);
|
242 |
+
alert(SS_WC_MailChimp_Messages.error_loading_lists);
|
243 |
+
}
|
244 |
+
|
245 |
+
if (result) {
|
246 |
+
$mainList.select2('destroy');
|
247 |
+
$mainList.removeAttr('disabled');
|
248 |
+
$mainList.children().remove();
|
249 |
+
$.each(result, function(key, val) {
|
250 |
+
$mainList
|
251 |
+
.append($('<option></option>')
|
252 |
+
.attr('value',key)
|
253 |
+
.text(val));
|
254 |
+
});
|
255 |
+
$mainList.select2();
|
256 |
+
}
|
257 |
+
}
|
258 |
+
);
|
259 |
|
260 |
} //end function loadLists
|
261 |
|
262 |
function loadGroups(apiKey, listId) {
|
263 |
|
264 |
/**
|
265 |
+
* Load interest groups
|
266 |
+
*/
|
267 |
+
$interestGroups.attr('disabled','disabled');
|
268 |
+
|
269 |
+
$interestGroups.children().remove();
|
270 |
+
|
271 |
+
$interestGroups.select2().hide();
|
272 |
+
$('#ss-wc-mailchimp-groups-msg').hide();
|
273 |
+
$interestGroupsLoadingIndicator.show();
|
274 |
+
$interestGroupsIndicator = $interestGroupsLoadingIndicator.children().first();
|
275 |
+
$interestGroupsIndicator.addClass('loading');
|
276 |
+
$.post(
|
277 |
+
ajaxurl,
|
278 |
+
{
|
279 |
+
'action': '' + namespace_prefixed('get_interest_groups'),
|
280 |
+
'data': { 'api_key': apiKey, 'list_id': listId }
|
281 |
+
},
|
282 |
+
function(response) {
|
283 |
+
console.log(response);
|
284 |
+
$interestGroupsLoadingIndicator.hide();
|
285 |
+
$interestGroupsIndicator.removeClass('loading');
|
286 |
+
var result = [];
|
287 |
+
|
288 |
+
try {
|
289 |
+
result = $.parseJSON(response);
|
290 |
+
} catch (err) {
|
291 |
+
console.error(err);
|
292 |
+
alert(SS_WC_MailChimp_Messages.error_loading_groups);
|
293 |
+
}
|
294 |
+
|
295 |
+
if (result.error) {
|
296 |
+
$('#ss-wc-mailchimp-groups-msg').text(result.error).show();
|
297 |
+
$interestGroups.children().remove();
|
298 |
+
$interestGroups.select2('destroy');
|
299 |
+
$interestGroups.hide();
|
300 |
+
return;
|
301 |
+
}
|
302 |
+
|
303 |
+
if (result.length === 0) {
|
304 |
+
$('#ss-wc-mailchimp-groups-msg').show();
|
305 |
+
initGroups();
|
306 |
+
return;
|
307 |
+
}
|
308 |
+
|
309 |
+
$interestGroups.show();
|
310 |
+
$interestGroups.removeAttr('disabled');
|
311 |
+
$interestGroups.children().remove();
|
312 |
+
$.each(result, function(id, grouping) {
|
313 |
+
$interestGroups.append(
|
314 |
+
$('<option></option>')
|
315 |
+
.attr('value',id)
|
316 |
+
.text(grouping));
|
317 |
+
});
|
318 |
+
|
319 |
+
initGroups();
|
320 |
+
}
|
321 |
+
);
|
322 |
|
323 |
} //end function loadGroups
|
324 |
|
includes/class-ss-wc-mailchimp-api.php
CHANGED
@@ -42,6 +42,11 @@ class SS_WC_MailChimp_API {
|
|
42 |
*/
|
43 |
private $last_error;
|
44 |
|
|
|
|
|
|
|
|
|
|
|
45 |
/**
|
46 |
* Create a new instance
|
47 |
* @param string $api_key MailChimp API key
|
@@ -51,7 +56,7 @@ class SS_WC_MailChimp_API {
|
|
51 |
|
52 |
$this->debug = $debug;
|
53 |
|
54 |
-
if ( $this->debug ) {
|
55 |
$this->log = new WC_Logger();
|
56 |
}
|
57 |
|
@@ -70,7 +75,7 @@ class SS_WC_MailChimp_API {
|
|
70 |
*/
|
71 |
public function get( $resource, $args = array() ) {
|
72 |
|
73 |
-
if ( ! array_key_exists( 'count', $args ) ) {
|
74 |
$args['count'] = 10;
|
75 |
}
|
76 |
|
@@ -151,7 +156,7 @@ class SS_WC_MailChimp_API {
|
|
151 |
'Content-Type' => 'application/json',
|
152 |
'Accept' => 'application/json',
|
153 |
'Authorization' => 'apikey ' . $this->api_key,
|
154 |
-
'User-Agent' => 'woocommerce-mailchimp/' .
|
155 |
),
|
156 |
);
|
157 |
|
@@ -216,7 +221,7 @@ class SS_WC_MailChimp_API {
|
|
216 |
*/
|
217 |
private function maybe_log( $resource, $method, $args, $response ) {
|
218 |
|
219 |
-
if ( $this->debug ) {
|
220 |
$this->log->add( 'woocommerce-mailchimp', "MailChimp API Call RESOURCE: $resource \n METHOD: $method \n BODY: " . print_r( $args, true ) . " \n RESPONSE: " . print_r( $response, true ) );
|
221 |
}
|
222 |
|
42 |
*/
|
43 |
private $last_error;
|
44 |
|
45 |
+
/**
|
46 |
+
* @var WC_Logger
|
47 |
+
*/
|
48 |
+
private $log;
|
49 |
+
|
50 |
/**
|
51 |
* Create a new instance
|
52 |
* @param string $api_key MailChimp API key
|
56 |
|
57 |
$this->debug = $debug;
|
58 |
|
59 |
+
if ( $this->debug === true ) {
|
60 |
$this->log = new WC_Logger();
|
61 |
}
|
62 |
|
75 |
*/
|
76 |
public function get( $resource, $args = array() ) {
|
77 |
|
78 |
+
if ( is_array( $args) && ! array_key_exists( 'count', $args ) ) {
|
79 |
$args['count'] = 10;
|
80 |
}
|
81 |
|
156 |
'Content-Type' => 'application/json',
|
157 |
'Accept' => 'application/json',
|
158 |
'Authorization' => 'apikey ' . $this->api_key,
|
159 |
+
'User-Agent' => 'woocommerce-mailchimp/' . SS_WC_MAILCHIMP_VERSION . '; WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
160 |
),
|
161 |
);
|
162 |
|
221 |
*/
|
222 |
private function maybe_log( $resource, $method, $args, $response ) {
|
223 |
|
224 |
+
if ( $this->debug === true ) {
|
225 |
$this->log->add( 'woocommerce-mailchimp', "MailChimp API Call RESOURCE: $resource \n METHOD: $method \n BODY: " . print_r( $args, true ) . " \n RESPONSE: " . print_r( $response, true ) );
|
226 |
}
|
227 |
|
includes/class-ss-wc-mailchimp-container.php
DELETED
@@ -1,121 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Class SS_WC_MailChimp_Container
|
5 |
-
*
|
6 |
-
* @access private
|
7 |
-
* @ignore
|
8 |
-
*/
|
9 |
-
class SS_WC_MailChimp_Container implements ArrayAccess {
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @var array
|
13 |
-
*/
|
14 |
-
protected $services = array();
|
15 |
-
|
16 |
-
/**
|
17 |
-
* @var array
|
18 |
-
*/
|
19 |
-
protected $resolved_services = array();
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @param $name
|
23 |
-
* @return boolean
|
24 |
-
*/
|
25 |
-
public function has( $name ) {
|
26 |
-
return isset( $this->services[ $name ] );
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @param $name
|
31 |
-
*
|
32 |
-
* @return mixed
|
33 |
-
* @throws Exception
|
34 |
-
*/
|
35 |
-
public function get( $name ) {
|
36 |
-
|
37 |
-
if( ! $this->has( $name ) ) {
|
38 |
-
throw new Exception( sprintf( 'No service named %s was registered.', $name ) );
|
39 |
-
}
|
40 |
-
|
41 |
-
$service = $this->services[ $name ];
|
42 |
-
|
43 |
-
// is this a resolvable service?
|
44 |
-
if( is_callable( $service ) ) {
|
45 |
-
|
46 |
-
// resolve service if it's not resolved yet
|
47 |
-
if( ! isset( $this->resolved_services[ $name ] ) ) {
|
48 |
-
$this->resolved_services[ $name ] = call_user_func( $service );
|
49 |
-
}
|
50 |
-
|
51 |
-
return $this->resolved_services[ $name ];
|
52 |
-
}
|
53 |
-
|
54 |
-
return $this->services[ $name ];
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* (PHP 5 >= 5.0.0)<br/>
|
59 |
-
* Whether a offset exists
|
60 |
-
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
|
61 |
-
*
|
62 |
-
* @param mixed $offset <p>
|
63 |
-
* An offset to check for.
|
64 |
-
* </p>
|
65 |
-
*
|
66 |
-
* @return boolean true on success or false on failure.
|
67 |
-
* </p>
|
68 |
-
* <p>
|
69 |
-
* The return value will be casted to boolean if non-boolean was returned.
|
70 |
-
*/
|
71 |
-
public function offsetExists( $offset ) {
|
72 |
-
return $this->has( $offset );
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* (PHP 5 >= 5.0.0)<br/>
|
77 |
-
* Offset to retrieve
|
78 |
-
* @link http://php.net/manual/en/arrayaccess.offsetget.php
|
79 |
-
*
|
80 |
-
* @param mixed $offset <p>
|
81 |
-
* The offset to retrieve.
|
82 |
-
* </p>
|
83 |
-
*
|
84 |
-
* @return mixed Can return all value types.
|
85 |
-
*/
|
86 |
-
public function offsetGet( $offset ) {
|
87 |
-
return $this->get( $offset );
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* (PHP 5 >= 5.0.0)<br/>
|
92 |
-
* Offset to set
|
93 |
-
* @link http://php.net/manual/en/arrayaccess.offsetset.php
|
94 |
-
*
|
95 |
-
* @param mixed $offset <p>
|
96 |
-
* The offset to assign the value to.
|
97 |
-
* </p>
|
98 |
-
* @param mixed $value <p>
|
99 |
-
* The value to set.
|
100 |
-
* </p>
|
101 |
-
*
|
102 |
-
* @return void
|
103 |
-
*/
|
104 |
-
public function offsetSet( $offset, $value ) {
|
105 |
-
$this->services[ $offset ] = $value;
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* (PHP 5 >= 5.0.0)<br/>
|
110 |
-
* Offset to unset
|
111 |
-
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
|
112 |
-
*
|
113 |
-
* @param mixed $offset <p>
|
114 |
-
* The offset to unset.
|
115 |
-
* </p>
|
116 |
-
*
|
117 |
-
* @return void
|
118 |
-
*/
|
119 |
-
public function offsetUnset( $offset ) {
|
120 |
-
unset( $this->services[ $offset ] );
|
121 |
-
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-ss-wc-mailchimp-handler.php
CHANGED
@@ -16,28 +16,6 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
16 |
*/
|
17 |
class SS_WC_MailChimp_Handler {
|
18 |
|
19 |
-
private static $_instance;
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Singleton instance
|
23 |
-
*
|
24 |
-
* @return SS_WC_Settings_MailChimp SS_WC_Settings_MailChimp object
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
|
28 |
-
if ( empty( self::$_instance ) ) {
|
29 |
-
self::$_instance = new self;
|
30 |
-
}
|
31 |
-
|
32 |
-
return self::$_instance;
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Instance of the API class.
|
37 |
-
* @var Object
|
38 |
-
*/
|
39 |
-
private static $api_instance = null;
|
40 |
-
|
41 |
/**
|
42 |
* Constructor
|
43 |
*
|
@@ -259,16 +237,53 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
259 |
}
|
260 |
|
261 |
add_action( $opt_in_checkbox_display_location, array( $this, 'maybe_add_checkout_fields' ) );
|
|
|
262 |
add_filter( 'default_checkout_ss_wc_mailchimp_opt_in', array( $this, 'checkbox_default_status' ) );
|
263 |
|
264 |
// Maybe save the "opt-in" field on the checkout
|
265 |
-
add_action( 'woocommerce_checkout_update_order_meta',
|
|
|
|
|
266 |
|
267 |
add_action( 'wp_ajax_ss_wc_mailchimp_get_lists', array( $this, 'ajax_get_lists' ) );
|
|
|
268 |
add_action( 'wp_ajax_ss_wc_mailchimp_get_interest_groups', array( $this, 'ajax_get_interest_groups' ) );
|
269 |
|
270 |
} //end function ensure_tab
|
271 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
272 |
/**
|
273 |
* Return all lists from MailChimp to be used in select fields
|
274 |
*
|
@@ -287,7 +302,7 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
287 |
|
288 |
$api_key = $_POST['data']['api_key'];
|
289 |
|
290 |
-
$lists = $this->
|
291 |
|
292 |
$results = array_merge( array('' => 'Select a list...'), $lists );
|
293 |
|
@@ -312,11 +327,11 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
312 |
|
313 |
try {
|
314 |
|
315 |
-
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
316 |
|
317 |
-
|
318 |
|
319 |
-
}
|
320 |
|
321 |
if ( !$_POST['data']['list_id'] || empty( $_POST['data']['list_id'] ) ) {
|
322 |
|
@@ -324,11 +339,9 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
324 |
|
325 |
}
|
326 |
|
327 |
-
$api_key = $_POST['data']['api_key'];
|
328 |
-
|
329 |
$list_id = $_POST['data']['list_id'];
|
330 |
|
331 |
-
$interest_groups = $this->
|
332 |
|
333 |
$results = $interest_groups;
|
334 |
|
@@ -392,24 +405,12 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
392 |
* API Instance Singleton
|
393 |
* @return Object
|
394 |
*/
|
395 |
-
public function
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
// self::$api_instance = new SS_WC_MailChimp_API( ( $api_key ? $api_key : $this->api_key() ), $this->debug_enabled() );
|
402 |
-
// }
|
403 |
-
// return self::$api_instance;
|
404 |
-
if ( ! is_null( $api_key ) ) {
|
405 |
-
global $ss_wc_mailchimp;
|
406 |
-
|
407 |
-
// $ss_wc_mailchimp['api'] = new SS_WC_MailChimp( $api_key , $this->debug_enabled() );
|
408 |
-
$ss_wc_mailchimp['api'] = ss_wc_mailchimp_get_api( $api_key , $this->debug_enabled() );
|
409 |
-
|
410 |
-
delete_transient( 'sswcmc_lists' );
|
411 |
-
}
|
412 |
-
return ss_wc_mailchimp('api');
|
413 |
}
|
414 |
|
415 |
/**
|
@@ -469,14 +470,14 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
|
469 |
$this->log( sprintf( __( __METHOD__ . '(): Subscribing customer to MailChimp: %s', 'woocommerce-mailchimp' ), print_r( $options, true ) ) );
|
470 |
|
471 |
// Call API
|
472 |
-
$api_response = $this->
|
473 |
|
474 |
// Log api response
|
475 |
$this->log( sprintf( __( __METHOD__ . '(): MailChimp API response: %s', 'woocommerce-mailchimp' ), print_r( $api_response, true ) ) );
|
476 |
|
477 |
if ( $api_response === false ) {
|
478 |
// Format error message
|
479 |
-
$error_response = sprintf( __( __METHOD__ . '(): WooCommerce MailChimp subscription failed: %s (%s)', 'woocommerce-mailchimp' ), $this->
|
480 |
|
481 |
// Log
|
482 |
$this->log( $error_response );
|
16 |
*/
|
17 |
class SS_WC_MailChimp_Handler {
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
/**
|
20 |
* Constructor
|
21 |
*
|
237 |
}
|
238 |
|
239 |
add_action( $opt_in_checkbox_display_location, array( $this, 'maybe_add_checkout_fields' ) );
|
240 |
+
|
241 |
add_filter( 'default_checkout_ss_wc_mailchimp_opt_in', array( $this, 'checkbox_default_status' ) );
|
242 |
|
243 |
// Maybe save the "opt-in" field on the checkout
|
244 |
+
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'maybe_save_checkout_fields' ) );
|
245 |
+
|
246 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_account', array( $this, 'ajax_get_account' ) );
|
247 |
|
248 |
add_action( 'wp_ajax_ss_wc_mailchimp_get_lists', array( $this, 'ajax_get_lists' ) );
|
249 |
+
|
250 |
add_action( 'wp_ajax_ss_wc_mailchimp_get_interest_groups', array( $this, 'ajax_get_interest_groups' ) );
|
251 |
|
252 |
} //end function ensure_tab
|
253 |
|
254 |
+
/**
|
255 |
+
* Return all lists from MailChimp to be used in select fields
|
256 |
+
*
|
257 |
+
* @access public
|
258 |
+
* @return array
|
259 |
+
*/
|
260 |
+
public function ajax_get_account() {
|
261 |
+
|
262 |
+
try {
|
263 |
+
|
264 |
+
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
265 |
+
|
266 |
+
throw new Exception( __( 'Please enter an api key.', 'woocommerce-mailchimp' ) );
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
$api_key = $_POST['data']['api_key'];
|
271 |
+
|
272 |
+
$account = $this->mailchimp()->get_account( $api_key );
|
273 |
+
|
274 |
+
$results = $account;
|
275 |
+
|
276 |
+
}
|
277 |
+
catch ( Exception $e ) {
|
278 |
+
|
279 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
return $this->toJSON( $results );
|
284 |
+
|
285 |
+
} //end function ajax_get_account
|
286 |
+
|
287 |
/**
|
288 |
* Return all lists from MailChimp to be used in select fields
|
289 |
*
|
302 |
|
303 |
$api_key = $_POST['data']['api_key'];
|
304 |
|
305 |
+
$lists = $this->mailchimp( $api_key )->get_lists();
|
306 |
|
307 |
$results = array_merge( array('' => 'Select a list...'), $lists );
|
308 |
|
327 |
|
328 |
try {
|
329 |
|
330 |
+
// if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
331 |
|
332 |
+
// return $this->toJSON( array( '' => __( 'Enter your api key above to see your lists', 'ss_wc_mailchimp' ) ) );
|
333 |
|
334 |
+
// }
|
335 |
|
336 |
if ( !$_POST['data']['list_id'] || empty( $_POST['data']['list_id'] ) ) {
|
337 |
|
339 |
|
340 |
}
|
341 |
|
|
|
|
|
342 |
$list_id = $_POST['data']['list_id'];
|
343 |
|
344 |
+
$interest_groups = $this->mailchimp()->get_interest_categories_with_interests( $list_id );
|
345 |
|
346 |
$results = $interest_groups;
|
347 |
|
405 |
* API Instance Singleton
|
406 |
* @return Object
|
407 |
*/
|
408 |
+
public function mailchimp( $api_key = null ) {
|
409 |
+
|
410 |
+
$sswcmc = SSWCMC();
|
411 |
+
|
412 |
+
return $sswcmc->mailchimp( $api_key );
|
413 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
414 |
}
|
415 |
|
416 |
/**
|
470 |
$this->log( sprintf( __( __METHOD__ . '(): Subscribing customer to MailChimp: %s', 'woocommerce-mailchimp' ), print_r( $options, true ) ) );
|
471 |
|
472 |
// Call API
|
473 |
+
$api_response = $this->mailchimp()->subscribe( $list_id, $email, $email_type, $merge_tags, $interest_groups, $double_optin );
|
474 |
|
475 |
// Log api response
|
476 |
$this->log( sprintf( __( __METHOD__ . '(): MailChimp API response: %s', 'woocommerce-mailchimp' ), print_r( $api_response, true ) ) );
|
477 |
|
478 |
if ( $api_response === false ) {
|
479 |
// Format error message
|
480 |
+
$error_response = sprintf( __( __METHOD__ . '(): WooCommerce MailChimp subscription failed: %s (%s)', 'woocommerce-mailchimp' ), $this->mailchimp()->get_error_message(), $this->mailchimp()->get_error_code() );
|
481 |
|
482 |
// Log
|
483 |
$this->log( $error_response );
|
includes/class-ss-wc-mailchimp-plugin.php
CHANGED
@@ -5,17 +5,42 @@
|
|
5 |
*/
|
6 |
final class SS_WC_MailChimp_Plugin {
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
public static function version() {
|
15 |
return self::$version;
|
16 |
-
// $plugin_data = get_plugin_data( SS_WC_MAILCHIMP_FILE );
|
17 |
-
// $plugin_version = $plugin_data['Version'];
|
18 |
-
// return $plugin_version;
|
19 |
}
|
20 |
|
21 |
/**
|
@@ -23,61 +48,110 @@ final class SS_WC_MailChimp_Plugin {
|
|
23 |
*
|
24 |
* @return SS_WC_MailChimp_Plugin SS_WC_MailChimp_Plugin object
|
25 |
*/
|
26 |
-
public static function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
-
if ( empty( self::$_instance ) ) {
|
29 |
-
self::$_instance = new self;
|
30 |
}
|
31 |
|
32 |
-
return self::$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
-
*
|
37 |
-
*
|
38 |
-
* @access public
|
39 |
* @return void
|
40 |
*/
|
41 |
-
public function
|
42 |
|
43 |
-
$this->
|
44 |
-
$this->namespace = 'ss_wc_' . $this->id;
|
45 |
-
$this->label = __( 'MailChimp', 'woocommerce-mailchimp' );
|
46 |
|
47 |
-
|
|
|
|
|
48 |
|
49 |
-
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
$this->
|
54 |
|
55 |
-
$this->
|
56 |
|
57 |
-
|
|
|
58 |
|
59 |
-
|
60 |
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
/**
|
64 |
* Define Plugin Constants.
|
65 |
*/
|
66 |
private function define_constants() {
|
67 |
-
|
68 |
-
global $woocommerce;
|
69 |
|
70 |
-
|
|
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
}
|
75 |
|
76 |
-
|
|
|
77 |
|
78 |
-
$
|
79 |
|
80 |
-
|
|
|
|
|
81 |
|
82 |
/**
|
83 |
* Define constant if not already set.
|
@@ -89,21 +163,13 @@ final class SS_WC_MailChimp_Plugin {
|
|
89 |
if ( ! defined( $name ) ) {
|
90 |
define( $name, $value );
|
91 |
}
|
92 |
-
}
|
93 |
|
94 |
/**
|
95 |
* Include required core plugin files
|
96 |
*/
|
97 |
public function includes() {
|
98 |
|
99 |
-
if ( ! class_exists( 'SS_WC_MailChimp_Container' ) ) {
|
100 |
-
require_once( 'class-ss-wc-mailchimp-container.php' );
|
101 |
-
}
|
102 |
-
|
103 |
-
if ( ! function_exists( 'ss_wc_mailchimp' ) ) {
|
104 |
-
require_once( 'functions.php' );
|
105 |
-
}
|
106 |
-
|
107 |
require_once( 'lib/class-ss-system-info.php' );
|
108 |
|
109 |
require_once( 'class-ss-wc-mailchimp-api.php' );
|
@@ -112,31 +178,7 @@ final class SS_WC_MailChimp_Plugin {
|
|
112 |
|
113 |
require_once( 'class-ss-wc-mailchimp-handler.php' );
|
114 |
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Initialize the plugin
|
119 |
-
* @return void
|
120 |
-
*/
|
121 |
-
private function init() {
|
122 |
-
|
123 |
-
if ( ! class_exists( 'WC_Integration' ) )
|
124 |
-
return;
|
125 |
-
|
126 |
-
global $ss_wc_mailchimp;
|
127 |
-
|
128 |
-
/**
|
129 |
-
* @global SS_WC_MailChimp_Container $GLOBALS['ss_wc_mailchimp']
|
130 |
-
* @name $mc4wp
|
131 |
-
*/
|
132 |
-
$ss_wc_mailchimp = ss_wc_mailchimp();
|
133 |
-
$ss_wc_mailchimp['mailchimp'] = 'ss_wc_mailchimp_get_mailchimp';
|
134 |
-
$ss_wc_mailchimp['api'] = 'ss_wc_mailchimp_get_api';
|
135 |
-
|
136 |
-
// Set up localization.
|
137 |
-
$this->load_plugin_textdomain();
|
138 |
-
|
139 |
-
}
|
140 |
|
141 |
/**
|
142 |
* Load Localization files.
|
@@ -144,31 +186,60 @@ final class SS_WC_MailChimp_Plugin {
|
|
144 |
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
|
145 |
*
|
146 |
* Locales found in:
|
147 |
-
* - WP_LANG_DIR/woocommerce-mailchimp/woocommerce-mailchimp-
|
148 |
-
* - WP_CONTENT_DIR/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp-
|
149 |
*/
|
150 |
public function load_plugin_textdomain() {
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-mailchimp' );
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
/**
|
158 |
* Add plugin hooks
|
159 |
*/
|
160 |
private function add_hooks() {
|
|
|
161 |
// Add the "Settings" links on the Plugins administration screen
|
162 |
if ( is_admin() ) {
|
|
|
163 |
add_filter( 'plugin_action_links_' . plugin_basename( SS_WC_MAILCHIMP_FILE ), array( $this, 'action_links' ) );
|
|
|
164 |
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_mailchimp_settings' ) );
|
165 |
|
166 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts') );
|
167 |
|
168 |
}
|
169 |
|
170 |
-
|
171 |
-
}
|
172 |
|
173 |
/**
|
174 |
* Add Settings link to plugins list
|
@@ -182,7 +253,8 @@ final class SS_WC_MailChimp_Plugin {
|
|
182 |
);
|
183 |
|
184 |
return array_merge( $plugin_links, $links );
|
185 |
-
|
|
|
186 |
|
187 |
/**
|
188 |
* Add the MailChimp settings tab to WooCommerce
|
@@ -204,16 +276,16 @@ final class SS_WC_MailChimp_Plugin {
|
|
204 |
public function enqueue_scripts() {
|
205 |
|
206 |
// Plugin scripts and styles
|
207 |
-
wp_register_script( 'woocommerce-mailchimp-admin',
|
208 |
-
wp_register_style( 'woocommerce-mailchimp',
|
209 |
|
210 |
// Localize javascript messages
|
211 |
$translation_array = array(
|
212 |
-
'connecting_to_mailchimp'
|
213 |
-
'
|
214 |
-
'error_loading_groups'
|
215 |
-
'select_groups_placeholder'
|
216 |
-
'interest_groups_not_enabled'
|
217 |
);
|
218 |
wp_localize_script( 'woocommerce-mailchimp-admin', 'SS_WC_MailChimp_Messages', $translation_array );
|
219 |
|
@@ -255,8 +327,19 @@ final class SS_WC_MailChimp_Plugin {
|
|
255 |
*/
|
256 |
public static function deactivate( $network_wide ) {
|
257 |
|
258 |
-
|
259 |
|
260 |
} //end function deactivate
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
} //end final class SS_WC_MailChimp_Plugin
|
5 |
*/
|
6 |
final class SS_WC_MailChimp_Plugin {
|
7 |
|
8 |
+
/**
|
9 |
+
* Plugin version
|
10 |
+
* @var string
|
11 |
+
*/
|
12 |
+
private static $version = '2.0.9';
|
13 |
|
14 |
+
/**
|
15 |
+
* Plugin singleton instance
|
16 |
+
* @var SS_WC_MailChimp_Plugin
|
17 |
+
*/
|
18 |
+
private static $instance;
|
19 |
|
20 |
+
/**
|
21 |
+
* Plugin namespace
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
private $namespace = 'ss_wc_mailchimp';
|
25 |
|
26 |
+
/**
|
27 |
+
* Plugin settings
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
private $settings;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Plugin MailChimp helper instance
|
34 |
+
* @var SS_WC_MailChimp
|
35 |
+
*/
|
36 |
+
private $mailchimp;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Returns the plugin version
|
40 |
+
* @return string
|
41 |
+
*/
|
42 |
public static function version() {
|
43 |
return self::$version;
|
|
|
|
|
|
|
44 |
}
|
45 |
|
46 |
/**
|
48 |
*
|
49 |
* @return SS_WC_MailChimp_Plugin SS_WC_MailChimp_Plugin object
|
50 |
*/
|
51 |
+
public static function instance() {
|
52 |
+
|
53 |
+
if ( empty( self::$instance ) && ! ( self::$instance instanceof SS_WC_MailChimp_Plugin ) ) {
|
54 |
+
|
55 |
+
self::$instance = new SS_WC_MailChimp_Plugin;
|
56 |
+
self::$instance->define_constants();
|
57 |
+
|
58 |
+
add_action( 'plugins_loaded', array( self::$instance, 'load_plugin_textdomain' ) );
|
59 |
+
|
60 |
+
self::$instance->save_settings();
|
61 |
+
self::$instance->settings();
|
62 |
+
self::$instance->includes();
|
63 |
+
self::$instance->mailchimp();
|
64 |
+
self::$instance->handler = new SS_WC_MailChimp_Handler();
|
65 |
+
self::$instance->add_hooks();
|
66 |
+
|
67 |
+
do_action( 'ss_wc_mailchimp_loaded' );
|
68 |
|
|
|
|
|
69 |
}
|
70 |
|
71 |
+
return self::$instance;
|
72 |
+
|
73 |
+
} //end function instance
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Gets the plugin db settings
|
77 |
+
* @param boolean $refresh refresh the settings from DB?
|
78 |
+
* @return array The plugin db settings
|
79 |
+
*/
|
80 |
+
public function settings( $refresh = false ) {
|
81 |
+
|
82 |
+
if ( empty( $this->settings ) ) {
|
83 |
+
|
84 |
+
$defaults = require( SS_WC_MAILCHIMP_DIR . 'config/default-settings.php' );
|
85 |
+
$settings = array();
|
86 |
+
|
87 |
+
foreach ( $defaults as $key => $val ) {
|
88 |
+
$settings[ $key ] = get_option( 'ss_wc_mailchimp_' . $key );
|
89 |
+
}
|
90 |
+
|
91 |
+
$this->settings = array_merge( $defaults, $settings );
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
return $this->settings;
|
96 |
}
|
97 |
|
98 |
/**
|
99 |
+
* Saves the settings back to the DB
|
|
|
|
|
100 |
* @return void
|
101 |
*/
|
102 |
+
public function save_settings() {
|
103 |
|
104 |
+
$settings = $this->settings();
|
|
|
|
|
105 |
|
106 |
+
foreach ( $settings as $key => $value ) {
|
107 |
+
update_option( $this->namespace_prefixed( $key ), $value );
|
108 |
+
}
|
109 |
|
110 |
+
} //end function save_settings
|
111 |
|
112 |
+
/**
|
113 |
+
* Gets the MailChimp Helper
|
114 |
+
* @param string $api_key MailChimp API Key
|
115 |
+
* @param boolean $debug Debug mode enabled/disabled
|
116 |
+
* @return SS_WC_MailChimp MailChimp Helper class
|
117 |
+
*/
|
118 |
+
public function mailchimp( $api_key = null, $debug = false ) {
|
119 |
|
120 |
+
$settings = $this->settings();
|
121 |
|
122 |
+
if ( empty( $this->mailchimp ) || ! is_null( $api_key ) ) {
|
123 |
|
124 |
+
$api_key = $api_key ? $api_key : $settings['api_key'];
|
125 |
+
$debug = $debug ? $debug : $settings['debug'];
|
126 |
|
127 |
+
$this->mailchimp = new SS_WC_MailChimp( $api_key, $debug );
|
128 |
|
129 |
+
delete_transient( 'sswcmc_lists' );
|
130 |
+
}
|
131 |
+
|
132 |
+
return $this->mailchimp;
|
133 |
+
|
134 |
+
} //end function mailchimp
|
135 |
|
136 |
/**
|
137 |
* Define Plugin Constants.
|
138 |
*/
|
139 |
private function define_constants() {
|
|
|
|
|
140 |
|
141 |
+
// Plugin version.
|
142 |
+
$this->define( 'SS_WC_MAILCHIMP_VERSION', self::version() );
|
143 |
|
144 |
+
// Plugin Folder Path.
|
145 |
+
$this->define( 'SS_WC_MAILCHIMP_DIR', plugin_dir_path( SS_WC_MAILCHIMP_FILE ) );
|
|
|
146 |
|
147 |
+
// Plugin Folder URL.
|
148 |
+
$this->define('SS_WC_MAILCHIMP_URL', plugin_dir_url( SS_WC_MAILCHIMP_FILE ) );
|
149 |
|
150 |
+
$settings_url = admin_url( 'admin.php?page=wc-settings&tab=mailchimp' );
|
151 |
|
152 |
+
$this->define( 'SS_WC_MAILCHIMP_SETTINGS_URL', $settings_url );
|
153 |
+
|
154 |
+
} //function define_constants
|
155 |
|
156 |
/**
|
157 |
* Define constant if not already set.
|
163 |
if ( ! defined( $name ) ) {
|
164 |
define( $name, $value );
|
165 |
}
|
166 |
+
} //function define
|
167 |
|
168 |
/**
|
169 |
* Include required core plugin files
|
170 |
*/
|
171 |
public function includes() {
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
require_once( 'lib/class-ss-system-info.php' );
|
174 |
|
175 |
require_once( 'class-ss-wc-mailchimp-api.php' );
|
178 |
|
179 |
require_once( 'class-ss-wc-mailchimp-handler.php' );
|
180 |
|
181 |
+
} //end function includes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
|
183 |
/**
|
184 |
* Load Localization files.
|
186 |
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
|
187 |
*
|
188 |
* Locales found in:
|
189 |
+
* - WP_LANG_DIR/plugins/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
190 |
+
* - WP_CONTENT_DIR/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp-{lang}_{country}.mo
|
191 |
*/
|
192 |
public function load_plugin_textdomain() {
|
193 |
+
|
194 |
+
// Set filter for plugin's languages directory.
|
195 |
+
$woocommerce_mailchimp_lang_dir = dirname( plugin_basename( SS_WC_MAILCHIMP_FILE ) ) . '/languages/';
|
196 |
+
|
197 |
+
// Traditional WordPress plugin locale filter.
|
198 |
+
// get locale in {lang}_{country} format (e.g. en_US)
|
199 |
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-mailchimp' );
|
200 |
|
201 |
+
$mofile = sprintf( '%1$s-%2$s.mo', 'woocommerce-mailchimp', $locale );
|
202 |
+
|
203 |
+
// Look for wp-content/languages/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
204 |
+
$mofile_global1 = WP_LANG_DIR . '/woocommerce-mailchimp/' . $mofile;
|
205 |
+
|
206 |
+
// Look in wp-content/languages/plugins/woocommerce-mailchimp
|
207 |
+
$mofile_global2 = WP_LANG_DIR . '/plugins/woocommerce-mailchimp/' . $mofile;
|
208 |
+
|
209 |
+
if ( file_exists( $mofile_global1 ) ) {
|
210 |
+
|
211 |
+
load_textdomain( 'woocommerce-mailchimp', $mofile_global1 );
|
212 |
+
|
213 |
+
} elseif ( file_exists( $mofile_global2 ) ) {
|
214 |
+
|
215 |
+
load_textdomain( 'woocommerce-mailchimp', $mofile_global2 );
|
216 |
+
|
217 |
+
} else {
|
218 |
+
|
219 |
+
// Load the default language files.
|
220 |
+
load_plugin_textdomain( 'woocommerce-mailchimp', false, $woocommerce_mailchimp_lang_dir );
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
} //end function load_plugin_textdomain
|
225 |
|
226 |
/**
|
227 |
* Add plugin hooks
|
228 |
*/
|
229 |
private function add_hooks() {
|
230 |
+
|
231 |
// Add the "Settings" links on the Plugins administration screen
|
232 |
if ( is_admin() ) {
|
233 |
+
|
234 |
add_filter( 'plugin_action_links_' . plugin_basename( SS_WC_MAILCHIMP_FILE ), array( $this, 'action_links' ) );
|
235 |
+
|
236 |
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_mailchimp_settings' ) );
|
237 |
|
238 |
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts') );
|
239 |
|
240 |
}
|
241 |
|
242 |
+
} //end function add_hooks
|
|
|
243 |
|
244 |
/**
|
245 |
* Add Settings link to plugins list
|
253 |
);
|
254 |
|
255 |
return array_merge( $plugin_links, $links );
|
256 |
+
|
257 |
+
} //end function action_links
|
258 |
|
259 |
/**
|
260 |
* Add the MailChimp settings tab to WooCommerce
|
276 |
public function enqueue_scripts() {
|
277 |
|
278 |
// Plugin scripts and styles
|
279 |
+
wp_register_script( 'woocommerce-mailchimp-admin', SS_WC_MAILCHIMP_URL . 'assets/js/woocommerce-mailchimp-admin.js', array( 'jquery' ), self::version() );
|
280 |
+
wp_register_style( 'woocommerce-mailchimp', SS_WC_MAILCHIMP_URL . 'assets/css/style.css', array(), self::version() );
|
281 |
|
282 |
// Localize javascript messages
|
283 |
$translation_array = array(
|
284 |
+
'connecting_to_mailchimp' => __( 'Connecting to MailChimp', 'woocommerce-mailchimp' ),
|
285 |
+
'error_loading_account' => __( 'Error. Please check your api key.', 'woocommerce-mailchimp' ),
|
286 |
+
'error_loading_groups' => __( 'Error loading groups. Please check your MailChimp Interest Groups for the selected list.', 'woocommerce-mailchimp' ),
|
287 |
+
'select_groups_placeholder' => __( 'Select one or more groups (optional)', 'woocommerce-mailchimp' ),
|
288 |
+
'interest_groups_not_enabled' => __( 'This list does not have interest groups enabled', 'woocommerce-mailchimp' ),
|
289 |
);
|
290 |
wp_localize_script( 'woocommerce-mailchimp-admin', 'SS_WC_MailChimp_Messages', $translation_array );
|
291 |
|
327 |
*/
|
328 |
public static function deactivate( $network_wide ) {
|
329 |
|
330 |
+
// Placeholder
|
331 |
|
332 |
} //end function deactivate
|
333 |
|
334 |
+
/**
|
335 |
+
* Returns namespace prefixed value
|
336 |
+
* @param string $suffix The suffix to prefix
|
337 |
+
* @return string
|
338 |
+
*/
|
339 |
+
private function namespace_prefixed( $suffix ) {
|
340 |
+
|
341 |
+
return $this->namespace . '_' . $suffix;
|
342 |
+
|
343 |
+
} // end function namespace_prefixed
|
344 |
+
|
345 |
} //end final class SS_WC_MailChimp_Plugin
|
includes/class-ss-wc-mailchimp.php
CHANGED
@@ -17,12 +17,18 @@ class SS_WC_MailChimp {
|
|
17 |
*/
|
18 |
public $api;
|
19 |
|
|
|
|
|
|
|
|
|
20 |
/**
|
21 |
* Create a new instance
|
22 |
* @param string $api_key MailChimp API key
|
23 |
*/
|
24 |
function __construct( $api_key, $debug = false ) {
|
25 |
|
|
|
|
|
26 |
$this->debug = $debug;
|
27 |
|
28 |
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-api.php' );
|
@@ -30,6 +36,32 @@ class SS_WC_MailChimp {
|
|
30 |
|
31 |
} //end function __construct
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
/**
|
34 |
* Get list
|
35 |
*
|
17 |
*/
|
18 |
public $api;
|
19 |
|
20 |
+
public $api_key;
|
21 |
+
|
22 |
+
public $debug;
|
23 |
+
|
24 |
/**
|
25 |
* Create a new instance
|
26 |
* @param string $api_key MailChimp API key
|
27 |
*/
|
28 |
function __construct( $api_key, $debug = false ) {
|
29 |
|
30 |
+
$this->api_key = $api_key;
|
31 |
+
|
32 |
$this->debug = $debug;
|
33 |
|
34 |
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-api.php' );
|
36 |
|
37 |
} //end function __construct
|
38 |
|
39 |
+
/**
|
40 |
+
* Get account
|
41 |
+
*
|
42 |
+
* @access public
|
43 |
+
* @return mixed
|
44 |
+
*/
|
45 |
+
public function get_account( $api_key = null ) {
|
46 |
+
|
47 |
+
$resource = '';
|
48 |
+
|
49 |
+
$api = $this->api;
|
50 |
+
|
51 |
+
if ( ! empty( $api_key ) ) {
|
52 |
+
$api = new SS_WC_MailChimp_API( $api_key, $this->debug );
|
53 |
+
}
|
54 |
+
|
55 |
+
$account = $api->get( $resource );
|
56 |
+
|
57 |
+
if ( ! $account ) {
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
|
61 |
+
return $account;
|
62 |
+
|
63 |
+
} //end function get_account
|
64 |
+
|
65 |
/**
|
66 |
* Get list
|
67 |
*
|
includes/class-ss-wc-settings-mailchimp.php
CHANGED
@@ -33,12 +33,6 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
33 |
return self::$_instance;
|
34 |
}
|
35 |
|
36 |
-
/**
|
37 |
-
* Instance of the API class.
|
38 |
-
* @var Object
|
39 |
-
*/
|
40 |
-
private static $api_instance = null;
|
41 |
-
|
42 |
/**
|
43 |
* Constructor
|
44 |
*
|
@@ -204,7 +198,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
204 |
// Check required fields
|
205 |
if ( $this->is_enabled() && ! $this->has_api_key() ) {
|
206 |
// Show notice
|
207 |
-
echo $this->get_message( sprintf( __( 'WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter your api key %
|
208 |
);
|
209 |
}
|
210 |
}
|
@@ -251,13 +245,13 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
251 |
// */
|
252 |
public function get_sections() {
|
253 |
|
254 |
-
$sections = array(
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
'troubleshooting'
|
260 |
-
|
261 |
|
262 |
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
|
263 |
}
|
@@ -292,7 +286,12 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
292 |
global $current_section;
|
293 |
|
294 |
$settings = $this->get_settings( $current_section );
|
|
|
295 |
WC_Admin_Settings::save_fields( $settings );
|
|
|
|
|
|
|
|
|
296 |
}
|
297 |
|
298 |
/**
|
@@ -304,213 +303,156 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
304 |
|
305 |
if ( '' === $current_section ) {
|
306 |
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
),
|
314 |
-
);
|
315 |
-
|
316 |
-
$settings[] = array(
|
317 |
-
'id' => $this->namespace_prefixed( 'api_key' ),
|
318 |
-
'title' => __( 'API Key', 'woocommerce-mailchimp' ),
|
319 |
-
'type' => 'text',
|
320 |
-
'desc' => sprintf( __( '%sLogin to MailChimp%s to look up your api key.', 'woocommerce-mailchimp' ), '<br/><a href="https://admin.mailchimp.com/account/api/" target="_blank">', '</a>'
|
321 |
),
|
322 |
-
'default' => '',
|
323 |
-
'css' => 'min-width:350px;',
|
324 |
-
'desc_tip' => 'Your API Key is required for the plugin to communicate with your MailChimp account.',
|
325 |
);
|
326 |
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
)
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
'class' => 'wc-enhanced-select',
|
367 |
-
'css' => 'min-width: 350px;',
|
368 |
-
// 'custom_attributes' => array(
|
369 |
-
// 'onchange' => 'form.submit()',
|
370 |
-
// ),
|
371 |
-
'desc_tip' => true,
|
372 |
-
);
|
373 |
-
// if ( array_key_exists( 'no_lists', $mailchimp_lists ) ) {
|
374 |
-
// $form_fields['list']['description'] = sprintf( __( 'There are no lists in your MailChimp account. <a href="%s" target="_blank">Click here</a> to create one.', 'woocommerce-mailchimp' ), 'https://admin.mailchimp.com/lists/new-list/' );
|
375 |
-
// }
|
376 |
-
|
377 |
-
$settings[] = array(
|
378 |
-
'id' => $this->namespace_prefixed( 'interest_groups' ),
|
379 |
-
'title' => __( 'Interest Groups', 'woocommerce-mailchimp' ),
|
380 |
-
'type' => 'multiselect',
|
381 |
-
'desc' => __( 'Optional: Interest groups to assign to subscribers.', 'woocommerce-mailchimp' ),
|
382 |
-
'default' => '',
|
383 |
-
'options' => $interest_groups,
|
384 |
-
'class' => 'wc-enhanced-select',
|
385 |
-
'custom_attributes' => array(
|
386 |
-
'placeholder' => __( 'Select interest groups...', 'woocommerce-mailchimp' ),
|
387 |
-
),
|
388 |
-
'css' => 'min-width: 350px;',
|
389 |
-
'desc_tip' => true,
|
390 |
-
);
|
391 |
-
|
392 |
-
// if ( is_array( $interest_groups ) && count( $interest_groups ) == 0 ) {
|
393 |
-
// // $form_fields['interest_groups']['description'] = __( 'Optional: Interest groups to assign to subscribers.', 'woocommerce-mailchimp' );
|
394 |
-
// $form_fields['interest_groups']['custom_attributes']['placeholder'] = __( 'This list has no interest groups.', 'woocommerce-mailchimp' );
|
395 |
-
// $form_fields['interest_groups']['custom_attributes']['disabled'] = 'disabled';
|
396 |
-
// } elseif ( !$this->has_list() ) {
|
397 |
-
// $form_fields['interest_groups']['custom_attributes']['placeholder'] = __( 'Select a list to see interests', 'woocommerce-mailchimp' );
|
398 |
-
// $form_fields['interest_groups']['custom_attributes']['disabled'] = 'disabled';
|
399 |
-
// }
|
400 |
-
$settings[] = array( 'type' => 'sectionend', 'id' => 'general_options' );
|
401 |
-
|
402 |
-
$settings[] = array(
|
403 |
-
'title' => __( 'Checkout Settings', 'woocommerce-mailchimp' ),
|
404 |
-
'type' => 'title',
|
405 |
-
'desc' => '',
|
406 |
-
'id' => 'checkout_settings'
|
407 |
);
|
408 |
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
);
|
423 |
-
|
424 |
-
$settings[] = array(
|
425 |
-
'id' => $this->namespace_prefixed( 'double_optin' ),
|
426 |
-
'title' => __( 'Double Opt-In', 'woocommerce-mailchimp' ),
|
427 |
-
'desc' => __( 'Enable Double Opt-In', 'woocommerce-mailchimp' ),
|
428 |
-
'type' => 'checkbox',
|
429 |
-
'default' => 'no',
|
430 |
-
'desc_tip' => __( 'If enabled, customers will receive an email prompting them to confirm their subscription to the list above.', 'woocommerce-mailchimp' ),
|
431 |
-
);
|
432 |
-
|
433 |
-
// $settings[] = array(
|
434 |
-
// 'id' => $this->namespace_prefixed( 'display_opt_in' ),
|
435 |
-
// 'title' => __( 'Display Opt-In Field', 'woocommerce-mailchimp' ),
|
436 |
-
// 'desc' => __( 'Display an Opt-In Field on Checkout', 'woocommerce-mailchimp' ),
|
437 |
-
// 'type' => 'checkbox',
|
438 |
-
// 'desc_tip' => __( '<p>Choose <strong>Automatically</strong> to subscribe customers silently upon checkout. Caution, this is without the customer\'s consent.</p> <p>Choose <strong>Ask for permission</strong> to show an "Opt-in" checkbox during checkout. Customers will only be subscribed to the list above if they opt-in.' , 'woocommerce-mailchimp' ),
|
439 |
-
// 'default' => no,
|
440 |
-
// );
|
441 |
-
|
442 |
-
$settings[] = array(
|
443 |
-
'id' => $this->namespace_prefixed( 'display_opt_in' ),
|
444 |
-
'title' => __( 'Subscribe Customers', 'woocommerce-mailchimp' ),
|
445 |
-
'desc' => __( '<p>Choose <strong>Ask for permission</strong> to show an "Opt-in" checkbox during checkout. Customers will only be subscribed to the list above if they opt-in. <p>Choose <strong>Automatically</strong> to subscribe customers silently upon checkout. Caution, this is without the customer\'s consent.</p>', 'woocommerce-mailchimp' ),
|
446 |
-
'type' => 'select',
|
447 |
-
'css' => 'min-width:300px;',
|
448 |
-
'class' => 'wc-enhanced-select',
|
449 |
-
'desc_tip' => true,
|
450 |
-
'default' => 'yes',
|
451 |
-
'options' => array(
|
452 |
-
// '0' => __( 'Disabled', 'woocommerce-mailchimp' ),
|
453 |
-
'yes' => __( 'Ask for permission', 'woocommerce-mailchimp' ),
|
454 |
-
'no' => __( 'Automatically', 'woocommerce-mailchimp' ),
|
455 |
-
)
|
456 |
);
|
457 |
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
'
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
)
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
)
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
|
515 |
$settings = apply_filters( $this->namespace_prefixed( 'settings_general' ), $settings );
|
516 |
|
@@ -546,7 +488,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
546 |
'id' => 'sysinfo',
|
547 |
'title' => __( 'System Info', 'woocommerce-mailchimp' ),
|
548 |
'type' => 'sysinfo',
|
549 |
-
'desc' => __( 'Copy the information below and send it to us when reporting an issue with the plugin
|
550 |
'desc_tip' => '',
|
551 |
);
|
552 |
|
@@ -556,8 +498,6 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
556 |
|
557 |
}
|
558 |
|
559 |
-
//}
|
560 |
-
|
561 |
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
|
562 |
|
563 |
} //end function get_settings
|
@@ -603,16 +543,12 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
603 |
* API Instance Singleton
|
604 |
* @return Object
|
605 |
*/
|
606 |
-
public function
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
// self::$api_instance = new SS_WC_MailChimp_API( $this->api_key(), $this->debug_enabled() );
|
613 |
-
// }
|
614 |
-
// return self::$api_instance;
|
615 |
-
return ss_wc_mailchimp('api');
|
616 |
}
|
617 |
|
618 |
/**
|
@@ -623,38 +559,32 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
623 |
*/
|
624 |
public function get_lists() {
|
625 |
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
} else {
|
632 |
-
return false;
|
633 |
-
}
|
634 |
-
|
635 |
-
if ( $mailchimp_lists === false ) {
|
636 |
|
637 |
-
|
638 |
-
add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
639 |
|
640 |
-
|
|
|
641 |
|
642 |
-
|
643 |
|
644 |
-
|
645 |
-
$default = array(
|
646 |
-
'no_lists' => __( 'Oops! No lists in your MailChimp account...', 'woocommerce-mailchimp' ),
|
647 |
-
);
|
648 |
-
add_action( 'admin_notices', array( $this, 'mailchimp_no_lists_found' ) );
|
649 |
-
} else {
|
650 |
-
$default = array(
|
651 |
-
'' => __( 'Select a list...', 'woocommerce-mailchimp' ),
|
652 |
-
);
|
653 |
-
set_transient( $this->namespace_prefixed( 'lists' ), $mailchimp_lists, 60 * 60 * 1 );
|
654 |
-
}
|
655 |
-
$mailchimp_lists = array_merge( $default, $mailchimp_lists );
|
656 |
|
657 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
658 |
|
659 |
return $mailchimp_lists;
|
660 |
|
@@ -668,8 +598,8 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
668 |
*/
|
669 |
public function get_interest_groups() {
|
670 |
|
671 |
-
if ( $this->
|
672 |
-
$interest_groups = $this->
|
673 |
} else {
|
674 |
return false;
|
675 |
}
|
@@ -703,7 +633,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
|
703 |
*/
|
704 |
public function mailchimp_api_error_msg() {
|
705 |
echo $this->get_message(
|
706 |
-
sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'woocommerce-mailchimp' ), $this->
|
707 |
sprintf( __( 'Please check your Settings %ssettings%s.', 'woocommerce-mailchimp' ), '<a href="' . WOOCOMMERCE_MAILCHIMP_SETTINGS_URL .'">', '</a>' )
|
708 |
);
|
709 |
} //end function mailchimp_api_error_msg
|
33 |
return self::$_instance;
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
/**
|
37 |
* Constructor
|
38 |
*
|
198 |
// Check required fields
|
199 |
if ( $this->is_enabled() && ! $this->has_api_key() ) {
|
200 |
// Show notice
|
201 |
+
echo $this->get_message( sprintf( __( 'WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter your api key <a href="%s">here</a>.', 'woocommerce-mailchimp' ), WOOCOMMERCE_MAILCHIMP_SETTINGS_URL )
|
202 |
);
|
203 |
}
|
204 |
}
|
245 |
// */
|
246 |
public function get_sections() {
|
247 |
|
248 |
+
$sections = array();
|
249 |
+
|
250 |
+
$sections[''] = __( 'General', 'woocommerce-mailchimp' );
|
251 |
+
|
252 |
+
if ( $this->has_api_key() ) {
|
253 |
+
$sections['troubleshooting'] = __( 'Troubleshooting', 'woocommerce-mailchimp' );
|
254 |
+
}
|
255 |
|
256 |
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
|
257 |
}
|
286 |
global $current_section;
|
287 |
|
288 |
$settings = $this->get_settings( $current_section );
|
289 |
+
|
290 |
WC_Admin_Settings::save_fields( $settings );
|
291 |
+
|
292 |
+
if ( !isset( $_POST[ 'ss_wc_mailchimp_api_key' ] ) || empty( $_POST[ 'ss_wc_mailchimp_api_key' ] ) ) {
|
293 |
+
delete_transient( 'sswcmc_lists' );
|
294 |
+
}
|
295 |
}
|
296 |
|
297 |
/**
|
303 |
|
304 |
if ( '' === $current_section ) {
|
305 |
|
306 |
+
$settings = array(
|
307 |
+
array(
|
308 |
+
'title' => __( 'MailChimp', 'woocommerce-mailchimp' ),
|
309 |
+
'type' => 'title',
|
310 |
+
'desc' => __( 'Enter your MailChimp settings below to control how WooCommerce integrates with your MailChimp account.', 'woocommerce-mailchimp' ),
|
311 |
+
'id' => 'general_options',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
),
|
|
|
|
|
|
|
313 |
);
|
314 |
|
315 |
+
$settings[] = array(
|
316 |
+
'id' => $this->namespace_prefixed( 'api_key' ),
|
317 |
+
'title' => __( 'API Key', 'woocommerce-mailchimp' ),
|
318 |
+
'type' => 'text',
|
319 |
+
'desc' => sprintf( __( '%sLogin to MailChimp%s to look up your api key.', 'woocommerce-mailchimp' ), '<br/><a href="https://admin.mailchimp.com/account/api/" target="_blank">', '</a>'
|
320 |
+
),
|
321 |
+
'placeholder' => __( 'Paste your MailChimp API key here', 'woocommerce-mailchimp' ),
|
322 |
+
'default' => '',
|
323 |
+
'css' => 'min-width:350px;',
|
324 |
+
'desc_tip' => 'Your API Key is required for the plugin to communicate with your MailChimp account.',
|
325 |
+
);
|
326 |
+
|
327 |
+
$settings[] = array(
|
328 |
+
'id' => $this->namespace_prefixed( 'enabled' ),
|
329 |
+
'title' => __( 'Enable/Disable', 'woocommerce-mailchimp' ),
|
330 |
+
'label' => __( 'Enable MailChimp Integration', 'woocommerce-mailchimp' ),
|
331 |
+
'type' => 'checkbox',
|
332 |
+
'desc' => __( 'Enable/disable the plugin functionality.', 'woocommerce-mailchimp' ),
|
333 |
+
'default' => 'yes',
|
334 |
+
);
|
335 |
+
|
336 |
+
$mailchimp_lists = $this->get_lists();
|
337 |
+
|
338 |
+
if ( $this->has_api_key() && $this->has_list() ) {
|
339 |
+
$interest_groups = $this->get_interest_groups();
|
340 |
+
} else {
|
341 |
+
$interest_groups = array();
|
342 |
+
}
|
343 |
+
|
344 |
+
$settings[] = array(
|
345 |
+
'id' => $this->namespace_prefixed( 'list' ),
|
346 |
+
'title' => __( 'Main List', 'woocommerce-mailchimp' ),
|
347 |
+
'type' => 'select',
|
348 |
+
'desc' => __( 'All customers will be added to this list.', 'woocommerce-mailchimp' ),
|
349 |
+
'default' => '',
|
350 |
+
'options' => $mailchimp_lists,
|
351 |
+
'class' => 'wc-enhanced-select',
|
352 |
+
'css' => 'min-width: 350px;',
|
353 |
+
'desc_tip' => true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
);
|
355 |
|
356 |
+
$settings[] = array(
|
357 |
+
'id' => $this->namespace_prefixed( 'interest_groups' ),
|
358 |
+
'title' => __( 'Interest Groups', 'woocommerce-mailchimp' ),
|
359 |
+
'type' => 'multiselect',
|
360 |
+
'desc' => __( 'Optional: Interest groups to assign to subscribers.', 'woocommerce-mailchimp' ),
|
361 |
+
'default' => '',
|
362 |
+
'options' => $interest_groups,
|
363 |
+
'class' => 'wc-enhanced-select',
|
364 |
+
'custom_attributes' => array(
|
365 |
+
'placeholder' => __( 'Select interest groups...', 'woocommerce-mailchimp' ),
|
366 |
+
),
|
367 |
+
'css' => 'min-width: 350px;',
|
368 |
+
'desc_tip' => true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
);
|
370 |
|
371 |
+
$settings[] = array(
|
372 |
+
'id' => $this->namespace_prefixed( 'occurs' ),
|
373 |
+
'title' => __( 'Subscribe Event', 'woocommerce-mailchimp' ),
|
374 |
+
'type' => 'select',
|
375 |
+
'desc' => __( 'Choose whether to subscribe customers as soon as an order is placed or after the order is processing or completed.', 'woocommerce-mailchimp' ),
|
376 |
+
'class' => 'wc-enhanced-select',
|
377 |
+
'default' => 'pending',
|
378 |
+
'options' => array(
|
379 |
+
'pending' => __( 'Order Created', 'woocommerce-mailchimp' ),
|
380 |
+
'processing' => __( 'Order Processing', 'woocommerce-mailchimp' ),
|
381 |
+
'completed' => __( 'Order Completed', 'woocommerce-mailchimp' ),
|
382 |
+
),
|
383 |
+
'desc_tip' => true,
|
384 |
+
);
|
385 |
+
|
386 |
+
$settings[] = array(
|
387 |
+
'id' => $this->namespace_prefixed( 'double_optin' ),
|
388 |
+
'title' => __( 'Double Opt-In', 'woocommerce-mailchimp' ),
|
389 |
+
'desc' => __( 'Enable Double Opt-In', 'woocommerce-mailchimp' ),
|
390 |
+
'type' => 'checkbox',
|
391 |
+
'default' => 'no',
|
392 |
+
'desc_tip' => __( 'If enabled, customers will receive an email prompting them to confirm their subscription to the list above.', 'woocommerce-mailchimp' ),
|
393 |
+
);
|
394 |
+
|
395 |
+
$settings[] = array(
|
396 |
+
'id' => $this->namespace_prefixed( 'display_opt_in' ),
|
397 |
+
'title' => __( 'Subscribe Customers', 'woocommerce-mailchimp' ),
|
398 |
+
'desc' => __( '<p>Choose <strong>Ask for permission</strong> to show an "Opt-in" checkbox during checkout. Customers will only be subscribed to the list above if they opt-in. <p>Choose <strong>Automatically</strong> to subscribe customers silently upon checkout. Caution, this is without the customer\'s consent.</p>', 'woocommerce-mailchimp' ),
|
399 |
+
'type' => 'select',
|
400 |
+
'css' => 'min-width:300px;',
|
401 |
+
'class' => 'wc-enhanced-select',
|
402 |
+
'desc_tip' => true,
|
403 |
+
'default' => 'yes',
|
404 |
+
'options' => array(
|
405 |
+
// '0' => __( 'Disabled', 'woocommerce-mailchimp' ),
|
406 |
+
'yes' => __( 'Ask for permission', 'woocommerce-mailchimp' ),
|
407 |
+
'no' => __( 'Automatically', 'woocommerce-mailchimp' ),
|
408 |
+
)
|
409 |
+
);
|
410 |
+
|
411 |
+
$settings[] = array(
|
412 |
+
'id' => $this->namespace_prefixed( 'opt_in_label' ),
|
413 |
+
'title' => __( 'Opt-In Field Label', 'woocommerce-mailchimp' ),
|
414 |
+
'type' => 'text',
|
415 |
+
'desc' => __( 'Optional: customize the label displayed next to the opt-in checkbox.', 'woocommerce-mailchimp' ),
|
416 |
+
'default' => __( 'Subscribe to our newsletter', 'woocommerce-mailchimp' ),
|
417 |
+
'css' => 'min-width:350px;',
|
418 |
+
'desc_tip' => true,
|
419 |
+
);
|
420 |
+
|
421 |
+
$settings[] = array(
|
422 |
+
'id' => $this->namespace_prefixed( 'opt_in_checkbox_default_status' ),
|
423 |
+
'title' => __( 'Opt-In Checkbox Default', 'woocommerce-mailchimp' ),
|
424 |
+
'type' => 'select',
|
425 |
+
'desc' => __( 'The default state of the opt-in checkbox.', 'woocommerce-mailchimp' ),
|
426 |
+
'class' => 'wc-enhanced-select',
|
427 |
+
'default' => 'checked',
|
428 |
+
'options' => array(
|
429 |
+
'checked' => __( 'Checked', 'woocommerce-mailchimp' ),
|
430 |
+
'unchecked' => __( 'Unchecked', 'woocommerce-mailchimp' )
|
431 |
+
),
|
432 |
+
'desc_tip' => true,
|
433 |
+
);
|
434 |
+
|
435 |
+
$settings[] = array(
|
436 |
+
'id' => $this->namespace_prefixed( 'opt_in_checkbox_display_location' ),
|
437 |
+
'title' => __( 'Opt-In Checkbox Location', 'woocommerce-mailchimp' ),
|
438 |
+
'type' => 'select',
|
439 |
+
'desc' => __( 'Where to display the opt-in checkbox on the checkout page.', 'woocommerce-mailchimp' ),
|
440 |
+
'class' => 'wc-enhanced-select',
|
441 |
+
'default' => 'woocommerce_review_order_before_submit',
|
442 |
+
'options' => array(
|
443 |
+
'woocommerce_checkout_before_customer_details' => __( 'Above customer details', 'woocommerce-mailchimp' ),
|
444 |
+
'woocommerce_checkout_after_customer_details' => __( 'Below customer details', 'woocommerce-mailchimp' ),
|
445 |
+
'woocommerce_review_order_before_submit' => __( 'Order review above submit', 'woocommerce-mailchimp' ),
|
446 |
+
'woocommerce_review_order_after_submit' => __( 'Order review below submit', 'woocommerce-mailchimp' ),
|
447 |
+
'woocommerce_review_order_before_order_total' => __( 'Order review above total', 'woocommerce-mailchimp' ),
|
448 |
+
'woocommerce_checkout_billing' => __( 'Above billing details', 'woocommerce-mailchimp' ),
|
449 |
+
'woocommerce_checkout_shipping' => __( 'Above shipping details', 'woocommerce-mailchimp' ),
|
450 |
+
'woocommerce_after_checkout_billing_form' => __( 'Below Checkout billing form', 'woocommerce-mailchimp' ),
|
451 |
+
),
|
452 |
+
'desc_tip' => true,
|
453 |
+
);
|
454 |
+
|
455 |
+
$settings[] = array( 'type' => 'sectionend', 'id' => 'general_options' );
|
456 |
|
457 |
$settings = apply_filters( $this->namespace_prefixed( 'settings_general' ), $settings );
|
458 |
|
488 |
'id' => 'sysinfo',
|
489 |
'title' => __( 'System Info', 'woocommerce-mailchimp' ),
|
490 |
'type' => 'sysinfo',
|
491 |
+
'desc' => __( 'Copy the information below and send it to us when reporting an issue with the plugin.', 'woocommerce-mailchimp' ) . '<p/>',
|
492 |
'desc_tip' => '',
|
493 |
);
|
494 |
|
498 |
|
499 |
}
|
500 |
|
|
|
|
|
501 |
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
|
502 |
|
503 |
} //end function get_settings
|
543 |
* API Instance Singleton
|
544 |
* @return Object
|
545 |
*/
|
546 |
+
public function mailchimp() {
|
547 |
+
|
548 |
+
$sswcmc = SSWCMC();
|
549 |
+
|
550 |
+
return $sswcmc->mailchimp();
|
551 |
+
|
|
|
|
|
|
|
|
|
552 |
}
|
553 |
|
554 |
/**
|
559 |
*/
|
560 |
public function get_lists() {
|
561 |
|
562 |
+
if ( $this->mailchimp() ) {
|
563 |
+
$mailchimp_lists = $this->mailchimp()->get_lists();
|
564 |
+
} else {
|
565 |
+
return false;
|
566 |
+
}
|
|
|
|
|
|
|
|
|
|
|
567 |
|
568 |
+
if ( $mailchimp_lists === false ) {
|
|
|
569 |
|
570 |
+
add_action( 'admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
571 |
+
add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
572 |
|
573 |
+
return false;
|
574 |
|
575 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
|
577 |
+
if ( count( $mailchimp_lists ) === 0 ) {
|
578 |
+
$default = array(
|
579 |
+
'no_lists' => __( 'Oops! No lists in your MailChimp account...', 'woocommerce-mailchimp' ),
|
580 |
+
);
|
581 |
+
add_action( 'admin_notices', array( $this, 'mailchimp_no_lists_found' ) );
|
582 |
+
} else {
|
583 |
+
$default = array(
|
584 |
+
'' => __( 'Select a list...', 'woocommerce-mailchimp' ),
|
585 |
+
);
|
586 |
+
}
|
587 |
+
$mailchimp_lists = array_merge( $default, $mailchimp_lists );
|
588 |
|
589 |
return $mailchimp_lists;
|
590 |
|
598 |
*/
|
599 |
public function get_interest_groups() {
|
600 |
|
601 |
+
if ( $this->mailchimp() && $this->has_list() ) {
|
602 |
+
$interest_groups = $this->mailchimp()->get_interest_categories_with_interests( $this->get_list() );
|
603 |
} else {
|
604 |
return false;
|
605 |
}
|
633 |
*/
|
634 |
public function mailchimp_api_error_msg() {
|
635 |
echo $this->get_message(
|
636 |
+
sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'woocommerce-mailchimp' ), $this->mailchimp()->get_error_code(), $this->mailchimp()->get_error_message() ) .
|
637 |
sprintf( __( 'Please check your Settings %ssettings%s.', 'woocommerce-mailchimp' ), '<a href="' . WOOCOMMERCE_MAILCHIMP_SETTINGS_URL .'">', '</a>' )
|
638 |
);
|
639 |
} //end function mailchimp_api_error_msg
|
includes/functions.php
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Get a service by its name
|
5 |
-
*
|
6 |
-
* _Example:_
|
7 |
-
*
|
8 |
-
* $forms = ss_wc_mailchimp('forms');
|
9 |
-
* $api = ss_wc_mailchimp('api');
|
10 |
-
*
|
11 |
-
* When no service parameter is given, the entire container will be returned.
|
12 |
-
*
|
13 |
-
* @ignore
|
14 |
-
* @access private
|
15 |
-
*
|
16 |
-
* @param string $service (optional)
|
17 |
-
* @return mixed
|
18 |
-
*
|
19 |
-
* @throws Exception when service is not found
|
20 |
-
*/
|
21 |
-
function ss_wc_mailchimp( $service = null ) {
|
22 |
-
static $ss_wc_mailchimp;
|
23 |
-
|
24 |
-
if ( ! $ss_wc_mailchimp ) {
|
25 |
-
$ss_wc_mailchimp = new SS_WC_MailChimp_Container();
|
26 |
-
}
|
27 |
-
|
28 |
-
if ( $service ) {
|
29 |
-
return $ss_wc_mailchimp->get( $service );
|
30 |
-
}
|
31 |
-
|
32 |
-
return $ss_wc_mailchimp;
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Gets the WooCommerce MailChimp options from the database
|
37 |
-
* Uses default values to prevent undefined index notices.
|
38 |
-
*
|
39 |
-
* @since 1.0
|
40 |
-
* @access public
|
41 |
-
* @static array $options
|
42 |
-
* @return array
|
43 |
-
*/
|
44 |
-
function ss_wc_mailchimp_get_options() {
|
45 |
-
static $options;
|
46 |
-
|
47 |
-
if ( ! $options ) {
|
48 |
-
$defaults = require SS_WC_MAILCHIMP_DIR . 'config/default-settings.php';
|
49 |
-
$options = array();
|
50 |
-
foreach ( $defaults as $key => $val ) {
|
51 |
-
$options[ $key ] = get_option( 'ss_wc_mailchimp_' . $key );
|
52 |
-
}
|
53 |
-
$options = array_merge( $defaults, $options );
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Filters the MailChimp for WordPress settings (general).
|
58 |
-
*
|
59 |
-
* @param array $options
|
60 |
-
*/
|
61 |
-
return apply_filters( 'ss_wc_mailchimp_settings', $options );
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Gets the WooCommerce MailChimp API Helper class and injects it with the API key
|
66 |
-
*
|
67 |
-
* @since 4.0
|
68 |
-
* @access public
|
69 |
-
*
|
70 |
-
* @return SS_WC_MailChimp
|
71 |
-
*/
|
72 |
-
function ss_wc_mailchimp_get_api( $api_key = null, $debug = null ) {
|
73 |
-
$opts = ss_wc_mailchimp_get_options();
|
74 |
-
$instance = new SS_WC_MailChimp( ($api_key ? $api_key : $opts['api_key']), ($debug ? $debug : $opts['debug']) );
|
75 |
-
return $instance;
|
76 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/migrations/class-ss-wc-migration-from-1.3.X-to-2.0.php
CHANGED
@@ -25,7 +25,7 @@ final class SS_WC_MailChimp_Migration_From_13X_To_20 extends SS_WC_MailChimp_Mig
|
|
25 |
|
26 |
if ( empty( $interest_groupings ) || empty( $groups ) || empty( $list ) ) return;
|
27 |
|
28 |
-
$interest_categories = $this->
|
29 |
|
30 |
$selected_interest_category = array_filter( $interest_categories, function($v) use($interest_groupings) {
|
31 |
return $v == $interest_groupings;
|
@@ -33,7 +33,7 @@ final class SS_WC_MailChimp_Migration_From_13X_To_20 extends SS_WC_MailChimp_Mig
|
|
33 |
|
34 |
$selected_interest_category_id = key( $selected_interest_category );
|
35 |
|
36 |
-
$interest_category_interests = $this->
|
37 |
|
38 |
$groups = explode( ',', $groups );
|
39 |
|
25 |
|
26 |
if ( empty( $interest_groupings ) || empty( $groups ) || empty( $list ) ) return;
|
27 |
|
28 |
+
$interest_categories = $this->mailchimp->get_interest_categories( $list );
|
29 |
|
30 |
$selected_interest_category = array_filter( $interest_categories, function($v) use($interest_groupings) {
|
31 |
return $v == $interest_groupings;
|
33 |
|
34 |
$selected_interest_category_id = key( $selected_interest_category );
|
35 |
|
36 |
+
$interest_category_interests = $this->mailchimp->get_interest_category_interests( $list, $selected_interest_category_id );
|
37 |
|
38 |
$groups = explode( ',', $groups );
|
39 |
|
includes/migrations/class-ss-wc-migration.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
abstract class SS_WC_MailChimp_Migration {
|
4 |
|
5 |
-
protected $
|
6 |
|
7 |
protected $settings;
|
8 |
|
@@ -38,7 +38,7 @@ abstract class SS_WC_MailChimp_Migration {
|
|
38 |
if ( empty( $this->settings['api_key'] ) ) return;
|
39 |
|
40 |
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
41 |
-
$this->
|
42 |
}
|
43 |
|
44 |
/**
|
2 |
|
3 |
abstract class SS_WC_MailChimp_Migration {
|
4 |
|
5 |
+
protected $mailchimp;
|
6 |
|
7 |
protected $settings;
|
8 |
|
38 |
if ( empty( $this->settings['api_key'] ) ) return;
|
39 |
|
40 |
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
41 |
+
$this->mailchimp = new SS_WC_MailChimp( $this->settings['api_key'] );
|
42 |
}
|
43 |
|
44 |
/**
|
languages/woocommerce-mailchimp.pot
CHANGED
@@ -1,14 +1,12 @@
|
|
1 |
-
# Copyright (C) 2016 Saint Systems
|
2 |
-
# This file is distributed under the same license as the WooCommerce MailChimp package.
|
3 |
#, fuzzy
|
4 |
msgid ""
|
5 |
msgstr ""
|
6 |
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
7 |
-
"Project-Id-Version: WooCommerce MailChimp
|
8 |
-
"POT-Creation-Date: 2016-09-
|
9 |
-
"PO-Revision-Date: 2016-09-
|
10 |
-
"Last-Translator: Adam Anderly
|
11 |
-
"Language-Team:
|
12 |
"MIME-Version: 1.0\n"
|
13 |
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -23,89 +21,91 @@ msgstr ""
|
|
23 |
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
24 |
|
25 |
#: config/default-settings.php:10
|
26 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
27 |
msgid "Subscribe to our newsletter"
|
28 |
msgstr ""
|
29 |
|
30 |
-
#: includes/class-ss-wc-mailchimp-handler.php:
|
31 |
-
#: includes/class-ss-wc-mailchimp
|
32 |
-
#: includes/class-ss-wc-settings-mailchimp.php:52
|
33 |
#: includes/class-ss-wc-settings-mailchimp.php:308
|
34 |
msgid "MailChimp"
|
35 |
msgstr ""
|
36 |
|
37 |
-
#: includes/class-ss-wc-mailchimp-handler.php:
|
38 |
#, php-format
|
39 |
msgid "(): Subscribing customer (%s) to list %s"
|
40 |
msgstr ""
|
41 |
|
42 |
-
#: includes/class-ss-wc-mailchimp-handler.php:
|
43 |
-
|
|
|
|
|
|
|
44 |
msgid "Enter your api key above to see your lists"
|
45 |
msgstr ""
|
46 |
|
47 |
-
#: includes/class-ss-wc-mailchimp-handler.php:
|
48 |
msgid "Please select a list from above."
|
49 |
msgstr ""
|
50 |
|
51 |
-
#: includes/class-ss-wc-mailchimp-handler.php:
|
52 |
#, php-format
|
53 |
msgid "(): Subscribing customer to MailChimp: %s"
|
54 |
msgstr ""
|
55 |
|
56 |
-
#: includes/class-ss-wc-mailchimp-handler.php:
|
57 |
#, php-format
|
58 |
msgid "(): MailChimp API response: %s"
|
59 |
msgstr ""
|
60 |
|
61 |
-
#: includes/class-ss-wc-mailchimp-handler.php:
|
62 |
#, php-format
|
63 |
msgid "(): WooCommerce MailChimp subscription failed: %s (%s)"
|
64 |
msgstr ""
|
65 |
|
66 |
-
#: includes/class-ss-wc-mailchimp-handler.php:
|
67 |
msgid "WooCommerce MailChimp subscription failed"
|
68 |
msgstr ""
|
69 |
|
70 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:
|
71 |
msgid "Settings"
|
72 |
msgstr ""
|
73 |
|
74 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:
|
75 |
msgid "Connecting to MailChimp"
|
76 |
msgstr ""
|
77 |
|
78 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:
|
79 |
-
msgid "Error
|
80 |
msgstr ""
|
81 |
|
82 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:
|
83 |
msgid ""
|
84 |
"Error loading groups. Please check your MailChimp Interest Groups for the "
|
85 |
"selected list."
|
86 |
msgstr ""
|
87 |
|
88 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:
|
89 |
msgid "Select one or more groups (optional)"
|
90 |
msgstr ""
|
91 |
|
92 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:
|
93 |
msgid "This list does not have interest groups enabled"
|
94 |
msgstr ""
|
95 |
|
96 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
97 |
#, php-format
|
98 |
msgid ""
|
99 |
"WooCommerce MailChimp error: Plugin is enabled but no api key provided. "
|
100 |
-
"Please enter your api key %
|
101 |
msgstr ""
|
102 |
|
103 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
104 |
msgid "General"
|
105 |
msgstr ""
|
106 |
|
107 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
108 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
109 |
msgid "Troubleshooting"
|
110 |
msgstr ""
|
111 |
|
@@ -124,83 +124,83 @@ msgstr ""
|
|
124 |
msgid "%sLogin to MailChimp%s to look up your api key."
|
125 |
msgstr ""
|
126 |
|
127 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
|
|
|
|
|
|
|
|
128 |
msgid "Enable/Disable"
|
129 |
msgstr ""
|
130 |
|
131 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
132 |
msgid "Enable MailChimp Integration"
|
133 |
msgstr ""
|
134 |
|
135 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
136 |
msgid "Enable/disable the plugin functionality."
|
137 |
msgstr ""
|
138 |
|
139 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
140 |
msgid "Main List"
|
141 |
msgstr ""
|
142 |
|
143 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
144 |
msgid "All customers will be added to this list."
|
145 |
msgstr ""
|
146 |
|
147 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
148 |
msgid "Interest Groups"
|
149 |
msgstr ""
|
150 |
|
151 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
152 |
msgid "Optional: Interest groups to assign to subscribers."
|
153 |
msgstr ""
|
154 |
|
155 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
156 |
msgid "Select interest groups..."
|
157 |
msgstr ""
|
158 |
|
159 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
160 |
-
msgid "Checkout Settings"
|
161 |
-
msgstr ""
|
162 |
-
|
163 |
-
#: includes/class-ss-wc-settings-mailchimp.php:410
|
164 |
msgid "Subscribe Event"
|
165 |
msgstr ""
|
166 |
|
167 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
168 |
msgid ""
|
169 |
"Choose whether to subscribe customers as soon as an order is placed or after "
|
170 |
"the order is processing or completed."
|
171 |
msgstr ""
|
172 |
|
173 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
174 |
msgid "Order Created"
|
175 |
msgstr ""
|
176 |
|
177 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
178 |
msgid "Order Processing"
|
179 |
msgstr ""
|
180 |
|
181 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
182 |
msgid "Order Completed"
|
183 |
msgstr ""
|
184 |
|
185 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
186 |
msgid "Double Opt-In"
|
187 |
msgstr ""
|
188 |
|
189 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
190 |
msgid "Enable Double Opt-In"
|
191 |
msgstr ""
|
192 |
|
193 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
194 |
msgid ""
|
195 |
"If enabled, customers will receive an email prompting them to confirm their "
|
196 |
"subscription to the list above."
|
197 |
msgstr ""
|
198 |
|
199 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
200 |
msgid "Subscribe Customers"
|
201 |
msgstr ""
|
202 |
|
203 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
204 |
msgid ""
|
205 |
"<p>Choose <strong>Ask for permission</strong> to show an \"Opt-in\" checkbox "
|
206 |
"during checkout. Customers will only be subscribed to the list above if they "
|
@@ -208,127 +208,127 @@ msgid ""
|
|
208 |
"silently upon checkout. Caution, this is without the customer's consent.</p>"
|
209 |
msgstr ""
|
210 |
|
211 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
212 |
msgid "Ask for permission"
|
213 |
msgstr ""
|
214 |
|
215 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
216 |
msgid "Automatically"
|
217 |
msgstr ""
|
218 |
|
219 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
220 |
msgid "Opt-In Field Label"
|
221 |
msgstr ""
|
222 |
|
223 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
224 |
msgid "Optional: customize the label displayed next to the opt-in checkbox."
|
225 |
msgstr ""
|
226 |
|
227 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
228 |
msgid "Opt-In Checkbox Default"
|
229 |
msgstr ""
|
230 |
|
231 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
232 |
msgid "The default state of the opt-in checkbox."
|
233 |
msgstr ""
|
234 |
|
235 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
236 |
msgid "Checked"
|
237 |
msgstr ""
|
238 |
|
239 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
240 |
msgid "Unchecked"
|
241 |
msgstr ""
|
242 |
|
243 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
244 |
msgid "Opt-In Checkbox Location"
|
245 |
msgstr ""
|
246 |
|
247 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
248 |
msgid "Where to display the opt-in checkbox on the checkout page."
|
249 |
msgstr ""
|
250 |
|
251 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
252 |
msgid "Above customer details"
|
253 |
msgstr ""
|
254 |
|
255 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
256 |
msgid "Below customer details"
|
257 |
msgstr ""
|
258 |
|
259 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
260 |
msgid "Order review above submit"
|
261 |
msgstr ""
|
262 |
|
263 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
264 |
msgid "Order review below submit"
|
265 |
msgstr ""
|
266 |
|
267 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
268 |
msgid "Order review above total"
|
269 |
msgstr ""
|
270 |
|
271 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
272 |
msgid "Above billing details"
|
273 |
msgstr ""
|
274 |
|
275 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
276 |
msgid "Above shipping details"
|
277 |
msgstr ""
|
278 |
|
279 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
280 |
msgid "Below Checkout billing form"
|
281 |
msgstr ""
|
282 |
|
283 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
284 |
msgid "Enable Logging"
|
285 |
msgstr ""
|
286 |
|
287 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
288 |
#, php-format
|
289 |
msgid "%1$sView Log%2$s"
|
290 |
msgstr ""
|
291 |
|
292 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
293 |
msgid "Debug Log"
|
294 |
msgstr ""
|
295 |
|
296 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
297 |
msgid ""
|
298 |
"Enable logging MailChimp API calls. Only enable for troubleshooting purposes."
|
299 |
msgstr ""
|
300 |
|
301 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
302 |
msgid "System Info"
|
303 |
msgstr ""
|
304 |
|
305 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
306 |
msgid ""
|
307 |
"Copy the information below and send it to us when reporting an issue with "
|
308 |
-
"the plugin
|
309 |
msgstr ""
|
310 |
|
311 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
312 |
msgid "Oops! No lists in your MailChimp account..."
|
313 |
msgstr ""
|
314 |
|
315 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
316 |
msgid "Select a list..."
|
317 |
msgstr ""
|
318 |
|
319 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
320 |
#, php-format
|
321 |
msgid ""
|
322 |
"Oops! There are no lists in your MailChimp account. %sClick here%s to create "
|
323 |
"one."
|
324 |
msgstr ""
|
325 |
|
326 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
327 |
#, php-format
|
328 |
msgid "Unable to load lists from MailChimp: (%s) %s. "
|
329 |
msgstr ""
|
330 |
|
331 |
-
#: includes/class-ss-wc-settings-mailchimp.php:
|
332 |
#, php-format
|
333 |
msgid "Please check your Settings %ssettings%s."
|
334 |
msgstr ""
|
|
|
|
|
1 |
#, fuzzy
|
2 |
msgid ""
|
3 |
msgstr ""
|
4 |
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
5 |
+
"Project-Id-Version: WooCommerce MailChimp\n"
|
6 |
+
"POT-Creation-Date: 2016-09-19 11:36-0500\n"
|
7 |
+
"PO-Revision-Date: 2016-09-19 11:34-0500\n"
|
8 |
+
"Last-Translator: Adam Anderly <adam.anderly@saintsystems.com>\n"
|
9 |
+
"Language-Team: Adam Anderly <adam.anderly@saintsystems.com>\n"
|
10 |
"MIME-Version: 1.0\n"
|
11 |
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
"Content-Transfer-Encoding: 8bit\n"
|
21 |
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
22 |
|
23 |
#: config/default-settings.php:10
|
24 |
+
#: includes/class-ss-wc-settings-mailchimp.php:416
|
25 |
msgid "Subscribe to our newsletter"
|
26 |
msgstr ""
|
27 |
|
28 |
+
#: includes/class-ss-wc-mailchimp-handler.php:29
|
29 |
+
#: includes/class-ss-wc-settings-mailchimp.php:46
|
|
|
30 |
#: includes/class-ss-wc-settings-mailchimp.php:308
|
31 |
msgid "MailChimp"
|
32 |
msgstr ""
|
33 |
|
34 |
+
#: includes/class-ss-wc-mailchimp-handler.php:194
|
35 |
#, php-format
|
36 |
msgid "(): Subscribing customer (%s) to list %s"
|
37 |
msgstr ""
|
38 |
|
39 |
+
#: includes/class-ss-wc-mailchimp-handler.php:266
|
40 |
+
msgid "Please enter an api key."
|
41 |
+
msgstr ""
|
42 |
+
|
43 |
+
#: includes/class-ss-wc-mailchimp-handler.php:299
|
44 |
msgid "Enter your api key above to see your lists"
|
45 |
msgstr ""
|
46 |
|
47 |
+
#: includes/class-ss-wc-mailchimp-handler.php:338
|
48 |
msgid "Please select a list from above."
|
49 |
msgstr ""
|
50 |
|
51 |
+
#: includes/class-ss-wc-mailchimp-handler.php:470
|
52 |
#, php-format
|
53 |
msgid "(): Subscribing customer to MailChimp: %s"
|
54 |
msgstr ""
|
55 |
|
56 |
+
#: includes/class-ss-wc-mailchimp-handler.php:476
|
57 |
#, php-format
|
58 |
msgid "(): MailChimp API response: %s"
|
59 |
msgstr ""
|
60 |
|
61 |
+
#: includes/class-ss-wc-mailchimp-handler.php:480
|
62 |
#, php-format
|
63 |
msgid "(): WooCommerce MailChimp subscription failed: %s (%s)"
|
64 |
msgstr ""
|
65 |
|
66 |
+
#: includes/class-ss-wc-mailchimp-handler.php:489
|
67 |
msgid "WooCommerce MailChimp subscription failed"
|
68 |
msgstr ""
|
69 |
|
70 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:252
|
71 |
msgid "Settings"
|
72 |
msgstr ""
|
73 |
|
74 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:284
|
75 |
msgid "Connecting to MailChimp"
|
76 |
msgstr ""
|
77 |
|
78 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:285
|
79 |
+
msgid "Error. Please check your api key."
|
80 |
msgstr ""
|
81 |
|
82 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:286
|
83 |
msgid ""
|
84 |
"Error loading groups. Please check your MailChimp Interest Groups for the "
|
85 |
"selected list."
|
86 |
msgstr ""
|
87 |
|
88 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:287
|
89 |
msgid "Select one or more groups (optional)"
|
90 |
msgstr ""
|
91 |
|
92 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:288
|
93 |
msgid "This list does not have interest groups enabled"
|
94 |
msgstr ""
|
95 |
|
96 |
+
#: includes/class-ss-wc-settings-mailchimp.php:201
|
97 |
#, php-format
|
98 |
msgid ""
|
99 |
"WooCommerce MailChimp error: Plugin is enabled but no api key provided. "
|
100 |
+
"Please enter your api key <a href=\"%s\">here</a>."
|
101 |
msgstr ""
|
102 |
|
103 |
+
#: includes/class-ss-wc-settings-mailchimp.php:250
|
104 |
msgid "General"
|
105 |
msgstr ""
|
106 |
|
107 |
+
#: includes/class-ss-wc-settings-mailchimp.php:253
|
108 |
+
#: includes/class-ss-wc-settings-mailchimp.php:472
|
109 |
msgid "Troubleshooting"
|
110 |
msgstr ""
|
111 |
|
124 |
msgid "%sLogin to MailChimp%s to look up your api key."
|
125 |
msgstr ""
|
126 |
|
127 |
+
#: includes/class-ss-wc-settings-mailchimp.php:321
|
128 |
+
msgid "Paste your MailChimp API key here"
|
129 |
+
msgstr ""
|
130 |
+
|
131 |
+
#: includes/class-ss-wc-settings-mailchimp.php:329
|
132 |
msgid "Enable/Disable"
|
133 |
msgstr ""
|
134 |
|
135 |
+
#: includes/class-ss-wc-settings-mailchimp.php:330
|
136 |
msgid "Enable MailChimp Integration"
|
137 |
msgstr ""
|
138 |
|
139 |
+
#: includes/class-ss-wc-settings-mailchimp.php:332
|
140 |
msgid "Enable/disable the plugin functionality."
|
141 |
msgstr ""
|
142 |
|
143 |
+
#: includes/class-ss-wc-settings-mailchimp.php:346
|
144 |
msgid "Main List"
|
145 |
msgstr ""
|
146 |
|
147 |
+
#: includes/class-ss-wc-settings-mailchimp.php:348
|
148 |
msgid "All customers will be added to this list."
|
149 |
msgstr ""
|
150 |
|
151 |
+
#: includes/class-ss-wc-settings-mailchimp.php:358
|
152 |
msgid "Interest Groups"
|
153 |
msgstr ""
|
154 |
|
155 |
+
#: includes/class-ss-wc-settings-mailchimp.php:360
|
156 |
msgid "Optional: Interest groups to assign to subscribers."
|
157 |
msgstr ""
|
158 |
|
159 |
+
#: includes/class-ss-wc-settings-mailchimp.php:365
|
160 |
msgid "Select interest groups..."
|
161 |
msgstr ""
|
162 |
|
163 |
+
#: includes/class-ss-wc-settings-mailchimp.php:373
|
|
|
|
|
|
|
|
|
164 |
msgid "Subscribe Event"
|
165 |
msgstr ""
|
166 |
|
167 |
+
#: includes/class-ss-wc-settings-mailchimp.php:375
|
168 |
msgid ""
|
169 |
"Choose whether to subscribe customers as soon as an order is placed or after "
|
170 |
"the order is processing or completed."
|
171 |
msgstr ""
|
172 |
|
173 |
+
#: includes/class-ss-wc-settings-mailchimp.php:379
|
174 |
msgid "Order Created"
|
175 |
msgstr ""
|
176 |
|
177 |
+
#: includes/class-ss-wc-settings-mailchimp.php:380
|
178 |
msgid "Order Processing"
|
179 |
msgstr ""
|
180 |
|
181 |
+
#: includes/class-ss-wc-settings-mailchimp.php:381
|
182 |
msgid "Order Completed"
|
183 |
msgstr ""
|
184 |
|
185 |
+
#: includes/class-ss-wc-settings-mailchimp.php:388
|
186 |
msgid "Double Opt-In"
|
187 |
msgstr ""
|
188 |
|
189 |
+
#: includes/class-ss-wc-settings-mailchimp.php:389
|
190 |
msgid "Enable Double Opt-In"
|
191 |
msgstr ""
|
192 |
|
193 |
+
#: includes/class-ss-wc-settings-mailchimp.php:392
|
194 |
msgid ""
|
195 |
"If enabled, customers will receive an email prompting them to confirm their "
|
196 |
"subscription to the list above."
|
197 |
msgstr ""
|
198 |
|
199 |
+
#: includes/class-ss-wc-settings-mailchimp.php:397
|
200 |
msgid "Subscribe Customers"
|
201 |
msgstr ""
|
202 |
|
203 |
+
#: includes/class-ss-wc-settings-mailchimp.php:398
|
204 |
msgid ""
|
205 |
"<p>Choose <strong>Ask for permission</strong> to show an \"Opt-in\" checkbox "
|
206 |
"during checkout. Customers will only be subscribed to the list above if they "
|
208 |
"silently upon checkout. Caution, this is without the customer's consent.</p>"
|
209 |
msgstr ""
|
210 |
|
211 |
+
#: includes/class-ss-wc-settings-mailchimp.php:406
|
212 |
msgid "Ask for permission"
|
213 |
msgstr ""
|
214 |
|
215 |
+
#: includes/class-ss-wc-settings-mailchimp.php:407
|
216 |
msgid "Automatically"
|
217 |
msgstr ""
|
218 |
|
219 |
+
#: includes/class-ss-wc-settings-mailchimp.php:413
|
220 |
msgid "Opt-In Field Label"
|
221 |
msgstr ""
|
222 |
|
223 |
+
#: includes/class-ss-wc-settings-mailchimp.php:415
|
224 |
msgid "Optional: customize the label displayed next to the opt-in checkbox."
|
225 |
msgstr ""
|
226 |
|
227 |
+
#: includes/class-ss-wc-settings-mailchimp.php:423
|
228 |
msgid "Opt-In Checkbox Default"
|
229 |
msgstr ""
|
230 |
|
231 |
+
#: includes/class-ss-wc-settings-mailchimp.php:425
|
232 |
msgid "The default state of the opt-in checkbox."
|
233 |
msgstr ""
|
234 |
|
235 |
+
#: includes/class-ss-wc-settings-mailchimp.php:429
|
236 |
msgid "Checked"
|
237 |
msgstr ""
|
238 |
|
239 |
+
#: includes/class-ss-wc-settings-mailchimp.php:430
|
240 |
msgid "Unchecked"
|
241 |
msgstr ""
|
242 |
|
243 |
+
#: includes/class-ss-wc-settings-mailchimp.php:437
|
244 |
msgid "Opt-In Checkbox Location"
|
245 |
msgstr ""
|
246 |
|
247 |
+
#: includes/class-ss-wc-settings-mailchimp.php:439
|
248 |
msgid "Where to display the opt-in checkbox on the checkout page."
|
249 |
msgstr ""
|
250 |
|
251 |
+
#: includes/class-ss-wc-settings-mailchimp.php:443
|
252 |
msgid "Above customer details"
|
253 |
msgstr ""
|
254 |
|
255 |
+
#: includes/class-ss-wc-settings-mailchimp.php:444
|
256 |
msgid "Below customer details"
|
257 |
msgstr ""
|
258 |
|
259 |
+
#: includes/class-ss-wc-settings-mailchimp.php:445
|
260 |
msgid "Order review above submit"
|
261 |
msgstr ""
|
262 |
|
263 |
+
#: includes/class-ss-wc-settings-mailchimp.php:446
|
264 |
msgid "Order review below submit"
|
265 |
msgstr ""
|
266 |
|
267 |
+
#: includes/class-ss-wc-settings-mailchimp.php:447
|
268 |
msgid "Order review above total"
|
269 |
msgstr ""
|
270 |
|
271 |
+
#: includes/class-ss-wc-settings-mailchimp.php:448
|
272 |
msgid "Above billing details"
|
273 |
msgstr ""
|
274 |
|
275 |
+
#: includes/class-ss-wc-settings-mailchimp.php:449
|
276 |
msgid "Above shipping details"
|
277 |
msgstr ""
|
278 |
|
279 |
+
#: includes/class-ss-wc-settings-mailchimp.php:450
|
280 |
msgid "Below Checkout billing form"
|
281 |
msgstr ""
|
282 |
|
283 |
+
#: includes/class-ss-wc-settings-mailchimp.php:461
|
284 |
msgid "Enable Logging"
|
285 |
msgstr ""
|
286 |
|
287 |
+
#: includes/class-ss-wc-settings-mailchimp.php:468
|
288 |
#, php-format
|
289 |
msgid "%1$sView Log%2$s"
|
290 |
msgstr ""
|
291 |
|
292 |
+
#: includes/class-ss-wc-settings-mailchimp.php:480
|
293 |
msgid "Debug Log"
|
294 |
msgstr ""
|
295 |
|
296 |
+
#: includes/class-ss-wc-settings-mailchimp.php:484
|
297 |
msgid ""
|
298 |
"Enable logging MailChimp API calls. Only enable for troubleshooting purposes."
|
299 |
msgstr ""
|
300 |
|
301 |
+
#: includes/class-ss-wc-settings-mailchimp.php:489
|
302 |
msgid "System Info"
|
303 |
msgstr ""
|
304 |
|
305 |
+
#: includes/class-ss-wc-settings-mailchimp.php:491
|
306 |
msgid ""
|
307 |
"Copy the information below and send it to us when reporting an issue with "
|
308 |
+
"the plugin."
|
309 |
msgstr ""
|
310 |
|
311 |
+
#: includes/class-ss-wc-settings-mailchimp.php:579
|
312 |
msgid "Oops! No lists in your MailChimp account..."
|
313 |
msgstr ""
|
314 |
|
315 |
+
#: includes/class-ss-wc-settings-mailchimp.php:584
|
316 |
msgid "Select a list..."
|
317 |
msgstr ""
|
318 |
|
319 |
+
#: includes/class-ss-wc-settings-mailchimp.php:624
|
320 |
#, php-format
|
321 |
msgid ""
|
322 |
"Oops! There are no lists in your MailChimp account. %sClick here%s to create "
|
323 |
"one."
|
324 |
msgstr ""
|
325 |
|
326 |
+
#: includes/class-ss-wc-settings-mailchimp.php:636
|
327 |
#, php-format
|
328 |
msgid "Unable to load lists from MailChimp: (%s) %s. "
|
329 |
msgstr ""
|
330 |
|
331 |
+
#: includes/class-ss-wc-settings-mailchimp.php:637
|
332 |
#, php-format
|
333 |
msgid "Please check your Settings %ssettings%s."
|
334 |
msgstr ""
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://ssms.us/hVdk
|
|
4 |
Tags: woocommerce, mailchimp
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 4.6.1
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv3
|
9 |
|
10 |
Simple and flexible MailChimp integration for WooCommerce.
|
@@ -37,19 +37,34 @@ Automatically subscribe customers to a designated MailChimp list and, optionally
|
|
37 |
|
38 |
= Translation Support =
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
- WPML support via wpml-config.xml
|
42 |
|
43 |
**Included Translations:**
|
44 |
|
45 |
-
- English (default)
|
46 |
- French.
|
47 |
|
48 |
**Custom Translations**
|
49 |
-
- Place custom translations in `/wp-content/languages/woocommerce-mailchimp/woocommerce-mailchim_{locale}.[mo|po]`. This ensures they won't get overwritten by plugin updates.
|
50 |
-
- If no custom translations are present, the plugin will load them from `/wp-content/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp_{locale}.[mo|po]`
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
= Multisite =
|
55 |
|
@@ -98,12 +113,12 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
|
|
98 |
|
99 |
== Changelog ==
|
100 |
|
101 |
-
#### 2.0 - 2.0.
|
102 |
-
|
103 |
-
**WARNING:** This release contains breaking changes to the plugins action hooks and filters. If you have custom code that hooks into the plugins action hooks and filters, please review the breaking changes below to know how to update your code appropriately.
|
104 |
|
105 |
**NOTE:** You must upgrade to version 2.X by December 31, 2016 as prior versions of the MailChimp API will stop working at that point.
|
106 |
|
|
|
|
|
107 |
**Breaking Changes**
|
108 |
|
109 |
- Action filter `ss_wc_mailchimp_subscribe_merge_vars` is now `ss_wc_mailchimp_subscribe_merge_tags`
|
4 |
Tags: woocommerce, mailchimp
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 4.6.1
|
7 |
+
Stable tag: 2.0.9
|
8 |
License: GPLv3
|
9 |
|
10 |
Simple and flexible MailChimp integration for WooCommerce.
|
37 |
|
38 |
= Translation Support =
|
39 |
|
40 |
+
Would you like to help translate the plugin into more languages? Join our Translations Community at https://translate.wordpress.org/projects/wp-plugins/woocommerce-mailchimp.
|
41 |
+
|
42 |
+
WooCommerce MailChimp translation is managed through WordPress language packs here: https://translate.wordpress.org. This allows WooCommerce MailChimp to be translated into other languages. The preferred tool for translating plugins is called [GlotPress](https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/). You can [read about how GlotPress works in the WordPress Translator's Handbook](https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/).
|
43 |
+
|
44 |
+
Thanks in advance for your help on any translation efforts!
|
45 |
+
|
46 |
+
We also support bundled translations via:
|
47 |
+
|
48 |
+
- Included woocommerce-mailchimp.pot file
|
49 |
- WPML support via wpml-config.xml
|
50 |
|
51 |
**Included Translations:**
|
52 |
|
53 |
+
- English (US) (default)
|
54 |
- French.
|
55 |
|
56 |
**Custom Translations**
|
|
|
|
|
57 |
|
58 |
+
If you don't want to use WordPress language packs or bundled translations, you can use your own custom translations.
|
59 |
+
|
60 |
+
- Place custom translations in `/wp-content/languages/woocommerce-mailchimp/woocommerce-mailchimp_{lang}_{country}.mo`. This ensures they won't get overwritten by plugin updates.
|
61 |
+
|
62 |
+
**Translation Loading**
|
63 |
+
|
64 |
+
If no custom translations are present, languages will be loaded in the following order:
|
65 |
+
|
66 |
+
- From WordPress language packs in: `/wp-content/languages/plugins/woocommerce-mailchimp/woocommerce-mailchimp_{lang}_{country}.mo`
|
67 |
+
- From the plugin bundled in: `/wp-content/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp_{lang}_{country}.mo`
|
68 |
|
69 |
= Multisite =
|
70 |
|
113 |
|
114 |
== Changelog ==
|
115 |
|
116 |
+
#### 2.0 - 2.0.9 - September 19, 2016
|
|
|
|
|
117 |
|
118 |
**NOTE:** You must upgrade to version 2.X by December 31, 2016 as prior versions of the MailChimp API will stop working at that point.
|
119 |
|
120 |
+
**WARNING:** This release contains breaking changes to the plugin's action hooks and filters. If you have custom code that hooks into the plugins action hooks and filters, please review the breaking changes below to know how to update your code appropriately.
|
121 |
+
|
122 |
**Breaking Changes**
|
123 |
|
124 |
- Action filter `ss_wc_mailchimp_subscribe_merge_vars` is now `ss_wc_mailchimp_subscribe_merge_tags`
|
woocommerce-mailchimp.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
-
* Version: 2.0.
|
9 |
* Text Domain: woocommerce-mailchimp
|
10 |
* Domain Path: languages
|
11 |
*
|
@@ -27,19 +27,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
27 |
*/
|
28 |
define( 'SS_WC_MAILCHIMP_FILE', __FILE__ );
|
29 |
|
30 |
-
/**
|
31 |
-
* The URL to this file
|
32 |
-
*/
|
33 |
-
define( 'SS_WC_MAILCHIMP_URL', plugin_dir_url( __FILE__ ) );
|
34 |
-
|
35 |
-
/**
|
36 |
-
* The absolute path to the plugin directory
|
37 |
-
* @define "SS_WC_MAILCHIMP_DIR" "./"
|
38 |
-
*/
|
39 |
-
define( 'SS_WC_MAILCHIMP_DIR', plugin_dir_path( __FILE__ ) );
|
40 |
-
|
41 |
-
define( 'SS_WC_MAILCHIMP_PLUGIN_URL', plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) );
|
42 |
-
|
43 |
/**
|
44 |
* The main plugin class (SS_WC_MailChimp_Plugin)
|
45 |
*/
|
@@ -47,8 +34,14 @@ require_once( 'includes/class-ss-wc-mailchimp-plugin.php' );
|
|
47 |
|
48 |
/** Register hooks that are fired when the plugin is activated and deactivated. */
|
49 |
if ( is_admin() ) {
|
50 |
-
register_activation_hook(
|
51 |
-
register_deactivation_hook(
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
-
|
|
5 |
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
+
* Version: 2.0.9
|
9 |
* Text Domain: woocommerce-mailchimp
|
10 |
* Domain Path: languages
|
11 |
*
|
27 |
*/
|
28 |
define( 'SS_WC_MAILCHIMP_FILE', __FILE__ );
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
/**
|
31 |
* The main plugin class (SS_WC_MailChimp_Plugin)
|
32 |
*/
|
34 |
|
35 |
/** Register hooks that are fired when the plugin is activated and deactivated. */
|
36 |
if ( is_admin() ) {
|
37 |
+
register_activation_hook( SS_WC_MAILCHIMP_FILE, array( 'SS_WC_MailChimp_Plugin', 'activate' ) );
|
38 |
+
register_deactivation_hook( SS_WC_MAILCHIMP_FILE, array( 'SS_WC_MailChimp_Plugin', 'deactivate' ) );
|
39 |
+
}
|
40 |
+
|
41 |
+
//add_action( 'plugins_loaded', array( 'SS_WC_MailChimp_Plugin', 'instance' ), 0 );
|
42 |
+
function SSWCMC() {
|
43 |
+
return SS_WC_MailChimp_Plugin::instance();
|
44 |
}
|
45 |
|
46 |
+
// Get WooCommerce Mailchipm Running.
|
47 |
+
SSWCMC();
|