Version Description
- February 4, 2015 =
Fixed
- Textual fix as entering "0" for no redirection does not work.
Improvements
- Moved third-party scripts to their own directory for easier exclusion
- All code is now adhering to the WP Code Standards
- Updated Dutch, German, Spanish, Hungarian, French, Italian and Turkish translations.
Additions
- Now showing a heads up when at limit of 100 MailChimp lists. (#71)
- Added
wpml-config.xml
file for better WPML compatibility - Added filter
mc4wp_menu_items
for adding & removing menu items from add-ons
Download this release
Release Info
Developer | DvanKooten |
Plugin | MailChimp for WordPress |
Version | 2.2.4 |
Comparing to | |
See all releases |
Code changes from version 2.2.3 to 2.2.4
- README.md +4 -0
- assets/css/index.php +6 -6
- assets/img/index.php +6 -6
- assets/index.php +6 -6
- assets/js/admin.js +13 -16
- assets/js/admin.min.js +1 -1
- assets/js/index.php +6 -6
- assets/js/{beautify-html.js → third-party/beautify-html.js} +0 -0
- assets/js/{beautify-html.min.js → third-party/beautify-html.min.js} +0 -0
- assets/js/{placeholders.min.js → third-party/placeholders.min.js} +0 -0
- assets/sass/index.php +6 -6
- assets/sass/partials/index.php +6 -6
- includes/class-admin.php +79 -39
- includes/class-api.php +31 -29
- includes/class-checkbox-manager.php +31 -31
- includes/class-form-manager.php +20 -20
- includes/class-form-request.php +10 -10
- includes/class-mailchimp.php +7 -7
- includes/class-plugin.php +21 -21
- includes/class-widget.php +94 -94
- includes/functions/general.php +6 -6
- includes/functions/template.php +146 -146
- includes/index.php +6 -6
- includes/integrations/class-bbpress.php +4 -4
- includes/integrations/class-buddypress.php +3 -3
- includes/integrations/class-cf7.php +3 -3
- includes/integrations/class-comment-form.php +6 -6
- includes/integrations/class-edd.php +1 -1
- includes/integrations/class-events-manager.php +1 -1
- includes/integrations/class-general.php +6 -6
- includes/integrations/class-integration.php +14 -14
- includes/integrations/class-multisite.php +5 -5
- includes/integrations/class-registration-form.php +5 -5
- includes/integrations/class-woocommerce.php +2 -2
- includes/views/api-settings.php +13 -13
- includes/views/checkbox-settings.php +7 -7
- includes/views/form-settings.php +34 -34
- includes/views/index.php +6 -6
- includes/views/parts/admin-field-wizard.php +4 -4
- includes/views/parts/admin-footer.php +2 -2
- includes/views/parts/admin-need-support.php +4 -4
- includes/views/parts/admin-upgrade-to-pro.php +2 -2
- includes/views/parts/index.php +6 -6
- index.php +6 -6
- languages/mailchimp-for-wp-cs_CZ.po +206 -174
- languages/mailchimp-for-wp-de_DE.po +302 -269
- languages/mailchimp-for-wp-es_ES.po +202 -170
- languages/mailchimp-for-wp-fr_FR.po +201 -170
- languages/mailchimp-for-wp-hu_HU.po +223 -192
- languages/mailchimp-for-wp-it_IT.po +200 -169
- languages/mailchimp-for-wp-nl_NL.po +200 -169
- languages/mailchimp-for-wp-pt_BR.po +201 -170
- languages/mailchimp-for-wp-sk_SK.po +199 -168
- languages/mailchimp-for-wp-tr_TR.po +303 -270
- mailchimp-for-wp.php +71 -71
- readme.txt +26 -35
- vendor/autoload.php +7 -0
- vendor/autoload_52.php +7 -0
- vendor/composer/ClassLoader.php +413 -0
- vendor/composer/ClassLoader52.php +271 -0
- vendor/composer/autoload_classmap.php +9 -0
- vendor/composer/autoload_namespaces.php +22 -0
- vendor/composer/autoload_psr4.php +9 -0
- vendor/composer/autoload_real.php +50 -0
- vendor/composer/autoload_real_52.php +44 -0
- vendor/composer/installed.json +581 -0
- wpml-config.xml +17 -0
README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
MailChimp for WordPress
|
2 |
======================
|
|
|
|
|
|
|
|
|
3 |
|
4 |
Here, you can browse the source of the [MailChimp for WordPress Plugin](https://wordpress.org/plugins/mailchimp-for-wp/) project, find and discuss open issues or contribute code to the plugin yourself.
|
5 |
|
1 |
MailChimp for WordPress
|
2 |
======================
|
3 |
+
[![Build Status](https://api.travis-ci.org/dannyvankooten/mailchimp-for-wordpress.png?branch=master)](https://travis-ci.org/dannyvankooten/mailchimp-for-wordpress)
|
4 |
+
[![Stable Version](https://poser.pugx.org/dannyvankooten/mailchimp-for-wordpress/v/stable.svg)](https://packagist.org/packages/dannyvankooten/mailchimp-for-wordpress)
|
5 |
+
[![License](https://poser.pugx.org/dannyvankooten/mailchimp-for-wordpress/license.svg)](https://packagist.org/packages/dannyvankooten/mailchimp-for-wordpress)
|
6 |
+
|
7 |
|
8 |
Here, you can browse the source of the [MailChimp for WordPress Plugin](https://wordpress.org/plugins/mailchimp-for-wp/) project, find and discuss open issues or contribute code to the plugin yourself.
|
9 |
|
assets/css/index.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
if( ! defined(
|
3 |
-
header( 'Status: 403 Forbidden' );
|
4 |
-
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
-
exit;
|
6 |
-
}
|
1 |
+
<?php
|
2 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
3 |
+
header( 'Status: 403 Forbidden' );
|
4 |
+
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
+
exit;
|
6 |
+
}
|
assets/img/index.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
if( ! defined(
|
3 |
-
header( 'Status: 403 Forbidden' );
|
4 |
-
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
-
exit;
|
6 |
-
}
|
1 |
+
<?php
|
2 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
3 |
+
header( 'Status: 403 Forbidden' );
|
4 |
+
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
+
exit;
|
6 |
+
}
|
assets/index.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
if( ! defined(
|
3 |
-
header( 'Status: 403 Forbidden' );
|
4 |
-
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
-
exit;
|
6 |
-
}
|
1 |
+
<?php
|
2 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
3 |
+
header( 'Status: 403 Forbidden' );
|
4 |
+
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
+
exit;
|
6 |
+
}
|
assets/js/admin.js
CHANGED
@@ -36,15 +36,13 @@
|
|
36 |
$(document).delegate('#mc4wpformmarkup', 'keydown', function(e) {
|
37 |
var keyCode = e.keyCode || e.which;
|
38 |
|
39 |
-
if (keyCode
|
40 |
e.preventDefault();
|
41 |
var start = this.selectionStart;
|
42 |
var end = this.selectionEnd;
|
43 |
|
44 |
// set textarea value to: text before caret + tab + text after caret
|
45 |
-
$(this).val($(this).val().substring(0, start)
|
46 |
-
+ "\t"
|
47 |
-
+ $(this).val().substring(end));
|
48 |
|
49 |
// put caret at right position again
|
50 |
this.selectionStart =
|
@@ -56,7 +54,7 @@
|
|
56 |
// Add buttons to QTags editor
|
57 |
(function() {
|
58 |
|
59 |
-
if ( typeof(QTags)
|
60 |
return;
|
61 |
}
|
62 |
|
@@ -65,7 +63,7 @@
|
|
65 |
QTags.addButton( 'mc4wp_response', 'form response', '{response}', '', 'response', 'Shows the form response' );
|
66 |
QTags.addButton( 'mc4wp_subscriber_count', '# of subscribers', '{subscriber_count}', '', 'subscribers', 'Shows number of subscribers of selected list(s)' );
|
67 |
|
68 |
-
if( window.mc4wp.hasCaptchaPlugin
|
69 |
QTags.addButton( 'mc4wp_captcha', 'CAPTCHA', '{captcha}', '', 'captcha', 'Display a CAPTCHA field' );
|
70 |
}
|
71 |
})();
|
@@ -112,7 +110,7 @@
|
|
112 |
var listField = list.merge_vars[i];
|
113 |
|
114 |
// add field to select if no similar option exists yet
|
115 |
-
if($mailchimpMergeFields.find("option[value='"+ listField.tag +"']").length
|
116 |
|
117 |
var text = (listField.name.length > 25) ? listField.name.substring(0, 25) + '..' : listField.name;
|
118 |
if(listField.req) { text += '*'; }
|
@@ -138,7 +136,7 @@
|
|
138 |
var listGrouping = list.interest_groupings[i];
|
139 |
|
140 |
// add field to select if no similar option exists yet
|
141 |
-
if($mailchimpGroupings.find("option[value='"+ listGrouping.id +"']").length
|
142 |
var text = (listGrouping.name.length > 25) ? listGrouping.name.substring(0, 25) + '..' : listGrouping.name;
|
143 |
|
144 |
// build option HTML
|
@@ -324,13 +322,13 @@
|
|
324 |
'dropdown': 'select', 'date': 'date', 'birthday': 'date', 'radio': 'radio', 'checkbox': 'checkbox'
|
325 |
};
|
326 |
|
327 |
-
if(fieldTypesMap[data.field_type]
|
328 |
fieldType = fieldTypesMap[data.field_type];
|
329 |
} else {
|
330 |
fieldType = 'text';
|
331 |
}
|
332 |
-
|
333 |
-
if(visibleRowsMap[fieldType]
|
334 |
var visibleRows = visibleRowsMap[fieldType];
|
335 |
} else {
|
336 |
var visibleRows = visibleRowsMap["default"];
|
@@ -443,7 +441,7 @@
|
|
443 |
}
|
444 |
|
445 |
// only do this piece when we're not adding radio inputs
|
446 |
-
if(fieldType
|
447 |
|
448 |
// set name attribute
|
449 |
if(fieldName.length > 0) {
|
@@ -452,7 +450,7 @@
|
|
452 |
|
453 |
// set value
|
454 |
if($value.is(":visible") && $value.val().length > 0) {
|
455 |
-
if(fieldType
|
456 |
$input.text($value.val());
|
457 |
} else {
|
458 |
$input.attr('value', $value.val());
|
@@ -482,8 +480,7 @@
|
|
482 |
$code.wrapInner($("<p />"));
|
483 |
}
|
484 |
|
485 |
-
|
486 |
-
setCodePreview(html);
|
487 |
}
|
488 |
|
489 |
/**
|
@@ -494,7 +491,7 @@
|
|
494 |
var result = false;
|
495 |
|
496 |
// try to insert in QuickTags editor at cursor position
|
497 |
-
if(typeof wpActiveEditor
|
498 |
result = QTags.insertContent($codePreview.val());
|
499 |
}
|
500 |
|
36 |
$(document).delegate('#mc4wpformmarkup', 'keydown', function(e) {
|
37 |
var keyCode = e.keyCode || e.which;
|
38 |
|
39 |
+
if (keyCode === 9) {
|
40 |
e.preventDefault();
|
41 |
var start = this.selectionStart;
|
42 |
var end = this.selectionEnd;
|
43 |
|
44 |
// set textarea value to: text before caret + tab + text after caret
|
45 |
+
$(this).val($(this).val().substring(0, start) + "\t" + $(this).val().substring(end));
|
|
|
|
|
46 |
|
47 |
// put caret at right position again
|
48 |
this.selectionStart =
|
54 |
// Add buttons to QTags editor
|
55 |
(function() {
|
56 |
|
57 |
+
if ( typeof(QTags) === 'undefined' ) {
|
58 |
return;
|
59 |
}
|
60 |
|
63 |
QTags.addButton( 'mc4wp_response', 'form response', '{response}', '', 'response', 'Shows the form response' );
|
64 |
QTags.addButton( 'mc4wp_subscriber_count', '# of subscribers', '{subscriber_count}', '', 'subscribers', 'Shows number of subscribers of selected list(s)' );
|
65 |
|
66 |
+
if( window.mc4wp.hasCaptchaPlugin === true ) {
|
67 |
QTags.addButton( 'mc4wp_captcha', 'CAPTCHA', '{captcha}', '', 'captcha', 'Display a CAPTCHA field' );
|
68 |
}
|
69 |
})();
|
110 |
var listField = list.merge_vars[i];
|
111 |
|
112 |
// add field to select if no similar option exists yet
|
113 |
+
if($mailchimpMergeFields.find("option[value='"+ listField.tag +"']").length === 0) {
|
114 |
|
115 |
var text = (listField.name.length > 25) ? listField.name.substring(0, 25) + '..' : listField.name;
|
116 |
if(listField.req) { text += '*'; }
|
136 |
var listGrouping = list.interest_groupings[i];
|
137 |
|
138 |
// add field to select if no similar option exists yet
|
139 |
+
if($mailchimpGroupings.find("option[value='"+ listGrouping.id +"']").length === 0) {
|
140 |
var text = (listGrouping.name.length > 25) ? listGrouping.name.substring(0, 25) + '..' : listGrouping.name;
|
141 |
|
142 |
// build option HTML
|
322 |
'dropdown': 'select', 'date': 'date', 'birthday': 'date', 'radio': 'radio', 'checkbox': 'checkbox'
|
323 |
};
|
324 |
|
325 |
+
if( typeof(fieldTypesMap[data.field_type]) !== "undefined") {
|
326 |
fieldType = fieldTypesMap[data.field_type];
|
327 |
} else {
|
328 |
fieldType = 'text';
|
329 |
}
|
330 |
+
|
331 |
+
if( typeof(visibleRowsMap[fieldType]) !== "undefined") {
|
332 |
var visibleRows = visibleRowsMap[fieldType];
|
333 |
} else {
|
334 |
var visibleRows = visibleRowsMap["default"];
|
441 |
}
|
442 |
|
443 |
// only do this piece when we're not adding radio inputs
|
444 |
+
if(fieldType !== 'radio' && fieldType !== 'checkbox') {
|
445 |
|
446 |
// set name attribute
|
447 |
if(fieldName.length > 0) {
|
450 |
|
451 |
// set value
|
452 |
if($value.is(":visible") && $value.val().length > 0) {
|
453 |
+
if(fieldType === 'textarea') {
|
454 |
$input.text($value.val());
|
455 |
} else {
|
456 |
$input.attr('value', $value.val());
|
480 |
$code.wrapInner($("<p />"));
|
481 |
}
|
482 |
|
483 |
+
setCodePreview($code.html());
|
|
|
484 |
}
|
485 |
|
486 |
/**
|
491 |
var result = false;
|
492 |
|
493 |
// try to insert in QuickTags editor at cursor position
|
494 |
+
if(typeof wpActiveEditor !== 'undefined' && typeof QTags !== 'undefined' && QTags.insertContent) {
|
495 |
result = QTags.insertContent($codePreview.val());
|
496 |
}
|
497 |
|
assets/js/admin.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(a){function b(){"boolean"==typeof this.checked&&(this.checked=!1),alert(mc4wp.strings.proOnlyNotice),event.stopPropagation()}var c=a("#mc4wp-admin");c.find(".pro-feature, .pro-feature label, .pro-feature :radio").click(b),c.find('input[name$="[show_at_woocommerce_checkout]"]').change(function(){c.find("tr#woocommerce-settings").toggle(a(this).prop("checked"))});var d=a("#mc4wp-lists").find(":input");d.change(function(){var b=d.filter(":checked").length>0;a(".mc4wp-notice.no-lists-selected").toggle(!b),a(document.getElementById("mc4wp-fw-fields")).toggle(b),a(document.getElementById("mc4wp-fw-mailchimp-fields")).toggle(b)}),a(document).delegate("#mc4wpformmarkup","keydown",function(b){var c=b.keyCode||b.which;if(9
|
1 |
+
!function(a){function b(){"boolean"==typeof this.checked&&(this.checked=!1),alert(mc4wp.strings.proOnlyNotice),event.stopPropagation()}var c=a("#mc4wp-admin");c.find(".pro-feature, .pro-feature label, .pro-feature :radio").click(b),c.find('input[name$="[show_at_woocommerce_checkout]"]').change(function(){c.find("tr#woocommerce-settings").toggle(a(this).prop("checked"))});var d=a("#mc4wp-lists").find(":input");d.change(function(){var b=d.filter(":checked").length>0;a(".mc4wp-notice.no-lists-selected").toggle(!b),a(document.getElementById("mc4wp-fw-fields")).toggle(b),a(document.getElementById("mc4wp-fw-mailchimp-fields")).toggle(b)}),a(document).delegate("#mc4wpformmarkup","keydown",function(b){var c=b.keyCode||b.which;if(9===c){b.preventDefault();var d=this.selectionStart,e=this.selectionEnd;a(this).val(a(this).val().substring(0,d)+" "+a(this).val().substring(e)),this.selectionStart=this.selectionEnd=d+1}}),function(){"undefined"!=typeof QTags&&(QTags.addButton("mc4wp_paragraph","<p>","<p>","</p>","paragraph","Paragraph tag",1),QTags.addButton("mc4wp_label","label","<label>","</label>","label","Label tag",2),QTags.addButton("mc4wp_response","form response","{response}","","response","Shows the form response"),QTags.addButton("mc4wp_subscriber_count","# of subscribers","{subscriber_count}","","subscribers","Shows number of subscribers of selected list(s)"),window.mc4wp.hasCaptchaPlugin===!0&&QTags.addButton("mc4wp_captcha","CAPTCHA","{captcha}","","captcha","Display a CAPTCHA field"))}(),function(){"use strict";function b(){p.find("option").not(".default").remove(),o.filter(":checked").each(function(){for(var b=a(this).val(),c=mc4wp.mailchimpLists[b],d=0,e=c.merge_vars.length;e>d;d++){var f=c.merge_vars[d];if(0===q.find("option[value='"+f.tag+"']").length){var g=f.name.length>25?f.name.substring(0,25)+"..":f.name;f.req&&(g+="*");var h=a("<option />").text(g).val(f.tag).data("list-field",f);d>3&&h.text(B.proOnly+" "+g).attr("disabled","disabled").data("field",null),q.append(h)}}for(var d=0,i=c.interest_groupings.length;i>d;d++){var j=c.interest_groupings[d];if(0===r.find("option[value='"+j.id+"']").length){var g=j.name.length>25?j.name.substring(0,25)+"..":j.name,h=a("<option />").text(g).val(j.id).data("list-grouping",j);d>=1&&h.text(B.proOnly+" "+g).attr("disabled","disabled").data("list-grouping",null),r.append(h)}}})}function c(){d();var b=a(this).find(":selected");switch(b.val()){case"submit":m="submit",u.text(B.buttonText),t.val(B.subscribe),s.find("p.row").filter(".value, .wrap-p").show();break;case"lists":m="lists",s.find(".wrap-p").show();break;default:var c=b.data("list-field");if(c)return h(c);var c=b.data("list-grouping");if(c)return f(c)}j()}function d(){s.find(".row :input").each(function(){a(this).is(":checkbox")?this.checked=!0:this.value=""}),s.find("p.row").hide(),v.find(":input").remove(),s.show(),m="text",n="",u.html(B.initialValue+" <small>"+B.optional+"</small>")}function e(b){for(var c=0,d=b.length;d>c;c++)a("<input />").attr("type","text").addClass("widefat").data("value",b[c].name).attr("placeholder",B.labelFor+' "'+b[c].name+'" '+B.orLeaveEmpty).attr("value",b[c].name).appendTo(v)}function f(a){switch(s.find("p.row").filter(".values, .label, .wrap-p").show(),w.val(a.name+":"),n="GROUPINGS["+a.id+"]",e(a.groups),a.form_field){case"radio":m="radio";break;case"hidden":s.find("p.row").filter(".values, .label, .wrap-p").hide(),s.find("p.row.value").show();for(var b=0,c=a.groups.length;c>b;b++)t.val(t.val()+a.groups[b].name+",");m="hidden";break;case"dropdown":m="select";break;default:m="checkbox",n+="[]"}j()}function g(){var b="";return o.each(function(){var c=a(this).val(),d=a(this).parent("label").text(),e="";a(this).is(":checked")&&(e+="checked "),b+="<label>\n",b+=' <input type="checkbox" name="_mc4wp_lists[]" value="'+c+'" '+e+" /> "+d+"\n",b+="</label>\n"}),b}function h(b){var c={"default":["label","value","placeholder","required","wrap-p"],select:["label","required","wrap-p","values"],radio:["label","required","wrap-p","values"],date:["label","required","wrap-p","value"]},d={text:"text",email:"email",phone:"tel",address:"text",number:"number",dropdown:"select",date:"date",birthday:"date",radio:"radio",checkbox:"checkbox"};if(m="undefined"!=typeof d[b.field_type]?d[b.field_type]:"text","undefined"!=typeof c[m])var e=c[m];else var e=c["default"];for(var f=0;f<e.length;f++)s.find("p.row."+e[f]).show();if(m=m,n=b.tag,x.val("Your "+b.name.toLowerCase()),w.val(b.name+":"),y.attr("checked",b.req),v.is(":visible")&&b.choices)for(var f=0;f<b.choices.length;f++)a("<input />").attr("type","text").addClass("widefat").data("value",b.choices[f]).attr("placeholder",B.labelFor+' "'+b.choices[f]+'" '+B.orLeaveEmpty).attr("value",b.choices[f]).appendTo(v);j()}function i(a){a=html_beautify(a),A.val(a)}function j(){var b,c=a("<div></div>");switch(m){case"lists":var d=g();return l()&&(d="<p>"+d+"</p>"),i(d);case"select":b=a("<select />"),v.find(":input").each(function(){a(this).val().length>0&&a("<option />").val(a(this).data("value")).text(a(this).val()).appendTo(b)});break;case"radio":case"checkbox":v.find(":input").each(function(){a(this).val().length>0&&(b=a("<input />").attr("type",m).attr("name",n).val(a(this).data("value")),y.is(":visible:checked")&&b.attr("required",!0),c.append(b),b.wrap("<label />"),a("<span />").text(a(this).val()+" ").insertAfter(b))});break;case"textarea":b=a("<textarea />");break;default:b=a("<input />").attr("type",m)}"radio"!==m&&"checkbox"!==m&&(n.length>0&&b.attr("name",n),t.is(":visible")&&t.val().length>0&&("textarea"===m?b.text(t.val()):b.attr("value",t.val())),x.is(":visible")&&x.val().length>0&&b.attr("placeholder",x.val()),y.is(":visible:checked")&&b.attr("required",!0),c.append(b)),w.is(":visible")&&w.val().length>0&&a("<label />").text(w.val()).prependTo(c),l()&&c.wrapInner(a("<p />")),i(c.html())}function k(){var b=!1;if("undefined"!=typeof wpActiveEditor&&"undefined"!=typeof QTags&&QTags.insertContent&&(b=QTags.insertContent(A.val())),!b){var c=a(document.getElementById("mc4wpformmarkup"));c.val(c.val()+"\n"+A.val())}}function l(){return z.is(":visible:checked")?!0:!1}var m,n,o=a("#mc4wp-lists :input"),p=a("#mc4wp-fw-mailchimp-fields"),q=p.find(".merge-fields"),r=p.find(".groupings"),s=a("#mc4wp-fw-fields"),t=a("#mc4wp-fw-value"),u=a("#mc4wp-fw-value-label"),v=a("#mc4wp-fw-values"),w=a("#mc4wp-fw-label"),x=a("#mc4wp-fw-placeholder"),y=a("#mc4wp-fw-required"),z=a("#mc4wp-fw-wrap-p"),A=a("#mc4wp-fw-preview"),B=mc4wp.strings.fieldWizard;o.change(b),p.change(c),s.change(j),a("#mc4wp-fw-add-to-form").click(k),b()}()}(jQuery);
|
assets/js/index.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
if( ! defined(
|
3 |
-
header( 'Status: 403 Forbidden' );
|
4 |
-
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
-
exit;
|
6 |
-
}
|
1 |
+
<?php
|
2 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
3 |
+
header( 'Status: 403 Forbidden' );
|
4 |
+
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
+
exit;
|
6 |
+
}
|
assets/js/{beautify-html.js → third-party/beautify-html.js}
RENAMED
File without changes
|
assets/js/{beautify-html.min.js → third-party/beautify-html.min.js}
RENAMED
File without changes
|
assets/js/{placeholders.min.js → third-party/placeholders.min.js}
RENAMED
File without changes
|
assets/sass/index.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
if( ! defined(
|
3 |
-
header( 'Status: 403 Forbidden' );
|
4 |
-
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
-
exit;
|
6 |
-
}
|
1 |
+
<?php
|
2 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
3 |
+
header( 'Status: 403 Forbidden' );
|
4 |
+
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
+
exit;
|
6 |
+
}
|
assets/sass/partials/index.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
if( ! defined(
|
3 |
-
header( 'Status: 403 Forbidden' );
|
4 |
-
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
-
exit;
|
6 |
-
}
|
1 |
+
<?php
|
2 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
3 |
+
header( 'Status: 403 Forbidden' );
|
4 |
+
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
+
exit;
|
6 |
+
}
|
includes/class-admin.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if( ! defined(
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
@@ -95,7 +95,7 @@ class MC4WP_Lite_Admin
|
|
95 |
// load the plugin text domain
|
96 |
load_plugin_textdomain( 'mailchimp-for-wp', false, dirname( $this->plugin_file ) . '/languages/' );
|
97 |
|
98 |
-
// store whether this plugin has the BWS captcha plugin running (
|
99 |
$this->has_captcha_plugin = function_exists( 'cptch_display_captcha_custom' );
|
100 |
|
101 |
$this->upgrade();
|
@@ -110,8 +110,8 @@ class MC4WP_Lite_Admin
|
|
110 |
*/
|
111 |
public function set_quicktags_buttons( $settings, $editor_id = '' )
|
112 |
{
|
113 |
-
if( $editor_id !== 'mc4wpformmarkup' ) {
|
114 |
-
return $settings;
|
115 |
}
|
116 |
|
117 |
$settings['buttons'] = 'strong,em,link,img,ul,li,close';
|
@@ -120,19 +120,21 @@ class MC4WP_Lite_Admin
|
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
129 |
if( $file !== $this->plugin_file ) {
|
130 |
return $links;
|
131 |
}
|
132 |
|
133 |
$settings_link = '<a href="admin.php?page=mailchimp-for-wp">'. __( 'Settings', 'mailchimp-for-wp' ) . '</a>';
|
134 |
-
|
135 |
-
|
136 |
}
|
137 |
|
138 |
/**
|
@@ -148,14 +150,14 @@ class MC4WP_Lite_Admin
|
|
148 |
return $links;
|
149 |
}
|
150 |
|
151 |
-
$links[] = '<a href="
|
152 |
$links[] = '<a href="https://mc4wp.com/#utm_source=lite-plugin&utm_medium=link&utm_campaign=plugins-upgrade-link">' . __( 'Upgrade to Pro', 'mailchimp-for-wp' ) . '</a>';
|
153 |
return $links;
|
154 |
}
|
155 |
|
156 |
/**
|
157 |
* Register the setting pages and their menu items
|
158 |
-
|
159 |
public function build_menu() {
|
160 |
|
161 |
/**
|
@@ -166,11 +168,43 @@ class MC4WP_Lite_Admin
|
|
166 |
*/
|
167 |
$required_cap = apply_filters( 'mc4wp_settings_cap', 'manage_options' );
|
168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
add_menu_page( 'MailChimp for WP Lite', 'MailChimp for WP', $required_cap, 'mailchimp-for-wp', array($this, 'show_api_settings'), MC4WP_LITE_PLUGIN_URL . 'assets/img/menu-icon.png' );
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
|
|
|
|
|
|
174 |
}
|
175 |
|
176 |
|
@@ -284,13 +318,13 @@ class MC4WP_Lite_Admin
|
|
284 |
}
|
285 |
|
286 |
/**
|
287 |
-
|
|
|
288 |
*/
|
289 |
-
public function load_css_and_js(
|
290 |
-
{
|
291 |
// only load asset files on the MailChimp for WordPress settings pages
|
292 |
-
if(
|
293 |
-
return;
|
294 |
}
|
295 |
|
296 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
@@ -300,7 +334,7 @@ class MC4WP_Lite_Admin
|
|
300 |
wp_enqueue_style( 'mc4wp-admin-css', MC4WP_LITE_PLUGIN_URL . 'assets/css/admin' . $suffix . '.css' );
|
301 |
|
302 |
// js
|
303 |
-
wp_register_script( 'mc4wp-beautifyhtml', MC4WP_LITE_PLUGIN_URL . 'assets/js/beautify-html'. $suffix .'.js', array( 'jquery' ), MC4WP_LITE_VERSION, true );
|
304 |
wp_register_script( 'mc4wp-admin', MC4WP_LITE_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'quicktags' ), MC4WP_LITE_VERSION, true );
|
305 |
wp_enqueue_script( array( 'jquery', 'mc4wp-beautifyhtml', 'mc4wp-admin' ) );
|
306 |
wp_localize_script( 'mc4wp-admin', 'mc4wp',
|
@@ -321,12 +355,14 @@ class MC4WP_Lite_Admin
|
|
321 |
'mailchimpLists' => $mailchimp->get_lists()
|
322 |
)
|
323 |
);
|
|
|
|
|
324 |
}
|
325 |
|
326 |
/**
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
*/
|
331 |
public function get_checkbox_compatible_plugins()
|
332 |
{
|
@@ -337,21 +373,21 @@ class MC4WP_Lite_Admin
|
|
337 |
}
|
338 |
|
339 |
$checkbox_plugins = array(
|
340 |
-
'comment_form' => __(
|
341 |
-
|
342 |
);
|
343 |
|
344 |
if( is_multisite() ) {
|
345 |
-
|
346 |
-
|
347 |
|
348 |
-
if( class_exists(
|
349 |
-
|
350 |
-
|
351 |
|
352 |
-
if( class_exists('bbPress') ) {
|
353 |
-
|
354 |
-
|
355 |
|
356 |
if ( class_exists( 'WooCommerce' ) ) {
|
357 |
$checkbox_plugins['woocommerce_checkout'] = sprintf( __( '%s checkout', 'mailchimp-for-wp' ), 'WooCommerce' );
|
@@ -385,11 +421,15 @@ class MC4WP_Lite_Admin
|
|
385 |
$mailchimp = new MC4WP_MailChimp();
|
386 |
$lists = $mailchimp->get_lists( $force_cache_refresh );
|
387 |
|
|
|
|
|
|
|
|
|
388 |
if ( $force_cache_refresh ) {
|
389 |
if ( false === empty ( $lists ) ) {
|
390 |
-
add_settings_error(
|
391 |
} else {
|
392 |
-
add_settings_error(
|
393 |
}
|
394 |
}
|
395 |
|
1 |
<?php
|
2 |
|
3 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
95 |
// load the plugin text domain
|
96 |
load_plugin_textdomain( 'mailchimp-for-wp', false, dirname( $this->plugin_file ) . '/languages/' );
|
97 |
|
98 |
+
// store whether this plugin has the BWS captcha plugin running (https://wordpress.org/plugins/captcha/)
|
99 |
$this->has_captcha_plugin = function_exists( 'cptch_display_captcha_custom' );
|
100 |
|
101 |
$this->upgrade();
|
110 |
*/
|
111 |
public function set_quicktags_buttons( $settings, $editor_id = '' )
|
112 |
{
|
113 |
+
if( $editor_id !== 'mc4wpformmarkup' ) {
|
114 |
+
return $settings;
|
115 |
}
|
116 |
|
117 |
$settings['buttons'] = 'strong,em,link,img,ul,li,close';
|
120 |
}
|
121 |
|
122 |
/**
|
123 |
+
* Add the settings link to the Plugins overview
|
124 |
+
*
|
125 |
+
* @param array $links
|
126 |
+
* @param $file
|
127 |
+
*
|
128 |
+
* @return array
|
129 |
+
*/
|
130 |
+
public function add_plugin_settings_link( $links, $file ) {
|
131 |
if( $file !== $this->plugin_file ) {
|
132 |
return $links;
|
133 |
}
|
134 |
|
135 |
$settings_link = '<a href="admin.php?page=mailchimp-for-wp">'. __( 'Settings', 'mailchimp-for-wp' ) . '</a>';
|
136 |
+
array_unshift( $links, $settings_link );
|
137 |
+
return $links;
|
138 |
}
|
139 |
|
140 |
/**
|
150 |
return $links;
|
151 |
}
|
152 |
|
153 |
+
$links[] = '<a href="https://wordpress.org/plugins/mailchimp-for-wp/faq/">FAQ</a>';
|
154 |
$links[] = '<a href="https://mc4wp.com/#utm_source=lite-plugin&utm_medium=link&utm_campaign=plugins-upgrade-link">' . __( 'Upgrade to Pro', 'mailchimp-for-wp' ) . '</a>';
|
155 |
return $links;
|
156 |
}
|
157 |
|
158 |
/**
|
159 |
* Register the setting pages and their menu items
|
160 |
+
*/
|
161 |
public function build_menu() {
|
162 |
|
163 |
/**
|
168 |
*/
|
169 |
$required_cap = apply_filters( 'mc4wp_settings_cap', 'manage_options' );
|
170 |
|
171 |
+
$menu_items = array(
|
172 |
+
array(
|
173 |
+
'title' => __( 'MailChimp API Settings', 'mailchimp-for-wp' ),
|
174 |
+
'text' => __( 'MailChimp', 'mailchimp-for-wp' ),
|
175 |
+
'slug' => '',
|
176 |
+
'callback' => array( $this, 'show_api_settings' ),
|
177 |
+
),
|
178 |
+
array(
|
179 |
+
'title' => __( 'Checkbox Settings', 'mailchimp-for-wp' ),
|
180 |
+
'text' => __( 'Checkboxes', 'mailchimp-for-wp' ),
|
181 |
+
'slug' => 'checkbox-settings',
|
182 |
+
'callback' => array( $this, 'show_checkbox_settings' ),
|
183 |
+
),
|
184 |
+
array(
|
185 |
+
'title' => __( 'Form Settings', 'mailchimp-for-wp' ),
|
186 |
+
'text' => __( 'Forms', 'mailchimp-for-wp' ),
|
187 |
+
'slug' => 'form-settings',
|
188 |
+
'callback' => array( $this, 'show_form_settings' ) ),
|
189 |
+
array(
|
190 |
+
'title' => __( 'Upgrade to Pro', 'mailchimp-for-wp' ),
|
191 |
+
'text' => '<span style="line-height: 20px;"><span class="dashicons dashicons-external"></span> ' .__( 'Upgrade to Pro', 'mailchimp-for-wp' ),
|
192 |
+
'slug' => 'upgrade',
|
193 |
+
'callback' => array( $this, 'redirect_to_pro' ),
|
194 |
+
),
|
195 |
+
);
|
196 |
+
|
197 |
+
$menu_items = apply_filters( 'mc4wp_menu_items', $menu_items );
|
198 |
+
|
199 |
+
// add top menu item
|
200 |
add_menu_page( 'MailChimp for WP Lite', 'MailChimp for WP', $required_cap, 'mailchimp-for-wp', array($this, 'show_api_settings'), MC4WP_LITE_PLUGIN_URL . 'assets/img/menu-icon.png' );
|
201 |
+
|
202 |
+
// add submenu pages
|
203 |
+
foreach( $menu_items as $item ) {
|
204 |
+
$slug = ( '' !== $item['slug'] ) ? "mailchimp-for-wp-{$item['slug']}" : 'mailchimp-for-wp';
|
205 |
+
add_submenu_page( 'mailchimp-for-wp', $item['title'] . ' - MailChimp for WordPress Lite', $item['text'], $required_cap, $slug, $item['callback'] );
|
206 |
+
}
|
207 |
+
|
208 |
}
|
209 |
|
210 |
|
318 |
}
|
319 |
|
320 |
/**
|
321 |
+
* Load scripts and stylesheet on MailChimp for WP Admin pages
|
322 |
+
* @return bool
|
323 |
*/
|
324 |
+
public function load_css_and_js() {
|
|
|
325 |
// only load asset files on the MailChimp for WordPress settings pages
|
326 |
+
if( ! isset( $_GET['page'] ) || strpos( $_GET['page'], 'mailchimp-for-wp' ) !== 0 ) {
|
327 |
+
return false;
|
328 |
}
|
329 |
|
330 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
334 |
wp_enqueue_style( 'mc4wp-admin-css', MC4WP_LITE_PLUGIN_URL . 'assets/css/admin' . $suffix . '.css' );
|
335 |
|
336 |
// js
|
337 |
+
wp_register_script( 'mc4wp-beautifyhtml', MC4WP_LITE_PLUGIN_URL . 'assets/js/third-party/beautify-html'. $suffix .'.js', array( 'jquery' ), MC4WP_LITE_VERSION, true );
|
338 |
wp_register_script( 'mc4wp-admin', MC4WP_LITE_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'quicktags' ), MC4WP_LITE_VERSION, true );
|
339 |
wp_enqueue_script( array( 'jquery', 'mc4wp-beautifyhtml', 'mc4wp-admin' ) );
|
340 |
wp_localize_script( 'mc4wp-admin', 'mc4wp',
|
355 |
'mailchimpLists' => $mailchimp->get_lists()
|
356 |
)
|
357 |
);
|
358 |
+
|
359 |
+
return true;
|
360 |
}
|
361 |
|
362 |
/**
|
363 |
+
* Returns available checkbox integrations
|
364 |
+
*
|
365 |
+
* @return array
|
366 |
*/
|
367 |
public function get_checkbox_compatible_plugins()
|
368 |
{
|
373 |
}
|
374 |
|
375 |
$checkbox_plugins = array(
|
376 |
+
'comment_form' => __( 'Comment form', 'mailchimp-for-wp' ),
|
377 |
+
'registration_form' => __( 'Registration form', 'mailchimp-for-wp' )
|
378 |
);
|
379 |
|
380 |
if( is_multisite() ) {
|
381 |
+
$checkbox_plugins['multisite_form'] = __( 'MultiSite forms', 'mailchimp-for-wp' );
|
382 |
+
}
|
383 |
|
384 |
+
if( class_exists( 'BuddyPress' ) ) {
|
385 |
+
$checkbox_plugins['buddypress_form'] = __( 'BuddyPress registration', 'mailchimp-for-wp' );
|
386 |
+
}
|
387 |
|
388 |
+
if( class_exists( 'bbPress' ) ) {
|
389 |
+
$checkbox_plugins['bbpress_forms'] = 'bbPress';
|
390 |
+
}
|
391 |
|
392 |
if ( class_exists( 'WooCommerce' ) ) {
|
393 |
$checkbox_plugins['woocommerce_checkout'] = sprintf( __( '%s checkout', 'mailchimp-for-wp' ), 'WooCommerce' );
|
421 |
$mailchimp = new MC4WP_MailChimp();
|
422 |
$lists = $mailchimp->get_lists( $force_cache_refresh );
|
423 |
|
424 |
+
if( $lists && count( $lists ) === 100 ) {
|
425 |
+
add_settings_error( 'mc4wp', 'mc4wp-lists-at-limit', __( 'The plugin can only fetch a maximum of 100 lists from MailChimp, only your first 100 lists are shown.', 'mailchimp-for-wp' ) );
|
426 |
+
}
|
427 |
+
|
428 |
if ( $force_cache_refresh ) {
|
429 |
if ( false === empty ( $lists ) ) {
|
430 |
+
add_settings_error( 'mc4wp', 'mc4wp-cache-success', __( 'Renewed MailChimp cache.', 'mailchimp-for-wp' ), 'updated' );
|
431 |
} else {
|
432 |
+
add_settings_error( 'mc4wp', 'mc4wp-cache-error', __( 'Failed to renew MailChimp cache - please try again later.', 'mailchimp-for-wp' ) );
|
433 |
}
|
434 |
}
|
435 |
|
includes/class-api.php
CHANGED
@@ -10,8 +10,8 @@ if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
|
10 |
* Takes care of requests to the MailChimp API
|
11 |
*
|
12 |
* @uses WP_HTTP
|
13 |
-
*/
|
14 |
-
class
|
15 |
|
16 |
/**
|
17 |
* @var string
|
@@ -84,12 +84,12 @@ class MC4WP_Lite_API {
|
|
84 |
if( isset( $result->msg ) && $result->msg === "Everything's Chimpy!" ) {
|
85 |
$this->connected = true;
|
86 |
} elseif( isset( $result->error ) ) {
|
87 |
-
$this->show_error(
|
88 |
}
|
89 |
-
}
|
90 |
-
|
91 |
}
|
92 |
-
|
93 |
return $this->connected;
|
94 |
}
|
95 |
|
@@ -116,7 +116,7 @@ class MC4WP_Lite_API {
|
|
116 |
'double_optin' => $double_optin,
|
117 |
'update_existing' => $update_existing,
|
118 |
'replace_interests' => $replace_interests,
|
119 |
-
'send_welcome' => $send_welcome
|
120 |
);
|
121 |
|
122 |
$response = $this->call( 'lists/subscribe', $data );
|
@@ -145,7 +145,7 @@ class MC4WP_Lite_API {
|
|
145 |
/**
|
146 |
* Gets the Groupings for a given List
|
147 |
* @param string $list_id
|
148 |
-
* @return array|boolean
|
149 |
*/
|
150 |
public function get_list_groupings( $list_id ) {
|
151 |
$result = $this->call( 'lists/interest-groupings', array( 'id' => $list_id ) );
|
@@ -164,13 +164,13 @@ class MC4WP_Lite_API {
|
|
164 |
*/
|
165 |
public function get_lists( $list_ids = array() ) {
|
166 |
$args = array(
|
167 |
-
'limit' => 100
|
168 |
);
|
169 |
|
170 |
// set filter if the $list_ids parameter was set
|
171 |
if( count( $list_ids ) > 0 ) {
|
172 |
$args['filters'] = array(
|
173 |
-
'list_id' => implode( ',', $list_ids )
|
174 |
);
|
175 |
}
|
176 |
|
@@ -191,7 +191,7 @@ class MC4WP_Lite_API {
|
|
191 |
*/
|
192 |
public function get_lists_with_merge_vars( $list_ids ) {
|
193 |
$result = $this->call( 'lists/merge-vars', array('id' => $list_ids ) );
|
194 |
-
|
195 |
if( is_object( $result ) && isset( $result->data ) ) {
|
196 |
return $result->data;
|
197 |
}
|
@@ -201,7 +201,7 @@ class MC4WP_Lite_API {
|
|
201 |
|
202 |
/**
|
203 |
* Gets the member info for one or multiple emails on a list
|
204 |
-
*
|
205 |
* @param string $list_id
|
206 |
* @param array $emails
|
207 |
* @return array|bool
|
@@ -209,7 +209,7 @@ class MC4WP_Lite_API {
|
|
209 |
public function get_subscriber_info( $list_id, $emails ) {
|
210 |
$result = $this->call( 'lists/member-info', array(
|
211 |
'id' => $list_id,
|
212 |
-
'emails' => $emails
|
213 |
)
|
214 |
);
|
215 |
|
@@ -234,7 +234,7 @@ class MC4WP_Lite_API {
|
|
234 |
// default to using email for updating
|
235 |
if( ! is_array( $email ) ) {
|
236 |
$email = array(
|
237 |
-
'email' => $email
|
238 |
);
|
239 |
}
|
240 |
|
@@ -243,7 +243,7 @@ class MC4WP_Lite_API {
|
|
243 |
'email' => $email,
|
244 |
'merge_vars' => $merge_vars,
|
245 |
'email_type' => $email_type,
|
246 |
-
'replace_interests' => $replace_interests
|
247 |
)
|
248 |
);
|
249 |
|
@@ -272,7 +272,7 @@ class MC4WP_Lite_API {
|
|
272 |
$member_info = $this->get_subscriber_info( $list_id, array( array( 'email' => $email ) ) );
|
273 |
|
274 |
if( is_array( $member_info ) && isset( $member_info[0] ) ) {
|
275 |
-
return ( $member_info[0]->status ===
|
276 |
}
|
277 |
|
278 |
return false;
|
@@ -294,7 +294,7 @@ class MC4WP_Lite_API {
|
|
294 |
if( ! is_array( $struct ) ) {
|
295 |
// assume $struct is an email
|
296 |
$struct = array(
|
297 |
-
'email' => $struct
|
298 |
);
|
299 |
}
|
300 |
|
@@ -303,7 +303,7 @@ class MC4WP_Lite_API {
|
|
303 |
'email' => $struct,
|
304 |
'delete_member' => $delete_member,
|
305 |
'send_goodbye' => $send_goodbye,
|
306 |
-
'send_notify' => $send_notification
|
307 |
)
|
308 |
);
|
309 |
|
@@ -333,32 +333,34 @@ class MC4WP_Lite_API {
|
|
333 |
*/
|
334 |
public function call( $method, array $data = array() ) {
|
335 |
// do not make request when no api key was provided.
|
336 |
-
if( empty( $this->api_key ) ) {
|
337 |
-
return false;
|
338 |
}
|
339 |
|
340 |
$data['apikey'] = $this->api_key;
|
341 |
$url = $this->api_url . $method . '.json';
|
342 |
|
343 |
-
$response = wp_remote_post( $url, array(
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
|
|
|
|
350 |
|
351 |
// test for wp errors
|
352 |
if( is_wp_error( $response ) ) {
|
353 |
// show error message to admins
|
354 |
-
$this->show_error(
|
355 |
return false;
|
356 |
}
|
357 |
|
358 |
// dirty fix for older WP versions
|
359 |
if( $method === 'helper/ping' && is_array( $response ) && isset( $response['headers']['content-length'] ) && (int) $response['headers']['content-length'] === 44 ) {
|
360 |
return (object) array(
|
361 |
-
'msg' => "Everything's Chimpy!"
|
362 |
);
|
363 |
}
|
364 |
|
10 |
* Takes care of requests to the MailChimp API
|
11 |
*
|
12 |
* @uses WP_HTTP
|
13 |
+
*/
|
14 |
+
class MC4WP_API {
|
15 |
|
16 |
/**
|
17 |
* @var string
|
84 |
if( isset( $result->msg ) && $result->msg === "Everything's Chimpy!" ) {
|
85 |
$this->connected = true;
|
86 |
} elseif( isset( $result->error ) ) {
|
87 |
+
$this->show_error( 'MailChimp Error: ' . $result->error );
|
88 |
}
|
89 |
+
}
|
90 |
+
|
91 |
}
|
92 |
+
|
93 |
return $this->connected;
|
94 |
}
|
95 |
|
116 |
'double_optin' => $double_optin,
|
117 |
'update_existing' => $update_existing,
|
118 |
'replace_interests' => $replace_interests,
|
119 |
+
'send_welcome' => $send_welcome,
|
120 |
);
|
121 |
|
122 |
$response = $this->call( 'lists/subscribe', $data );
|
145 |
/**
|
146 |
* Gets the Groupings for a given List
|
147 |
* @param string $list_id
|
148 |
+
* @return array|boolean
|
149 |
*/
|
150 |
public function get_list_groupings( $list_id ) {
|
151 |
$result = $this->call( 'lists/interest-groupings', array( 'id' => $list_id ) );
|
164 |
*/
|
165 |
public function get_lists( $list_ids = array() ) {
|
166 |
$args = array(
|
167 |
+
'limit' => 100,
|
168 |
);
|
169 |
|
170 |
// set filter if the $list_ids parameter was set
|
171 |
if( count( $list_ids ) > 0 ) {
|
172 |
$args['filters'] = array(
|
173 |
+
'list_id' => implode( ',', $list_ids ),
|
174 |
);
|
175 |
}
|
176 |
|
191 |
*/
|
192 |
public function get_lists_with_merge_vars( $list_ids ) {
|
193 |
$result = $this->call( 'lists/merge-vars', array('id' => $list_ids ) );
|
194 |
+
|
195 |
if( is_object( $result ) && isset( $result->data ) ) {
|
196 |
return $result->data;
|
197 |
}
|
201 |
|
202 |
/**
|
203 |
* Gets the member info for one or multiple emails on a list
|
204 |
+
*
|
205 |
* @param string $list_id
|
206 |
* @param array $emails
|
207 |
* @return array|bool
|
209 |
public function get_subscriber_info( $list_id, $emails ) {
|
210 |
$result = $this->call( 'lists/member-info', array(
|
211 |
'id' => $list_id,
|
212 |
+
'emails' => $emails,
|
213 |
)
|
214 |
);
|
215 |
|
234 |
// default to using email for updating
|
235 |
if( ! is_array( $email ) ) {
|
236 |
$email = array(
|
237 |
+
'email' => $email,
|
238 |
);
|
239 |
}
|
240 |
|
243 |
'email' => $email,
|
244 |
'merge_vars' => $merge_vars,
|
245 |
'email_type' => $email_type,
|
246 |
+
'replace_interests' => $replace_interests,
|
247 |
)
|
248 |
);
|
249 |
|
272 |
$member_info = $this->get_subscriber_info( $list_id, array( array( 'email' => $email ) ) );
|
273 |
|
274 |
if( is_array( $member_info ) && isset( $member_info[0] ) ) {
|
275 |
+
return ( $member_info[0]->status === 'subscribed' );
|
276 |
}
|
277 |
|
278 |
return false;
|
294 |
if( ! is_array( $struct ) ) {
|
295 |
// assume $struct is an email
|
296 |
$struct = array(
|
297 |
+
'email' => $struct,
|
298 |
);
|
299 |
}
|
300 |
|
303 |
'email' => $struct,
|
304 |
'delete_member' => $delete_member,
|
305 |
'send_goodbye' => $send_goodbye,
|
306 |
+
'send_notify' => $send_notification,
|
307 |
)
|
308 |
);
|
309 |
|
333 |
*/
|
334 |
public function call( $method, array $data = array() ) {
|
335 |
// do not make request when no api key was provided.
|
336 |
+
if( empty( $this->api_key ) ) {
|
337 |
+
return false;
|
338 |
}
|
339 |
|
340 |
$data['apikey'] = $this->api_key;
|
341 |
$url = $this->api_url . $method . '.json';
|
342 |
|
343 |
+
$response = wp_remote_post( $url, array(
|
344 |
+
'body' => $data,
|
345 |
+
'timeout' => 15,
|
346 |
+
'headers' => array(
|
347 |
+
'Accept-Encoding' => '',
|
348 |
+
),
|
349 |
+
'sslverify' => false,
|
350 |
+
)
|
351 |
+
);
|
352 |
|
353 |
// test for wp errors
|
354 |
if( is_wp_error( $response ) ) {
|
355 |
// show error message to admins
|
356 |
+
$this->show_error( 'HTTP Error: ' . $response->get_error_message() );
|
357 |
return false;
|
358 |
}
|
359 |
|
360 |
// dirty fix for older WP versions
|
361 |
if( $method === 'helper/ping' && is_array( $response ) && isset( $response['headers']['content-length'] ) && (int) $response['headers']['content-length'] === 44 ) {
|
362 |
return (object) array(
|
363 |
+
'msg' => "Everything's Chimpy!",
|
364 |
);
|
365 |
}
|
366 |
|
includes/class-checkbox-manager.php
CHANGED
@@ -26,41 +26,41 @@ class MC4WP_Lite_Checkbox_Manager
|
|
26 |
*/
|
27 |
public function __construct()
|
28 |
{
|
29 |
-
|
30 |
|
31 |
-
|
32 |
-
|
33 |
add_action( 'login_enqueue_scripts', array( $this, 'load_stylesheet' ) );
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
|
65 |
// Load Events Manager integration
|
66 |
if( defined( 'EM_VERSION' ) ) {
|
@@ -89,14 +89,14 @@ class MC4WP_Lite_Checkbox_Manager
|
|
89 |
*/
|
90 |
public function load_stylesheet( ) {
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
|
96 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
97 |
|
98 |
wp_enqueue_style( 'mailchimp-for-wp-checkbox', MC4WP_LITE_PLUGIN_URL . 'assets/css/checkbox' . $suffix . '.css', array(), MC4WP_LITE_VERSION, 'all' );
|
99 |
-
|
100 |
}
|
101 |
|
102 |
}
|
26 |
*/
|
27 |
public function __construct()
|
28 |
{
|
29 |
+
$this->options = mc4wp_get_options( 'checkbox' );
|
30 |
|
31 |
+
// load checkbox css if necessary
|
32 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'load_stylesheet' ) );
|
33 |
add_action( 'login_enqueue_scripts', array( $this, 'load_stylesheet' ) );
|
34 |
|
35 |
+
// Load WP Comment Form Integration
|
36 |
+
if ( $this->options['show_at_comment_form'] ) {
|
37 |
+
$this->integrations['comment_form'] = new MC4WP_Comment_Form_Integration();
|
38 |
+
}
|
39 |
|
40 |
+
// Load WordPress Registration Form Integration
|
41 |
+
if ( $this->options['show_at_registration_form'] ) {
|
42 |
+
$this->integrations['registration_form'] = new MC4WP_Registration_Form_Integration();
|
43 |
+
}
|
44 |
|
45 |
+
// Load BuddyPress Integration
|
46 |
+
if ( $this->options['show_at_buddypress_form'] ) {
|
47 |
+
$this->integrations['buddypress_form'] = new MC4WP_BuddyPress_Integration();
|
48 |
+
}
|
49 |
|
50 |
+
// Load MultiSite Integration
|
51 |
+
if ( $this->options['show_at_multisite_form'] ) {
|
52 |
+
$this->integrations['multisite_form'] = new MC4WP_MultiSite_Integration();
|
53 |
+
}
|
54 |
|
55 |
+
// Load bbPress Integration
|
56 |
+
if ( $this->options['show_at_bbpress_forms'] ) {
|
57 |
+
$this->integrations['bbpress_forms'] = new MC4WP_bbPress_Integration();
|
58 |
+
}
|
59 |
|
60 |
+
// Load CF7 Integration
|
61 |
+
if( function_exists( 'wpcf7_add_shortcode' ) ) {
|
62 |
+
$this->integrations['contact_form_7'] = new MC4WP_CF7_Integration();
|
63 |
+
}
|
64 |
|
65 |
// Load Events Manager integration
|
66 |
if( defined( 'EM_VERSION' ) ) {
|
89 |
*/
|
90 |
public function load_stylesheet( ) {
|
91 |
|
92 |
+
if( $this->options['css'] == false ) {
|
93 |
+
return false;
|
94 |
+
}
|
95 |
|
96 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
97 |
|
98 |
wp_enqueue_style( 'mailchimp-for-wp-checkbox', MC4WP_LITE_PLUGIN_URL . 'assets/css/checkbox' . $suffix . '.css', array(), MC4WP_LITE_VERSION, 'all' );
|
99 |
+
return true;
|
100 |
}
|
101 |
|
102 |
}
|
includes/class-form-manager.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if( ! defined(
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
@@ -34,8 +34,8 @@ class MC4WP_Lite_Form_Manager {
|
|
34 |
add_filter( 'widget_text', 'shortcode_unautop' );
|
35 |
add_filter( 'widget_text', 'do_shortcode', 11 );
|
36 |
|
37 |
-
|
38 |
-
|
39 |
|
40 |
/**
|
41 |
* @deprecated
|
@@ -60,7 +60,7 @@ class MC4WP_Lite_Form_Manager {
|
|
60 |
// frontend only
|
61 |
if( ! is_admin() ) {
|
62 |
// register placeholder script, which will later be enqueued for IE only
|
63 |
-
wp_register_script( 'mc4wp-placeholders', MC4WP_LITE_PLUGIN_URL . 'assets/js/placeholders.min.js', array(), MC4WP_LITE_VERSION, true );
|
64 |
|
65 |
// register non-AJAX script (that handles form submissions)
|
66 |
wp_register_script( 'mc4wp-form-request', MC4WP_LITE_PLUGIN_URL . 'assets/js/form-request' . $suffix . '.js', array(), MC4WP_LITE_VERSION, true );
|
@@ -72,26 +72,26 @@ class MC4WP_Lite_Form_Manager {
|
|
72 |
* Load the form stylesheet(s)
|
73 |
*/
|
74 |
public function load_stylesheet( ) {
|
75 |
-
$opts = mc4wp_get_options('form');
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
82 |
|
83 |
-
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
|
95 |
}
|
96 |
|
97 |
/**
|
@@ -144,13 +144,13 @@ class MC4WP_Lite_Form_Manager {
|
|
144 |
}
|
145 |
|
146 |
// Get form options
|
147 |
-
$opts = mc4wp_get_options('form');
|
148 |
|
149 |
// was this form submitted?
|
150 |
$was_submitted = ( is_object( $this->form_request ) && $this->form_request->get_form_instance_number() === $this->form_instance_number );
|
151 |
|
152 |
// Generate opening HTML
|
153 |
-
$opening_html =
|
154 |
$opening_html .= '<div id="mc4wp-form-' . $this->form_instance_number . '" class="' . $this->get_css_classes() . '">';
|
155 |
|
156 |
// Generate before & after fields HTML
|
@@ -255,7 +255,7 @@ class MC4WP_Lite_Form_Manager {
|
|
255 |
$visible_fields = str_ireplace( '{response}', $response_html, $visible_fields );
|
256 |
|
257 |
// Generate closing HTML
|
258 |
-
$closing_html =
|
259 |
|
260 |
// increase form instance number in case there is more than one form on a page
|
261 |
$this->form_instance_number++;
|
1 |
<?php
|
2 |
|
3 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
34 |
add_filter( 'widget_text', 'shortcode_unautop' );
|
35 |
add_filter( 'widget_text', 'do_shortcode', 11 );
|
36 |
|
37 |
+
// load checkbox css if necessary
|
38 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'load_stylesheet' ) );
|
39 |
|
40 |
/**
|
41 |
* @deprecated
|
60 |
// frontend only
|
61 |
if( ! is_admin() ) {
|
62 |
// register placeholder script, which will later be enqueued for IE only
|
63 |
+
wp_register_script( 'mc4wp-placeholders', MC4WP_LITE_PLUGIN_URL . 'assets/js/third-party/placeholders.min.js', array(), MC4WP_LITE_VERSION, true );
|
64 |
|
65 |
// register non-AJAX script (that handles form submissions)
|
66 |
wp_register_script( 'mc4wp-form-request', MC4WP_LITE_PLUGIN_URL . 'assets/js/form-request' . $suffix . '.js', array(), MC4WP_LITE_VERSION, true );
|
72 |
* Load the form stylesheet(s)
|
73 |
*/
|
74 |
public function load_stylesheet( ) {
|
75 |
+
$opts = mc4wp_get_options( 'form' );
|
76 |
|
77 |
+
if( $opts['css'] == false ) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
|
81 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
|
82 |
|
83 |
+
if( $opts['css'] != 1 && $opts['css'] !== 'default' ) {
|
84 |
|
85 |
+
$form_theme = $opts['css'];
|
86 |
+
if( in_array( $form_theme, array( 'blue', 'green', 'dark', 'light', 'red' ) ) ) {
|
87 |
+
wp_enqueue_style( 'mailchimp-for-wp-form-theme-' . $opts['css'], MC4WP_LITE_PLUGIN_URL . 'assets/css/form-theme-' . $opts['css'] . $suffix . '.css', array(), MC4WP_LITE_VERSION, 'all' );
|
88 |
+
}
|
89 |
|
90 |
+
} else {
|
91 |
+
wp_enqueue_style( 'mailchimp-for-wp-form', MC4WP_LITE_PLUGIN_URL . 'assets/css/form' . $suffix . '.css', array(), MC4WP_LITE_VERSION, 'all' );
|
92 |
+
}
|
93 |
|
94 |
+
return true;
|
95 |
}
|
96 |
|
97 |
/**
|
144 |
}
|
145 |
|
146 |
// Get form options
|
147 |
+
$opts = mc4wp_get_options( 'form' );
|
148 |
|
149 |
// was this form submitted?
|
150 |
$was_submitted = ( is_object( $this->form_request ) && $this->form_request->get_form_instance_number() === $this->form_instance_number );
|
151 |
|
152 |
// Generate opening HTML
|
153 |
+
$opening_html = '<!-- Form by MailChimp for WordPress plugin v'. MC4WP_LITE_VERSION .' - https://mc4wp.com/ -->';
|
154 |
$opening_html .= '<div id="mc4wp-form-' . $this->form_instance_number . '" class="' . $this->get_css_classes() . '">';
|
155 |
|
156 |
// Generate before & after fields HTML
|
255 |
$visible_fields = str_ireplace( '{response}', $response_html, $visible_fields );
|
256 |
|
257 |
// Generate closing HTML
|
258 |
+
$closing_html = '</div><!-- / MailChimp for WP Plugin -->';
|
259 |
|
260 |
// increase form instance number in case there is more than one form on a page
|
261 |
$this->form_instance_number++;
|
includes/class-form-request.php
CHANGED
@@ -364,7 +364,7 @@ class MC4WP_Lite_Form_Request {
|
|
364 |
// format new grouping
|
365 |
$grouping = array(
|
366 |
'id' => $grouping->id,
|
367 |
-
'groups' => $group_data
|
368 |
);
|
369 |
|
370 |
// make sure groups is an array
|
@@ -639,7 +639,7 @@ class MC4WP_Lite_Form_Request {
|
|
639 |
*
|
640 |
* Used to alter the error message, don't use. Use `mc4wp_form_messages` instead.
|
641 |
*/
|
642 |
-
$message['text'] = apply_filters('mc4wp_form_error_message', $message['text'], $this->error_code );
|
643 |
|
644 |
$html = '<div class="mc4wp-alert mc4wp-'. $message['type'].'">' . $message['text'] . '</div>';
|
645 |
|
@@ -673,32 +673,32 @@ class MC4WP_Lite_Form_Request {
|
|
673 |
$messages = array(
|
674 |
'already_subscribed' => array(
|
675 |
'type' => 'notice',
|
676 |
-
'text' => $this->form_options['text_already_subscribed']
|
677 |
),
|
678 |
'error' => array(
|
679 |
'type' => 'error',
|
680 |
-
'text' => $this->form_options['text_error']
|
681 |
),
|
682 |
'invalid_email' => array(
|
683 |
'type' => 'error',
|
684 |
-
'text' => $this->form_options['text_invalid_email']
|
685 |
),
|
686 |
'success' => array(
|
687 |
'type' => 'success',
|
688 |
-
'text' => $this->form_options['text_success']
|
689 |
),
|
690 |
'invalid_captcha' => array(
|
691 |
'type' => 'error',
|
692 |
-
'text' => $this->form_options['text_invalid_captcha']
|
693 |
),
|
694 |
'required_field_missing' => array(
|
695 |
'type' => 'error',
|
696 |
-
'text' => $this->form_options['text_required_field_missing']
|
697 |
),
|
698 |
'no_lists_selected' => array(
|
699 |
'type' => 'error',
|
700 |
-
'text' => __( 'Please select at least one list to subscribe to.', 'mailchimp-for-wp' )
|
701 |
-
)
|
702 |
);
|
703 |
|
704 |
/**
|
364 |
// format new grouping
|
365 |
$grouping = array(
|
366 |
'id' => $grouping->id,
|
367 |
+
'groups' => $group_data,
|
368 |
);
|
369 |
|
370 |
// make sure groups is an array
|
639 |
*
|
640 |
* Used to alter the error message, don't use. Use `mc4wp_form_messages` instead.
|
641 |
*/
|
642 |
+
$message['text'] = apply_filters( 'mc4wp_form_error_message', $message['text'], $this->error_code );
|
643 |
|
644 |
$html = '<div class="mc4wp-alert mc4wp-'. $message['type'].'">' . $message['text'] . '</div>';
|
645 |
|
673 |
$messages = array(
|
674 |
'already_subscribed' => array(
|
675 |
'type' => 'notice',
|
676 |
+
'text' => $this->form_options['text_already_subscribed'],
|
677 |
),
|
678 |
'error' => array(
|
679 |
'type' => 'error',
|
680 |
+
'text' => $this->form_options['text_error'],
|
681 |
),
|
682 |
'invalid_email' => array(
|
683 |
'type' => 'error',
|
684 |
+
'text' => $this->form_options['text_invalid_email'],
|
685 |
),
|
686 |
'success' => array(
|
687 |
'type' => 'success',
|
688 |
+
'text' => $this->form_options['text_success'],
|
689 |
),
|
690 |
'invalid_captcha' => array(
|
691 |
'type' => 'error',
|
692 |
+
'text' => $this->form_options['text_invalid_captcha'],
|
693 |
),
|
694 |
'required_field_missing' => array(
|
695 |
'type' => 'error',
|
696 |
+
'text' => $this->form_options['text_required_field_missing'],
|
697 |
),
|
698 |
'no_lists_selected' => array(
|
699 |
'type' => 'error',
|
700 |
+
'text' => __( 'Please select at least one list to subscribe to.', 'mailchimp-for-wp' ),
|
701 |
+
),
|
702 |
);
|
703 |
|
704 |
/**
|
includes/class-mailchimp.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
if( ! defined(
|
3 |
header( 'Status: 403 Forbidden' );
|
4 |
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
exit;
|
@@ -54,7 +54,7 @@ class MC4WP_MailChimp {
|
|
54 |
}
|
55 |
|
56 |
// get merge vars for all lists at once
|
57 |
-
$merge_vars_data = $api->get_lists_with_merge_vars( array_keys($lists) );
|
58 |
if ( $merge_vars_data ) {
|
59 |
foreach ( $merge_vars_data as $list ) {
|
60 |
// add merge vars to list
|
@@ -173,7 +173,7 @@ class MC4WP_MailChimp {
|
|
173 |
*/
|
174 |
public function strip_unnecessary_group_properties( $group ) {
|
175 |
return (object) array(
|
176 |
-
'name' => $group->name
|
177 |
);
|
178 |
}
|
179 |
|
@@ -188,7 +188,7 @@ class MC4WP_MailChimp {
|
|
188 |
'id' => $grouping->id,
|
189 |
'name' => $grouping->name,
|
190 |
'groups' => array_map( array( $this, 'strip_unnecessary_group_properties' ), $grouping->groups ),
|
191 |
-
'form_field' => $grouping->form_field
|
192 |
);
|
193 |
}
|
194 |
|
@@ -203,15 +203,15 @@ class MC4WP_MailChimp {
|
|
203 |
'name' => $merge_var->name,
|
204 |
'field_type' => $merge_var->field_type,
|
205 |
'req' => $merge_var->req,
|
206 |
-
'tag' => $merge_var->tag
|
207 |
);
|
208 |
|
209 |
if ( isset( $merge_var->choices ) ) {
|
210 |
-
$array[
|
211 |
}
|
212 |
|
213 |
return (object) $array;
|
214 |
|
215 |
}
|
216 |
|
217 |
-
}
|
1 |
<?php
|
2 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
3 |
header( 'Status: 403 Forbidden' );
|
4 |
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
exit;
|
54 |
}
|
55 |
|
56 |
// get merge vars for all lists at once
|
57 |
+
$merge_vars_data = $api->get_lists_with_merge_vars( array_keys( $lists ) );
|
58 |
if ( $merge_vars_data ) {
|
59 |
foreach ( $merge_vars_data as $list ) {
|
60 |
// add merge vars to list
|
173 |
*/
|
174 |
public function strip_unnecessary_group_properties( $group ) {
|
175 |
return (object) array(
|
176 |
+
'name' => $group->name,
|
177 |
);
|
178 |
}
|
179 |
|
188 |
'id' => $grouping->id,
|
189 |
'name' => $grouping->name,
|
190 |
'groups' => array_map( array( $this, 'strip_unnecessary_group_properties' ), $grouping->groups ),
|
191 |
+
'form_field' => $grouping->form_field,
|
192 |
);
|
193 |
}
|
194 |
|
203 |
'name' => $merge_var->name,
|
204 |
'field_type' => $merge_var->field_type,
|
205 |
'req' => $merge_var->req,
|
206 |
+
'tag' => $merge_var->tag,
|
207 |
);
|
208 |
|
209 |
if ( isset( $merge_var->choices ) ) {
|
210 |
+
$array['choices'] = $merge_var->choices;
|
211 |
}
|
212 |
|
213 |
return (object) $array;
|
214 |
|
215 |
}
|
216 |
|
217 |
+
}
|
includes/class-plugin.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if( ! defined(
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
@@ -19,7 +19,7 @@ class MC4WP_Lite {
|
|
19 |
private $checkbox_manager;
|
20 |
|
21 |
/**
|
22 |
-
* @var
|
23 |
*/
|
24 |
private $api = null;
|
25 |
|
@@ -28,7 +28,7 @@ class MC4WP_Lite {
|
|
28 |
*/
|
29 |
public function __construct() {
|
30 |
|
31 |
-
|
32 |
|
33 |
// checkbox
|
34 |
$this->checkbox_manager = new MC4WP_Lite_Checkbox_Manager();
|
@@ -40,17 +40,17 @@ class MC4WP_Lite {
|
|
40 |
add_action( 'widgets_init', array( $this, 'register_widget' ) );
|
41 |
}
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
-
|
49 |
|
50 |
-
|
51 |
|
52 |
$classes = array(
|
53 |
-
'
|
54 |
'MC4WP_Lite_Checkbox_Manager' => 'class-checkbox-manager.php',
|
55 |
'MC4WP_Lite_Form_Manager' => 'class-form-manager.php',
|
56 |
'MC4WP_Lite_Form_Request' => 'class-form-request.php',
|
@@ -68,20 +68,20 @@ class MC4WP_Lite {
|
|
68 |
'MC4WP_MultiSite_Integration' => 'integrations/class-multisite.php',
|
69 |
'MC4WP_Registration_Form_Integration' => 'integrations/class-registration-form.php',
|
70 |
'MC4WP_WooCommerce_Integration' => 'integrations/class-woocommerce.php',
|
71 |
-
'MC4WP_EDD_Integration' => 'integrations/class-edd.php'
|
72 |
);
|
73 |
|
74 |
-
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
-
|
82 |
|
83 |
|
84 |
-
|
85 |
|
86 |
/**
|
87 |
* @return MC4WP_Lite_Checkbox
|
@@ -98,15 +98,15 @@ class MC4WP_Lite {
|
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
-
* @return
|
102 |
*/
|
103 |
public function get_api() {
|
104 |
|
105 |
if( $this->api === null ) {
|
106 |
$opts = mc4wp_get_options();
|
107 |
-
$this->api = new
|
108 |
}
|
109 |
-
|
110 |
return $this->api;
|
111 |
}
|
112 |
|
1 |
<?php
|
2 |
|
3 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
19 |
private $checkbox_manager;
|
20 |
|
21 |
/**
|
22 |
+
* @var MC4WP_API
|
23 |
*/
|
24 |
private $api = null;
|
25 |
|
28 |
*/
|
29 |
public function __construct() {
|
30 |
|
31 |
+
spl_autoload_register( array( $this, 'autoload') );
|
32 |
|
33 |
// checkbox
|
34 |
$this->checkbox_manager = new MC4WP_Lite_Checkbox_Manager();
|
40 |
add_action( 'widgets_init', array( $this, 'register_widget' ) );
|
41 |
}
|
42 |
|
43 |
+
/**
|
44 |
+
* @return bool
|
45 |
+
*/
|
46 |
+
public function autoload( $class_name ) {
|
47 |
|
48 |
+
static $classes = null;
|
49 |
|
50 |
+
if( $classes === null ) {
|
51 |
|
52 |
$classes = array(
|
53 |
+
'MC4WP_API' => 'class-api.php',
|
54 |
'MC4WP_Lite_Checkbox_Manager' => 'class-checkbox-manager.php',
|
55 |
'MC4WP_Lite_Form_Manager' => 'class-form-manager.php',
|
56 |
'MC4WP_Lite_Form_Request' => 'class-form-request.php',
|
68 |
'MC4WP_MultiSite_Integration' => 'integrations/class-multisite.php',
|
69 |
'MC4WP_Registration_Form_Integration' => 'integrations/class-registration-form.php',
|
70 |
'MC4WP_WooCommerce_Integration' => 'integrations/class-woocommerce.php',
|
71 |
+
'MC4WP_EDD_Integration' => 'integrations/class-edd.php',
|
72 |
);
|
73 |
|
74 |
+
}
|
75 |
|
76 |
+
if( isset( $classes[$class_name] ) ) {
|
77 |
+
require_once MC4WP_LITE_PLUGIN_DIR . 'includes/' . $classes[$class_name];
|
78 |
+
return true;
|
79 |
+
}
|
80 |
|
81 |
+
return false;
|
82 |
|
83 |
|
84 |
+
}
|
85 |
|
86 |
/**
|
87 |
* @return MC4WP_Lite_Checkbox
|
98 |
}
|
99 |
|
100 |
/**
|
101 |
+
* @return MC4WP_API
|
102 |
*/
|
103 |
public function get_api() {
|
104 |
|
105 |
if( $this->api === null ) {
|
106 |
$opts = mc4wp_get_options();
|
107 |
+
$this->api = new MC4WP_API( $opts['general']['api_key'] );
|
108 |
}
|
109 |
+
|
110 |
return $this->api;
|
111 |
}
|
112 |
|
includes/class-widget.php
CHANGED
@@ -1,94 +1,94 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
4 |
-
header( 'Status: 403 Forbidden' );
|
5 |
-
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
-
exit;
|
7 |
-
}
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Adds MC4WP_Widget widget.
|
11 |
-
*/
|
12 |
-
class MC4WP_Lite_Widget extends WP_Widget {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Register widget with WordPress.
|
16 |
-
*/
|
17 |
-
function __construct() {
|
18 |
-
parent::__construct(
|
19 |
-
'MC4WP_Widget', // Base ID
|
20 |
-
__( 'MailChimp Sign-Up Form', 'mailchimp-for-wp' ), // Name
|
21 |
-
array(
|
22 |
-
'description' => __( 'Displays your MailChimp for WordPress sign-up form', 'mailchimp-for-wp' ),
|
23 |
-
)
|
24 |
-
);
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Front-end display of widget.
|
29 |
-
*
|
30 |
-
* @see WP_Widget::widget()
|
31 |
-
*
|
32 |
-
* @param array $args Widget arguments.
|
33 |
-
* @param array $instance Saved values from database.
|
34 |
-
*/
|
35 |
-
public function widget( $args, $instance ) {
|
36 |
-
|
37 |
-
$title = isset( $instance['title'] ) ? $instance['title'] : '';
|
38 |
-
$title = apply_filters( 'widget_title', $title );
|
39 |
-
|
40 |
-
echo $args['before_widget'];
|
41 |
-
|
42 |
-
if ( ! empty( $title ) ) {
|
43 |
-
echo $args['before_title'] . $title . $args['after_title'];
|
44 |
-
}
|
45 |
-
|
46 |
-
// make sure template functions exist (for usage in avia layout builder)
|
47 |
-
if ( ! function_exists( 'mc4wp_get_form' ) ) {
|
48 |
-
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions/template.php';
|
49 |
-
}
|
50 |
-
|
51 |
-
echo mc4wp_get_form();
|
52 |
-
|
53 |
-
echo $args['after_widget'];
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Back-end widget form.
|
58 |
-
*
|
59 |
-
* @see WP_Widget::form()
|
60 |
-
*
|
61 |
-
* @param array $instance Previously saved values from database.
|
62 |
-
*
|
63 |
-
* @return string|void
|
64 |
-
*/
|
65 |
-
public function form( $instance ) {
|
66 |
-
$title = isset( $instance['title'] ) ? $instance['title'] : __( 'Newsletter', 'mailchimp-for-wp' );
|
67 |
-
?>
|
68 |
-
|
69 |
-
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'mailchimp-for-wp' ); ?></label>
|
70 |
-
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
71 |
-
|
72 |
-
|
73 |
-
<?php printf( __( 'You can edit your sign-up form in the %sMailChimp for WordPress form settings%s.', 'mailchimp-for-wp' ), '<a href="' . admin_url('admin.php?page=mailchimp-for-wp-form-settings') . '">', '</a>' ); ?>
|
74 |
-
|
75 |
-
<?php
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Sanitize widget form values as they are saved.
|
80 |
-
*
|
81 |
-
* @see WP_Widget::update()
|
82 |
-
*
|
83 |
-
* @param array $new_instance Values just sent to be saved.
|
84 |
-
* @param array $old_instance Previously saved values from database.
|
85 |
-
*
|
86 |
-
* @return array Updated safe values to be saved.
|
87 |
-
*/
|
88 |
-
public function update( $new_instance, $old_instance ) {
|
89 |
-
$instance = array();
|
90 |
-
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : '';
|
91 |
-
return $instance;
|
92 |
-
}
|
93 |
-
|
94 |
-
} // class MC4WP_Widget
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
4 |
+
header( 'Status: 403 Forbidden' );
|
5 |
+
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Adds MC4WP_Widget widget.
|
11 |
+
*/
|
12 |
+
class MC4WP_Lite_Widget extends WP_Widget {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Register widget with WordPress.
|
16 |
+
*/
|
17 |
+
function __construct() {
|
18 |
+
parent::__construct(
|
19 |
+
'MC4WP_Widget', // Base ID
|
20 |
+
__( 'MailChimp Sign-Up Form', 'mailchimp-for-wp' ), // Name
|
21 |
+
array(
|
22 |
+
'description' => __( 'Displays your MailChimp for WordPress sign-up form', 'mailchimp-for-wp' ),
|
23 |
+
)
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Front-end display of widget.
|
29 |
+
*
|
30 |
+
* @see WP_Widget::widget()
|
31 |
+
*
|
32 |
+
* @param array $args Widget arguments.
|
33 |
+
* @param array $instance Saved values from database.
|
34 |
+
*/
|
35 |
+
public function widget( $args, $instance ) {
|
36 |
+
|
37 |
+
$title = isset( $instance['title'] ) ? $instance['title'] : '';
|
38 |
+
$title = apply_filters( 'widget_title', $title );
|
39 |
+
|
40 |
+
echo $args['before_widget'];
|
41 |
+
|
42 |
+
if ( ! empty( $title ) ) {
|
43 |
+
echo $args['before_title'] . $title . $args['after_title'];
|
44 |
+
}
|
45 |
+
|
46 |
+
// make sure template functions exist (for usage in avia layout builder)
|
47 |
+
if ( ! function_exists( 'mc4wp_get_form' ) ) {
|
48 |
+
include_once MC4WP_LITE_PLUGIN_DIR . 'includes/functions/template.php';
|
49 |
+
}
|
50 |
+
|
51 |
+
echo mc4wp_get_form();
|
52 |
+
|
53 |
+
echo $args['after_widget'];
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Back-end widget form.
|
58 |
+
*
|
59 |
+
* @see WP_Widget::form()
|
60 |
+
*
|
61 |
+
* @param array $instance Previously saved values from database.
|
62 |
+
*
|
63 |
+
* @return string|void
|
64 |
+
*/
|
65 |
+
public function form( $instance ) {
|
66 |
+
$title = isset( $instance['title'] ) ? $instance['title'] : __( 'Newsletter', 'mailchimp-for-wp' );
|
67 |
+
?>
|
68 |
+
<p>
|
69 |
+
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'mailchimp-for-wp' ); ?></label>
|
70 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
71 |
+
</p>
|
72 |
+
<p class="help">
|
73 |
+
<?php printf( __( 'You can edit your sign-up form in the %sMailChimp for WordPress form settings%s.', 'mailchimp-for-wp' ), '<a href="' . admin_url( 'admin.php?page=mailchimp-for-wp-form-settings' ) . '">', '</a>' ); ?>
|
74 |
+
</p>
|
75 |
+
<?php
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Sanitize widget form values as they are saved.
|
80 |
+
*
|
81 |
+
* @see WP_Widget::update()
|
82 |
+
*
|
83 |
+
* @param array $new_instance Values just sent to be saved.
|
84 |
+
* @param array $old_instance Previously saved values from database.
|
85 |
+
*
|
86 |
+
* @return array Updated safe values to be saved.
|
87 |
+
*/
|
88 |
+
public function update( $new_instance, $old_instance ) {
|
89 |
+
$instance = array();
|
90 |
+
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : '';
|
91 |
+
return $instance;
|
92 |
+
}
|
93 |
+
|
94 |
+
} // class MC4WP_Widget
|
includes/functions/general.php
CHANGED
@@ -24,7 +24,7 @@ function mc4wp_get_options( $key = '' ) {
|
|
24 |
|
25 |
$defaults = array(
|
26 |
'general' => array(
|
27 |
-
'api_key' => ''
|
28 |
),
|
29 |
'checkbox' => array(
|
30 |
'label' => __( 'Sign me up for the newsletter!', 'mailchimp-for-wp' ),
|
@@ -39,7 +39,7 @@ function mc4wp_get_options( $key = '' ) {
|
|
39 |
'show_at_edd_checkout' => 0,
|
40 |
'lists' => array(),
|
41 |
'double_optin' => 1,
|
42 |
-
'woocommerce_position' => 'order'
|
43 |
),
|
44 |
'form' => array(
|
45 |
'css' => 'default',
|
@@ -56,14 +56,14 @@ function mc4wp_get_options( $key = '' ) {
|
|
56 |
'hide_after_success' => 0,
|
57 |
'update_existing' => false,
|
58 |
'replace_interests' => true,
|
59 |
-
'send_welcome' => false
|
60 |
-
)
|
61 |
);
|
62 |
|
63 |
$db_keys_option_keys = array(
|
64 |
'mc4wp_lite' => 'general',
|
65 |
'mc4wp_lite_checkbox' => 'checkbox',
|
66 |
-
'mc4wp_lite_form' => 'form'
|
67 |
);
|
68 |
|
69 |
$options = array();
|
@@ -89,7 +89,7 @@ function mc4wp_get_options( $key = '' ) {
|
|
89 |
/**
|
90 |
* Gets the MailChimp for WP API class and injects it with the given API key
|
91 |
*
|
92 |
-
* @return
|
93 |
*/
|
94 |
function mc4wp_get_api() {
|
95 |
global $mc4wp;
|
24 |
|
25 |
$defaults = array(
|
26 |
'general' => array(
|
27 |
+
'api_key' => '',
|
28 |
),
|
29 |
'checkbox' => array(
|
30 |
'label' => __( 'Sign me up for the newsletter!', 'mailchimp-for-wp' ),
|
39 |
'show_at_edd_checkout' => 0,
|
40 |
'lists' => array(),
|
41 |
'double_optin' => 1,
|
42 |
+
'woocommerce_position' => 'order',
|
43 |
),
|
44 |
'form' => array(
|
45 |
'css' => 'default',
|
56 |
'hide_after_success' => 0,
|
57 |
'update_existing' => false,
|
58 |
'replace_interests' => true,
|
59 |
+
'send_welcome' => false,
|
60 |
+
),
|
61 |
);
|
62 |
|
63 |
$db_keys_option_keys = array(
|
64 |
'mc4wp_lite' => 'general',
|
65 |
'mc4wp_lite_checkbox' => 'checkbox',
|
66 |
+
'mc4wp_lite_form' => 'form',
|
67 |
);
|
68 |
|
69 |
$options = array();
|
89 |
/**
|
90 |
* Gets the MailChimp for WP API class and injects it with the given API key
|
91 |
*
|
92 |
+
* @return MC4WP_API
|
93 |
*/
|
94 |
function mc4wp_get_api() {
|
95 |
global $mc4wp;
|
includes/functions/template.php
CHANGED
@@ -1,146 +1,146 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if( ! defined(
|
4 |
-
header( 'Status: 403 Forbidden' );
|
5 |
-
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
-
exit;
|
7 |
-
}
|
8 |
-
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Echoes a sign-up checkbox.
|
12 |
-
*/
|
13 |
-
function mc4wp_checkbox() {
|
14 |
-
global $mc4wp;
|
15 |
-
|
16 |
-
// manually instantiate comment form integration class
|
17 |
-
if( ! isset( $mc4wp->get_checkbox_manager()->integrations['comment_form'] ) ) {
|
18 |
-
$mc4wp->get_checkbox_manager()->integrations['comment_form'] = new MC4WP_Comment_Form_Integration();
|
19 |
-
}
|
20 |
-
|
21 |
-
$mc4wp->get_checkbox_manager()->integrations['comment_form']->output_checkbox();
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Echoes a MailChimp for WordPress form
|
26 |
-
*
|
27 |
-
* @param int $id The form ID
|
28 |
-
*/
|
29 |
-
function mc4wp_form( $id = 0 ) {
|
30 |
-
echo mc4wp_get_form( $id );
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Returns HTML for sign-up form with the given $form_id.
|
35 |
-
*
|
36 |
-
* @param int $form_id.
|
37 |
-
* @return string HTML of given form_id.
|
38 |
-
*/
|
39 |
-
function mc4wp_get_form( $id = 0 ) {
|
40 |
-
global $mc4wp;
|
41 |
-
return $mc4wp->get_form_manager()->form( array( 'id' => $id ) );
|
42 |
-
}
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Returns text with {variables} replaced.
|
47 |
-
*
|
48 |
-
* @param string $text
|
49 |
-
* @param array $list_ids Array of list id's
|
50 |
-
* @return string $text The text with {variables} replaced.
|
51 |
-
*/
|
52 |
-
function mc4wp_replace_variables( $text, $list_ids = array() ) {
|
53 |
-
|
54 |
-
// get current WPML language or general site language
|
55 |
-
$language = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : get_locale();
|
56 |
-
|
57 |
-
// replace general vars
|
58 |
-
$needles = array( '{ip}', '{current_url}', '{date}', '{time}', '{language}' );
|
59 |
-
$replacements = array( $_SERVER['REMOTE_ADDR'], mc4wp_get_current_url(), date(
|
60 |
-
$text = str_ireplace( $needles, $replacements, $text );
|
61 |
-
|
62 |
-
// subscriber count? only fetch these if the tag is actually used
|
63 |
-
if ( stristr( $text, '{subscriber_count}' ) !== false ) {
|
64 |
-
$mailchimp = new MC4WP_MailChimp();
|
65 |
-
$subscriber_count = $mailchimp->get_subscriber_count( $list_ids );
|
66 |
-
$text = str_ireplace( '{subscriber_count}', $subscriber_count, $text );
|
67 |
-
}
|
68 |
-
|
69 |
-
// replace {email} tag
|
70 |
-
if( isset( $_GET['mc4wp_email'] ) ) {
|
71 |
-
$email = esc_attr( $_GET['mc4wp_email'] );
|
72 |
-
} elseif( isset( $_COOKIE['mc4wp_email'] ) ) {
|
73 |
-
$email = esc_attr( $_COOKIE['mc4wp_email'] );
|
74 |
-
} else {
|
75 |
-
$email = '';
|
76 |
-
}
|
77 |
-
|
78 |
-
$text = str_ireplace( '{email}', $email, $text );
|
79 |
-
|
80 |
-
// replace user variables
|
81 |
-
$needles = array( '{user_email}', '{user_firstname}', '{user_lastname}', '{user_name}', '{user_id}' );
|
82 |
-
if ( is_user_logged_in() && ( $user = wp_get_current_user() ) && ( $user instanceof WP_User ) ) {
|
83 |
-
// logged in user, replace vars by user vars
|
84 |
-
$replacements = array( $user->user_email, $user->first_name, $user->last_name, $user->display_name, $user->ID );
|
85 |
-
$text = str_replace( $needles, $replacements, $text );
|
86 |
-
} else {
|
87 |
-
// no logged in user, replace vars with empty string
|
88 |
-
$text = str_replace( $needles, '', $text );
|
89 |
-
}
|
90 |
-
|
91 |
-
return $text;
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Retrieves the URL of the current WordPress page
|
96 |
-
*
|
97 |
-
* @return string The current URL, escaped for safe usage inside attributes.
|
98 |
-
*/
|
99 |
-
function mc4wp_get_current_url() {
|
100 |
-
|
101 |
-
global $wp;
|
102 |
-
|
103 |
-
// get requested url from global $wp object
|
104 |
-
$site_request_uri = $wp->request;
|
105 |
-
|
106 |
-
// fix for IIS servers using index.php in the URL
|
107 |
-
if( false !== stripos( $_SERVER['REQUEST_URI'], '/index.php/' . $site_request_uri ) ) {
|
108 |
-
$site_request_uri = 'index.php/' . $site_request_uri;
|
109 |
-
}
|
110 |
-
|
111 |
-
// concatenate request url to home url
|
112 |
-
$url = home_url( $site_request_uri );
|
113 |
-
|
114 |
-
// add trailing slash, if necessary
|
115 |
-
if( substr( $_SERVER['REQUEST_URI'] , -1 ) === '/' ) {
|
116 |
-
$url = trailingslashit( $url );
|
117 |
-
}
|
118 |
-
|
119 |
-
return esc_url( $url );
|
120 |
-
}
|
121 |
-
|
122 |
-
/****************************~***
|
123 |
-
* Deprecated functions *
|
124 |
-
********************************/
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Echoes a sign-up form.
|
128 |
-
*
|
129 |
-
* @deprecated 1.3.1 Use mc4wp_form() instead.
|
130 |
-
* @see mc4wp_form()
|
131 |
-
*/
|
132 |
-
function mc4wp_show_form( $id = 0 ) {
|
133 |
-
_deprecated_function( __FUNCTION__, 'MailChimp for WP v1.3.1', 'mc4wp_form' );
|
134 |
-
mc4wp_form( $id );
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Echoes a sign-up checkbox.
|
139 |
-
*
|
140 |
-
* @deprecated 1.3.1 Use mc4wp_checkbox() instead
|
141 |
-
* @see mc4wp_checkbox()
|
142 |
-
*/
|
143 |
-
function mc4wp_show_checkbox() {
|
144 |
-
_deprecated_function( __FUNCTION__, 'MailChimp for WP v1.3.1', 'mc4wp_form' );
|
145 |
-
mc4wp_checkbox();
|
146 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
4 |
+
header( 'Status: 403 Forbidden' );
|
5 |
+
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Echoes a sign-up checkbox.
|
12 |
+
*/
|
13 |
+
function mc4wp_checkbox() {
|
14 |
+
global $mc4wp;
|
15 |
+
|
16 |
+
// manually instantiate comment form integration class
|
17 |
+
if( ! isset( $mc4wp->get_checkbox_manager()->integrations['comment_form'] ) ) {
|
18 |
+
$mc4wp->get_checkbox_manager()->integrations['comment_form'] = new MC4WP_Comment_Form_Integration();
|
19 |
+
}
|
20 |
+
|
21 |
+
$mc4wp->get_checkbox_manager()->integrations['comment_form']->output_checkbox();
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Echoes a MailChimp for WordPress form
|
26 |
+
*
|
27 |
+
* @param int $id The form ID
|
28 |
+
*/
|
29 |
+
function mc4wp_form( $id = 0 ) {
|
30 |
+
echo mc4wp_get_form( $id );
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Returns HTML for sign-up form with the given $form_id.
|
35 |
+
*
|
36 |
+
* @param int $form_id.
|
37 |
+
* @return string HTML of given form_id.
|
38 |
+
*/
|
39 |
+
function mc4wp_get_form( $id = 0 ) {
|
40 |
+
global $mc4wp;
|
41 |
+
return $mc4wp->get_form_manager()->form( array( 'id' => $id ) );
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Returns text with {variables} replaced.
|
47 |
+
*
|
48 |
+
* @param string $text
|
49 |
+
* @param array $list_ids Array of list id's
|
50 |
+
* @return string $text The text with {variables} replaced.
|
51 |
+
*/
|
52 |
+
function mc4wp_replace_variables( $text, $list_ids = array() ) {
|
53 |
+
|
54 |
+
// get current WPML language or general site language
|
55 |
+
$language = defined( 'ICL_LANGUAGE_CODE' ) ? ICL_LANGUAGE_CODE : get_locale();
|
56 |
+
|
57 |
+
// replace general vars
|
58 |
+
$needles = array( '{ip}', '{current_url}', '{date}', '{time}', '{language}' );
|
59 |
+
$replacements = array( $_SERVER['REMOTE_ADDR'], mc4wp_get_current_url(), date( 'm/d/Y' ), date( 'H:i:s' ), $language );
|
60 |
+
$text = str_ireplace( $needles, $replacements, $text );
|
61 |
+
|
62 |
+
// subscriber count? only fetch these if the tag is actually used
|
63 |
+
if ( stristr( $text, '{subscriber_count}' ) !== false ) {
|
64 |
+
$mailchimp = new MC4WP_MailChimp();
|
65 |
+
$subscriber_count = $mailchimp->get_subscriber_count( $list_ids );
|
66 |
+
$text = str_ireplace( '{subscriber_count}', $subscriber_count, $text );
|
67 |
+
}
|
68 |
+
|
69 |
+
// replace {email} tag
|
70 |
+
if( isset( $_GET['mc4wp_email'] ) ) {
|
71 |
+
$email = esc_attr( $_GET['mc4wp_email'] );
|
72 |
+
} elseif( isset( $_COOKIE['mc4wp_email'] ) ) {
|
73 |
+
$email = esc_attr( $_COOKIE['mc4wp_email'] );
|
74 |
+
} else {
|
75 |
+
$email = '';
|
76 |
+
}
|
77 |
+
|
78 |
+
$text = str_ireplace( '{email}', $email, $text );
|
79 |
+
|
80 |
+
// replace user variables
|
81 |
+
$needles = array( '{user_email}', '{user_firstname}', '{user_lastname}', '{user_name}', '{user_id}' );
|
82 |
+
if ( is_user_logged_in() && ( $user = wp_get_current_user() ) && ( $user instanceof WP_User ) ) {
|
83 |
+
// logged in user, replace vars by user vars
|
84 |
+
$replacements = array( $user->user_email, $user->first_name, $user->last_name, $user->display_name, $user->ID );
|
85 |
+
$text = str_replace( $needles, $replacements, $text );
|
86 |
+
} else {
|
87 |
+
// no logged in user, replace vars with empty string
|
88 |
+
$text = str_replace( $needles, '', $text );
|
89 |
+
}
|
90 |
+
|
91 |
+
return $text;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Retrieves the URL of the current WordPress page
|
96 |
+
*
|
97 |
+
* @return string The current URL, escaped for safe usage inside attributes.
|
98 |
+
*/
|
99 |
+
function mc4wp_get_current_url() {
|
100 |
+
|
101 |
+
global $wp;
|
102 |
+
|
103 |
+
// get requested url from global $wp object
|
104 |
+
$site_request_uri = $wp->request;
|
105 |
+
|
106 |
+
// fix for IIS servers using index.php in the URL
|
107 |
+
if( false !== stripos( $_SERVER['REQUEST_URI'], '/index.php/' . $site_request_uri ) ) {
|
108 |
+
$site_request_uri = 'index.php/' . $site_request_uri;
|
109 |
+
}
|
110 |
+
|
111 |
+
// concatenate request url to home url
|
112 |
+
$url = home_url( $site_request_uri );
|
113 |
+
|
114 |
+
// add trailing slash, if necessary
|
115 |
+
if( substr( $_SERVER['REQUEST_URI'] , -1 ) === '/' ) {
|
116 |
+
$url = trailingslashit( $url );
|
117 |
+
}
|
118 |
+
|
119 |
+
return esc_url( $url );
|
120 |
+
}
|
121 |
+
|
122 |
+
/****************************~***
|
123 |
+
* Deprecated functions *
|
124 |
+
********************************/
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Echoes a sign-up form.
|
128 |
+
*
|
129 |
+
* @deprecated 1.3.1 Use mc4wp_form() instead.
|
130 |
+
* @see mc4wp_form()
|
131 |
+
*/
|
132 |
+
function mc4wp_show_form( $id = 0 ) {
|
133 |
+
_deprecated_function( __FUNCTION__, 'MailChimp for WP v1.3.1', 'mc4wp_form' );
|
134 |
+
mc4wp_form( $id );
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Echoes a sign-up checkbox.
|
139 |
+
*
|
140 |
+
* @deprecated 1.3.1 Use mc4wp_checkbox() instead
|
141 |
+
* @see mc4wp_checkbox()
|
142 |
+
*/
|
143 |
+
function mc4wp_show_checkbox() {
|
144 |
+
_deprecated_function( __FUNCTION__, 'MailChimp for WP v1.3.1', 'mc4wp_form' );
|
145 |
+
mc4wp_checkbox();
|
146 |
+
}
|
includes/index.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
if( ! defined(
|
3 |
-
header( 'Status: 403 Forbidden' );
|
4 |
-
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
-
exit;
|
6 |
-
}
|
1 |
+
<?php
|
2 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
3 |
+
header( 'Status: 403 Forbidden' );
|
4 |
+
header( 'HTTP/1.1 403 Forbidden' );
|
5 |
+
exit;
|
6 |
+
}
|
includes/integrations/class-bbpress.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
-
if( ! defined(
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
@@ -38,14 +38,14 @@ class MC4WP_bbPress_Integration extends MC4WP_Integration {
|
|
38 |
}
|
39 |
|
40 |
if ( $this->checkbox_was_checked() === false ) {
|
41 |
-
return false;
|
42 |
}
|
43 |
|
44 |
if ( $anonymous_data ) {
|
45 |
|
46 |
$email = $anonymous_data['bbp_anonymous_email'];
|
47 |
$merge_vars = array(
|
48 |
-
'NAME' => $anonymous_data['bbp_anonymous_name']
|
49 |
);
|
50 |
|
51 |
} elseif ( $user_id ) {
|
@@ -55,7 +55,7 @@ class MC4WP_bbPress_Integration extends MC4WP_Integration {
|
|
55 |
$merge_vars = array(
|
56 |
'NAME' => $user_info->first_name . ' ' . $user_info->last_name,
|
57 |
'FNAME' => $user_info->first_name,
|
58 |
-
'LNAME' => $user_info->last_name
|
59 |
);
|
60 |
|
61 |
} else {
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
38 |
}
|
39 |
|
40 |
if ( $this->checkbox_was_checked() === false ) {
|
41 |
+
return false;
|
42 |
}
|
43 |
|
44 |
if ( $anonymous_data ) {
|
45 |
|
46 |
$email = $anonymous_data['bbp_anonymous_email'];
|
47 |
$merge_vars = array(
|
48 |
+
'NAME' => $anonymous_data['bbp_anonymous_name'],
|
49 |
);
|
50 |
|
51 |
} elseif ( $user_id ) {
|
55 |
$merge_vars = array(
|
56 |
'NAME' => $user_info->first_name . ' ' . $user_info->last_name,
|
57 |
'FNAME' => $user_info->first_name,
|
58 |
+
'LNAME' => $user_info->last_name,
|
59 |
);
|
60 |
|
61 |
} else {
|
includes/integrations/class-buddypress.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
-
if( ! defined(
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
@@ -34,14 +34,14 @@ class MC4WP_BuddyPress_Integration extends MC4WP_Integration {
|
|
34 |
}
|
35 |
|
36 |
if ( $this->checkbox_was_checked() === false ) {
|
37 |
-
return false;
|
38 |
}
|
39 |
|
40 |
// gather emailadress and name from user who BuddyPress registered
|
41 |
$email = $user_email;
|
42 |
|
43 |
$merge_vars = array(
|
44 |
-
'NAME' => $user_login
|
45 |
);
|
46 |
|
47 |
return $this->subscribe( $email, $merge_vars, 'buddypress_registration' );
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
34 |
}
|
35 |
|
36 |
if ( $this->checkbox_was_checked() === false ) {
|
37 |
+
return false;
|
38 |
}
|
39 |
|
40 |
// gather emailadress and name from user who BuddyPress registered
|
41 |
$email = $user_email;
|
42 |
|
43 |
$merge_vars = array(
|
44 |
+
'NAME' => $user_login,
|
45 |
);
|
46 |
|
47 |
return $this->subscribe( $email, $merge_vars, 'buddypress_registration' );
|
includes/integrations/class-cf7.php
CHANGED
@@ -45,7 +45,7 @@ class MC4WP_CF7_Integration extends MC4WP_General_Integration {
|
|
45 |
|
46 |
/**
|
47 |
* Alter Contact Form 7 data.
|
48 |
-
*
|
49 |
* Adds mc4wp_checkbox to post data so users can use `mc4wp_checkbox` in their email templates
|
50 |
*
|
51 |
* @param array $data
|
@@ -62,8 +62,8 @@ class MC4WP_CF7_Integration extends MC4WP_General_Integration {
|
|
62 |
public function subscribe_from_cf7() {
|
63 |
|
64 |
// was sign-up checkbox checked?
|
65 |
-
if ( $this->checkbox_was_checked() === false ) {
|
66 |
-
return false;
|
67 |
}
|
68 |
|
69 |
return $this->try_subscribe();
|
45 |
|
46 |
/**
|
47 |
* Alter Contact Form 7 data.
|
48 |
+
*
|
49 |
* Adds mc4wp_checkbox to post data so users can use `mc4wp_checkbox` in their email templates
|
50 |
*
|
51 |
* @param array $data
|
62 |
public function subscribe_from_cf7() {
|
63 |
|
64 |
// was sign-up checkbox checked?
|
65 |
+
if ( $this->checkbox_was_checked() === false ) {
|
66 |
+
return false;
|
67 |
}
|
68 |
|
69 |
return $this->try_subscribe();
|
includes/integrations/class-comment-form.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if( ! defined(
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
@@ -37,13 +37,13 @@ class MC4WP_Comment_Form_Integration extends MC4WP_Integration {
|
|
37 |
}
|
38 |
|
39 |
// was sign-up checkbox checked?
|
40 |
-
if ( $this->checkbox_was_checked() === false ) {
|
41 |
-
return false;
|
42 |
}
|
43 |
|
44 |
// is this a spam comment?
|
45 |
-
if ( $comment_approved === 'spam' ) {
|
46 |
-
return false;
|
47 |
}
|
48 |
|
49 |
$comment = get_comment( $comment_id );
|
@@ -51,7 +51,7 @@ class MC4WP_Comment_Form_Integration extends MC4WP_Integration {
|
|
51 |
$email = $comment->comment_author_email;
|
52 |
$merge_vars = array(
|
53 |
'NAME' => $comment->comment_author,
|
54 |
-
'OPTIN_IP' => $comment->comment_author_IP
|
55 |
);
|
56 |
|
57 |
return $this->subscribe( $email, $merge_vars, 'comment', $comment_id );
|
1 |
<?php
|
2 |
|
3 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
37 |
}
|
38 |
|
39 |
// was sign-up checkbox checked?
|
40 |
+
if ( $this->checkbox_was_checked() === false ) {
|
41 |
+
return false;
|
42 |
}
|
43 |
|
44 |
// is this a spam comment?
|
45 |
+
if ( $comment_approved === 'spam' ) {
|
46 |
+
return false;
|
47 |
}
|
48 |
|
49 |
$comment = get_comment( $comment_id );
|
51 |
$email = $comment->comment_author_email;
|
52 |
$merge_vars = array(
|
53 |
'NAME' => $comment->comment_author,
|
54 |
+
'OPTIN_IP' => $comment->comment_author_IP,
|
55 |
);
|
56 |
|
57 |
return $this->subscribe( $email, $merge_vars, 'comment', $comment_id );
|
includes/integrations/class-edd.php
CHANGED
@@ -23,7 +23,7 @@ class MC4WP_EDD_Integration extends MC4WP_Integration {
|
|
23 |
|
24 |
add_action( 'edd_purchase_form_user_info', array( $this, 'output_checkbox' ) );
|
25 |
add_action( 'edd_payment_meta', array( $this, 'save_checkbox_value' ) );
|
26 |
-
add_action( 'edd_complete_purchase', array( $this, 'subscribe_from_edd'), 50);
|
27 |
}
|
28 |
|
29 |
/**
|
23 |
|
24 |
add_action( 'edd_purchase_form_user_info', array( $this, 'output_checkbox' ) );
|
25 |
add_action( 'edd_payment_meta', array( $this, 'save_checkbox_value' ) );
|
26 |
+
add_action( 'edd_complete_purchase', array( $this, 'subscribe_from_edd'), 50 );
|
27 |
}
|
28 |
|
29 |
/**
|
includes/integrations/class-events-manager.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
-
if( ! defined(
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
includes/integrations/class-general.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
-
if( ! defined(
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
@@ -123,7 +123,7 @@ class MC4WP_General_Integration extends MC4WP_Integration {
|
|
123 |
if( ! is_array( $groups ) ) {
|
124 |
$groups = explode( ',', sanitize_text_field( $groups ) );
|
125 |
}
|
126 |
-
|
127 |
$grouping['groups'] = array_map( 'stripslashes', $groups );
|
128 |
|
129 |
// add grouping to array
|
@@ -153,19 +153,19 @@ class MC4WP_General_Integration extends MC4WP_Integration {
|
|
153 |
if( ! isset( $merge_vars['NAME'] ) && in_array( $simple_key, array( 'name', 'yourname', 'username', 'fullname' ) ) ) {
|
154 |
// find name field
|
155 |
$merge_vars['NAME'] = $value;
|
156 |
-
} elseif( ! isset( $merge_vars['FNAME'] ) && in_array( $simple_key, array( 'firstname', 'fname',
|
157 |
// find first name field
|
158 |
$merge_vars['FNAME'] = $value;
|
159 |
} elseif( ! isset( $merge_vars['LNAME'] ) && in_array( $simple_key, array( 'lastname', 'lname', 'surname', 'familyname' ) ) ) {
|
160 |
// find last name field
|
161 |
$merge_vars['LNAME'] = $value;
|
162 |
}
|
163 |
-
}
|
164 |
}
|
165 |
|
166 |
// unset groupings if not used
|
167 |
-
if( empty( $merge_vars['GROUPINGS'] ) ) {
|
168 |
-
unset( $merge_vars['GROUPINGS'] );
|
169 |
}
|
170 |
|
171 |
// if email has not been found by the smart field guessing, return false.. Sorry
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
123 |
if( ! is_array( $groups ) ) {
|
124 |
$groups = explode( ',', sanitize_text_field( $groups ) );
|
125 |
}
|
126 |
+
|
127 |
$grouping['groups'] = array_map( 'stripslashes', $groups );
|
128 |
|
129 |
// add grouping to array
|
153 |
if( ! isset( $merge_vars['NAME'] ) && in_array( $simple_key, array( 'name', 'yourname', 'username', 'fullname' ) ) ) {
|
154 |
// find name field
|
155 |
$merge_vars['NAME'] = $value;
|
156 |
+
} elseif( ! isset( $merge_vars['FNAME'] ) && in_array( $simple_key, array( 'firstname', 'fname', 'givenname', 'forename' ) ) ) {
|
157 |
// find first name field
|
158 |
$merge_vars['FNAME'] = $value;
|
159 |
} elseif( ! isset( $merge_vars['LNAME'] ) && in_array( $simple_key, array( 'lastname', 'lname', 'surname', 'familyname' ) ) ) {
|
160 |
// find last name field
|
161 |
$merge_vars['LNAME'] = $value;
|
162 |
}
|
163 |
+
}
|
164 |
}
|
165 |
|
166 |
// unset groupings if not used
|
167 |
+
if( empty( $merge_vars['GROUPINGS'] ) ) {
|
168 |
+
unset( $merge_vars['GROUPINGS'] );
|
169 |
}
|
170 |
|
171 |
// if email has not been found by the smart field guessing, return false.. Sorry
|
includes/integrations/class-integration.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if( ! defined(
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
@@ -158,12 +158,12 @@ abstract class MC4WP_Integration {
|
|
158 |
} else if( in_array( 'default:0', $args['options'] ) ) {
|
159 |
$checked = '';
|
160 |
}
|
161 |
-
|
162 |
}
|
163 |
|
164 |
-
$content =
|
165 |
|
166 |
-
do_action( 'mc4wp_before_checkbox' );
|
167 |
|
168 |
// checkbox
|
169 |
$content .= '<p id="mc4wp-checkbox">';
|
@@ -242,7 +242,7 @@ abstract class MC4WP_Integration {
|
|
242 |
}
|
243 |
|
244 |
// maybe guess first and last name
|
245 |
-
if ( isset( $merge_vars['NAME'] ) && !isset( $merge_vars['FNAME'] ) && !isset( $merge_vars['LNAME'] ) ) {
|
246 |
|
247 |
$strpos = strpos( $merge_vars['NAME'], ' ' );
|
248 |
if ( $strpos !== false ) {
|
@@ -312,15 +312,15 @@ abstract class MC4WP_Integration {
|
|
312 |
// check if result succeeded, show debug message to administrators (only in NON-AJAX requests)
|
313 |
if ( $result !== true && $api->has_error() && $this->show_error_messages() ) {
|
314 |
wp_die( '<h3>' . __( 'MailChimp for WordPress - Error', 'mailchimp-for-wp' ) . '</h3>' .
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
}
|
325 |
|
326 |
return $result;
|
1 |
<?php
|
2 |
|
3 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
158 |
} else if( in_array( 'default:0', $args['options'] ) ) {
|
159 |
$checked = '';
|
160 |
}
|
161 |
+
|
162 |
}
|
163 |
|
164 |
+
$content = '<!-- MailChimp for WP v'. MC4WP_LITE_VERSION .' - https://mc4wp.com/ -->';
|
165 |
|
166 |
+
do_action( 'mc4wp_before_checkbox' );
|
167 |
|
168 |
// checkbox
|
169 |
$content .= '<p id="mc4wp-checkbox">';
|
242 |
}
|
243 |
|
244 |
// maybe guess first and last name
|
245 |
+
if ( isset( $merge_vars['NAME'] ) && ! isset( $merge_vars['FNAME'] ) && ! isset( $merge_vars['LNAME'] ) ) {
|
246 |
|
247 |
$strpos = strpos( $merge_vars['NAME'], ' ' );
|
248 |
if ( $strpos !== false ) {
|
312 |
// check if result succeeded, show debug message to administrators (only in NON-AJAX requests)
|
313 |
if ( $result !== true && $api->has_error() && $this->show_error_messages() ) {
|
314 |
wp_die( '<h3>' . __( 'MailChimp for WordPress - Error', 'mailchimp-for-wp' ) . '</h3>' .
|
315 |
+
'<p>' . __( 'The MailChimp server returned the following error message as a response to our sign-up request:', 'mailchimp-for-wp' ) . '</p>' .
|
316 |
+
'<pre>' . $api->get_error_message() . '</pre>' .
|
317 |
+
'<p>' . __( 'This is the data that was sent to MailChimp:', 'mailchimp-for-wp' ) . '</p>' .
|
318 |
+
'<strong>' . __( 'Email address:', 'mailchimp-for-wp' ) . '</strong>' .
|
319 |
+
'<pre>' . esc_html( $email ) . '</pre>' .
|
320 |
+
'<strong>' . __( 'Merge variables:', 'mailchimp-for-wp' ) . '</strong>' .
|
321 |
+
'<pre>' . esc_html( print_r( $merge_vars, true ) ) . '</pre>' .
|
322 |
+
'<p style="font-style:italic; font-size:12px;">' . __( 'This message is only visible to administrators for debugging purposes.', 'mailchimp-for-wp' ) . '</p>',
|
323 |
+
__( 'MailChimp for WordPress - Error', 'mailchimp-for-wp' ), array( 'back_link' => true ) );
|
324 |
}
|
325 |
|
326 |
return $result;
|
includes/integrations/class-multisite.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
-
if( ! defined(
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
@@ -38,7 +38,7 @@ class MC4WP_MultiSite_Integration extends MC4WP_Integration {
|
|
38 |
* @param int $user_id
|
39 |
* @return boolean
|
40 |
*/
|
41 |
-
public function on_multisite_blog_signup( $blog_id, $user_id, $a, $b
|
42 |
// was sign-up checkbox checked?
|
43 |
if ( ! isset( $meta['_mc4wp_subscribe'] ) || $meta['_mc4wp_subscribe'] !== 1 ) {
|
44 |
return false;
|
@@ -55,7 +55,7 @@ class MC4WP_MultiSite_Integration extends MC4WP_Integration {
|
|
55 |
* @param array $meta
|
56 |
* @return boolean
|
57 |
*/
|
58 |
-
public function on_multisite_user_signup( $user_id, $password =
|
59 |
// abandon if sign-up checkbox was not checked
|
60 |
if ( ! isset( $meta['_mc4wp_subscribe'] ) || $meta['_mc4wp_subscribe'] !== 1 ) {
|
61 |
return false;
|
@@ -66,7 +66,7 @@ class MC4WP_MultiSite_Integration extends MC4WP_Integration {
|
|
66 |
|
67 |
/**
|
68 |
* Add user meta from Multisite sign-ups to store the checkbox value
|
69 |
-
*
|
70 |
* @param array $meta
|
71 |
* @return array
|
72 |
*/
|
@@ -91,7 +91,7 @@ class MC4WP_MultiSite_Integration extends MC4WP_Integration {
|
|
91 |
$merge_vars = array(
|
92 |
'NAME' => $user->first_name . ' ' . $user->last_name,
|
93 |
'FNAME' => $user->first_name,
|
94 |
-
'LNAME' => $user->last_name
|
95 |
);
|
96 |
|
97 |
return $this->subscribe( $email, $merge_vars, 'multisite_registration' );
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
38 |
* @param int $user_id
|
39 |
* @return boolean
|
40 |
*/
|
41 |
+
public function on_multisite_blog_signup( $blog_id, $user_id, $a, $b, $meta = null ) {
|
42 |
// was sign-up checkbox checked?
|
43 |
if ( ! isset( $meta['_mc4wp_subscribe'] ) || $meta['_mc4wp_subscribe'] !== 1 ) {
|
44 |
return false;
|
55 |
* @param array $meta
|
56 |
* @return boolean
|
57 |
*/
|
58 |
+
public function on_multisite_user_signup( $user_id, $password = null, $meta = array() ) {
|
59 |
// abandon if sign-up checkbox was not checked
|
60 |
if ( ! isset( $meta['_mc4wp_subscribe'] ) || $meta['_mc4wp_subscribe'] !== 1 ) {
|
61 |
return false;
|
66 |
|
67 |
/**
|
68 |
* Add user meta from Multisite sign-ups to store the checkbox value
|
69 |
+
*
|
70 |
* @param array $meta
|
71 |
* @return array
|
72 |
*/
|
91 |
$merge_vars = array(
|
92 |
'NAME' => $user->first_name . ' ' . $user->last_name,
|
93 |
'FNAME' => $user->first_name,
|
94 |
+
'LNAME' => $user->last_name,
|
95 |
);
|
96 |
|
97 |
return $this->subscribe( $email, $merge_vars, 'multisite_registration' );
|
includes/integrations/class-registration-form.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
-
if( ! defined(
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
@@ -39,7 +39,7 @@ class MC4WP_Registration_Form_Integration extends MC4WP_Integration {
|
|
39 |
}
|
40 |
|
41 |
// was sign-up checkbox checked?
|
42 |
-
if ( $this->checkbox_was_checked() === false ) {
|
43 |
return false;
|
44 |
}
|
45 |
|
@@ -48,19 +48,19 @@ class MC4WP_Registration_Form_Integration extends MC4WP_Integration {
|
|
48 |
|
49 |
// was a user found with the given ID?
|
50 |
if ( ! is_object( $user ) || ! isset( $user->user_email ) ) {
|
51 |
-
return false;
|
52 |
}
|
53 |
|
54 |
$email = $user->user_email;
|
55 |
$merge_vars = array( 'NAME' => $user->user_login );
|
56 |
|
57 |
// try to add first name
|
58 |
-
if ( isset( $user->first_name ) && !empty( $user->first_name ) ) {
|
59 |
$merge_vars['FNAME'] = $user->first_name;
|
60 |
}
|
61 |
|
62 |
// try to add last name
|
63 |
-
if ( isset( $user->last_name ) && !empty( $user->last_name ) ) {
|
64 |
$merge_vars['LNAME'] = $user->last_name;
|
65 |
}
|
66 |
|
1 |
<?php
|
2 |
|
3 |
// prevent direct file access
|
4 |
+
if( ! defined( 'MC4WP_LITE_VERSION' ) ) {
|
5 |
header( 'Status: 403 Forbidden' );
|
6 |
header( 'HTTP/1.1 403 Forbidden' );
|
7 |
exit;
|
39 |
}
|
40 |
|
41 |
// was sign-up checkbox checked?
|
42 |
+
if ( $this->checkbox_was_checked() === false ) {
|
43 |
return false;
|
44 |
}
|
45 |
|
48 |
|
49 |
// was a user found with the given ID?
|
50 |
if ( ! is_object( $user ) || ! isset( $user->user_email ) ) {
|
51 |
+
return false;
|
52 |
}
|
53 |
|
54 |
$email = $user->user_email;
|
55 |
$merge_vars = array( 'NAME' => $user->user_login );
|
56 |
|
57 |
// try to add first name
|
58 |
+
if ( isset( $user->first_name ) && ! empty( $user->first_name ) ) {
|
59 |
$merge_vars['FNAME'] = $user->first_name;
|
60 |
}
|
61 |
|
62 |
// try to add last name
|
63 |
+
if ( isset( $user->last_name ) && ! empty( $user->last_name ) ) {
|
64 |
$merge_vars['LNAME'] = $user->last_name;
|
65 |
}
|
66 |
|
includes/integrations/class-woocommerce.php
CHANGED
@@ -70,7 +70,7 @@ class MC4WP_WooCommerce_Integration extends MC4WP_Integration {
|
|
70 |
public function subscribe_from_woocommerce_checkout( $order_id ) {
|
71 |
|
72 |
$do_optin = get_post_meta( $order_id, '_mc4wp_optin', true );
|
73 |
-
|
74 |
if( $do_optin ) {
|
75 |
|
76 |
$order = new WC_Order( $order_id );
|
@@ -78,7 +78,7 @@ class MC4WP_WooCommerce_Integration extends MC4WP_Integration {
|
|
78 |
$merge_vars = array(
|
79 |
'NAME' => "{$order->billing_first_name} {$order->billing_last_name}",
|
80 |
'FNAME' => $order->billing_first_name,
|
81 |
-
'LNAME' => $order->billing_last_name
|
82 |
|
83 |
);
|
84 |
|
70 |
public function subscribe_from_woocommerce_checkout( $order_id ) {
|
71 |
|
72 |
$do_optin = get_post_meta( $order_id, '_mc4wp_optin', true );
|
73 |
+
|
74 |
if( $do_optin ) {
|
75 |
|
76 |
$order = new WC_Order( $order_id );
|
78 |
$merge_vars = array(
|
79 |
'NAME' => "{$order->billing_first_name} {$order->billing_last_name}",
|
80 |
'FNAME' => $order->billing_first_name,
|
81 |
+
'LNAME' => $order->billing_last_name,
|
82 |
|
83 |
);
|
84 |
|
includes/views/api-settings.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
|
3 |
-
if( ! defined(
|
4 |
header( 'Status: 403 Forbidden' );
|
5 |
header( 'HTTP/1.1 403 Forbidden' );
|
6 |
exit;
|
@@ -32,7 +32,7 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
32 |
<th scope="row"><label for="mailchimp_api_key">MailChimp <?php _e( 'API Key', 'mailchimp-for-wp' ); ?></label></th>
|
33 |
<td>
|
34 |
<input type="text" class="widefat" placeholder="<?php _e( 'Your MailChimp API key', 'mailchimp-for-wp' ); ?>" id="mailchimp_api_key" name="mc4wp_lite[api_key]" value="<?php echo $opts['api_key']; ?>" />
|
35 |
-
<p class="help"><a target="_blank" href="
|
36 |
</td>
|
37 |
|
38 |
</tr>
|
@@ -66,7 +66,7 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
66 |
</tr>
|
67 |
</thead>
|
68 |
<tbody>
|
69 |
-
<?php
|
70 |
if( ! empty( $lists ) && is_array( $lists ) ) {
|
71 |
foreach($lists as $list) { ?>
|
72 |
|
@@ -78,13 +78,13 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
78 |
<?php if( ! empty( $list->merge_vars ) && is_array( $list->merge_vars ) ) { ?>
|
79 |
<ul class="ul-square" style="margin-top: 0;">
|
80 |
<?php foreach( $list->merge_vars as $merge_var ) { ?>
|
81 |
-
<li><?php echo esc_html( $merge_var->name ); if( $merge_var->req ) echo '<span style="color:red;">*</span>'; ?> <code><?php echo esc_html( $merge_var->tag ); ?></code></li>
|
82 |
<?php } ?>
|
83 |
</ul>
|
84 |
<?php } ?>
|
85 |
</td>
|
86 |
<td>
|
87 |
-
<?php
|
88 |
if( ! empty( $list->interest_groupings ) && is_array( $list->interest_groupings ) ) {
|
89 |
foreach($list->interest_groupings as $grouping) { ?>
|
90 |
<strong><?php echo esc_html( $grouping->name ); ?></strong>
|
@@ -97,23 +97,23 @@ if( ! defined("MC4WP_LITE_VERSION") ) {
|
|
97 |
</ul>
|
98 |
<?php } ?>
|
99 |
<?php }
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
|
104 |
</td>
|
105 |
<td class="mc4wp-hide-smallscreens"><?php echo esc_html( $list->subscriber_count ); ?></td>
|
106 |
</tr>
|
107 |
-
<?php
|
108 |
-
}
|
109 |
} else { ?>
|
110 |
<tr>
|
111 |
<td colspan="5">
|
112 |
<p><?php _e( 'No lists were found in your MailChimp account', 'mailchimp-for-wp' ); ?>.</p>
|
113 |
</td>
|
114 |
</tr>
|
115 |
-
<?php
|
116 |
-
}
|