Version Description
Download this release
Release Info
Developer | anderly |
Plugin | WooCommerce MailChimp |
Version | 2.1.10 |
Comparing to | |
See all releases |
Code changes from version 2.1.8 to 2.1.10
- COPYRIGHT.txt +28 -28
- assets/banner-1544x500.png +0 -0
- assets/banner-772x250.png +0 -0
- assets/css/style.css +47 -47
- assets/icon-128x128.png +0 -0
- assets/icon-256x256.png +0 -0
- assets/icon-500x500.png +0 -0
- assets/icon.svg +141 -0
- assets/js/woocommerce-mailchimp-admin.js +339 -339
- assets/screenshot-1.png +0 -0
- assets/screenshot-2.png +0 -0
- config/default-settings.php +13 -13
- includes/class-ss-wc-mailchimp-admin-notices.php +193 -193
- includes/class-ss-wc-mailchimp-api.php +295 -295
- includes/class-ss-wc-mailchimp-compatibility.php +297 -297
- includes/class-ss-wc-mailchimp-handler.php +471 -471
- includes/class-ss-wc-mailchimp-migrator.php +71 -71
- includes/class-ss-wc-mailchimp-plugin.php +572 -572
- includes/class-ss-wc-mailchimp.php +399 -399
- includes/class-ss-wc-settings-mailchimp.php +706 -706
- includes/helper-functions.php +23 -23
- includes/lib/class-ss-system-info.php +238 -238
- includes/migrations/class-ss-wc-migration-from-1.3.X-to-2.0.php +76 -76
- includes/migrations/class-ss-wc-migration-from-2.0-to-2.0.15.php +50 -50
- includes/migrations/class-ss-wc-migration.php +97 -97
- languages/woocommerce-mailchimp-fr_FR.po +273 -273
- languages/woocommerce-mailchimp.pot +404 -404
- readme.txt +6 -2
- woocommerce-mailchimp.php +2 -1
COPYRIGHT.txt
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
|
2 |
-
WooCommerce MailChimp
|
3 |
-
|
4 |
-
Copyright 2018 "saintsystems" (Saint Systems) www.saintsystems.com
|
5 |
-
|
6 |
-
The files COPYRIGHT.txt and LICENSE.txt as well as ALL NOTICES IN THE
|
7 |
-
HEADERS OF ALL FILES MUST BE KEPT INTACT.
|
8 |
-
|
9 |
-
GPL-licensed
|
10 |
-
|
11 |
-
Unless otherwise stated, all code in this plugin is licensed under
|
12 |
-
the GPL License:
|
13 |
-
|
14 |
-
All code is part of this plugin, hereinafter referred to as "program".
|
15 |
-
|
16 |
-
This program is free software: you can redistribute it and/or modify
|
17 |
-
it under the terms of the GNU General Public License as published by
|
18 |
-
the Free Software Foundation, either version 3 of the License, or
|
19 |
-
(at your option) any later version.
|
20 |
-
|
21 |
-
This program is distributed in the hope that it will be useful,
|
22 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
-
GNU General Public License for more details.
|
25 |
-
|
26 |
-
You should have received a copy of the GNU General Public License
|
27 |
-
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
-
|
1 |
+
|
2 |
+
WooCommerce MailChimp
|
3 |
+
|
4 |
+
Copyright 2018 "saintsystems" (Saint Systems) www.saintsystems.com
|
5 |
+
|
6 |
+
The files COPYRIGHT.txt and LICENSE.txt as well as ALL NOTICES IN THE
|
7 |
+
HEADERS OF ALL FILES MUST BE KEPT INTACT.
|
8 |
+
|
9 |
+
GPL-licensed
|
10 |
+
|
11 |
+
Unless otherwise stated, all code in this plugin is licensed under
|
12 |
+
the GPL License:
|
13 |
+
|
14 |
+
All code is part of this plugin, hereinafter referred to as "program".
|
15 |
+
|
16 |
+
This program is free software: you can redistribute it and/or modify
|
17 |
+
it under the terms of the GNU General Public License as published by
|
18 |
+
the Free Software Foundation, either version 3 of the License, or
|
19 |
+
(at your option) any later version.
|
20 |
+
|
21 |
+
This program is distributed in the hope that it will be useful,
|
22 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
+
GNU General Public License for more details.
|
25 |
+
|
26 |
+
You should have received a copy of the GNU General Public License
|
27 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
28 |
+
|
assets/banner-1544x500.png
ADDED
Binary file
|
assets/banner-772x250.png
ADDED
Binary file
|
assets/css/style.css
CHANGED
@@ -1,48 +1,48 @@
|
|
1 |
-
.loading-indicator {
|
2 |
-
display: inline-block;
|
3 |
-
vertical-align:top;
|
4 |
-
margin-top:5px;
|
5 |
-
}
|
6 |
-
|
7 |
-
.woocommerce table.form-table .select2-container {
|
8 |
-
display: inline-block !important;
|
9 |
-
}
|
10 |
-
|
11 |
-
.woocommerce-mailchimp-loading {
|
12 |
-
margin-left: 5px;
|
13 |
-
margin-top: 2px;
|
14 |
-
display: inline-block;
|
15 |
-
}
|
16 |
-
|
17 |
-
.woocommerce-mailchimp-loading-indicator {
|
18 |
-
color: #32373c;
|
19 |
-
}
|
20 |
-
|
21 |
-
.woocommerce-mailchimp-loading-indicator:before {
|
22 |
-
font-family: dashicons;
|
23 |
-
line-height: 1.5em;
|
24 |
-
display: inline-block;
|
25 |
-
font-size: 20px;
|
26 |
-
line-height: 1;
|
27 |
-
text-decoration: inherit;
|
28 |
-
font-weight: 400;
|
29 |
-
font-style: normal;
|
30 |
-
vertical-align: top;
|
31 |
-
text-align: center;
|
32 |
-
content: "\f463";
|
33 |
-
}
|
34 |
-
|
35 |
-
.woocommerce-mailchimp-loading-indicator.loading:before {\
|
36 |
-
-webkit-animation: rotation 2s infinite linear;
|
37 |
-
animation: rotation 2s infinite linear;
|
38 |
-
}
|
39 |
-
|
40 |
-
.woocommerce-mailchimp-loading-indicator.success:before {
|
41 |
-
color: #46b450;
|
42 |
-
content: "\f147";
|
43 |
-
}
|
44 |
-
|
45 |
-
.woocommerce-mailchimp-loading-indicator.error:before {
|
46 |
-
color: #dc3232;
|
47 |
-
content: "\f534";
|
48 |
}
|
1 |
+
.loading-indicator {
|
2 |
+
display: inline-block;
|
3 |
+
vertical-align:top;
|
4 |
+
margin-top:5px;
|
5 |
+
}
|
6 |
+
|
7 |
+
.woocommerce table.form-table .select2-container {
|
8 |
+
display: inline-block !important;
|
9 |
+
}
|
10 |
+
|
11 |
+
.woocommerce-mailchimp-loading {
|
12 |
+
margin-left: 5px;
|
13 |
+
margin-top: 2px;
|
14 |
+
display: inline-block;
|
15 |
+
}
|
16 |
+
|
17 |
+
.woocommerce-mailchimp-loading-indicator {
|
18 |
+
color: #32373c;
|
19 |
+
}
|
20 |
+
|
21 |
+
.woocommerce-mailchimp-loading-indicator:before {
|
22 |
+
font-family: dashicons;
|
23 |
+
line-height: 1.5em;
|
24 |
+
display: inline-block;
|
25 |
+
font-size: 20px;
|
26 |
+
line-height: 1;
|
27 |
+
text-decoration: inherit;
|
28 |
+
font-weight: 400;
|
29 |
+
font-style: normal;
|
30 |
+
vertical-align: top;
|
31 |
+
text-align: center;
|
32 |
+
content: "\f463";
|
33 |
+
}
|
34 |
+
|
35 |
+
.woocommerce-mailchimp-loading-indicator.loading:before {\
|
36 |
+
-webkit-animation: rotation 2s infinite linear;
|
37 |
+
animation: rotation 2s infinite linear;
|
38 |
+
}
|
39 |
+
|
40 |
+
.woocommerce-mailchimp-loading-indicator.success:before {
|
41 |
+
color: #46b450;
|
42 |
+
content: "\f147";
|
43 |
+
}
|
44 |
+
|
45 |
+
.woocommerce-mailchimp-loading-indicator.error:before {
|
46 |
+
color: #dc3232;
|
47 |
+
content: "\f534";
|
48 |
}
|
assets/icon-128x128.png
ADDED
Binary file
|
assets/icon-256x256.png
ADDED
Binary file
|
assets/icon-500x500.png
ADDED
Binary file
|
assets/icon.svg
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
4 |
+
viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve">
|
5 |
+
<style type="text/css">
|
6 |
+
.st0{fill:url(#SVGID_1_);}
|
7 |
+
.st1{fill:#684C46;}
|
8 |
+
.st2{fill:#F5DCBA;}
|
9 |
+
.st3{fill:#0788BF;}
|
10 |
+
.st4{fill:#46B8E3;}
|
11 |
+
.st5{fill:#FFD14F;}
|
12 |
+
.st6{fill:#122030;}
|
13 |
+
.st7{fill:#FFFFFF;}
|
14 |
+
.st8{fill:#EABE8D;}
|
15 |
+
.st9{fill:#9C7356;}
|
16 |
+
.st10{fill:#9B5C8F;}
|
17 |
+
</style>
|
18 |
+
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="-1" y1="250" x2="501" y2="250" gradientTransform="matrix(4.489659e-11 1 -1 4.489659e-11 500 0)">
|
19 |
+
<stop offset="0" style="stop-color:#0087C1"/>
|
20 |
+
<stop offset="1" style="stop-color:#3FB7E5"/>
|
21 |
+
</linearGradient>
|
22 |
+
<rect x="-1" y="-1" class="st0" width="502" height="502"/>
|
23 |
+
<g>
|
24 |
+
<path class="st1" d="M425,374.1c-0.3,1-27.9,107-136.3,107c-93.7,0-138.2-81.5-138.2-81.5c-6.8,0.4-13.4-0.7-19.5-2.9
|
25 |
+
c-27.5-10.1-40.7-41.6-31.2-68l-15.1-11.5C26.2,272.5,192,68.5,250.7,114.6c0.3,0.2,14,11.3,14,11.3c21.1-12.8,41.9-19.7,58.9-19.7
|
26 |
+
c12,0,22.1,3.5,28.9,10.8c15.2,16.5,9.8,48-11,79.8c4.5,4.2,8.2,10,10.8,15.7c6.6,5.1,10.9,12.8,13,23.6
|
27 |
+
c2.4,11.9,2.9,28.9,4.3,36.1c5.6,2.5,3.2,1.4,9.2,4.3c6.2,3.1,13.8,6.9,22.2,15c14.9,3.7,20.6,19.6,11.9,30.4
|
28 |
+
c-0.2,0.3-1.3,1.5-2.4,2.8c0.3,0.7,3.1,5.3,5.2,14.7c6.2,1.5,11.1,5.3,13.7,10.8C433.8,361.1,425,374.1,425,374.1z M382,454.2v4.4
|
29 |
+
h1.7v-4.4h1.7v-1.4h-5.2v1.4H382z M386,452.8v5.8h1.6v-4.2l1.3,4.2h1.3l1.3-4.2v4.2h1.6v-5.8h-2.4l-1,3.4l-1.1-3.4H386z"/>
|
30 |
+
<path class="st2" d="M172.7,334.2L172.7,334.2L172.7,334.2c2.4-6,3.6-10.9,3.6-10.9c2.7,8.3,4.1,17,3.5,25.7l0,0l0,0
|
31 |
+
c2.2-3,4.6-8.6,4.6-8.6c4.2,24.5-13.7,47-37.3,47c-20.9,0-37.9-17.9-37.9-39.9c0-22.1,17-39.9,37.9-39.9c5.4,0,10.6,1.2,15.3,3.4
|
32 |
+
C162.3,310.9,170.4,315,172.7,334.2z M379.1,420.7c29.4-23.1,34.5-50.9,35-51.9c7.2-8.7,5.3-17.2-4.3-17.2c-3,0-5.3,0.8-5.3,0.8
|
33 |
+
s0-12.7-5.8-22.5c-4.5,5.1-17,15.1-33.5,22.9c-15.4,7.3-36,13.7-61.5,14.6h0c-7.1,0.3-11.6-0.9-14,7.5c-0.8,2.9-0.5,7.3,0.1,8.6
|
34 |
+
c2,6.9,7.3,9.9,14.2,11.5c5.2,1.2,10.8,1.3,10.8,1.3c51.7,1.5,93.3-38.9,93.7-39.2c0.5-0.4,0.9-0.9,0.9-0.9s-0.5,1.1-0.5,1.2
|
35 |
+
c-7.5,16.8-50.7,47.3-93.8,46.4l-0.1,0c-10,0-22.1-2.6-28.4-10.4c-10-12.4-4.8-32.9,11.1-33.4c0,0,3.7-0.1,5.3-0.1
|
36 |
+
c39.4-1.2,74.7-15.7,100-45.9c3.5-4.3-0.4-10.3-7.9-10.4c-0.1,0-0.1,0-0.2-0.1c-8.9-9.6-16.8-13-23.8-16.5
|
37 |
+
c-14.7-7.5-13.3-1-16.7-37.2c-0.9-9.8-2.8-23.1-11.3-28.2c-2.2-1.3-4.7-1.9-7.3-1.9c-2.5,0-3.7,0.5-4.2,0.6
|
38 |
+
c-4.7,1-7.4,3.7-10.7,6.8c-15.8,14.6-28.5,10.6-47.3,10.5c-17.7-0.2-33.4,12.2-36.4,31.2l0,0c-1.5,9.9-0.5,20,1,24.6
|
39 |
+
c0,0-4.8-3.2-7.1-6c2.8,17.3,18.6,28.7,18.6,28.7c-2.5,0.6-6.1,0.3-6.1,0.3c0,0,9,7.1,16.9,9.6c-2,1.3-12.3,11.4-17.7,25.5
|
40 |
+
c-5,13.1-2.9,28.8-2.9,28.8l4.3-6.4c0,0-2.8,14.4,2.6,28.3c1.8-4.1,5.8-11.5,5.8-11.5s-0.6,15.4,6.8,28c0.2-2.9,1.3-10.3,1.3-10.3
|
41 |
+
s4.3,13.2,14.1,22.4C293.2,446.9,342,449.9,379.1,420.7z"/>
|
42 |
+
<path class="st3" d="M105.5,317.5c-0.1,0-14.3-10.4-16.3-13.8c-11.9-20.1,8.8-61.2,23.5-84.7c36.4-57.9,96.9-103.5,124.4-97
|
43 |
+
l28.2,14.6c-11,6.4-21.6,14.4-27.9,19.6l-6,5c0,0-17.5,11.8-26.3,19.3c-35,29.8-69.4,76-82.2,120.6
|
44 |
+
C123,301.1,112.5,306.3,105.5,317.5z"/>
|
45 |
+
<path class="st4" d="M237.1,122L237.1,122c-27.5-6.5-88,39.1-124.4,97c0,0,0,0,0,0.1l0.1,0l29,22.8c31.8-50.5,71.8-76.5,72.9-77.3
|
46 |
+
l-4.6-30.9l8.6-4.1l17.3,5.6l-1.3-5.8L237.1,122L237.1,122z"/>
|
47 |
+
<path class="st5" d="M265.3,136.5l-27.9,19.6l-2,1.5l-24.7-20.2l-0.6-3.8l8.6-4.1c0.4,0.1,16.6,5.4,17.3,5.6l0.3-10.7l0.8-2.4
|
48 |
+
l7.6-2.9C244.7,119.1,265.3,136.5,265.3,136.5z"/>
|
49 |
+
<g>
|
50 |
+
<path class="st6" d="M320.4,117.3c-18.5,0-39.2,9.7-55.1,19.3c-2.2,1.3-4.4,2.7-6.6,4.1l-8.3-7l3,10.5c-1.1,0.8-2.3,1.6-3.3,2.3
|
51 |
+
l-17.2-5.2l11.4,9.5c-2.6,2-4.9,3.8-6.8,5.4l-27.3-22.5l1.4,10.1l19.8,17.5c0,0-17.5,11.8-26.3,19.3c-35,29.8-69.4,76-82.2,120.6
|
52 |
+
l0.7-0.4c0.1-0.1,0.2-0.1,0.3-0.2c0.4-0.2,0.7-0.4,1.1-0.6c0.2-0.1,0.5-0.2,0.7-0.3c0.4-0.2,0.7-0.3,1.1-0.5
|
53 |
+
c0.2-0.1,0.4-0.2,0.6-0.3c0.4-0.2,0.8-0.3,1.2-0.5c0.2-0.1,0.4-0.1,0.5-0.2c0.6-0.2,1.2-0.4,1.7-0.6c8.7-2.6,20.5-4.3,34.3,1.6
|
54 |
+
c6.9-17.5,15.2-35.3,28.3-52.4c10.6-13.9,20.8-26.3,33-33.1c23.2-21.8,85.6-44.8,105.6-24.8c4.7-7.7,8.8-15.1,12.2-24.2
|
55 |
+
C352.7,142.6,352.9,117.3,320.4,117.3z"/>
|
56 |
+
<polygon class="st6" points="241.2,136.8 237.1,122 234.7,129.4 236.1,135.2 "/>
|
57 |
+
</g>
|
58 |
+
<path class="st7" d="M404.5,352.4c0,0,0-12.7-5.8-22.5c-4.5,5.1-17,15.1-33.5,22.9c-15.4,7.3-36,13.7-61.5,14.6h0
|
59 |
+
c-7.1,0.3-11.6-0.9-14,7.5c-0.2,0.7-0.3,1.5-0.4,2.3l0,0.1c0,0,0,0,0,0c0,0.3,0,0.5,0,0.8c0,0.8,0,1.4,0,2c0,0,0,0,0,0
|
60 |
+
c0,0,0,0.1,0,0.1c0,0.4,0.1,0.7,0.1,1c0,0,0,0,0,0c0,0,0,0,0,0.1c0.2,1.3,0.4,1.9,0.5,2c0,0,0,0,0,0l0,0.1c2,6.8,7.3,9.8,14.2,11.4
|
61 |
+
c5.2,1.2,10.8,1.3,10.8,1.3c42.2,1.2,77.6-25.5,89.5-35.5C404.5,358,404.6,356,404.5,352.4z M283.3,127c10.1-4.6,20.9-8.3,31.2-9.4
|
62 |
+
c-10.3,2.3-22.8,7.7-37.7,16.7c-0.4,0.2-35.2,23.7-56.4,44.8c-11.6,11.5-58.1,67.3-58.1,67.2c8.5-16.1,14.1-24,27.6-40.9
|
63 |
+
c7.6-9.6,15.7-18.9,24.1-27.5c2.8-2.9,5.6-5.7,8.4-8.4l0,0l0,0C223.4,168.5,247.8,143.6,283.3,127z"/>
|
64 |
+
<path class="st8" d="M379.1,420.7c-5,4-10.3,7.3-15.7,10.2c-12.4-4.7-20-14.8-20-14.8s10.7-2.5,24.9-9.8
|
65 |
+
c17.3-8.8,33.5-21.5,45.9-37.5C413.6,369.8,408.5,397.6,379.1,420.7z M345.3,286.6c-6-4.3-16-0.9-18.2,6.2c3.5,0.2,7.2,2.8,6.9,6.2
|
66 |
+
c2.5-2.4,5.9-3.7,9.3-3.7C341.8,292.7,342.6,288.1,345.3,286.6z M282.2,372.9c1.9-7,7.2-12.6,15.4-12.9c0,0,3.7-0.1,5.3-0.1
|
67 |
+
c39.4-1.2,74.7-15.7,100-45.9c3.5-4.3-0.4-10.3-7.9-10.4c0,0-0.1,0-0.1,0c-1.3,1.3-1.5,3.8-3.6,7.5c-7.7,13.4-18.3,19.5-32.5,26.6
|
68 |
+
c-43.5,21.7-66.1,11.6-75.1,24.8C281,366.4,280.9,370.7,282.2,372.9C282.2,372.9,282.2,372.9,282.2,372.9z M360.9,282
|
69 |
+
c-4.2-3-4.3-8.2-6.6-32.3c-0.7-7.7-2-17.6-6.7-23.9c-1-0.8-2.3-1.8-4.3-1.8c-3-0.1-6.3,2.9-8.2,5.1c-5.4,7.8-10.6,12.8-19.7,17.2
|
70 |
+
c-9.2,4.2-18,5.7-27.1,5.4c-6.7-0.2-12.5-1.3-18.2-1.4c-10.6-0.2-19.8,3.3-26.5,11.7c-4.6,5.8-6.4,11.9-7,19.3
|
71 |
+
c0,0.9,0.1,1.7,0.1,2.5c0.1,1.2,0.2,2.3,0.3,3.3c0.5,3.7,1.1,5.6,1.1,5.6c0,0,0,0.1,0,0.1c0.1,0.2,0.1,0.4,0.2,0.5
|
72 |
+
c0,0-4.8-3.2-7.1-6c2.3,14.5,13.7,24.7,17.4,27.8c0.2,0.2,0.4,0.3,0.6,0.5c0,0,0,0,0,0c0.3,0.2,0.5,0.4,0.5,0.4
|
73 |
+
c-2.5,0.6-6.1,0.3-6.1,0.3c0,0,9,7.1,16.9,9.6c10.4-8.8,22.1-12.1,31.8-13.2c5.9-3.6,12.2-7.2,18.9-10.6
|
74 |
+
c-2-12.7,9.3-25.6,23.5-26.8c10.7-0.8,16,4,19.7,9.2c2-0.7,4.3-1.4,6.9-2.1C361.2,282.2,361,282.2,360.9,282z M366.1,367.9
|
75 |
+
c-0.1,0-0.2,0-0.4,0.1c-4.3,1-48.5,18.1-76.5,9.3c-0.1,1.5-0.1,4.7,0.5,6.1c0,0,0,0,0,0c4.2,0.8,9.6,1.4,15.8,1.4
|
76 |
+
C342.3,384.8,368.8,368.1,366.1,367.9z M160.3,364.5C160.3,364.5,160.3,364.4,160.3,364.5c2.3-2.4,3.2-5.8,2.7-9
|
77 |
+
c-0.8-4.6-6.1-5.6-9.5-9.2c-0.1-0.1-0.1-0.1-0.2-0.2c-0.1-0.1-0.1-0.1-0.2-0.2c0,0,0,0,0,0c-1.6-1.8-2.1-3.8-2-5.7
|
78 |
+
c0.3-4.7,4.5-6.1,6.7-5.2c0,0,2.6,0.6,4.6,3.4c0,0,0,0,0,0c-0.3-0.9-0.2-2.4-1.8-4.6c-2.6-3.7-8.5-7.4-16.9-5.6h0
|
79 |
+
c-1.6,0.3-0.7,0.1-2.2,0.6c-0.2,0.1-0.5,0.1-0.6,0.2c-0.5,0.2-0.9,0.4-1.4,0.6l0,0c-0.2,0.1-1.5,0.7-3,1.8
|
80 |
+
C127,343.6,143,365.7,160.3,364.5z"/>
|
81 |
+
<path class="st9" d="M299.4,289.5c0.8,1.2,1,2,0.7,2.4c-0.6,0.7-2.9-0.3-6.3-1.6c-8.7-3.2-15-3.7-26.3,0.6
|
82 |
+
c-2.9,1.1-4.9,1.9-5.9,1.8c-1.6-0.2-0.1-3.1,3.4-5.9c7-5.6,16.5-7.3,24.7-4.2C293.3,283.8,297.3,286.4,299.4,289.5z M297.7,298.4
|
83 |
+
c-2.4-1.8-6.7-3-11.3-2.3c-1,0.1-1.8,0.4-2.7,0.7c-0.3,0.1-0.6,0.2-0.9,0.3c-1.9,0.8-3.5,1.6-5.1,3.2c-1.8,1.7-2.3,3.4-1.8,3.8
|
84 |
+
c0.5,0.4,1.8-0.2,3.7-1c6.5-2.7,11.1-2.8,15.4-2.5c2.1,0.1,3.5,0.3,3.8-0.3C299.1,299.9,298.7,299.1,297.7,298.4z M158.1,331.6
|
85 |
+
L158.1,331.6L158.1,331.6c1.1,0.8,1.9,1.8,2.5,2.6c2,2.8,1.4,4.5,2.2,5.3c0.3,0.3,0.7,0.4,1.1,0.2c1.1-0.5,1.7-2.3,1.8-3.5l0,0l0,0
|
86 |
+
l0,0c0.3-3-1.3-6.4-3.4-8.8l0,0l0,0l0,0c-1.3-1.5-3-2.9-5-4c-2-1.1-4.4-2-7-2.4c-4.5-0.7-8.9,0.2-10.1,0.6l0,0
|
87 |
+
c-0.6,0.2-1.4,0.3-2.1,0.6c-7.3,2.8-12.1,8.1-14.2,15l0,0l0,0c-0.8,2.6-1.1,5.2-1.1,7.5c0,2,0.2,3.9,0.6,5.6v0l0,0l0,0
|
88 |
+
c0.6,2.8,1.9,6,3.8,8.1l0,0l0,0l0,0c2.5,2.7,5.2,2.2,4-0.3c-0.3-0.7-1.8-3.5-2-8.6c-0.1-3.3,0.3-6.8,1.5-9.9
|
89 |
+
c0.7-1.7,1.6-3.4,2.8-4.9c2.5-3,5.5-4.4,5.9-4.6l0,0c0.4-0.2,0.9-0.4,1.4-0.6c0.2-0.1,0.4-0.1,0.6-0.2c1.5-0.4,0.7-0.2,2.2-0.6h0
|
90 |
+
C149.5,327.4,154.5,328.7,158.1,331.6z M156.8,342.9c-0.8-0.6-1.2-1.2-1.4-2c-0.3-1.5-0.2-2.4,1.1-3.3c1-0.7,1.8-1,1.8-1.5
|
91 |
+
c0-0.8-3.3-1.7-5.7,0.7c-2,2.1-2.6,6.4,0.5,9.8c3.5,3.7,8.9,4.6,9.7,9.3c0.1,0.7,0.2,1.4,0.1,2.1c0,0.8-0.3,2.1-0.3,2.1
|
92 |
+
c-1,4.5-5.4,8.9-12.5,7.8c-1.3-0.2-2.2-0.4-2.4,0c-0.5,0.8,2.5,4.3,8.1,4.1c5.5-0.1,10.9-4.2,12.6-10.3c0-0.1,0.5-1.8,0.6-3.4
|
93 |
+
c0.1-1.2,0-2.3-0.2-3.6C167.6,346.8,159.7,345.2,156.8,342.9z M347.1,286.5c-2.2-0.3-4.3,1.8-4.7,4.7c-0.5,3,0.9,5.6,3.1,6
|
94 |
+
c2.2,0.3,4.3-1.8,4.7-4.7C350.7,289.6,349.3,286.9,347.1,286.5z M323.4,295.2c-1.2,2.2,0.3,5.2,3.2,6.9c3,1.6,6.3,1.2,7.5-1
|
95 |
+
c1.2-2.2-0.3-5.2-3.2-6.9C328,292.6,324.6,293,323.4,295.2z M236.6,207.6c40.8-26.5,81.6-29.5,95.6-18.8c0,0,0,0,0,0
|
96 |
+
c0-0.1-0.3-0.7-0.3-0.9l0,0c-3.5-7.5-11.8-12.8-19.2-14.9c1.3,1.3,3.2,3.8,3.9,5.3c-5.6-3.8-13-7.2-20.7-8.8c0,0,0.9,0.7,1.1,0.8
|
97 |
+
c1.5,1.4,3.6,3.7,4.4,5.6c-7.4-3-16.7-4.6-24.7-3.1c-0.1,0-1,0.2-1,0.2s1,0.3,1.3,0.3c2.6,0.8,6.4,2.4,8.1,4.6
|
98 |
+
c-13.3-2.3-27.8,0.2-35.7,4.6c1,0,1,0,1.9,0c2.9,0.1,8.7,0.5,11.2,2c-8.4,1.7-20.5,5.4-27,11c1.1-0.1,7.7-1,10.3-0.5
|
99 |
+
c-35.8,20.5-52.2,51.5-52.2,51.5l0,0C204.2,233,217.9,219.7,236.6,207.6z"/>
|
100 |
+
<path class="st1" d="M332.9,265.4c-0.1-2.8,0.4-7.5,3-8.3l0,0c0,0,0,0,0,0l0,0c4.5-1.6,10.5,10,10.8,20.3
|
101 |
+
c-3.6-1.8-7.8-2.6-12.1-2.2C333.5,271.9,333,268.8,332.9,265.4z"/>
|
102 |
+
</g>
|
103 |
+
<g>
|
104 |
+
<path class="st10" d="M35.4,19.2h126.9c8,0,14.5,6.5,14.5,14.5v48.4c0,8-6.5,14.5-14.5,14.5h-45.5L123,112L95.5,96.7H35.4
|
105 |
+
c-8,0-14.5-6.5-14.5-14.5V33.7C20.8,25.8,27.3,19.2,35.4,19.2z"/>
|
106 |
+
<path class="st7" d="M28.7,32.4c0.9-1.2,2.2-1.8,4-2c3.3-0.3,5.1,1.3,5.5,4.6c2,13.3,4.1,24.6,6.4,33.8l14-26.6
|
107 |
+
c1.3-2.4,2.9-3.7,4.8-3.8c2.8-0.2,4.5,1.6,5.2,5.4c1.6,8.5,3.6,15.7,6.1,21.8c1.7-16.2,4.5-27.9,8.4-35.1c1-1.8,2.4-2.7,4.2-2.8
|
108 |
+
c1.5-0.1,2.8,0.3,4,1.3c1.2,1,1.8,2.2,2,3.6c0.1,1.1-0.1,2.1-0.6,3.1c-2.5,4.6-4.5,12.3-6.2,23c-1.6,10.4-2.2,18.5-1.8,24.3
|
109 |
+
c0.1,1.6-0.1,3-0.8,4.2c-0.8,1.4-1.9,2.2-3.4,2.3c-1.7,0.1-3.4-0.6-5-2.4C69.6,81.1,64.9,72,61.4,60c-4.1,8.2-7.2,14.3-9.2,18.4
|
110 |
+
c-3.8,7.2-6.9,10.9-9.6,11.1c-1.7,0.1-3.2-1.3-4.5-4.4c-3.3-8.3-6.8-24.5-10.5-48.4C27.5,35,27.8,33.5,28.7,32.4z"/>
|
111 |
+
<path class="st7" d="M165.7,42.4c-2.3-4-5.7-6.4-10.2-7.4c-1.2-0.3-2.4-0.4-3.4-0.4c-6.1,0-11.1,3.2-15,9.6c-3.3,5.4-5,11.4-5,18
|
112 |
+
c0,4.9,1,9.1,3.1,12.6c2.3,4,5.7,6.4,10.2,7.4c1.2,0.3,2.4,0.4,3.4,0.4c6.2,0,11.2-3.2,15-9.6c3.3-5.5,5-11.5,5-18
|
113 |
+
C168.8,50,167.7,45.8,165.7,42.4L165.7,42.4z M157.7,60c-0.9,4.2-2.5,7.3-4.8,9.4c-1.8,1.7-3.6,2.4-5.2,2c-1.5-0.3-2.8-1.7-3.8-4.1
|
114 |
+
c-0.8-2-1.1-4-1.1-5.8c0-1.6,0.1-3.2,0.4-4.7c0.6-2.6,1.7-5.2,3.4-7.6c2.1-3.1,4.3-4.4,6.6-4c1.5,0.3,2.8,1.7,3.8,4.1
|
115 |
+
c0.8,2,1.1,4,1.1,5.8C158.1,57,157.9,58.6,157.7,60L157.7,60z"/>
|
116 |
+
<path class="st7" d="M125.7,42.4c-2.3-4-5.7-6.4-10.2-7.4c-1.2-0.3-2.4-0.4-3.4-0.4c-6.1,0-11.1,3.2-15,9.6c-3.3,5.4-5,11.4-5,18
|
117 |
+
c0,4.9,1,9.1,3.1,12.6c2.3,4,5.7,6.4,10.2,7.4c1.2,0.3,2.4,0.4,3.4,0.4c6.2,0,11.2-3.2,15-9.6c3.3-5.5,5-11.5,5-18
|
118 |
+
C128.8,50,127.8,45.8,125.7,42.4L125.7,42.4z M117.7,60c-0.9,4.2-2.5,7.3-4.8,9.4c-1.8,1.7-3.6,2.4-5.2,2c-1.5-0.3-2.8-1.7-3.8-4.1
|
119 |
+
c-0.8-2-1.1-4-1.1-5.8c0-1.6,0.1-3.2,0.4-4.7c0.6-2.6,1.7-5.2,3.4-7.6c2.1-3.1,4.3-4.4,6.6-4c1.5,0.3,2.8,1.7,3.8,4.1
|
120 |
+
c0.8,2,1.1,4,1.1,5.8C118.1,57,118,58.6,117.7,60L117.7,60z"/>
|
121 |
+
<g>
|
122 |
+
<g>
|
123 |
+
<path d="M192.9,41.8c-4.3,4.2-6.4,9.6-6.4,16.1c0,6.9,2.1,12.6,6.3,16.9c4.2,4.3,9.7,6.4,16.5,6.4c2,0,4.2-0.3,6.6-1V69.9
|
124 |
+
c-2.2,0.6-4.1,1-5.8,1c-3.4,0-6.1-1.1-8.1-3.4c-2-2.3-3.1-5.4-3.1-9.2c0-3.6,1-6.6,3-8.9c2-2.4,4.5-3.5,7.6-3.5
|
125 |
+
c2,0,4.1,0.3,6.4,1V36.4c-2.1-0.6-4.5-0.8-6.9-0.8C202.5,35.5,197.2,37.6,192.9,41.8z M237.1,35.5c-5.9,0-10.5,2-13.8,5.9
|
126 |
+
s-4.9,9.4-4.9,16.4c0,7.6,1.7,13.4,4.9,17.4s8,6.1,14.3,6.1c6.1,0,10.7-2,14-6.1s4.9-9.7,4.9-17s-1.7-12.9-5-16.8
|
127 |
+
C248.2,37.5,243.4,35.5,237.1,35.5z M242.2,68.6c-1.1,1.8-2.9,2.7-5,2.7c-2,0-3.6-0.9-4.7-2.7c-1.1-1.8-1.6-5.4-1.6-10.8
|
128 |
+
c0-8.3,2.1-12.5,6.4-12.5c4.5,0,6.8,4.2,6.8,12.7C244,63.3,243.3,66.9,242.2,68.6z M288,36.7l-2.3,9.8c-0.6,2.5-1.1,5-1.7,7.6
|
129 |
+
l-1.3,6.8c-1.2-6.8-2.9-14.8-5-24.2H263l-5.5,43.4h11.1l3-29.9l7.6,29.9h7.9l7.3-29.8l3.1,29.8H309l-5.9-43.4L288,36.7L288,36.7z
|
130 |
+
M341.1,36.7l-2.3,9.8c-0.6,2.5-1.1,5-1.7,7.6l-1.3,6.8c-1.2-6.8-2.9-14.8-5-24.2h-14.8l-5.5,43.4h11.1l3-29.9l7.6,29.9h7.9
|
131 |
+
l7.2-29.8l3.1,29.8h11.6l-5.9-43.4H341.1z M377.2,63h10.4v-9h-10.4v-8h12v-9.2h-23.7v43.4h23.8v-9.2h-12V63z M422.2,56.1
|
132 |
+
c1.2-2,1.8-4,1.8-6.1c0-4.1-1.6-7.3-4.8-9.7c-3.2-2.4-7.6-3.6-13.1-3.6h-13.6v43.4h11.7V60.4h0.2l9.5,19.8h12.4L417,60.6
|
133 |
+
C419.2,59.5,421,58.1,422.2,56.1z M404.2,55.4V45.1c2.8,0.1,4.8,0.5,6,1.4c1.2,0.9,1.8,2.3,1.8,4.3
|
134 |
+
C412,53.8,409.4,55.3,404.2,55.4z M431,41.8c-4.3,4.2-6.4,9.6-6.4,16.1c0,6.9,2.1,12.6,6.3,16.9c4.2,4.3,9.7,6.4,16.5,6.4
|
135 |
+
c2,0,4.2-0.3,6.6-1V69.9c-2.2,0.6-4.1,1-5.8,1c-3.4,0-6.1-1.1-8.1-3.4c-2-2.3-3.1-5.4-3.1-9.2c0-3.6,1-6.6,3-8.9
|
136 |
+
c2-2.4,4.5-3.5,7.6-3.5c2,0,4.1,0.3,6.4,1V36.4c-2.1-0.6-4.5-0.8-6.9-0.8C440.6,35.5,435.2,37.6,431,41.8z M469,70.8v-7.9h10.4
|
137 |
+
v-9H469v-8h12v-9.2h-23.7v43.4h23.8v-9.2L469,70.8L469,70.8z"/>
|
138 |
+
</g>
|
139 |
+
</g>
|
140 |
+
</g>
|
141 |
+
</svg>
|
assets/js/woocommerce-mailchimp-admin.js
CHANGED
@@ -1,340 +1,340 @@
|
|
1 |
-
/**
|
2 |
-
* WooCommerce MailChimp Plugin
|
3 |
-
*/
|
4 |
-
var SS_WC_MailChimp = function($) {
|
5 |
-
|
6 |
-
var $enabled;
|
7 |
-
var $apiKey;
|
8 |
-
var $accountLoadingIndicator;
|
9 |
-
var $listsLoadingIndicator;
|
10 |
-
var $mainList;
|
11 |
-
var $interestGroupsLoadingIndicator;
|
12 |
-
var $interestGroups;
|
13 |
-
var $displayOptIn;
|
14 |
-
var $occurs;
|
15 |
-
var $optInLabel;
|
16 |
-
var $optInCheckboxDefault;
|
17 |
-
var $optInCheckboxLocation;
|
18 |
-
var $doubleOptIn;
|
19 |
-
|
20 |
-
var namespace = 'ss_wc_mailchimp';
|
21 |
-
|
22 |
-
return {
|
23 |
-
init: init,
|
24 |
-
checkApiKey: checkApiKey,
|
25 |
-
loadLists: loadLists,
|
26 |
-
loadGroups: loadGroups,
|
27 |
-
};
|
28 |
-
|
29 |
-
function init() {
|
30 |
-
|
31 |
-
initHandles();
|
32 |
-
initAccount();
|
33 |
-
initHandlers();
|
34 |
-
initLists();
|
35 |
-
initGroups();
|
36 |
-
|
37 |
-
} //end function init
|
38 |
-
|
39 |
-
function initHandles() {
|
40 |
-
// Capture jQuery handles to elements
|
41 |
-
$enabled = $('#' + namespace_prefixed('enabled'));
|
42 |
-
$apiKey = $('#' + namespace_prefixed('api_key'));
|
43 |
-
$mainList = $('#' + namespace_prefixed('list'));
|
44 |
-
$interestGroups = $('#' + namespace_prefixed('interest_groups'));
|
45 |
-
$displayOptIn = $('#' + namespace_prefixed('display_opt_in'));
|
46 |
-
$occurs = $('#' + namespace_prefixed('occurs'));
|
47 |
-
$optInLabel = $('#' + namespace_prefixed('opt_in_label'));
|
48 |
-
$optInCheckboxDefault = $('#' + namespace_prefixed('opt_in_checkbox_default_status'));
|
49 |
-
$optInCheckboxLocation = $('#' + namespace_prefixed('opt_in_checkbox_display_location'));
|
50 |
-
$doubleOptIn = $('#' + namespace_prefixed('double_opt_in'));
|
51 |
-
}
|
52 |
-
|
53 |
-
function initHandlers() {
|
54 |
-
$mainList.closest('tr').hide();
|
55 |
-
|
56 |
-
if ($mainList.val() === '') {
|
57 |
-
$interestGroups.attr('disabled','disabled');
|
58 |
-
}
|
59 |
-
|
60 |
-
$apiKey.change(function() {
|
61 |
-
checkApiKey($apiKey.val(), true);
|
62 |
-
});
|
63 |
-
checkApiKey($apiKey.val(), false)
|
64 |
-
|
65 |
-
$mainList.change(function() {
|
66 |
-
if ($mainList.val()) {
|
67 |
-
$interestGroups.removeAttr('disabled');
|
68 |
-
} else {
|
69 |
-
$interestGroups.children().remove();
|
70 |
-
$interestGroups.attr('disabled','disabled');
|
71 |
-
}
|
72 |
-
});
|
73 |
-
|
74 |
-
$apiKey.on('paste cut', function() {
|
75 |
-
// Short pause to wait for paste to complete
|
76 |
-
setTimeout( function() {
|
77 |
-
$apiKey.change();
|
78 |
-
$apiKey.blur();
|
79 |
-
}, 100);
|
80 |
-
});
|
81 |
-
|
82 |
-
$mainList.on('change', function() {
|
83 |
-
if ($mainList.val() !== '') {
|
84 |
-
loadGroups($apiKey.val(), $mainList.val());
|
85 |
-
}
|
86 |
-
});
|
87 |
-
|
88 |
-
$optInLabel.closest('tr').hide();
|
89 |
-
$optInCheckboxDefault.closest('tr').hide();
|
90 |
-
$optInCheckboxLocation.closest('tr').hide();
|
91 |
-
$doubleOptIn.closest('tr').hide();
|
92 |
-
$displayOptIn.change(function() {
|
93 |
-
if ( '' === $apiKey.val() ) return;
|
94 |
-
|
95 |
-
switch ($displayOptIn.val()) {
|
96 |
-
case 'no':
|
97 |
-
$optInLabel.closest('tr').fadeOut();
|
98 |
-
$optInCheckboxDefault.closest('tr').fadeOut();
|
99 |
-
$optInCheckboxLocation.closest('tr').fadeOut();
|
100 |
-
$doubleOptIn.closest('tr').fadeIn();
|
101 |
-
break;
|
102 |
-
case 'yes':
|
103 |
-
$optInLabel.closest('tr').fadeIn();
|
104 |
-
$optInCheckboxDefault.closest('tr').fadeIn();
|
105 |
-
$optInCheckboxLocation.closest('tr').fadeIn();
|
106 |
-
$doubleOptIn.closest('tr').fadeIn();
|
107 |
-
break;
|
108 |
-
}
|
109 |
-
}).change();
|
110 |
-
|
111 |
-
} //end function initHandlers
|
112 |
-
|
113 |
-
function initAccount() {
|
114 |
-
$accountLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_account" class="woocommerce-mailchimp-loading"><span id="woocommerce_mailchimp_account_indicator" class="woocommerce-mailchimp-loading-indicator"></span></div>');
|
115 |
-
$apiKey.after($accountLoadingIndicator.hide());
|
116 |
-
|
117 |
-
} //end function initAccount
|
118 |
-
|
119 |
-
function initLists() {
|
120 |
-
$listsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_lists" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"> '+SS_WC_MailChimp_Messages.connecting_to_mailchimp+'</span></div>');
|
121 |
-
$mainList.after($listsLoadingIndicator.hide());
|
122 |
-
|
123 |
-
} //end function initLists
|
124 |
-
|
125 |
-
function initGroups() {
|
126 |
-
//return;
|
127 |
-
|
128 |
-
// Reinitialize the <optgroup> elements by splitting out the option names
|
129 |
-
var currentGroup = '';
|
130 |
-
var lastGroup = '';
|
131 |
-
var grouping;
|
132 |
-
var $options = $interestGroups.children('option').clone();
|
133 |
-
|
134 |
-
$interestGroups.attr('data-placeholder', SS_WC_MailChimp_Messages.select_groups_placeholder);
|
135 |
-
|
136 |
-
$interestGroups.select2('destroy').select2();
|
137 |
-
var groupsMessage = $('#ss-wc-mailchimp-groups-msg').length > 0 ? $('#ss-wc-mailchimp-groups-msg') : $('<div id="ss-wc-mailchimp-groups-msg" style="display: inline-block"/>');
|
138 |
-
$interestGroups.after(groupsMessage);
|
139 |
-
if ($options.length === 0) {
|
140 |
-
groupsMessage.text(SS_WC_MailChimp_Messages.interest_groups_not_enabled);
|
141 |
-
$interestGroups.siblings('.select2-container').remove();
|
142 |
-
groupsMessage.show();
|
143 |
-
} else {
|
144 |
-
$interestGroups.siblings('.select2-container').show();
|
145 |
-
groupsMessage.hide();
|
146 |
-
}
|
147 |
-
|
148 |
-
// Add the loading indicator for groups (set to hidden by default)
|
149 |
-
$interestGroupsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_groups" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"> '+SS_WC_MailChimp_Messages.connecting_to_mailchimp+'</span></div>');
|
150 |
-
$interestGroups.parent().append($interestGroupsLoadingIndicator.hide());
|
151 |
-
|
152 |
-
} //end function initGroups
|
153 |
-
|
154 |
-
function checkApiKey(apiKey, shouldLoadLists = false) {
|
155 |
-
|
156 |
-
if ( $apiKey.val() === '' ) {
|
157 |
-
toggleAllSettings('hide');
|
158 |
-
} else {
|
159 |
-
toggleAllSettings('show');
|
160 |
-
}
|
161 |
-
|
162 |
-
if (apiKey === '') return;
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Load account
|
166 |
-
*/
|
167 |
-
$mainList.attr('disabled','disabled');
|
168 |
-
$accountLoadingIndicator.show();
|
169 |
-
$accountIndicator = $accountLoadingIndicator.children().first();
|
170 |
-
$accountIndicator.removeClass('success').removeClass('error');
|
171 |
-
$accountIndicator.addClass('loading');
|
172 |
-
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.connecting_to_mailchimp);
|
173 |
-
$.post(
|
174 |
-
ajaxurl,
|
175 |
-
{
|
176 |
-
'action': '' + namespace_prefixed('get_account'),
|
177 |
-
'data': { 'api_key': apiKey }
|
178 |
-
},
|
179 |
-
function(response) {
|
180 |
-
console.log(response);
|
181 |
-
$accountIndicator.removeClass('loading');
|
182 |
-
var result = [];
|
183 |
-
|
184 |
-
try {
|
185 |
-
result = $.parseJSON(response);
|
186 |
-
} catch (err) {
|
187 |
-
console.error(err);
|
188 |
-
$accountIndicator.addClass('error');
|
189 |
-
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.error_loading_account);
|
190 |
-
return;
|
191 |
-
}
|
192 |
-
|
193 |
-
if ( result.error ) {
|
194 |
-
$accountIndicator.addClass('error');
|
195 |
-
$accountIndicator.html(result.error);
|
196 |
-
return;
|
197 |
-
}
|
198 |
-
|
199 |
-
if ( ! result.account_id ) {
|
200 |
-
$accountIndicator.addClass('error');
|
201 |
-
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.error_loading_account);
|
202 |
-
return;
|
203 |
-
}
|
204 |
-
|
205 |
-
$accountIndicator.addClass('success');
|
206 |
-
$mainList.removeAttr('disabled');
|
207 |
-
$accountIndicator.html('');
|
208 |
-
|
209 |
-
// API Key looks good. Let's load the lists.
|
210 |
-
if ( shouldLoadLists ) {
|
211 |
-
loadLists( apiKey );
|
212 |
-
}
|
213 |
-
}
|
214 |
-
);
|
215 |
-
|
216 |
-
} //end function checkApiKey
|
217 |
-
|
218 |
-
function loadLists(apiKey) {
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Load lists
|
222 |
-
*/
|
223 |
-
$mainList.attr('disabled','disabled');
|
224 |
-
$listsLoadingIndicator.show();
|
225 |
-
$listsIndicator = $listsLoadingIndicator.children().first();
|
226 |
-
$listsIndicator.addClass('loading');
|
227 |
-
$.post(
|
228 |
-
ajaxurl,
|
229 |
-
{
|
230 |
-
'action': '' + namespace_prefixed('get_lists'),
|
231 |
-
'data': { 'api_key': apiKey }
|
232 |
-
},
|
233 |
-
function(response) {
|
234 |
-
console.log(response);
|
235 |
-
$listsLoadingIndicator.hide();
|
236 |
-
$listsIndicator.removeClass('loading');
|
237 |
-
var result = [];
|
238 |
-
|
239 |
-
try {
|
240 |
-
result = $.parseJSON(response);
|
241 |
-
} catch (err) {
|
242 |
-
console.error(err);
|
243 |
-
alert(SS_WC_MailChimp_Messages.error_loading_lists);
|
244 |
-
}
|
245 |
-
|
246 |
-
if (result) {
|
247 |
-
$mainList.select2('destroy');
|
248 |
-
$mainList.removeAttr('disabled');
|
249 |
-
$mainList.children().remove();
|
250 |
-
$.each(result, function(key, val) {
|
251 |
-
$mainList
|
252 |
-
.append($('<option></option>')
|
253 |
-
.attr('value',key)
|
254 |
-
.text(val));
|
255 |
-
});
|
256 |
-
$mainList.select2();
|
257 |
-
}
|
258 |
-
}
|
259 |
-
);
|
260 |
-
|
261 |
-
} //end function loadLists
|
262 |
-
|
263 |
-
function loadGroups(apiKey, listId) {
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Load interest groups
|
267 |
-
*/
|
268 |
-
$interestGroups.attr('disabled','disabled');
|
269 |
-
|
270 |
-
$interestGroups.children().remove();
|
271 |
-
|
272 |
-
$interestGroups.select2().hide();
|
273 |
-
$('#ss-wc-mailchimp-groups-msg').hide();
|
274 |
-
$interestGroupsLoadingIndicator.show();
|
275 |
-
$interestGroupsIndicator = $interestGroupsLoadingIndicator.children().first();
|
276 |
-
$interestGroupsIndicator.addClass('loading');
|
277 |
-
$.post(
|
278 |
-
ajaxurl,
|
279 |
-
{
|
280 |
-
'action': '' + namespace_prefixed('get_interest_groups'),
|
281 |
-
'data': { 'api_key': apiKey, 'list_id': listId }
|
282 |
-
},
|
283 |
-
function(response) {
|
284 |
-
console.log(response);
|
285 |
-
$interestGroupsLoadingIndicator.hide();
|
286 |
-
$interestGroupsIndicator.removeClass('loading');
|
287 |
-
var result = [];
|
288 |
-
|
289 |
-
try {
|
290 |
-
result = $.parseJSON(response);
|
291 |
-
} catch (err) {
|
292 |
-
console.error(err);
|
293 |
-
alert(SS_WC_MailChimp_Messages.error_loading_groups);
|
294 |
-
}
|
295 |
-
|
296 |
-
if (result.error) {
|
297 |
-
$('#ss-wc-mailchimp-groups-msg').text(result.error).show();
|
298 |
-
$interestGroups.children().remove();
|
299 |
-
$interestGroups.select2('destroy');
|
300 |
-
$interestGroups.hide();
|
301 |
-
return;
|
302 |
-
}
|
303 |
-
|
304 |
-
if (result.length === 0) {
|
305 |
-
$('#ss-wc-mailchimp-groups-msg').show();
|
306 |
-
initGroups();
|
307 |
-
return;
|
308 |
-
}
|
309 |
-
|
310 |
-
$interestGroups.show();
|
311 |
-
$interestGroups.removeAttr('disabled');
|
312 |
-
$interestGroups.children().remove();
|
313 |
-
$.each(result, function(id, grouping) {
|
314 |
-
$interestGroups.append(
|
315 |
-
$('<option></option>')
|
316 |
-
.attr('value',id)
|
317 |
-
.text(grouping));
|
318 |
-
});
|
319 |
-
|
320 |
-
initGroups();
|
321 |
-
}
|
322 |
-
);
|
323 |
-
|
324 |
-
} //end function loadGroups
|
325 |
-
|
326 |
-
function toggleAllSettings( show_hide ) {
|
327 |
-
if (show_hide == 'show') {
|
328 |
-
$apiKey.closest('tr').nextAll('tr').fadeIn();
|
329 |
-
$apiKey.closest('table').nextAll('h2, .form-table').fadeIn();
|
330 |
-
} else {
|
331 |
-
$apiKey.closest('tr').nextAll('tr').fadeOut();
|
332 |
-
$apiKey.closest('table').nextAll('h2, .form-table').fadeOut();
|
333 |
-
}
|
334 |
-
}
|
335 |
-
|
336 |
-
function namespace_prefixed( suffix ) {
|
337 |
-
return namespace + '_' + suffix;
|
338 |
-
}
|
339 |
-
|
340 |
}(jQuery);
|
1 |
+
/**
|
2 |
+
* WooCommerce MailChimp Plugin
|
3 |
+
*/
|
4 |
+
var SS_WC_MailChimp = function($) {
|
5 |
+
|
6 |
+
var $enabled;
|
7 |
+
var $apiKey;
|
8 |
+
var $accountLoadingIndicator;
|
9 |
+
var $listsLoadingIndicator;
|
10 |
+
var $mainList;
|
11 |
+
var $interestGroupsLoadingIndicator;
|
12 |
+
var $interestGroups;
|
13 |
+
var $displayOptIn;
|
14 |
+
var $occurs;
|
15 |
+
var $optInLabel;
|
16 |
+
var $optInCheckboxDefault;
|
17 |
+
var $optInCheckboxLocation;
|
18 |
+
var $doubleOptIn;
|
19 |
+
|
20 |
+
var namespace = 'ss_wc_mailchimp';
|
21 |
+
|
22 |
+
return {
|
23 |
+
init: init,
|
24 |
+
checkApiKey: checkApiKey,
|
25 |
+
loadLists: loadLists,
|
26 |
+
loadGroups: loadGroups,
|
27 |
+
};
|
28 |
+
|
29 |
+
function init() {
|
30 |
+
|
31 |
+
initHandles();
|
32 |
+
initAccount();
|
33 |
+
initHandlers();
|
34 |
+
initLists();
|
35 |
+
initGroups();
|
36 |
+
|
37 |
+
} //end function init
|
38 |
+
|
39 |
+
function initHandles() {
|
40 |
+
// Capture jQuery handles to elements
|
41 |
+
$enabled = $('#' + namespace_prefixed('enabled'));
|
42 |
+
$apiKey = $('#' + namespace_prefixed('api_key'));
|
43 |
+
$mainList = $('#' + namespace_prefixed('list'));
|
44 |
+
$interestGroups = $('#' + namespace_prefixed('interest_groups'));
|
45 |
+
$displayOptIn = $('#' + namespace_prefixed('display_opt_in'));
|
46 |
+
$occurs = $('#' + namespace_prefixed('occurs'));
|
47 |
+
$optInLabel = $('#' + namespace_prefixed('opt_in_label'));
|
48 |
+
$optInCheckboxDefault = $('#' + namespace_prefixed('opt_in_checkbox_default_status'));
|
49 |
+
$optInCheckboxLocation = $('#' + namespace_prefixed('opt_in_checkbox_display_location'));
|
50 |
+
$doubleOptIn = $('#' + namespace_prefixed('double_opt_in'));
|
51 |
+
}
|
52 |
+
|
53 |
+
function initHandlers() {
|
54 |
+
$mainList.closest('tr').hide();
|
55 |
+
|
56 |
+
if ($mainList.val() === '') {
|
57 |
+
$interestGroups.attr('disabled','disabled');
|
58 |
+
}
|
59 |
+
|
60 |
+
$apiKey.change(function() {
|
61 |
+
checkApiKey($apiKey.val(), true);
|
62 |
+
});
|
63 |
+
checkApiKey($apiKey.val(), false)
|
64 |
+
|
65 |
+
$mainList.change(function() {
|
66 |
+
if ($mainList.val()) {
|
67 |
+
$interestGroups.removeAttr('disabled');
|
68 |
+
} else {
|
69 |
+
$interestGroups.children().remove();
|
70 |
+
$interestGroups.attr('disabled','disabled');
|
71 |
+
}
|
72 |
+
});
|
73 |
+
|
74 |
+
$apiKey.on('paste cut', function() {
|
75 |
+
// Short pause to wait for paste to complete
|
76 |
+
setTimeout( function() {
|
77 |
+
$apiKey.change();
|
78 |
+
$apiKey.blur();
|
79 |
+
}, 100);
|
80 |
+
});
|
81 |
+
|
82 |
+
$mainList.on('change', function() {
|
83 |
+
if ($mainList.val() !== '') {
|
84 |
+
loadGroups($apiKey.val(), $mainList.val());
|
85 |
+
}
|
86 |
+
});
|
87 |
+
|
88 |
+
$optInLabel.closest('tr').hide();
|
89 |
+
$optInCheckboxDefault.closest('tr').hide();
|
90 |
+
$optInCheckboxLocation.closest('tr').hide();
|
91 |
+
$doubleOptIn.closest('tr').hide();
|
92 |
+
$displayOptIn.change(function() {
|
93 |
+
if ( '' === $apiKey.val() ) return;
|
94 |
+
|
95 |
+
switch ($displayOptIn.val()) {
|
96 |
+
case 'no':
|
97 |
+
$optInLabel.closest('tr').fadeOut();
|
98 |
+
$optInCheckboxDefault.closest('tr').fadeOut();
|
99 |
+
$optInCheckboxLocation.closest('tr').fadeOut();
|
100 |
+
$doubleOptIn.closest('tr').fadeIn();
|
101 |
+
break;
|
102 |
+
case 'yes':
|
103 |
+
$optInLabel.closest('tr').fadeIn();
|
104 |
+
$optInCheckboxDefault.closest('tr').fadeIn();
|
105 |
+
$optInCheckboxLocation.closest('tr').fadeIn();
|
106 |
+
$doubleOptIn.closest('tr').fadeIn();
|
107 |
+
break;
|
108 |
+
}
|
109 |
+
}).change();
|
110 |
+
|
111 |
+
} //end function initHandlers
|
112 |
+
|
113 |
+
function initAccount() {
|
114 |
+
$accountLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_account" class="woocommerce-mailchimp-loading"><span id="woocommerce_mailchimp_account_indicator" class="woocommerce-mailchimp-loading-indicator"></span></div>');
|
115 |
+
$apiKey.after($accountLoadingIndicator.hide());
|
116 |
+
|
117 |
+
} //end function initAccount
|
118 |
+
|
119 |
+
function initLists() {
|
120 |
+
$listsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_lists" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"> '+SS_WC_MailChimp_Messages.connecting_to_mailchimp+'</span></div>');
|
121 |
+
$mainList.after($listsLoadingIndicator.hide());
|
122 |
+
|
123 |
+
} //end function initLists
|
124 |
+
|
125 |
+
function initGroups() {
|
126 |
+
//return;
|
127 |
+
|
128 |
+
// Reinitialize the <optgroup> elements by splitting out the option names
|
129 |
+
var currentGroup = '';
|
130 |
+
var lastGroup = '';
|
131 |
+
var grouping;
|
132 |
+
var $options = $interestGroups.children('option').clone();
|
133 |
+
|
134 |
+
$interestGroups.attr('data-placeholder', SS_WC_MailChimp_Messages.select_groups_placeholder);
|
135 |
+
|
136 |
+
$interestGroups.select2('destroy').select2();
|
137 |
+
var groupsMessage = $('#ss-wc-mailchimp-groups-msg').length > 0 ? $('#ss-wc-mailchimp-groups-msg') : $('<div id="ss-wc-mailchimp-groups-msg" style="display: inline-block"/>');
|
138 |
+
$interestGroups.after(groupsMessage);
|
139 |
+
if ($options.length === 0) {
|
140 |
+
groupsMessage.text(SS_WC_MailChimp_Messages.interest_groups_not_enabled);
|
141 |
+
$interestGroups.siblings('.select2-container').remove();
|
142 |
+
groupsMessage.show();
|
143 |
+
} else {
|
144 |
+
$interestGroups.siblings('.select2-container').show();
|
145 |
+
groupsMessage.hide();
|
146 |
+
}
|
147 |
+
|
148 |
+
// Add the loading indicator for groups (set to hidden by default)
|
149 |
+
$interestGroupsLoadingIndicator = $('<div id="ss_wc_mailchimp_loading_groups" class="woocommerce-mailchimp-loading"><span class="woocommerce-mailchimp-loading-indicator"> '+SS_WC_MailChimp_Messages.connecting_to_mailchimp+'</span></div>');
|
150 |
+
$interestGroups.parent().append($interestGroupsLoadingIndicator.hide());
|
151 |
+
|
152 |
+
} //end function initGroups
|
153 |
+
|
154 |
+
function checkApiKey(apiKey, shouldLoadLists = false) {
|
155 |
+
|
156 |
+
if ( $apiKey.val() === '' ) {
|
157 |
+
toggleAllSettings('hide');
|
158 |
+
} else {
|
159 |
+
toggleAllSettings('show');
|
160 |
+
}
|
161 |
+
|
162 |
+
if (apiKey === '') return;
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Load account
|
166 |
+
*/
|
167 |
+
$mainList.attr('disabled','disabled');
|
168 |
+
$accountLoadingIndicator.show();
|
169 |
+
$accountIndicator = $accountLoadingIndicator.children().first();
|
170 |
+
$accountIndicator.removeClass('success').removeClass('error');
|
171 |
+
$accountIndicator.addClass('loading');
|
172 |
+
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.connecting_to_mailchimp);
|
173 |
+
$.post(
|
174 |
+
ajaxurl,
|
175 |
+
{
|
176 |
+
'action': '' + namespace_prefixed('get_account'),
|
177 |
+
'data': { 'api_key': apiKey }
|
178 |
+
},
|
179 |
+
function(response) {
|
180 |
+
console.log(response);
|
181 |
+
$accountIndicator.removeClass('loading');
|
182 |
+
var result = [];
|
183 |
+
|
184 |
+
try {
|
185 |
+
result = $.parseJSON(response);
|
186 |
+
} catch (err) {
|
187 |
+
console.error(err);
|
188 |
+
$accountIndicator.addClass('error');
|
189 |
+
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.error_loading_account);
|
190 |
+
return;
|
191 |
+
}
|
192 |
+
|
193 |
+
if ( result.error ) {
|
194 |
+
$accountIndicator.addClass('error');
|
195 |
+
$accountIndicator.html(result.error);
|
196 |
+
return;
|
197 |
+
}
|
198 |
+
|
199 |
+
if ( ! result.account_id ) {
|
200 |
+
$accountIndicator.addClass('error');
|
201 |
+
$accountIndicator.html(' '+SS_WC_MailChimp_Messages.error_loading_account);
|
202 |
+
return;
|
203 |
+
}
|
204 |
+
|
205 |
+
$accountIndicator.addClass('success');
|
206 |
+
$mainList.removeAttr('disabled');
|
207 |
+
$accountIndicator.html('');
|
208 |
+
|
209 |
+
// API Key looks good. Let's load the lists.
|
210 |
+
if ( shouldLoadLists ) {
|
211 |
+
loadLists( apiKey );
|
212 |
+
}
|
213 |
+
}
|
214 |
+
);
|
215 |
+
|
216 |
+
} //end function checkApiKey
|
217 |
+
|
218 |
+
function loadLists(apiKey) {
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Load lists
|
222 |
+
*/
|
223 |
+
$mainList.attr('disabled','disabled');
|
224 |
+
$listsLoadingIndicator.show();
|
225 |
+
$listsIndicator = $listsLoadingIndicator.children().first();
|
226 |
+
$listsIndicator.addClass('loading');
|
227 |
+
$.post(
|
228 |
+
ajaxurl,
|
229 |
+
{
|
230 |
+
'action': '' + namespace_prefixed('get_lists'),
|
231 |
+
'data': { 'api_key': apiKey }
|
232 |
+
},
|
233 |
+
function(response) {
|
234 |
+
console.log(response);
|
235 |
+
$listsLoadingIndicator.hide();
|
236 |
+
$listsIndicator.removeClass('loading');
|
237 |
+
var result = [];
|
238 |
+
|
239 |
+
try {
|
240 |
+
result = $.parseJSON(response);
|
241 |
+
} catch (err) {
|
242 |
+
console.error(err);
|
243 |
+
alert(SS_WC_MailChimp_Messages.error_loading_lists);
|
244 |
+
}
|
245 |
+
|
246 |
+
if (result) {
|
247 |
+
$mainList.select2('destroy');
|
248 |
+
$mainList.removeAttr('disabled');
|
249 |
+
$mainList.children().remove();
|
250 |
+
$.each(result, function(key, val) {
|
251 |
+
$mainList
|
252 |
+
.append($('<option></option>')
|
253 |
+
.attr('value',key)
|
254 |
+
.text(val));
|
255 |
+
});
|
256 |
+
$mainList.select2();
|
257 |
+
}
|
258 |
+
}
|
259 |
+
);
|
260 |
+
|
261 |
+
} //end function loadLists
|
262 |
+
|
263 |
+
function loadGroups(apiKey, listId) {
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Load interest groups
|
267 |
+
*/
|
268 |
+
$interestGroups.attr('disabled','disabled');
|
269 |
+
|
270 |
+
$interestGroups.children().remove();
|
271 |
+
|
272 |
+
$interestGroups.select2().hide();
|
273 |
+
$('#ss-wc-mailchimp-groups-msg').hide();
|
274 |
+
$interestGroupsLoadingIndicator.show();
|
275 |
+
$interestGroupsIndicator = $interestGroupsLoadingIndicator.children().first();
|
276 |
+
$interestGroupsIndicator.addClass('loading');
|
277 |
+
$.post(
|
278 |
+
ajaxurl,
|
279 |
+
{
|
280 |
+
'action': '' + namespace_prefixed('get_interest_groups'),
|
281 |
+
'data': { 'api_key': apiKey, 'list_id': listId }
|
282 |
+
},
|
283 |
+
function(response) {
|
284 |
+
console.log(response);
|
285 |
+
$interestGroupsLoadingIndicator.hide();
|
286 |
+
$interestGroupsIndicator.removeClass('loading');
|
287 |
+
var result = [];
|
288 |
+
|
289 |
+
try {
|
290 |
+
result = $.parseJSON(response);
|
291 |
+
} catch (err) {
|
292 |
+
console.error(err);
|
293 |
+
alert(SS_WC_MailChimp_Messages.error_loading_groups);
|
294 |
+
}
|
295 |
+
|
296 |
+
if (result.error) {
|
297 |
+
$('#ss-wc-mailchimp-groups-msg').text(result.error).show();
|
298 |
+
$interestGroups.children().remove();
|
299 |
+
$interestGroups.select2('destroy');
|
300 |
+
$interestGroups.hide();
|
301 |
+
return;
|
302 |
+
}
|
303 |
+
|
304 |
+
if (result.length === 0) {
|
305 |
+
$('#ss-wc-mailchimp-groups-msg').show();
|
306 |
+
initGroups();
|
307 |
+
return;
|
308 |
+
}
|
309 |
+
|
310 |
+
$interestGroups.show();
|
311 |
+
$interestGroups.removeAttr('disabled');
|
312 |
+
$interestGroups.children().remove();
|
313 |
+
$.each(result, function(id, grouping) {
|
314 |
+
$interestGroups.append(
|
315 |
+
$('<option></option>')
|
316 |
+
.attr('value',id)
|
317 |
+
.text(grouping));
|
318 |
+
});
|
319 |
+
|
320 |
+
initGroups();
|
321 |
+
}
|
322 |
+
);
|
323 |
+
|
324 |
+
} //end function loadGroups
|
325 |
+
|
326 |
+
function toggleAllSettings( show_hide ) {
|
327 |
+
if (show_hide == 'show') {
|
328 |
+
$apiKey.closest('tr').nextAll('tr').fadeIn();
|
329 |
+
$apiKey.closest('table').nextAll('h2, .form-table').fadeIn();
|
330 |
+
} else {
|
331 |
+
$apiKey.closest('tr').nextAll('tr').fadeOut();
|
332 |
+
$apiKey.closest('table').nextAll('h2, .form-table').fadeOut();
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
function namespace_prefixed( suffix ) {
|
337 |
+
return namespace + '_' + suffix;
|
338 |
+
}
|
339 |
+
|
340 |
}(jQuery);
|
assets/screenshot-1.png
ADDED
Binary file
|
assets/screenshot-2.png
ADDED
Binary file
|
config/default-settings.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php
|
2 |
-
return array(
|
3 |
-
'api_key' => '',
|
4 |
-
'enabled' => 'yes',
|
5 |
-
'list' => '',
|
6 |
-
'interest_groups' => '',
|
7 |
-
'display_opt_in' => 'no',
|
8 |
-
'occurs' => 'pending',
|
9 |
-
'double_opt_in' => 'no',
|
10 |
-
'opt_in_label' => __( 'Subscribe to our newsletter', 'ss_wc_mailchimp' ),
|
11 |
-
'opt_in_checkbox_default_status' => 'checked',
|
12 |
-
'opt_in_checkbox_display_location' => 'woocommerce_review_order_before_submit',
|
13 |
-
'debug' => 'no',
|
14 |
);
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
'api_key' => '',
|
4 |
+
'enabled' => 'yes',
|
5 |
+
'list' => '',
|
6 |
+
'interest_groups' => '',
|
7 |
+
'display_opt_in' => 'no',
|
8 |
+
'occurs' => 'pending',
|
9 |
+
'double_opt_in' => 'no',
|
10 |
+
'opt_in_label' => __( 'Subscribe to our newsletter', 'ss_wc_mailchimp' ),
|
11 |
+
'opt_in_checkbox_default_status' => 'checked',
|
12 |
+
'opt_in_checkbox_display_location' => 'woocommerce_review_order_before_submit',
|
13 |
+
'debug' => 'no',
|
14 |
);
|
includes/class-ss-wc-mailchimp-admin-notices.php
CHANGED
@@ -1,193 +1,193 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce MailChimp Admin notices
|
4 |
-
*
|
5 |
-
* @package WooCommerce MailChimp
|
6 |
-
* @author Saint Systems, LLC
|
7 |
-
* @link http://www.saintsystems.com
|
8 |
-
* @copyright Copyright 2016, Saint Systems, LLC
|
9 |
-
*
|
10 |
-
* @since 2.0.13
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Handle displaying and storing of admin notices for WooCommerce MailChimp
|
15 |
-
* @since 2.0.13
|
16 |
-
*/
|
17 |
-
class SS_WC_MailChimp_Admin_Notices {
|
18 |
-
|
19 |
-
static private $admin_notices = array();
|
20 |
-
|
21 |
-
static private $dismissed_notices = array();
|
22 |
-
|
23 |
-
function __construct() {
|
24 |
-
|
25 |
-
$this->add_hooks();
|
26 |
-
}
|
27 |
-
|
28 |
-
function add_hooks() {
|
29 |
-
add_action( 'network_admin_notices', array( $this, 'dismiss_notice' ), 50 );
|
30 |
-
add_action( 'admin_notices', array( $this, 'dismiss_notice' ), 50 );
|
31 |
-
add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 );
|
32 |
-
add_action( 'network_admin_notices', array( $this, 'admin_notice' ), 100 );
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Dismiss a WooCommerce notice - stores the dismissed notices for 16 weeks
|
37 |
-
* @return void
|
38 |
-
*/
|
39 |
-
public function dismiss_notice() {
|
40 |
-
|
41 |
-
// No dismiss sent
|
42 |
-
if ( empty( $_GET['sswcmc-dismiss'] ) ) {
|
43 |
-
return;
|
44 |
-
}
|
45 |
-
|
46 |
-
// Invalid nonce
|
47 |
-
if ( !wp_verify_nonce( $_GET['sswcmc-dismiss'], 'dismiss' ) ) {
|
48 |
-
return;
|
49 |
-
}
|
50 |
-
|
51 |
-
$notice_id = esc_attr( $_GET['notice'] );
|
52 |
-
|
53 |
-
//don't display a message if use has dismissed the message for this version
|
54 |
-
$dismissed_notices = (array)get_transient( 'ss_wc_mailchimp_dismissed_notices' );
|
55 |
-
|
56 |
-
$dismissed_notices[] = $notice_id;
|
57 |
-
|
58 |
-
$dismissed_notices = array_unique( $dismissed_notices );
|
59 |
-
|
60 |
-
// Remind users every 16 weeks
|
61 |
-
set_transient( 'ss_wc_mailchimp_dismissed_notices', $dismissed_notices, WEEK_IN_SECONDS * 16 );
|
62 |
-
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Should the notice be shown in the admin (Has it been dismissed already)?
|
67 |
-
*
|
68 |
-
* If the passed notice array has a `dismiss` key, the notice is dismissable. If it's dismissable,
|
69 |
-
* we check against other notices that have already been dismissed.
|
70 |
-
*
|
71 |
-
* @see GravityView_Admin::dismiss_notice()
|
72 |
-
* @see GravityView_Admin::add_notice()
|
73 |
-
* @param string $notice Notice array, set using `add_notice()`.
|
74 |
-
* @return boolean True: show notice; False: hide notice
|
75 |
-
*/
|
76 |
-
function _maybe_show_notice( $notice ) {
|
77 |
-
|
78 |
-
// There are no dismissed notices.
|
79 |
-
if( empty( self::$dismissed_notices ) ) {
|
80 |
-
return true;
|
81 |
-
}
|
82 |
-
|
83 |
-
// Has the
|
84 |
-
$is_dismissed = !empty( $notice['dismiss'] ) && in_array( $notice['dismiss'], self::$dismissed_notices );
|
85 |
-
|
86 |
-
return $is_dismissed ? false : true;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Get admin notices
|
91 |
-
* @since 1.12
|
92 |
-
* @return array
|
93 |
-
*/
|
94 |
-
public static function get_notices() {
|
95 |
-
return self::$admin_notices;
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Handle whether to display notices in Multisite based on plugin activation status
|
100 |
-
*
|
101 |
-
* @since 2.0.13
|
102 |
-
*
|
103 |
-
* @return bool True: show the notices; false: don't show
|
104 |
-
*/
|
105 |
-
private function check_show_multisite_notices() {
|
106 |
-
|
107 |
-
if ( ! is_multisite() ) {
|
108 |
-
return true;
|
109 |
-
}
|
110 |
-
|
111 |
-
// It's network activated but the user can't manage network plugins; they can't do anything about it.
|
112 |
-
if ( SS_WC_MailChimp_Plugin::is_network_activated() && ! is_main_site() ) {
|
113 |
-
return false;
|
114 |
-
}
|
115 |
-
|
116 |
-
// or they don't have admin capabilities
|
117 |
-
if ( ! is_super_admin() ) {
|
118 |
-
return false;
|
119 |
-
}
|
120 |
-
|
121 |
-
return true;
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Outputs the admin notices generated by the plugin
|
126 |
-
*
|
127 |
-
* @since 2.0.13
|
128 |
-
*
|
129 |
-
* @return void
|
130 |
-
*/
|
131 |
-
public function admin_notice() {
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Modify the notices displayed
|
135 |
-
* @since 2.0.13
|
136 |
-
*/
|
137 |
-
$notices = apply_filters( 'ss_wc_mailchimp/admin/notices', self::$admin_notices );
|
138 |
-
|
139 |
-
if( empty( $notices ) || ! $this->check_show_multisite_notices() ) {
|
140 |
-
return;
|
141 |
-
}
|
142 |
-
|
143 |
-
//don't display a message if use has dismissed the message for this version
|
144 |
-
self::$dismissed_notices = isset( $_GET['show-dismissed-notices'] ) ? array() : (array)get_transient( 'ss_wc_mailchimp_dismissed_notices' );
|
145 |
-
|
146 |
-
foreach( $notices as $notice ) {
|
147 |
-
|
148 |
-
if( false === $this->_maybe_show_notice( $notice ) ) {
|
149 |
-
continue;
|
150 |
-
}
|
151 |
-
|
152 |
-
echo '<div id="message" class="notice '. sswcmc_sanitize_html_class( $notice['class'] ).'">';
|
153 |
-
|
154 |
-
if( !empty( $notice['title'] ) ) {
|
155 |
-
echo '<h3>'.esc_html( $notice['title'] ) .'</h3>';
|
156 |
-
}
|
157 |
-
|
158 |
-
echo wpautop( $notice['message'] );
|
159 |
-
|
160 |
-
if( !empty( $notice['dismiss'] ) ) {
|
161 |
-
|
162 |
-
$dismiss = esc_attr($notice['dismiss']);
|
163 |
-
|
164 |
-
$url = esc_url( add_query_arg( array( 'sswcmc-dismiss' => wp_create_nonce( 'dismiss' ), 'notice' => $dismiss ) ) );
|
165 |
-
|
166 |
-
echo wpautop( '<a href="'.$url.'" data-notice="'.$dismiss.'" class="button-small button button-secondary">'.esc_html__( 'Dismiss', 'woocommerce-mailchimp' ).'</a>' );
|
167 |
-
}
|
168 |
-
|
169 |
-
echo '<div class="clear"></div>';
|
170 |
-
echo '</div>';
|
171 |
-
|
172 |
-
}
|
173 |
-
|
174 |
-
//reset the notices handler
|
175 |
-
self::$admin_notices = array();
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Add a notice to be displayed in the admin.
|
180 |
-
* @param array $notice Array with `class` and `message` keys. The message is not escaped.
|
181 |
-
*/
|
182 |
-
public static function add_notice( $notice = array() ) {
|
183 |
-
|
184 |
-
if( !isset( $notice['message'] ) ) {
|
185 |
-
do_action( 'ss_wc_mailchimp_log_error', 'SSWCMC_Admin[add_notice] Notice not set', $notice );
|
186 |
-
return;
|
187 |
-
}
|
188 |
-
|
189 |
-
$notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class'];
|
190 |
-
|
191 |
-
self::$admin_notices[] = $notice;
|
192 |
-
}
|
193 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce MailChimp Admin notices
|
4 |
+
*
|
5 |
+
* @package WooCommerce MailChimp
|
6 |
+
* @author Saint Systems, LLC
|
7 |
+
* @link http://www.saintsystems.com
|
8 |
+
* @copyright Copyright 2016, Saint Systems, LLC
|
9 |
+
*
|
10 |
+
* @since 2.0.13
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Handle displaying and storing of admin notices for WooCommerce MailChimp
|
15 |
+
* @since 2.0.13
|
16 |
+
*/
|
17 |
+
class SS_WC_MailChimp_Admin_Notices {
|
18 |
+
|
19 |
+
static private $admin_notices = array();
|
20 |
+
|
21 |
+
static private $dismissed_notices = array();
|
22 |
+
|
23 |
+
function __construct() {
|
24 |
+
|
25 |
+
$this->add_hooks();
|
26 |
+
}
|
27 |
+
|
28 |
+
function add_hooks() {
|
29 |
+
add_action( 'network_admin_notices', array( $this, 'dismiss_notice' ), 50 );
|
30 |
+
add_action( 'admin_notices', array( $this, 'dismiss_notice' ), 50 );
|
31 |
+
add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 );
|
32 |
+
add_action( 'network_admin_notices', array( $this, 'admin_notice' ), 100 );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Dismiss a WooCommerce notice - stores the dismissed notices for 16 weeks
|
37 |
+
* @return void
|
38 |
+
*/
|
39 |
+
public function dismiss_notice() {
|
40 |
+
|
41 |
+
// No dismiss sent
|
42 |
+
if ( empty( $_GET['sswcmc-dismiss'] ) ) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
// Invalid nonce
|
47 |
+
if ( !wp_verify_nonce( $_GET['sswcmc-dismiss'], 'dismiss' ) ) {
|
48 |
+
return;
|
49 |
+
}
|
50 |
+
|
51 |
+
$notice_id = esc_attr( $_GET['notice'] );
|
52 |
+
|
53 |
+
//don't display a message if use has dismissed the message for this version
|
54 |
+
$dismissed_notices = (array)get_transient( 'ss_wc_mailchimp_dismissed_notices' );
|
55 |
+
|
56 |
+
$dismissed_notices[] = $notice_id;
|
57 |
+
|
58 |
+
$dismissed_notices = array_unique( $dismissed_notices );
|
59 |
+
|
60 |
+
// Remind users every 16 weeks
|
61 |
+
set_transient( 'ss_wc_mailchimp_dismissed_notices', $dismissed_notices, WEEK_IN_SECONDS * 16 );
|
62 |
+
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Should the notice be shown in the admin (Has it been dismissed already)?
|
67 |
+
*
|
68 |
+
* If the passed notice array has a `dismiss` key, the notice is dismissable. If it's dismissable,
|
69 |
+
* we check against other notices that have already been dismissed.
|
70 |
+
*
|
71 |
+
* @see GravityView_Admin::dismiss_notice()
|
72 |
+
* @see GravityView_Admin::add_notice()
|
73 |
+
* @param string $notice Notice array, set using `add_notice()`.
|
74 |
+
* @return boolean True: show notice; False: hide notice
|
75 |
+
*/
|
76 |
+
function _maybe_show_notice( $notice ) {
|
77 |
+
|
78 |
+
// There are no dismissed notices.
|
79 |
+
if( empty( self::$dismissed_notices ) ) {
|
80 |
+
return true;
|
81 |
+
}
|
82 |
+
|
83 |
+
// Has the
|
84 |
+
$is_dismissed = !empty( $notice['dismiss'] ) && in_array( $notice['dismiss'], self::$dismissed_notices );
|
85 |
+
|
86 |
+
return $is_dismissed ? false : true;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get admin notices
|
91 |
+
* @since 1.12
|
92 |
+
* @return array
|
93 |
+
*/
|
94 |
+
public static function get_notices() {
|
95 |
+
return self::$admin_notices;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Handle whether to display notices in Multisite based on plugin activation status
|
100 |
+
*
|
101 |
+
* @since 2.0.13
|
102 |
+
*
|
103 |
+
* @return bool True: show the notices; false: don't show
|
104 |
+
*/
|
105 |
+
private function check_show_multisite_notices() {
|
106 |
+
|
107 |
+
if ( ! is_multisite() ) {
|
108 |
+
return true;
|
109 |
+
}
|
110 |
+
|
111 |
+
// It's network activated but the user can't manage network plugins; they can't do anything about it.
|
112 |
+
if ( SS_WC_MailChimp_Plugin::is_network_activated() && ! is_main_site() ) {
|
113 |
+
return false;
|
114 |
+
}
|
115 |
+
|
116 |
+
// or they don't have admin capabilities
|
117 |
+
if ( ! is_super_admin() ) {
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
+
return true;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Outputs the admin notices generated by the plugin
|
126 |
+
*
|
127 |
+
* @since 2.0.13
|
128 |
+
*
|
129 |
+
* @return void
|
130 |
+
*/
|
131 |
+
public function admin_notice() {
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Modify the notices displayed
|
135 |
+
* @since 2.0.13
|
136 |
+
*/
|
137 |
+
$notices = apply_filters( 'ss_wc_mailchimp/admin/notices', self::$admin_notices );
|
138 |
+
|
139 |
+
if( empty( $notices ) || ! $this->check_show_multisite_notices() ) {
|
140 |
+
return;
|
141 |
+
}
|
142 |
+
|
143 |
+
//don't display a message if use has dismissed the message for this version
|
144 |
+
self::$dismissed_notices = isset( $_GET['show-dismissed-notices'] ) ? array() : (array)get_transient( 'ss_wc_mailchimp_dismissed_notices' );
|
145 |
+
|
146 |
+
foreach( $notices as $notice ) {
|
147 |
+
|
148 |
+
if( false === $this->_maybe_show_notice( $notice ) ) {
|
149 |
+
continue;
|
150 |
+
}
|
151 |
+
|
152 |
+
echo '<div id="message" class="notice '. sswcmc_sanitize_html_class( $notice['class'] ).'">';
|
153 |
+
|
154 |
+
if( !empty( $notice['title'] ) ) {
|
155 |
+
echo '<h3>'.esc_html( $notice['title'] ) .'</h3>';
|
156 |
+
}
|
157 |
+
|
158 |
+
echo wpautop( $notice['message'] );
|
159 |
+
|
160 |
+
if( !empty( $notice['dismiss'] ) ) {
|
161 |
+
|
162 |
+
$dismiss = esc_attr($notice['dismiss']);
|
163 |
+
|
164 |
+
$url = esc_url( add_query_arg( array( 'sswcmc-dismiss' => wp_create_nonce( 'dismiss' ), 'notice' => $dismiss ) ) );
|
165 |
+
|
166 |
+
echo wpautop( '<a href="'.$url.'" data-notice="'.$dismiss.'" class="button-small button button-secondary">'.esc_html__( 'Dismiss', 'woocommerce-mailchimp' ).'</a>' );
|
167 |
+
}
|
168 |
+
|
169 |
+
echo '<div class="clear"></div>';
|
170 |
+
echo '</div>';
|
171 |
+
|
172 |
+
}
|
173 |
+
|
174 |
+
//reset the notices handler
|
175 |
+
self::$admin_notices = array();
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Add a notice to be displayed in the admin.
|
180 |
+
* @param array $notice Array with `class` and `message` keys. The message is not escaped.
|
181 |
+
*/
|
182 |
+
public static function add_notice( $notice = array() ) {
|
183 |
+
|
184 |
+
if( !isset( $notice['message'] ) ) {
|
185 |
+
do_action( 'ss_wc_mailchimp_log_error', 'SSWCMC_Admin[add_notice] Notice not set', $notice );
|
186 |
+
return;
|
187 |
+
}
|
188 |
+
|
189 |
+
$notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class'];
|
190 |
+
|
191 |
+
self::$admin_notices[] = $notice;
|
192 |
+
}
|
193 |
+
}
|
includes/class-ss-wc-mailchimp-api.php
CHANGED
@@ -1,295 +1,295 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Minimal MailChimp API v3.0 wrapper
|
7 |
-
*
|
8 |
-
* @class SS_WC_MailChimp_API
|
9 |
-
* @version 2.0
|
10 |
-
* @package WooCommerce MailChimp
|
11 |
-
* @author Saint Systems
|
12 |
-
*/
|
13 |
-
class SS_WC_MailChimp_API {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @var string
|
17 |
-
*/
|
18 |
-
public $api_key;
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @var string
|
22 |
-
*/
|
23 |
-
public $datacenter = 'us1';
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @var string
|
27 |
-
*/
|
28 |
-
private $api_root = 'https://<dc>.api.mailchimp.com/3.0/';
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var boolean
|
32 |
-
*/
|
33 |
-
private $debug = false;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @var array
|
37 |
-
*/
|
38 |
-
private $last_response;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @var WP_Error
|
42 |
-
*/
|
43 |
-
private $last_error;
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @var WC_Logger
|
47 |
-
*/
|
48 |
-
private $log;
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Create a new instance
|
52 |
-
* @param string $api_key MailChimp API key
|
53 |
-
* @param boolean $debug Whether or not to log API calls
|
54 |
-
*/
|
55 |
-
function __construct( $api_key, $debug = false ) {
|
56 |
-
|
57 |
-
$this->debug = $debug;
|
58 |
-
|
59 |
-
if ( $this->debug === true ) {
|
60 |
-
$this->log = new WC_Logger();
|
61 |
-
}
|
62 |
-
|
63 |
-
$this->api_key = $api_key;
|
64 |
-
$api_key_parts = explode( '-', $this->api_key );
|
65 |
-
$this->datacenter = empty( $api_key_parts[1] ) ? 'us1' : $api_key_parts[1];
|
66 |
-
$this->api_root = str_replace( '<dc>', $this->datacenter, $this->api_root );
|
67 |
-
|
68 |
-
} //end function __construct
|
69 |
-
|
70 |
-
/**
|
71 |
-
* @param string $resource
|
72 |
-
* @param array $args
|
73 |
-
*
|
74 |
-
* @return mixed
|
75 |
-
*/
|
76 |
-
public function get( $resource, $args = array() ) {
|
77 |
-
|
78 |
-
if ( is_array( $args) && ! array_key_exists( 'count', $args ) ) {
|
79 |
-
$args['count'] = 10;
|
80 |
-
}
|
81 |
-
|
82 |
-
return $this->api_request( 'GET', $resource, $args );
|
83 |
-
|
84 |
-
} //end function post
|
85 |
-
|
86 |
-
/**
|
87 |
-
* @param string $resource
|
88 |
-
* @param array $args
|
89 |
-
*
|
90 |
-
* @return mixed
|
91 |
-
*/
|
92 |
-
public function post( $resource, $args = array() ) {
|
93 |
-
|
94 |
-
return $this->api_request( 'POST', $resource, $args );
|
95 |
-
|
96 |
-
} //end function post
|
97 |
-
|
98 |
-
/**
|
99 |
-
* @param string $resource
|
100 |
-
* @param array $args
|
101 |
-
*
|
102 |
-
* @return mixed
|
103 |
-
*/
|
104 |
-
public function put( $resource, $args = array() ) {
|
105 |
-
|
106 |
-
return $this->api_request( 'PUT', $resource, $args );
|
107 |
-
|
108 |
-
} //end function put
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @param string $resource
|
112 |
-
* @param array $args
|
113 |
-
*
|
114 |
-
* @return mixed
|
115 |
-
*/
|
116 |
-
public function patch( $resource, $args = array() ) {
|
117 |
-
|
118 |
-
return $this->api_request( 'PATCH', $resource, $args );
|
119 |
-
|
120 |
-
} //end function patch
|
121 |
-
|
122 |
-
/**
|
123 |
-
* @param string $resource
|
124 |
-
* @param array $args
|
125 |
-
*
|
126 |
-
* @return mixed
|
127 |
-
*/
|
128 |
-
public function delete( $resource, $args = array() ) {
|
129 |
-
|
130 |
-
return $this->api_request( 'DELETE', $resource, $args );
|
131 |
-
|
132 |
-
} //end function delete
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Performs the underlying HTTP request.
|
136 |
-
* @param string $method HTTP method (GET|POST|PUT|PATCH|DELETE)
|
137 |
-
* @param string $resource MailChimp API resource to be called
|
138 |
-
* @param array $args array of parameters to be passed
|
139 |
-
* @return array array of decoded result
|
140 |
-
*/
|
141 |
-
private function api_request( $method, $resource, $args = array() ) {
|
142 |
-
|
143 |
-
$this->reset();
|
144 |
-
|
145 |
-
$url = $this->api_root . $resource;
|
146 |
-
|
147 |
-
global $wp_version;
|
148 |
-
|
149 |
-
$request_args = array(
|
150 |
-
'method' => $method,
|
151 |
-
'sslverify' => false,
|
152 |
-
'timeout' => 60,
|
153 |
-
'redirection' => 5,
|
154 |
-
'httpversion' => '1.1',
|
155 |
-
'headers' => array(
|
156 |
-
'Content-Type' => 'application/json',
|
157 |
-
'Accept' => 'application/json',
|
158 |
-
'Authorization' => 'apikey ' . $this->api_key,
|
159 |
-
'User-Agent' => 'woocommerce-mailchimp/' . SS_WC_MAILCHIMP_VERSION . '; WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
160 |
-
),
|
161 |
-
);
|
162 |
-
|
163 |
-
// attach arguments (in body or URL)
|
164 |
-
if ( $method === 'GET' ) {
|
165 |
-
$url = add_query_arg( $args, $url );
|
166 |
-
} else {
|
167 |
-
$request_args['body'] = json_encode( $args );
|
168 |
-
}
|
169 |
-
|
170 |
-
// print_r($url);
|
171 |
-
// die();
|
172 |
-
|
173 |
-
$raw_response = wp_remote_request( $url, $request_args );
|
174 |
-
|
175 |
-
$this->last_response = $raw_response;
|
176 |
-
|
177 |
-
$this->maybe_log( $url, $method, $args, $raw_response );
|
178 |
-
|
179 |
-
if ( is_wp_error( $raw_response ) ) {
|
180 |
-
|
181 |
-
$this->last_error = new WP_Error( 'ss-wc-mc-api-request-error', $raw_response->get_error_message(), $this->format_error( $resource, $method, $raw_response ) );
|
182 |
-
|
183 |
-
return false;
|
184 |
-
|
185 |
-
} elseif ( is_array( $raw_response )
|
186 |
-
&& $raw_response['response']['code']
|
187 |
-
&& floor( $raw_response['response']['code'] ) / 100 >= 4 ) {
|
188 |
-
|
189 |
-
$json = wp_remote_retrieve_body( $raw_response );
|
190 |
-
|
191 |
-
$error = json_decode( $json, true );
|
192 |
-
|
193 |
-
$this->last_error = new WP_Error( 'ss-wc-mc-api-request-error', $error['detail'], $this->format_error( $resource, $method, $raw_response ) );
|
194 |
-
|
195 |
-
return false;
|
196 |
-
|
197 |
-
} else {
|
198 |
-
|
199 |
-
$json = wp_remote_retrieve_body( $raw_response );
|
200 |
-
|
201 |
-
$result = json_decode( $json, true );
|
202 |
-
|
203 |
-
return $result;
|
204 |
-
|
205 |
-
}
|
206 |
-
|
207 |
-
} //end function api_request
|
208 |
-
|
209 |
-
/**
|
210 |
-
* Empties all data from previous response
|
211 |
-
*/
|
212 |
-
private function reset() {
|
213 |
-
$this->last_response = null;
|
214 |
-
$this->last_error = null;
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Conditionally log MailChimp API Call
|
219 |
-
* @param string $resource MailChimp API Resource
|
220 |
-
* @param string $method HTTP Method
|
221 |
-
* @param array $args HTTP Request Body
|
222 |
-
* @param array $response WP HTTP Response
|
223 |
-
* @return void
|
224 |
-
*/
|
225 |
-
private function maybe_log( $resource, $method, $args, $response ) {
|
226 |
-
|
227 |
-
if ( $this->debug === true ) {
|
228 |
-
$this->log->add( 'woocommerce-mailchimp', "MailChimp API Call RESOURCE: $resource \n METHOD: $method \n BODY: " . print_r( $args, true ) . " \n RESPONSE: " . print_r( $response, true ) );
|
229 |
-
}
|
230 |
-
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Formats api_request info for inclusion in WP_Error $data
|
235 |
-
* @param [type] $resource [description]
|
236 |
-
* @param [type] $method [description]
|
237 |
-
* @param [type] $response [description]
|
238 |
-
* @return [type] [description]
|
239 |
-
*/
|
240 |
-
private function format_error( $resource, $method, $response ) {
|
241 |
-
return array(
|
242 |
-
'resource' => $resource,
|
243 |
-
'method' => $method,
|
244 |
-
'response' => json_encode($response),
|
245 |
-
);
|
246 |
-
}
|
247 |
-
|
248 |
-
/**
|
249 |
-
* has_api_key function.
|
250 |
-
*
|
251 |
-
* @access public
|
252 |
-
* @return void
|
253 |
-
*/
|
254 |
-
public function has_api_key() {
|
255 |
-
|
256 |
-
return !empty( $this->api_key );
|
257 |
-
|
258 |
-
} //end function has_api_key
|
259 |
-
|
260 |
-
/**
|
261 |
-
* @return array|WP_Error
|
262 |
-
*/
|
263 |
-
public function get_last_response() {
|
264 |
-
return $this->last_response;
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Returns error code from error property
|
269 |
-
* @return string error code
|
270 |
-
*/
|
271 |
-
public function get_error_code() {
|
272 |
-
|
273 |
-
$last_error = $this->last_error;
|
274 |
-
if ( is_wp_error( $last_error ) ) {
|
275 |
-
return $last_error->get_error_code();
|
276 |
-
}
|
277 |
-
return null;
|
278 |
-
|
279 |
-
} //end get_error_code
|
280 |
-
|
281 |
-
/**
|
282 |
-
* Returns error message from error property
|
283 |
-
* @return string error message
|
284 |
-
*/
|
285 |
-
public function get_error_message() {
|
286 |
-
|
287 |
-
$last_error = $this->last_error;
|
288 |
-
if ( is_wp_error( $last_error ) ) {
|
289 |
-
return $last_error->get_error_message();
|
290 |
-
}
|
291 |
-
return null;
|
292 |
-
|
293 |
-
} //end get_error_message
|
294 |
-
|
295 |
-
} //end class SS_WC_MailChimp_API
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Minimal MailChimp API v3.0 wrapper
|
7 |
+
*
|
8 |
+
* @class SS_WC_MailChimp_API
|
9 |
+
* @version 2.0
|
10 |
+
* @package WooCommerce MailChimp
|
11 |
+
* @author Saint Systems
|
12 |
+
*/
|
13 |
+
class SS_WC_MailChimp_API {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
public $api_key;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var string
|
22 |
+
*/
|
23 |
+
public $datacenter = 'us1';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
private $api_root = 'https://<dc>.api.mailchimp.com/3.0/';
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var boolean
|
32 |
+
*/
|
33 |
+
private $debug = false;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
private $last_response;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @var WP_Error
|
42 |
+
*/
|
43 |
+
private $last_error;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @var WC_Logger
|
47 |
+
*/
|
48 |
+
private $log;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Create a new instance
|
52 |
+
* @param string $api_key MailChimp API key
|
53 |
+
* @param boolean $debug Whether or not to log API calls
|
54 |
+
*/
|
55 |
+
function __construct( $api_key, $debug = false ) {
|
56 |
+
|
57 |
+
$this->debug = $debug;
|
58 |
+
|
59 |
+
if ( $this->debug === true ) {
|
60 |
+
$this->log = new WC_Logger();
|
61 |
+
}
|
62 |
+
|
63 |
+
$this->api_key = $api_key;
|
64 |
+
$api_key_parts = explode( '-', $this->api_key );
|
65 |
+
$this->datacenter = empty( $api_key_parts[1] ) ? 'us1' : $api_key_parts[1];
|
66 |
+
$this->api_root = str_replace( '<dc>', $this->datacenter, $this->api_root );
|
67 |
+
|
68 |
+
} //end function __construct
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @param string $resource
|
72 |
+
* @param array $args
|
73 |
+
*
|
74 |
+
* @return mixed
|
75 |
+
*/
|
76 |
+
public function get( $resource, $args = array() ) {
|
77 |
+
|
78 |
+
if ( is_array( $args) && ! array_key_exists( 'count', $args ) ) {
|
79 |
+
$args['count'] = 10;
|
80 |
+
}
|
81 |
+
|
82 |
+
return $this->api_request( 'GET', $resource, $args );
|
83 |
+
|
84 |
+
} //end function post
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @param string $resource
|
88 |
+
* @param array $args
|
89 |
+
*
|
90 |
+
* @return mixed
|
91 |
+
*/
|
92 |
+
public function post( $resource, $args = array() ) {
|
93 |
+
|
94 |
+
return $this->api_request( 'POST', $resource, $args );
|
95 |
+
|
96 |
+
} //end function post
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @param string $resource
|
100 |
+
* @param array $args
|
101 |
+
*
|
102 |
+
* @return mixed
|
103 |
+
*/
|
104 |
+
public function put( $resource, $args = array() ) {
|
105 |
+
|
106 |
+
return $this->api_request( 'PUT', $resource, $args );
|
107 |
+
|
108 |
+
} //end function put
|
109 |
+
|
110 |
+
/**
|
111 |
+
* @param string $resource
|
112 |
+
* @param array $args
|
113 |
+
*
|
114 |
+
* @return mixed
|
115 |
+
*/
|
116 |
+
public function patch( $resource, $args = array() ) {
|
117 |
+
|
118 |
+
return $this->api_request( 'PATCH', $resource, $args );
|
119 |
+
|
120 |
+
} //end function patch
|
121 |
+
|
122 |
+
/**
|
123 |
+
* @param string $resource
|
124 |
+
* @param array $args
|
125 |
+
*
|
126 |
+
* @return mixed
|
127 |
+
*/
|
128 |
+
public function delete( $resource, $args = array() ) {
|
129 |
+
|
130 |
+
return $this->api_request( 'DELETE', $resource, $args );
|
131 |
+
|
132 |
+
} //end function delete
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Performs the underlying HTTP request.
|
136 |
+
* @param string $method HTTP method (GET|POST|PUT|PATCH|DELETE)
|
137 |
+
* @param string $resource MailChimp API resource to be called
|
138 |
+
* @param array $args array of parameters to be passed
|
139 |
+
* @return array array of decoded result
|
140 |
+
*/
|
141 |
+
private function api_request( $method, $resource, $args = array() ) {
|
142 |
+
|
143 |
+
$this->reset();
|
144 |
+
|
145 |
+
$url = $this->api_root . $resource;
|
146 |
+
|
147 |
+
global $wp_version;
|
148 |
+
|
149 |
+
$request_args = array(
|
150 |
+
'method' => $method,
|
151 |
+
'sslverify' => false,
|
152 |
+
'timeout' => 60,
|
153 |
+
'redirection' => 5,
|
154 |
+
'httpversion' => '1.1',
|
155 |
+
'headers' => array(
|
156 |
+
'Content-Type' => 'application/json',
|
157 |
+
'Accept' => 'application/json',
|
158 |
+
'Authorization' => 'apikey ' . $this->api_key,
|
159 |
+
'User-Agent' => 'woocommerce-mailchimp/' . SS_WC_MAILCHIMP_VERSION . '; WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ),
|
160 |
+
),
|
161 |
+
);
|
162 |
+
|
163 |
+
// attach arguments (in body or URL)
|
164 |
+
if ( $method === 'GET' ) {
|
165 |
+
$url = add_query_arg( $args, $url );
|
166 |
+
} else {
|
167 |
+
$request_args['body'] = json_encode( $args );
|
168 |
+
}
|
169 |
+
|
170 |
+
// print_r($url);
|
171 |
+
// die();
|
172 |
+
|
173 |
+
$raw_response = wp_remote_request( $url, $request_args );
|
174 |
+
|
175 |
+
$this->last_response = $raw_response;
|
176 |
+
|
177 |
+
$this->maybe_log( $url, $method, $args, $raw_response );
|
178 |
+
|
179 |
+
if ( is_wp_error( $raw_response ) ) {
|
180 |
+
|
181 |
+
$this->last_error = new WP_Error( 'ss-wc-mc-api-request-error', $raw_response->get_error_message(), $this->format_error( $resource, $method, $raw_response ) );
|
182 |
+
|
183 |
+
return false;
|
184 |
+
|
185 |
+
} elseif ( is_array( $raw_response )
|
186 |
+
&& $raw_response['response']['code']
|
187 |
+
&& floor( $raw_response['response']['code'] ) / 100 >= 4 ) {
|
188 |
+
|
189 |
+
$json = wp_remote_retrieve_body( $raw_response );
|
190 |
+
|
191 |
+
$error = json_decode( $json, true );
|
192 |
+
|
193 |
+
$this->last_error = new WP_Error( 'ss-wc-mc-api-request-error', $error['detail'], $this->format_error( $resource, $method, $raw_response ) );
|
194 |
+
|
195 |
+
return false;
|
196 |
+
|
197 |
+
} else {
|
198 |
+
|
199 |
+
$json = wp_remote_retrieve_body( $raw_response );
|
200 |
+
|
201 |
+
$result = json_decode( $json, true );
|
202 |
+
|
203 |
+
return $result;
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
} //end function api_request
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Empties all data from previous response
|
211 |
+
*/
|
212 |
+
private function reset() {
|
213 |
+
$this->last_response = null;
|
214 |
+
$this->last_error = null;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Conditionally log MailChimp API Call
|
219 |
+
* @param string $resource MailChimp API Resource
|
220 |
+
* @param string $method HTTP Method
|
221 |
+
* @param array $args HTTP Request Body
|
222 |
+
* @param array $response WP HTTP Response
|
223 |
+
* @return void
|
224 |
+
*/
|
225 |
+
private function maybe_log( $resource, $method, $args, $response ) {
|
226 |
+
|
227 |
+
if ( $this->debug === true ) {
|
228 |
+
$this->log->add( 'woocommerce-mailchimp', "MailChimp API Call RESOURCE: $resource \n METHOD: $method \n BODY: " . print_r( $args, true ) . " \n RESPONSE: " . print_r( $response, true ) );
|
229 |
+
}
|
230 |
+
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Formats api_request info for inclusion in WP_Error $data
|
235 |
+
* @param [type] $resource [description]
|
236 |
+
* @param [type] $method [description]
|
237 |
+
* @param [type] $response [description]
|
238 |
+
* @return [type] [description]
|
239 |
+
*/
|
240 |
+
private function format_error( $resource, $method, $response ) {
|
241 |
+
return array(
|
242 |
+
'resource' => $resource,
|
243 |
+
'method' => $method,
|
244 |
+
'response' => json_encode($response),
|
245 |
+
);
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* has_api_key function.
|
250 |
+
*
|
251 |
+
* @access public
|
252 |
+
* @return void
|
253 |
+
*/
|
254 |
+
public function has_api_key() {
|
255 |
+
|
256 |
+
return !empty( $this->api_key );
|
257 |
+
|
258 |
+
} //end function has_api_key
|
259 |
+
|
260 |
+
/**
|
261 |
+
* @return array|WP_Error
|
262 |
+
*/
|
263 |
+
public function get_last_response() {
|
264 |
+
return $this->last_response;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Returns error code from error property
|
269 |
+
* @return string error code
|
270 |
+
*/
|
271 |
+
public function get_error_code() {
|
272 |
+
|
273 |
+
$last_error = $this->last_error;
|
274 |
+
if ( is_wp_error( $last_error ) ) {
|
275 |
+
return $last_error->get_error_code();
|
276 |
+
}
|
277 |
+
return null;
|
278 |
+
|
279 |
+
} //end get_error_code
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Returns error message from error property
|
283 |
+
* @return string error message
|
284 |
+
*/
|
285 |
+
public function get_error_message() {
|
286 |
+
|
287 |
+
$last_error = $this->last_error;
|
288 |
+
if ( is_wp_error( $last_error ) ) {
|
289 |
+
return $last_error->get_error_message();
|
290 |
+
}
|
291 |
+
return null;
|
292 |
+
|
293 |
+
} //end get_error_message
|
294 |
+
|
295 |
+
} //end class SS_WC_MailChimp_API
|
includes/class-ss-wc-mailchimp-compatibility.php
CHANGED
@@ -1,297 +1,297 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Handle issues with plugin and version compatibility
|
4 |
-
*
|
5 |
-
* @package WooCommerce MailChimp
|
6 |
-
* @author Saint Systems, LLC
|
7 |
-
* @link http://www.saintsystems.com
|
8 |
-
* @copyright Copyright 2016, Saint Systems, LLC
|
9 |
-
*
|
10 |
-
* @since 2.0.13
|
11 |
-
*/
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Handle WooCommerce MailChimp compatibility notices and fallback shortcodes
|
15 |
-
* @since 2.0.13
|
16 |
-
*/
|
17 |
-
final class SS_WC_MailChimp_Compatibility {
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Plugin singleton instance
|
21 |
-
* @var SS_WC_MailChimp_Compatibility
|
22 |
-
*/
|
23 |
-
private static $instance = null;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* @var bool Is WooCommerce version valid and is WooCommerce loaded?
|
27 |
-
*/
|
28 |
-
public static $valid_woocommerce = false;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @var bool Is the WordPress installation compatible?
|
32 |
-
*/
|
33 |
-
public static $valid_wordpress = false;
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @var bool Is the server's PHP version compatible?
|
37 |
-
*/
|
38 |
-
public static $valid_php = false;
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @var array Holder for notices to be displayed in frontend shortcodes if not valid
|
42 |
-
*/
|
43 |
-
static private $notices = array();
|
44 |
-
|
45 |
-
function __construct() {
|
46 |
-
|
47 |
-
self::$valid_woocommerce = self::check_woocommerce();
|
48 |
-
|
49 |
-
self::$valid_wordpress = self::check_wordpress();
|
50 |
-
|
51 |
-
self::$valid_php = self::check_php();
|
52 |
-
|
53 |
-
$this->add_hooks();
|
54 |
-
}
|
55 |
-
|
56 |
-
function add_hooks() {
|
57 |
-
|
58 |
-
add_filter( 'ss_wc_mailchimp/admin/notices', array( $this, 'insert_admin_notices' ) );
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Add the compatibility notices to the other admin notices
|
64 |
-
* @param array $notices
|
65 |
-
*
|
66 |
-
* @return array
|
67 |
-
*/
|
68 |
-
function insert_admin_notices( $notices = array() ) {
|
69 |
-
|
70 |
-
return array_merge( $notices, self::$notices );
|
71 |
-
|
72 |
-
} //end function insert_admin_notices
|
73 |
-
|
74 |
-
/**
|
75 |
-
* @return SS_WC_MailChimp_Compatibility
|
76 |
-
*/
|
77 |
-
public static function get_instance() {
|
78 |
-
|
79 |
-
if ( empty( self::$instance ) ) {
|
80 |
-
self::$instance = new self;
|
81 |
-
}
|
82 |
-
|
83 |
-
return self::$instance;
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Is everything compatible with this version of the plugin?
|
89 |
-
* @return bool
|
90 |
-
*/
|
91 |
-
public static function is_valid() {
|
92 |
-
|
93 |
-
return ( self::is_valid_woocommerce()
|
94 |
-
&& self::is_valid_wordpress()
|
95 |
-
&& self::is_valid_php()
|
96 |
-
);
|
97 |
-
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Is the version of WordPress compatible?
|
102 |
-
* @since 2.0.13
|
103 |
-
*/
|
104 |
-
static function is_valid_wordpress() {
|
105 |
-
return self::$valid_wordpress;
|
106 |
-
}
|
107 |
-
|
108 |
-
/**
|
109 |
-
* @since 2.0.13
|
110 |
-
* @return bool
|
111 |
-
*/
|
112 |
-
static function is_valid_woocommerce() {
|
113 |
-
return self::$valid_woocommerce;
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* @since 2.0.13
|
118 |
-
* @return bool
|
119 |
-
*/
|
120 |
-
static function is_valid_php() {
|
121 |
-
return self::$valid_php;
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Get admin notices
|
126 |
-
* @since 2.0.13
|
127 |
-
* @return array
|
128 |
-
*/
|
129 |
-
public static function get_notices() {
|
130 |
-
return self::$notices;
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Is the version of PHP compatible?
|
135 |
-
*
|
136 |
-
* @since 2.0.13
|
137 |
-
* @return boolean
|
138 |
-
*/
|
139 |
-
public static function check_php() {
|
140 |
-
if ( false === version_compare( phpversion(), SS_WC_MAILCHIMP_MIN_PHP_VERSION , '>=' ) ) {
|
141 |
-
|
142 |
-
self::$notices['php_version'] = array(
|
143 |
-
'class' => 'notice-error',
|
144 |
-
'message' => sprintf( __( "%sWooCommerce MailChimp requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'woocommerce-mailchimp' ), '<h3>', SS_WC_MAILCHIMP_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' )
|
145 |
-
);
|
146 |
-
|
147 |
-
return false;
|
148 |
-
}
|
149 |
-
|
150 |
-
return true;
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Is WordPress compatible?
|
155 |
-
*
|
156 |
-
* @since 2.0.13
|
157 |
-
* @return boolean
|
158 |
-
*/
|
159 |
-
public static function check_wordpress() {
|
160 |
-
global $wp_version;
|
161 |
-
|
162 |
-
if ( version_compare( $wp_version, SS_WC_MAILCHIMP_MIN_WP_VERSION ) <= 0 ) {
|
163 |
-
|
164 |
-
self::$notices['wp_version'] = array(
|
165 |
-
'class' => 'notice-error',
|
166 |
-
'message' => sprintf( __( "%sWooCommerce MailChimp requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'woocommerce-mailchimp' ), '<h3>', SS_WC_MAILCHIMP_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' )
|
167 |
-
);
|
168 |
-
|
169 |
-
return false;
|
170 |
-
}
|
171 |
-
|
172 |
-
return true;
|
173 |
-
|
174 |
-
} //end public static function check_wordpress()
|
175 |
-
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Check if WooCommerce plugin is active and show notice if not.
|
179 |
-
*
|
180 |
-
* @since 2.0.13
|
181 |
-
*
|
182 |
-
* @access public
|
183 |
-
* @return boolean True: checks have been passed; WooCommerce MailChimp is fine to run; False: checks have failed, don't continue loading
|
184 |
-
*/
|
185 |
-
public static function check_woocommerce() {
|
186 |
-
|
187 |
-
$woocommerce_is_active = false;
|
188 |
-
|
189 |
-
// Bypass other checks: if the class exists
|
190 |
-
if ( class_exists( 'WooCommerce' ) ) {
|
191 |
-
|
192 |
-
$woocommerce_is_active = true;
|
193 |
-
$woocommerce_version = WC()->version;
|
194 |
-
|
195 |
-
} else {
|
196 |
-
|
197 |
-
if ( $wc_status = self::get_plugin_status( 'woocommerce/woocommerce.php' ) ) {
|
198 |
-
if ( true === $wc_status ) {
|
199 |
-
$woocommerce_is_active = true;
|
200 |
-
}
|
201 |
-
$wc_data = get_plugin_data( WP_CONTENT_DIR . '/plugins/woocommerce/woocommerce.php' );
|
202 |
-
$woocommerce_version = $wc_data['Version'];
|
203 |
-
}
|
204 |
-
|
205 |
-
}
|
206 |
-
|
207 |
-
if ( true === $woocommerce_is_active ) {
|
208 |
-
// and the version's right, we're good.
|
209 |
-
if ( true === version_compare( $woocommerce_version, SS_WC_MAILCHIMP_MIN_WC_VERSION, ">=" ) ) {
|
210 |
-
return true;
|
211 |
-
}
|
212 |
-
|
213 |
-
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'update.php?action=upgrade-plugin&plugin=woocommerce/woocommerce.php' ), 'upgrade-plugin_woocommerce/woocommerce.php') . '" class="button button-large">';
|
214 |
-
|
215 |
-
// Or the version's wrong
|
216 |
-
self::$notices['wc_version'] = array(
|
217 |
-
'class' => 'notice-error',
|
218 |
-
'message' => sprintf( __( "%sWooCommerce MailChimp requires WooCommerce Version %s or newer.%s You're using Version %s. %sUpdate WooCommerce%s to use the WooCommerce MailChimp plugin.", 'woocommerce-mailchimp' ), '<h3>', SS_WC_MAILCHIMP_MIN_WC_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$woocommerce_version.'</span>', $button, '</strong></a>' )
|
219 |
-
);
|
220 |
-
|
221 |
-
return false;
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* The plugin is activated and yet somehow WooCommerce didn't get picked up...
|
226 |
-
* OR
|
227 |
-
* It's the Network Admin and we just don't know whether the sites have WooCommerce activated themselves.
|
228 |
-
*/
|
229 |
-
if ( $woocommerce_is_active || is_network_admin() ) {
|
230 |
-
return true;
|
231 |
-
}
|
232 |
-
|
233 |
-
// If WooCommerce doesn't exist, assume WooCommerce not active
|
234 |
-
$return = false;
|
235 |
-
|
236 |
-
// Required for multisite
|
237 |
-
if ( ! function_exists('wp_create_nonce') ) {
|
238 |
-
require_once ABSPATH . WPINC . '/pluggable.php';
|
239 |
-
}
|
240 |
-
|
241 |
-
// Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE"
|
242 |
-
if ( is_multisite() ) {
|
243 |
-
wp_cookie_constants();
|
244 |
-
}
|
245 |
-
|
246 |
-
switch ( $wc_status ) {
|
247 |
-
case 'inactive':
|
248 |
-
$return = false;
|
249 |
-
|
250 |
-
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=woocommerce/woocommerce.php' ), 'activate-plugin_woocommerce/woocommerce.php') . '" class="button button-large">';
|
251 |
-
|
252 |
-
self::$notices['wc_inactive'] = array( 'class' => 'error', 'message' => sprintf( __( '%sWooCommerce MailChimp requires WooCommerce to be active. %sActivate WooCommerce%s to use the WooCommerce MailChimp plugin.', 'woocommerce-mailchimp' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ) );
|
253 |
-
break;
|
254 |
-
default:
|
255 |
-
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ) . '" class="button button-large">';
|
256 |
-
|
257 |
-
self::$notices['wc_installed'] = array( 'class' => 'error', 'message' => sprintf( __( '%sWooCommerce MailChimp requires WooCommerce to be installed in order to run properly. %sInstall WooCommerce%s to use the WooCommerce MailChimp plugin.', 'woocommerce-mailchimp' ), '<h3>', "</h3>\n\n". $button, '</a></strong>') );
|
258 |
-
break;
|
259 |
-
}
|
260 |
-
|
261 |
-
return $return;
|
262 |
-
|
263 |
-
} //end public static function check_woocommerce()
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Check if specified plugin is active, inactive or not installed
|
267 |
-
*
|
268 |
-
* @access public
|
269 |
-
* @static
|
270 |
-
* @param string $location (default: '')
|
271 |
-
* @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive
|
272 |
-
*/
|
273 |
-
public static function get_plugin_status( $location = '' ) {
|
274 |
-
|
275 |
-
if ( ! function_exists('is_plugin_active') ) {
|
276 |
-
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
277 |
-
}
|
278 |
-
|
279 |
-
if ( is_network_admin() && is_plugin_active_for_network( $location ) ) {
|
280 |
-
return true;
|
281 |
-
}
|
282 |
-
|
283 |
-
if ( !is_network_admin() && is_plugin_active( $location ) ) {
|
284 |
-
return true;
|
285 |
-
}
|
286 |
-
|
287 |
-
if (
|
288 |
-
!file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
|
289 |
-
!file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
|
290 |
-
) {
|
291 |
-
return false;
|
292 |
-
}
|
293 |
-
|
294 |
-
return 'inactive';
|
295 |
-
}
|
296 |
-
|
297 |
-
} //SS_WC_MailChimp_Compatibility
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Handle issues with plugin and version compatibility
|
4 |
+
*
|
5 |
+
* @package WooCommerce MailChimp
|
6 |
+
* @author Saint Systems, LLC
|
7 |
+
* @link http://www.saintsystems.com
|
8 |
+
* @copyright Copyright 2016, Saint Systems, LLC
|
9 |
+
*
|
10 |
+
* @since 2.0.13
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Handle WooCommerce MailChimp compatibility notices and fallback shortcodes
|
15 |
+
* @since 2.0.13
|
16 |
+
*/
|
17 |
+
final class SS_WC_MailChimp_Compatibility {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Plugin singleton instance
|
21 |
+
* @var SS_WC_MailChimp_Compatibility
|
22 |
+
*/
|
23 |
+
private static $instance = null;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var bool Is WooCommerce version valid and is WooCommerce loaded?
|
27 |
+
*/
|
28 |
+
public static $valid_woocommerce = false;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var bool Is the WordPress installation compatible?
|
32 |
+
*/
|
33 |
+
public static $valid_wordpress = false;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @var bool Is the server's PHP version compatible?
|
37 |
+
*/
|
38 |
+
public static $valid_php = false;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @var array Holder for notices to be displayed in frontend shortcodes if not valid
|
42 |
+
*/
|
43 |
+
static private $notices = array();
|
44 |
+
|
45 |
+
function __construct() {
|
46 |
+
|
47 |
+
self::$valid_woocommerce = self::check_woocommerce();
|
48 |
+
|
49 |
+
self::$valid_wordpress = self::check_wordpress();
|
50 |
+
|
51 |
+
self::$valid_php = self::check_php();
|
52 |
+
|
53 |
+
$this->add_hooks();
|
54 |
+
}
|
55 |
+
|
56 |
+
function add_hooks() {
|
57 |
+
|
58 |
+
add_filter( 'ss_wc_mailchimp/admin/notices', array( $this, 'insert_admin_notices' ) );
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Add the compatibility notices to the other admin notices
|
64 |
+
* @param array $notices
|
65 |
+
*
|
66 |
+
* @return array
|
67 |
+
*/
|
68 |
+
function insert_admin_notices( $notices = array() ) {
|
69 |
+
|
70 |
+
return array_merge( $notices, self::$notices );
|
71 |
+
|
72 |
+
} //end function insert_admin_notices
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @return SS_WC_MailChimp_Compatibility
|
76 |
+
*/
|
77 |
+
public static function get_instance() {
|
78 |
+
|
79 |
+
if ( empty( self::$instance ) ) {
|
80 |
+
self::$instance = new self;
|
81 |
+
}
|
82 |
+
|
83 |
+
return self::$instance;
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Is everything compatible with this version of the plugin?
|
89 |
+
* @return bool
|
90 |
+
*/
|
91 |
+
public static function is_valid() {
|
92 |
+
|
93 |
+
return ( self::is_valid_woocommerce()
|
94 |
+
&& self::is_valid_wordpress()
|
95 |
+
&& self::is_valid_php()
|
96 |
+
);
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Is the version of WordPress compatible?
|
102 |
+
* @since 2.0.13
|
103 |
+
*/
|
104 |
+
static function is_valid_wordpress() {
|
105 |
+
return self::$valid_wordpress;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @since 2.0.13
|
110 |
+
* @return bool
|
111 |
+
*/
|
112 |
+
static function is_valid_woocommerce() {
|
113 |
+
return self::$valid_woocommerce;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* @since 2.0.13
|
118 |
+
* @return bool
|
119 |
+
*/
|
120 |
+
static function is_valid_php() {
|
121 |
+
return self::$valid_php;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Get admin notices
|
126 |
+
* @since 2.0.13
|
127 |
+
* @return array
|
128 |
+
*/
|
129 |
+
public static function get_notices() {
|
130 |
+
return self::$notices;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Is the version of PHP compatible?
|
135 |
+
*
|
136 |
+
* @since 2.0.13
|
137 |
+
* @return boolean
|
138 |
+
*/
|
139 |
+
public static function check_php() {
|
140 |
+
if ( false === version_compare( phpversion(), SS_WC_MAILCHIMP_MIN_PHP_VERSION , '>=' ) ) {
|
141 |
+
|
142 |
+
self::$notices['php_version'] = array(
|
143 |
+
'class' => 'notice-error',
|
144 |
+
'message' => sprintf( __( "%sWooCommerce MailChimp requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'woocommerce-mailchimp' ), '<h3>', SS_WC_MAILCHIMP_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' )
|
145 |
+
);
|
146 |
+
|
147 |
+
return false;
|
148 |
+
}
|
149 |
+
|
150 |
+
return true;
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Is WordPress compatible?
|
155 |
+
*
|
156 |
+
* @since 2.0.13
|
157 |
+
* @return boolean
|
158 |
+
*/
|
159 |
+
public static function check_wordpress() {
|
160 |
+
global $wp_version;
|
161 |
+
|
162 |
+
if ( version_compare( $wp_version, SS_WC_MAILCHIMP_MIN_WP_VERSION ) <= 0 ) {
|
163 |
+
|
164 |
+
self::$notices['wp_version'] = array(
|
165 |
+
'class' => 'notice-error',
|
166 |
+
'message' => sprintf( __( "%sWooCommerce MailChimp requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'woocommerce-mailchimp' ), '<h3>', SS_WC_MAILCHIMP_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' )
|
167 |
+
);
|
168 |
+
|
169 |
+
return false;
|
170 |
+
}
|
171 |
+
|
172 |
+
return true;
|
173 |
+
|
174 |
+
} //end public static function check_wordpress()
|
175 |
+
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Check if WooCommerce plugin is active and show notice if not.
|
179 |
+
*
|
180 |
+
* @since 2.0.13
|
181 |
+
*
|
182 |
+
* @access public
|
183 |
+
* @return boolean True: checks have been passed; WooCommerce MailChimp is fine to run; False: checks have failed, don't continue loading
|
184 |
+
*/
|
185 |
+
public static function check_woocommerce() {
|
186 |
+
|
187 |
+
$woocommerce_is_active = false;
|
188 |
+
|
189 |
+
// Bypass other checks: if the class exists
|
190 |
+
if ( class_exists( 'WooCommerce' ) ) {
|
191 |
+
|
192 |
+
$woocommerce_is_active = true;
|
193 |
+
$woocommerce_version = WC()->version;
|
194 |
+
|
195 |
+
} else {
|
196 |
+
|
197 |
+
if ( $wc_status = self::get_plugin_status( 'woocommerce/woocommerce.php' ) ) {
|
198 |
+
if ( true === $wc_status ) {
|
199 |
+
$woocommerce_is_active = true;
|
200 |
+
}
|
201 |
+
$wc_data = get_plugin_data( WP_CONTENT_DIR . '/plugins/woocommerce/woocommerce.php' );
|
202 |
+
$woocommerce_version = $wc_data['Version'];
|
203 |
+
}
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
if ( true === $woocommerce_is_active ) {
|
208 |
+
// and the version's right, we're good.
|
209 |
+
if ( true === version_compare( $woocommerce_version, SS_WC_MAILCHIMP_MIN_WC_VERSION, ">=" ) ) {
|
210 |
+
return true;
|
211 |
+
}
|
212 |
+
|
213 |
+
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'update.php?action=upgrade-plugin&plugin=woocommerce/woocommerce.php' ), 'upgrade-plugin_woocommerce/woocommerce.php') . '" class="button button-large">';
|
214 |
+
|
215 |
+
// Or the version's wrong
|
216 |
+
self::$notices['wc_version'] = array(
|
217 |
+
'class' => 'notice-error',
|
218 |
+
'message' => sprintf( __( "%sWooCommerce MailChimp requires WooCommerce Version %s or newer.%s You're using Version %s. %sUpdate WooCommerce%s to use the WooCommerce MailChimp plugin.", 'woocommerce-mailchimp' ), '<h3>', SS_WC_MAILCHIMP_MIN_WC_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$woocommerce_version.'</span>', $button, '</strong></a>' )
|
219 |
+
);
|
220 |
+
|
221 |
+
return false;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* The plugin is activated and yet somehow WooCommerce didn't get picked up...
|
226 |
+
* OR
|
227 |
+
* It's the Network Admin and we just don't know whether the sites have WooCommerce activated themselves.
|
228 |
+
*/
|
229 |
+
if ( $woocommerce_is_active || is_network_admin() ) {
|
230 |
+
return true;
|
231 |
+
}
|
232 |
+
|
233 |
+
// If WooCommerce doesn't exist, assume WooCommerce not active
|
234 |
+
$return = false;
|
235 |
+
|
236 |
+
// Required for multisite
|
237 |
+
if ( ! function_exists('wp_create_nonce') ) {
|
238 |
+
require_once ABSPATH . WPINC . '/pluggable.php';
|
239 |
+
}
|
240 |
+
|
241 |
+
// Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE"
|
242 |
+
if ( is_multisite() ) {
|
243 |
+
wp_cookie_constants();
|
244 |
+
}
|
245 |
+
|
246 |
+
switch ( $wc_status ) {
|
247 |
+
case 'inactive':
|
248 |
+
$return = false;
|
249 |
+
|
250 |
+
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=woocommerce/woocommerce.php' ), 'activate-plugin_woocommerce/woocommerce.php') . '" class="button button-large">';
|
251 |
+
|
252 |
+
self::$notices['wc_inactive'] = array( 'class' => 'error', 'message' => sprintf( __( '%sWooCommerce MailChimp requires WooCommerce to be active. %sActivate WooCommerce%s to use the WooCommerce MailChimp plugin.', 'woocommerce-mailchimp' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ) );
|
253 |
+
break;
|
254 |
+
default:
|
255 |
+
$button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#woocommerce">' : '<strong><a href="'. wp_nonce_url( admin_url( 'update.php?action=install-plugin&plugin=woocommerce' ), 'install-plugin_woocommerce' ) . '" class="button button-large">';
|
256 |
+
|
257 |
+
self::$notices['wc_installed'] = array( 'class' => 'error', 'message' => sprintf( __( '%sWooCommerce MailChimp requires WooCommerce to be installed in order to run properly. %sInstall WooCommerce%s to use the WooCommerce MailChimp plugin.', 'woocommerce-mailchimp' ), '<h3>', "</h3>\n\n". $button, '</a></strong>') );
|
258 |
+
break;
|
259 |
+
}
|
260 |
+
|
261 |
+
return $return;
|
262 |
+
|
263 |
+
} //end public static function check_woocommerce()
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Check if specified plugin is active, inactive or not installed
|
267 |
+
*
|
268 |
+
* @access public
|
269 |
+
* @static
|
270 |
+
* @param string $location (default: '')
|
271 |
+
* @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive
|
272 |
+
*/
|
273 |
+
public static function get_plugin_status( $location = '' ) {
|
274 |
+
|
275 |
+
if ( ! function_exists('is_plugin_active') ) {
|
276 |
+
include_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
277 |
+
}
|
278 |
+
|
279 |
+
if ( is_network_admin() && is_plugin_active_for_network( $location ) ) {
|
280 |
+
return true;
|
281 |
+
}
|
282 |
+
|
283 |
+
if ( !is_network_admin() && is_plugin_active( $location ) ) {
|
284 |
+
return true;
|
285 |
+
}
|
286 |
+
|
287 |
+
if (
|
288 |
+
!file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) &&
|
289 |
+
!file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location )
|
290 |
+
) {
|
291 |
+
return false;
|
292 |
+
}
|
293 |
+
|
294 |
+
return 'inactive';
|
295 |
+
}
|
296 |
+
|
297 |
+
} //SS_WC_MailChimp_Compatibility
|
includes/class-ss-wc-mailchimp-handler.php
CHANGED
@@ -1,471 +1,471 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce MailChimp Handler
|
4 |
-
*
|
5 |
-
* @author Saint Systems
|
6 |
-
* @package WooCommerce MailChimp
|
7 |
-
* @version 2.0
|
8 |
-
*/
|
9 |
-
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
11 |
-
|
12 |
-
if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @class SS_WC_MailChimp_Handler
|
16 |
-
*/
|
17 |
-
final class SS_WC_MailChimp_Handler {
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Plugin singleton instance
|
21 |
-
* @var SS_WC_MailChimp_Handler
|
22 |
-
*/
|
23 |
-
private static $instance = null;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Constructor
|
27 |
-
*
|
28 |
-
* @access public
|
29 |
-
* @return void
|
30 |
-
*/
|
31 |
-
public function __construct() {
|
32 |
-
|
33 |
-
$this->id = 'mailchimp';
|
34 |
-
$this->namespace = 'ss_wc_' . $this->id;
|
35 |
-
$this->label = __( 'MailChimp', 'woocommerce-mailchimp' );
|
36 |
-
$this->sswcmc = SSWCMC();
|
37 |
-
$this->register_hooks();
|
38 |
-
|
39 |
-
} //end function __construct
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @return SS_WC_MailChimp_Handler
|
43 |
-
*/
|
44 |
-
public static function get_instance() {
|
45 |
-
|
46 |
-
if ( empty( self::$instance ) ) {
|
47 |
-
self::$instance = new self;
|
48 |
-
}
|
49 |
-
|
50 |
-
return self::$instance;
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* order_status_changed function.
|
56 |
-
*
|
57 |
-
* @access public
|
58 |
-
* @return void
|
59 |
-
*/
|
60 |
-
public function order_status_changed( $id, $status = 'new', $new_status = 'pending' ) {
|
61 |
-
if ( $this->sswcmc->is_valid() && $new_status === $this->sswcmc->occurs() ) {
|
62 |
-
// Get WC order
|
63 |
-
$order = $this->wc_get_order( $id );
|
64 |
-
|
65 |
-
// get the ss_wc_mailchimp_opt_in value from the post meta. "order_custom_fields" was removed with WooCommerce 2.1
|
66 |
-
$subscribe_customer = get_post_meta( $id, $this->namespace_prefixed( 'opt_in' ), true );
|
67 |
-
|
68 |
-
$order_id = method_exists($order, 'get_id') ? $order->get_id(): $order->id;
|
69 |
-
$order_billing_email = method_exists($order, 'get_billing_email') ? $order->get_billing_email(): $order->billing_email;
|
70 |
-
$order_billing_first_name = method_exists($order, 'get_billing_first_name') ? $order->get_billing_first_name(): $order->billing_first_name;
|
71 |
-
$order_billing_last_name = method_exists($order, 'get_billing_last_name') ? $order->get_billing_last_name(): $order->billing_last_name;
|
72 |
-
|
73 |
-
// If the 'ss_wc_mailchimp_opt_in' meta value isn't set
|
74 |
-
// (because 'display_opt_in' wasn't enabled at the time the order was placed)
|
75 |
-
// or the 'ss_wc_mailchimp_opt_in' is yes, subscriber the customer
|
76 |
-
if ( ! $subscribe_customer || empty( $subscribe_customer ) || 'yes' === $subscribe_customer ) {
|
77 |
-
// log
|
78 |
-
$this->log( sprintf( __( __METHOD__ . '(): Subscribing customer (%s) to list %s', 'woocommerce-mailchimp' ), $order_billing_email , $this->sswcmc->get_list() ) );
|
79 |
-
|
80 |
-
// subscribe
|
81 |
-
$this->subscribe( $order_id, $order_billing_first_name, $order_billing_last_name, $order_billing_email , $this->sswcmc->get_list() );
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Register plugin hooks
|
88 |
-
*
|
89 |
-
* @access public
|
90 |
-
* @return void
|
91 |
-
*/
|
92 |
-
public function register_hooks() {
|
93 |
-
|
94 |
-
// We would use the 'woocommerce_new_order' action but first name, last name and email address (order meta) is not yet available,
|
95 |
-
// so instead we use the 'woocommerce_checkout_update_order_meta' action hook which fires after the checkout process on the "thank you" page
|
96 |
-
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'order_status_changed' ), 1000, 1 );
|
97 |
-
|
98 |
-
// hook into woocommerce order status changed hook to handle the desired subscription event trigger
|
99 |
-
add_action( 'woocommerce_order_status_changed', array( $this, 'order_status_changed' ), 10, 3 );
|
100 |
-
|
101 |
-
$opt_in_checkbox_display_location = $this->sswcmc->opt_in_checkbox_display_location();
|
102 |
-
|
103 |
-
// Maybe add an "opt-in" field to the checkout
|
104 |
-
$opt_in_checkbox_display_location = !empty( $opt_in_checkbox_display_location ) ? $opt_in_checkbox_display_location : 'woocommerce_review_order_before_submit';
|
105 |
-
|
106 |
-
// Old opt-in checkbox display locations
|
107 |
-
$old_opt_in_checkbox_display_locations = array(
|
108 |
-
'billing' => 'woocommerce_after_checkout_billing_form',
|
109 |
-
'order' => 'woocommerce_review_order_before_submit',
|
110 |
-
);
|
111 |
-
|
112 |
-
// Map old billing/order checkbox display locations to new format
|
113 |
-
if ( array_key_exists( $opt_in_checkbox_display_location, $old_opt_in_checkbox_display_locations ) ) {
|
114 |
-
$opt_in_checkbox_display_location = $old_opt_in_checkbox_display_locations[ $opt_in_checkbox_display_location ];
|
115 |
-
}
|
116 |
-
|
117 |
-
add_action( $opt_in_checkbox_display_location, array( $this, 'maybe_add_checkout_fields' ) );
|
118 |
-
|
119 |
-
// Maybe save the "opt-in" field on the checkout
|
120 |
-
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'maybe_save_checkout_fields' ) );
|
121 |
-
|
122 |
-
add_action( 'wp_ajax_ss_wc_mailchimp_get_account', array( $this, 'ajax_get_account' ) );
|
123 |
-
|
124 |
-
add_action( 'wp_ajax_ss_wc_mailchimp_get_lists', array( $this, 'ajax_get_lists' ) );
|
125 |
-
|
126 |
-
add_action( 'wp_ajax_ss_wc_mailchimp_get_interest_groups', array( $this, 'ajax_get_interest_groups' ) );
|
127 |
-
|
128 |
-
add_action( 'wp_ajax_ss_wc_mailchimp_get_merge_fields', array( $this, 'ajax_get_merge_fields' ) );
|
129 |
-
|
130 |
-
} //end function ensure_tab
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Return all lists from MailChimp to be used in select fields
|
134 |
-
*
|
135 |
-
* @access public
|
136 |
-
* @return array
|
137 |
-
*/
|
138 |
-
public function ajax_get_account() {
|
139 |
-
|
140 |
-
try {
|
141 |
-
|
142 |
-
if ( !isset($_POST['data']) ) {
|
143 |
-
throw new Exception( __( __METHOD__ . ': $_POST[\'data\'] not provided.', 'woocommerce-mailchimp' ) );
|
144 |
-
}
|
145 |
-
|
146 |
-
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
147 |
-
|
148 |
-
throw new Exception( __( 'Please enter an api key.', 'woocommerce-mailchimp' ) );
|
149 |
-
|
150 |
-
}
|
151 |
-
|
152 |
-
$api_key = $_POST['data']['api_key'];
|
153 |
-
|
154 |
-
$account = $this->sswcmc->mailchimp()->get_account( $api_key );
|
155 |
-
|
156 |
-
$results = $account;
|
157 |
-
|
158 |
-
}
|
159 |
-
catch ( Exception $e ) {
|
160 |
-
|
161 |
-
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
-
return $this->toJSON( $results );
|
166 |
-
|
167 |
-
} //end function ajax_get_account
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Return all lists from MailChimp to be used in select fields
|
171 |
-
*
|
172 |
-
* @access public
|
173 |
-
* @return array
|
174 |
-
*/
|
175 |
-
public function ajax_get_lists() {
|
176 |
-
|
177 |
-
try {
|
178 |
-
|
179 |
-
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
180 |
-
|
181 |
-
return $this->toJSON( array( '' => __( 'Enter your api key above to see your lists', 'woocommerce-mailchimp' ) ) );
|
182 |
-
|
183 |
-
}
|
184 |
-
|
185 |
-
$api_key = $_POST['data']['api_key'];
|
186 |
-
|
187 |
-
$lists = $this->sswcmc->mailchimp( $api_key )->get_lists();
|
188 |
-
|
189 |
-
$results = array_merge( array('' => 'Select a list...'), $lists );
|
190 |
-
|
191 |
-
}
|
192 |
-
catch ( Exception $e ) {
|
193 |
-
|
194 |
-
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
-
return $this->toJSON( $results );
|
199 |
-
|
200 |
-
} //end function ajax_get_lists
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Return interest categories for the passed MailChimp List to be used in select fields
|
204 |
-
*
|
205 |
-
* @access public
|
206 |
-
* @return array
|
207 |
-
*/
|
208 |
-
public function ajax_get_interest_groups() {
|
209 |
-
|
210 |
-
try {
|
211 |
-
|
212 |
-
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
213 |
-
|
214 |
-
return $this->toJSON( array( '' => __( 'Enter your api key above to see your lists', 'ss_wc_mailchimp' ) ) );
|
215 |
-
|
216 |
-
}
|
217 |
-
|
218 |
-
if ( !$_POST['data']['list_id'] || empty( $_POST['data']['list_id'] ) ) {
|
219 |
-
|
220 |
-
return $this->toJSON( array( '' => __( 'Please select a list from above.', 'ss_wc_mailchimp' ) ) );
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
$api_key = $_POST['data']['api_key'];
|
225 |
-
$list_id = $_POST['data']['list_id'];
|
226 |
-
|
227 |
-
$interest_groups = $this->sswcmc->mailchimp( $api_key )->get_interest_categories_with_interests( $list_id );
|
228 |
-
|
229 |
-
$results = $interest_groups;
|
230 |
-
|
231 |
-
}
|
232 |
-
catch ( Exception $e ) {
|
233 |
-
|
234 |
-
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
235 |
-
|
236 |
-
}
|
237 |
-
|
238 |
-
return $this->toJSON( $results );
|
239 |
-
|
240 |
-
} //end function ajax_get_interest_groups
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Return merge fields (a.k.a. merge tags) for the passed MailChimp List
|
244 |
-
*
|
245 |
-
* @access public
|
246 |
-
* @return array
|
247 |
-
*/
|
248 |
-
public function ajax_get_merge_fields() {
|
249 |
-
|
250 |
-
try {
|
251 |
-
|
252 |
-
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
253 |
-
|
254 |
-
return $this->toJSON( array( '' => __( 'Please enter your api key above.', 'ss_wc_mailchimp' ) ) );
|
255 |
-
|
256 |
-
}
|
257 |
-
|
258 |
-
if ( !$_POST['data']['list_id'] || empty( $_POST['data']['list_id'] ) ) {
|
259 |
-
|
260 |
-
return $this->toJSON( array( '' => __( 'Please select a list from above.', 'ss_wc_mailchimp' ) ) );
|
261 |
-
|
262 |
-
}
|
263 |
-
|
264 |
-
$api_key = $_POST['data']['api_key'];
|
265 |
-
$list_id = $_POST['data']['list_id'];
|
266 |
-
|
267 |
-
$merge_fields = $this->sswcmc->mailchimp( $api_key )->get_merge_fields( $list_id );
|
268 |
-
|
269 |
-
$results = $merge_fields;
|
270 |
-
|
271 |
-
}
|
272 |
-
catch ( Exception $e ) {
|
273 |
-
|
274 |
-
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
275 |
-
|
276 |
-
}
|
277 |
-
|
278 |
-
return $this->toJSON( $results );
|
279 |
-
|
280 |
-
} //end function ajax_get_merge_fields
|
281 |
-
|
282 |
-
private function toJSON( $response ) {
|
283 |
-
|
284 |
-
// Commented out due to json_encode not preserving quotes around MailChimp ids
|
285 |
-
// header('Content-Type: application/json');
|
286 |
-
echo json_encode( $response );
|
287 |
-
exit();
|
288 |
-
|
289 |
-
} //end function toJSON
|
290 |
-
|
291 |
-
private function namespace_prefixed( $suffix ) {
|
292 |
-
return $this->namespace . '_' . $suffix;
|
293 |
-
}
|
294 |
-
|
295 |
-
/**
|
296 |
-
* WooCommerce 2.2 support for wc_get_order
|
297 |
-
*
|
298 |
-
* @since 1.2.1
|
299 |
-
*
|
300 |
-
* @access private
|
301 |
-
* @param int $order_id
|
302 |
-
* @return void
|
303 |
-
*/
|
304 |
-
private function wc_get_order( $order_id ) {
|
305 |
-
if ( function_exists( 'wc_get_order' ) ) {
|
306 |
-
return wc_get_order( $order_id );
|
307 |
-
} else {
|
308 |
-
return new WC_Order( $order_id );
|
309 |
-
}
|
310 |
-
}
|
311 |
-
|
312 |
-
/**
|
313 |
-
* Get message
|
314 |
-
* @return string Error
|
315 |
-
*/
|
316 |
-
private function get_message( $message, $type = 'error' ) {
|
317 |
-
ob_start();
|
318 |
-
|
319 |
-
?>
|
320 |
-
<div class="<?php echo $type ?>">
|
321 |
-
<p><?php echo $message ?></p>
|
322 |
-
</div>
|
323 |
-
<?php
|
324 |
-
return ob_get_clean();
|
325 |
-
}
|
326 |
-
|
327 |
-
/**
|
328 |
-
* subscribe function.
|
329 |
-
*
|
330 |
-
* @access public
|
331 |
-
* @param int $order_id
|
332 |
-
* @param mixed $first_name
|
333 |
-
* @param mixed $last_name
|
334 |
-
* @param mixed $email
|
335 |
-
* @param string $listid (default: 'false')
|
336 |
-
* @return void
|
337 |
-
*/
|
338 |
-
public function subscribe( $order_id, $first_name, $last_name, $email, $list_id = 'false' ) {
|
339 |
-
if ( ! $email ) {
|
340 |
-
return; // Email is required
|
341 |
-
}
|
342 |
-
|
343 |
-
if ( 'false' == $list_id ) {
|
344 |
-
$list_id = $this->sswcmc->get_list();
|
345 |
-
}
|
346 |
-
|
347 |
-
$merge_tags = array(
|
348 |
-
'FNAME' => $first_name,
|
349 |
-
'LNAME' => $last_name
|
350 |
-
);
|
351 |
-
|
352 |
-
$interest_groups = $this->sswcmc->interest_groups();
|
353 |
-
|
354 |
-
if ( ! empty( $interest_groups) ) {
|
355 |
-
$interest_groups = array_fill_keys( $this->sswcmc->interest_groups(), true );
|
356 |
-
|
357 |
-
// Allow hooking into variables
|
358 |
-
$interest_groups = apply_filters( $this->namespace_prefixed( 'subscribe_interest_groups' ), $interest_groups, $order_id, $email );
|
359 |
-
}
|
360 |
-
|
361 |
-
// Allow hooking into variables
|
362 |
-
$merge_tags = apply_filters( $this->namespace_prefixed( 'subscribe_merge_tags' ), $merge_tags, $order_id, $email );
|
363 |
-
|
364 |
-
// Set subscription options
|
365 |
-
$subscribe_options = array(
|
366 |
-
'list_id' => $list_id,
|
367 |
-
'email' => $email,
|
368 |
-
'merge_tags' => $merge_tags,
|
369 |
-
'interest_groups' => $interest_groups,
|
370 |
-
'email_type' => 'html',
|
371 |
-
'double_opt_in' => $this->sswcmc->double_opt_in(),
|
372 |
-
);
|
373 |
-
|
374 |
-
// Allow hooking into subscription options
|
375 |
-
$options = apply_filters( $this->namespace_prefixed( 'subscribe_options' ), $subscribe_options, $order_id );
|
376 |
-
|
377 |
-
// Extract options into variables
|
378 |
-
extract( $options );
|
379 |
-
|
380 |
-
// Log
|
381 |
-
$this->log( sprintf( __( __METHOD__ . '(): Subscribing customer to MailChimp: %s', 'woocommerce-mailchimp' ), print_r( $options, true ) ) );
|
382 |
-
|
383 |
-
do_action( $this->namespace_prefixed( 'before_subscribe' ), $subscribe_options, $order_id );
|
384 |
-
|
385 |
-
// Call API
|
386 |
-
$api_response = $this->sswcmc->mailchimp()->subscribe( $list_id, $email, $email_type, $merge_tags, $interest_groups, $double_opt_in );
|
387 |
-
|
388 |
-
do_action( $this->namespace_prefixed( 'after_subscribe' ), $subscribe_options, $order_id );
|
389 |
-
|
390 |
-
// Log api response
|
391 |
-
$this->log( sprintf( __( __METHOD__ . '(): MailChimp API response: %s', 'woocommerce-mailchimp' ), print_r( $api_response, true ) ) );
|
392 |
-
|
393 |
-
if ( $api_response === false ) {
|
394 |
-
// Format error message
|
395 |
-
$error_response = sprintf( __( __METHOD__ . '(): WooCommerce MailChimp subscription failed: %s (%s)', 'woocommerce-mailchimp' ), $this->sswcmc->mailchimp()->get_error_message(), $this->sswcmc->mailchimp()->get_error_code() );
|
396 |
-
|
397 |
-
// Log
|
398 |
-
$this->log( $error_response );
|
399 |
-
|
400 |
-
// New hook for failing operations
|
401 |
-
do_action( $this->namespace_prefixed( 'subscription_failed' ), $email, array( 'list_id' => $list_id, 'order_id' => $order_id ) );
|
402 |
-
|
403 |
-
// Email admin
|
404 |
-
$admin_email = get_option( 'admin_email' );
|
405 |
-
$admin_email = apply_filters( $this->namespace_prefixed( 'admin_email'), $admin_email );
|
406 |
-
wp_mail( $admin_email, __( 'WooCommerce MailChimp subscription failed', 'woocommerce-mailchimp' ), $error_response );
|
407 |
-
} else {
|
408 |
-
// Hook on success
|
409 |
-
do_action( $this->namespace_prefixed( 'subscription_success' ), $email, array( 'list_id' => $list_id, 'order_id' => $order_id ) );
|
410 |
-
}
|
411 |
-
}
|
412 |
-
|
413 |
-
/**
|
414 |
-
* Add the opt-in checkbox to the checkout fields (to be displayed on checkout).
|
415 |
-
*
|
416 |
-
* @since 1.1
|
417 |
-
*/
|
418 |
-
function maybe_add_checkout_fields() {
|
419 |
-
|
420 |
-
if ( $this->sswcmc->is_valid() ) {
|
421 |
-
if ( $this->sswcmc->display_opt_in() ) {
|
422 |
-
do_action( $this->namespace_prefixed( 'before_opt_in_checkbox' ) );
|
423 |
-
|
424 |
-
echo apply_filters( $this->namespace_prefixed( 'opt_in_checkbox' ), '<p class="form-row woocommerce-mailchimp-opt-in"><label class="checkbox" for="ss_wc_mailchimp_opt_in"><input type="checkbox" name="ss_wc_mailchimp_opt_in" id="ss_wc_mailchimp_opt_in" class="input-checkbox" value="yes"' . ($this->sswcmc->opt_in_checkbox_default_status() == 'checked' ? ' checked="checked"' : '') . '/> ' . esc_html( $this->sswcmc->opt_in_label() ) . '</label></p>' . "\n", $this->sswcmc->opt_in_checkbox_default_status(), $this->sswcmc->opt_in_label(), $this->sswcmc->opt_in_checkbox_default_status(), $this->sswcmc->opt_in_label() );
|
425 |
-
// woocommerce_form_field( '2ss_wc_mailchimp_opt_in', array(
|
426 |
-
// 'type' => 'checkbox',
|
427 |
-
// 'class' => array('woocommerce-mailchimp-opt-in'),
|
428 |
-
// 'label' => esc_html( $this->sswcmc->opt_in_label() ),
|
429 |
-
// 'custom_attributes' => array(
|
430 |
-
// 'for' => '2ss_wc_mailchimp_opt_in',
|
431 |
-
// ),
|
432 |
-
// ), $this->sswcmc->opt_in_checkbox_default_status() == 'checked' );
|
433 |
-
do_action( $this->namespace_prefixed( 'after_opt_in_checkbox' ) );
|
434 |
-
}
|
435 |
-
}
|
436 |
-
}
|
437 |
-
|
438 |
-
/**
|
439 |
-
* When the checkout form is submitted, save opt-in value.
|
440 |
-
*
|
441 |
-
* @version 1.1
|
442 |
-
*/
|
443 |
-
function maybe_save_checkout_fields( $order_id ) {
|
444 |
-
if ( $this->sswcmc->display_opt_in() ) {
|
445 |
-
$opt_in = isset( $_POST[ $this->namespace_prefixed( 'opt_in' ) ] ) ? 'yes' : 'no';
|
446 |
-
|
447 |
-
update_post_meta( $order_id, $this->namespace_prefixed( 'opt_in' ), $opt_in );
|
448 |
-
}
|
449 |
-
}
|
450 |
-
|
451 |
-
/**
|
452 |
-
* Helper log function for debugging
|
453 |
-
*
|
454 |
-
* @since 1.2.2
|
455 |
-
*/
|
456 |
-
private function log( $message ) {
|
457 |
-
if ( $this->sswcmc->debug_enabled() ) {
|
458 |
-
$logger = new WC_Logger();
|
459 |
-
|
460 |
-
if ( is_array( $message ) || is_object( $message ) ) {
|
461 |
-
$logger->add( 'woocommerce-mailchimp', print_r( $message, true ) );
|
462 |
-
}
|
463 |
-
else {
|
464 |
-
$logger->add( 'woocommerce-mailchimp', $message );
|
465 |
-
}
|
466 |
-
}
|
467 |
-
}
|
468 |
-
|
469 |
-
} //end class SS_WC_MailChimp_Handler
|
470 |
-
|
471 |
-
} //end if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) )
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce MailChimp Handler
|
4 |
+
*
|
5 |
+
* @author Saint Systems
|
6 |
+
* @package WooCommerce MailChimp
|
7 |
+
* @version 2.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
11 |
+
|
12 |
+
if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @class SS_WC_MailChimp_Handler
|
16 |
+
*/
|
17 |
+
final class SS_WC_MailChimp_Handler {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Plugin singleton instance
|
21 |
+
* @var SS_WC_MailChimp_Handler
|
22 |
+
*/
|
23 |
+
private static $instance = null;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Constructor
|
27 |
+
*
|
28 |
+
* @access public
|
29 |
+
* @return void
|
30 |
+
*/
|
31 |
+
public function __construct() {
|
32 |
+
|
33 |
+
$this->id = 'mailchimp';
|
34 |
+
$this->namespace = 'ss_wc_' . $this->id;
|
35 |
+
$this->label = __( 'MailChimp', 'woocommerce-mailchimp' );
|
36 |
+
$this->sswcmc = SSWCMC();
|
37 |
+
$this->register_hooks();
|
38 |
+
|
39 |
+
} //end function __construct
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @return SS_WC_MailChimp_Handler
|
43 |
+
*/
|
44 |
+
public static function get_instance() {
|
45 |
+
|
46 |
+
if ( empty( self::$instance ) ) {
|
47 |
+
self::$instance = new self;
|
48 |
+
}
|
49 |
+
|
50 |
+
return self::$instance;
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* order_status_changed function.
|
56 |
+
*
|
57 |
+
* @access public
|
58 |
+
* @return void
|
59 |
+
*/
|
60 |
+
public function order_status_changed( $id, $status = 'new', $new_status = 'pending' ) {
|
61 |
+
if ( $this->sswcmc->is_valid() && $new_status === $this->sswcmc->occurs() ) {
|
62 |
+
// Get WC order
|
63 |
+
$order = $this->wc_get_order( $id );
|
64 |
+
|
65 |
+
// get the ss_wc_mailchimp_opt_in value from the post meta. "order_custom_fields" was removed with WooCommerce 2.1
|
66 |
+
$subscribe_customer = get_post_meta( $id, $this->namespace_prefixed( 'opt_in' ), true );
|
67 |
+
|
68 |
+
$order_id = method_exists($order, 'get_id') ? $order->get_id(): $order->id;
|
69 |
+
$order_billing_email = method_exists($order, 'get_billing_email') ? $order->get_billing_email(): $order->billing_email;
|
70 |
+
$order_billing_first_name = method_exists($order, 'get_billing_first_name') ? $order->get_billing_first_name(): $order->billing_first_name;
|
71 |
+
$order_billing_last_name = method_exists($order, 'get_billing_last_name') ? $order->get_billing_last_name(): $order->billing_last_name;
|
72 |
+
|
73 |
+
// If the 'ss_wc_mailchimp_opt_in' meta value isn't set
|
74 |
+
// (because 'display_opt_in' wasn't enabled at the time the order was placed)
|
75 |
+
// or the 'ss_wc_mailchimp_opt_in' is yes, subscriber the customer
|
76 |
+
if ( ! $subscribe_customer || empty( $subscribe_customer ) || 'yes' === $subscribe_customer ) {
|
77 |
+
// log
|
78 |
+
$this->log( sprintf( __( __METHOD__ . '(): Subscribing customer (%s) to list %s', 'woocommerce-mailchimp' ), $order_billing_email , $this->sswcmc->get_list() ) );
|
79 |
+
|
80 |
+
// subscribe
|
81 |
+
$this->subscribe( $order_id, $order_billing_first_name, $order_billing_last_name, $order_billing_email , $this->sswcmc->get_list() );
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Register plugin hooks
|
88 |
+
*
|
89 |
+
* @access public
|
90 |
+
* @return void
|
91 |
+
*/
|
92 |
+
public function register_hooks() {
|
93 |
+
|
94 |
+
// We would use the 'woocommerce_new_order' action but first name, last name and email address (order meta) is not yet available,
|
95 |
+
// so instead we use the 'woocommerce_checkout_update_order_meta' action hook which fires after the checkout process on the "thank you" page
|
96 |
+
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'order_status_changed' ), 1000, 1 );
|
97 |
+
|
98 |
+
// hook into woocommerce order status changed hook to handle the desired subscription event trigger
|
99 |
+
add_action( 'woocommerce_order_status_changed', array( $this, 'order_status_changed' ), 10, 3 );
|
100 |
+
|
101 |
+
$opt_in_checkbox_display_location = $this->sswcmc->opt_in_checkbox_display_location();
|
102 |
+
|
103 |
+
// Maybe add an "opt-in" field to the checkout
|
104 |
+
$opt_in_checkbox_display_location = !empty( $opt_in_checkbox_display_location ) ? $opt_in_checkbox_display_location : 'woocommerce_review_order_before_submit';
|
105 |
+
|
106 |
+
// Old opt-in checkbox display locations
|
107 |
+
$old_opt_in_checkbox_display_locations = array(
|
108 |
+
'billing' => 'woocommerce_after_checkout_billing_form',
|
109 |
+
'order' => 'woocommerce_review_order_before_submit',
|
110 |
+
);
|
111 |
+
|
112 |
+
// Map old billing/order checkbox display locations to new format
|
113 |
+
if ( array_key_exists( $opt_in_checkbox_display_location, $old_opt_in_checkbox_display_locations ) ) {
|
114 |
+
$opt_in_checkbox_display_location = $old_opt_in_checkbox_display_locations[ $opt_in_checkbox_display_location ];
|
115 |
+
}
|
116 |
+
|
117 |
+
add_action( $opt_in_checkbox_display_location, array( $this, 'maybe_add_checkout_fields' ) );
|
118 |
+
|
119 |
+
// Maybe save the "opt-in" field on the checkout
|
120 |
+
add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'maybe_save_checkout_fields' ) );
|
121 |
+
|
122 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_account', array( $this, 'ajax_get_account' ) );
|
123 |
+
|
124 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_lists', array( $this, 'ajax_get_lists' ) );
|
125 |
+
|
126 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_interest_groups', array( $this, 'ajax_get_interest_groups' ) );
|
127 |
+
|
128 |
+
add_action( 'wp_ajax_ss_wc_mailchimp_get_merge_fields', array( $this, 'ajax_get_merge_fields' ) );
|
129 |
+
|
130 |
+
} //end function ensure_tab
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Return all lists from MailChimp to be used in select fields
|
134 |
+
*
|
135 |
+
* @access public
|
136 |
+
* @return array
|
137 |
+
*/
|
138 |
+
public function ajax_get_account() {
|
139 |
+
|
140 |
+
try {
|
141 |
+
|
142 |
+
if ( !isset($_POST['data']) ) {
|
143 |
+
throw new Exception( __( __METHOD__ . ': $_POST[\'data\'] not provided.', 'woocommerce-mailchimp' ) );
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
147 |
+
|
148 |
+
throw new Exception( __( 'Please enter an api key.', 'woocommerce-mailchimp' ) );
|
149 |
+
|
150 |
+
}
|
151 |
+
|
152 |
+
$api_key = $_POST['data']['api_key'];
|
153 |
+
|
154 |
+
$account = $this->sswcmc->mailchimp()->get_account( $api_key );
|
155 |
+
|
156 |
+
$results = $account;
|
157 |
+
|
158 |
+
}
|
159 |
+
catch ( Exception $e ) {
|
160 |
+
|
161 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
return $this->toJSON( $results );
|
166 |
+
|
167 |
+
} //end function ajax_get_account
|
168 |
+
|
169 |
+
/**
|
170 |
+
* Return all lists from MailChimp to be used in select fields
|
171 |
+
*
|
172 |
+
* @access public
|
173 |
+
* @return array
|
174 |
+
*/
|
175 |
+
public function ajax_get_lists() {
|
176 |
+
|
177 |
+
try {
|
178 |
+
|
179 |
+
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
180 |
+
|
181 |
+
return $this->toJSON( array( '' => __( 'Enter your api key above to see your lists', 'woocommerce-mailchimp' ) ) );
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
$api_key = $_POST['data']['api_key'];
|
186 |
+
|
187 |
+
$lists = $this->sswcmc->mailchimp( $api_key )->get_lists();
|
188 |
+
|
189 |
+
$results = array_merge( array('' => 'Select a list...'), $lists );
|
190 |
+
|
191 |
+
}
|
192 |
+
catch ( Exception $e ) {
|
193 |
+
|
194 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
return $this->toJSON( $results );
|
199 |
+
|
200 |
+
} //end function ajax_get_lists
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Return interest categories for the passed MailChimp List to be used in select fields
|
204 |
+
*
|
205 |
+
* @access public
|
206 |
+
* @return array
|
207 |
+
*/
|
208 |
+
public function ajax_get_interest_groups() {
|
209 |
+
|
210 |
+
try {
|
211 |
+
|
212 |
+
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
213 |
+
|
214 |
+
return $this->toJSON( array( '' => __( 'Enter your api key above to see your lists', 'ss_wc_mailchimp' ) ) );
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
if ( !$_POST['data']['list_id'] || empty( $_POST['data']['list_id'] ) ) {
|
219 |
+
|
220 |
+
return $this->toJSON( array( '' => __( 'Please select a list from above.', 'ss_wc_mailchimp' ) ) );
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
$api_key = $_POST['data']['api_key'];
|
225 |
+
$list_id = $_POST['data']['list_id'];
|
226 |
+
|
227 |
+
$interest_groups = $this->sswcmc->mailchimp( $api_key )->get_interest_categories_with_interests( $list_id );
|
228 |
+
|
229 |
+
$results = $interest_groups;
|
230 |
+
|
231 |
+
}
|
232 |
+
catch ( Exception $e ) {
|
233 |
+
|
234 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
235 |
+
|
236 |
+
}
|
237 |
+
|
238 |
+
return $this->toJSON( $results );
|
239 |
+
|
240 |
+
} //end function ajax_get_interest_groups
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Return merge fields (a.k.a. merge tags) for the passed MailChimp List
|
244 |
+
*
|
245 |
+
* @access public
|
246 |
+
* @return array
|
247 |
+
*/
|
248 |
+
public function ajax_get_merge_fields() {
|
249 |
+
|
250 |
+
try {
|
251 |
+
|
252 |
+
if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
|
253 |
+
|
254 |
+
return $this->toJSON( array( '' => __( 'Please enter your api key above.', 'ss_wc_mailchimp' ) ) );
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
if ( !$_POST['data']['list_id'] || empty( $_POST['data']['list_id'] ) ) {
|
259 |
+
|
260 |
+
return $this->toJSON( array( '' => __( 'Please select a list from above.', 'ss_wc_mailchimp' ) ) );
|
261 |
+
|
262 |
+
}
|
263 |
+
|
264 |
+
$api_key = $_POST['data']['api_key'];
|
265 |
+
$list_id = $_POST['data']['list_id'];
|
266 |
+
|
267 |
+
$merge_fields = $this->sswcmc->mailchimp( $api_key )->get_merge_fields( $list_id );
|
268 |
+
|
269 |
+
$results = $merge_fields;
|
270 |
+
|
271 |
+
}
|
272 |
+
catch ( Exception $e ) {
|
273 |
+
|
274 |
+
return $this->toJSON( array( 'error' => $e->getMessage() ) );
|
275 |
+
|
276 |
+
}
|
277 |
+
|
278 |
+
return $this->toJSON( $results );
|
279 |
+
|
280 |
+
} //end function ajax_get_merge_fields
|
281 |
+
|
282 |
+
private function toJSON( $response ) {
|
283 |
+
|
284 |
+
// Commented out due to json_encode not preserving quotes around MailChimp ids
|
285 |
+
// header('Content-Type: application/json');
|
286 |
+
echo json_encode( $response );
|
287 |
+
exit();
|
288 |
+
|
289 |
+
} //end function toJSON
|
290 |
+
|
291 |
+
private function namespace_prefixed( $suffix ) {
|
292 |
+
return $this->namespace . '_' . $suffix;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* WooCommerce 2.2 support for wc_get_order
|
297 |
+
*
|
298 |
+
* @since 1.2.1
|
299 |
+
*
|
300 |
+
* @access private
|
301 |
+
* @param int $order_id
|
302 |
+
* @return void
|
303 |
+
*/
|
304 |
+
private function wc_get_order( $order_id ) {
|
305 |
+
if ( function_exists( 'wc_get_order' ) ) {
|
306 |
+
return wc_get_order( $order_id );
|
307 |
+
} else {
|
308 |
+
return new WC_Order( $order_id );
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Get message
|
314 |
+
* @return string Error
|
315 |
+
*/
|
316 |
+
private function get_message( $message, $type = 'error' ) {
|
317 |
+
ob_start();
|
318 |
+
|
319 |
+
?>
|
320 |
+
<div class="<?php echo $type ?>">
|
321 |
+
<p><?php echo $message ?></p>
|
322 |
+
</div>
|
323 |
+
<?php
|
324 |
+
return ob_get_clean();
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* subscribe function.
|
329 |
+
*
|
330 |
+
* @access public
|
331 |
+
* @param int $order_id
|
332 |
+
* @param mixed $first_name
|
333 |
+
* @param mixed $last_name
|
334 |
+
* @param mixed $email
|
335 |
+
* @param string $listid (default: 'false')
|
336 |
+
* @return void
|
337 |
+
*/
|
338 |
+
public function subscribe( $order_id, $first_name, $last_name, $email, $list_id = 'false' ) {
|
339 |
+
if ( ! $email ) {
|
340 |
+
return; // Email is required
|
341 |
+
}
|
342 |
+
|
343 |
+
if ( 'false' == $list_id ) {
|
344 |
+
$list_id = $this->sswcmc->get_list();
|
345 |
+
}
|
346 |
+
|
347 |
+
$merge_tags = array(
|
348 |
+
'FNAME' => $first_name,
|
349 |
+
'LNAME' => $last_name
|
350 |
+
);
|
351 |
+
|
352 |
+
$interest_groups = $this->sswcmc->interest_groups();
|
353 |
+
|
354 |
+
if ( ! empty( $interest_groups) ) {
|
355 |
+
$interest_groups = array_fill_keys( $this->sswcmc->interest_groups(), true );
|
356 |
+
|
357 |
+
// Allow hooking into variables
|
358 |
+
$interest_groups = apply_filters( $this->namespace_prefixed( 'subscribe_interest_groups' ), $interest_groups, $order_id, $email );
|
359 |
+
}
|
360 |
+
|
361 |
+
// Allow hooking into variables
|
362 |
+
$merge_tags = apply_filters( $this->namespace_prefixed( 'subscribe_merge_tags' ), $merge_tags, $order_id, $email );
|
363 |
+
|
364 |
+
// Set subscription options
|
365 |
+
$subscribe_options = array(
|
366 |
+
'list_id' => $list_id,
|
367 |
+
'email' => $email,
|
368 |
+
'merge_tags' => $merge_tags,
|
369 |
+
'interest_groups' => $interest_groups,
|
370 |
+
'email_type' => 'html',
|
371 |
+
'double_opt_in' => $this->sswcmc->double_opt_in(),
|
372 |
+
);
|
373 |
+
|
374 |
+
// Allow hooking into subscription options
|
375 |
+
$options = apply_filters( $this->namespace_prefixed( 'subscribe_options' ), $subscribe_options, $order_id );
|
376 |
+
|
377 |
+
// Extract options into variables
|
378 |
+
extract( $options );
|
379 |
+
|
380 |
+
// Log
|
381 |
+
$this->log( sprintf( __( __METHOD__ . '(): Subscribing customer to MailChimp: %s', 'woocommerce-mailchimp' ), print_r( $options, true ) ) );
|
382 |
+
|
383 |
+
do_action( $this->namespace_prefixed( 'before_subscribe' ), $subscribe_options, $order_id );
|
384 |
+
|
385 |
+
// Call API
|
386 |
+
$api_response = $this->sswcmc->mailchimp()->subscribe( $list_id, $email, $email_type, $merge_tags, $interest_groups, $double_opt_in );
|
387 |
+
|
388 |
+
do_action( $this->namespace_prefixed( 'after_subscribe' ), $subscribe_options, $order_id );
|
389 |
+
|
390 |
+
// Log api response
|
391 |
+
$this->log( sprintf( __( __METHOD__ . '(): MailChimp API response: %s', 'woocommerce-mailchimp' ), print_r( $api_response, true ) ) );
|
392 |
+
|
393 |
+
if ( $api_response === false ) {
|
394 |
+
// Format error message
|
395 |
+
$error_response = sprintf( __( __METHOD__ . '(): WooCommerce MailChimp subscription failed: %s (%s)', 'woocommerce-mailchimp' ), $this->sswcmc->mailchimp()->get_error_message(), $this->sswcmc->mailchimp()->get_error_code() );
|
396 |
+
|
397 |
+
// Log
|
398 |
+
$this->log( $error_response );
|
399 |
+
|
400 |
+
// New hook for failing operations
|
401 |
+
do_action( $this->namespace_prefixed( 'subscription_failed' ), $email, array( 'list_id' => $list_id, 'order_id' => $order_id ) );
|
402 |
+
|
403 |
+
// Email admin
|
404 |
+
$admin_email = get_option( 'admin_email' );
|
405 |
+
$admin_email = apply_filters( $this->namespace_prefixed( 'admin_email'), $admin_email );
|
406 |
+
wp_mail( $admin_email, __( 'WooCommerce MailChimp subscription failed', 'woocommerce-mailchimp' ), $error_response );
|
407 |
+
} else {
|
408 |
+
// Hook on success
|
409 |
+
do_action( $this->namespace_prefixed( 'subscription_success' ), $email, array( 'list_id' => $list_id, 'order_id' => $order_id ) );
|
410 |
+
}
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Add the opt-in checkbox to the checkout fields (to be displayed on checkout).
|
415 |
+
*
|
416 |
+
* @since 1.1
|
417 |
+
*/
|
418 |
+
function maybe_add_checkout_fields() {
|
419 |
+
|
420 |
+
if ( $this->sswcmc->is_valid() ) {
|
421 |
+
if ( $this->sswcmc->display_opt_in() ) {
|
422 |
+
do_action( $this->namespace_prefixed( 'before_opt_in_checkbox' ) );
|
423 |
+
|
424 |
+
echo apply_filters( $this->namespace_prefixed( 'opt_in_checkbox' ), '<p class="form-row woocommerce-mailchimp-opt-in"><label class="checkbox" for="ss_wc_mailchimp_opt_in"><input type="checkbox" name="ss_wc_mailchimp_opt_in" id="ss_wc_mailchimp_opt_in" class="input-checkbox" value="yes"' . ($this->sswcmc->opt_in_checkbox_default_status() == 'checked' ? ' checked="checked"' : '') . '/> ' . esc_html( $this->sswcmc->opt_in_label() ) . '</label></p>' . "\n", $this->sswcmc->opt_in_checkbox_default_status(), $this->sswcmc->opt_in_label(), $this->sswcmc->opt_in_checkbox_default_status(), $this->sswcmc->opt_in_label() );
|
425 |
+
// woocommerce_form_field( '2ss_wc_mailchimp_opt_in', array(
|
426 |
+
// 'type' => 'checkbox',
|
427 |
+
// 'class' => array('woocommerce-mailchimp-opt-in'),
|
428 |
+
// 'label' => esc_html( $this->sswcmc->opt_in_label() ),
|
429 |
+
// 'custom_attributes' => array(
|
430 |
+
// 'for' => '2ss_wc_mailchimp_opt_in',
|
431 |
+
// ),
|
432 |
+
// ), $this->sswcmc->opt_in_checkbox_default_status() == 'checked' );
|
433 |
+
do_action( $this->namespace_prefixed( 'after_opt_in_checkbox' ) );
|
434 |
+
}
|
435 |
+
}
|
436 |
+
}
|
437 |
+
|
438 |
+
/**
|
439 |
+
* When the checkout form is submitted, save opt-in value.
|
440 |
+
*
|
441 |
+
* @version 1.1
|
442 |
+
*/
|
443 |
+
function maybe_save_checkout_fields( $order_id ) {
|
444 |
+
if ( $this->sswcmc->display_opt_in() ) {
|
445 |
+
$opt_in = isset( $_POST[ $this->namespace_prefixed( 'opt_in' ) ] ) ? 'yes' : 'no';
|
446 |
+
|
447 |
+
update_post_meta( $order_id, $this->namespace_prefixed( 'opt_in' ), $opt_in );
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Helper log function for debugging
|
453 |
+
*
|
454 |
+
* @since 1.2.2
|
455 |
+
*/
|
456 |
+
private function log( $message ) {
|
457 |
+
if ( $this->sswcmc->debug_enabled() ) {
|
458 |
+
$logger = new WC_Logger();
|
459 |
+
|
460 |
+
if ( is_array( $message ) || is_object( $message ) ) {
|
461 |
+
$logger->add( 'woocommerce-mailchimp', print_r( $message, true ) );
|
462 |
+
}
|
463 |
+
else {
|
464 |
+
$logger->add( 'woocommerce-mailchimp', $message );
|
465 |
+
}
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
} //end class SS_WC_MailChimp_Handler
|
470 |
+
|
471 |
+
} //end if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) )
|
includes/class-ss-wc-mailchimp-migrator.php
CHANGED
@@ -1,72 +1,72 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* WooCommerce MailChimp plugin migrator class
|
5 |
-
*/
|
6 |
-
final class SS_WC_MailChimp_Migrator {
|
7 |
-
|
8 |
-
const VERSION_KEY = 'ss_wc_mailchimp_version';
|
9 |
-
const OLD_SETTINGS_KEY = 'woocommerce_mailchimp_settings';
|
10 |
-
|
11 |
-
protected static $versions = array(
|
12 |
-
'1.3.X',
|
13 |
-
'2.0',
|
14 |
-
'2.0.15',
|
15 |
-
);
|
16 |
-
|
17 |
-
public static function migrate( $target_version ) {
|
18 |
-
|
19 |
-
$old_settings = get_option( self::OLD_SETTINGS_KEY );
|
20 |
-
$current_version = get_option( self::VERSION_KEY );
|
21 |
-
|
22 |
-
if ( ! $old_settings && ! $current_version ) {
|
23 |
-
// This is a new install, so no need to migrate
|
24 |
-
return;
|
25 |
-
}
|
26 |
-
|
27 |
-
if ( ! $current_version ) {
|
28 |
-
$current_version = '1.3.X';
|
29 |
-
}
|
30 |
-
|
31 |
-
if ( $current_version !== $target_version ) {
|
32 |
-
|
33 |
-
// error_log( 'Need to migrate from ' . $current_version . ' to ' . $target_version );
|
34 |
-
|
35 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/migrations/class-ss-wc-migration.php' );
|
36 |
-
|
37 |
-
$start = array_search( $current_version, self::$versions );
|
38 |
-
|
39 |
-
// error_log( 'Starting at migration ' . $start );
|
40 |
-
|
41 |
-
for ($start; $start < count(self::$versions) - 1; $start++) {
|
42 |
-
$next = $start + 1;
|
43 |
-
$current_version = self::$versions[$start];
|
44 |
-
$next_version = self::$versions[$next];
|
45 |
-
|
46 |
-
// error_log( 'Migrating from ' . $current_version . ' to ' . $target_version );
|
47 |
-
//
|
48 |
-
if ( file_exists( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" ) ) {
|
49 |
-
|
50 |
-
require_once( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" );
|
51 |
-
|
52 |
-
$migration_name = 'SS_WC_MailChimp_Migration_From_'. self::clean_version( $current_version ) .'_To_'. self::clean_version( $next_version );
|
53 |
-
|
54 |
-
$migration = new $migration_name( $current_version, $next_version );
|
55 |
-
if ( $migration->up() ) {
|
56 |
-
// Update the current plugin version
|
57 |
-
update_option( self::VERSION_KEY, $next_version );
|
58 |
-
}
|
59 |
-
|
60 |
-
}
|
61 |
-
}
|
62 |
-
//update_option( self::VERSION_KEY, $target_version );
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
private static function clean_version( $version ) {
|
69 |
-
return str_replace( '.', '_', $version );
|
70 |
-
}
|
71 |
-
|
72 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WooCommerce MailChimp plugin migrator class
|
5 |
+
*/
|
6 |
+
final class SS_WC_MailChimp_Migrator {
|
7 |
+
|
8 |
+
const VERSION_KEY = 'ss_wc_mailchimp_version';
|
9 |
+
const OLD_SETTINGS_KEY = 'woocommerce_mailchimp_settings';
|
10 |
+
|
11 |
+
protected static $versions = array(
|
12 |
+
'1.3.X',
|
13 |
+
'2.0',
|
14 |
+
'2.0.15',
|
15 |
+
);
|
16 |
+
|
17 |
+
public static function migrate( $target_version ) {
|
18 |
+
|
19 |
+
$old_settings = get_option( self::OLD_SETTINGS_KEY );
|
20 |
+
$current_version = get_option( self::VERSION_KEY );
|
21 |
+
|
22 |
+
if ( ! $old_settings && ! $current_version ) {
|
23 |
+
// This is a new install, so no need to migrate
|
24 |
+
return;
|
25 |
+
}
|
26 |
+
|
27 |
+
if ( ! $current_version ) {
|
28 |
+
$current_version = '1.3.X';
|
29 |
+
}
|
30 |
+
|
31 |
+
if ( $current_version !== $target_version ) {
|
32 |
+
|
33 |
+
// error_log( 'Need to migrate from ' . $current_version . ' to ' . $target_version );
|
34 |
+
|
35 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/migrations/class-ss-wc-migration.php' );
|
36 |
+
|
37 |
+
$start = array_search( $current_version, self::$versions );
|
38 |
+
|
39 |
+
// error_log( 'Starting at migration ' . $start );
|
40 |
+
|
41 |
+
for ($start; $start < count(self::$versions) - 1; $start++) {
|
42 |
+
$next = $start + 1;
|
43 |
+
$current_version = self::$versions[$start];
|
44 |
+
$next_version = self::$versions[$next];
|
45 |
+
|
46 |
+
// error_log( 'Migrating from ' . $current_version . ' to ' . $target_version );
|
47 |
+
//
|
48 |
+
if ( file_exists( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" ) ) {
|
49 |
+
|
50 |
+
require_once( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" );
|
51 |
+
|
52 |
+
$migration_name = 'SS_WC_MailChimp_Migration_From_'. self::clean_version( $current_version ) .'_To_'. self::clean_version( $next_version );
|
53 |
+
|
54 |
+
$migration = new $migration_name( $current_version, $next_version );
|
55 |
+
if ( $migration->up() ) {
|
56 |
+
// Update the current plugin version
|
57 |
+
update_option( self::VERSION_KEY, $next_version );
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
61 |
+
}
|
62 |
+
//update_option( self::VERSION_KEY, $target_version );
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
private static function clean_version( $version ) {
|
69 |
+
return str_replace( '.', '_', $version );
|
70 |
+
}
|
71 |
+
|
72 |
}
|
includes/class-ss-wc-mailchimp-plugin.php
CHANGED
@@ -1,572 +1,572 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Main Plugin Class
|
4 |
-
*
|
5 |
-
* @package WooCommerce MailChimp
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* WooCommerce MailChimp plugin main class
|
10 |
-
*/
|
11 |
-
final class SS_WC_MailChimp_Plugin {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Plugin version
|
15 |
-
*
|
16 |
-
* @var string
|
17 |
-
*/
|
18 |
-
private static $version = '2.1.
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Plugin singleton instance
|
22 |
-
*
|
23 |
-
* @var SS_WC_MailChimp_Plugin
|
24 |
-
*/
|
25 |
-
private static $instance;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Plugin namespace
|
29 |
-
*
|
30 |
-
* @var string
|
31 |
-
*/
|
32 |
-
private $namespace = 'ss_wc_mailchimp';
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Plugin settings
|
36 |
-
*
|
37 |
-
* @var array
|
38 |
-
*/
|
39 |
-
private $settings;
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Plugin MailChimp helper instance
|
43 |
-
*
|
44 |
-
* @var SS_WC_MailChimp
|
45 |
-
*/
|
46 |
-
private $mailchimp;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Plugin compatibility checker
|
50 |
-
*
|
51 |
-
* @var SS_WC_MailChimp_Compatibility
|
52 |
-
*/
|
53 |
-
public $compatibility;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Returns the plugin version
|
57 |
-
*
|
58 |
-
* @return string
|
59 |
-
*/
|
60 |
-
public static function version() {
|
61 |
-
return self::$version;
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Singleton instance
|
66 |
-
*
|
67 |
-
* @return SS_WC_MailChimp_Plugin SS_WC_MailChimp_Plugin object
|
68 |
-
*/
|
69 |
-
public static function get_instance() {
|
70 |
-
|
71 |
-
if ( empty( self::$instance ) && ! ( self::$instance instanceof SS_WC_MailChimp_Plugin ) ) {
|
72 |
-
|
73 |
-
self::$instance = new SS_WC_MailChimp_Plugin();
|
74 |
-
self::$instance->define_constants();
|
75 |
-
|
76 |
-
self::$instance->save_settings();
|
77 |
-
self::$instance->settings();
|
78 |
-
self::$instance->includes();
|
79 |
-
self::$instance->mailchimp();
|
80 |
-
self::$instance->handler = SS_WC_MailChimp_Handler::get_instance();
|
81 |
-
self::$instance->compatibility = SS_WC_MailChimp_Compatibility::get_instance();
|
82 |
-
self::$instance->admin_notices = new SS_WC_MailChimp_Admin_Notices();
|
83 |
-
self::$instance->load_plugin_textdomain();
|
84 |
-
|
85 |
-
self::update();
|
86 |
-
self::$instance->add_hooks();
|
87 |
-
do_action( 'ss_wc_mailchimp_loaded' );
|
88 |
-
|
89 |
-
}
|
90 |
-
|
91 |
-
return self::$instance;
|
92 |
-
|
93 |
-
} //end function instance
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Gets the plugin db settings
|
97 |
-
*
|
98 |
-
* @param boolean $refresh refresh the settings from DB.
|
99 |
-
* @return array The plugin db settings
|
100 |
-
*/
|
101 |
-
public function settings( $refresh = false ) {
|
102 |
-
|
103 |
-
if ( empty( $this->settings ) || true === $refresh ) {
|
104 |
-
|
105 |
-
$defaults = require( SS_WC_MAILCHIMP_DIR . 'config/default-settings.php' );
|
106 |
-
$defaults = apply_filters( 'ss_wc_mailchimp_default_settings', $defaults );
|
107 |
-
$settings = array();
|
108 |
-
|
109 |
-
foreach ( $defaults as $key => $default_value ) {
|
110 |
-
|
111 |
-
$setting_value = get_option( $this->namespace_prefixed( $key ) );
|
112 |
-
|
113 |
-
$settings[ $key ] = $setting_value ? $setting_value : $default_value;
|
114 |
-
}
|
115 |
-
|
116 |
-
$merged_settings = apply_filters( 'ss_wc_mailchimp_settings', array_merge( $defaults, $settings ) );
|
117 |
-
|
118 |
-
$this->settings = $merged_settings;
|
119 |
-
|
120 |
-
$this->mailchimp( $settings['api_key'] );
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
return $this->settings;
|
125 |
-
}
|
126 |
-
|
127 |
-
/**
|
128 |
-
* Returns the api key.
|
129 |
-
*
|
130 |
-
* @return string MailChimp API Key
|
131 |
-
*/
|
132 |
-
public function api_key() {
|
133 |
-
return $this->settings['api_key'];
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* Whether or not the plugin functionality is enabled.
|
138 |
-
*
|
139 |
-
* @access public
|
140 |
-
* @return boolean
|
141 |
-
*/
|
142 |
-
public function is_enabled() {
|
143 |
-
return 'yes' === $this->settings['enabled'];
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Whether or not a main list has been selected.
|
148 |
-
*
|
149 |
-
* @access public
|
150 |
-
* @return boolean
|
151 |
-
*/
|
152 |
-
public function has_list() {
|
153 |
-
$has_list = false;
|
154 |
-
|
155 |
-
if ( $this->get_list() ) {
|
156 |
-
$has_list = true;
|
157 |
-
}
|
158 |
-
return apply_filters( 'ss_wc_mailchimp_has_list', $has_list );
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* When the subscription should be triggered.
|
163 |
-
*
|
164 |
-
* @return string
|
165 |
-
*/
|
166 |
-
public function occurs() {
|
167 |
-
return $this->settings['occurs'];
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Returns the selected list.
|
172 |
-
*
|
173 |
-
* @access public
|
174 |
-
* @return string MailChimp list ID
|
175 |
-
*/
|
176 |
-
public function get_list() {
|
177 |
-
return $this->settings['list'];
|
178 |
-
}
|
179 |
-
|
180 |
-
/**
|
181 |
-
* Whether or not double opt-in is selected.
|
182 |
-
*
|
183 |
-
* @access public
|
184 |
-
* @return boolean
|
185 |
-
*/
|
186 |
-
public function double_opt_in() {
|
187 |
-
return 'yes' === $this->settings['double_opt_in'];
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Whether or not to display opt-in checkbox to user.
|
192 |
-
*
|
193 |
-
* @access public
|
194 |
-
* @return boolean
|
195 |
-
*/
|
196 |
-
public function display_opt_in() {
|
197 |
-
return 'yes' === $this->settings['display_opt_in'];
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Opt-in label.
|
202 |
-
*
|
203 |
-
* @access public
|
204 |
-
* @return string
|
205 |
-
*/
|
206 |
-
public function opt_in_label() {
|
207 |
-
return $this->settings['opt_in_label'];
|
208 |
-
}
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Opt-in checkbox default status.
|
212 |
-
*
|
213 |
-
* @access public
|
214 |
-
* @return string
|
215 |
-
*/
|
216 |
-
public function opt_in_checkbox_default_status() {
|
217 |
-
return $this->settings['opt_in_checkbox_default_status'];
|
218 |
-
}
|
219 |
-
|
220 |
-
/**
|
221 |
-
* Opt-in checkbox display location.
|
222 |
-
*
|
223 |
-
* @access public
|
224 |
-
* @return string
|
225 |
-
*/
|
226 |
-
public function opt_in_checkbox_display_location() {
|
227 |
-
return $this->settings['opt_in_checkbox_display_location'];
|
228 |
-
}
|
229 |
-
|
230 |
-
/**
|
231 |
-
* Returns selected MailChimp interest groups.
|
232 |
-
*
|
233 |
-
* @access public
|
234 |
-
* @return array
|
235 |
-
*/
|
236 |
-
public function interest_groups() {
|
237 |
-
return $this->settings['interest_groups'];
|
238 |
-
}
|
239 |
-
|
240 |
-
/**
|
241 |
-
* Whether or not an api key has been set.
|
242 |
-
*
|
243 |
-
* @access public
|
244 |
-
* @return boolean
|
245 |
-
*/
|
246 |
-
public function has_api_key() {
|
247 |
-
$api_key = $this->api_key();
|
248 |
-
return ! empty( $api_key );
|
249 |
-
}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* Whether or not the configuration is valid.
|
253 |
-
*
|
254 |
-
* @access public
|
255 |
-
* @return boolean
|
256 |
-
*/
|
257 |
-
public function is_valid() {
|
258 |
-
return $this->is_enabled() && $this->has_api_key() && $this->has_list();
|
259 |
-
}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* Whether or not debug is enabled.
|
263 |
-
*
|
264 |
-
* @access public
|
265 |
-
* @return boolean
|
266 |
-
*/
|
267 |
-
public function debug_enabled() {
|
268 |
-
return 'yes' === $this->settings['debug'];
|
269 |
-
}
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Saves the settings back to the DB
|
273 |
-
*
|
274 |
-
* @return void
|
275 |
-
*/
|
276 |
-
public function save_settings() {
|
277 |
-
|
278 |
-
$settings = $this->settings();
|
279 |
-
|
280 |
-
foreach ( $settings as $key => $value ) {
|
281 |
-
update_option( $this->namespace_prefixed( $key ), $value );
|
282 |
-
}
|
283 |
-
|
284 |
-
} //end function save_settings
|
285 |
-
|
286 |
-
/**
|
287 |
-
* Gets the MailChimp Helper
|
288 |
-
*
|
289 |
-
* @param string $api_key MailChimp API Key.
|
290 |
-
* @param boolean $debug Debug mode enabled/disabled.
|
291 |
-
* @return SS_WC_MailChimp MailChimp Helper class
|
292 |
-
*/
|
293 |
-
public function mailchimp( $api_key = null, $debug = false ) {
|
294 |
-
|
295 |
-
$settings = $this->settings();
|
296 |
-
|
297 |
-
if ( empty( $this->mailchimp ) || ! is_null( $api_key ) ) {
|
298 |
-
|
299 |
-
$api_key = $api_key ? $api_key : $settings['api_key'];
|
300 |
-
$debug = $debug ? $debug : $settings['debug'];
|
301 |
-
|
302 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
303 |
-
$this->mailchimp = new SS_WC_MailChimp( $api_key, $debug );
|
304 |
-
|
305 |
-
delete_transient( 'sswcmc_lists' );
|
306 |
-
}
|
307 |
-
|
308 |
-
return $this->mailchimp;
|
309 |
-
|
310 |
-
} //end function mailchimp
|
311 |
-
|
312 |
-
/**
|
313 |
-
* Define Plugin Constants.
|
314 |
-
*/
|
315 |
-
private function define_constants() {
|
316 |
-
|
317 |
-
// Minimum supported version of WordPress.
|
318 |
-
$this->define( 'SS_WC_MAILCHIMP_MIN_WP_VERSION', '3.5.1' );
|
319 |
-
|
320 |
-
// Minimum supported version of WooCommerce.
|
321 |
-
$this->define( 'SS_WC_MAILCHIMP_MIN_WC_VERSION', '2.2.0' );
|
322 |
-
|
323 |
-
// Minimum supported version of PHP.
|
324 |
-
$this->define( 'SS_WC_MAILCHIMP_MIN_PHP_VERSION', '5.4.0' );
|
325 |
-
|
326 |
-
// Plugin version.
|
327 |
-
$this->define( 'SS_WC_MAILCHIMP_VERSION', self::version() );
|
328 |
-
|
329 |
-
// Plugin Folder Path.
|
330 |
-
$this->define( 'SS_WC_MAILCHIMP_DIR', plugin_dir_path( SS_WC_MAILCHIMP_FILE ) );
|
331 |
-
|
332 |
-
// Plugin Folder URL.
|
333 |
-
$this->define( 'SS_WC_MAILCHIMP_URL', plugin_dir_url( SS_WC_MAILCHIMP_FILE ) );
|
334 |
-
|
335 |
-
$settings_url = admin_url( 'admin.php?page=wc-settings&tab=mailchimp' );
|
336 |
-
|
337 |
-
$this->define( 'SS_WC_MAILCHIMP_SETTINGS_URL', $settings_url );
|
338 |
-
|
339 |
-
} //function define_constants
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Define constant if not already set.
|
343 |
-
*
|
344 |
-
* @param string $name Constant name.
|
345 |
-
* @param string|bool $value Constant value.
|
346 |
-
* @return void
|
347 |
-
*/
|
348 |
-
private function define( $name, $value ) {
|
349 |
-
if ( ! defined( $name ) ) {
|
350 |
-
define( $name, $value );
|
351 |
-
}
|
352 |
-
} //function define
|
353 |
-
|
354 |
-
/**
|
355 |
-
* Include required core plugin files
|
356 |
-
*
|
357 |
-
* @return void
|
358 |
-
*/
|
359 |
-
public function includes() {
|
360 |
-
|
361 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/lib/class-ss-system-info.php' );
|
362 |
-
|
363 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/helper-functions.php' );
|
364 |
-
|
365 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-compatibility.php' );
|
366 |
-
|
367 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-admin-notices.php' );
|
368 |
-
|
369 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-api.php' );
|
370 |
-
|
371 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
372 |
-
|
373 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-handler.php' );
|
374 |
-
|
375 |
-
} //end function includes
|
376 |
-
|
377 |
-
/**
|
378 |
-
* Add plugin hooks
|
379 |
-
*
|
380 |
-
* @return void
|
381 |
-
*/
|
382 |
-
private function add_hooks() {
|
383 |
-
|
384 |
-
/** Register hooks that are fired when the plugin is activated and deactivated. */
|
385 |
-
register_activation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'activate' ) );
|
386 |
-
register_deactivation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'deactivate' ) );
|
387 |
-
|
388 |
-
// Add the "Settings" links on the Plugins administration screen.
|
389 |
-
if ( is_admin() ) {
|
390 |
-
|
391 |
-
add_filter( 'plugin_action_links_' . plugin_basename( SS_WC_MAILCHIMP_FILE ), array( $this, 'action_links' ) );
|
392 |
-
|
393 |
-
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_mailchimp_settings' ) );
|
394 |
-
|
395 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
396 |
-
|
397 |
-
}
|
398 |
-
|
399 |
-
} //end function add_hooks
|
400 |
-
|
401 |
-
/**
|
402 |
-
* Load Localization files.
|
403 |
-
*
|
404 |
-
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
|
405 |
-
*
|
406 |
-
* Locales found in:
|
407 |
-
* - WP_LANG_DIR/plugins/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
408 |
-
* - WP_CONTENT_DIR/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp-{lang}_{country}.mo
|
409 |
-
*
|
410 |
-
* @return void
|
411 |
-
*/
|
412 |
-
public function load_plugin_textdomain() {
|
413 |
-
|
414 |
-
// Set filter for plugin's languages directory.
|
415 |
-
$woocommerce_mailchimp_lang_dir = dirname( plugin_basename( SS_WC_MAILCHIMP_FILE ) ) . '/languages/';
|
416 |
-
|
417 |
-
// Traditional WordPress plugin locale filter.
|
418 |
-
// get locale in {lang}_{country} format (e.g. en_US).
|
419 |
-
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-mailchimp' );
|
420 |
-
|
421 |
-
$mofile = sprintf( '%1$s-%2$s.mo', 'woocommerce-mailchimp', $locale );
|
422 |
-
|
423 |
-
// Look for wp-content/languages/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
424 |
-
$mofile_global1 = WP_LANG_DIR . '/woocommerce-mailchimp/' . $mofile;
|
425 |
-
|
426 |
-
// Look in wp-content/languages/plugins/woocommerce-mailchimp
|
427 |
-
$mofile_global2 = WP_LANG_DIR . '/plugins/woocommerce-mailchimp/' . $mofile;
|
428 |
-
|
429 |
-
if ( file_exists( $mofile_global1 ) ) {
|
430 |
-
|
431 |
-
load_textdomain( 'woocommerce-mailchimp', $mofile_global1 );
|
432 |
-
|
433 |
-
} elseif ( file_exists( $mofile_global2 ) ) {
|
434 |
-
|
435 |
-
load_textdomain( 'woocommerce-mailchimp', $mofile_global2 );
|
436 |
-
|
437 |
-
} else {
|
438 |
-
|
439 |
-
// Load the default language files.
|
440 |
-
load_plugin_textdomain( 'woocommerce-mailchimp', false, $woocommerce_mailchimp_lang_dir );
|
441 |
-
|
442 |
-
}
|
443 |
-
|
444 |
-
} //end function load_plugin_textdomain
|
445 |
-
|
446 |
-
/**
|
447 |
-
* Add Settings link to plugins list
|
448 |
-
*
|
449 |
-
* @param array $links Plugin links.
|
450 |
-
* @return array Modified plugin links
|
451 |
-
*/
|
452 |
-
public function action_links( $links ) {
|
453 |
-
$plugin_links = array(
|
454 |
-
'<a href="' . SS_WC_MAILCHIMP_SETTINGS_URL . '">' . __( 'Settings', 'woocommerce-mailchimp' ) . '</a>',
|
455 |
-
);
|
456 |
-
|
457 |
-
return array_merge( $plugin_links, $links );
|
458 |
-
|
459 |
-
} //end function action_links
|
460 |
-
|
461 |
-
/**
|
462 |
-
* Add the MailChimp settings tab to WooCommerce
|
463 |
-
*
|
464 |
-
* @param array $settings MailChimp settings.
|
465 |
-
* @return array Settings.
|
466 |
-
*/
|
467 |
-
function add_mailchimp_settings( $settings ) {
|
468 |
-
|
469 |
-
if ( ! is_array( $settings ) ) {
|
470 |
-
$settings = array();
|
471 |
-
}
|
472 |
-
|
473 |
-
$settings[] = require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-settings-mailchimp.php' );
|
474 |
-
|
475 |
-
return $settings;
|
476 |
-
|
477 |
-
} //end function add_mailchimp_settings
|
478 |
-
|
479 |
-
/**
|
480 |
-
* Load scripts required for admin
|
481 |
-
*
|
482 |
-
* @access public
|
483 |
-
* @return void
|
484 |
-
*/
|
485 |
-
public function enqueue_scripts() {
|
486 |
-
|
487 |
-
// Plugin scripts and styles.
|
488 |
-
wp_register_script( 'woocommerce-mailchimp-admin', SS_WC_MAILCHIMP_URL . 'assets/js/woocommerce-mailchimp-admin.js', array( 'jquery' ), self::version() );
|
489 |
-
wp_register_style( 'woocommerce-mailchimp', SS_WC_MAILCHIMP_URL . 'assets/css/style.css', array(), self::version() );
|
490 |
-
|
491 |
-
// Localize javascript messages.
|
492 |
-
$translation_array = array(
|
493 |
-
'connecting_to_mailchimp' => __( 'Connecting to MailChimp', 'woocommerce-mailchimp' ),
|
494 |
-
'error_loading_account' => __( 'Error. Please check your api key.', 'woocommerce-mailchimp' ),
|
495 |
-
'error_loading_groups' => __( 'Error loading groups. Please check your MailChimp Interest Groups for the selected list.', 'woocommerce-mailchimp' ),
|
496 |
-
'select_groups_placeholder' => __( 'Select one or more groups (optional)', 'woocommerce-mailchimp' ),
|
497 |
-
'interest_groups_not_enabled' => __( 'This list does not have interest groups enabled', 'woocommerce-mailchimp' ),
|
498 |
-
);
|
499 |
-
wp_localize_script( 'woocommerce-mailchimp-admin', 'SS_WC_MailChimp_Messages', $translation_array );
|
500 |
-
|
501 |
-
// Scripts.
|
502 |
-
wp_enqueue_script( 'woocommerce-mailchimp-admin' );
|
503 |
-
|
504 |
-
// Styles.
|
505 |
-
wp_enqueue_style( 'woocommerce-mailchimp' );
|
506 |
-
|
507 |
-
} //end function enqueue_scripts
|
508 |
-
|
509 |
-
/**
|
510 |
-
* Handles running plugin upgrades if necessary
|
511 |
-
*
|
512 |
-
* @return void
|
513 |
-
*/
|
514 |
-
public static function update() {
|
515 |
-
|
516 |
-
require_once( 'class-ss-wc-mailchimp-migrator.php' );
|
517 |
-
|
518 |
-
SS_WC_MailChimp_Migrator::migrate( self::version() );
|
519 |
-
|
520 |
-
} //end function update
|
521 |
-
|
522 |
-
/**
|
523 |
-
* Plugin activate function.
|
524 |
-
*
|
525 |
-
* @access public
|
526 |
-
* @static
|
527 |
-
* @param mixed $network_wide Network activate.
|
528 |
-
* @return void
|
529 |
-
*/
|
530 |
-
public static function activate( $network_wide = false ) {
|
531 |
-
|
532 |
-
self::update();
|
533 |
-
|
534 |
-
} //end function activate
|
535 |
-
|
536 |
-
/**
|
537 |
-
* Plugin deactivate function.
|
538 |
-
*
|
539 |
-
* @access public
|
540 |
-
* @static
|
541 |
-
* @param mixed $network_wide Network activate.
|
542 |
-
* @return void
|
543 |
-
*/
|
544 |
-
public static function deactivate( $network_wide ) {
|
545 |
-
|
546 |
-
// Placeholder.
|
547 |
-
|
548 |
-
} //end function deactivate
|
549 |
-
|
550 |
-
/**
|
551 |
-
* Check whether WooCommerce MailChimp is network activated
|
552 |
-
*
|
553 |
-
* @since 1.0
|
554 |
-
* @return bool
|
555 |
-
*/
|
556 |
-
public static function is_network_activated() {
|
557 |
-
return is_multisite() && ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'woocommerce-mailchimp/woocommerce-mailchimp.php' ) );
|
558 |
-
}
|
559 |
-
|
560 |
-
/**
|
561 |
-
* Returns namespace prefixed value
|
562 |
-
*
|
563 |
-
* @param string $suffix The suffix to prefix.
|
564 |
-
* @return string
|
565 |
-
*/
|
566 |
-
private function namespace_prefixed( $suffix ) {
|
567 |
-
|
568 |
-
return $this->namespace . '_' . $suffix;
|
569 |
-
|
570 |
-
} // end function namespace_prefixed
|
571 |
-
|
572 |
-
} //end final class SS_WC_MailChimp_Plugin
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Main Plugin Class
|
4 |
+
*
|
5 |
+
* @package WooCommerce MailChimp
|
6 |
+
*/
|
7 |
+
|
8 |
+
/**
|
9 |
+
* WooCommerce MailChimp plugin main class
|
10 |
+
*/
|
11 |
+
final class SS_WC_MailChimp_Plugin {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Plugin version
|
15 |
+
*
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
private static $version = '2.1.10';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Plugin singleton instance
|
22 |
+
*
|
23 |
+
* @var SS_WC_MailChimp_Plugin
|
24 |
+
*/
|
25 |
+
private static $instance;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Plugin namespace
|
29 |
+
*
|
30 |
+
* @var string
|
31 |
+
*/
|
32 |
+
private $namespace = 'ss_wc_mailchimp';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Plugin settings
|
36 |
+
*
|
37 |
+
* @var array
|
38 |
+
*/
|
39 |
+
private $settings;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Plugin MailChimp helper instance
|
43 |
+
*
|
44 |
+
* @var SS_WC_MailChimp
|
45 |
+
*/
|
46 |
+
private $mailchimp;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Plugin compatibility checker
|
50 |
+
*
|
51 |
+
* @var SS_WC_MailChimp_Compatibility
|
52 |
+
*/
|
53 |
+
public $compatibility;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Returns the plugin version
|
57 |
+
*
|
58 |
+
* @return string
|
59 |
+
*/
|
60 |
+
public static function version() {
|
61 |
+
return self::$version;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Singleton instance
|
66 |
+
*
|
67 |
+
* @return SS_WC_MailChimp_Plugin SS_WC_MailChimp_Plugin object
|
68 |
+
*/
|
69 |
+
public static function get_instance() {
|
70 |
+
|
71 |
+
if ( empty( self::$instance ) && ! ( self::$instance instanceof SS_WC_MailChimp_Plugin ) ) {
|
72 |
+
|
73 |
+
self::$instance = new SS_WC_MailChimp_Plugin();
|
74 |
+
self::$instance->define_constants();
|
75 |
+
|
76 |
+
self::$instance->save_settings();
|
77 |
+
self::$instance->settings();
|
78 |
+
self::$instance->includes();
|
79 |
+
self::$instance->mailchimp();
|
80 |
+
self::$instance->handler = SS_WC_MailChimp_Handler::get_instance();
|
81 |
+
self::$instance->compatibility = SS_WC_MailChimp_Compatibility::get_instance();
|
82 |
+
self::$instance->admin_notices = new SS_WC_MailChimp_Admin_Notices();
|
83 |
+
self::$instance->load_plugin_textdomain();
|
84 |
+
|
85 |
+
self::update();
|
86 |
+
self::$instance->add_hooks();
|
87 |
+
do_action( 'ss_wc_mailchimp_loaded' );
|
88 |
+
|
89 |
+
}
|
90 |
+
|
91 |
+
return self::$instance;
|
92 |
+
|
93 |
+
} //end function instance
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Gets the plugin db settings
|
97 |
+
*
|
98 |
+
* @param boolean $refresh refresh the settings from DB.
|
99 |
+
* @return array The plugin db settings
|
100 |
+
*/
|
101 |
+
public function settings( $refresh = false ) {
|
102 |
+
|
103 |
+
if ( empty( $this->settings ) || true === $refresh ) {
|
104 |
+
|
105 |
+
$defaults = require( SS_WC_MAILCHIMP_DIR . 'config/default-settings.php' );
|
106 |
+
$defaults = apply_filters( 'ss_wc_mailchimp_default_settings', $defaults );
|
107 |
+
$settings = array();
|
108 |
+
|
109 |
+
foreach ( $defaults as $key => $default_value ) {
|
110 |
+
|
111 |
+
$setting_value = get_option( $this->namespace_prefixed( $key ) );
|
112 |
+
|
113 |
+
$settings[ $key ] = $setting_value ? $setting_value : $default_value;
|
114 |
+
}
|
115 |
+
|
116 |
+
$merged_settings = apply_filters( 'ss_wc_mailchimp_settings', array_merge( $defaults, $settings ) );
|
117 |
+
|
118 |
+
$this->settings = $merged_settings;
|
119 |
+
|
120 |
+
$this->mailchimp( $settings['api_key'] );
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
return $this->settings;
|
125 |
+
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Returns the api key.
|
129 |
+
*
|
130 |
+
* @return string MailChimp API Key
|
131 |
+
*/
|
132 |
+
public function api_key() {
|
133 |
+
return $this->settings['api_key'];
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Whether or not the plugin functionality is enabled.
|
138 |
+
*
|
139 |
+
* @access public
|
140 |
+
* @return boolean
|
141 |
+
*/
|
142 |
+
public function is_enabled() {
|
143 |
+
return 'yes' === $this->settings['enabled'];
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Whether or not a main list has been selected.
|
148 |
+
*
|
149 |
+
* @access public
|
150 |
+
* @return boolean
|
151 |
+
*/
|
152 |
+
public function has_list() {
|
153 |
+
$has_list = false;
|
154 |
+
|
155 |
+
if ( $this->get_list() ) {
|
156 |
+
$has_list = true;
|
157 |
+
}
|
158 |
+
return apply_filters( 'ss_wc_mailchimp_has_list', $has_list );
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* When the subscription should be triggered.
|
163 |
+
*
|
164 |
+
* @return string
|
165 |
+
*/
|
166 |
+
public function occurs() {
|
167 |
+
return $this->settings['occurs'];
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Returns the selected list.
|
172 |
+
*
|
173 |
+
* @access public
|
174 |
+
* @return string MailChimp list ID
|
175 |
+
*/
|
176 |
+
public function get_list() {
|
177 |
+
return $this->settings['list'];
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Whether or not double opt-in is selected.
|
182 |
+
*
|
183 |
+
* @access public
|
184 |
+
* @return boolean
|
185 |
+
*/
|
186 |
+
public function double_opt_in() {
|
187 |
+
return 'yes' === $this->settings['double_opt_in'];
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Whether or not to display opt-in checkbox to user.
|
192 |
+
*
|
193 |
+
* @access public
|
194 |
+
* @return boolean
|
195 |
+
*/
|
196 |
+
public function display_opt_in() {
|
197 |
+
return 'yes' === $this->settings['display_opt_in'];
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Opt-in label.
|
202 |
+
*
|
203 |
+
* @access public
|
204 |
+
* @return string
|
205 |
+
*/
|
206 |
+
public function opt_in_label() {
|
207 |
+
return $this->settings['opt_in_label'];
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Opt-in checkbox default status.
|
212 |
+
*
|
213 |
+
* @access public
|
214 |
+
* @return string
|
215 |
+
*/
|
216 |
+
public function opt_in_checkbox_default_status() {
|
217 |
+
return $this->settings['opt_in_checkbox_default_status'];
|
218 |
+
}
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Opt-in checkbox display location.
|
222 |
+
*
|
223 |
+
* @access public
|
224 |
+
* @return string
|
225 |
+
*/
|
226 |
+
public function opt_in_checkbox_display_location() {
|
227 |
+
return $this->settings['opt_in_checkbox_display_location'];
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Returns selected MailChimp interest groups.
|
232 |
+
*
|
233 |
+
* @access public
|
234 |
+
* @return array
|
235 |
+
*/
|
236 |
+
public function interest_groups() {
|
237 |
+
return $this->settings['interest_groups'];
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Whether or not an api key has been set.
|
242 |
+
*
|
243 |
+
* @access public
|
244 |
+
* @return boolean
|
245 |
+
*/
|
246 |
+
public function has_api_key() {
|
247 |
+
$api_key = $this->api_key();
|
248 |
+
return ! empty( $api_key );
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* Whether or not the configuration is valid.
|
253 |
+
*
|
254 |
+
* @access public
|
255 |
+
* @return boolean
|
256 |
+
*/
|
257 |
+
public function is_valid() {
|
258 |
+
return $this->is_enabled() && $this->has_api_key() && $this->has_list();
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Whether or not debug is enabled.
|
263 |
+
*
|
264 |
+
* @access public
|
265 |
+
* @return boolean
|
266 |
+
*/
|
267 |
+
public function debug_enabled() {
|
268 |
+
return 'yes' === $this->settings['debug'];
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Saves the settings back to the DB
|
273 |
+
*
|
274 |
+
* @return void
|
275 |
+
*/
|
276 |
+
public function save_settings() {
|
277 |
+
|
278 |
+
$settings = $this->settings();
|
279 |
+
|
280 |
+
foreach ( $settings as $key => $value ) {
|
281 |
+
update_option( $this->namespace_prefixed( $key ), $value );
|
282 |
+
}
|
283 |
+
|
284 |
+
} //end function save_settings
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Gets the MailChimp Helper
|
288 |
+
*
|
289 |
+
* @param string $api_key MailChimp API Key.
|
290 |
+
* @param boolean $debug Debug mode enabled/disabled.
|
291 |
+
* @return SS_WC_MailChimp MailChimp Helper class
|
292 |
+
*/
|
293 |
+
public function mailchimp( $api_key = null, $debug = false ) {
|
294 |
+
|
295 |
+
$settings = $this->settings();
|
296 |
+
|
297 |
+
if ( empty( $this->mailchimp ) || ! is_null( $api_key ) ) {
|
298 |
+
|
299 |
+
$api_key = $api_key ? $api_key : $settings['api_key'];
|
300 |
+
$debug = $debug ? $debug : $settings['debug'];
|
301 |
+
|
302 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
303 |
+
$this->mailchimp = new SS_WC_MailChimp( $api_key, $debug );
|
304 |
+
|
305 |
+
delete_transient( 'sswcmc_lists' );
|
306 |
+
}
|
307 |
+
|
308 |
+
return $this->mailchimp;
|
309 |
+
|
310 |
+
} //end function mailchimp
|
311 |
+
|
312 |
+
/**
|
313 |
+
* Define Plugin Constants.
|
314 |
+
*/
|
315 |
+
private function define_constants() {
|
316 |
+
|
317 |
+
// Minimum supported version of WordPress.
|
318 |
+
$this->define( 'SS_WC_MAILCHIMP_MIN_WP_VERSION', '3.5.1' );
|
319 |
+
|
320 |
+
// Minimum supported version of WooCommerce.
|
321 |
+
$this->define( 'SS_WC_MAILCHIMP_MIN_WC_VERSION', '2.2.0' );
|
322 |
+
|
323 |
+
// Minimum supported version of PHP.
|
324 |
+
$this->define( 'SS_WC_MAILCHIMP_MIN_PHP_VERSION', '5.4.0' );
|
325 |
+
|
326 |
+
// Plugin version.
|
327 |
+
$this->define( 'SS_WC_MAILCHIMP_VERSION', self::version() );
|
328 |
+
|
329 |
+
// Plugin Folder Path.
|
330 |
+
$this->define( 'SS_WC_MAILCHIMP_DIR', plugin_dir_path( SS_WC_MAILCHIMP_FILE ) );
|
331 |
+
|
332 |
+
// Plugin Folder URL.
|
333 |
+
$this->define( 'SS_WC_MAILCHIMP_URL', plugin_dir_url( SS_WC_MAILCHIMP_FILE ) );
|
334 |
+
|
335 |
+
$settings_url = admin_url( 'admin.php?page=wc-settings&tab=mailchimp' );
|
336 |
+
|
337 |
+
$this->define( 'SS_WC_MAILCHIMP_SETTINGS_URL', $settings_url );
|
338 |
+
|
339 |
+
} //function define_constants
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Define constant if not already set.
|
343 |
+
*
|
344 |
+
* @param string $name Constant name.
|
345 |
+
* @param string|bool $value Constant value.
|
346 |
+
* @return void
|
347 |
+
*/
|
348 |
+
private function define( $name, $value ) {
|
349 |
+
if ( ! defined( $name ) ) {
|
350 |
+
define( $name, $value );
|
351 |
+
}
|
352 |
+
} //function define
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Include required core plugin files
|
356 |
+
*
|
357 |
+
* @return void
|
358 |
+
*/
|
359 |
+
public function includes() {
|
360 |
+
|
361 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/lib/class-ss-system-info.php' );
|
362 |
+
|
363 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/helper-functions.php' );
|
364 |
+
|
365 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-compatibility.php' );
|
366 |
+
|
367 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-admin-notices.php' );
|
368 |
+
|
369 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-api.php' );
|
370 |
+
|
371 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
372 |
+
|
373 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-handler.php' );
|
374 |
+
|
375 |
+
} //end function includes
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Add plugin hooks
|
379 |
+
*
|
380 |
+
* @return void
|
381 |
+
*/
|
382 |
+
private function add_hooks() {
|
383 |
+
|
384 |
+
/** Register hooks that are fired when the plugin is activated and deactivated. */
|
385 |
+
register_activation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'activate' ) );
|
386 |
+
register_deactivation_hook( SS_WC_MAILCHIMP_FILE, array( __CLASS__, 'deactivate' ) );
|
387 |
+
|
388 |
+
// Add the "Settings" links on the Plugins administration screen.
|
389 |
+
if ( is_admin() ) {
|
390 |
+
|
391 |
+
add_filter( 'plugin_action_links_' . plugin_basename( SS_WC_MAILCHIMP_FILE ), array( $this, 'action_links' ) );
|
392 |
+
|
393 |
+
add_filter( 'woocommerce_get_settings_pages', array( $this, 'add_mailchimp_settings' ) );
|
394 |
+
|
395 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
396 |
+
|
397 |
+
}
|
398 |
+
|
399 |
+
} //end function add_hooks
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Load Localization files.
|
403 |
+
*
|
404 |
+
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
|
405 |
+
*
|
406 |
+
* Locales found in:
|
407 |
+
* - WP_LANG_DIR/plugins/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
408 |
+
* - WP_CONTENT_DIR/plugins/woocommerce-mailchimp/languages/woocommerce-mailchimp-{lang}_{country}.mo
|
409 |
+
*
|
410 |
+
* @return void
|
411 |
+
*/
|
412 |
+
public function load_plugin_textdomain() {
|
413 |
+
|
414 |
+
// Set filter for plugin's languages directory.
|
415 |
+
$woocommerce_mailchimp_lang_dir = dirname( plugin_basename( SS_WC_MAILCHIMP_FILE ) ) . '/languages/';
|
416 |
+
|
417 |
+
// Traditional WordPress plugin locale filter.
|
418 |
+
// get locale in {lang}_{country} format (e.g. en_US).
|
419 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-mailchimp' );
|
420 |
+
|
421 |
+
$mofile = sprintf( '%1$s-%2$s.mo', 'woocommerce-mailchimp', $locale );
|
422 |
+
|
423 |
+
// Look for wp-content/languages/woocommerce-mailchimp/woocommerce-mailchimp-{lang}_{country}.mo
|
424 |
+
$mofile_global1 = WP_LANG_DIR . '/woocommerce-mailchimp/' . $mofile;
|
425 |
+
|
426 |
+
// Look in wp-content/languages/plugins/woocommerce-mailchimp
|
427 |
+
$mofile_global2 = WP_LANG_DIR . '/plugins/woocommerce-mailchimp/' . $mofile;
|
428 |
+
|
429 |
+
if ( file_exists( $mofile_global1 ) ) {
|
430 |
+
|
431 |
+
load_textdomain( 'woocommerce-mailchimp', $mofile_global1 );
|
432 |
+
|
433 |
+
} elseif ( file_exists( $mofile_global2 ) ) {
|
434 |
+
|
435 |
+
load_textdomain( 'woocommerce-mailchimp', $mofile_global2 );
|
436 |
+
|
437 |
+
} else {
|
438 |
+
|
439 |
+
// Load the default language files.
|
440 |
+
load_plugin_textdomain( 'woocommerce-mailchimp', false, $woocommerce_mailchimp_lang_dir );
|
441 |
+
|
442 |
+
}
|
443 |
+
|
444 |
+
} //end function load_plugin_textdomain
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Add Settings link to plugins list
|
448 |
+
*
|
449 |
+
* @param array $links Plugin links.
|
450 |
+
* @return array Modified plugin links
|
451 |
+
*/
|
452 |
+
public function action_links( $links ) {
|
453 |
+
$plugin_links = array(
|
454 |
+
'<a href="' . SS_WC_MAILCHIMP_SETTINGS_URL . '">' . __( 'Settings', 'woocommerce-mailchimp' ) . '</a>',
|
455 |
+
);
|
456 |
+
|
457 |
+
return array_merge( $plugin_links, $links );
|
458 |
+
|
459 |
+
} //end function action_links
|
460 |
+
|
461 |
+
/**
|
462 |
+
* Add the MailChimp settings tab to WooCommerce
|
463 |
+
*
|
464 |
+
* @param array $settings MailChimp settings.
|
465 |
+
* @return array Settings.
|
466 |
+
*/
|
467 |
+
function add_mailchimp_settings( $settings ) {
|
468 |
+
|
469 |
+
if ( ! is_array( $settings ) ) {
|
470 |
+
$settings = array();
|
471 |
+
}
|
472 |
+
|
473 |
+
$settings[] = require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-settings-mailchimp.php' );
|
474 |
+
|
475 |
+
return $settings;
|
476 |
+
|
477 |
+
} //end function add_mailchimp_settings
|
478 |
+
|
479 |
+
/**
|
480 |
+
* Load scripts required for admin
|
481 |
+
*
|
482 |
+
* @access public
|
483 |
+
* @return void
|
484 |
+
*/
|
485 |
+
public function enqueue_scripts() {
|
486 |
+
|
487 |
+
// Plugin scripts and styles.
|
488 |
+
wp_register_script( 'woocommerce-mailchimp-admin', SS_WC_MAILCHIMP_URL . 'assets/js/woocommerce-mailchimp-admin.js', array( 'jquery' ), self::version() );
|
489 |
+
wp_register_style( 'woocommerce-mailchimp', SS_WC_MAILCHIMP_URL . 'assets/css/style.css', array(), self::version() );
|
490 |
+
|
491 |
+
// Localize javascript messages.
|
492 |
+
$translation_array = array(
|
493 |
+
'connecting_to_mailchimp' => __( 'Connecting to MailChimp', 'woocommerce-mailchimp' ),
|
494 |
+
'error_loading_account' => __( 'Error. Please check your api key.', 'woocommerce-mailchimp' ),
|
495 |
+
'error_loading_groups' => __( 'Error loading groups. Please check your MailChimp Interest Groups for the selected list.', 'woocommerce-mailchimp' ),
|
496 |
+
'select_groups_placeholder' => __( 'Select one or more groups (optional)', 'woocommerce-mailchimp' ),
|
497 |
+
'interest_groups_not_enabled' => __( 'This list does not have interest groups enabled', 'woocommerce-mailchimp' ),
|
498 |
+
);
|
499 |
+
wp_localize_script( 'woocommerce-mailchimp-admin', 'SS_WC_MailChimp_Messages', $translation_array );
|
500 |
+
|
501 |
+
// Scripts.
|
502 |
+
wp_enqueue_script( 'woocommerce-mailchimp-admin' );
|
503 |
+
|
504 |
+
// Styles.
|
505 |
+
wp_enqueue_style( 'woocommerce-mailchimp' );
|
506 |
+
|
507 |
+
} //end function enqueue_scripts
|
508 |
+
|
509 |
+
/**
|
510 |
+
* Handles running plugin upgrades if necessary
|
511 |
+
*
|
512 |
+
* @return void
|
513 |
+
*/
|
514 |
+
public static function update() {
|
515 |
+
|
516 |
+
require_once( 'class-ss-wc-mailchimp-migrator.php' );
|
517 |
+
|
518 |
+
SS_WC_MailChimp_Migrator::migrate( self::version() );
|
519 |
+
|
520 |
+
} //end function update
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Plugin activate function.
|
524 |
+
*
|
525 |
+
* @access public
|
526 |
+
* @static
|
527 |
+
* @param mixed $network_wide Network activate.
|
528 |
+
* @return void
|
529 |
+
*/
|
530 |
+
public static function activate( $network_wide = false ) {
|
531 |
+
|
532 |
+
self::update();
|
533 |
+
|
534 |
+
} //end function activate
|
535 |
+
|
536 |
+
/**
|
537 |
+
* Plugin deactivate function.
|
538 |
+
*
|
539 |
+
* @access public
|
540 |
+
* @static
|
541 |
+
* @param mixed $network_wide Network activate.
|
542 |
+
* @return void
|
543 |
+
*/
|
544 |
+
public static function deactivate( $network_wide ) {
|
545 |
+
|
546 |
+
// Placeholder.
|
547 |
+
|
548 |
+
} //end function deactivate
|
549 |
+
|
550 |
+
/**
|
551 |
+
* Check whether WooCommerce MailChimp is network activated
|
552 |
+
*
|
553 |
+
* @since 1.0
|
554 |
+
* @return bool
|
555 |
+
*/
|
556 |
+
public static function is_network_activated() {
|
557 |
+
return is_multisite() && ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'woocommerce-mailchimp/woocommerce-mailchimp.php' ) );
|
558 |
+
}
|
559 |
+
|
560 |
+
/**
|
561 |
+
* Returns namespace prefixed value
|
562 |
+
*
|
563 |
+
* @param string $suffix The suffix to prefix.
|
564 |
+
* @return string
|
565 |
+
*/
|
566 |
+
private function namespace_prefixed( $suffix ) {
|
567 |
+
|
568 |
+
return $this->namespace . '_' . $suffix;
|
569 |
+
|
570 |
+
} // end function namespace_prefixed
|
571 |
+
|
572 |
+
} //end final class SS_WC_MailChimp_Plugin
|
includes/class-ss-wc-mailchimp.php
CHANGED
@@ -1,399 +1,399 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Minimal MailChimp helper
|
7 |
-
*
|
8 |
-
* @class SS_WC_MailChimp
|
9 |
-
* @version 2.0
|
10 |
-
* @package WooCommerce MailChimp
|
11 |
-
* @author Saint Systems
|
12 |
-
*/
|
13 |
-
class SS_WC_MailChimp {
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @var SS_WC_MailChimp_API
|
17 |
-
*/
|
18 |
-
public $api;
|
19 |
-
|
20 |
-
public $api_key;
|
21 |
-
|
22 |
-
public $debug;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Create a new instance
|
26 |
-
* @param string $api_key MailChimp API key
|
27 |
-
*/
|
28 |
-
function __construct( $api_key, $debug = false ) {
|
29 |
-
|
30 |
-
$this->api_key = $api_key;
|
31 |
-
|
32 |
-
$this->debug = $debug;
|
33 |
-
|
34 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-api.php' );
|
35 |
-
$this->api = new SS_WC_MailChimp_API( $api_key, $debug );
|
36 |
-
|
37 |
-
} //end function __construct
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Get account
|
41 |
-
*
|
42 |
-
* @access public
|
43 |
-
* @return mixed
|
44 |
-
*/
|
45 |
-
public function get_account( $api_key = null ) {
|
46 |
-
|
47 |
-
$resource = '';
|
48 |
-
|
49 |
-
$api = $this->api;
|
50 |
-
|
51 |
-
if ( ! empty( $api_key ) ) {
|
52 |
-
$api = new SS_WC_MailChimp_API( $api_key, $this->debug );
|
53 |
-
}
|
54 |
-
|
55 |
-
$account = $api->get( $resource );
|
56 |
-
|
57 |
-
if ( ! $account ) {
|
58 |
-
$last_response = $api->get_last_response();
|
59 |
-
if (floor( $last_response['response']['code'] ) / 100 >= 4) {
|
60 |
-
$body = $last_response['body'];
|
61 |
-
$errorMessage = $last_response['response']['code'] . ' ' . $last_response['response']['message'];
|
62 |
-
if (preg_match("'<h1>(.*)</h1>'si", $body, $matches)) {
|
63 |
-
$errorMessage .= '<br/>' . $matches[1] . ': ';
|
64 |
-
}
|
65 |
-
if (preg_match("'<p>(.*)</p>'si", $body, $matches)) {
|
66 |
-
$errorMessage .= $matches[1];
|
67 |
-
}
|
68 |
-
return array(
|
69 |
-
'error' => $errorMessage
|
70 |
-
);
|
71 |
-
}
|
72 |
-
return false;
|
73 |
-
}
|
74 |
-
|
75 |
-
return $account;
|
76 |
-
|
77 |
-
} //end function get_account
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Get list
|
81 |
-
*
|
82 |
-
* @access public
|
83 |
-
* @return mixed
|
84 |
-
*/
|
85 |
-
public function get_lists( $args = array() ) {
|
86 |
-
|
87 |
-
if ( ! $results = get_transient( 'sswcmc_lists' ) ) {
|
88 |
-
|
89 |
-
$resource = 'lists';
|
90 |
-
|
91 |
-
if ( ! array_key_exists( 'count', $args ) ) {
|
92 |
-
$args['count'] = 100;
|
93 |
-
}
|
94 |
-
|
95 |
-
$response = $this->api->get( $resource, $args );
|
96 |
-
|
97 |
-
if ( ! $response ) {
|
98 |
-
return false;
|
99 |
-
}
|
100 |
-
|
101 |
-
$lists = $response['lists'];
|
102 |
-
|
103 |
-
$results = array();
|
104 |
-
|
105 |
-
foreach ( $lists as $list ) {
|
106 |
-
|
107 |
-
$results[ (string)$list['id'] ] = $list['name'];
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
set_transient( 'sswcmc_lists', $results, 60*15*1 );
|
112 |
-
|
113 |
-
}
|
114 |
-
|
115 |
-
return $results;
|
116 |
-
|
117 |
-
} //end function get_lists
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Get Subscriber
|
121 |
-
* @param string $list_id The MailChimp list ID
|
122 |
-
* @param string $email_address The user's email address
|
123 |
-
* @return string The status of the subscriber
|
124 |
-
*/
|
125 |
-
public function get_subscriber_status( $list_id, $email_address ) {
|
126 |
-
|
127 |
-
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
128 |
-
|
129 |
-
$resource = "lists/$list_id/members/$subscriber_hash";
|
130 |
-
|
131 |
-
$response = $this->api->get( $resource, array() );
|
132 |
-
|
133 |
-
if ( ! $response ) {
|
134 |
-
return false;
|
135 |
-
}
|
136 |
-
|
137 |
-
return $response['status'];
|
138 |
-
|
139 |
-
} //end function get_subscriber_status
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Subscribe the user to the list
|
143 |
-
* @param string $list_id The MailChimp list ID
|
144 |
-
* @param string $email_address The user's email address
|
145 |
-
* @param string $email_type html|text
|
146 |
-
* @param array $merge_fields Array of MailChimp Merge Tags
|
147 |
-
* @param array $interests Array of MailChimp Interest Groups
|
148 |
-
* @param boolean $double_opt_in Whether to send a double opt-in email to confirm subscription
|
149 |
-
* @return mixed $response The MailChimp API response
|
150 |
-
*/
|
151 |
-
public function subscribe( $list_id, $email_address, $email_type, $merge_fields, $interests, $double_opt_in ) {
|
152 |
-
|
153 |
-
$args = array(
|
154 |
-
'email_address' => $email_address,
|
155 |
-
'status' => $double_opt_in ? 'pending' : 'subscribed',
|
156 |
-
'email_type' => $email_type,
|
157 |
-
'merge_fields' => $merge_fields,
|
158 |
-
);
|
159 |
-
|
160 |
-
if ( is_array( $interests ) && !empty( $interests ) ) {
|
161 |
-
$args['interests'] = $interests;
|
162 |
-
}
|
163 |
-
|
164 |
-
$subscriber_status = $this->get_subscriber_status( $list_id, $email_address );
|
165 |
-
|
166 |
-
// If the user is already subscribed, bypass the double opt-in email
|
167 |
-
if ( 'subscribed' === $subscriber_status ) {
|
168 |
-
$args['status'] = 'subscribed';
|
169 |
-
}
|
170 |
-
|
171 |
-
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
172 |
-
|
173 |
-
$resource = "lists/$list_id/members/$subscriber_hash";
|
174 |
-
|
175 |
-
$response = $this->api->put( $resource, $args );
|
176 |
-
|
177 |
-
if ( ! $response ) {
|
178 |
-
return false;
|
179 |
-
}
|
180 |
-
|
181 |
-
return $response;
|
182 |
-
|
183 |
-
} //end function subscribe
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Unsubscribe the user from the list
|
187 |
-
* @param string $list_id The MailChimp list ID
|
188 |
-
* @param string $email_address The user's email address
|
189 |
-
* @return mixed $response The MailChimp API response
|
190 |
-
*/
|
191 |
-
public function unsubscribe( $list_id, $email_address ) {
|
192 |
-
|
193 |
-
$args = array(
|
194 |
-
'status' => 'unsubscribed',
|
195 |
-
);
|
196 |
-
|
197 |
-
if ( ! $subscriber_status = $this->get_subscriber_status( $list_id, $email_address ) ) {
|
198 |
-
return false;
|
199 |
-
}
|
200 |
-
|
201 |
-
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
202 |
-
|
203 |
-
$resource = "lists/$list_id/members/$subscriber_hash";
|
204 |
-
|
205 |
-
$response = $this->api->put( $resource, $args );
|
206 |
-
|
207 |
-
if ( ! $response ) {
|
208 |
-
return false;
|
209 |
-
}
|
210 |
-
|
211 |
-
return $response;
|
212 |
-
|
213 |
-
} //end function subscribe
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Returns the MD5 hash of the email
|
217 |
-
* @param string $email_address The email address to hash
|
218 |
-
* @return string MD5 hash of the lower-cased email address
|
219 |
-
*/
|
220 |
-
public function get_subscriber_hash( $email_address ) {
|
221 |
-
|
222 |
-
return md5( strtolower( $email_address ) );
|
223 |
-
|
224 |
-
} //end function get_subscriber_hash
|
225 |
-
|
226 |
-
/**
|
227 |
-
* Get merge fields
|
228 |
-
*
|
229 |
-
* @access public
|
230 |
-
* @param string $list_id
|
231 |
-
* @return mixed
|
232 |
-
*/
|
233 |
-
public function get_merge_fields( $list_id ) {
|
234 |
-
|
235 |
-
if ( ! $results = get_transient( "sswcmc_{$list_id}_merge_fields" ) ) {
|
236 |
-
|
237 |
-
$resource = "lists/$list_id/merge-fields";
|
238 |
-
|
239 |
-
$response = $this->api->get( $resource );
|
240 |
-
|
241 |
-
if ( ! $response ) {
|
242 |
-
return false;
|
243 |
-
}
|
244 |
-
|
245 |
-
$merge_fields = $response['merge_fields'];
|
246 |
-
|
247 |
-
$results = array();
|
248 |
-
|
249 |
-
foreach ( $merge_fields as $merge_field ) {
|
250 |
-
|
251 |
-
$results[ $merge_field['tag'] ] = array(
|
252 |
-
'name' => sprintf( '%s (%s)', $merge_field['name'], $merge_field['tag'] ),
|
253 |
-
'required' => $merge_field['required'],
|
254 |
-
);
|
255 |
-
|
256 |
-
}
|
257 |
-
|
258 |
-
// Cache list merge tags for 15 minutes
|
259 |
-
set_transient( "sswcmc_{$list_id}_merge_fields", $results, 60*15*1 );
|
260 |
-
|
261 |
-
}
|
262 |
-
|
263 |
-
return $results;
|
264 |
-
|
265 |
-
} //end function get_merge_fields
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Get interest categories
|
269 |
-
*
|
270 |
-
* @access public
|
271 |
-
* @param string $list_id
|
272 |
-
* @return mixed
|
273 |
-
*/
|
274 |
-
public function get_interest_categories( $list_id ) {
|
275 |
-
|
276 |
-
if ( ! $results = get_transient( "sswcmc_{$list_id}_interest_categories" ) ) {
|
277 |
-
|
278 |
-
$resource = "lists/$list_id/interest-categories";
|
279 |
-
|
280 |
-
$response = $this->api->get( $resource );
|
281 |
-
|
282 |
-
if ( ! $response ) {
|
283 |
-
return false;
|
284 |
-
}
|
285 |
-
|
286 |
-
$categories = $response['categories'];
|
287 |
-
|
288 |
-
$results = array();
|
289 |
-
|
290 |
-
foreach ( $categories as $category ) {
|
291 |
-
|
292 |
-
$results[ $category['id'] ] = $category['title'];
|
293 |
-
|
294 |
-
}
|
295 |
-
|
296 |
-
set_transient( "sswcmc_{$list_id}_interest_categories", $results, 60*15*1 );
|
297 |
-
|
298 |
-
}
|
299 |
-
|
300 |
-
return $results;
|
301 |
-
|
302 |
-
} //end function get_interest_categories
|
303 |
-
|
304 |
-
/**
|
305 |
-
* Get interest category interests
|
306 |
-
*
|
307 |
-
* @access public
|
308 |
-
* @param string $list_id
|
309 |
-
* * @param string $interest_category_id
|
310 |
-
* @return mixed
|
311 |
-
*/
|
312 |
-
public function get_interest_category_interests( $list_id, $interest_category_id ) {
|
313 |
-
|
314 |
-
if ( ! $results = get_transient( "sswcmc_{$list_id}_{$interest_category_id }_interests" ) ) {
|
315 |
-
|
316 |
-
$resource = "lists/$list_id/interest-categories/$interest_category_id/interests";
|
317 |
-
|
318 |
-
$response = $this->api->get( $resource );
|
319 |
-
|
320 |
-
if ( ! $response ) {
|
321 |
-
return false;
|
322 |
-
}
|
323 |
-
|
324 |
-
$interests = $response['interests'];
|
325 |
-
|
326 |
-
$results = array();
|
327 |
-
|
328 |
-
foreach ( $interests as $interest ) {
|
329 |
-
|
330 |
-
$results[ $interest['id'] ] = $interest['name'];
|
331 |
-
|
332 |
-
}
|
333 |
-
|
334 |
-
set_transient( "sswcmc_{$list_id}_{$interest_category_id }_interests", $results, 60*15*1 );
|
335 |
-
|
336 |
-
}
|
337 |
-
|
338 |
-
return $results;
|
339 |
-
|
340 |
-
} //end function get_interest_category_interests
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Get interest categories with interests
|
344 |
-
*
|
345 |
-
* @access public
|
346 |
-
* @param string $list_id
|
347 |
-
* @return mixed
|
348 |
-
*/
|
349 |
-
public function get_interest_categories_with_interests( $list_id ) {
|
350 |
-
|
351 |
-
$categories = $this->get_interest_categories( $list_id );
|
352 |
-
|
353 |
-
if ( ! $categories ) {
|
354 |
-
return false;
|
355 |
-
}
|
356 |
-
|
357 |
-
$results = array();
|
358 |
-
|
359 |
-
foreach ( $categories as $category_id => $category ) {
|
360 |
-
|
361 |
-
$interests = $this->get_interest_category_interests( $list_id, $category_id );
|
362 |
-
|
363 |
-
if ( ! $interests ) {
|
364 |
-
return false;
|
365 |
-
}
|
366 |
-
|
367 |
-
foreach ( $interests as $interest_id => $interest ) {
|
368 |
-
|
369 |
-
$results[ $interest_id ] = $category . ': ' . $interest;
|
370 |
-
|
371 |
-
}
|
372 |
-
|
373 |
-
}
|
374 |
-
|
375 |
-
return $results;
|
376 |
-
|
377 |
-
} //end function get_interest_categories_with_interests
|
378 |
-
|
379 |
-
/**
|
380 |
-
* Returns error code from error property
|
381 |
-
* @return string error code
|
382 |
-
*/
|
383 |
-
public function get_error_code() {
|
384 |
-
|
385 |
-
return $this->api->get_error_code();
|
386 |
-
|
387 |
-
} //end get_error_code
|
388 |
-
|
389 |
-
/**
|
390 |
-
* Returns error message from error property
|
391 |
-
* @return string error message
|
392 |
-
*/
|
393 |
-
public function get_error_message() {
|
394 |
-
|
395 |
-
return $this->api->get_error_message();
|
396 |
-
|
397 |
-
} //end get_error_message
|
398 |
-
|
399 |
-
} //end class SS_WC_MailChimp
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Minimal MailChimp helper
|
7 |
+
*
|
8 |
+
* @class SS_WC_MailChimp
|
9 |
+
* @version 2.0
|
10 |
+
* @package WooCommerce MailChimp
|
11 |
+
* @author Saint Systems
|
12 |
+
*/
|
13 |
+
class SS_WC_MailChimp {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var SS_WC_MailChimp_API
|
17 |
+
*/
|
18 |
+
public $api;
|
19 |
+
|
20 |
+
public $api_key;
|
21 |
+
|
22 |
+
public $debug;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Create a new instance
|
26 |
+
* @param string $api_key MailChimp API key
|
27 |
+
*/
|
28 |
+
function __construct( $api_key, $debug = false ) {
|
29 |
+
|
30 |
+
$this->api_key = $api_key;
|
31 |
+
|
32 |
+
$this->debug = $debug;
|
33 |
+
|
34 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp-api.php' );
|
35 |
+
$this->api = new SS_WC_MailChimp_API( $api_key, $debug );
|
36 |
+
|
37 |
+
} //end function __construct
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Get account
|
41 |
+
*
|
42 |
+
* @access public
|
43 |
+
* @return mixed
|
44 |
+
*/
|
45 |
+
public function get_account( $api_key = null ) {
|
46 |
+
|
47 |
+
$resource = '';
|
48 |
+
|
49 |
+
$api = $this->api;
|
50 |
+
|
51 |
+
if ( ! empty( $api_key ) ) {
|
52 |
+
$api = new SS_WC_MailChimp_API( $api_key, $this->debug );
|
53 |
+
}
|
54 |
+
|
55 |
+
$account = $api->get( $resource );
|
56 |
+
|
57 |
+
if ( ! $account ) {
|
58 |
+
$last_response = $api->get_last_response();
|
59 |
+
if (floor( $last_response['response']['code'] ) / 100 >= 4) {
|
60 |
+
$body = $last_response['body'];
|
61 |
+
$errorMessage = $last_response['response']['code'] . ' ' . $last_response['response']['message'];
|
62 |
+
if (preg_match("'<h1>(.*)</h1>'si", $body, $matches)) {
|
63 |
+
$errorMessage .= '<br/>' . $matches[1] . ': ';
|
64 |
+
}
|
65 |
+
if (preg_match("'<p>(.*)</p>'si", $body, $matches)) {
|
66 |
+
$errorMessage .= $matches[1];
|
67 |
+
}
|
68 |
+
return array(
|
69 |
+
'error' => $errorMessage
|
70 |
+
);
|
71 |
+
}
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
|
75 |
+
return $account;
|
76 |
+
|
77 |
+
} //end function get_account
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Get list
|
81 |
+
*
|
82 |
+
* @access public
|
83 |
+
* @return mixed
|
84 |
+
*/
|
85 |
+
public function get_lists( $args = array() ) {
|
86 |
+
|
87 |
+
if ( ! $results = get_transient( 'sswcmc_lists' ) ) {
|
88 |
+
|
89 |
+
$resource = 'lists';
|
90 |
+
|
91 |
+
if ( ! array_key_exists( 'count', $args ) ) {
|
92 |
+
$args['count'] = 100;
|
93 |
+
}
|
94 |
+
|
95 |
+
$response = $this->api->get( $resource, $args );
|
96 |
+
|
97 |
+
if ( ! $response ) {
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
|
101 |
+
$lists = $response['lists'];
|
102 |
+
|
103 |
+
$results = array();
|
104 |
+
|
105 |
+
foreach ( $lists as $list ) {
|
106 |
+
|
107 |
+
$results[ (string)$list['id'] ] = $list['name'];
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
set_transient( 'sswcmc_lists', $results, 60*15*1 );
|
112 |
+
|
113 |
+
}
|
114 |
+
|
115 |
+
return $results;
|
116 |
+
|
117 |
+
} //end function get_lists
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get Subscriber
|
121 |
+
* @param string $list_id The MailChimp list ID
|
122 |
+
* @param string $email_address The user's email address
|
123 |
+
* @return string The status of the subscriber
|
124 |
+
*/
|
125 |
+
public function get_subscriber_status( $list_id, $email_address ) {
|
126 |
+
|
127 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
128 |
+
|
129 |
+
$resource = "lists/$list_id/members/$subscriber_hash";
|
130 |
+
|
131 |
+
$response = $this->api->get( $resource, array() );
|
132 |
+
|
133 |
+
if ( ! $response ) {
|
134 |
+
return false;
|
135 |
+
}
|
136 |
+
|
137 |
+
return $response['status'];
|
138 |
+
|
139 |
+
} //end function get_subscriber_status
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Subscribe the user to the list
|
143 |
+
* @param string $list_id The MailChimp list ID
|
144 |
+
* @param string $email_address The user's email address
|
145 |
+
* @param string $email_type html|text
|
146 |
+
* @param array $merge_fields Array of MailChimp Merge Tags
|
147 |
+
* @param array $interests Array of MailChimp Interest Groups
|
148 |
+
* @param boolean $double_opt_in Whether to send a double opt-in email to confirm subscription
|
149 |
+
* @return mixed $response The MailChimp API response
|
150 |
+
*/
|
151 |
+
public function subscribe( $list_id, $email_address, $email_type, $merge_fields, $interests, $double_opt_in ) {
|
152 |
+
|
153 |
+
$args = array(
|
154 |
+
'email_address' => $email_address,
|
155 |
+
'status' => $double_opt_in ? 'pending' : 'subscribed',
|
156 |
+
'email_type' => $email_type,
|
157 |
+
'merge_fields' => $merge_fields,
|
158 |
+
);
|
159 |
+
|
160 |
+
if ( is_array( $interests ) && !empty( $interests ) ) {
|
161 |
+
$args['interests'] = $interests;
|
162 |
+
}
|
163 |
+
|
164 |
+
$subscriber_status = $this->get_subscriber_status( $list_id, $email_address );
|
165 |
+
|
166 |
+
// If the user is already subscribed, bypass the double opt-in email
|
167 |
+
if ( 'subscribed' === $subscriber_status ) {
|
168 |
+
$args['status'] = 'subscribed';
|
169 |
+
}
|
170 |
+
|
171 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
172 |
+
|
173 |
+
$resource = "lists/$list_id/members/$subscriber_hash";
|
174 |
+
|
175 |
+
$response = $this->api->put( $resource, $args );
|
176 |
+
|
177 |
+
if ( ! $response ) {
|
178 |
+
return false;
|
179 |
+
}
|
180 |
+
|
181 |
+
return $response;
|
182 |
+
|
183 |
+
} //end function subscribe
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Unsubscribe the user from the list
|
187 |
+
* @param string $list_id The MailChimp list ID
|
188 |
+
* @param string $email_address The user's email address
|
189 |
+
* @return mixed $response The MailChimp API response
|
190 |
+
*/
|
191 |
+
public function unsubscribe( $list_id, $email_address ) {
|
192 |
+
|
193 |
+
$args = array(
|
194 |
+
'status' => 'unsubscribed',
|
195 |
+
);
|
196 |
+
|
197 |
+
if ( ! $subscriber_status = $this->get_subscriber_status( $list_id, $email_address ) ) {
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
|
201 |
+
$subscriber_hash = $this->get_subscriber_hash( $email_address );
|
202 |
+
|
203 |
+
$resource = "lists/$list_id/members/$subscriber_hash";
|
204 |
+
|
205 |
+
$response = $this->api->put( $resource, $args );
|
206 |
+
|
207 |
+
if ( ! $response ) {
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
|
211 |
+
return $response;
|
212 |
+
|
213 |
+
} //end function subscribe
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Returns the MD5 hash of the email
|
217 |
+
* @param string $email_address The email address to hash
|
218 |
+
* @return string MD5 hash of the lower-cased email address
|
219 |
+
*/
|
220 |
+
public function get_subscriber_hash( $email_address ) {
|
221 |
+
|
222 |
+
return md5( strtolower( $email_address ) );
|
223 |
+
|
224 |
+
} //end function get_subscriber_hash
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Get merge fields
|
228 |
+
*
|
229 |
+
* @access public
|
230 |
+
* @param string $list_id
|
231 |
+
* @return mixed
|
232 |
+
*/
|
233 |
+
public function get_merge_fields( $list_id ) {
|
234 |
+
|
235 |
+
if ( ! $results = get_transient( "sswcmc_{$list_id}_merge_fields" ) ) {
|
236 |
+
|
237 |
+
$resource = "lists/$list_id/merge-fields";
|
238 |
+
|
239 |
+
$response = $this->api->get( $resource );
|
240 |
+
|
241 |
+
if ( ! $response ) {
|
242 |
+
return false;
|
243 |
+
}
|
244 |
+
|
245 |
+
$merge_fields = $response['merge_fields'];
|
246 |
+
|
247 |
+
$results = array();
|
248 |
+
|
249 |
+
foreach ( $merge_fields as $merge_field ) {
|
250 |
+
|
251 |
+
$results[ $merge_field['tag'] ] = array(
|
252 |
+
'name' => sprintf( '%s (%s)', $merge_field['name'], $merge_field['tag'] ),
|
253 |
+
'required' => $merge_field['required'],
|
254 |
+
);
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
// Cache list merge tags for 15 minutes
|
259 |
+
set_transient( "sswcmc_{$list_id}_merge_fields", $results, 60*15*1 );
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
return $results;
|
264 |
+
|
265 |
+
} //end function get_merge_fields
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Get interest categories
|
269 |
+
*
|
270 |
+
* @access public
|
271 |
+
* @param string $list_id
|
272 |
+
* @return mixed
|
273 |
+
*/
|
274 |
+
public function get_interest_categories( $list_id ) {
|
275 |
+
|
276 |
+
if ( ! $results = get_transient( "sswcmc_{$list_id}_interest_categories" ) ) {
|
277 |
+
|
278 |
+
$resource = "lists/$list_id/interest-categories";
|
279 |
+
|
280 |
+
$response = $this->api->get( $resource );
|
281 |
+
|
282 |
+
if ( ! $response ) {
|
283 |
+
return false;
|
284 |
+
}
|
285 |
+
|
286 |
+
$categories = $response['categories'];
|
287 |
+
|
288 |
+
$results = array();
|
289 |
+
|
290 |
+
foreach ( $categories as $category ) {
|
291 |
+
|
292 |
+
$results[ $category['id'] ] = $category['title'];
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
set_transient( "sswcmc_{$list_id}_interest_categories", $results, 60*15*1 );
|
297 |
+
|
298 |
+
}
|
299 |
+
|
300 |
+
return $results;
|
301 |
+
|
302 |
+
} //end function get_interest_categories
|
303 |
+
|
304 |
+
/**
|
305 |
+
* Get interest category interests
|
306 |
+
*
|
307 |
+
* @access public
|
308 |
+
* @param string $list_id
|
309 |
+
* * @param string $interest_category_id
|
310 |
+
* @return mixed
|
311 |
+
*/
|
312 |
+
public function get_interest_category_interests( $list_id, $interest_category_id ) {
|
313 |
+
|
314 |
+
if ( ! $results = get_transient( "sswcmc_{$list_id}_{$interest_category_id }_interests" ) ) {
|
315 |
+
|
316 |
+
$resource = "lists/$list_id/interest-categories/$interest_category_id/interests";
|
317 |
+
|
318 |
+
$response = $this->api->get( $resource );
|
319 |
+
|
320 |
+
if ( ! $response ) {
|
321 |
+
return false;
|
322 |
+
}
|
323 |
+
|
324 |
+
$interests = $response['interests'];
|
325 |
+
|
326 |
+
$results = array();
|
327 |
+
|
328 |
+
foreach ( $interests as $interest ) {
|
329 |
+
|
330 |
+
$results[ $interest['id'] ] = $interest['name'];
|
331 |
+
|
332 |
+
}
|
333 |
+
|
334 |
+
set_transient( "sswcmc_{$list_id}_{$interest_category_id }_interests", $results, 60*15*1 );
|
335 |
+
|
336 |
+
}
|
337 |
+
|
338 |
+
return $results;
|
339 |
+
|
340 |
+
} //end function get_interest_category_interests
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Get interest categories with interests
|
344 |
+
*
|
345 |
+
* @access public
|
346 |
+
* @param string $list_id
|
347 |
+
* @return mixed
|
348 |
+
*/
|
349 |
+
public function get_interest_categories_with_interests( $list_id ) {
|
350 |
+
|
351 |
+
$categories = $this->get_interest_categories( $list_id );
|
352 |
+
|
353 |
+
if ( ! $categories ) {
|
354 |
+
return false;
|
355 |
+
}
|
356 |
+
|
357 |
+
$results = array();
|
358 |
+
|
359 |
+
foreach ( $categories as $category_id => $category ) {
|
360 |
+
|
361 |
+
$interests = $this->get_interest_category_interests( $list_id, $category_id );
|
362 |
+
|
363 |
+
if ( ! $interests ) {
|
364 |
+
return false;
|
365 |
+
}
|
366 |
+
|
367 |
+
foreach ( $interests as $interest_id => $interest ) {
|
368 |
+
|
369 |
+
$results[ $interest_id ] = $category . ': ' . $interest;
|
370 |
+
|
371 |
+
}
|
372 |
+
|
373 |
+
}
|
374 |
+
|
375 |
+
return $results;
|
376 |
+
|
377 |
+
} //end function get_interest_categories_with_interests
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Returns error code from error property
|
381 |
+
* @return string error code
|
382 |
+
*/
|
383 |
+
public function get_error_code() {
|
384 |
+
|
385 |
+
return $this->api->get_error_code();
|
386 |
+
|
387 |
+
} //end get_error_code
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Returns error message from error property
|
391 |
+
* @return string error message
|
392 |
+
*/
|
393 |
+
public function get_error_message() {
|
394 |
+
|
395 |
+
return $this->api->get_error_message();
|
396 |
+
|
397 |
+
} //end get_error_message
|
398 |
+
|
399 |
+
} //end class SS_WC_MailChimp
|
includes/class-ss-wc-settings-mailchimp.php
CHANGED
@@ -1,706 +1,706 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce MailChimp Settings
|
4 |
-
*
|
5 |
-
* @author Saint Systems
|
6 |
-
* @package WooCommerce MailChimp
|
7 |
-
* @version 2.0
|
8 |
-
*/
|
9 |
-
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
11 |
-
|
12 |
-
if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @class SS_WC_Settings_MailChimp
|
16 |
-
* @extends WC_Settings_Page
|
17 |
-
*/
|
18 |
-
class SS_WC_Settings_MailChimp extends WC_Settings_Page {
|
19 |
-
|
20 |
-
private static $instance;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Singleton instance
|
24 |
-
*
|
25 |
-
* @return SS_WC_Settings_MailChimp SS_WC_Settings_MailChimp object
|
26 |
-
*/
|
27 |
-
public static function get_instance() {
|
28 |
-
|
29 |
-
if ( empty( self::$instance ) ) {
|
30 |
-
self::$instance = new self;
|
31 |
-
}
|
32 |
-
|
33 |
-
return self::$instance;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Constructor
|
38 |
-
*
|
39 |
-
* @access public
|
40 |
-
* @return void
|
41 |
-
*/
|
42 |
-
public function __construct() {
|
43 |
-
|
44 |
-
$this->id = 'mailchimp';
|
45 |
-
$this->namespace = 'ss_wc_' . $this->id;
|
46 |
-
$this->label = __( 'MailChimp', 'woocommerce-mailchimp' );
|
47 |
-
$this->init();
|
48 |
-
|
49 |
-
$this->register_hooks();
|
50 |
-
|
51 |
-
} //end function __construct
|
52 |
-
|
53 |
-
/**
|
54 |
-
* api_key function.
|
55 |
-
* @return string MailChimp API Key
|
56 |
-
*/
|
57 |
-
public function api_key() {
|
58 |
-
return $this->get_option( 'api_key' );
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* is_enabled function.
|
63 |
-
*
|
64 |
-
* @access public
|
65 |
-
* @return boolean
|
66 |
-
*/
|
67 |
-
public function is_enabled() {
|
68 |
-
return 'yes' === $this->get_option( 'enabled' );
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* occurs function
|
73 |
-
* @return string
|
74 |
-
*/
|
75 |
-
public function occurs() {
|
76 |
-
return $this->get_option( 'occurs' );
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* get_list function.
|
81 |
-
*
|
82 |
-
* @access public
|
83 |
-
* @return string MailChimp list ID
|
84 |
-
*/
|
85 |
-
public function get_list() {
|
86 |
-
return $this->get_option( 'list' );
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* double_opt_in function.
|
91 |
-
*
|
92 |
-
* @access public
|
93 |
-
* @return boolean
|
94 |
-
*/
|
95 |
-
public function double_opt_in() {
|
96 |
-
return 'yes' === $this->get_option( 'double_opt_in' );
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* display_opt_in function.
|
101 |
-
*
|
102 |
-
* @access public
|
103 |
-
* @return boolean
|
104 |
-
*/
|
105 |
-
public function display_opt_in() {
|
106 |
-
return 'yes' === $this->get_option( 'display_opt_in' );
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* opt_in_label function.
|
111 |
-
*
|
112 |
-
* @access public
|
113 |
-
* @return string
|
114 |
-
*/
|
115 |
-
public function opt_in_label() {
|
116 |
-
return $this->get_option( 'opt_in_label' );
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* opt_in_checkbox_default_status function.
|
121 |
-
*
|
122 |
-
* @access public
|
123 |
-
* @return string
|
124 |
-
*/
|
125 |
-
public function opt_in_checkbox_default_status() {
|
126 |
-
return $this->get_option( 'opt_in_checkbox_default_status' );
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* opt_in_checkbox_display_location function.
|
131 |
-
*
|
132 |
-
* @access public
|
133 |
-
* @return string
|
134 |
-
*/
|
135 |
-
public function opt_in_checkbox_display_location() {
|
136 |
-
return $this->get_option( 'opt_in_checkbox_display_location' );
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* interests function.
|
141 |
-
*
|
142 |
-
* @access public
|
143 |
-
* @return array
|
144 |
-
*/
|
145 |
-
public function interest_groups() {
|
146 |
-
return $this->get_option( 'interest_groups' );
|
147 |
-
}
|
148 |
-
|
149 |
-
/**
|
150 |
-
* has_list function.
|
151 |
-
*
|
152 |
-
* @access public
|
153 |
-
* @return boolean
|
154 |
-
*/
|
155 |
-
public function has_list() {
|
156 |
-
if ( $this->get_list() ) {
|
157 |
-
return true;
|
158 |
-
}
|
159 |
-
return false;
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* has_api_key function.
|
164 |
-
*
|
165 |
-
* @access public
|
166 |
-
* @return boolean
|
167 |
-
*/
|
168 |
-
public function has_api_key() {
|
169 |
-
$api_key = $this->api_key();
|
170 |
-
return !empty( $api_key );
|
171 |
-
}
|
172 |
-
|
173 |
-
/**
|
174 |
-
* is_valid function.
|
175 |
-
*
|
176 |
-
* @access public
|
177 |
-
* @return boolean
|
178 |
-
*/
|
179 |
-
public function is_valid() {
|
180 |
-
return $this->is_enabled() && $this->has_api_key() && $this->has_list();
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* debug_enabled function.
|
185 |
-
*
|
186 |
-
* @access public
|
187 |
-
* @return boolean
|
188 |
-
*/
|
189 |
-
public function debug_enabled() {
|
190 |
-
return 'yes' === $this->get_option( 'debug' );
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Check if the user has enabled the plugin functionality, but hasn't provided an api key
|
195 |
-
**/
|
196 |
-
function checks() {
|
197 |
-
// Check required fields
|
198 |
-
if ( $this->is_enabled() && ! $this->has_api_key() ) {
|
199 |
-
// Show notice
|
200 |
-
echo $this->get_message( sprintf( __( 'WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter your api key <a href="%s">here</a>.', 'woocommerce-mailchimp' ), SS_WC_MAILCHIMP_SETTINGS_URL )
|
201 |
-
);
|
202 |
-
}
|
203 |
-
}
|
204 |
-
|
205 |
-
public function init() {
|
206 |
-
|
207 |
-
$this->api_key = $this->get_option( 'api_key' );
|
208 |
-
|
209 |
-
$this->enabled = $this->get_option( 'enabled' );
|
210 |
-
|
211 |
-
}
|
212 |
-
|
213 |
-
public function get_option( $option_suffix ) {
|
214 |
-
|
215 |
-
return get_option( $this->namespace_prefixed( $option_suffix ) );
|
216 |
-
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Register plugin hooks
|
221 |
-
*
|
222 |
-
* @access public
|
223 |
-
* @return void
|
224 |
-
*/
|
225 |
-
public function register_hooks() {
|
226 |
-
|
227 |
-
// Hook in to add the MailChimp tab
|
228 |
-
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
229 |
-
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
|
230 |
-
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
|
231 |
-
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
|
232 |
-
add_action( 'woocommerce_settings_saved', array( $this, 'init' ) );
|
233 |
-
|
234 |
-
// Hooks
|
235 |
-
add_action( 'admin_notices', array( $this, 'checks' ) );
|
236 |
-
add_action( 'woocommerce_admin_field_sysinfo', array( $this, 'sysinfo_field' ), 10, 1 );
|
237 |
-
|
238 |
-
} //end function ensure_tab
|
239 |
-
|
240 |
-
// /**
|
241 |
-
// * Get sections
|
242 |
-
// *
|
243 |
-
// * @return array
|
244 |
-
// */
|
245 |
-
public function get_sections() {
|
246 |
-
|
247 |
-
$sections = array();
|
248 |
-
|
249 |
-
$sections[''] = __( 'General', 'woocommerce-mailchimp' );
|
250 |
-
|
251 |
-
if ( $this->has_api_key() ) {
|
252 |
-
$sections['troubleshooting'] = __( 'Troubleshooting', 'woocommerce-mailchimp' );
|
253 |
-
}
|
254 |
-
|
255 |
-
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Output the settings
|
260 |
-
*/
|
261 |
-
public function output() {
|
262 |
-
|
263 |
-
global $current_section;
|
264 |
-
|
265 |
-
$settings = $this->get_settings( $current_section );
|
266 |
-
|
267 |
-
WC_Admin_Settings::output_fields( $settings );
|
268 |
-
|
269 |
-
$this->wc_enqueue_js("
|
270 |
-
(function($){
|
271 |
-
|
272 |
-
$(document).ready(function() {
|
273 |
-
SS_WC_MailChimp.init();
|
274 |
-
});
|
275 |
-
|
276 |
-
})(jQuery);
|
277 |
-
");
|
278 |
-
|
279 |
-
do_action( 'ss_wc_mailchimp_after_settings_enqueue_js' );
|
280 |
-
|
281 |
-
}
|
282 |
-
|
283 |
-
/**
|
284 |
-
* Save settings
|
285 |
-
*/
|
286 |
-
public function save() {
|
287 |
-
global $current_section;
|
288 |
-
|
289 |
-
$settings = $this->get_settings( $current_section );
|
290 |
-
|
291 |
-
WC_Admin_Settings::save_fields( $settings );
|
292 |
-
|
293 |
-
if ( !isset( $_POST[ 'ss_wc_mailchimp_api_key' ] ) || empty( $_POST[ 'ss_wc_mailchimp_api_key' ] ) ) {
|
294 |
-
delete_transient( 'sswcmc_lists' );
|
295 |
-
}
|
296 |
-
|
297 |
-
$sswcmc = SSWCMC();
|
298 |
-
// Trigger reload of plugin settings
|
299 |
-
$settings = $sswcmc->settings( true );
|
300 |
-
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Get settings array
|
305 |
-
*
|
306 |
-
* @return array
|
307 |
-
*/
|
308 |
-
public function get_settings( $current_section = '' ) {
|
309 |
-
|
310 |
-
$settings = array();
|
311 |
-
|
312 |
-
if ( '' === $current_section ) {
|
313 |
-
|
314 |
-
$settings = array(
|
315 |
-
array(
|
316 |
-
'title' => __( 'MailChimp', 'woocommerce-mailchimp' ),
|
317 |
-
'type' => 'title',
|
318 |
-
'desc' => __( 'Enter your MailChimp settings below to control how WooCommerce integrates with your MailChimp account.', 'woocommerce-mailchimp' ),
|
319 |
-
'id' => 'general_options',
|
320 |
-
),
|
321 |
-
);
|
322 |
-
|
323 |
-
$settings[] = array(
|
324 |
-
'id' => $this->namespace_prefixed( 'api_key' ),
|
325 |
-
'title' => __( 'API Key', 'woocommerce-mailchimp' ),
|
326 |
-
'type' => 'text',
|
327 |
-
'desc' => sprintf( __( '%sLogin to MailChimp%s to look up your api key.', 'woocommerce-mailchimp' ), '<br/><a href="https://admin.mailchimp.com/account/api/" target="_blank">', '</a>'
|
328 |
-
),
|
329 |
-
'placeholder' => __( 'Paste your MailChimp API key here', 'woocommerce-mailchimp' ),
|
330 |
-
'default' => '',
|
331 |
-
'css' => 'min-width:350px;',
|
332 |
-
'desc_tip' => 'Your API Key is required for the plugin to communicate with your MailChimp account.',
|
333 |
-
);
|
334 |
-
|
335 |
-
$settings[] = array(
|
336 |
-
'id' => $this->namespace_prefixed( 'enabled' ),
|
337 |
-
'title' => __( 'Enable/Disable', 'woocommerce-mailchimp' ),
|
338 |
-
'label' => __( 'Enable MailChimp Integration', 'woocommerce-mailchimp' ),
|
339 |
-
'type' => 'checkbox',
|
340 |
-
'desc' => __( 'Enable/disable the plugin functionality.', 'woocommerce-mailchimp' ),
|
341 |
-
'default' => 'yes',
|
342 |
-
);
|
343 |
-
|
344 |
-
$mailchimp_lists = $this->get_lists();
|
345 |
-
|
346 |
-
if ( $this->has_api_key() && $this->has_list() ) {
|
347 |
-
$interest_groups = $this->get_interest_groups();
|
348 |
-
} else {
|
349 |
-
$interest_groups = array();
|
350 |
-
}
|
351 |
-
|
352 |
-
$settings[] = array(
|
353 |
-
'id' => $this->namespace_prefixed( 'list' ),
|
354 |
-
'title' => __( 'Main List', 'woocommerce-mailchimp' ),
|
355 |
-
'type' => 'select',
|
356 |
-
'desc' => __( 'All customers will be added to this list.', 'woocommerce-mailchimp' ),
|
357 |
-
'default' => '',
|
358 |
-
'options' => $mailchimp_lists,
|
359 |
-
'class' => 'wc-enhanced-select',
|
360 |
-
'css' => 'min-width: 350px;',
|
361 |
-
'desc_tip' => true,
|
362 |
-
);
|
363 |
-
|
364 |
-
$settings[] = array(
|
365 |
-
'id' => $this->namespace_prefixed( 'interest_groups' ),
|
366 |
-
'title' => __( 'Interest Groups', 'woocommerce-mailchimp' ),
|
367 |
-
'type' => 'multiselect',
|
368 |
-
'desc' => __( 'Optional: Interest groups to assign to subscribers.', 'woocommerce-mailchimp' ),
|
369 |
-
'default' => '',
|
370 |
-
'options' => $interest_groups,
|
371 |
-
'class' => 'wc-enhanced-select',
|
372 |
-
'custom_attributes' => array(
|
373 |
-
'placeholder' => __( 'Select interest groups...', 'woocommerce-mailchimp' ),
|
374 |
-
),
|
375 |
-
'css' => 'min-width: 350px;',
|
376 |
-
'desc_tip' => true,
|
377 |
-
);
|
378 |
-
|
379 |
-
$settings = apply_filters( $this->namespace_prefixed( 'settings_general_after_interest_groups' ), $settings );
|
380 |
-
|
381 |
-
$settings[] = array(
|
382 |
-
'id' => $this->namespace_prefixed( 'occurs' ),
|
383 |
-
'title' => __( 'Subscribe Event', 'woocommerce-mailchimp' ),
|
384 |
-
'type' => 'select',
|
385 |
-
'desc' => __( 'Choose whether to subscribe customers as soon as an order is placed or after the order is processing or completed.', 'woocommerce-mailchimp' ),
|
386 |
-
'class' => 'wc-enhanced-select',
|
387 |
-
'default' => 'pending',
|
388 |
-
'options' => array(
|
389 |
-
'pending' => __( 'Order Created', 'woocommerce-mailchimp' ),
|
390 |
-
'processing' => __( 'Order Processing', 'woocommerce-mailchimp' ),
|
391 |
-
'completed' => __( 'Order Completed', 'woocommerce-mailchimp' ),
|
392 |
-
),
|
393 |
-
'desc_tip' => true,
|
394 |
-
);
|
395 |
-
|
396 |
-
$settings[] = array(
|
397 |
-
'id' => $this->namespace_prefixed( 'double_opt_in' ),
|
398 |
-
'title' => __( 'Double Opt-In', 'woocommerce-mailchimp' ),
|
399 |
-
'desc' => __( 'Enable Double Opt-In', 'woocommerce-mailchimp' ),
|
400 |
-
'type' => 'checkbox',
|
401 |
-
'default' => 'no',
|
402 |
-
'desc_tip' => __( 'If enabled, customers will receive an email prompting them to confirm their subscription to the list above.', 'woocommerce-mailchimp' ),
|
403 |
-
);
|
404 |
-
|
405 |
-
$settings[] = array(
|
406 |
-
'id' => $this->namespace_prefixed( 'display_opt_in' ),
|
407 |
-
'title' => __( 'Subscribe Customers', 'woocommerce-mailchimp' ),
|
408 |
-
'desc' => __( '<p>Choose <strong>Ask for permission</strong> to show an "Opt-in" checkbox during checkout. Customers will only be subscribed to the list above if they opt-in. <p>Choose <strong>Automatically</strong> to subscribe customers silently upon checkout. Caution, this is without the customer\'s consent.</p>', 'woocommerce-mailchimp' ),
|
409 |
-
'type' => 'select',
|
410 |
-
'css' => 'min-width:300px;',
|
411 |
-
'class' => 'wc-enhanced-select',
|
412 |
-
'desc_tip' => true,
|
413 |
-
'default' => 'yes',
|
414 |
-
'options' => array(
|
415 |
-
// '0' => __( 'Disabled', 'woocommerce-mailchimp' ),
|
416 |
-
'yes' => __( 'Ask for permission', 'woocommerce-mailchimp' ),
|
417 |
-
'no' => __( 'Automatically', 'woocommerce-mailchimp' ),
|
418 |
-
)
|
419 |
-
);
|
420 |
-
|
421 |
-
$settings[] = array(
|
422 |
-
'id' => $this->namespace_prefixed( 'opt_in_label' ),
|
423 |
-
'title' => __( 'Opt-In Field Label', 'woocommerce-mailchimp' ),
|
424 |
-
'type' => 'text',
|
425 |
-
'desc' => __( 'Optional: customize the label displayed next to the opt-in checkbox.', 'woocommerce-mailchimp' ),
|
426 |
-
'default' => __( 'Subscribe to our newsletter', 'woocommerce-mailchimp' ),
|
427 |
-
'css' => 'min-width:350px;',
|
428 |
-
'desc_tip' => true,
|
429 |
-
);
|
430 |
-
|
431 |
-
$settings[] = array(
|
432 |
-
'id' => $this->namespace_prefixed( 'opt_in_checkbox_default_status' ),
|
433 |
-
'title' => __( 'Opt-In Checkbox Default', 'woocommerce-mailchimp' ),
|
434 |
-
'type' => 'select',
|
435 |
-
'desc' => __( 'The default state of the opt-in checkbox.', 'woocommerce-mailchimp' ),
|
436 |
-
'class' => 'wc-enhanced-select',
|
437 |
-
'default' => 'checked',
|
438 |
-
'options' => array(
|
439 |
-
'checked' => __( 'Checked', 'woocommerce-mailchimp' ),
|
440 |
-
'unchecked' => __( 'Unchecked', 'woocommerce-mailchimp' )
|
441 |
-
),
|
442 |
-
'desc_tip' => true,
|
443 |
-
);
|
444 |
-
|
445 |
-
$settings[] = array(
|
446 |
-
'id' => $this->namespace_prefixed( 'opt_in_checkbox_display_location' ),
|
447 |
-
'title' => __( 'Opt-In Checkbox Location', 'woocommerce-mailchimp' ),
|
448 |
-
'type' => 'select',
|
449 |
-
'desc' => __( 'Where to display the opt-in checkbox on the checkout page.', 'woocommerce-mailchimp' ),
|
450 |
-
'class' => 'wc-enhanced-select',
|
451 |
-
'default' => 'woocommerce_review_order_before_submit',
|
452 |
-
'options' => array(
|
453 |
-
'woocommerce_checkout_before_customer_details' => __( 'Above customer details', 'woocommerce-mailchimp' ),
|
454 |
-
'woocommerce_checkout_after_customer_details' => __( 'Below customer details', 'woocommerce-mailchimp' ),
|
455 |
-
'woocommerce_checkout_before_order_review' => __( 'Order review above cart/product table.', 'woocommerce-mailchimp' ),
|
456 |
-
'woocommerce_review_order_before_submit' => __( 'Order review above submit', 'woocommerce-mailchimp' ),
|
457 |
-
'woocommerce_review_order_after_submit' => __( 'Order review below submit', 'woocommerce-mailchimp' ),
|
458 |
-
'woocommerce_review_order_before_order_total' => __( 'Order review above total', 'woocommerce-mailchimp' ),
|
459 |
-
'woocommerce_checkout_billing' => __( 'Above billing details', 'woocommerce-mailchimp' ),
|
460 |
-
'woocommerce_checkout_shipping' => __( 'Above shipping details', 'woocommerce-mailchimp' ),
|
461 |
-
'woocommerce_after_checkout_billing_form' => __( 'Below Checkout billing form', 'woocommerce-mailchimp' ),
|
462 |
-
'woocommerce_checkout_before_terms_and_conditions' => __( 'Above Checkout Terms and Conditions', 'woocommerce-mailchimp' ),
|
463 |
-
'woocommerce_checkout_after_terms_and_conditions' => __( 'Below Checkout Terms and Conditions', 'woocommerce-mailchimp' ),
|
464 |
-
),
|
465 |
-
'desc_tip' => true,
|
466 |
-
);
|
467 |
-
|
468 |
-
$settings = apply_filters( $this->namespace_prefixed( 'settings_general' ), $settings );
|
469 |
-
|
470 |
-
$settings[] = array( 'type' => 'sectionend', 'id' => 'general_options' );
|
471 |
-
|
472 |
-
} elseif ( 'troubleshooting' === $current_section ) {
|
473 |
-
|
474 |
-
$label = __( 'Enable Logging', 'woocommerce-mailchimp' );
|
475 |
-
|
476 |
-
if ( defined( 'WC_LOG_DIR' ) ) {
|
477 |
-
$debug_log_url = add_query_arg( 'tab', 'logs', add_query_arg( 'page', 'wc-status', admin_url( 'admin.php' ) ) );
|
478 |
-
$debug_log_key = 'woocommerce-mailchimp-' . sanitize_file_name( wp_hash( 'woocommerce-mailchimp' ) ) . '-log';
|
479 |
-
$debug_log_url = add_query_arg( 'log_file', $debug_log_key, $debug_log_url );
|
480 |
-
|
481 |
-
$label .= ' | ' . sprintf( __( '%1$sView Log%2$s', 'woocommerce-mailchimp' ), '<a href="' . esc_url( $debug_log_url ) . '">', '</a>' );
|
482 |
-
}
|
483 |
-
|
484 |
-
$settings[] = array(
|
485 |
-
'title' => __( 'Troubleshooting', 'woocommerce-mailchimp' ),
|
486 |
-
'type' => 'title',
|
487 |
-
'desc' => '',
|
488 |
-
'id' => 'troubleshooting_settings'
|
489 |
-
);
|
490 |
-
|
491 |
-
$settings[] = array(
|
492 |
-
'id' => $this->namespace_prefixed( 'debug' ),
|
493 |
-
'title' => __( 'Debug Log', 'woocommerce-mailchimp' ),
|
494 |
-
'desc' => $label,
|
495 |
-
'type' => 'checkbox',
|
496 |
-
'default' => 'no',
|
497 |
-
'desc_tip' => __( 'Enable logging MailChimp API calls. Only enable for troubleshooting purposes.', 'woocommerce-mailchimp' ),
|
498 |
-
);
|
499 |
-
|
500 |
-
$settings[] = array(
|
501 |
-
'id' => 'sysinfo',
|
502 |
-
'title' => __( 'System Info', 'woocommerce-mailchimp' ),
|
503 |
-
'type' => 'sysinfo',
|
504 |
-
'desc' => __( 'Copy the information below and send it to us when reporting an issue with the plugin.', 'woocommerce-mailchimp' ) . '<p/>',
|
505 |
-
'desc_tip' => '',
|
506 |
-
);
|
507 |
-
|
508 |
-
$settings[] = array( 'type' => 'sectionend', 'id' => 'troubleshooting_settings' );
|
509 |
-
|
510 |
-
$settings = apply_filters( $this->namespace_prefixed( 'settings_troubleshooting' ), $settings );
|
511 |
-
|
512 |
-
}
|
513 |
-
|
514 |
-
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
|
515 |
-
|
516 |
-
} //end function get_settings
|
517 |
-
|
518 |
-
private function namespace_prefixed( $value ) {
|
519 |
-
return $this->namespace . '_' . $value;
|
520 |
-
}
|
521 |
-
|
522 |
-
/**
|
523 |
-
* WooCommerce 2.1 support for wc_enqueue_js
|
524 |
-
*
|
525 |
-
* @since 1.2.1
|
526 |
-
*
|
527 |
-
* @access private
|
528 |
-
* @param string $code
|
529 |
-
* @return void
|
530 |
-
*/
|
531 |
-
private function wc_enqueue_js( $code ) {
|
532 |
-
if ( function_exists( 'wc_enqueue_js' ) ) {
|
533 |
-
wc_enqueue_js( $code );
|
534 |
-
} else {
|
535 |
-
global $woocommerce;
|
536 |
-
$woocommerce->add_inline_js( $code );
|
537 |
-
}
|
538 |
-
}
|
539 |
-
|
540 |
-
/**
|
541 |
-
* Get message
|
542 |
-
* @return string Error
|
543 |
-
*/
|
544 |
-
private function get_message( $message, $type = 'error' ) {
|
545 |
-
ob_start();
|
546 |
-
|
547 |
-
?>
|
548 |
-
<div class="<?php echo $type ?>">
|
549 |
-
<p><?php echo $message ?></p>
|
550 |
-
</div>
|
551 |
-
<?php
|
552 |
-
return ob_get_clean();
|
553 |
-
}
|
554 |
-
|
555 |
-
/**
|
556 |
-
* API Instance Singleton
|
557 |
-
* @return Object
|
558 |
-
*/
|
559 |
-
public function mailchimp( $api_key = null ) {
|
560 |
-
|
561 |
-
$sswcmc = SSWCMC();
|
562 |
-
|
563 |
-
return $sswcmc->mailchimp( $api_key );
|
564 |
-
|
565 |
-
}
|
566 |
-
|
567 |
-
/**
|
568 |
-
* get_lists function.
|
569 |
-
*
|
570 |
-
* @access public
|
571 |
-
* @return void
|
572 |
-
*/
|
573 |
-
public function get_lists() {
|
574 |
-
|
575 |
-
if ( $this->mailchimp() ) {
|
576 |
-
$mailchimp_lists = $this->mailchimp()->get_lists();
|
577 |
-
} else {
|
578 |
-
return false;
|
579 |
-
}
|
580 |
-
|
581 |
-
if ( $mailchimp_lists === false ) {
|
582 |
-
|
583 |
-
add_action( 'admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
584 |
-
add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
585 |
-
|
586 |
-
return false;
|
587 |
-
|
588 |
-
}
|
589 |
-
|
590 |
-
if ( count( $mailchimp_lists ) === 0 ) {
|
591 |
-
$default = array(
|
592 |
-
'no_lists' => __( 'Oops! No lists in your MailChimp account...', 'woocommerce-mailchimp' ),
|
593 |
-
);
|
594 |
-
add_action( 'admin_notices', array( $this, 'mailchimp_no_lists_found' ) );
|
595 |
-
} else {
|
596 |
-
$default = array(
|
597 |
-
'' => __( 'Select a list...', 'woocommerce-mailchimp' ),
|
598 |
-
);
|
599 |
-
}
|
600 |
-
$mailchimp_lists = $default + $mailchimp_lists;
|
601 |
-
|
602 |
-
return $mailchimp_lists;
|
603 |
-
|
604 |
-
}
|
605 |
-
|
606 |
-
/**
|
607 |
-
* get_interest_groups function.
|
608 |
-
*
|
609 |
-
* @access public
|
610 |
-
* @return void
|
611 |
-
*/
|
612 |
-
public function get_interest_groups() {
|
613 |
-
|
614 |
-
if ( $this->mailchimp() && $this->has_list() ) {
|
615 |
-
$interest_groups = $this->mailchimp()->get_interest_categories_with_interests( $this->get_list() );
|
616 |
-
} else {
|
617 |
-
return array();
|
618 |
-
}
|
619 |
-
|
620 |
-
if ( $interest_groups === false ) {
|
621 |
-
|
622 |
-
add_action( 'admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
623 |
-
add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
624 |
-
|
625 |
-
return array();
|
626 |
-
|
627 |
-
}
|
628 |
-
|
629 |
-
return $interest_groups;
|
630 |
-
|
631 |
-
}
|
632 |
-
|
633 |
-
/**
|
634 |
-
* Inform the user they don't have any MailChimp lists
|
635 |
-
*/
|
636 |
-
public function mailchimp_no_lists_found() {
|
637 |
-
echo $this->get_message( sprintf( __( 'Oops! There are no lists in your MailChimp account. %sClick here%s to create one.', 'woocommerce-mailchimp' ), '<a href="https://admin.mailchimp.com/lists/new-list/" target="_blank">', '</a>' ) );
|
638 |
-
}
|
639 |
-
|
640 |
-
/**
|
641 |
-
* Display message to user if there is an issue with the MailChimp API call
|
642 |
-
*
|
643 |
-
* @since 1.0
|
644 |
-
* @param void
|
645 |
-
* @return html the message for the user
|
646 |
-
*/
|
647 |
-
public function mailchimp_api_error_msg() {
|
648 |
-
echo $this->get_message(
|
649 |
-
sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'woocommerce-mailchimp' ), $this->mailchimp()->get_error_code(), $this->mailchimp()->get_error_message() ) .
|
650 |
-
sprintf( __( 'Please check your Settings %ssettings%s.', 'woocommerce-mailchimp' ), '<a href="' . SS_WC_MAILCHIMP_SETTINGS_URL .'">', '</a>' )
|
651 |
-
);
|
652 |
-
} //end function mailchimp_api_error_msg
|
653 |
-
|
654 |
-
/**
|
655 |
-
* Helper log function for debugging
|
656 |
-
*
|
657 |
-
* @since 1.2.2
|
658 |
-
*/
|
659 |
-
private function log( $message ) {
|
660 |
-
if ( $this->debug_enabled() ) {
|
661 |
-
$logger = new WC_Logger();
|
662 |
-
|
663 |
-
if ( is_array( $message ) || is_object( $message ) ) {
|
664 |
-
$logger->add( 'woocommerce-mailchimp', print_r( $message, true ) );
|
665 |
-
}
|
666 |
-
else {
|
667 |
-
$logger->add( 'woocommerce-mailchimp', $message );
|
668 |
-
}
|
669 |
-
}
|
670 |
-
}
|
671 |
-
|
672 |
-
public function sysinfo_field( $value ) {
|
673 |
-
|
674 |
-
// $option_value = self::get_option( $value['id'], $value['default'] );
|
675 |
-
$option_value = SS_System_Info::get_system_info();
|
676 |
-
// Description handling
|
677 |
-
$field_description = WC_Admin_Settings::get_field_description( $value );
|
678 |
-
extract( $field_description );
|
679 |
-
?>
|
680 |
-
<tr valign="top">
|
681 |
-
<th scope="row" class="titledesc">
|
682 |
-
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
683 |
-
<?php echo $tooltip_html; ?>
|
684 |
-
</th>
|
685 |
-
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
|
686 |
-
<?php echo $description; ?>
|
687 |
-
|
688 |
-
<textarea
|
689 |
-
name="<?php echo esc_attr( $value['id'] ); ?>"
|
690 |
-
id="<?php echo esc_attr( $value['id'] ); ?>"
|
691 |
-
style="font-family: Menlo,Monaco,monospace;display: block; overflow: auto; white-space: pre; width: 800px; height: 400px;<?php echo esc_attr( $value['css'] ); ?>"
|
692 |
-
class="<?php echo esc_attr( $value['class'] ); ?>"
|
693 |
-
placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
|
694 |
-
readonly="readonly" onclick="this.focus(); this.select()"
|
695 |
-
<?php //echo implode( ' ', $custom_attributes ); ?>
|
696 |
-
><?php echo esc_textarea( $option_value ); ?></textarea>
|
697 |
-
</td>
|
698 |
-
</tr>
|
699 |
-
<?php
|
700 |
-
}
|
701 |
-
|
702 |
-
} //end class SS_WC_MailChimp
|
703 |
-
|
704 |
-
return SS_WC_Settings_MailChimp::get_instance();
|
705 |
-
|
706 |
-
} //end if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) )
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce MailChimp Settings
|
4 |
+
*
|
5 |
+
* @author Saint Systems
|
6 |
+
* @package WooCommerce MailChimp
|
7 |
+
* @version 2.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
11 |
+
|
12 |
+
if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @class SS_WC_Settings_MailChimp
|
16 |
+
* @extends WC_Settings_Page
|
17 |
+
*/
|
18 |
+
class SS_WC_Settings_MailChimp extends WC_Settings_Page {
|
19 |
+
|
20 |
+
private static $instance;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Singleton instance
|
24 |
+
*
|
25 |
+
* @return SS_WC_Settings_MailChimp SS_WC_Settings_MailChimp object
|
26 |
+
*/
|
27 |
+
public static function get_instance() {
|
28 |
+
|
29 |
+
if ( empty( self::$instance ) ) {
|
30 |
+
self::$instance = new self;
|
31 |
+
}
|
32 |
+
|
33 |
+
return self::$instance;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Constructor
|
38 |
+
*
|
39 |
+
* @access public
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
+
public function __construct() {
|
43 |
+
|
44 |
+
$this->id = 'mailchimp';
|
45 |
+
$this->namespace = 'ss_wc_' . $this->id;
|
46 |
+
$this->label = __( 'MailChimp', 'woocommerce-mailchimp' );
|
47 |
+
$this->init();
|
48 |
+
|
49 |
+
$this->register_hooks();
|
50 |
+
|
51 |
+
} //end function __construct
|
52 |
+
|
53 |
+
/**
|
54 |
+
* api_key function.
|
55 |
+
* @return string MailChimp API Key
|
56 |
+
*/
|
57 |
+
public function api_key() {
|
58 |
+
return $this->get_option( 'api_key' );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* is_enabled function.
|
63 |
+
*
|
64 |
+
* @access public
|
65 |
+
* @return boolean
|
66 |
+
*/
|
67 |
+
public function is_enabled() {
|
68 |
+
return 'yes' === $this->get_option( 'enabled' );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* occurs function
|
73 |
+
* @return string
|
74 |
+
*/
|
75 |
+
public function occurs() {
|
76 |
+
return $this->get_option( 'occurs' );
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* get_list function.
|
81 |
+
*
|
82 |
+
* @access public
|
83 |
+
* @return string MailChimp list ID
|
84 |
+
*/
|
85 |
+
public function get_list() {
|
86 |
+
return $this->get_option( 'list' );
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* double_opt_in function.
|
91 |
+
*
|
92 |
+
* @access public
|
93 |
+
* @return boolean
|
94 |
+
*/
|
95 |
+
public function double_opt_in() {
|
96 |
+
return 'yes' === $this->get_option( 'double_opt_in' );
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* display_opt_in function.
|
101 |
+
*
|
102 |
+
* @access public
|
103 |
+
* @return boolean
|
104 |
+
*/
|
105 |
+
public function display_opt_in() {
|
106 |
+
return 'yes' === $this->get_option( 'display_opt_in' );
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* opt_in_label function.
|
111 |
+
*
|
112 |
+
* @access public
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
public function opt_in_label() {
|
116 |
+
return $this->get_option( 'opt_in_label' );
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* opt_in_checkbox_default_status function.
|
121 |
+
*
|
122 |
+
* @access public
|
123 |
+
* @return string
|
124 |
+
*/
|
125 |
+
public function opt_in_checkbox_default_status() {
|
126 |
+
return $this->get_option( 'opt_in_checkbox_default_status' );
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* opt_in_checkbox_display_location function.
|
131 |
+
*
|
132 |
+
* @access public
|
133 |
+
* @return string
|
134 |
+
*/
|
135 |
+
public function opt_in_checkbox_display_location() {
|
136 |
+
return $this->get_option( 'opt_in_checkbox_display_location' );
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* interests function.
|
141 |
+
*
|
142 |
+
* @access public
|
143 |
+
* @return array
|
144 |
+
*/
|
145 |
+
public function interest_groups() {
|
146 |
+
return $this->get_option( 'interest_groups' );
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* has_list function.
|
151 |
+
*
|
152 |
+
* @access public
|
153 |
+
* @return boolean
|
154 |
+
*/
|
155 |
+
public function has_list() {
|
156 |
+
if ( $this->get_list() ) {
|
157 |
+
return true;
|
158 |
+
}
|
159 |
+
return false;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* has_api_key function.
|
164 |
+
*
|
165 |
+
* @access public
|
166 |
+
* @return boolean
|
167 |
+
*/
|
168 |
+
public function has_api_key() {
|
169 |
+
$api_key = $this->api_key();
|
170 |
+
return !empty( $api_key );
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* is_valid function.
|
175 |
+
*
|
176 |
+
* @access public
|
177 |
+
* @return boolean
|
178 |
+
*/
|
179 |
+
public function is_valid() {
|
180 |
+
return $this->is_enabled() && $this->has_api_key() && $this->has_list();
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* debug_enabled function.
|
185 |
+
*
|
186 |
+
* @access public
|
187 |
+
* @return boolean
|
188 |
+
*/
|
189 |
+
public function debug_enabled() {
|
190 |
+
return 'yes' === $this->get_option( 'debug' );
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Check if the user has enabled the plugin functionality, but hasn't provided an api key
|
195 |
+
**/
|
196 |
+
function checks() {
|
197 |
+
// Check required fields
|
198 |
+
if ( $this->is_enabled() && ! $this->has_api_key() ) {
|
199 |
+
// Show notice
|
200 |
+
echo $this->get_message( sprintf( __( 'WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter your api key <a href="%s">here</a>.', 'woocommerce-mailchimp' ), SS_WC_MAILCHIMP_SETTINGS_URL )
|
201 |
+
);
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
public function init() {
|
206 |
+
|
207 |
+
$this->api_key = $this->get_option( 'api_key' );
|
208 |
+
|
209 |
+
$this->enabled = $this->get_option( 'enabled' );
|
210 |
+
|
211 |
+
}
|
212 |
+
|
213 |
+
public function get_option( $option_suffix ) {
|
214 |
+
|
215 |
+
return get_option( $this->namespace_prefixed( $option_suffix ) );
|
216 |
+
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Register plugin hooks
|
221 |
+
*
|
222 |
+
* @access public
|
223 |
+
* @return void
|
224 |
+
*/
|
225 |
+
public function register_hooks() {
|
226 |
+
|
227 |
+
// Hook in to add the MailChimp tab
|
228 |
+
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
|
229 |
+
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
|
230 |
+
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
|
231 |
+
add_action( 'woocommerce_sections_' . $this->id, array( $this, 'output_sections' ) );
|
232 |
+
add_action( 'woocommerce_settings_saved', array( $this, 'init' ) );
|
233 |
+
|
234 |
+
// Hooks
|
235 |
+
add_action( 'admin_notices', array( $this, 'checks' ) );
|
236 |
+
add_action( 'woocommerce_admin_field_sysinfo', array( $this, 'sysinfo_field' ), 10, 1 );
|
237 |
+
|
238 |
+
} //end function ensure_tab
|
239 |
+
|
240 |
+
// /**
|
241 |
+
// * Get sections
|
242 |
+
// *
|
243 |
+
// * @return array
|
244 |
+
// */
|
245 |
+
public function get_sections() {
|
246 |
+
|
247 |
+
$sections = array();
|
248 |
+
|
249 |
+
$sections[''] = __( 'General', 'woocommerce-mailchimp' );
|
250 |
+
|
251 |
+
if ( $this->has_api_key() ) {
|
252 |
+
$sections['troubleshooting'] = __( 'Troubleshooting', 'woocommerce-mailchimp' );
|
253 |
+
}
|
254 |
+
|
255 |
+
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Output the settings
|
260 |
+
*/
|
261 |
+
public function output() {
|
262 |
+
|
263 |
+
global $current_section;
|
264 |
+
|
265 |
+
$settings = $this->get_settings( $current_section );
|
266 |
+
|
267 |
+
WC_Admin_Settings::output_fields( $settings );
|
268 |
+
|
269 |
+
$this->wc_enqueue_js("
|
270 |
+
(function($){
|
271 |
+
|
272 |
+
$(document).ready(function() {
|
273 |
+
SS_WC_MailChimp.init();
|
274 |
+
});
|
275 |
+
|
276 |
+
})(jQuery);
|
277 |
+
");
|
278 |
+
|
279 |
+
do_action( 'ss_wc_mailchimp_after_settings_enqueue_js' );
|
280 |
+
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Save settings
|
285 |
+
*/
|
286 |
+
public function save() {
|
287 |
+
global $current_section;
|
288 |
+
|
289 |
+
$settings = $this->get_settings( $current_section );
|
290 |
+
|
291 |
+
WC_Admin_Settings::save_fields( $settings );
|
292 |
+
|
293 |
+
if ( !isset( $_POST[ 'ss_wc_mailchimp_api_key' ] ) || empty( $_POST[ 'ss_wc_mailchimp_api_key' ] ) ) {
|
294 |
+
delete_transient( 'sswcmc_lists' );
|
295 |
+
}
|
296 |
+
|
297 |
+
$sswcmc = SSWCMC();
|
298 |
+
// Trigger reload of plugin settings
|
299 |
+
$settings = $sswcmc->settings( true );
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Get settings array
|
305 |
+
*
|
306 |
+
* @return array
|
307 |
+
*/
|
308 |
+
public function get_settings( $current_section = '' ) {
|
309 |
+
|
310 |
+
$settings = array();
|
311 |
+
|
312 |
+
if ( '' === $current_section ) {
|
313 |
+
|
314 |
+
$settings = array(
|
315 |
+
array(
|
316 |
+
'title' => __( 'MailChimp', 'woocommerce-mailchimp' ),
|
317 |
+
'type' => 'title',
|
318 |
+
'desc' => __( 'Enter your MailChimp settings below to control how WooCommerce integrates with your MailChimp account.', 'woocommerce-mailchimp' ),
|
319 |
+
'id' => 'general_options',
|
320 |
+
),
|
321 |
+
);
|
322 |
+
|
323 |
+
$settings[] = array(
|
324 |
+
'id' => $this->namespace_prefixed( 'api_key' ),
|
325 |
+
'title' => __( 'API Key', 'woocommerce-mailchimp' ),
|
326 |
+
'type' => 'text',
|
327 |
+
'desc' => sprintf( __( '%sLogin to MailChimp%s to look up your api key.', 'woocommerce-mailchimp' ), '<br/><a href="https://admin.mailchimp.com/account/api/" target="_blank">', '</a>'
|
328 |
+
),
|
329 |
+
'placeholder' => __( 'Paste your MailChimp API key here', 'woocommerce-mailchimp' ),
|
330 |
+
'default' => '',
|
331 |
+
'css' => 'min-width:350px;',
|
332 |
+
'desc_tip' => 'Your API Key is required for the plugin to communicate with your MailChimp account.',
|
333 |
+
);
|
334 |
+
|
335 |
+
$settings[] = array(
|
336 |
+
'id' => $this->namespace_prefixed( 'enabled' ),
|
337 |
+
'title' => __( 'Enable/Disable', 'woocommerce-mailchimp' ),
|
338 |
+
'label' => __( 'Enable MailChimp Integration', 'woocommerce-mailchimp' ),
|
339 |
+
'type' => 'checkbox',
|
340 |
+
'desc' => __( 'Enable/disable the plugin functionality.', 'woocommerce-mailchimp' ),
|
341 |
+
'default' => 'yes',
|
342 |
+
);
|
343 |
+
|
344 |
+
$mailchimp_lists = $this->get_lists();
|
345 |
+
|
346 |
+
if ( $this->has_api_key() && $this->has_list() ) {
|
347 |
+
$interest_groups = $this->get_interest_groups();
|
348 |
+
} else {
|
349 |
+
$interest_groups = array();
|
350 |
+
}
|
351 |
+
|
352 |
+
$settings[] = array(
|
353 |
+
'id' => $this->namespace_prefixed( 'list' ),
|
354 |
+
'title' => __( 'Main List', 'woocommerce-mailchimp' ),
|
355 |
+
'type' => 'select',
|
356 |
+
'desc' => __( 'All customers will be added to this list.', 'woocommerce-mailchimp' ),
|
357 |
+
'default' => '',
|
358 |
+
'options' => $mailchimp_lists,
|
359 |
+
'class' => 'wc-enhanced-select',
|
360 |
+
'css' => 'min-width: 350px;',
|
361 |
+
'desc_tip' => true,
|
362 |
+
);
|
363 |
+
|
364 |
+
$settings[] = array(
|
365 |
+
'id' => $this->namespace_prefixed( 'interest_groups' ),
|
366 |
+
'title' => __( 'Interest Groups', 'woocommerce-mailchimp' ),
|
367 |
+
'type' => 'multiselect',
|
368 |
+
'desc' => __( 'Optional: Interest groups to assign to subscribers.', 'woocommerce-mailchimp' ),
|
369 |
+
'default' => '',
|
370 |
+
'options' => $interest_groups,
|
371 |
+
'class' => 'wc-enhanced-select',
|
372 |
+
'custom_attributes' => array(
|
373 |
+
'placeholder' => __( 'Select interest groups...', 'woocommerce-mailchimp' ),
|
374 |
+
),
|
375 |
+
'css' => 'min-width: 350px;',
|
376 |
+
'desc_tip' => true,
|
377 |
+
);
|
378 |
+
|
379 |
+
$settings = apply_filters( $this->namespace_prefixed( 'settings_general_after_interest_groups' ), $settings );
|
380 |
+
|
381 |
+
$settings[] = array(
|
382 |
+
'id' => $this->namespace_prefixed( 'occurs' ),
|
383 |
+
'title' => __( 'Subscribe Event', 'woocommerce-mailchimp' ),
|
384 |
+
'type' => 'select',
|
385 |
+
'desc' => __( 'Choose whether to subscribe customers as soon as an order is placed or after the order is processing or completed.', 'woocommerce-mailchimp' ),
|
386 |
+
'class' => 'wc-enhanced-select',
|
387 |
+
'default' => 'pending',
|
388 |
+
'options' => array(
|
389 |
+
'pending' => __( 'Order Created', 'woocommerce-mailchimp' ),
|
390 |
+
'processing' => __( 'Order Processing', 'woocommerce-mailchimp' ),
|
391 |
+
'completed' => __( 'Order Completed', 'woocommerce-mailchimp' ),
|
392 |
+
),
|
393 |
+
'desc_tip' => true,
|
394 |
+
);
|
395 |
+
|
396 |
+
$settings[] = array(
|
397 |
+
'id' => $this->namespace_prefixed( 'double_opt_in' ),
|
398 |
+
'title' => __( 'Double Opt-In', 'woocommerce-mailchimp' ),
|
399 |
+
'desc' => __( 'Enable Double Opt-In', 'woocommerce-mailchimp' ),
|
400 |
+
'type' => 'checkbox',
|
401 |
+
'default' => 'no',
|
402 |
+
'desc_tip' => __( 'If enabled, customers will receive an email prompting them to confirm their subscription to the list above.', 'woocommerce-mailchimp' ),
|
403 |
+
);
|
404 |
+
|
405 |
+
$settings[] = array(
|
406 |
+
'id' => $this->namespace_prefixed( 'display_opt_in' ),
|
407 |
+
'title' => __( 'Subscribe Customers', 'woocommerce-mailchimp' ),
|
408 |
+
'desc' => __( '<p>Choose <strong>Ask for permission</strong> to show an "Opt-in" checkbox during checkout. Customers will only be subscribed to the list above if they opt-in. <p>Choose <strong>Automatically</strong> to subscribe customers silently upon checkout. Caution, this is without the customer\'s consent.</p>', 'woocommerce-mailchimp' ),
|
409 |
+
'type' => 'select',
|
410 |
+
'css' => 'min-width:300px;',
|
411 |
+
'class' => 'wc-enhanced-select',
|
412 |
+
'desc_tip' => true,
|
413 |
+
'default' => 'yes',
|
414 |
+
'options' => array(
|
415 |
+
// '0' => __( 'Disabled', 'woocommerce-mailchimp' ),
|
416 |
+
'yes' => __( 'Ask for permission', 'woocommerce-mailchimp' ),
|
417 |
+
'no' => __( 'Automatically', 'woocommerce-mailchimp' ),
|
418 |
+
)
|
419 |
+
);
|
420 |
+
|
421 |
+
$settings[] = array(
|
422 |
+
'id' => $this->namespace_prefixed( 'opt_in_label' ),
|
423 |
+
'title' => __( 'Opt-In Field Label', 'woocommerce-mailchimp' ),
|
424 |
+
'type' => 'text',
|
425 |
+
'desc' => __( 'Optional: customize the label displayed next to the opt-in checkbox.', 'woocommerce-mailchimp' ),
|
426 |
+
'default' => __( 'Subscribe to our newsletter', 'woocommerce-mailchimp' ),
|
427 |
+
'css' => 'min-width:350px;',
|
428 |
+
'desc_tip' => true,
|
429 |
+
);
|
430 |
+
|
431 |
+
$settings[] = array(
|
432 |
+
'id' => $this->namespace_prefixed( 'opt_in_checkbox_default_status' ),
|
433 |
+
'title' => __( 'Opt-In Checkbox Default', 'woocommerce-mailchimp' ),
|
434 |
+
'type' => 'select',
|
435 |
+
'desc' => __( 'The default state of the opt-in checkbox.', 'woocommerce-mailchimp' ),
|
436 |
+
'class' => 'wc-enhanced-select',
|
437 |
+
'default' => 'checked',
|
438 |
+
'options' => array(
|
439 |
+
'checked' => __( 'Checked', 'woocommerce-mailchimp' ),
|
440 |
+
'unchecked' => __( 'Unchecked', 'woocommerce-mailchimp' )
|
441 |
+
),
|
442 |
+
'desc_tip' => true,
|
443 |
+
);
|
444 |
+
|
445 |
+
$settings[] = array(
|
446 |
+
'id' => $this->namespace_prefixed( 'opt_in_checkbox_display_location' ),
|
447 |
+
'title' => __( 'Opt-In Checkbox Location', 'woocommerce-mailchimp' ),
|
448 |
+
'type' => 'select',
|
449 |
+
'desc' => __( 'Where to display the opt-in checkbox on the checkout page.', 'woocommerce-mailchimp' ),
|
450 |
+
'class' => 'wc-enhanced-select',
|
451 |
+
'default' => 'woocommerce_review_order_before_submit',
|
452 |
+
'options' => array(
|
453 |
+
'woocommerce_checkout_before_customer_details' => __( 'Above customer details', 'woocommerce-mailchimp' ),
|
454 |
+
'woocommerce_checkout_after_customer_details' => __( 'Below customer details', 'woocommerce-mailchimp' ),
|
455 |
+
'woocommerce_checkout_before_order_review' => __( 'Order review above cart/product table.', 'woocommerce-mailchimp' ),
|
456 |
+
'woocommerce_review_order_before_submit' => __( 'Order review above submit', 'woocommerce-mailchimp' ),
|
457 |
+
'woocommerce_review_order_after_submit' => __( 'Order review below submit', 'woocommerce-mailchimp' ),
|
458 |
+
'woocommerce_review_order_before_order_total' => __( 'Order review above total', 'woocommerce-mailchimp' ),
|
459 |
+
'woocommerce_checkout_billing' => __( 'Above billing details', 'woocommerce-mailchimp' ),
|
460 |
+
'woocommerce_checkout_shipping' => __( 'Above shipping details', 'woocommerce-mailchimp' ),
|
461 |
+
'woocommerce_after_checkout_billing_form' => __( 'Below Checkout billing form', 'woocommerce-mailchimp' ),
|
462 |
+
'woocommerce_checkout_before_terms_and_conditions' => __( 'Above Checkout Terms and Conditions', 'woocommerce-mailchimp' ),
|
463 |
+
'woocommerce_checkout_after_terms_and_conditions' => __( 'Below Checkout Terms and Conditions', 'woocommerce-mailchimp' ),
|
464 |
+
),
|
465 |
+
'desc_tip' => true,
|
466 |
+
);
|
467 |
+
|
468 |
+
$settings = apply_filters( $this->namespace_prefixed( 'settings_general' ), $settings );
|
469 |
+
|
470 |
+
$settings[] = array( 'type' => 'sectionend', 'id' => 'general_options' );
|
471 |
+
|
472 |
+
} elseif ( 'troubleshooting' === $current_section ) {
|
473 |
+
|
474 |
+
$label = __( 'Enable Logging', 'woocommerce-mailchimp' );
|
475 |
+
|
476 |
+
if ( defined( 'WC_LOG_DIR' ) ) {
|
477 |
+
$debug_log_url = add_query_arg( 'tab', 'logs', add_query_arg( 'page', 'wc-status', admin_url( 'admin.php' ) ) );
|
478 |
+
$debug_log_key = 'woocommerce-mailchimp-' . sanitize_file_name( wp_hash( 'woocommerce-mailchimp' ) ) . '-log';
|
479 |
+
$debug_log_url = add_query_arg( 'log_file', $debug_log_key, $debug_log_url );
|
480 |
+
|
481 |
+
$label .= ' | ' . sprintf( __( '%1$sView Log%2$s', 'woocommerce-mailchimp' ), '<a href="' . esc_url( $debug_log_url ) . '">', '</a>' );
|
482 |
+
}
|
483 |
+
|
484 |
+
$settings[] = array(
|
485 |
+
'title' => __( 'Troubleshooting', 'woocommerce-mailchimp' ),
|
486 |
+
'type' => 'title',
|
487 |
+
'desc' => '',
|
488 |
+
'id' => 'troubleshooting_settings'
|
489 |
+
);
|
490 |
+
|
491 |
+
$settings[] = array(
|
492 |
+
'id' => $this->namespace_prefixed( 'debug' ),
|
493 |
+
'title' => __( 'Debug Log', 'woocommerce-mailchimp' ),
|
494 |
+
'desc' => $label,
|
495 |
+
'type' => 'checkbox',
|
496 |
+
'default' => 'no',
|
497 |
+
'desc_tip' => __( 'Enable logging MailChimp API calls. Only enable for troubleshooting purposes.', 'woocommerce-mailchimp' ),
|
498 |
+
);
|
499 |
+
|
500 |
+
$settings[] = array(
|
501 |
+
'id' => 'sysinfo',
|
502 |
+
'title' => __( 'System Info', 'woocommerce-mailchimp' ),
|
503 |
+
'type' => 'sysinfo',
|
504 |
+
'desc' => __( 'Copy the information below and send it to us when reporting an issue with the plugin.', 'woocommerce-mailchimp' ) . '<p/>',
|
505 |
+
'desc_tip' => '',
|
506 |
+
);
|
507 |
+
|
508 |
+
$settings[] = array( 'type' => 'sectionend', 'id' => 'troubleshooting_settings' );
|
509 |
+
|
510 |
+
$settings = apply_filters( $this->namespace_prefixed( 'settings_troubleshooting' ), $settings );
|
511 |
+
|
512 |
+
}
|
513 |
+
|
514 |
+
return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings, $current_section );
|
515 |
+
|
516 |
+
} //end function get_settings
|
517 |
+
|
518 |
+
private function namespace_prefixed( $value ) {
|
519 |
+
return $this->namespace . '_' . $value;
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* WooCommerce 2.1 support for wc_enqueue_js
|
524 |
+
*
|
525 |
+
* @since 1.2.1
|
526 |
+
*
|
527 |
+
* @access private
|
528 |
+
* @param string $code
|
529 |
+
* @return void
|
530 |
+
*/
|
531 |
+
private function wc_enqueue_js( $code ) {
|
532 |
+
if ( function_exists( 'wc_enqueue_js' ) ) {
|
533 |
+
wc_enqueue_js( $code );
|
534 |
+
} else {
|
535 |
+
global $woocommerce;
|
536 |
+
$woocommerce->add_inline_js( $code );
|
537 |
+
}
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
* Get message
|
542 |
+
* @return string Error
|
543 |
+
*/
|
544 |
+
private function get_message( $message, $type = 'error' ) {
|
545 |
+
ob_start();
|
546 |
+
|
547 |
+
?>
|
548 |
+
<div class="<?php echo $type ?>">
|
549 |
+
<p><?php echo $message ?></p>
|
550 |
+
</div>
|
551 |
+
<?php
|
552 |
+
return ob_get_clean();
|
553 |
+
}
|
554 |
+
|
555 |
+
/**
|
556 |
+
* API Instance Singleton
|
557 |
+
* @return Object
|
558 |
+
*/
|
559 |
+
public function mailchimp( $api_key = null ) {
|
560 |
+
|
561 |
+
$sswcmc = SSWCMC();
|
562 |
+
|
563 |
+
return $sswcmc->mailchimp( $api_key );
|
564 |
+
|
565 |
+
}
|
566 |
+
|
567 |
+
/**
|
568 |
+
* get_lists function.
|
569 |
+
*
|
570 |
+
* @access public
|
571 |
+
* @return void
|
572 |
+
*/
|
573 |
+
public function get_lists() {
|
574 |
+
|
575 |
+
if ( $this->mailchimp() ) {
|
576 |
+
$mailchimp_lists = $this->mailchimp()->get_lists();
|
577 |
+
} else {
|
578 |
+
return false;
|
579 |
+
}
|
580 |
+
|
581 |
+
if ( $mailchimp_lists === false ) {
|
582 |
+
|
583 |
+
add_action( 'admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
584 |
+
add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
585 |
+
|
586 |
+
return false;
|
587 |
+
|
588 |
+
}
|
589 |
+
|
590 |
+
if ( count( $mailchimp_lists ) === 0 ) {
|
591 |
+
$default = array(
|
592 |
+
'no_lists' => __( 'Oops! No lists in your MailChimp account...', 'woocommerce-mailchimp' ),
|
593 |
+
);
|
594 |
+
add_action( 'admin_notices', array( $this, 'mailchimp_no_lists_found' ) );
|
595 |
+
} else {
|
596 |
+
$default = array(
|
597 |
+
'' => __( 'Select a list...', 'woocommerce-mailchimp' ),
|
598 |
+
);
|
599 |
+
}
|
600 |
+
$mailchimp_lists = $default + $mailchimp_lists;
|
601 |
+
|
602 |
+
return $mailchimp_lists;
|
603 |
+
|
604 |
+
}
|
605 |
+
|
606 |
+
/**
|
607 |
+
* get_interest_groups function.
|
608 |
+
*
|
609 |
+
* @access public
|
610 |
+
* @return void
|
611 |
+
*/
|
612 |
+
public function get_interest_groups() {
|
613 |
+
|
614 |
+
if ( $this->mailchimp() && $this->has_list() ) {
|
615 |
+
$interest_groups = $this->mailchimp()->get_interest_categories_with_interests( $this->get_list() );
|
616 |
+
} else {
|
617 |
+
return array();
|
618 |
+
}
|
619 |
+
|
620 |
+
if ( $interest_groups === false ) {
|
621 |
+
|
622 |
+
add_action( 'admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
623 |
+
add_action( 'network_admin_notices', array( $this, 'mailchimp_api_error_msg' ) );
|
624 |
+
|
625 |
+
return array();
|
626 |
+
|
627 |
+
}
|
628 |
+
|
629 |
+
return $interest_groups;
|
630 |
+
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* Inform the user they don't have any MailChimp lists
|
635 |
+
*/
|
636 |
+
public function mailchimp_no_lists_found() {
|
637 |
+
echo $this->get_message( sprintf( __( 'Oops! There are no lists in your MailChimp account. %sClick here%s to create one.', 'woocommerce-mailchimp' ), '<a href="https://admin.mailchimp.com/lists/new-list/" target="_blank">', '</a>' ) );
|
638 |
+
}
|
639 |
+
|
640 |
+
/**
|
641 |
+
* Display message to user if there is an issue with the MailChimp API call
|
642 |
+
*
|
643 |
+
* @since 1.0
|
644 |
+
* @param void
|
645 |
+
* @return html the message for the user
|
646 |
+
*/
|
647 |
+
public function mailchimp_api_error_msg() {
|
648 |
+
echo $this->get_message(
|
649 |
+
sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'woocommerce-mailchimp' ), $this->mailchimp()->get_error_code(), $this->mailchimp()->get_error_message() ) .
|
650 |
+
sprintf( __( 'Please check your Settings %ssettings%s.', 'woocommerce-mailchimp' ), '<a href="' . SS_WC_MAILCHIMP_SETTINGS_URL .'">', '</a>' )
|
651 |
+
);
|
652 |
+
} //end function mailchimp_api_error_msg
|
653 |
+
|
654 |
+
/**
|
655 |
+
* Helper log function for debugging
|
656 |
+
*
|
657 |
+
* @since 1.2.2
|
658 |
+
*/
|
659 |
+
private function log( $message ) {
|
660 |
+
if ( $this->debug_enabled() ) {
|
661 |
+
$logger = new WC_Logger();
|
662 |
+
|
663 |
+
if ( is_array( $message ) || is_object( $message ) ) {
|
664 |
+
$logger->add( 'woocommerce-mailchimp', print_r( $message, true ) );
|
665 |
+
}
|
666 |
+
else {
|
667 |
+
$logger->add( 'woocommerce-mailchimp', $message );
|
668 |
+
}
|
669 |
+
}
|
670 |
+
}
|
671 |
+
|
672 |
+
public function sysinfo_field( $value ) {
|
673 |
+
|
674 |
+
// $option_value = self::get_option( $value['id'], $value['default'] );
|
675 |
+
$option_value = SS_System_Info::get_system_info();
|
676 |
+
// Description handling
|
677 |
+
$field_description = WC_Admin_Settings::get_field_description( $value );
|
678 |
+
extract( $field_description );
|
679 |
+
?>
|
680 |
+
<tr valign="top">
|
681 |
+
<th scope="row" class="titledesc">
|
682 |
+
<label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
|
683 |
+
<?php echo $tooltip_html; ?>
|
684 |
+
</th>
|
685 |
+
<td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
|
686 |
+
<?php echo $description; ?>
|
687 |
+
|
688 |
+
<textarea
|
689 |
+
name="<?php echo esc_attr( $value['id'] ); ?>"
|
690 |
+
id="<?php echo esc_attr( $value['id'] ); ?>"
|
691 |
+
style="font-family: Menlo,Monaco,monospace;display: block; overflow: auto; white-space: pre; width: 800px; height: 400px;<?php echo esc_attr( $value['css'] ); ?>"
|
692 |
+
class="<?php echo esc_attr( $value['class'] ); ?>"
|
693 |
+
placeholder="<?php echo esc_attr( $value['placeholder'] ); ?>"
|
694 |
+
readonly="readonly" onclick="this.focus(); this.select()"
|
695 |
+
<?php //echo implode( ' ', $custom_attributes ); ?>
|
696 |
+
><?php echo esc_textarea( $option_value ); ?></textarea>
|
697 |
+
</td>
|
698 |
+
</tr>
|
699 |
+
<?php
|
700 |
+
}
|
701 |
+
|
702 |
+
} //end class SS_WC_MailChimp
|
703 |
+
|
704 |
+
return SS_WC_Settings_MailChimp::get_instance();
|
705 |
+
|
706 |
+
} //end if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) )
|
includes/helper-functions.php
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Utility helper functions
|
4 |
-
*/
|
5 |
-
|
6 |
-
/**
|
7 |
-
* sanitize_html_class doesn't handle spaces (multiple classes). We remedy that.
|
8 |
-
* @uses sanitize_html_class
|
9 |
-
* @param string|array $classes Text or arrray of classes to sanitize
|
10 |
-
* @return string Sanitized CSS string
|
11 |
-
*/
|
12 |
-
function sswcmc_sanitize_html_class( $classes ) {
|
13 |
-
|
14 |
-
if( is_string( $classes ) ) {
|
15 |
-
$classes = explode(' ', $classes );
|
16 |
-
}
|
17 |
-
|
18 |
-
// If someone passes something not string or array, we get outta here.
|
19 |
-
if( !is_array( $classes ) ) { return $classes; }
|
20 |
-
|
21 |
-
$classes = array_map( 'sanitize_html_class' , $classes );
|
22 |
-
|
23 |
-
return implode( ' ', $classes );
|
24 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Utility helper functions
|
4 |
+
*/
|
5 |
+
|
6 |
+
/**
|
7 |
+
* sanitize_html_class doesn't handle spaces (multiple classes). We remedy that.
|
8 |
+
* @uses sanitize_html_class
|
9 |
+
* @param string|array $classes Text or arrray of classes to sanitize
|
10 |
+
* @return string Sanitized CSS string
|
11 |
+
*/
|
12 |
+
function sswcmc_sanitize_html_class( $classes ) {
|
13 |
+
|
14 |
+
if( is_string( $classes ) ) {
|
15 |
+
$classes = explode(' ', $classes );
|
16 |
+
}
|
17 |
+
|
18 |
+
// If someone passes something not string or array, we get outta here.
|
19 |
+
if( !is_array( $classes ) ) { return $classes; }
|
20 |
+
|
21 |
+
$classes = array_map( 'sanitize_html_class' , $classes );
|
22 |
+
|
23 |
+
return implode( ' ', $classes );
|
24 |
}
|
includes/lib/class-ss-system-info.php
CHANGED
@@ -1,239 +1,239 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
-
|
5 |
-
if ( ! class_exists( 'SS_System_Info' ) ) {
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Helper class for generating system information on WordPress installations
|
9 |
-
*/
|
10 |
-
final class SS_System_Info {
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Get system info
|
14 |
-
*
|
15 |
-
* @since 2.0
|
16 |
-
* @access public
|
17 |
-
* @global object $wpdb Used to query the database using the WordPress Database API
|
18 |
-
* @return string $return A string containing the info to output
|
19 |
-
*/
|
20 |
-
public static function get_system_info() {
|
21 |
-
global $wpdb;
|
22 |
-
|
23 |
-
// Get theme info
|
24 |
-
$theme_data = wp_get_theme();
|
25 |
-
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
26 |
-
|
27 |
-
// Try to identify the hosting provider
|
28 |
-
$host = self::get_host();
|
29 |
-
|
30 |
-
$return = '### Begin System Info ###' . "\n\n";
|
31 |
-
|
32 |
-
// Start with the basics...
|
33 |
-
$return .= '-- Site Info' . "\n\n";
|
34 |
-
$return .= 'Site URL: ' . site_url() . "\n";
|
35 |
-
$return .= 'Home URL: ' . home_url() . "\n";
|
36 |
-
$return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
|
37 |
-
|
38 |
-
// Can we determine the site's host?
|
39 |
-
if( $host ) {
|
40 |
-
$return .= "\n" . '-- Hosting Provider' . "\n\n";
|
41 |
-
$return .= 'Host: ' . $host . "\n";
|
42 |
-
}
|
43 |
-
|
44 |
-
// WordPress configuration
|
45 |
-
$return .= "\n" . '-- WordPress Configuration' . "\n\n";
|
46 |
-
$return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
|
47 |
-
$return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
|
48 |
-
$return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
|
49 |
-
$return .= 'Active Theme: ' . $theme . "\n";
|
50 |
-
$return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
|
51 |
-
|
52 |
-
// Only show page specs if frontpage is set to 'page'
|
53 |
-
if( get_option( 'show_on_front' ) == 'page' ) {
|
54 |
-
$front_page_id = get_option( 'page_on_front' );
|
55 |
-
$blog_page_id = get_option( 'page_for_posts' );
|
56 |
-
|
57 |
-
$return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
|
58 |
-
$return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
|
59 |
-
}
|
60 |
-
|
61 |
-
$return .= 'ABSPATH: ' . ABSPATH . "\n";
|
62 |
-
|
63 |
-
// Make sure wp_remote_post() is working
|
64 |
-
$request['cmd'] = '_notify-validate';
|
65 |
-
|
66 |
-
$params = array(
|
67 |
-
'sslverify' => false,
|
68 |
-
'timeout' => 60,
|
69 |
-
'user-agent' => 'SS_System_Info/',
|
70 |
-
'body' => $request
|
71 |
-
);
|
72 |
-
|
73 |
-
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
74 |
-
|
75 |
-
if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
76 |
-
$WP_REMOTE_POST = 'wp_remote_post() works';
|
77 |
-
} else {
|
78 |
-
$WP_REMOTE_POST = 'wp_remote_post() does not work';
|
79 |
-
}
|
80 |
-
|
81 |
-
$return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
|
82 |
-
$return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
|
83 |
-
|
84 |
-
$return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
|
85 |
-
$return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
|
86 |
-
$return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
|
87 |
-
|
88 |
-
// Get plugins that have an update
|
89 |
-
$updates = get_plugin_updates();
|
90 |
-
|
91 |
-
// Must-use plugins
|
92 |
-
// NOTE: MU plugins can't show updates!
|
93 |
-
$muplugins = get_mu_plugins();
|
94 |
-
if( count( $muplugins ) > 0 ) {
|
95 |
-
$return .= "\n" . '-- Must-Use Plugins' . "\n\n";
|
96 |
-
|
97 |
-
foreach( $muplugins as $plugin => $plugin_data ) {
|
98 |
-
$return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
|
99 |
-
}
|
100 |
-
|
101 |
-
$return = apply_filters( 'edd_sysinfo_after_wordpress_mu_plugins', $return );
|
102 |
-
}
|
103 |
-
|
104 |
-
// WordPress active plugins
|
105 |
-
$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
|
106 |
-
|
107 |
-
$plugins = get_plugins();
|
108 |
-
$active_plugins = get_option( 'active_plugins', array() );
|
109 |
-
|
110 |
-
foreach( $plugins as $plugin_path => $plugin ) {
|
111 |
-
if( !in_array( $plugin_path, $active_plugins ) )
|
112 |
-
continue;
|
113 |
-
|
114 |
-
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
|
115 |
-
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
116 |
-
}
|
117 |
-
|
118 |
-
// WordPress inactive plugins
|
119 |
-
$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
|
120 |
-
|
121 |
-
foreach( $plugins as $plugin_path => $plugin ) {
|
122 |
-
if( in_array( $plugin_path, $active_plugins ) )
|
123 |
-
continue;
|
124 |
-
|
125 |
-
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
|
126 |
-
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
127 |
-
}
|
128 |
-
|
129 |
-
if( is_multisite() ) {
|
130 |
-
// WordPress Multisite active plugins
|
131 |
-
$return .= "\n" . '-- Network Active Plugins' . "\n\n";
|
132 |
-
|
133 |
-
$plugins = wp_get_active_network_plugins();
|
134 |
-
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
135 |
-
|
136 |
-
foreach( $plugins as $plugin_path ) {
|
137 |
-
$plugin_base = plugin_basename( $plugin_path );
|
138 |
-
|
139 |
-
if( !array_key_exists( $plugin_base, $active_plugins ) )
|
140 |
-
continue;
|
141 |
-
|
142 |
-
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
|
143 |
-
$plugin = get_plugin_data( $plugin_path );
|
144 |
-
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
145 |
-
}
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
// Server configuration (really just versioning)
|
150 |
-
$return .= "\n" . '-- Webserver Configuration' . "\n\n";
|
151 |
-
$return .= 'PHP Version: ' . PHP_VERSION . "\n";
|
152 |
-
$return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
|
153 |
-
$return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
|
154 |
-
|
155 |
-
// PHP configs... now we're getting to the important stuff
|
156 |
-
$return .= "\n" . '-- PHP Configuration' . "\n\n";
|
157 |
-
$return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
|
158 |
-
$return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
|
159 |
-
$return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
160 |
-
$return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
|
161 |
-
$return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
162 |
-
$return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
|
163 |
-
$return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
|
164 |
-
$return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
|
165 |
-
$return .= 'PHP Arg Separator: ' . ini_get( 'arg_separator.output' ) . "\n";
|
166 |
-
|
167 |
-
// PHP extensions and such
|
168 |
-
$return .= "\n" . '-- PHP Extensions' . "\n\n";
|
169 |
-
$return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
170 |
-
$return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
171 |
-
$return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
|
172 |
-
$return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
|
173 |
-
|
174 |
-
$return = apply_filters( 'edd_sysinfo_after_php_ext', $return );
|
175 |
-
|
176 |
-
// Session stuff
|
177 |
-
$return .= "\n" . '-- Session Configuration' . "\n\n";
|
178 |
-
$return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n";
|
179 |
-
|
180 |
-
// The rest of this is only relevant is session is enabled
|
181 |
-
if( isset( $_SESSION ) ) {
|
182 |
-
$return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n";
|
183 |
-
$return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n";
|
184 |
-
$return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n";
|
185 |
-
$return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n";
|
186 |
-
$return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n";
|
187 |
-
}
|
188 |
-
|
189 |
-
$return .= "\n" . '### End System Info ###';
|
190 |
-
|
191 |
-
return $return;
|
192 |
-
|
193 |
-
} //end function sysinfo_get
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Get user host
|
197 |
-
*
|
198 |
-
* Returns the webhost this site is using if possible
|
199 |
-
*
|
200 |
-
* @since 2.0
|
201 |
-
* @return mixed string $host if detected, false otherwise
|
202 |
-
*/
|
203 |
-
public static function get_host() {
|
204 |
-
$host = false;
|
205 |
-
|
206 |
-
if( defined( 'WPE_APIKEY' ) ) {
|
207 |
-
$host = 'WP Engine';
|
208 |
-
} elseif( defined( 'PAGELYBIN' ) ) {
|
209 |
-
$host = 'Pagely';
|
210 |
-
} elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
|
211 |
-
$host = 'ICDSoft';
|
212 |
-
} elseif( DB_HOST == 'mysqlv5' ) {
|
213 |
-
$host = 'NetworkSolutions';
|
214 |
-
} elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
|
215 |
-
$host = 'iPage';
|
216 |
-
} elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
|
217 |
-
$host = 'IPower';
|
218 |
-
} elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
|
219 |
-
$host = 'MediaTemple Grid';
|
220 |
-
} elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
|
221 |
-
$host = 'pair Networks';
|
222 |
-
} elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
|
223 |
-
$host = 'Rackspace Cloud';
|
224 |
-
} elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
|
225 |
-
$host = 'SysFix.eu Power Hosting';
|
226 |
-
} elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
|
227 |
-
$host = 'Flywheel';
|
228 |
-
} else {
|
229 |
-
// Adding a general fallback for data gathering
|
230 |
-
$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
|
231 |
-
}
|
232 |
-
|
233 |
-
return $host;
|
234 |
-
|
235 |
-
} //end function get_host
|
236 |
-
|
237 |
-
}
|
238 |
-
|
239 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
4 |
+
|
5 |
+
if ( ! class_exists( 'SS_System_Info' ) ) {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Helper class for generating system information on WordPress installations
|
9 |
+
*/
|
10 |
+
final class SS_System_Info {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Get system info
|
14 |
+
*
|
15 |
+
* @since 2.0
|
16 |
+
* @access public
|
17 |
+
* @global object $wpdb Used to query the database using the WordPress Database API
|
18 |
+
* @return string $return A string containing the info to output
|
19 |
+
*/
|
20 |
+
public static function get_system_info() {
|
21 |
+
global $wpdb;
|
22 |
+
|
23 |
+
// Get theme info
|
24 |
+
$theme_data = wp_get_theme();
|
25 |
+
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
26 |
+
|
27 |
+
// Try to identify the hosting provider
|
28 |
+
$host = self::get_host();
|
29 |
+
|
30 |
+
$return = '### Begin System Info ###' . "\n\n";
|
31 |
+
|
32 |
+
// Start with the basics...
|
33 |
+
$return .= '-- Site Info' . "\n\n";
|
34 |
+
$return .= 'Site URL: ' . site_url() . "\n";
|
35 |
+
$return .= 'Home URL: ' . home_url() . "\n";
|
36 |
+
$return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
|
37 |
+
|
38 |
+
// Can we determine the site's host?
|
39 |
+
if( $host ) {
|
40 |
+
$return .= "\n" . '-- Hosting Provider' . "\n\n";
|
41 |
+
$return .= 'Host: ' . $host . "\n";
|
42 |
+
}
|
43 |
+
|
44 |
+
// WordPress configuration
|
45 |
+
$return .= "\n" . '-- WordPress Configuration' . "\n\n";
|
46 |
+
$return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
|
47 |
+
$return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
|
48 |
+
$return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
|
49 |
+
$return .= 'Active Theme: ' . $theme . "\n";
|
50 |
+
$return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
|
51 |
+
|
52 |
+
// Only show page specs if frontpage is set to 'page'
|
53 |
+
if( get_option( 'show_on_front' ) == 'page' ) {
|
54 |
+
$front_page_id = get_option( 'page_on_front' );
|
55 |
+
$blog_page_id = get_option( 'page_for_posts' );
|
56 |
+
|
57 |
+
$return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
|
58 |
+
$return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
|
59 |
+
}
|
60 |
+
|
61 |
+
$return .= 'ABSPATH: ' . ABSPATH . "\n";
|
62 |
+
|
63 |
+
// Make sure wp_remote_post() is working
|
64 |
+
$request['cmd'] = '_notify-validate';
|
65 |
+
|
66 |
+
$params = array(
|
67 |
+
'sslverify' => false,
|
68 |
+
'timeout' => 60,
|
69 |
+
'user-agent' => 'SS_System_Info/',
|
70 |
+
'body' => $request
|
71 |
+
);
|
72 |
+
|
73 |
+
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
74 |
+
|
75 |
+
if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
76 |
+
$WP_REMOTE_POST = 'wp_remote_post() works';
|
77 |
+
} else {
|
78 |
+
$WP_REMOTE_POST = 'wp_remote_post() does not work';
|
79 |
+
}
|
80 |
+
|
81 |
+
$return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
|
82 |
+
$return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
|
83 |
+
|
84 |
+
$return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
|
85 |
+
$return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
|
86 |
+
$return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
|
87 |
+
|
88 |
+
// Get plugins that have an update
|
89 |
+
$updates = get_plugin_updates();
|
90 |
+
|
91 |
+
// Must-use plugins
|
92 |
+
// NOTE: MU plugins can't show updates!
|
93 |
+
$muplugins = get_mu_plugins();
|
94 |
+
if( count( $muplugins ) > 0 ) {
|
95 |
+
$return .= "\n" . '-- Must-Use Plugins' . "\n\n";
|
96 |
+
|
97 |
+
foreach( $muplugins as $plugin => $plugin_data ) {
|
98 |
+
$return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
|
99 |
+
}
|
100 |
+
|
101 |
+
$return = apply_filters( 'edd_sysinfo_after_wordpress_mu_plugins', $return );
|
102 |
+
}
|
103 |
+
|
104 |
+
// WordPress active plugins
|
105 |
+
$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
|
106 |
+
|
107 |
+
$plugins = get_plugins();
|
108 |
+
$active_plugins = get_option( 'active_plugins', array() );
|
109 |
+
|
110 |
+
foreach( $plugins as $plugin_path => $plugin ) {
|
111 |
+
if( !in_array( $plugin_path, $active_plugins ) )
|
112 |
+
continue;
|
113 |
+
|
114 |
+
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
|
115 |
+
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
116 |
+
}
|
117 |
+
|
118 |
+
// WordPress inactive plugins
|
119 |
+
$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
|
120 |
+
|
121 |
+
foreach( $plugins as $plugin_path => $plugin ) {
|
122 |
+
if( in_array( $plugin_path, $active_plugins ) )
|
123 |
+
continue;
|
124 |
+
|
125 |
+
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
|
126 |
+
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
127 |
+
}
|
128 |
+
|
129 |
+
if( is_multisite() ) {
|
130 |
+
// WordPress Multisite active plugins
|
131 |
+
$return .= "\n" . '-- Network Active Plugins' . "\n\n";
|
132 |
+
|
133 |
+
$plugins = wp_get_active_network_plugins();
|
134 |
+
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
135 |
+
|
136 |
+
foreach( $plugins as $plugin_path ) {
|
137 |
+
$plugin_base = plugin_basename( $plugin_path );
|
138 |
+
|
139 |
+
if( !array_key_exists( $plugin_base, $active_plugins ) )
|
140 |
+
continue;
|
141 |
+
|
142 |
+
$update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
|
143 |
+
$plugin = get_plugin_data( $plugin_path );
|
144 |
+
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
// Server configuration (really just versioning)
|
150 |
+
$return .= "\n" . '-- Webserver Configuration' . "\n\n";
|
151 |
+
$return .= 'PHP Version: ' . PHP_VERSION . "\n";
|
152 |
+
$return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
|
153 |
+
$return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
|
154 |
+
|
155 |
+
// PHP configs... now we're getting to the important stuff
|
156 |
+
$return .= "\n" . '-- PHP Configuration' . "\n\n";
|
157 |
+
$return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
|
158 |
+
$return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
|
159 |
+
$return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
160 |
+
$return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
|
161 |
+
$return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
162 |
+
$return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
|
163 |
+
$return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
|
164 |
+
$return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
|
165 |
+
$return .= 'PHP Arg Separator: ' . ini_get( 'arg_separator.output' ) . "\n";
|
166 |
+
|
167 |
+
// PHP extensions and such
|
168 |
+
$return .= "\n" . '-- PHP Extensions' . "\n\n";
|
169 |
+
$return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
170 |
+
$return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
171 |
+
$return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
|
172 |
+
$return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
|
173 |
+
|
174 |
+
$return = apply_filters( 'edd_sysinfo_after_php_ext', $return );
|
175 |
+
|
176 |
+
// Session stuff
|
177 |
+
$return .= "\n" . '-- Session Configuration' . "\n\n";
|
178 |
+
$return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n";
|
179 |
+
|
180 |
+
// The rest of this is only relevant is session is enabled
|
181 |
+
if( isset( $_SESSION ) ) {
|
182 |
+
$return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n";
|
183 |
+
$return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n";
|
184 |
+
$return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n";
|
185 |
+
$return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n";
|
186 |
+
$return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n";
|
187 |
+
}
|
188 |
+
|
189 |
+
$return .= "\n" . '### End System Info ###';
|
190 |
+
|
191 |
+
return $return;
|
192 |
+
|
193 |
+
} //end function sysinfo_get
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Get user host
|
197 |
+
*
|
198 |
+
* Returns the webhost this site is using if possible
|
199 |
+
*
|
200 |
+
* @since 2.0
|
201 |
+
* @return mixed string $host if detected, false otherwise
|
202 |
+
*/
|
203 |
+
public static function get_host() {
|
204 |
+
$host = false;
|
205 |
+
|
206 |
+
if( defined( 'WPE_APIKEY' ) ) {
|
207 |
+
$host = 'WP Engine';
|
208 |
+
} elseif( defined( 'PAGELYBIN' ) ) {
|
209 |
+
$host = 'Pagely';
|
210 |
+
} elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
|
211 |
+
$host = 'ICDSoft';
|
212 |
+
} elseif( DB_HOST == 'mysqlv5' ) {
|
213 |
+
$host = 'NetworkSolutions';
|
214 |
+
} elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
|
215 |
+
$host = 'iPage';
|
216 |
+
} elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
|
217 |
+
$host = 'IPower';
|
218 |
+
} elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
|
219 |
+
$host = 'MediaTemple Grid';
|
220 |
+
} elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
|
221 |
+
$host = 'pair Networks';
|
222 |
+
} elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
|
223 |
+
$host = 'Rackspace Cloud';
|
224 |
+
} elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
|
225 |
+
$host = 'SysFix.eu Power Hosting';
|
226 |
+
} elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
|
227 |
+
$host = 'Flywheel';
|
228 |
+
} else {
|
229 |
+
// Adding a general fallback for data gathering
|
230 |
+
$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
|
231 |
+
}
|
232 |
+
|
233 |
+
return $host;
|
234 |
+
|
235 |
+
} //end function get_host
|
236 |
+
|
237 |
+
}
|
238 |
+
|
239 |
}
|
includes/migrations/class-ss-wc-migration-from-1.3.X-to-2.0.php
CHANGED
@@ -1,76 +1,76 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
final class SS_WC_MailChimp_Migration_From_1_3_X_To_2_0 extends SS_WC_MailChimp_Migration {
|
4 |
-
|
5 |
-
protected $interest_groupings;
|
6 |
-
|
7 |
-
public function __construct( $current_version, $target_version ) {
|
8 |
-
parent::__construct( $current_version, $target_version );
|
9 |
-
}
|
10 |
-
|
11 |
-
/**
|
12 |
-
* [up description]
|
13 |
-
* @return [type] [description]
|
14 |
-
*/
|
15 |
-
public function up() {
|
16 |
-
|
17 |
-
$interest_groupings_key = 'interest_groupings';
|
18 |
-
$groups_key = 'groups';
|
19 |
-
|
20 |
-
try {
|
21 |
-
|
22 |
-
if ( !array_key_exists( $interest_groupings_key, $this->settings ) || !array_key_exists( $groups_key, $this->settings ) ) return;
|
23 |
-
|
24 |
-
$list = $this->settings['list'];
|
25 |
-
$this->interest_groupings = $this->settings[$interest_groupings_key];
|
26 |
-
$groups = $this->settings[$groups_key];
|
27 |
-
|
28 |
-
if ( empty( $this->interest_groupings ) || empty( $groups ) || empty( $list ) ) return;
|
29 |
-
|
30 |
-
$interest_categories = $this->mailchimp->get_interest_categories( $list );
|
31 |
-
|
32 |
-
$selected_interest_category = array_filter( $interest_categories, array( $this, 'filter_interest_groups' ) );
|
33 |
-
|
34 |
-
$selected_interest_category_id = key( $selected_interest_category );
|
35 |
-
|
36 |
-
$interest_category_interests = $this->mailchimp->get_interest_category_interests( $list, $selected_interest_category_id );
|
37 |
-
|
38 |
-
$groups = explode( ',', $groups );
|
39 |
-
|
40 |
-
$selected_interest_category_interests = array_intersect( $interest_category_interests, $groups );
|
41 |
-
|
42 |
-
$interest_groups = array_keys($selected_interest_category_interests);
|
43 |
-
|
44 |
-
$this->settings['interest_groups'] = $interest_groups;
|
45 |
-
|
46 |
-
unset($this->settings[$interest_groupings_key]);
|
47 |
-
unset($this->settings[$groups_key]);
|
48 |
-
|
49 |
-
$this->save_settings();
|
50 |
-
} catch (Exception $e) {
|
51 |
-
// If all else fails, finish the upgrade and the user will have to reselect the interest groups.
|
52 |
-
unset($this->settings[$interest_groupings_key]);
|
53 |
-
unset($this->settings[$groups_key]);
|
54 |
-
|
55 |
-
$this->save_settings();
|
56 |
-
}
|
57 |
-
|
58 |
-
return true;
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
public function filter_interest_groups( $interest_group ) {
|
63 |
-
return $interest_group == $this->interest_groupings;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* [down description]
|
68 |
-
* @return [type] [description]
|
69 |
-
*/
|
70 |
-
public function down() {
|
71 |
-
|
72 |
-
throw new Exception('Cannot rollback to versions prior to 2.0');
|
73 |
-
|
74 |
-
}
|
75 |
-
|
76 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
final class SS_WC_MailChimp_Migration_From_1_3_X_To_2_0 extends SS_WC_MailChimp_Migration {
|
4 |
+
|
5 |
+
protected $interest_groupings;
|
6 |
+
|
7 |
+
public function __construct( $current_version, $target_version ) {
|
8 |
+
parent::__construct( $current_version, $target_version );
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* [up description]
|
13 |
+
* @return [type] [description]
|
14 |
+
*/
|
15 |
+
public function up() {
|
16 |
+
|
17 |
+
$interest_groupings_key = 'interest_groupings';
|
18 |
+
$groups_key = 'groups';
|
19 |
+
|
20 |
+
try {
|
21 |
+
|
22 |
+
if ( !array_key_exists( $interest_groupings_key, $this->settings ) || !array_key_exists( $groups_key, $this->settings ) ) return;
|
23 |
+
|
24 |
+
$list = $this->settings['list'];
|
25 |
+
$this->interest_groupings = $this->settings[$interest_groupings_key];
|
26 |
+
$groups = $this->settings[$groups_key];
|
27 |
+
|
28 |
+
if ( empty( $this->interest_groupings ) || empty( $groups ) || empty( $list ) ) return;
|
29 |
+
|
30 |
+
$interest_categories = $this->mailchimp->get_interest_categories( $list );
|
31 |
+
|
32 |
+
$selected_interest_category = array_filter( $interest_categories, array( $this, 'filter_interest_groups' ) );
|
33 |
+
|
34 |
+
$selected_interest_category_id = key( $selected_interest_category );
|
35 |
+
|
36 |
+
$interest_category_interests = $this->mailchimp->get_interest_category_interests( $list, $selected_interest_category_id );
|
37 |
+
|
38 |
+
$groups = explode( ',', $groups );
|
39 |
+
|
40 |
+
$selected_interest_category_interests = array_intersect( $interest_category_interests, $groups );
|
41 |
+
|
42 |
+
$interest_groups = array_keys($selected_interest_category_interests);
|
43 |
+
|
44 |
+
$this->settings['interest_groups'] = $interest_groups;
|
45 |
+
|
46 |
+
unset($this->settings[$interest_groupings_key]);
|
47 |
+
unset($this->settings[$groups_key]);
|
48 |
+
|
49 |
+
$this->save_settings();
|
50 |
+
} catch (Exception $e) {
|
51 |
+
// If all else fails, finish the upgrade and the user will have to reselect the interest groups.
|
52 |
+
unset($this->settings[$interest_groupings_key]);
|
53 |
+
unset($this->settings[$groups_key]);
|
54 |
+
|
55 |
+
$this->save_settings();
|
56 |
+
}
|
57 |
+
|
58 |
+
return true;
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
public function filter_interest_groups( $interest_group ) {
|
63 |
+
return $interest_group == $this->interest_groupings;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* [down description]
|
68 |
+
* @return [type] [description]
|
69 |
+
*/
|
70 |
+
public function down() {
|
71 |
+
|
72 |
+
throw new Exception('Cannot rollback to versions prior to 2.0');
|
73 |
+
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
includes/migrations/class-ss-wc-migration-from-2.0-to-2.0.15.php
CHANGED
@@ -1,51 +1,51 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
final class SS_WC_MailChimp_Migration_From_2_0_To_2_0_15 extends SS_WC_MailChimp_Migration {
|
4 |
-
|
5 |
-
public function __construct( $current_version, $target_version ) {
|
6 |
-
parent::__construct( $current_version, $target_version );
|
7 |
-
}
|
8 |
-
|
9 |
-
/**
|
10 |
-
* [up description]
|
11 |
-
* @return [type] [description]
|
12 |
-
*/
|
13 |
-
public function up() {
|
14 |
-
|
15 |
-
try {
|
16 |
-
|
17 |
-
$wrong_double_optin_setting_name = $this->namespace_prefixed('double_optin' );
|
18 |
-
|
19 |
-
if ( !$wrong_double_optin_setting = get_option( $wrong_double_optin_setting_name ) ) {
|
20 |
-
// we didn't find the wrong double optin setting (ss_wc_mailchimp_double_optin) saved in the database, so nothing to do
|
21 |
-
return true;
|
22 |
-
}
|
23 |
-
|
24 |
-
// Let's set the correct double opt in setting
|
25 |
-
$this->settings['double_opt_in'] = $wrong_double_optin_setting;
|
26 |
-
|
27 |
-
// Save the settings
|
28 |
-
$this->save_settings();
|
29 |
-
|
30 |
-
// Finally, let's delete the wrong setting so we don't cause any confusion
|
31 |
-
delete_option( $wrong_double_optin_setting_name );
|
32 |
-
|
33 |
-
} catch (Exception $e) {
|
34 |
-
return false;
|
35 |
-
}
|
36 |
-
|
37 |
-
return true;
|
38 |
-
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* [down description]
|
43 |
-
* @return [type] [description]
|
44 |
-
*/
|
45 |
-
public function down() {
|
46 |
-
|
47 |
-
throw new Exception('Cannot rollback to versions prior to 2.0.15');
|
48 |
-
|
49 |
-
}
|
50 |
-
|
51 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
final class SS_WC_MailChimp_Migration_From_2_0_To_2_0_15 extends SS_WC_MailChimp_Migration {
|
4 |
+
|
5 |
+
public function __construct( $current_version, $target_version ) {
|
6 |
+
parent::__construct( $current_version, $target_version );
|
7 |
+
}
|
8 |
+
|
9 |
+
/**
|
10 |
+
* [up description]
|
11 |
+
* @return [type] [description]
|
12 |
+
*/
|
13 |
+
public function up() {
|
14 |
+
|
15 |
+
try {
|
16 |
+
|
17 |
+
$wrong_double_optin_setting_name = $this->namespace_prefixed('double_optin' );
|
18 |
+
|
19 |
+
if ( !$wrong_double_optin_setting = get_option( $wrong_double_optin_setting_name ) ) {
|
20 |
+
// we didn't find the wrong double optin setting (ss_wc_mailchimp_double_optin) saved in the database, so nothing to do
|
21 |
+
return true;
|
22 |
+
}
|
23 |
+
|
24 |
+
// Let's set the correct double opt in setting
|
25 |
+
$this->settings['double_opt_in'] = $wrong_double_optin_setting;
|
26 |
+
|
27 |
+
// Save the settings
|
28 |
+
$this->save_settings();
|
29 |
+
|
30 |
+
// Finally, let's delete the wrong setting so we don't cause any confusion
|
31 |
+
delete_option( $wrong_double_optin_setting_name );
|
32 |
+
|
33 |
+
} catch (Exception $e) {
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
|
37 |
+
return true;
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* [down description]
|
43 |
+
* @return [type] [description]
|
44 |
+
*/
|
45 |
+
public function down() {
|
46 |
+
|
47 |
+
throw new Exception('Cannot rollback to versions prior to 2.0.15');
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
}
|
includes/migrations/class-ss-wc-migration.php
CHANGED
@@ -1,98 +1,98 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
abstract class SS_WC_MailChimp_Migration {
|
4 |
-
|
5 |
-
protected $mailchimp;
|
6 |
-
|
7 |
-
protected $settings;
|
8 |
-
|
9 |
-
protected $namespace = 'ss_wc_mailchimp';
|
10 |
-
|
11 |
-
protected $current_version;
|
12 |
-
protected $target_version;
|
13 |
-
|
14 |
-
protected $setting_keys;
|
15 |
-
|
16 |
-
protected $settings_key = 'woocommerce_mailchimp_settings';
|
17 |
-
|
18 |
-
public function __construct( $current_version, $target_version ) {
|
19 |
-
|
20 |
-
$this->setting_keys = array(
|
21 |
-
'api_key',
|
22 |
-
'enabled',
|
23 |
-
'list',
|
24 |
-
'interest_groups',
|
25 |
-
'display_opt_in',
|
26 |
-
'occurs',
|
27 |
-
'double_opt_in',
|
28 |
-
'opt_in_label',
|
29 |
-
'opt_in_checkbox_default_status',
|
30 |
-
'opt_in_checkbox_display_location',
|
31 |
-
);
|
32 |
-
|
33 |
-
$this->settings = array();
|
34 |
-
|
35 |
-
$this->current_version = $current_version;
|
36 |
-
$this->target_version = $target_version;
|
37 |
-
|
38 |
-
if ( ! $this->load_settings() ) return;
|
39 |
-
|
40 |
-
if ( empty( $this->settings['api_key'] ) ) return;
|
41 |
-
|
42 |
-
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
43 |
-
$this->mailchimp = new SS_WC_MailChimp( $this->settings['api_key'] );
|
44 |
-
}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* [save_settings description]
|
48 |
-
* @return [type] [description]
|
49 |
-
*/
|
50 |
-
public function load_settings() {
|
51 |
-
|
52 |
-
if ( $this->current_version === '1.3.X' ) {
|
53 |
-
|
54 |
-
if ( ! $this->settings = get_option( $this->settings_key ) ) {
|
55 |
-
return false;
|
56 |
-
}
|
57 |
-
|
58 |
-
if ( !is_array( $this->settings ) ) {
|
59 |
-
return false;
|
60 |
-
}
|
61 |
-
|
62 |
-
} else {
|
63 |
-
|
64 |
-
foreach ( $this->setting_keys as $key ) {
|
65 |
-
$this->settings[ $key ] = get_option( $this->namespace_prefixed( $key ) );
|
66 |
-
}
|
67 |
-
|
68 |
-
}
|
69 |
-
|
70 |
-
return true;
|
71 |
-
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* [save_settings description]
|
76 |
-
* @return [type] [description]
|
77 |
-
*/
|
78 |
-
public function save_settings() {
|
79 |
-
|
80 |
-
if ( $this->target_version === '1.3.X' ) {
|
81 |
-
|
82 |
-
update_option( $this->settings_key , $this->settings );
|
83 |
-
|
84 |
-
} else {
|
85 |
-
|
86 |
-
foreach ( $this->settings as $key => $value ) {
|
87 |
-
update_option( $this->namespace_prefixed( $key ), $value );
|
88 |
-
}
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
protected function namespace_prefixed( $suffix ) {
|
95 |
-
return $this->namespace . '_' . $suffix;
|
96 |
-
}
|
97 |
-
|
98 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class SS_WC_MailChimp_Migration {
|
4 |
+
|
5 |
+
protected $mailchimp;
|
6 |
+
|
7 |
+
protected $settings;
|
8 |
+
|
9 |
+
protected $namespace = 'ss_wc_mailchimp';
|
10 |
+
|
11 |
+
protected $current_version;
|
12 |
+
protected $target_version;
|
13 |
+
|
14 |
+
protected $setting_keys;
|
15 |
+
|
16 |
+
protected $settings_key = 'woocommerce_mailchimp_settings';
|
17 |
+
|
18 |
+
public function __construct( $current_version, $target_version ) {
|
19 |
+
|
20 |
+
$this->setting_keys = array(
|
21 |
+
'api_key',
|
22 |
+
'enabled',
|
23 |
+
'list',
|
24 |
+
'interest_groups',
|
25 |
+
'display_opt_in',
|
26 |
+
'occurs',
|
27 |
+
'double_opt_in',
|
28 |
+
'opt_in_label',
|
29 |
+
'opt_in_checkbox_default_status',
|
30 |
+
'opt_in_checkbox_display_location',
|
31 |
+
);
|
32 |
+
|
33 |
+
$this->settings = array();
|
34 |
+
|
35 |
+
$this->current_version = $current_version;
|
36 |
+
$this->target_version = $target_version;
|
37 |
+
|
38 |
+
if ( ! $this->load_settings() ) return;
|
39 |
+
|
40 |
+
if ( empty( $this->settings['api_key'] ) ) return;
|
41 |
+
|
42 |
+
require_once( SS_WC_MAILCHIMP_DIR . 'includes/class-ss-wc-mailchimp.php' );
|
43 |
+
$this->mailchimp = new SS_WC_MailChimp( $this->settings['api_key'] );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* [save_settings description]
|
48 |
+
* @return [type] [description]
|
49 |
+
*/
|
50 |
+
public function load_settings() {
|
51 |
+
|
52 |
+
if ( $this->current_version === '1.3.X' ) {
|
53 |
+
|
54 |
+
if ( ! $this->settings = get_option( $this->settings_key ) ) {
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
if ( !is_array( $this->settings ) ) {
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
} else {
|
63 |
+
|
64 |
+
foreach ( $this->setting_keys as $key ) {
|
65 |
+
$this->settings[ $key ] = get_option( $this->namespace_prefixed( $key ) );
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
return true;
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* [save_settings description]
|
76 |
+
* @return [type] [description]
|
77 |
+
*/
|
78 |
+
public function save_settings() {
|
79 |
+
|
80 |
+
if ( $this->target_version === '1.3.X' ) {
|
81 |
+
|
82 |
+
update_option( $this->settings_key , $this->settings );
|
83 |
+
|
84 |
+
} else {
|
85 |
+
|
86 |
+
foreach ( $this->settings as $key => $value ) {
|
87 |
+
update_option( $this->namespace_prefixed( $key ), $value );
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
protected function namespace_prefixed( $suffix ) {
|
95 |
+
return $this->namespace . '_' . $suffix;
|
96 |
+
}
|
97 |
+
|
98 |
}
|
languages/woocommerce-mailchimp-fr_FR.po
CHANGED
@@ -1,273 +1,273 @@
|
|
1 |
-
# Copyright (C) 2014 WooCommerce MailChimp
|
2 |
-
# This file is distributed under the same license as the WooCommerce MailChimp package.
|
3 |
-
msgid ""
|
4 |
-
msgstr ""
|
5 |
-
"Project-Id-Version: WooCommerce MailChimp 1.1.3\n"
|
6 |
-
"Report-Msgid-Bugs-To: http://wordpress.org/tag/woocommerce-mailchimp\n"
|
7 |
-
"POT-Creation-Date: 2015-02-06 15:05+0200\n"
|
8 |
-
"PO-Revision-Date: 2015-02-06 09:54-0600\n"
|
9 |
-
"Last-Translator: Vincent Pintat <vincent@walliecreation.com>\n"
|
10 |
-
"Language-Team: \n"
|
11 |
-
"Language: fr_FR\n"
|
12 |
-
"MIME-Version: 1.0\n"
|
13 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
-
"Content-Transfer-Encoding: 8bit\n"
|
15 |
-
"X-Generator: Poedit 1.7.4\n"
|
16 |
-
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
17 |
-
|
18 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:31
|
19 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:518
|
20 |
-
msgid "MailChimp"
|
21 |
-
msgstr "MailChimp"
|
22 |
-
|
23 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:32
|
24 |
-
msgid "MailChimp is a popular email marketing service."
|
25 |
-
msgstr "MailChimp est un service d'emailing marketing très populaire."
|
26 |
-
|
27 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:82
|
28 |
-
#, php-format
|
29 |
-
msgid ""
|
30 |
-
"WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter "
|
31 |
-
"your api key <a href=\"%s\">here</a>."
|
32 |
-
msgstr ""
|
33 |
-
"Erreur WooCommerce MailChimp : Le plugin est activé mais la clé d'API n'a pas été "
|
34 |
-
"renseignée. Entrez votre clé d'API <a href=\"%s\">ici</a>"
|
35 |
-
|
36 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:101
|
37 |
-
#, php-format
|
38 |
-
msgid "Order Opt-In Value: %s"
|
39 |
-
msgstr ""
|
40 |
-
|
41 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:107
|
42 |
-
#, php-format
|
43 |
-
msgid "Subscribe customer (%s) to list %s"
|
44 |
-
msgstr ""
|
45 |
-
|
46 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:177
|
47 |
-
msgid "Select a list..."
|
48 |
-
msgstr "Sélectionnez une liste..."
|
49 |
-
|
50 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:180
|
51 |
-
msgid "Enter your key and save to see your lists"
|
52 |
-
msgstr "Entrez votre clé et enregistrez pour voir vos listes"
|
53 |
-
|
54 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:185
|
55 |
-
msgid "Enable/Disable"
|
56 |
-
msgstr "Activer/Désactiver"
|
57 |
-
|
58 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:186
|
59 |
-
msgid "Enable MailChimp"
|
60 |
-
msgstr "Activer MailChimp"
|
61 |
-
|
62 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:192
|
63 |
-
msgid "Subscribe Event"
|
64 |
-
msgstr "Evénément d'inscription"
|
65 |
-
|
66 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:194
|
67 |
-
msgid "When should customers be subscribed to lists?"
|
68 |
-
msgstr "Quand les abonnés doivent-ils être inscrits aux listes ?"
|
69 |
-
|
70 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:197
|
71 |
-
msgid "Order Created"
|
72 |
-
msgstr "Commande crée"
|
73 |
-
|
74 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:198
|
75 |
-
msgid "Order Processing"
|
76 |
-
msgstr "Commande"
|
77 |
-
|
78 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:199
|
79 |
-
msgid "Order Completed"
|
80 |
-
msgstr "Commande terminée"
|
81 |
-
|
82 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:203
|
83 |
-
msgid "API Key"
|
84 |
-
msgstr "Clé d'API"
|
85 |
-
|
86 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:205
|
87 |
-
msgid ""
|
88 |
-
"<a href=\"https://us2.admin.mailchimp.com/account/api/\" target=\"_blank\">Login to "
|
89 |
-
"mailchimp</a> to look up your api key."
|
90 |
-
msgstr ""
|
91 |
-
"<a href=\"https://us2.admin.mailchimp.com/account/api/\" target=\"_blank\">Connectez-"
|
92 |
-
"vous à MailChimp</a> pour voir votre clé d'API."
|
93 |
-
|
94 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:209
|
95 |
-
msgid "Main List"
|
96 |
-
msgstr "Liste principale"
|
97 |
-
|
98 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:211
|
99 |
-
msgid "All customers will be added to this list."
|
100 |
-
msgstr "Tous les clients seront ajoutés à cette liste."
|
101 |
-
|
102 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:216
|
103 |
-
msgid "Group Name"
|
104 |
-
msgstr "Nom du groupe"
|
105 |
-
|
106 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:218
|
107 |
-
msgid ""
|
108 |
-
"Optional: Enter the name of the group. Learn more about <a href=\"http://mailchimp."
|
109 |
-
"com/features/groups\" target=\"_blank\">Groups</a>"
|
110 |
-
msgstr ""
|
111 |
-
"Optionnel : Entrez le nom du groupe. Apprenez-en plus au sujet des <a href=\"http://"
|
112 |
-
"mailchimp.com/features/groups\" target=\"_blank\">Groupes</a>"
|
113 |
-
|
114 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:222
|
115 |
-
msgid "Groups"
|
116 |
-
msgstr "Groupes"
|
117 |
-
|
118 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:224
|
119 |
-
msgid ""
|
120 |
-
"Optional: Comma separated list of interest groups to which subscribers should be "
|
121 |
-
"added."
|
122 |
-
msgstr ""
|
123 |
-
"Optionnel : Liste des groupes d'intérêt auxquels ajouter les nouveaux inscrits, "
|
124 |
-
"séparés par des virgules."
|
125 |
-
|
126 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:228
|
127 |
-
msgid "Double Opt-In"
|
128 |
-
msgstr "Double validation"
|
129 |
-
|
130 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:229
|
131 |
-
msgid "Enable Double Opt-In"
|
132 |
-
msgstr "Activer la double validation"
|
133 |
-
|
134 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:231
|
135 |
-
msgid ""
|
136 |
-
"If enabled, customers will receive an email prompting them to confirm their "
|
137 |
-
"subscription to the list above."
|
138 |
-
msgstr ""
|
139 |
-
"Si activé, les clients recevront un email les incitant à confirmer leur inscription "
|
140 |
-
"à la liste ci-dessus."
|
141 |
-
|
142 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:235
|
143 |
-
msgid "Display Opt-In Field"
|
144 |
-
msgstr "Afficher le champs choix d'inscription"
|
145 |
-
|
146 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:236
|
147 |
-
msgid "Display an Opt-In Field on Checkout"
|
148 |
-
msgstr "Afficher un champs de choix d'inscription sur la page Commande (checkout)"
|
149 |
-
|
150 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:238
|
151 |
-
msgid ""
|
152 |
-
"If enabled, customers will be presented with a \"Opt-in\" checkbox during checkout "
|
153 |
-
"and will only be added to the list above if they opt-in."
|
154 |
-
msgstr ""
|
155 |
-
"Si activé, une case à cocher de choix d'inscription sera affichée aux clients "
|
156 |
-
"pendant le processus de commande. Les clients choisissant de s'inscrire seront "
|
157 |
-
"ajoutés à la liste ce-dessus s'ils cochent la case."
|
158 |
-
|
159 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:242
|
160 |
-
msgid "Opt-In Field Label"
|
161 |
-
msgstr "Label du champs \"choix d'inscription\""
|
162 |
-
|
163 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:244
|
164 |
-
msgid "Optional: customize the label displayed next to the opt-in checkbox."
|
165 |
-
msgstr "Optionnel : personnalisez le label affiché à côté de la case à cocher."
|
166 |
-
|
167 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:245
|
168 |
-
msgid "Add me to the newsletter (we will never share your email)."
|
169 |
-
msgstr "M'inscrire à la newsletter (votre email restera confidentiel)"
|
170 |
-
|
171 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:248
|
172 |
-
msgid "Opt-In Checkbox Default Status"
|
173 |
-
msgstr "Etat par défaut de la case à cocher"
|
174 |
-
|
175 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:250
|
176 |
-
msgid "The default state of the opt-in checkbox."
|
177 |
-
msgstr "L'état par défaut de la case à cocher"
|
178 |
-
|
179 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:253
|
180 |
-
msgid "Checked"
|
181 |
-
msgstr "Coché"
|
182 |
-
|
183 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:254
|
184 |
-
msgid "Unchecked"
|
185 |
-
msgstr "Non coché"
|
186 |
-
|
187 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:258
|
188 |
-
msgid "Opt-In Checkbox Display Location"
|
189 |
-
msgstr "Localisation de la case à cocher d'inscription"
|
190 |
-
|
191 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:260
|
192 |
-
msgid ""
|
193 |
-
"Where to display the opt-in checkbox on the checkout page (under Billing info or "
|
194 |
-
"Order info)."
|
195 |
-
msgstr ""
|
196 |
-
"Où afficher la case à cocher sur la page de commande (en dessous de Facturation ou "
|
197 |
-
"Récapitulatif de commande). "
|
198 |
-
|
199 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:263
|
200 |
-
msgid "Billing"
|
201 |
-
msgstr "Facturation"
|
202 |
-
|
203 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:264
|
204 |
-
msgid "Order"
|
205 |
-
msgstr "Commande"
|
206 |
-
|
207 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:378
|
208 |
-
#, php-format
|
209 |
-
msgid "Unable to load lists from MailChimp: (%s) %s. "
|
210 |
-
msgstr ""
|
211 |
-
|
212 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:379
|
213 |
-
#, php-format
|
214 |
-
msgid "Please check your %s <a href=\"%s\">settings</a>."
|
215 |
-
msgstr ""
|
216 |
-
|
217 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:399
|
218 |
-
#, php-format
|
219 |
-
msgid "Unable to load listInterestGroupings() from MailChimp: (%s) %s"
|
220 |
-
msgstr "Impossible de charger listInterestGroupings() depuis MailChimp: (%s) %s"
|
221 |
-
|
222 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:483
|
223 |
-
#, php-format
|
224 |
-
msgid "Calling MailChimp API listSubscribe method with the following: %s"
|
225 |
-
msgstr ""
|
226 |
-
|
227 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:489
|
228 |
-
#, php-format
|
229 |
-
msgid "MailChimp API response: %s"
|
230 |
-
msgstr ""
|
231 |
-
|
232 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:493
|
233 |
-
#, php-format
|
234 |
-
msgid "WooCommerce MailChimp subscription failed: %s (%s)"
|
235 |
-
msgstr ""
|
236 |
-
|
237 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:505
|
238 |
-
msgid "WooCommerce MailChimp subscription failed"
|
239 |
-
msgstr "L'inscription à WooCommerce MailChimp a échoué"
|
240 |
-
|
241 |
-
#: ../classes/class-ss-wc-integration-mailchimp.php:519
|
242 |
-
msgid ""
|
243 |
-
"Enter your MailChimp settings below to control how WooCommerce integrates with your "
|
244 |
-
"MailChimp lists."
|
245 |
-
msgstr ""
|
246 |
-
"Entrez vos paramètres MailChimp ci-dessous pour contrôler comment WooCommerce "
|
247 |
-
"s'intègre à vos listes MailChimp."
|
248 |
-
|
249 |
-
#: ../woocommerce-mailchimp.php:60
|
250 |
-
msgid "Settings"
|
251 |
-
msgstr "Paramètres"
|
252 |
-
|
253 |
-
#~ msgid "Unable to load lists from MailChimp: (%s) %s."
|
254 |
-
#~ msgstr "Impossible de charger les listes depuis MailChimp : (%s) %s"
|
255 |
-
|
256 |
-
#~ msgid "WooCommerce MailChimp"
|
257 |
-
#~ msgstr "WooCommerce MailChimp"
|
258 |
-
|
259 |
-
#~ msgid "http://anderly.com/woocommerce-mailchimp"
|
260 |
-
#~ msgstr "http://anderly.com/woocommerce-mailchimp"
|
261 |
-
|
262 |
-
#~ msgid "WooCommerce MailChimp provides simple MailChimp integration for WooCommerce."
|
263 |
-
#~ msgstr ""
|
264 |
-
#~ "WooCommerce MailChimp fourni une intégration simple de MailChimp dans WooCommerce."
|
265 |
-
|
266 |
-
#~ msgid "Adam Anderly"
|
267 |
-
#~ msgstr "Adam Anderly"
|
268 |
-
|
269 |
-
#~ msgid "http://anderly.com"
|
270 |
-
#~ msgstr "http://anderly.com"
|
271 |
-
|
272 |
-
#~ msgid "Email subscription failed (Mailchimp)"
|
273 |
-
#~ msgstr "Inscription de cet email échouée (MailChimp)"
|
1 |
+
# Copyright (C) 2014 WooCommerce MailChimp
|
2 |
+
# This file is distributed under the same license as the WooCommerce MailChimp package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: WooCommerce MailChimp 1.1.3\n"
|
6 |
+
"Report-Msgid-Bugs-To: http://wordpress.org/tag/woocommerce-mailchimp\n"
|
7 |
+
"POT-Creation-Date: 2015-02-06 15:05+0200\n"
|
8 |
+
"PO-Revision-Date: 2015-02-06 09:54-0600\n"
|
9 |
+
"Last-Translator: Vincent Pintat <vincent@walliecreation.com>\n"
|
10 |
+
"Language-Team: \n"
|
11 |
+
"Language: fr_FR\n"
|
12 |
+
"MIME-Version: 1.0\n"
|
13 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
14 |
+
"Content-Transfer-Encoding: 8bit\n"
|
15 |
+
"X-Generator: Poedit 1.7.4\n"
|
16 |
+
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
17 |
+
|
18 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:31
|
19 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:518
|
20 |
+
msgid "MailChimp"
|
21 |
+
msgstr "MailChimp"
|
22 |
+
|
23 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:32
|
24 |
+
msgid "MailChimp is a popular email marketing service."
|
25 |
+
msgstr "MailChimp est un service d'emailing marketing très populaire."
|
26 |
+
|
27 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:82
|
28 |
+
#, php-format
|
29 |
+
msgid ""
|
30 |
+
"WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter "
|
31 |
+
"your api key <a href=\"%s\">here</a>."
|
32 |
+
msgstr ""
|
33 |
+
"Erreur WooCommerce MailChimp : Le plugin est activé mais la clé d'API n'a pas été "
|
34 |
+
"renseignée. Entrez votre clé d'API <a href=\"%s\">ici</a>"
|
35 |
+
|
36 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:101
|
37 |
+
#, php-format
|
38 |
+
msgid "Order Opt-In Value: %s"
|
39 |
+
msgstr ""
|
40 |
+
|
41 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:107
|
42 |
+
#, php-format
|
43 |
+
msgid "Subscribe customer (%s) to list %s"
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:177
|
47 |
+
msgid "Select a list..."
|
48 |
+
msgstr "Sélectionnez une liste..."
|
49 |
+
|
50 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:180
|
51 |
+
msgid "Enter your key and save to see your lists"
|
52 |
+
msgstr "Entrez votre clé et enregistrez pour voir vos listes"
|
53 |
+
|
54 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:185
|
55 |
+
msgid "Enable/Disable"
|
56 |
+
msgstr "Activer/Désactiver"
|
57 |
+
|
58 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:186
|
59 |
+
msgid "Enable MailChimp"
|
60 |
+
msgstr "Activer MailChimp"
|
61 |
+
|
62 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:192
|
63 |
+
msgid "Subscribe Event"
|
64 |
+
msgstr "Evénément d'inscription"
|
65 |
+
|
66 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:194
|
67 |
+
msgid "When should customers be subscribed to lists?"
|
68 |
+
msgstr "Quand les abonnés doivent-ils être inscrits aux listes ?"
|
69 |
+
|
70 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:197
|
71 |
+
msgid "Order Created"
|
72 |
+
msgstr "Commande crée"
|
73 |
+
|
74 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:198
|
75 |
+
msgid "Order Processing"
|
76 |
+
msgstr "Commande"
|
77 |
+
|
78 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:199
|
79 |
+
msgid "Order Completed"
|
80 |
+
msgstr "Commande terminée"
|
81 |
+
|
82 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:203
|
83 |
+
msgid "API Key"
|
84 |
+
msgstr "Clé d'API"
|
85 |
+
|
86 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:205
|
87 |
+
msgid ""
|
88 |
+
"<a href=\"https://us2.admin.mailchimp.com/account/api/\" target=\"_blank\">Login to "
|
89 |
+
"mailchimp</a> to look up your api key."
|
90 |
+
msgstr ""
|
91 |
+
"<a href=\"https://us2.admin.mailchimp.com/account/api/\" target=\"_blank\">Connectez-"
|
92 |
+
"vous à MailChimp</a> pour voir votre clé d'API."
|
93 |
+
|
94 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:209
|
95 |
+
msgid "Main List"
|
96 |
+
msgstr "Liste principale"
|
97 |
+
|
98 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:211
|
99 |
+
msgid "All customers will be added to this list."
|
100 |
+
msgstr "Tous les clients seront ajoutés à cette liste."
|
101 |
+
|
102 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:216
|
103 |
+
msgid "Group Name"
|
104 |
+
msgstr "Nom du groupe"
|
105 |
+
|
106 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:218
|
107 |
+
msgid ""
|
108 |
+
"Optional: Enter the name of the group. Learn more about <a href=\"http://mailchimp."
|
109 |
+
"com/features/groups\" target=\"_blank\">Groups</a>"
|
110 |
+
msgstr ""
|
111 |
+
"Optionnel : Entrez le nom du groupe. Apprenez-en plus au sujet des <a href=\"http://"
|
112 |
+
"mailchimp.com/features/groups\" target=\"_blank\">Groupes</a>"
|
113 |
+
|
114 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:222
|
115 |
+
msgid "Groups"
|
116 |
+
msgstr "Groupes"
|
117 |
+
|
118 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:224
|
119 |
+
msgid ""
|
120 |
+
"Optional: Comma separated list of interest groups to which subscribers should be "
|
121 |
+
"added."
|
122 |
+
msgstr ""
|
123 |
+
"Optionnel : Liste des groupes d'intérêt auxquels ajouter les nouveaux inscrits, "
|
124 |
+
"séparés par des virgules."
|
125 |
+
|
126 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:228
|
127 |
+
msgid "Double Opt-In"
|
128 |
+
msgstr "Double validation"
|
129 |
+
|
130 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:229
|
131 |
+
msgid "Enable Double Opt-In"
|
132 |
+
msgstr "Activer la double validation"
|
133 |
+
|
134 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:231
|
135 |
+
msgid ""
|
136 |
+
"If enabled, customers will receive an email prompting them to confirm their "
|
137 |
+
"subscription to the list above."
|
138 |
+
msgstr ""
|
139 |
+
"Si activé, les clients recevront un email les incitant à confirmer leur inscription "
|
140 |
+
"à la liste ci-dessus."
|
141 |
+
|
142 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:235
|
143 |
+
msgid "Display Opt-In Field"
|
144 |
+
msgstr "Afficher le champs choix d'inscription"
|
145 |
+
|
146 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:236
|
147 |
+
msgid "Display an Opt-In Field on Checkout"
|
148 |
+
msgstr "Afficher un champs de choix d'inscription sur la page Commande (checkout)"
|
149 |
+
|
150 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:238
|
151 |
+
msgid ""
|
152 |
+
"If enabled, customers will be presented with a \"Opt-in\" checkbox during checkout "
|
153 |
+
"and will only be added to the list above if they opt-in."
|
154 |
+
msgstr ""
|
155 |
+
"Si activé, une case à cocher de choix d'inscription sera affichée aux clients "
|
156 |
+
"pendant le processus de commande. Les clients choisissant de s'inscrire seront "
|
157 |
+
"ajoutés à la liste ce-dessus s'ils cochent la case."
|
158 |
+
|
159 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:242
|
160 |
+
msgid "Opt-In Field Label"
|
161 |
+
msgstr "Label du champs \"choix d'inscription\""
|
162 |
+
|
163 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:244
|
164 |
+
msgid "Optional: customize the label displayed next to the opt-in checkbox."
|
165 |
+
msgstr "Optionnel : personnalisez le label affiché à côté de la case à cocher."
|
166 |
+
|
167 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:245
|
168 |
+
msgid "Add me to the newsletter (we will never share your email)."
|
169 |
+
msgstr "M'inscrire à la newsletter (votre email restera confidentiel)"
|
170 |
+
|
171 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:248
|
172 |
+
msgid "Opt-In Checkbox Default Status"
|
173 |
+
msgstr "Etat par défaut de la case à cocher"
|
174 |
+
|
175 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:250
|
176 |
+
msgid "The default state of the opt-in checkbox."
|
177 |
+
msgstr "L'état par défaut de la case à cocher"
|
178 |
+
|
179 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:253
|
180 |
+
msgid "Checked"
|
181 |
+
msgstr "Coché"
|
182 |
+
|
183 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:254
|
184 |
+
msgid "Unchecked"
|
185 |
+
msgstr "Non coché"
|
186 |
+
|
187 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:258
|
188 |
+
msgid "Opt-In Checkbox Display Location"
|
189 |
+
msgstr "Localisation de la case à cocher d'inscription"
|
190 |
+
|
191 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:260
|
192 |
+
msgid ""
|
193 |
+
"Where to display the opt-in checkbox on the checkout page (under Billing info or "
|
194 |
+
"Order info)."
|
195 |
+
msgstr ""
|
196 |
+
"Où afficher la case à cocher sur la page de commande (en dessous de Facturation ou "
|
197 |
+
"Récapitulatif de commande). "
|
198 |
+
|
199 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:263
|
200 |
+
msgid "Billing"
|
201 |
+
msgstr "Facturation"
|
202 |
+
|
203 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:264
|
204 |
+
msgid "Order"
|
205 |
+
msgstr "Commande"
|
206 |
+
|
207 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:378
|
208 |
+
#, php-format
|
209 |
+
msgid "Unable to load lists from MailChimp: (%s) %s. "
|
210 |
+
msgstr ""
|
211 |
+
|
212 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:379
|
213 |
+
#, php-format
|
214 |
+
msgid "Please check your %s <a href=\"%s\">settings</a>."
|
215 |
+
msgstr ""
|
216 |
+
|
217 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:399
|
218 |
+
#, php-format
|
219 |
+
msgid "Unable to load listInterestGroupings() from MailChimp: (%s) %s"
|
220 |
+
msgstr "Impossible de charger listInterestGroupings() depuis MailChimp: (%s) %s"
|
221 |
+
|
222 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:483
|
223 |
+
#, php-format
|
224 |
+
msgid "Calling MailChimp API listSubscribe method with the following: %s"
|
225 |
+
msgstr ""
|
226 |
+
|
227 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:489
|
228 |
+
#, php-format
|
229 |
+
msgid "MailChimp API response: %s"
|
230 |
+
msgstr ""
|
231 |
+
|
232 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:493
|
233 |
+
#, php-format
|
234 |
+
msgid "WooCommerce MailChimp subscription failed: %s (%s)"
|
235 |
+
msgstr ""
|
236 |
+
|
237 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:505
|
238 |
+
msgid "WooCommerce MailChimp subscription failed"
|
239 |
+
msgstr "L'inscription à WooCommerce MailChimp a échoué"
|
240 |
+
|
241 |
+
#: ../classes/class-ss-wc-integration-mailchimp.php:519
|
242 |
+
msgid ""
|
243 |
+
"Enter your MailChimp settings below to control how WooCommerce integrates with your "
|
244 |
+
"MailChimp lists."
|
245 |
+
msgstr ""
|
246 |
+
"Entrez vos paramètres MailChimp ci-dessous pour contrôler comment WooCommerce "
|
247 |
+
"s'intègre à vos listes MailChimp."
|
248 |
+
|
249 |
+
#: ../woocommerce-mailchimp.php:60
|
250 |
+
msgid "Settings"
|
251 |
+
msgstr "Paramètres"
|
252 |
+
|
253 |
+
#~ msgid "Unable to load lists from MailChimp: (%s) %s."
|
254 |
+
#~ msgstr "Impossible de charger les listes depuis MailChimp : (%s) %s"
|
255 |
+
|
256 |
+
#~ msgid "WooCommerce MailChimp"
|
257 |
+
#~ msgstr "WooCommerce MailChimp"
|
258 |
+
|
259 |
+
#~ msgid "http://anderly.com/woocommerce-mailchimp"
|
260 |
+
#~ msgstr "http://anderly.com/woocommerce-mailchimp"
|
261 |
+
|
262 |
+
#~ msgid "WooCommerce MailChimp provides simple MailChimp integration for WooCommerce."
|
263 |
+
#~ msgstr ""
|
264 |
+
#~ "WooCommerce MailChimp fourni une intégration simple de MailChimp dans WooCommerce."
|
265 |
+
|
266 |
+
#~ msgid "Adam Anderly"
|
267 |
+
#~ msgstr "Adam Anderly"
|
268 |
+
|
269 |
+
#~ msgid "http://anderly.com"
|
270 |
+
#~ msgstr "http://anderly.com"
|
271 |
+
|
272 |
+
#~ msgid "Email subscription failed (Mailchimp)"
|
273 |
+
#~ msgstr "Inscription de cet email échouée (MailChimp)"
|
languages/woocommerce-mailchimp.pot
CHANGED
@@ -1,404 +1,404 @@
|
|
1 |
-
#, fuzzy
|
2 |
-
msgid ""
|
3 |
-
msgstr ""
|
4 |
-
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
5 |
-
"Project-Id-Version: WooCommerce MailChimp\n"
|
6 |
-
"POT-Creation-Date: 2016-09-20 10:27-0500\n"
|
7 |
-
"PO-Revision-Date: 2016-09-20 10:27-0500\n"
|
8 |
-
"Last-Translator: Adam Anderly <adam.anderly@saintsystems.com>\n"
|
9 |
-
"Language-Team: Adam Anderly <adam.anderly@saintsystems.com>\n"
|
10 |
-
"MIME-Version: 1.0\n"
|
11 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
-
"Content-Transfer-Encoding: 8bit\n"
|
13 |
-
"X-Generator: Poedit 1.8.9\n"
|
14 |
-
"X-Poedit-Basepath: ..\n"
|
15 |
-
"X-Poedit-WPHeader: woocommerce-mailchimp.php\n"
|
16 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
-
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
18 |
-
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
19 |
-
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
20 |
-
"X-Poedit-SearchPath-0: .\n"
|
21 |
-
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
22 |
-
|
23 |
-
#: config/default-settings.php:10
|
24 |
-
#: includes/class-ss-wc-settings-mailchimp.php:421
|
25 |
-
msgid "Subscribe to our newsletter"
|
26 |
-
msgstr ""
|
27 |
-
|
28 |
-
#: includes/class-ss-wc-mailchimp-admin-notices.php:166
|
29 |
-
msgid "Dismiss"
|
30 |
-
msgstr ""
|
31 |
-
|
32 |
-
#: includes/class-ss-wc-mailchimp-compatibility.php:158
|
33 |
-
msgid ""
|
34 |
-
"You are seeing this notice because you are an administrator. Other users of "
|
35 |
-
"the site will see nothing."
|
36 |
-
msgstr ""
|
37 |
-
|
38 |
-
#: includes/class-ss-wc-mailchimp-compatibility.php:179
|
39 |
-
#, php-format
|
40 |
-
msgid ""
|
41 |
-
"%sWooCommerce MailChimp requires PHP Version %s or newer.%s \n"
|
42 |
-
"\n"
|
43 |
-
"You're using Version %s. Please ask your host to upgrade your server's PHP."
|
44 |
-
msgstr ""
|
45 |
-
|
46 |
-
#: includes/class-ss-wc-mailchimp-compatibility.php:201
|
47 |
-
#, php-format
|
48 |
-
msgid ""
|
49 |
-
"%sWooCommerce MailChimp requires WordPress %s or newer.%s \n"
|
50 |
-
"\n"
|
51 |
-
"You're using Version %s. Please upgrade your WordPress installation."
|
52 |
-
msgstr ""
|
53 |
-
|
54 |
-
#: includes/class-ss-wc-mailchimp-compatibility.php:253
|
55 |
-
#, php-format
|
56 |
-
msgid ""
|
57 |
-
"%sWooCommerce MailChimp requires WooCommerce Version %s or newer.%s You're "
|
58 |
-
"using Version %s. %sUpdate WooCommerce%s to use the WooCommerce MailChimp "
|
59 |
-
"plugin."
|
60 |
-
msgstr ""
|
61 |
-
|
62 |
-
#: includes/class-ss-wc-mailchimp-compatibility.php:288
|
63 |
-
#, php-format
|
64 |
-
msgid ""
|
65 |
-
"%sWooCommerce MailChimp requires WooCommerce to be active. %sActivate "
|
66 |
-
"WooCommerce%s to use the WooCommerce MailChimp plugin."
|
67 |
-
msgstr ""
|
68 |
-
|
69 |
-
#: includes/class-ss-wc-mailchimp-compatibility.php:293
|
70 |
-
#, php-format
|
71 |
-
msgid ""
|
72 |
-
"%sWooCommerce MailChimp requires WooCommerce to be installed in order to run "
|
73 |
-
"properly. %sInstall WooCommerce%s to use the WooCommerce MailChimp plugin."
|
74 |
-
msgstr ""
|
75 |
-
|
76 |
-
#: includes/class-ss-wc-mailchimp-handler.php:35
|
77 |
-
#: includes/class-ss-wc-settings-mailchimp.php:46
|
78 |
-
#: includes/class-ss-wc-settings-mailchimp.php:313
|
79 |
-
msgid "MailChimp"
|
80 |
-
msgstr ""
|
81 |
-
|
82 |
-
#: includes/class-ss-wc-mailchimp-handler.php:213
|
83 |
-
#, php-format
|
84 |
-
msgid "(): Subscribing customer (%s) to list %s"
|
85 |
-
msgstr ""
|
86 |
-
|
87 |
-
#: includes/class-ss-wc-mailchimp-handler.php:285
|
88 |
-
msgid "Please enter an api key."
|
89 |
-
msgstr ""
|
90 |
-
|
91 |
-
#: includes/class-ss-wc-mailchimp-handler.php:318
|
92 |
-
#: includes/class-ss-wc-mailchimp-handler.php:351
|
93 |
-
msgid "Enter your api key above to see your lists"
|
94 |
-
msgstr ""
|
95 |
-
|
96 |
-
#: includes/class-ss-wc-mailchimp-handler.php:357
|
97 |
-
msgid "Please select a list from above."
|
98 |
-
msgstr ""
|
99 |
-
|
100 |
-
#: includes/class-ss-wc-mailchimp-handler.php:490
|
101 |
-
#, php-format
|
102 |
-
msgid "(): Subscribing customer to MailChimp: %s"
|
103 |
-
msgstr ""
|
104 |
-
|
105 |
-
#: includes/class-ss-wc-mailchimp-handler.php:496
|
106 |
-
#, php-format
|
107 |
-
msgid "(): MailChimp API response: %s"
|
108 |
-
msgstr ""
|
109 |
-
|
110 |
-
#: includes/class-ss-wc-mailchimp-handler.php:500
|
111 |
-
#, php-format
|
112 |
-
msgid "(): WooCommerce MailChimp subscription failed: %s (%s)"
|
113 |
-
msgstr ""
|
114 |
-
|
115 |
-
#: includes/class-ss-wc-mailchimp-handler.php:509
|
116 |
-
msgid "WooCommerce MailChimp subscription failed"
|
117 |
-
msgstr ""
|
118 |
-
|
119 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:281
|
120 |
-
msgid "Settings"
|
121 |
-
msgstr ""
|
122 |
-
|
123 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:313
|
124 |
-
msgid "Connecting to MailChimp"
|
125 |
-
msgstr ""
|
126 |
-
|
127 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:314
|
128 |
-
msgid "Error. Please check your api key."
|
129 |
-
msgstr ""
|
130 |
-
|
131 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:315
|
132 |
-
msgid ""
|
133 |
-
"Error loading groups. Please check your MailChimp Interest Groups for the "
|
134 |
-
"selected list."
|
135 |
-
msgstr ""
|
136 |
-
|
137 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:316
|
138 |
-
msgid "Select one or more groups (optional)"
|
139 |
-
msgstr ""
|
140 |
-
|
141 |
-
#: includes/class-ss-wc-mailchimp-plugin.php:317
|
142 |
-
msgid "This list does not have interest groups enabled"
|
143 |
-
msgstr ""
|
144 |
-
|
145 |
-
#: includes/class-ss-wc-settings-mailchimp.php:201
|
146 |
-
#, php-format
|
147 |
-
msgid ""
|
148 |
-
"WooCommerce MailChimp error: Plugin is enabled but no api key provided. "
|
149 |
-
"Please enter your api key <a href=\"%s\">here</a>."
|
150 |
-
msgstr ""
|
151 |
-
|
152 |
-
#: includes/class-ss-wc-settings-mailchimp.php:250
|
153 |
-
msgid "General"
|
154 |
-
msgstr ""
|
155 |
-
|
156 |
-
#: includes/class-ss-wc-settings-mailchimp.php:253
|
157 |
-
#: includes/class-ss-wc-settings-mailchimp.php:477
|
158 |
-
msgid "Troubleshooting"
|
159 |
-
msgstr ""
|
160 |
-
|
161 |
-
#: includes/class-ss-wc-settings-mailchimp.php:315
|
162 |
-
msgid ""
|
163 |
-
"Enter your MailChimp settings below to control how WooCommerce integrates "
|
164 |
-
"with your MailChimp account."
|
165 |
-
msgstr ""
|
166 |
-
|
167 |
-
#: includes/class-ss-wc-settings-mailchimp.php:322
|
168 |
-
msgid "API Key"
|
169 |
-
msgstr ""
|
170 |
-
|
171 |
-
#: includes/class-ss-wc-settings-mailchimp.php:324
|
172 |
-
#, php-format
|
173 |
-
msgid "%sLogin to MailChimp%s to look up your api key."
|
174 |
-
msgstr ""
|
175 |
-
|
176 |
-
#: includes/class-ss-wc-settings-mailchimp.php:326
|
177 |
-
msgid "Paste your MailChimp API key here"
|
178 |
-
msgstr ""
|
179 |
-
|
180 |
-
#: includes/class-ss-wc-settings-mailchimp.php:334
|
181 |
-
msgid "Enable/Disable"
|
182 |
-
msgstr ""
|
183 |
-
|
184 |
-
#: includes/class-ss-wc-settings-mailchimp.php:335
|
185 |
-
msgid "Enable MailChimp Integration"
|
186 |
-
msgstr ""
|
187 |
-
|
188 |
-
#: includes/class-ss-wc-settings-mailchimp.php:337
|
189 |
-
msgid "Enable/disable the plugin functionality."
|
190 |
-
msgstr ""
|
191 |
-
|
192 |
-
#: includes/class-ss-wc-settings-mailchimp.php:351
|
193 |
-
msgid "Main List"
|
194 |
-
msgstr ""
|
195 |
-
|
196 |
-
#: includes/class-ss-wc-settings-mailchimp.php:353
|
197 |
-
msgid "All customers will be added to this list."
|
198 |
-
msgstr ""
|
199 |
-
|
200 |
-
#: includes/class-ss-wc-settings-mailchimp.php:363
|
201 |
-
msgid "Interest Groups"
|
202 |
-
msgstr ""
|
203 |
-
|
204 |
-
#: includes/class-ss-wc-settings-mailchimp.php:365
|
205 |
-
msgid "Optional: Interest groups to assign to subscribers."
|
206 |
-
msgstr ""
|
207 |
-
|
208 |
-
#: includes/class-ss-wc-settings-mailchimp.php:370
|
209 |
-
msgid "Select interest groups..."
|
210 |
-
msgstr ""
|
211 |
-
|
212 |
-
#: includes/class-ss-wc-settings-mailchimp.php:378
|
213 |
-
msgid "Subscribe Event"
|
214 |
-
msgstr ""
|
215 |
-
|
216 |
-
#: includes/class-ss-wc-settings-mailchimp.php:380
|
217 |
-
msgid ""
|
218 |
-
"Choose whether to subscribe customers as soon as an order is placed or after "
|
219 |
-
"the order is processing or completed."
|
220 |
-
msgstr ""
|
221 |
-
|
222 |
-
#: includes/class-ss-wc-settings-mailchimp.php:384
|
223 |
-
msgid "Order Created"
|
224 |
-
msgstr ""
|
225 |
-
|
226 |
-
#: includes/class-ss-wc-settings-mailchimp.php:385
|
227 |
-
msgid "Order Processing"
|
228 |
-
msgstr ""
|
229 |
-
|
230 |
-
#: includes/class-ss-wc-settings-mailchimp.php:386
|
231 |
-
msgid "Order Completed"
|
232 |
-
msgstr ""
|
233 |
-
|
234 |
-
#: includes/class-ss-wc-settings-mailchimp.php:393
|
235 |
-
msgid "Double Opt-In"
|
236 |
-
msgstr ""
|
237 |
-
|
238 |
-
#: includes/class-ss-wc-settings-mailchimp.php:394
|
239 |
-
msgid "Enable Double Opt-In"
|
240 |
-
msgstr ""
|
241 |
-
|
242 |
-
#: includes/class-ss-wc-settings-mailchimp.php:397
|
243 |
-
msgid ""
|
244 |
-
"If enabled, customers will receive an email prompting them to confirm their "
|
245 |
-
"subscription to the list above."
|
246 |
-
msgstr ""
|
247 |
-
|
248 |
-
#: includes/class-ss-wc-settings-mailchimp.php:402
|
249 |
-
msgid "Subscribe Customers"
|
250 |
-
msgstr ""
|
251 |
-
|
252 |
-
#: includes/class-ss-wc-settings-mailchimp.php:403
|
253 |
-
msgid ""
|
254 |
-
"<p>Choose <strong>Ask for permission</strong> to show an \"Opt-in\" checkbox "
|
255 |
-
"during checkout. Customers will only be subscribed to the list above if they "
|
256 |
-
"opt-in. <p>Choose <strong>Automatically</strong> to subscribe customers "
|
257 |
-
"silently upon checkout. Caution, this is without the customer's consent.</p>"
|
258 |
-
msgstr ""
|
259 |
-
|
260 |
-
#: includes/class-ss-wc-settings-mailchimp.php:411
|
261 |
-
msgid "Ask for permission"
|
262 |
-
msgstr ""
|
263 |
-
|
264 |
-
#: includes/class-ss-wc-settings-mailchimp.php:412
|
265 |
-
msgid "Automatically"
|
266 |
-
msgstr ""
|
267 |
-
|
268 |
-
#: includes/class-ss-wc-settings-mailchimp.php:418
|
269 |
-
msgid "Opt-In Field Label"
|
270 |
-
msgstr ""
|
271 |
-
|
272 |
-
#: includes/class-ss-wc-settings-mailchimp.php:420
|
273 |
-
msgid "Optional: customize the label displayed next to the opt-in checkbox."
|
274 |
-
msgstr ""
|
275 |
-
|
276 |
-
#: includes/class-ss-wc-settings-mailchimp.php:428
|
277 |
-
msgid "Opt-In Checkbox Default"
|
278 |
-
msgstr ""
|
279 |
-
|
280 |
-
#: includes/class-ss-wc-settings-mailchimp.php:430
|
281 |
-
msgid "The default state of the opt-in checkbox."
|
282 |
-
msgstr ""
|
283 |
-
|
284 |
-
#: includes/class-ss-wc-settings-mailchimp.php:434
|
285 |
-
msgid "Checked"
|
286 |
-
msgstr ""
|
287 |
-
|
288 |
-
#: includes/class-ss-wc-settings-mailchimp.php:435
|
289 |
-
msgid "Unchecked"
|
290 |
-
msgstr ""
|
291 |
-
|
292 |
-
#: includes/class-ss-wc-settings-mailchimp.php:442
|
293 |
-
msgid "Opt-In Checkbox Location"
|
294 |
-
msgstr ""
|
295 |
-
|
296 |
-
#: includes/class-ss-wc-settings-mailchimp.php:444
|
297 |
-
msgid "Where to display the opt-in checkbox on the checkout page."
|
298 |
-
msgstr ""
|
299 |
-
|
300 |
-
#: includes/class-ss-wc-settings-mailchimp.php:448
|
301 |
-
msgid "Above customer details"
|
302 |
-
msgstr ""
|
303 |
-
|
304 |
-
#: includes/class-ss-wc-settings-mailchimp.php:449
|
305 |
-
msgid "Below customer details"
|
306 |
-
msgstr ""
|
307 |
-
|
308 |
-
#: includes/class-ss-wc-settings-mailchimp.php:450
|
309 |
-
msgid "Order review above submit"
|
310 |
-
msgstr ""
|
311 |
-
|
312 |
-
#: includes/class-ss-wc-settings-mailchimp.php:451
|
313 |
-
msgid "Order review below submit"
|
314 |
-
msgstr ""
|
315 |
-
|
316 |
-
#: includes/class-ss-wc-settings-mailchimp.php:452
|
317 |
-
msgid "Order review above total"
|
318 |
-
msgstr ""
|
319 |
-
|
320 |
-
#: includes/class-ss-wc-settings-mailchimp.php:453
|
321 |
-
msgid "Above billing details"
|
322 |
-
msgstr ""
|
323 |
-
|
324 |
-
#: includes/class-ss-wc-settings-mailchimp.php:454
|
325 |
-
msgid "Above shipping details"
|
326 |
-
msgstr ""
|
327 |
-
|
328 |
-
#: includes/class-ss-wc-settings-mailchimp.php:455
|
329 |
-
msgid "Below Checkout billing form"
|
330 |
-
msgstr ""
|
331 |
-
|
332 |
-
#: includes/class-ss-wc-settings-mailchimp.php:466
|
333 |
-
msgid "Enable Logging"
|
334 |
-
msgstr ""
|
335 |
-
|
336 |
-
#: includes/class-ss-wc-settings-mailchimp.php:473
|
337 |
-
#, php-format
|
338 |
-
msgid "%1$sView Log%2$s"
|
339 |
-
msgstr ""
|
340 |
-
|
341 |
-
#: includes/class-ss-wc-settings-mailchimp.php:485
|
342 |
-
msgid "Debug Log"
|
343 |
-
msgstr ""
|
344 |
-
|
345 |
-
#: includes/class-ss-wc-settings-mailchimp.php:489
|
346 |
-
msgid ""
|
347 |
-
"Enable logging MailChimp API calls. Only enable for troubleshooting purposes."
|
348 |
-
msgstr ""
|
349 |
-
|
350 |
-
#: includes/class-ss-wc-settings-mailchimp.php:494
|
351 |
-
msgid "System Info"
|
352 |
-
msgstr ""
|
353 |
-
|
354 |
-
#: includes/class-ss-wc-settings-mailchimp.php:496
|
355 |
-
msgid ""
|
356 |
-
"Copy the information below and send it to us when reporting an issue with "
|
357 |
-
"the plugin."
|
358 |
-
msgstr ""
|
359 |
-
|
360 |
-
#: includes/class-ss-wc-settings-mailchimp.php:584
|
361 |
-
msgid "Oops! No lists in your MailChimp account..."
|
362 |
-
msgstr ""
|
363 |
-
|
364 |
-
#: includes/class-ss-wc-settings-mailchimp.php:589
|
365 |
-
msgid "Select a list..."
|
366 |
-
msgstr ""
|
367 |
-
|
368 |
-
#: includes/class-ss-wc-settings-mailchimp.php:629
|
369 |
-
#, php-format
|
370 |
-
msgid ""
|
371 |
-
"Oops! There are no lists in your MailChimp account. %sClick here%s to create "
|
372 |
-
"one."
|
373 |
-
msgstr ""
|
374 |
-
|
375 |
-
#: includes/class-ss-wc-settings-mailchimp.php:641
|
376 |
-
#, php-format
|
377 |
-
msgid "Unable to load lists from MailChimp: (%s) %s. "
|
378 |
-
msgstr ""
|
379 |
-
|
380 |
-
#: includes/class-ss-wc-settings-mailchimp.php:642
|
381 |
-
#, php-format
|
382 |
-
msgid "Please check your Settings %ssettings%s."
|
383 |
-
msgstr ""
|
384 |
-
|
385 |
-
#. Plugin Name of the plugin/theme
|
386 |
-
msgid "WooCommerce MailChimp"
|
387 |
-
msgstr ""
|
388 |
-
|
389 |
-
#. Plugin URI of the plugin/theme
|
390 |
-
msgid "https://www.saintsystems.com/products/woocommerce-mailchimp/"
|
391 |
-
msgstr ""
|
392 |
-
|
393 |
-
#. Description of the plugin/theme
|
394 |
-
msgid ""
|
395 |
-
"WooCommerce MailChimp provides simple MailChimp integration for WooCommerce."
|
396 |
-
msgstr ""
|
397 |
-
|
398 |
-
#. Author of the plugin/theme
|
399 |
-
msgid "Saint Systems"
|
400 |
-
msgstr ""
|
401 |
-
|
402 |
-
#. Author URI of the plugin/theme
|
403 |
-
msgid "https://www.saintsystems.com"
|
404 |
-
msgstr ""
|
1 |
+
#, fuzzy
|
2 |
+
msgid ""
|
3 |
+
msgstr ""
|
4 |
+
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
5 |
+
"Project-Id-Version: WooCommerce MailChimp\n"
|
6 |
+
"POT-Creation-Date: 2016-09-20 10:27-0500\n"
|
7 |
+
"PO-Revision-Date: 2016-09-20 10:27-0500\n"
|
8 |
+
"Last-Translator: Adam Anderly <adam.anderly@saintsystems.com>\n"
|
9 |
+
"Language-Team: Adam Anderly <adam.anderly@saintsystems.com>\n"
|
10 |
+
"MIME-Version: 1.0\n"
|
11 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
+
"Content-Transfer-Encoding: 8bit\n"
|
13 |
+
"X-Generator: Poedit 1.8.9\n"
|
14 |
+
"X-Poedit-Basepath: ..\n"
|
15 |
+
"X-Poedit-WPHeader: woocommerce-mailchimp.php\n"
|
16 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
+
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
18 |
+
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
|
19 |
+
"_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
20 |
+
"X-Poedit-SearchPath-0: .\n"
|
21 |
+
"X-Poedit-SearchPathExcluded-0: *.js\n"
|
22 |
+
|
23 |
+
#: config/default-settings.php:10
|
24 |
+
#: includes/class-ss-wc-settings-mailchimp.php:421
|
25 |
+
msgid "Subscribe to our newsletter"
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: includes/class-ss-wc-mailchimp-admin-notices.php:166
|
29 |
+
msgid "Dismiss"
|
30 |
+
msgstr ""
|
31 |
+
|
32 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:158
|
33 |
+
msgid ""
|
34 |
+
"You are seeing this notice because you are an administrator. Other users of "
|
35 |
+
"the site will see nothing."
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:179
|
39 |
+
#, php-format
|
40 |
+
msgid ""
|
41 |
+
"%sWooCommerce MailChimp requires PHP Version %s or newer.%s \n"
|
42 |
+
"\n"
|
43 |
+
"You're using Version %s. Please ask your host to upgrade your server's PHP."
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:201
|
47 |
+
#, php-format
|
48 |
+
msgid ""
|
49 |
+
"%sWooCommerce MailChimp requires WordPress %s or newer.%s \n"
|
50 |
+
"\n"
|
51 |
+
"You're using Version %s. Please upgrade your WordPress installation."
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:253
|
55 |
+
#, php-format
|
56 |
+
msgid ""
|
57 |
+
"%sWooCommerce MailChimp requires WooCommerce Version %s or newer.%s You're "
|
58 |
+
"using Version %s. %sUpdate WooCommerce%s to use the WooCommerce MailChimp "
|
59 |
+
"plugin."
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:288
|
63 |
+
#, php-format
|
64 |
+
msgid ""
|
65 |
+
"%sWooCommerce MailChimp requires WooCommerce to be active. %sActivate "
|
66 |
+
"WooCommerce%s to use the WooCommerce MailChimp plugin."
|
67 |
+
msgstr ""
|
68 |
+
|
69 |
+
#: includes/class-ss-wc-mailchimp-compatibility.php:293
|
70 |
+
#, php-format
|
71 |
+
msgid ""
|
72 |
+
"%sWooCommerce MailChimp requires WooCommerce to be installed in order to run "
|
73 |
+
"properly. %sInstall WooCommerce%s to use the WooCommerce MailChimp plugin."
|
74 |
+
msgstr ""
|
75 |
+
|
76 |
+
#: includes/class-ss-wc-mailchimp-handler.php:35
|
77 |
+
#: includes/class-ss-wc-settings-mailchimp.php:46
|
78 |
+
#: includes/class-ss-wc-settings-mailchimp.php:313
|
79 |
+
msgid "MailChimp"
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: includes/class-ss-wc-mailchimp-handler.php:213
|
83 |
+
#, php-format
|
84 |
+
msgid "(): Subscribing customer (%s) to list %s"
|
85 |
+
msgstr ""
|
86 |
+
|
87 |
+
#: includes/class-ss-wc-mailchimp-handler.php:285
|
88 |
+
msgid "Please enter an api key."
|
89 |
+
msgstr ""
|
90 |
+
|
91 |
+
#: includes/class-ss-wc-mailchimp-handler.php:318
|
92 |
+
#: includes/class-ss-wc-mailchimp-handler.php:351
|
93 |
+
msgid "Enter your api key above to see your lists"
|
94 |
+
msgstr ""
|
95 |
+
|
96 |
+
#: includes/class-ss-wc-mailchimp-handler.php:357
|
97 |
+
msgid "Please select a list from above."
|
98 |
+
msgstr ""
|
99 |
+
|
100 |
+
#: includes/class-ss-wc-mailchimp-handler.php:490
|
101 |
+
#, php-format
|
102 |
+
msgid "(): Subscribing customer to MailChimp: %s"
|
103 |
+
msgstr ""
|
104 |
+
|
105 |
+
#: includes/class-ss-wc-mailchimp-handler.php:496
|
106 |
+
#, php-format
|
107 |
+
msgid "(): MailChimp API response: %s"
|
108 |
+
msgstr ""
|
109 |
+
|
110 |
+
#: includes/class-ss-wc-mailchimp-handler.php:500
|
111 |
+
#, php-format
|
112 |
+
msgid "(): WooCommerce MailChimp subscription failed: %s (%s)"
|
113 |
+
msgstr ""
|
114 |
+
|
115 |
+
#: includes/class-ss-wc-mailchimp-handler.php:509
|
116 |
+
msgid "WooCommerce MailChimp subscription failed"
|
117 |
+
msgstr ""
|
118 |
+
|
119 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:281
|
120 |
+
msgid "Settings"
|
121 |
+
msgstr ""
|
122 |
+
|
123 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:313
|
124 |
+
msgid "Connecting to MailChimp"
|
125 |
+
msgstr ""
|
126 |
+
|
127 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:314
|
128 |
+
msgid "Error. Please check your api key."
|
129 |
+
msgstr ""
|
130 |
+
|
131 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:315
|
132 |
+
msgid ""
|
133 |
+
"Error loading groups. Please check your MailChimp Interest Groups for the "
|
134 |
+
"selected list."
|
135 |
+
msgstr ""
|
136 |
+
|
137 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:316
|
138 |
+
msgid "Select one or more groups (optional)"
|
139 |
+
msgstr ""
|
140 |
+
|
141 |
+
#: includes/class-ss-wc-mailchimp-plugin.php:317
|
142 |
+
msgid "This list does not have interest groups enabled"
|
143 |
+
msgstr ""
|
144 |
+
|
145 |
+
#: includes/class-ss-wc-settings-mailchimp.php:201
|
146 |
+
#, php-format
|
147 |
+
msgid ""
|
148 |
+
"WooCommerce MailChimp error: Plugin is enabled but no api key provided. "
|
149 |
+
"Please enter your api key <a href=\"%s\">here</a>."
|
150 |
+
msgstr ""
|
151 |
+
|
152 |
+
#: includes/class-ss-wc-settings-mailchimp.php:250
|
153 |
+
msgid "General"
|
154 |
+
msgstr ""
|
155 |
+
|
156 |
+
#: includes/class-ss-wc-settings-mailchimp.php:253
|
157 |
+
#: includes/class-ss-wc-settings-mailchimp.php:477
|
158 |
+
msgid "Troubleshooting"
|
159 |
+
msgstr ""
|
160 |
+
|
161 |
+
#: includes/class-ss-wc-settings-mailchimp.php:315
|
162 |
+
msgid ""
|
163 |
+
"Enter your MailChimp settings below to control how WooCommerce integrates "
|
164 |
+
"with your MailChimp account."
|
165 |
+
msgstr ""
|
166 |
+
|
167 |
+
#: includes/class-ss-wc-settings-mailchimp.php:322
|
168 |
+
msgid "API Key"
|
169 |
+
msgstr ""
|
170 |
+
|
171 |
+
#: includes/class-ss-wc-settings-mailchimp.php:324
|
172 |
+
#, php-format
|
173 |
+
msgid "%sLogin to MailChimp%s to look up your api key."
|
174 |
+
msgstr ""
|
175 |
+
|
176 |
+
#: includes/class-ss-wc-settings-mailchimp.php:326
|
177 |
+
msgid "Paste your MailChimp API key here"
|
178 |
+
msgstr ""
|
179 |
+
|
180 |
+
#: includes/class-ss-wc-settings-mailchimp.php:334
|
181 |
+
msgid "Enable/Disable"
|
182 |
+
msgstr ""
|
183 |
+
|
184 |
+
#: includes/class-ss-wc-settings-mailchimp.php:335
|
185 |
+
msgid "Enable MailChimp Integration"
|
186 |
+
msgstr ""
|
187 |
+
|
188 |
+
#: includes/class-ss-wc-settings-mailchimp.php:337
|
189 |
+
msgid "Enable/disable the plugin functionality."
|
190 |
+
msgstr ""
|
191 |
+
|
192 |
+
#: includes/class-ss-wc-settings-mailchimp.php:351
|
193 |
+
msgid "Main List"
|
194 |
+
msgstr ""
|
195 |
+
|
196 |
+
#: includes/class-ss-wc-settings-mailchimp.php:353
|
197 |
+
msgid "All customers will be added to this list."
|
198 |
+
msgstr ""
|
199 |
+
|
200 |
+
#: includes/class-ss-wc-settings-mailchimp.php:363
|
201 |
+
msgid "Interest Groups"
|
202 |
+
msgstr ""
|
203 |
+
|
204 |
+
#: includes/class-ss-wc-settings-mailchimp.php:365
|
205 |
+
msgid "Optional: Interest groups to assign to subscribers."
|
206 |
+
msgstr ""
|
207 |
+
|
208 |
+
#: includes/class-ss-wc-settings-mailchimp.php:370
|
209 |
+
msgid "Select interest groups..."
|
210 |
+
msgstr ""
|
211 |
+
|
212 |
+
#: includes/class-ss-wc-settings-mailchimp.php:378
|
213 |
+
msgid "Subscribe Event"
|
214 |
+
msgstr ""
|
215 |
+
|
216 |
+
#: includes/class-ss-wc-settings-mailchimp.php:380
|
217 |
+
msgid ""
|
218 |
+
"Choose whether to subscribe customers as soon as an order is placed or after "
|
219 |
+
"the order is processing or completed."
|
220 |
+
msgstr ""
|
221 |
+
|
222 |
+
#: includes/class-ss-wc-settings-mailchimp.php:384
|
223 |
+
msgid "Order Created"
|
224 |
+
msgstr ""
|
225 |
+
|
226 |
+
#: includes/class-ss-wc-settings-mailchimp.php:385
|
227 |
+
msgid "Order Processing"
|
228 |
+
msgstr ""
|
229 |
+
|
230 |
+
#: includes/class-ss-wc-settings-mailchimp.php:386
|
231 |
+
msgid "Order Completed"
|
232 |
+
msgstr ""
|
233 |
+
|
234 |
+
#: includes/class-ss-wc-settings-mailchimp.php:393
|
235 |
+
msgid "Double Opt-In"
|
236 |
+
msgstr ""
|
237 |
+
|
238 |
+
#: includes/class-ss-wc-settings-mailchimp.php:394
|
239 |
+
msgid "Enable Double Opt-In"
|
240 |
+
msgstr ""
|
241 |
+
|
242 |
+
#: includes/class-ss-wc-settings-mailchimp.php:397
|
243 |
+
msgid ""
|
244 |
+
"If enabled, customers will receive an email prompting them to confirm their "
|
245 |
+
"subscription to the list above."
|
246 |
+
msgstr ""
|
247 |
+
|
248 |
+
#: includes/class-ss-wc-settings-mailchimp.php:402
|
249 |
+
msgid "Subscribe Customers"
|
250 |
+
msgstr ""
|
251 |
+
|
252 |
+
#: includes/class-ss-wc-settings-mailchimp.php:403
|
253 |
+
msgid ""
|
254 |
+
"<p>Choose <strong>Ask for permission</strong> to show an \"Opt-in\" checkbox "
|
255 |
+
"during checkout. Customers will only be subscribed to the list above if they "
|
256 |
+
"opt-in. <p>Choose <strong>Automatically</strong> to subscribe customers "
|
257 |
+
"silently upon checkout. Caution, this is without the customer's consent.</p>"
|
258 |
+
msgstr ""
|
259 |
+
|
260 |
+
#: includes/class-ss-wc-settings-mailchimp.php:411
|
261 |
+
msgid "Ask for permission"
|
262 |
+
msgstr ""
|
263 |
+
|
264 |
+
#: includes/class-ss-wc-settings-mailchimp.php:412
|
265 |
+
msgid "Automatically"
|
266 |
+
msgstr ""
|
267 |
+
|
268 |
+
#: includes/class-ss-wc-settings-mailchimp.php:418
|
269 |
+
msgid "Opt-In Field Label"
|
270 |
+
msgstr ""
|
271 |
+
|
272 |
+
#: includes/class-ss-wc-settings-mailchimp.php:420
|
273 |
+
msgid "Optional: customize the label displayed next to the opt-in checkbox."
|
274 |
+
msgstr ""
|
275 |
+
|
276 |
+
#: includes/class-ss-wc-settings-mailchimp.php:428
|
277 |
+
msgid "Opt-In Checkbox Default"
|
278 |
+
msgstr ""
|
279 |
+
|
280 |
+
#: includes/class-ss-wc-settings-mailchimp.php:430
|
281 |
+
msgid "The default state of the opt-in checkbox."
|
282 |
+
msgstr ""
|
283 |
+
|
284 |
+
#: includes/class-ss-wc-settings-mailchimp.php:434
|
285 |
+
msgid "Checked"
|
286 |
+
msgstr ""
|
287 |
+
|
288 |
+
#: includes/class-ss-wc-settings-mailchimp.php:435
|
289 |
+
msgid "Unchecked"
|
290 |
+
msgstr ""
|
291 |
+
|
292 |
+
#: includes/class-ss-wc-settings-mailchimp.php:442
|
293 |
+
msgid "Opt-In Checkbox Location"
|
294 |
+
msgstr ""
|
295 |
+
|
296 |
+
#: includes/class-ss-wc-settings-mailchimp.php:444
|
297 |
+
msgid "Where to display the opt-in checkbox on the checkout page."
|
298 |
+
msgstr ""
|
299 |
+
|
300 |
+
#: includes/class-ss-wc-settings-mailchimp.php:448
|
301 |
+
msgid "Above customer details"
|
302 |
+
msgstr ""
|
303 |
+
|
304 |
+
#: includes/class-ss-wc-settings-mailchimp.php:449
|
305 |
+
msgid "Below customer details"
|
306 |
+
msgstr ""
|
307 |
+
|
308 |
+
#: includes/class-ss-wc-settings-mailchimp.php:450
|
309 |
+
msgid "Order review above submit"
|
310 |
+
msgstr ""
|
311 |
+
|
312 |
+
#: includes/class-ss-wc-settings-mailchimp.php:451
|
313 |
+
msgid "Order review below submit"
|
314 |
+
msgstr ""
|
315 |
+
|
316 |
+
#: includes/class-ss-wc-settings-mailchimp.php:452
|
317 |
+
msgid "Order review above total"
|
318 |
+
msgstr ""
|
319 |
+
|
320 |
+
#: includes/class-ss-wc-settings-mailchimp.php:453
|
321 |
+
msgid "Above billing details"
|
322 |
+
msgstr ""
|
323 |
+
|
324 |
+
#: includes/class-ss-wc-settings-mailchimp.php:454
|
325 |
+
msgid "Above shipping details"
|
326 |
+
msgstr ""
|
327 |
+
|
328 |
+
#: includes/class-ss-wc-settings-mailchimp.php:455
|
329 |
+
msgid "Below Checkout billing form"
|
330 |
+
msgstr ""
|
331 |
+
|
332 |
+
#: includes/class-ss-wc-settings-mailchimp.php:466
|
333 |
+
msgid "Enable Logging"
|
334 |
+
msgstr ""
|
335 |
+
|
336 |
+
#: includes/class-ss-wc-settings-mailchimp.php:473
|
337 |
+
#, php-format
|
338 |
+
msgid "%1$sView Log%2$s"
|
339 |
+
msgstr ""
|
340 |
+
|
341 |
+
#: includes/class-ss-wc-settings-mailchimp.php:485
|
342 |
+
msgid "Debug Log"
|
343 |
+
msgstr ""
|
344 |
+
|
345 |
+
#: includes/class-ss-wc-settings-mailchimp.php:489
|
346 |
+
msgid ""
|
347 |
+
"Enable logging MailChimp API calls. Only enable for troubleshooting purposes."
|
348 |
+
msgstr ""
|
349 |
+
|
350 |
+
#: includes/class-ss-wc-settings-mailchimp.php:494
|
351 |
+
msgid "System Info"
|
352 |
+
msgstr ""
|
353 |
+
|
354 |
+
#: includes/class-ss-wc-settings-mailchimp.php:496
|
355 |
+
msgid ""
|
356 |
+
"Copy the information below and send it to us when reporting an issue with "
|
357 |
+
"the plugin."
|
358 |
+
msgstr ""
|
359 |
+
|
360 |
+
#: includes/class-ss-wc-settings-mailchimp.php:584
|
361 |
+
msgid "Oops! No lists in your MailChimp account..."
|
362 |
+
msgstr ""
|
363 |
+
|
364 |
+
#: includes/class-ss-wc-settings-mailchimp.php:589
|
365 |
+
msgid "Select a list..."
|
366 |
+
msgstr ""
|
367 |
+
|
368 |
+
#: includes/class-ss-wc-settings-mailchimp.php:629
|
369 |
+
#, php-format
|
370 |
+
msgid ""
|
371 |
+
"Oops! There are no lists in your MailChimp account. %sClick here%s to create "
|
372 |
+
"one."
|
373 |
+
msgstr ""
|
374 |
+
|
375 |
+
#: includes/class-ss-wc-settings-mailchimp.php:641
|
376 |
+
#, php-format
|
377 |
+
msgid "Unable to load lists from MailChimp: (%s) %s. "
|
378 |
+
msgstr ""
|
379 |
+
|
380 |
+
#: includes/class-ss-wc-settings-mailchimp.php:642
|
381 |
+
#, php-format
|
382 |
+
msgid "Please check your Settings %ssettings%s."
|
383 |
+
msgstr ""
|
384 |
+
|
385 |
+
#. Plugin Name of the plugin/theme
|
386 |
+
msgid "WooCommerce MailChimp"
|
387 |
+
msgstr ""
|
388 |
+
|
389 |
+
#. Plugin URI of the plugin/theme
|
390 |
+
msgid "https://www.saintsystems.com/products/woocommerce-mailchimp/"
|
391 |
+
msgstr ""
|
392 |
+
|
393 |
+
#. Description of the plugin/theme
|
394 |
+
msgid ""
|
395 |
+
"WooCommerce MailChimp provides simple MailChimp integration for WooCommerce."
|
396 |
+
msgstr ""
|
397 |
+
|
398 |
+
#. Author of the plugin/theme
|
399 |
+
msgid "Saint Systems"
|
400 |
+
msgstr ""
|
401 |
+
|
402 |
+
#. Author URI of the plugin/theme
|
403 |
+
msgid "https://www.saintsystems.com"
|
404 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -3,8 +3,9 @@ Contributors: saintsystems, anderly
|
|
3 |
Donate link: http://ssms.us/hVdk
|
4 |
Tags: woocommerce, mailchimp
|
5 |
Requires at least: 3.5.1
|
6 |
-
Tested up to: 4.9.
|
7 |
-
|
|
|
8 |
License: GPLv3
|
9 |
|
10 |
Simple and flexible MailChimp integration for WooCommerce.
|
@@ -113,6 +114,9 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
|
|
113 |
|
114 |
== Changelog ==
|
115 |
|
|
|
|
|
|
|
116 |
#### 2.1.9 - February 1, 2018
|
117 |
- Added new opt-in checkbox location for order review above cart/product table.
|
118 |
|
3 |
Donate link: http://ssms.us/hVdk
|
4 |
Tags: woocommerce, mailchimp
|
5 |
Requires at least: 3.5.1
|
6 |
+
Tested up to: 4.9.5
|
7 |
+
WC tested up to: 3.3.1
|
8 |
+
Stable tag: 2.1.10
|
9 |
License: GPLv3
|
10 |
|
11 |
Simple and flexible MailChimp integration for WooCommerce.
|
114 |
|
115 |
== Changelog ==
|
116 |
|
117 |
+
#### 2.1.10 - February 12, 2018
|
118 |
+
- Added WooCommerce tested up to header
|
119 |
+
|
120 |
#### 2.1.9 - February 1, 2018
|
121 |
- Added new opt-in checkbox location for order review above cart/product table.
|
122 |
|
woocommerce-mailchimp.php
CHANGED
@@ -5,7 +5,8 @@
|
|
5 |
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
-
* Version: 2.1.
|
|
|
9 |
* Text Domain: woocommerce-mailchimp
|
10 |
* Domain Path: languages
|
11 |
*
|
5 |
* Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
|
6 |
* Author: Saint Systems
|
7 |
* Author URI: https://www.saintsystems.com
|
8 |
+
* Version: 2.1.10
|
9 |
+
* WC tested up to: 3.3.1
|
10 |
* Text Domain: woocommerce-mailchimp
|
11 |
* Domain Path: languages
|
12 |
*
|