Version Description
- moved to an autoloader for performance enhancement
- flush database tables on un-installation to assist with stale records in the queue
- turn on standard debugging by default to help troubleshoot issues
- moved the plugin button to the left main navigation
- allow store owners to select the image size being used for products
- fix paypal new order bug where it did not send on initial placement
- add additional configuration success checks for the plugin being configured before pushing any jobs into the queue
- fix the multisite network activation issue
- hide the opt in checkbox for already logged in customers that were previously subscribed
- miscellaneous UI enhancements
Download this release
Release Info
Developer | ryanhungate |
Plugin | MailChimp for WooCommerce |
Version | 2.1.6 |
Comparing to | |
See all releases |
Code changes from version 2.1.5 to 2.1.6
- README.txt +17 -2
- admin/class-mailchimp-woocommerce-admin.php +41 -66
- admin/partials/mailchimp-woocommerce-admin-tabs.php +2 -2
- admin/partials/tabs/campaign_defaults.php +1 -2
- admin/partials/tabs/logs.php +0 -0
- admin/partials/tabs/newsletter_settings.php +21 -0
- admin/partials/tabs/store_info.php +1 -1
- bootstrap.php +668 -0
- includes/api/assets/class-mailchimp-address.php +1 -1
- includes/api/assets/class-mailchimp-cart.php +1 -1
- includes/api/assets/class-mailchimp-customer.php +1 -1
- includes/api/assets/class-mailchimp-line-item.php +1 -1
- includes/api/assets/class-mailchimp-order.php +7 -5
- includes/api/assets/class-mailchimp-product-variation.php +1 -1
- includes/api/assets/class-mailchimp-product.php +1 -1
- includes/api/assets/class-mailchimp-promo-code.php +0 -0
- includes/api/assets/class-mailchimp-promo-rule.php +0 -0
- includes/api/assets/class-mailchimp-store.php +1 -1
- includes/api/class-mailchimp-api.php +1 -1
- includes/api/class-mailchimp-woocommerce-api.php +1 -1
- includes/api/class-mailchimp-woocommerce-create-list-submission.php +1 -1
- includes/api/class-mailchimp-woocommerce-transform-coupons.php +1 -1
- includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php +1 -1
- includes/api/class-mailchimp-woocommerce-transform-products.php +28 -4
- includes/api/errors/class-mailchimp-error.php +1 -1
- includes/api/errors/class-mailchimp-server-error.php +1 -1
- includes/api/helpers/class-mailchimp-woocommerce-api-currency-codes.php +1 -1
- includes/api/helpers/class-mailchimp-woocommerce-api-locales.php +1 -1
- includes/class-mailchimp-woocommerce-activator.php +9 -9
- includes/class-mailchimp-woocommerce-deactivator.php +6 -6
- includes/class-mailchimp-woocommerce-i18n.php +6 -6
- includes/class-mailchimp-woocommerce-loader.php +6 -6
- includes/class-mailchimp-woocommerce-newsletter.php +8 -5
- includes/class-mailchimp-woocommerce-options.php +10 -2
- includes/class-mailchimp-woocommerce-service.php +62 -45
- includes/class-mailchimp-woocommerce.php +120 -89
- includes/processes/class-mailchimp-woocommerce-abstract-sync.php +8 -3
- includes/processes/class-mailchimp-woocommerce-cart-update.php +64 -63
- includes/processes/class-mailchimp-woocommerce-process-coupons.php +2 -2
- includes/processes/class-mailchimp-woocommerce-process-orders.php +2 -2
- includes/processes/class-mailchimp-woocommerce-process-products.php +2 -2
- includes/processes/class-mailchimp-woocommerce-single-coupon.php +8 -2
- includes/processes/class-mailchimp-woocommerce-single-order.php +106 -106
- includes/processes/class-mailchimp-woocommerce-single-product.php +6 -1
- includes/processes/class-mailchimp-woocommerce-user-submit.php +5 -0
- mailchimp-woocommerce.php +7 -473
- public/class-mailchimp-woocommerce-public.php +7 -36
- public/js/mailchimp-woocommerce-public.js +92 -51
- public/js/mailchimp-woocommerce-public.min.js +1 -1
- public/partials/mailchimp-woocommerce-public-display.php +2 -2
- uninstall.php +5 -40
README.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: ryanhungate, MailChimp
|
|
3 |
Tags: ecommerce,email,workflows,mailchimp
|
4 |
Donate link: https://mailchimp.com
|
5 |
Requires at least: 4.3
|
6 |
-
Tested up to: 4.9
|
7 |
-
Stable tag: 2.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -69,6 +69,21 @@ You have 2 options to run this process:
|
|
69 |
|
70 |
|
71 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
= 2.1.5 =
|
73 |
* added support for Polish (zloty - zł) and Moldovan Leu currencies
|
74 |
* update currency code for Belarusian Rouble
|
3 |
Tags: ecommerce,email,workflows,mailchimp
|
4 |
Donate link: https://mailchimp.com
|
5 |
Requires at least: 4.3
|
6 |
+
Tested up to: 4.9.5
|
7 |
+
Stable tag: 2.1.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
69 |
|
70 |
|
71 |
== Changelog ==
|
72 |
+
= 2.1.6 =
|
73 |
+
* moved to an autoloader for performance enhancement
|
74 |
+
* flush database tables on un-installation to assist with stale records in the queue
|
75 |
+
* turn on standard debugging by default to help troubleshoot issues
|
76 |
+
* moved the plugin button to the left main navigation
|
77 |
+
* allow store owners to select the image size being used for products
|
78 |
+
* fix paypal new order bug where it did not send on initial placement
|
79 |
+
* add additional configuration success checks for the plugin being configured before pushing any jobs into the queue
|
80 |
+
* fix the multisite network activation issue
|
81 |
+
* hide the opt in checkbox for already logged in customers that were previously subscribed
|
82 |
+
* miscellaneous UI enhancements
|
83 |
+
|
84 |
+
= 2.1.5 =
|
85 |
+
* is_configured filters applied before certain jobs were firing and failing.
|
86 |
+
|
87 |
= 2.1.5 =
|
88 |
* added support for Polish (zloty - zł) and Moldovan Leu currencies
|
89 |
* update currency code for Belarusian Rouble
|
admin/class-mailchimp-woocommerce-admin.php
CHANGED
@@ -6,8 +6,8 @@
|
|
6 |
* @link https://mailchimp.com
|
7 |
* @since 1.0.1
|
8 |
*
|
9 |
-
* @package
|
10 |
-
* @subpackage
|
11 |
*/
|
12 |
|
13 |
/**
|
@@ -16,14 +16,14 @@
|
|
16 |
* Defines the plugin name, version, and two examples hooks for how to
|
17 |
* enqueue the admin-specific stylesheet and JavaScript.
|
18 |
*
|
19 |
-
* @package
|
20 |
-
* @subpackage
|
21 |
-
* @author Ryan Hungate <ryan@
|
22 |
*/
|
23 |
-
class
|
24 |
|
25 |
/**
|
26 |
-
* @return
|
27 |
*/
|
28 |
public static function connect()
|
29 |
{
|
@@ -67,80 +67,52 @@ class MailChimp_Woocommerce_Admin extends MailChimp_Woocommerce_Options {
|
|
67 |
*
|
68 |
* @since 1.0.0
|
69 |
*/
|
70 |
-
|
71 |
public function add_plugin_admin_menu() {
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
/**
|
79 |
* Add settings action link to the plugins page.
|
80 |
*
|
81 |
* @since 1.0.0
|
82 |
*/
|
83 |
public function add_action_links($links) {
|
84 |
-
/*
|
85 |
-
* Documentation : https://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name)
|
86 |
-
*/
|
87 |
$settings_link = array(
|
88 |
'<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_name ) . '">' . __('Settings', $this->plugin_name) . '</a>',
|
89 |
);
|
90 |
-
|
91 |
return array_merge($settings_link, $links);
|
92 |
}
|
93 |
|
94 |
-
/**
|
95 |
-
* Admin bar
|
96 |
-
*
|
97 |
-
* @param WP_Admin_Bar $wp_admin_bar
|
98 |
-
*/
|
99 |
-
public function admin_bar( $wp_admin_bar ) {
|
100 |
-
if ( ! current_user_can( 'manage_options' ) ) {
|
101 |
-
return;
|
102 |
-
}
|
103 |
-
$wp_admin_bar->add_menu( array(
|
104 |
-
'id' => 'mailchimp-woocommerce',
|
105 |
-
'title' => __('MailChimp', 'mailchimp-woocommerce' ),
|
106 |
-
'href' => '#',
|
107 |
-
));
|
108 |
-
$wp_admin_bar->add_menu( array(
|
109 |
-
'parent' => 'mailchimp-woocommerce',
|
110 |
-
'id' => 'mailchimp-woocommerce-api-key',
|
111 |
-
'title' => __('API Key', 'mailchimp-woocommerce' ),
|
112 |
-
'href' => wp_nonce_url(admin_url('options-general.php?page=mailchimp-woocommerce&tab=api_key'), 'mc-api-key'),
|
113 |
-
));
|
114 |
-
$wp_admin_bar->add_menu( array(
|
115 |
-
'parent' => 'mailchimp-woocommerce',
|
116 |
-
'id' => 'mailchimp-woocommerce-store-info',
|
117 |
-
'title' => __('Store Info', 'mailchimp-woocommerce' ),
|
118 |
-
'href' => wp_nonce_url(admin_url('options-general.php?page=mailchimp-woocommerce&tab=store_info'), 'mc-store-info'),
|
119 |
-
));
|
120 |
-
$wp_admin_bar->add_menu( array(
|
121 |
-
'parent' => 'mailchimp-woocommerce',
|
122 |
-
'id' => 'mailchimp-woocommerce-campaign-defaults',
|
123 |
-
'title' => __('Campaign Defaults', 'mailchimp-woocommerce' ),
|
124 |
-
'href' => wp_nonce_url(admin_url('options-general.php?page=mailchimp-woocommerce&tab=campaign_defaults'), 'mc-campaign-defaults'),
|
125 |
-
));
|
126 |
-
$wp_admin_bar->add_menu( array(
|
127 |
-
'parent' => 'mailchimp-woocommerce',
|
128 |
-
'id' => 'mailchimp-woocommerce-newsletter-settings',
|
129 |
-
'title' => __('Newsletter Settings', 'mailchimp-woocommerce' ),
|
130 |
-
'href' => wp_nonce_url(admin_url('options-general.php?page=mailchimp-woocommerce&tab=newsletter_settings'), 'mc-newsletter-settings'),
|
131 |
-
));
|
132 |
-
|
133 |
-
// only display this button if the data is not syncing and we have a valid api key
|
134 |
-
if ((bool) $this->getOption('mailchimp_list', false) && (bool) $this->getData('sync.syncing', false) === false) {
|
135 |
-
$wp_admin_bar->add_menu( array(
|
136 |
-
'parent' => 'mailchimp-woocommerce',
|
137 |
-
'id' => 'mailchimp-woocommerce-sync',
|
138 |
-
'title' => __('Sync', 'mailchimp-woocommerce'),
|
139 |
-
'href' => wp_nonce_url(admin_url('?mailchimp-woocommerce[action]=sync&mailchimp-woocommerce[action]=sync'), 'mc-sync'),
|
140 |
-
));
|
141 |
-
}
|
142 |
-
}
|
143 |
-
|
144 |
/**
|
145 |
* Render the settings page for this plugin.
|
146 |
*
|
@@ -505,6 +477,7 @@ class MailChimp_Woocommerce_Admin extends MailChimp_Woocommerce_Options {
|
|
505 |
'mailchimp_auto_subscribe' => isset($input['mailchimp_auto_subscribe']) ? (bool) $input['mailchimp_auto_subscribe'] : $this->getOption('mailchimp_auto_subscribe', '0'),
|
506 |
'mailchimp_checkbox_defaults' => $checkbox,
|
507 |
'mailchimp_checkbox_action' => isset($input['mailchimp_checkbox_action']) ? $input['mailchimp_checkbox_action'] : $this->getOption('mailchimp_checkbox_action', 'woocommerce_after_checkout_billing_form'),
|
|
|
508 |
);
|
509 |
|
510 |
if ($data['mailchimp_list'] === 'create_new') {
|
@@ -891,6 +864,8 @@ class MailChimp_Woocommerce_Admin extends MailChimp_Woocommerce_Options {
|
|
891 |
*/
|
892 |
private function startSync()
|
893 |
{
|
|
|
|
|
894 |
$coupon_sync = new MailChimp_WooCommerce_Process_Coupons();
|
895 |
wp_queue($coupon_sync);
|
896 |
|
6 |
* @link https://mailchimp.com
|
7 |
* @since 1.0.1
|
8 |
*
|
9 |
+
* @package MailChimp_WooCommerce
|
10 |
+
* @subpackage MailChimp_WooCommerce/admin
|
11 |
*/
|
12 |
|
13 |
/**
|
16 |
* Defines the plugin name, version, and two examples hooks for how to
|
17 |
* enqueue the admin-specific stylesheet and JavaScript.
|
18 |
*
|
19 |
+
* @package MailChimp_WooCommerce
|
20 |
+
* @subpackage MailChimp_WooCommerce/admin
|
21 |
+
* @author Ryan Hungate <ryan@vextras.com>
|
22 |
*/
|
23 |
+
class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
24 |
|
25 |
/**
|
26 |
+
* @return MailChimp_WooCommerce_Admin
|
27 |
*/
|
28 |
public static function connect()
|
29 |
{
|
67 |
*
|
68 |
* @since 1.0.0
|
69 |
*/
|
|
|
70 |
public function add_plugin_admin_menu() {
|
71 |
+
add_menu_page(
|
72 |
+
'MailChimp - WooCommerce Setup',
|
73 |
+
'MailChimp',
|
74 |
+
'manage_options',
|
75 |
+
$this->plugin_name,
|
76 |
+
array($this, 'display_plugin_setup_page'),
|
77 |
+
'data:image/svg+xml;base64,'.$this->mailchimp_svg()
|
78 |
+
);
|
79 |
}
|
80 |
|
81 |
+
/**
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
protected function mailchimp_svg()
|
85 |
+
{
|
86 |
+
return base64_encode('<?xml version="1.0" encoding="UTF-8"?>
|
87 |
+
<svg width="111px" height="116px" viewBox="0 0 111 116" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
88 |
+
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
|
89 |
+
<title>Group</title>
|
90 |
+
<desc>Created with Sketch.</desc>
|
91 |
+
<defs></defs>
|
92 |
+
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
93 |
+
<g id="Group">
|
94 |
+
<path d="M76.5859,0.7017 L76.5849,0.7017 C71.6089,0.7017 65.7009,2.4987 59.7709,5.7927 C58.6459,4.8877 57.3339,3.8317 57.2839,3.7927 C55.0919,2.0667 52.4549,1.1907 49.4489,1.1897 C39.2019,1.1897 27.9399,11.1957 22.1389,17.1607 C12.9849,26.5727 5.6129,37.8427 2.4179,47.3087 C-1.5161,58.9627 1.8869,64.6287 5.4329,67.3307 L8.1899,69.4387 C6.2259,78.2517 11.1159,87.7027 19.6639,90.8437 C21.2849,91.4397 22.9629,91.7857 24.6639,91.8777 C28.2049,97.4237 41.6679,115.5347 66.4699,115.5417 C80.1529,115.5417 91.7799,109.9377 100.1089,99.3337 C105.7329,92.1747 108.1719,84.8867 108.8149,82.7097 C109.6379,81.3307 111.6759,77.2977 110.0739,73.4267 L110.0479,73.3637 L110.0189,73.3007 C109.1609,71.4697 107.6859,70.0227 105.8399,69.1577 C105.6629,68.5617 105.4829,68.0447 105.3149,67.6077 C106.7299,65.4787 107.0949,62.8477 106.2809,60.4207 C105.4089,57.8187 103.3169,55.7857 100.6029,54.8587 C98.0479,52.5407 95.7049,51.3697 93.9629,50.4987 L93.6009,50.3177 C93.1359,50.0857 92.8879,49.9617 92.6859,49.8647 C92.6089,49.1767 92.5369,48.3707 92.4619,47.5407 C92.2669,45.3737 92.0449,42.9177 91.6319,40.8417 C90.9369,37.3437 89.4899,34.6077 87.3279,32.6967 C86.8749,31.7957 86.2689,30.7457 85.4899,29.7127 C91.4609,19.6007 92.1439,10.1877 87.1759,4.8097 C84.6939,2.1217 81.0319,0.7017 76.5859,0.7017 M76.5859,3.7017 C80.0809,3.7017 83.0039,4.7137 84.9719,6.8447 C89.3919,11.6297 87.8029,20.7677 81.7689,30.0187 C83.0659,31.2507 84.1419,32.9257 84.9099,34.5887 C86.8279,36.0687 88.0709,38.3197 88.6899,41.4277 C89.3779,44.8837 89.5209,49.8057 89.9519,51.9207 C91.5789,52.6557 90.8869,52.3157 92.6209,53.1827 C94.4309,54.0867 96.6339,55.1877 99.0679,57.5307 C103.3969,58.6147 105.0489,63.2157 102.5169,66.3567 C102.4479,66.4407 102.1429,66.8027 101.8259,67.1627 C101.9009,67.3627 102.7319,68.7067 103.3309,71.4447 C105.1239,71.8687 106.5529,72.9727 107.3019,74.5737 C108.5989,77.7077 106.0479,81.4777 106.0479,81.4777 C105.9629,81.7547 97.9549,112.5417 66.4849,112.5417 L66.4709,112.5417 C39.2589,112.5337 26.3599,88.8807 26.3599,88.8807 C26.0989,88.8947 25.8389,88.9027 25.5799,88.9027 C23.8749,88.9027 22.2309,88.5907 20.6979,88.0277 C12.7149,85.0947 8.8839,75.9607 11.6389,68.2977 L7.2499,64.9447 C-8.0381,53.2977 29.3809,4.1887 49.4489,4.1897 C51.6919,4.1907 53.7189,4.8037 55.4309,6.1517 C55.5169,6.2197 59.4949,9.4217 59.4949,9.4217 C65.6079,5.7087 71.6629,3.7017 76.5849,3.7017 L76.5859,3.7017" id="Fill-40" fill="#FFFFFF"></path>
|
95 |
+
<path d="M79.1367,27.5845 L79.1377,27.5835 C79.1297,27.5625 79.0647,27.3825 79.0387,27.3335 C78.0087,25.1455 75.6057,23.6175 73.4647,23.0045 C73.8397,23.3955 74.3827,24.1095 74.6037,24.5345 C72.9877,23.4245 70.8397,22.4465 68.5987,21.9825 C68.5987,21.9825 68.8657,22.1745 68.9117,22.2165 C69.3587,22.6325 69.9527,23.2905 70.1967,23.8555 C68.0547,22.9955 65.3467,22.5135 63.0297,22.9595 C62.9957,22.9655 62.7397,23.0265 62.7397,23.0265 C62.7397,23.0265 63.0407,23.1015 63.1087,23.1215 C63.8767,23.3495 64.9737,23.8175 65.4567,24.4595 C61.6097,23.7825 57.3767,24.5315 55.0947,25.8085 C55.3887,25.7955 55.3857,25.7945 55.6337,25.8015 C56.4727,25.8235 58.1647,25.9375 58.8747,26.3895 C56.4487,26.8825 52.9367,27.9685 51.0457,29.5945 C51.3787,29.5555 53.2737,29.3145 54.0487,29.4385 C43.6427,35.3935 38.9067,44.3965 38.9067,44.3965 C41.9747,40.3985 45.9547,36.5505 51.3827,33.0325 C63.2387,25.3485 75.0797,24.4655 79.1367,27.5845" id="Fill-42" fill="#FFFFFE"></path>
|
96 |
+
<path d="M27.9473,80.7656 C26.3263,80.8026 25.4413,79.7896 25.6003,79.5686 C25.6743,79.4626 25.9213,79.5096 26.3013,79.5656 C28.3663,79.8866 29.6193,78.6266 29.9223,77.3066 C29.9263,77.2856 30.0083,76.9336 30.0043,76.6886 C30.0203,76.4766 29.9973,76.2606 29.9653,76.0676 C29.7203,74.7016 28.1543,74.4446 27.1473,73.3576 C26.2433,72.3756 26.4223,71.1166 26.9893,70.5126 C27.6723,69.8396 28.6483,70.0846 28.6353,70.3236 C28.6343,70.4496 28.3993,70.5446 28.1073,70.7446 C27.7283,71.0116 27.6783,71.2696 27.7743,71.7126 C27.8393,71.9556 27.9473,72.1156 28.1813,72.2996 C29.0283,72.9756 31.3043,73.4466 31.7183,75.7366 C32.1753,78.3656 30.2603,80.7166 27.9473,80.7656 M24.3623,68.1646 C23.9123,68.2606 24.1643,68.2056 23.7193,68.3306 C23.6503,68.3506 23.5873,68.3696 23.5323,68.3926 C23.3923,68.4586 23.2633,68.5036 23.1393,68.5696 C23.0363,68.6266 22.1513,69.0216 21.4313,69.9016 C20.4633,71.1046 20.1113,72.6796 20.1703,74.1956 C20.2283,75.6676 20.6603,76.4826 20.7403,76.6816 C21.0743,77.4006 20.2913,77.5476 19.5763,76.7756 L19.5743,76.7736 C19.0033,76.1676 18.6353,75.2456 18.4573,74.4276 L18.4573,74.4266 L18.4573,74.4276 C17.7313,71.0386 19.2443,67.6326 22.7353,66.2716 C22.9303,66.1946 23.1583,66.1466 23.3423,66.0926 L23.3413,66.0936 C23.6973,65.9876 24.9743,65.7286 26.2723,65.9306 C27.6973,66.1516 28.9563,66.8666 29.7543,67.7936 L29.7563,67.7956 C30.3703,68.4946 30.8333,69.4786 30.7503,70.3546 L30.7503,70.3566 C30.7193,70.7206 30.5573,71.2436 30.2293,71.3786 C30.1073,71.4286 29.9853,71.4026 29.8993,71.3186 C29.6623,71.0856 29.8453,70.6076 29.2663,69.7876 C28.4993,68.6996 26.7633,67.6566 24.3623,68.1646 M34.8423,74.1896 C34.9993,71.6386 34.5973,69.1156 33.8133,66.7166 C33.8133,66.7166 33.4683,68.1466 32.7823,69.8896 C32.1243,64.3126 29.7833,63.1316 29.7833,63.1316 C28.4263,62.5036 26.9273,62.1546 25.3503,62.1546 C19.2683,62.1546 14.3393,67.3446 14.3393,73.7476 C14.3393,80.1516 19.2683,85.3416 25.3503,85.3416 C32.2013,85.3416 37.4013,78.8196 36.1913,71.6936 C36.1913,71.6936 35.4923,73.3246 34.8423,74.1896" id="Fill-44" fill="#FFFFFF"></path>
|
97 |
+
<path d="M55.2637,15.4038 C54.6187,15.8608 54.0497,16.2798 53.5687,16.6428 L50.2657,13.8778 L55.2637,15.4038 Z M57.7737,13.7038 C57.2307,14.0548 56.7147,14.3998 56.2307,14.7308 L55.3507,11.6728 L57.7737,13.7038 Z M18.5667,60.1648 L18.3907,60.1708 C22.0977,47.2248 32.0597,33.9258 42.2127,25.2628 C44.7447,23.1018 49.8377,19.6738 49.8377,19.6738 L44.0837,14.6028 L43.6637,11.6738 L51.5817,18.2108 C51.5807,18.2118 51.5797,18.2128 51.5797,18.2128 C51.2217,18.5058 50.8627,18.8068 50.5027,19.1138 C49.7227,19.7818 48.9407,20.4808 48.1597,21.2078 C47.0237,22.2638 45.8907,23.3788 44.7697,24.5368 C42.3547,27.0338 39.9957,29.7368 37.7857,32.5168 C33.8777,37.4318 32.2517,39.7248 29.7837,44.3968 C29.7727,44.4108 43.2807,28.2128 46.6437,24.8758 C52.8167,18.7528 62.9197,11.9348 63.0257,11.8738 C67.3387,9.2338 70.9807,7.6838 73.9687,7.0118 C69.0587,7.5128 63.8067,10.0368 59.6847,12.5108 C59.6777,12.5048 53.6927,7.4468 53.6847,7.4408 L51.4907,8.2808 L52.6747,12.5858 L51.2097,12.1118 L50.7927,10.4258 L51.4907,8.2808 C43.5097,6.3878 25.9397,19.6458 15.3837,36.4458 C11.1127,43.2428 5.1097,55.2008 8.5607,61.0238 C9.1437,62.0148 13.2437,65.0248 13.2867,65.0358 C14.8877,62.8148 16.7207,61.1818 18.5667,60.1648 Z" id="Fill-46" fill="#FFFFFF"></path>
|
98 |
+
<path d="M62.7568,61.0156 C62.6058,60.8996 62.7548,60.4276 63.2788,59.9196 C63.7368,59.4816 64.2098,59.2346 64.7548,59.0046 C64.8408,58.9686 64.9288,58.9356 65.0208,58.9126 C65.2728,58.8456 65.5278,58.7596 65.8048,58.7176 C68.0218,58.3406 69.6438,59.5706 69.4328,59.9276 C69.3378,60.0936 68.9278,60.0566 68.3158,60.0156 C67.0468,59.9276 65.7148,59.9486 63.8318,60.7316 C63.2698,60.9576 62.9058,61.1346 62.7568,61.0156 M60.2968,57.2016 C59.4678,57.5176 58.8788,57.7626 58.5968,57.7206 C58.1368,57.6526 58.5818,56.8096 59.5878,55.9936 C61.6108,54.3786 64.3888,53.8776 66.7638,54.7616 C67.8028,55.1446 68.9698,55.9076 69.5798,56.8006 C69.8118,57.1386 69.8738,57.3946 69.7798,57.4996 C69.5938,57.7176 68.9288,57.4236 67.9448,57.0406 C65.4308,56.1026 63.5768,55.9596 60.2968,57.2016 M76.5508,58.4516 C76.8948,57.8226 77.8728,57.6966 78.7348,58.1676 C79.5958,58.6406 80.0158,59.5326 79.6708,60.1616 C79.3268,60.7886 78.3488,60.9156 77.4868,60.4436 C76.6258,59.9716 76.2058,59.0786 76.5508,58.4516 M80.1828,47.5176 L80.1818,47.5176 C80.1828,47.5176 80.1828,47.5176 80.1838,47.5176 C81.4978,47.0616 83.2388,50.4286 83.3188,53.4166 C82.2798,52.8976 81.0598,52.6766 79.8038,52.7856 C79.4878,51.8236 79.3368,50.9166 79.2998,49.9356 C79.2828,49.1196 79.4128,47.7686 80.1828,47.5176 M84.3258,57.6766 C84.1928,58.5366 83.5748,59.1536 82.9488,59.0556 C82.3218,58.9576 81.9228,58.1826 82.0578,57.3236 C82.1918,56.4636 82.8078,55.8466 83.4348,55.9446 C84.0608,56.0416 84.4598,56.8186 84.3258,57.6766 M101.6328,74.9486 C100.7498,74.9486 100.0828,75.1816 100.0828,75.1816 C100.0828,75.1816 100.0938,71.5046 98.3928,68.6416 C97.0818,70.1166 93.4438,73.0366 88.6678,75.3036 C84.1908,77.4296 78.2158,79.2906 70.8118,79.5376 C68.7378,79.6276 67.4548,79.2896 66.7338,81.7066 C66.6748,81.9226 66.6378,82.1646 66.6178,82.4116 C74.7338,84.9606 87.5698,79.9886 88.8158,79.6996 C88.8678,79.6876 88.9008,79.6806 88.9318,79.6796 C89.7358,79.7446 82.0398,84.5996 71.3608,84.5996 C69.5578,84.5996 68.0038,84.4426 66.7768,84.1966 C67.3608,86.1986 68.8858,87.0806 70.8948,87.5476 C72.4178,87.9026 74.0348,87.9366 74.0348,87.9366 C88.8308,88.3516 101.0058,76.8876 101.5088,76.2986 C101.5088,76.2986 101.3758,76.6096 101.3608,76.6446 C99.1918,81.5226 86.6338,90.3676 74.1338,90.1146 L74.0928,90.1276 C71.1948,90.1176 67.6718,89.3706 65.8408,87.1006 C62.9438,83.5076 64.4468,77.5356 69.0648,77.3946 C69.0698,77.3946 70.1318,77.3696 70.6048,77.3586 C82.0368,77.0066 92.2948,72.8066 99.6398,64.0356 C100.6498,62.7816 99.5218,61.0576 97.3328,61.0046 L97.3018,61.0046 C97.3018,61.0046 97.2888,60.9906 97.2808,60.9826 C94.6868,58.2026 92.4048,57.2216 90.3758,56.1906 C86.1208,54.0236 86.5218,55.8956 85.5308,45.3816 C85.2638,42.5476 84.7268,38.6816 82.2368,37.1996 C81.5838,36.8106 80.8708,36.6446 80.1298,36.6446 C79.3988,36.6446 79.0418,36.7936 78.8978,36.8256 C77.5338,37.1276 76.7578,37.9016 75.7858,38.7966 C71.1948,43.0306 67.5268,41.8816 62.0488,41.8326 C56.9048,41.7876 52.3628,45.3756 51.4948,50.8866 L51.4928,50.8896 C51.0708,53.7746 51.3448,56.7046 51.7958,58.0226 C51.7958,58.0226 50.4008,57.0936 49.7348,56.2716 C50.5398,61.3056 55.1328,64.5956 55.1328,64.5956 C54.4088,64.7616 53.3688,64.6926 53.3688,64.6926 C53.3728,64.6966 55.9898,66.7666 58.2618,67.4886 C57.6698,67.8566 54.6758,70.8106 53.1318,74.8776 C51.6878,78.6836 52.2758,83.2536 52.2758,83.2536 L53.5298,81.3826 C53.5298,81.3826 52.7108,85.5516 54.2968,89.5886 C54.8228,88.3886 55.9738,86.2446 55.9738,86.2446 C55.9738,86.2446 55.7908,90.7206 57.9458,94.3866 C58.0018,93.5406 58.3248,91.3866 58.3248,91.3866 C58.3248,91.3866 59.5628,95.2086 62.4188,97.8816 C67.7678,102.6276 81.9298,103.4856 92.7078,95.0156 C101.2448,88.3076 102.7358,80.2286 102.8788,79.9506 C104.9798,77.4306 104.4078,74.9486 101.6328,74.9486" id="Fill-48" fill="#FFFFFF"></path>
|
99 |
+
</g>
|
100 |
+
</g>
|
101 |
+
</svg>');
|
102 |
+
}
|
103 |
+
|
104 |
/**
|
105 |
* Add settings action link to the plugins page.
|
106 |
*
|
107 |
* @since 1.0.0
|
108 |
*/
|
109 |
public function add_action_links($links) {
|
|
|
|
|
|
|
110 |
$settings_link = array(
|
111 |
'<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_name ) . '">' . __('Settings', $this->plugin_name) . '</a>',
|
112 |
);
|
|
|
113 |
return array_merge($settings_link, $links);
|
114 |
}
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
/**
|
117 |
* Render the settings page for this plugin.
|
118 |
*
|
477 |
'mailchimp_auto_subscribe' => isset($input['mailchimp_auto_subscribe']) ? (bool) $input['mailchimp_auto_subscribe'] : $this->getOption('mailchimp_auto_subscribe', '0'),
|
478 |
'mailchimp_checkbox_defaults' => $checkbox,
|
479 |
'mailchimp_checkbox_action' => isset($input['mailchimp_checkbox_action']) ? $input['mailchimp_checkbox_action'] : $this->getOption('mailchimp_checkbox_action', 'woocommerce_after_checkout_billing_form'),
|
480 |
+
'mailchimp_product_image_key' => isset($input['mailchimp_product_image_key']) ? $input['mailchimp_product_image_key'] : 'medium',
|
481 |
);
|
482 |
|
483 |
if ($data['mailchimp_list'] === 'create_new') {
|
864 |
*/
|
865 |
private function startSync()
|
866 |
{
|
867 |
+
mailchimp_flush_sync_pointers();
|
868 |
+
|
869 |
$coupon_sync = new MailChimp_WooCommerce_Process_Coupons();
|
870 |
wp_queue($coupon_sync);
|
871 |
|
admin/partials/mailchimp-woocommerce-admin-tabs.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'api_key';
|
3 |
$is_mailchimp_post = isset($_POST['mailchimp_woocommerce_settings_hidden']) && $_POST['mailchimp_woocommerce_settings_hidden'] === 'Y';
|
4 |
|
5 |
-
$handler =
|
6 |
|
7 |
//Grab all options for this particular tab we're viewing.
|
8 |
$options = get_option($this->plugin_name, array());
|
@@ -100,7 +100,7 @@ if (isset($options['mailchimp_api_key']) && $handler->hasValidApiKey()) {
|
|
100 |
}
|
101 |
?>
|
102 |
|
103 |
-
<input type="hidden" name="<?php echo $this->plugin_name; ?>[mailchimp_active_tab]" value="<?php echo $active_tab; ?>"/>
|
104 |
|
105 |
<?php if ($active_tab == 'api_key' ): ?>
|
106 |
<?php include_once 'tabs/api_key.php'; ?>
|
2 |
$active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'api_key';
|
3 |
$is_mailchimp_post = isset($_POST['mailchimp_woocommerce_settings_hidden']) && $_POST['mailchimp_woocommerce_settings_hidden'] === 'Y';
|
4 |
|
5 |
+
$handler = MailChimp_WooCommerce_Admin::connect();
|
6 |
|
7 |
//Grab all options for this particular tab we're viewing.
|
8 |
$options = get_option($this->plugin_name, array());
|
100 |
}
|
101 |
?>
|
102 |
|
103 |
+
<input type="hidden" name="<?php echo $this->plugin_name; ?>[mailchimp_active_tab]" value="<?php echo esc_attr($active_tab); ?>"/>
|
104 |
|
105 |
<?php if ($active_tab == 'api_key' ): ?>
|
106 |
<?php include_once 'tabs/api_key.php'; ?>
|
admin/partials/tabs/campaign_defaults.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
$handler =
|
4 |
|
5 |
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
6 |
if (!$handler->hasValidApiKey()) {
|
@@ -9,7 +9,6 @@ if (!$handler->hasValidApiKey()) {
|
|
9 |
if (!$handler->hasValidStoreInfo()) {
|
10 |
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=store_info&error_notice=missing_store');
|
11 |
}
|
12 |
-
|
13 |
?>
|
14 |
|
15 |
<input type="hidden" name="mailchimp_active_settings_tab" value="campaign_defaults"/>
|
1 |
<?php
|
2 |
|
3 |
+
$handler = MailChimp_WooCommerce_Admin::connect();
|
4 |
|
5 |
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
6 |
if (!$handler->hasValidApiKey()) {
|
9 |
if (!$handler->hasValidStoreInfo()) {
|
10 |
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=store_info&error_notice=missing_store');
|
11 |
}
|
|
|
12 |
?>
|
13 |
|
14 |
<input type="hidden" name="mailchimp_active_settings_tab" value="campaign_defaults"/>
|
admin/partials/tabs/logs.php
CHANGED
File without changes
|
admin/partials/tabs/newsletter_settings.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
3 |
if (!$handler->hasValidApiKey()) {
|
4 |
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=api_key&error_notice=missing_api_key');
|
@@ -20,6 +21,7 @@ if (empty($mailchimp_lists) && !$handler->hasValidCampaignDefaults()) {
|
|
20 |
}
|
21 |
|
22 |
$list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mailchimp_list'])) && array_key_exists($options['mailchimp_list'], $mailchimp_lists);
|
|
|
23 |
?>
|
24 |
|
25 |
<?php if(($newsletter_settings_error = $this->getData('errors.mailchimp_list', false))) : ?>
|
@@ -126,3 +128,22 @@ $list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mai
|
|
126 |
</label>
|
127 |
</fieldset>
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
|
3 |
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
4 |
if (!$handler->hasValidApiKey()) {
|
5 |
wp_redirect('options-general.php?page=mailchimp-woocommerce&tab=api_key&error_notice=missing_api_key');
|
21 |
}
|
22 |
|
23 |
$list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mailchimp_list'])) && array_key_exists($options['mailchimp_list'], $mailchimp_lists);
|
24 |
+
|
25 |
?>
|
26 |
|
27 |
<?php if(($newsletter_settings_error = $this->getData('errors.mailchimp_list', false))) : ?>
|
128 |
</label>
|
129 |
</fieldset>
|
130 |
|
131 |
+
<h2 style="padding-top: 1em;">Product Image Size</h2>
|
132 |
+
<p>Define the product image size used by abandoned carts, order notifications, and product recommendations.</p>
|
133 |
+
|
134 |
+
<fieldset>
|
135 |
+
<legend class="screen-reader-text">
|
136 |
+
<span>Product Image Size</span>
|
137 |
+
</legend>
|
138 |
+
<label for="<?php echo $this->plugin_name; ?>-mailchimp-product_image_key">
|
139 |
+
<select name="<?php echo $this->plugin_name; ?>[mailchimp_product_image_key]" style="width:30%">
|
140 |
+
<?php
|
141 |
+
$enable_auto_subscribe = (array_key_exists('mailchimp_product_image_key', $options) && !is_null($options['mailchimp_product_image_key'])) ? $options['mailchimp_product_image_key'] : 'medium';
|
142 |
+
foreach (mailchimp_woocommerce_get_all_image_sizes_list() as $key => $value ) {
|
143 |
+
echo '<option value="' . esc_attr( $key ) . '" ' . selected($key == $enable_auto_subscribe, true, false ) . '>' . esc_html( $value ) . '</option>';
|
144 |
+
}
|
145 |
+
?>
|
146 |
+
</select>
|
147 |
+
<span><?php esc_attr_e('Select an image size', $this->plugin_name); ?></span>
|
148 |
+
</label>
|
149 |
+
</fieldset>
|
admin/partials/tabs/store_info.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
$handler =
|
4 |
|
5 |
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
6 |
if (!$handler->hasValidApiKey()) {
|
1 |
<?php
|
2 |
|
3 |
+
$handler = MailChimp_WooCommerce_Admin::connect();
|
4 |
|
5 |
// if we don't have valid campaign defaults we need to redirect back to the 'campaign_defaults' tab.
|
6 |
if (!$handler->hasValidApiKey()) {
|
bootstrap.php
ADDED
@@ -0,0 +1,668 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// If this file is called directly, abort.
|
4 |
+
if (!defined( 'WPINC')) {
|
5 |
+
die;
|
6 |
+
}
|
7 |
+
|
8 |
+
$mailchimp_woocommerce_spl_autoloader = true;
|
9 |
+
|
10 |
+
spl_autoload_register(function($class) {
|
11 |
+
$classes = array(
|
12 |
+
// includes root
|
13 |
+
'MailChimp_Service' => 'includes/class-mailchimp-woocommerce-service.php',
|
14 |
+
'MailChimp_WooCommerce_Options' => 'includes/class-mailchimp-woocommerce-options.php',
|
15 |
+
'MailChimp_Newsletter' => 'includes/class-mailchimp-woocommerce-newsletter.php',
|
16 |
+
'MailChimp_WooCommerce_Loader' => 'includes/class-mailchimp-woocommerce-loader.php',
|
17 |
+
'MailChimp_WooCommerce_i18n' => 'includes/class-mailchimp-woocommerce-i18n.php',
|
18 |
+
'MailChimp_WooCommerce_Deactivator' => 'includes/class-mailchimp-woocommerce-deactivator.php',
|
19 |
+
'MailChimp_WooCommerce_Activator' => 'includes/class-mailchimp-woocommerce-activator.php',
|
20 |
+
'MailChimp_WooCommerce' => 'includes/class-mailchimp-woocommerce.php',
|
21 |
+
|
22 |
+
// includes/api/assets
|
23 |
+
'MailChimp_WooCommerce_Address' => 'includes/api/assets/class-mailchimp-address.php',
|
24 |
+
'MailChimp_WooCommerce_Cart' => 'includes/api/assets/class-mailchimp-cart.php',
|
25 |
+
'MailChimp_WooCommerce_Customer' => 'includes/api/assets/class-mailchimp-customer.php',
|
26 |
+
'MailChimp_WooCommerce_LineItem' => 'includes/api/assets/class-mailchimp-line-item.php',
|
27 |
+
'MailChimp_WooCommerce_Order' => 'includes/api/assets/class-mailchimp-order.php',
|
28 |
+
'MailChimp_WooCommerce_Product' => 'includes/api/assets/class-mailchimp-product.php',
|
29 |
+
'MailChimp_WooCommerce_ProductVariation' => 'includes/api/assets/class-mailchimp-product-variation.php',
|
30 |
+
'MailChimp_WooCommerce_PromoCode' => 'includes/api/assets/class-mailchimp-promo-code.php',
|
31 |
+
'MailChimp_WooCommerce_PromoRule' => 'includes/api/assets/class-mailchimp-promo-rule.php',
|
32 |
+
'MailChimp_WooCommerce_Store' => 'includes/api/assets/class-mailchimp-store.php',
|
33 |
+
|
34 |
+
// includes/api/errors
|
35 |
+
'MailChimp_WooCommerce_Error' => 'includes/api/errors/class-mailchimp-error.php',
|
36 |
+
'MailChimp_WooCommerce_ServerError' => 'includes/api/errors/class-mailchimp-server-error.php',
|
37 |
+
|
38 |
+
// includes/api/helpers
|
39 |
+
'MailChimp_WooCommerce_CurrencyCodes' => 'includes/api/helpers/class-mailchimp-woocommerce-api-currency-codes.php',
|
40 |
+
'MailChimp_Api_Locales' => 'includes/api/helpers/class-mailchimp-woocommerce-api-locales.php',
|
41 |
+
|
42 |
+
// includes/api
|
43 |
+
'MailChimp_WooCommerce_MailChimpApi' => 'includes/api/class-mailchimp-api.php',
|
44 |
+
'MailChimp_WooCommerce_Api' => 'includes/api/class-mailchimp-woocommerce-api.php',
|
45 |
+
'MailChimp_WooCommerce_CreateListSubmission' => 'includes/api/class-mailchimp-woocommerce-create-list-submission.php',
|
46 |
+
'MailChimp_WooCommerce_Transform_Coupons' => 'includes/api/class-mailchimp-woocommerce-transform-coupons.php',
|
47 |
+
'MailChimp_WooCommerce_Transform_Orders' => 'includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php',
|
48 |
+
'MailChimp_WooCommerce_Transform_Products' => 'includes/api/class-mailchimp-woocommerce-transform-products.php',
|
49 |
+
|
50 |
+
// includes/processes
|
51 |
+
'MailChimp_WooCommerce_Abstract_Sync' => 'includes/processes/class-mailchimp-woocommerce-abstract-sync.php',
|
52 |
+
'MailChimp_WooCommerce_Cart_Update' => 'includes/processes/class-mailchimp-woocommerce-cart-update.php',
|
53 |
+
'MailChimp_WooCommerce_Process_Coupons' => 'includes/processes/class-mailchimp-woocommerce-process-coupons.php',
|
54 |
+
'MailChimp_WooCommerce_Process_Orders' => 'includes/processes/class-mailchimp-woocommerce-process-orders.php',
|
55 |
+
'MailChimp_WooCommerce_Process_Products' => 'includes/processes/class-mailchimp-woocommerce-process-products.php',
|
56 |
+
'MailChimp_WooCommerce_SingleCoupon' => 'includes/processes/class-mailchimp-woocommerce-single-coupon.php',
|
57 |
+
'MailChimp_WooCommerce_Single_Order' => 'includes/processes/class-mailchimp-woocommerce-single-order.php',
|
58 |
+
'MailChimp_WooCommerce_Single_Product' => 'includes/processes/class-mailchimp-woocommerce-single-product.php',
|
59 |
+
'MailChimp_WooCommerce_User_Submit' => 'includes/processes/class-mailchimp-woocommerce-user-submit.php',
|
60 |
+
|
61 |
+
'MailChimp_WooCommerce_Public' => 'public/class-mailchimp-woocommerce-public.php',
|
62 |
+
'MailChimp_WooCommerce_Admin' => 'admin/class-mailchimp-woocommerce-admin.php',
|
63 |
+
|
64 |
+
'WP_Job' => 'includes/vendor/queue/classes/wp-job.php',
|
65 |
+
'WP_Queue' => 'includes/vendor/queue/classes/wp-queue.php',
|
66 |
+
'WP_Http_Worker' => 'includes/vendor/queue/classes/worker/wp-http-worker.php',
|
67 |
+
'WP_Worker' => 'includes/vendor/queue/classes/worker/wp-worker.php',
|
68 |
+
'Queue_Command' => 'includes/vendor/queue/classes/cli-queue-command.php',
|
69 |
+
);
|
70 |
+
|
71 |
+
// if the file exists, require it
|
72 |
+
$path = plugin_dir_path( __FILE__ );
|
73 |
+
if (array_key_exists($class, $classes) && file_exists($path.$classes[$class])) {
|
74 |
+
require $path.$classes[$class];
|
75 |
+
}
|
76 |
+
});
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @return object
|
80 |
+
*/
|
81 |
+
function mailchimp_environment_variables() {
|
82 |
+
global $wp_version;
|
83 |
+
|
84 |
+
$o = get_option('mailchimp-woocommerce', false);
|
85 |
+
|
86 |
+
return (object) array(
|
87 |
+
'repo' => 'master',
|
88 |
+
'environment' => 'production',
|
89 |
+
'version' => '2.1.6',
|
90 |
+
'php_version' => phpversion(),
|
91 |
+
'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
|
92 |
+
'wc_version' => class_exists('WC') ? WC()->version : null,
|
93 |
+
'logging' => ($o && is_array($o) && isset($o['mailchimp_logging'])) ? $o['mailchimp_logging'] : 'standard',
|
94 |
+
);
|
95 |
+
}
|
96 |
+
|
97 |
+
// Add WP CLI commands
|
98 |
+
if (defined( 'WP_CLI' ) && WP_CLI) {
|
99 |
+
try {
|
100 |
+
/**
|
101 |
+
* Service push to MailChimp
|
102 |
+
*
|
103 |
+
* <type>
|
104 |
+
* : product_sync order_sync order product
|
105 |
+
*/
|
106 |
+
function mailchimp_cli_push_command( $args, $assoc_args ) {
|
107 |
+
if (is_array($args) && isset($args[0])) {
|
108 |
+
switch($args[0]) {
|
109 |
+
|
110 |
+
case 'product_sync':
|
111 |
+
wp_queue(new MailChimp_WooCommerce_Process_Products());
|
112 |
+
WP_CLI::success("queued up the product sync!");
|
113 |
+
break;
|
114 |
+
|
115 |
+
case 'order_sync':
|
116 |
+
wp_queue(new MailChimp_WooCommerce_Process_Orders());
|
117 |
+
WP_CLI::success("queued up the order sync!");
|
118 |
+
break;
|
119 |
+
|
120 |
+
case 'order':
|
121 |
+
if (!isset($args[1])) {
|
122 |
+
wp_die('You must specify an order id as the 2nd parameter.');
|
123 |
+
}
|
124 |
+
wp_queue(new MailChimp_WooCommerce_Single_Order($args[1]));
|
125 |
+
WP_CLI::success("queued up the order {$args[1]}!");
|
126 |
+
break;
|
127 |
+
|
128 |
+
case 'product':
|
129 |
+
if (!isset($args[1])) {
|
130 |
+
wp_die('You must specify a product id as the 2nd parameter.');
|
131 |
+
}
|
132 |
+
wp_queue(new MailChimp_WooCommerce_Single_Product($args[1]));
|
133 |
+
WP_CLI::success("queued up the product {$args[1]}!");
|
134 |
+
break;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
};
|
138 |
+
WP_CLI::add_command( 'mailchimp_push', 'mailchimp_cli_push_command');
|
139 |
+
WP_CLI::add_command( 'queue', 'Queue_Command' );
|
140 |
+
} catch (\Exception $e) {}
|
141 |
+
}
|
142 |
+
|
143 |
+
if (!function_exists( 'wp_queue')) {
|
144 |
+
/**
|
145 |
+
* WP queue.
|
146 |
+
*
|
147 |
+
* @param WP_Job $job
|
148 |
+
* @param int $delay
|
149 |
+
*/
|
150 |
+
function wp_queue( WP_Job $job, $delay = 0 ) {
|
151 |
+
global $wp_queue;
|
152 |
+
if (empty($wp_queue)) {
|
153 |
+
$wp_queue = new WP_Queue();
|
154 |
+
}
|
155 |
+
$wp_queue->push( $job, $delay );
|
156 |
+
do_action( 'wp_queue_job_pushed', $job );
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
|
161 |
+
/**
|
162 |
+
* @return bool
|
163 |
+
*/
|
164 |
+
function mailchimp_should_init_queue() {
|
165 |
+
return mailchimp_detect_admin_ajax() && mailchimp_is_configured() && !mailchimp_running_in_console() && !mailchimp_http_worker_is_running();
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* @return bool
|
170 |
+
*/
|
171 |
+
function mailchimp_is_configured() {
|
172 |
+
return (bool) (mailchimp_get_api_key() && mailchimp_get_list_id());
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* @return bool|int
|
177 |
+
*/
|
178 |
+
function mailchimp_get_api_key() {
|
179 |
+
return mailchimp_get_option('mailchimp_api_key', false);
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* @return bool|int
|
184 |
+
*/
|
185 |
+
function mailchimp_get_list_id() {
|
186 |
+
return mailchimp_get_option('mailchimp_list', false);
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* @return string
|
191 |
+
*/
|
192 |
+
function mailchimp_get_store_id() {
|
193 |
+
$store_id = mailchimp_get_data('store_id', false);
|
194 |
+
if (empty($store_id)) {
|
195 |
+
mailchimp_set_data('store_id', $store_id = uniqid(), 'yes');
|
196 |
+
}
|
197 |
+
return $store_id;
|
198 |
+
}
|
199 |
+
|
200 |
+
|
201 |
+
/**
|
202 |
+
* @return bool|MailChimp_WooCommerce_MailChimpApi
|
203 |
+
*/
|
204 |
+
function mailchimp_get_api() {
|
205 |
+
if (($key = mailchimp_get_api_key())) {
|
206 |
+
return new MailChimp_WooCommerce_MailChimpApi($key);
|
207 |
+
}
|
208 |
+
return false;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* @param $key
|
213 |
+
* @param null $default
|
214 |
+
* @return null
|
215 |
+
*/
|
216 |
+
function mailchimp_get_option($key, $default = null) {
|
217 |
+
$options = get_option('mailchimp-woocommerce');
|
218 |
+
if (!is_array($options)) {
|
219 |
+
return $default;
|
220 |
+
}
|
221 |
+
if (!array_key_exists($key, $options)) {
|
222 |
+
return $default;
|
223 |
+
}
|
224 |
+
return $options[$key];
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* @param $key
|
229 |
+
* @param null $default
|
230 |
+
* @return mixed
|
231 |
+
*/
|
232 |
+
function mailchimp_get_data($key, $default = null) {
|
233 |
+
return get_option('mailchimp-woocommerce-'.$key, $default);
|
234 |
+
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* @param $key
|
238 |
+
* @param $value
|
239 |
+
* @param string $autoload
|
240 |
+
* @return bool
|
241 |
+
*/
|
242 |
+
function mailchimp_set_data($key, $value, $autoload = 'yes') {
|
243 |
+
return update_option('mailchimp-woocommerce-'.$key, $value, $autoload);
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* @param $date
|
248 |
+
* @return DateTime
|
249 |
+
*/
|
250 |
+
function mailchimp_date_utc($date) {
|
251 |
+
$timezone = wc_timezone_string();
|
252 |
+
if (is_numeric($date)) {
|
253 |
+
$stamp = $date;
|
254 |
+
$date = new \DateTime('now', new DateTimeZone($timezone));
|
255 |
+
$date->setTimestamp($stamp);
|
256 |
+
} else {
|
257 |
+
$date = new \DateTime($date, new DateTimeZone($timezone));
|
258 |
+
}
|
259 |
+
|
260 |
+
$date->setTimezone(new DateTimeZone('UTC'));
|
261 |
+
return $date;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* @param $date
|
266 |
+
* @return DateTime
|
267 |
+
*/
|
268 |
+
function mailchimp_date_local($date) {
|
269 |
+
$timezone = mailchimp_get_option('store_timezone', 'America/New_York');
|
270 |
+
if (is_numeric($date)) {
|
271 |
+
$stamp = $date;
|
272 |
+
$date = new \DateTime('now', new DateTimeZone('UTC'));
|
273 |
+
$date->setTimestamp($stamp);
|
274 |
+
} else {
|
275 |
+
$date = new \DateTime($date, new DateTimeZone('UTC'));
|
276 |
+
}
|
277 |
+
|
278 |
+
$date->setTimezone(new DateTimeZone($timezone));
|
279 |
+
return $date;
|
280 |
+
}
|
281 |
+
|
282 |
+
/**
|
283 |
+
* @param array $data
|
284 |
+
* @return mixed
|
285 |
+
*/
|
286 |
+
function mailchimp_array_remove_empty($data) {
|
287 |
+
if (empty($data) || !is_array($data)) {
|
288 |
+
return array();
|
289 |
+
}
|
290 |
+
foreach ($data as $key => $value) {
|
291 |
+
if ($value === null || $value === '' || (is_array($value) && empty($value))) {
|
292 |
+
unset($data[$key]);
|
293 |
+
}
|
294 |
+
}
|
295 |
+
return $data;
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* @return array
|
300 |
+
*/
|
301 |
+
function mailchimp_get_timezone_list() {
|
302 |
+
$zones_array = array();
|
303 |
+
$timestamp = time();
|
304 |
+
$current = date_default_timezone_get();
|
305 |
+
|
306 |
+
foreach(timezone_identifiers_list() as $key => $zone) {
|
307 |
+
date_default_timezone_set($zone);
|
308 |
+
$zones_array[$key]['zone'] = $zone;
|
309 |
+
$zones_array[$key]['diff_from_GMT'] = 'UTC/GMT ' . date('P', $timestamp);
|
310 |
+
}
|
311 |
+
|
312 |
+
date_default_timezone_set($current);
|
313 |
+
|
314 |
+
return $zones_array;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* @return bool
|
319 |
+
*/
|
320 |
+
function mailchimp_check_woocommerce_plugin_status()
|
321 |
+
{
|
322 |
+
// if you are using a custom folder name other than woocommerce just define the constant to TRUE
|
323 |
+
if (defined("RUNNING_CUSTOM_WOOCOMMERCE") && RUNNING_CUSTOM_WOOCOMMERCE === true) {
|
324 |
+
return true;
|
325 |
+
}
|
326 |
+
// it the plugin is active, we're good.
|
327 |
+
if (in_array('woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option('active_plugins')))) {
|
328 |
+
return true;
|
329 |
+
}
|
330 |
+
// lets check for network activation woo installs now too.
|
331 |
+
if (function_exists('is_plugin_active_for_network')) {
|
332 |
+
return is_plugin_active_for_network( 'woocommerce/woocommerce.php');
|
333 |
+
}
|
334 |
+
return false;
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Get all the registered image sizes along with their dimensions
|
339 |
+
*
|
340 |
+
* @global array $_wp_additional_image_sizes
|
341 |
+
*
|
342 |
+
* @link http://core.trac.wordpress.org/ticket/18947 Reference ticket
|
343 |
+
*
|
344 |
+
* @return array $image_sizes The image sizes
|
345 |
+
*/
|
346 |
+
function mailchimp_woocommerce_get_all_image_sizes() {
|
347 |
+
global $_wp_additional_image_sizes;
|
348 |
+
$image_sizes = array();
|
349 |
+
$default_image_sizes = get_intermediate_image_sizes();
|
350 |
+
foreach ($default_image_sizes as $size) {
|
351 |
+
$image_sizes[$size]['width'] = intval( get_option("{$size}_size_w"));
|
352 |
+
$image_sizes[$size]['height'] = intval( get_option("{$size}_size_h"));
|
353 |
+
$image_sizes[$size]['crop'] = get_option("{$size}_crop") ? get_option("{$size}_crop") : false;
|
354 |
+
}
|
355 |
+
if (isset($_wp_additional_image_sizes) && count($_wp_additional_image_sizes)) {
|
356 |
+
$image_sizes = array_merge( $image_sizes, $_wp_additional_image_sizes );
|
357 |
+
}
|
358 |
+
return $image_sizes;
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* @return array
|
363 |
+
*/
|
364 |
+
function mailchimp_woocommerce_get_all_image_sizes_list() {
|
365 |
+
$response = array();
|
366 |
+
foreach (mailchimp_woocommerce_get_all_image_sizes() as $key => $data) {
|
367 |
+
$label = ucwords(str_replace('_', ' ', $key));
|
368 |
+
$response[$key] = "{$label} ({$data['width']} x {$data['height']})";
|
369 |
+
}
|
370 |
+
return $response;
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* The code that runs during plugin activation.
|
375 |
+
* This action is documented in includes/class-mailchimp-woocommerce-activator.php
|
376 |
+
*/
|
377 |
+
function activate_mailchimp_woocommerce() {
|
378 |
+
// if we don't have woocommerce we need to display a horrible error message before the plugin is installed.
|
379 |
+
if (!mailchimp_check_woocommerce_plugin_status()) {
|
380 |
+
// Deactivate the plugin
|
381 |
+
deactivate_plugins(__FILE__);
|
382 |
+
$error_message = __('The MailChimp For WooCommerce plugin requires the <a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a> plugin to be active!', 'woocommerce');
|
383 |
+
wp_die($error_message);
|
384 |
+
}
|
385 |
+
MailChimp_WooCommerce_Activator::activate();
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Create the queue tables
|
390 |
+
*/
|
391 |
+
function install_mailchimp_queue() {
|
392 |
+
MailChimp_WooCommerce_Activator::create_queue_tables();
|
393 |
+
}
|
394 |
+
|
395 |
+
/**
|
396 |
+
* The code that runs during plugin deactivation.
|
397 |
+
* This action is documented in includes/class-mailchimp-woocommerce-deactivator.php
|
398 |
+
*/
|
399 |
+
function deactivate_mailchimp_woocommerce() {
|
400 |
+
MailChimp_WooCommerce_Deactivator::deactivate();
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* @param $action
|
405 |
+
* @param $message
|
406 |
+
* @param null $data
|
407 |
+
*/
|
408 |
+
function mailchimp_debug($action, $message, $data = null) {
|
409 |
+
if (mailchimp_environment_variables()->logging === 'debug' && function_exists('wc_get_logger')) {
|
410 |
+
if (is_array($data) && !empty($data)) $message .= " :: ".wc_print_r($data, true);
|
411 |
+
wc_get_logger()->debug("{$action} :: {$message}", array('source' => 'mailchimp_woocommerce'));
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* @param $action
|
417 |
+
* @param $message
|
418 |
+
* @param array $data
|
419 |
+
* @return array|WP_Error
|
420 |
+
*/
|
421 |
+
function mailchimp_log($action, $message, $data = array()) {
|
422 |
+
if (mailchimp_environment_variables()->logging !== 'none' && function_exists('wc_get_logger')) {
|
423 |
+
if (is_array($data) && !empty($data)) $message .= " :: ".wc_print_r($data, true);
|
424 |
+
wc_get_logger()->notice("{$action} :: {$message}", array('source' => 'mailchimp_woocommerce'));
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
/**
|
429 |
+
* @param $action
|
430 |
+
* @param $message
|
431 |
+
* @param array $data
|
432 |
+
* @return array|WP_Error
|
433 |
+
*/
|
434 |
+
function mailchimp_error($action, $message, $data = array()) {
|
435 |
+
if (mailchimp_environment_variables()->logging !== 'none' && function_exists('wc_get_logger')) {
|
436 |
+
if ($message instanceof \Exception) $message = mailchimp_error_trace($message);
|
437 |
+
if (is_array($data) && !empty($data)) $message .= " :: ".wc_print_r($data, true);
|
438 |
+
wc_get_logger()->error("{$action} :: {$message}", array('source' => 'mailchimp_woocommerce'));
|
439 |
+
}
|
440 |
+
}
|
441 |
+
|
442 |
+
/**
|
443 |
+
* @param Exception $e
|
444 |
+
* @param string $wrap
|
445 |
+
* @return string
|
446 |
+
*/
|
447 |
+
function mailchimp_error_trace(\Exception $e, $wrap = "") {
|
448 |
+
$error = "{$e->getMessage()} on {$e->getLine()} in {$e->getFile()}";
|
449 |
+
if (empty($wrap)) return $error;
|
450 |
+
return "{$wrap} :: {$error}";
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
* Determine if a given string contains a given substring.
|
455 |
+
*
|
456 |
+
* @param string $haystack
|
457 |
+
* @param string|array $needles
|
458 |
+
* @return bool
|
459 |
+
*/
|
460 |
+
function mailchimp_string_contains($haystack, $needles) {
|
461 |
+
foreach ((array) $needles as $needle) {
|
462 |
+
if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
|
463 |
+
return true;
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
return false;
|
468 |
+
}
|
469 |
+
|
470 |
+
|
471 |
+
/**
|
472 |
+
* @return int
|
473 |
+
*/
|
474 |
+
function mailchimp_get_product_count() {
|
475 |
+
$posts = mailchimp_count_posts('product');
|
476 |
+
unset($posts['auto-draft'], $posts['trash']);
|
477 |
+
$total = 0;
|
478 |
+
foreach ($posts as $status => $count) {
|
479 |
+
$total += $count;
|
480 |
+
}
|
481 |
+
return $total;
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* @return int
|
486 |
+
*/
|
487 |
+
function mailchimp_get_order_count() {
|
488 |
+
$posts = mailchimp_count_posts('shop_order');
|
489 |
+
unset($posts['auto-draft'], $posts['trash']);
|
490 |
+
$total = 0;
|
491 |
+
foreach ($posts as $status => $count) {
|
492 |
+
$total += $count;
|
493 |
+
}
|
494 |
+
return $total;
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* @param $type
|
499 |
+
* @return array|null|object
|
500 |
+
*/
|
501 |
+
function mailchimp_count_posts($type) {
|
502 |
+
global $wpdb;
|
503 |
+
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s GROUP BY post_status";
|
504 |
+
$posts = $wpdb->get_results( $wpdb->prepare($query, $type));
|
505 |
+
$response = array();
|
506 |
+
foreach ($posts as $post) {
|
507 |
+
$response[$post->post_status] = $post->num_posts;
|
508 |
+
}
|
509 |
+
return $response;
|
510 |
+
}
|
511 |
+
|
512 |
+
/**
|
513 |
+
* @return bool
|
514 |
+
*/
|
515 |
+
function mailchimp_update_connected_site_script() {
|
516 |
+
// pull the store ID
|
517 |
+
$store_id = mailchimp_get_store_id();
|
518 |
+
|
519 |
+
// if the api is configured
|
520 |
+
if ($store_id && ($api = mailchimp_get_api())) {
|
521 |
+
|
522 |
+
// if we have a store
|
523 |
+
if (($store = $api->getStore($store_id))) {
|
524 |
+
|
525 |
+
// handle the coupon sync if we don't have a flag that says otherwise.
|
526 |
+
$job = new MailChimp_WooCommerce_Process_Coupons();
|
527 |
+
if ($job->getData('sync.coupons.completed_at', false) === false) {
|
528 |
+
wp_queue($job);
|
529 |
+
}
|
530 |
+
|
531 |
+
// see if we have a connected site script url/fragment
|
532 |
+
$url = $store->getConnectedSiteScriptUrl();
|
533 |
+
$fragment = $store->getConnectedSiteScriptFragment();
|
534 |
+
|
535 |
+
// if it's not empty we need to set the values
|
536 |
+
if ($url && $fragment) {
|
537 |
+
|
538 |
+
// update the options for script_url and script_fragment
|
539 |
+
update_option('mailchimp-woocommerce-script_url', $url);
|
540 |
+
update_option('mailchimp-woocommerce-script_fragment', $fragment);
|
541 |
+
|
542 |
+
// check to see if the site is connected
|
543 |
+
if (!$api->checkConnectedSite($store_id)) {
|
544 |
+
|
545 |
+
// if it's not, connect it now.
|
546 |
+
$api->connectSite($store_id);
|
547 |
+
}
|
548 |
+
|
549 |
+
return true;
|
550 |
+
}
|
551 |
+
}
|
552 |
+
}
|
553 |
+
return false;
|
554 |
+
}
|
555 |
+
|
556 |
+
/**
|
557 |
+
* @return bool
|
558 |
+
*/
|
559 |
+
function mailchimp_detect_admin_ajax() {
|
560 |
+
if (defined('DOING_CRON') && DOING_CRON) return true;
|
561 |
+
if (!is_admin()) return false;
|
562 |
+
if (!defined('DOING_AJAX')) return false;
|
563 |
+
return DOING_AJAX;
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* @return string|false
|
568 |
+
*/
|
569 |
+
function mailchimp_get_connected_site_script_url() {
|
570 |
+
return get_option('mailchimp-woocommerce-script_url', false);
|
571 |
+
}
|
572 |
+
|
573 |
+
/**
|
574 |
+
* @return string|false
|
575 |
+
*/
|
576 |
+
function mailchimp_get_connected_site_script_fragment() {
|
577 |
+
return get_option('mailchimp-woocommerce-script_fragment', false);
|
578 |
+
}
|
579 |
+
|
580 |
+
/**
|
581 |
+
* @return bool
|
582 |
+
*/
|
583 |
+
function mailchimp_running_in_console() {
|
584 |
+
return (bool) (defined( 'DISABLE_WP_HTTP_WORKER' ) && true === DISABLE_WP_HTTP_WORKER);
|
585 |
+
}
|
586 |
+
|
587 |
+
/**
|
588 |
+
* @return bool
|
589 |
+
*/
|
590 |
+
function mailchimp_http_worker_is_running() {
|
591 |
+
return (bool) get_site_transient('http_worker_lock');
|
592 |
+
}
|
593 |
+
|
594 |
+
/**
|
595 |
+
* @return array|WP_Error
|
596 |
+
*/
|
597 |
+
function mailchimp_call_http_worker_manually() {
|
598 |
+
$action = 'http_worker';
|
599 |
+
$query_args = apply_filters('http_worker_query_args', array(
|
600 |
+
'action' => $action,
|
601 |
+
'nonce' => wp_create_nonce($action),
|
602 |
+
));
|
603 |
+
$query_url = apply_filters('http_worker_query_url', admin_url('admin-ajax.php'));
|
604 |
+
$post_args = apply_filters('http_worker_post_args', array(
|
605 |
+
'timeout' => 0.01,
|
606 |
+
'blocking' => false,
|
607 |
+
'cookies' => $_COOKIE,
|
608 |
+
'sslverify' => apply_filters('https_local_ssl_verify', false),
|
609 |
+
));
|
610 |
+
$url = add_query_arg($query_args, $query_url);
|
611 |
+
return wp_remote_post(esc_url_raw($url), $post_args);
|
612 |
+
}
|
613 |
+
|
614 |
+
function mailchimp_flush_queue_tables() {
|
615 |
+
try {
|
616 |
+
/** @var \ */
|
617 |
+
global $wpdb;
|
618 |
+
$wpdb->query($wpdb->prepare("TRUNCATE `{$wpdb->prefix}queue`", array()));
|
619 |
+
$wpdb->query($wpdb->prepare("TRUNCATE `{$wpdb->prefix}failed_jobs`", array()));
|
620 |
+
$wpdb->query($wpdb->prepare("TRUNCATE `{$wpdb->prefix}mailchimp_carts`", array()));
|
621 |
+
} catch (\Exception $e) {}
|
622 |
+
}
|
623 |
+
|
624 |
+
function mailchimp_flush_sync_pointers() {
|
625 |
+
// clean up the initial sync pointers
|
626 |
+
foreach (array('orders', 'products', 'coupons') as $resource_type) {
|
627 |
+
delete_option("mailchimp-woocommerce-sync.{$resource_type}.started_at");
|
628 |
+
delete_option("mailchimp-woocommerce-sync.{$resource_type}.completed_at");
|
629 |
+
delete_option("mailchimp-woocommerce-sync.{$resource_type}.current_page");
|
630 |
+
}
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* To be used when running clean up for uninstalls or re-installs.
|
635 |
+
*/
|
636 |
+
function mailchimp_clean_database() {
|
637 |
+
mailchimp_flush_queue_tables();
|
638 |
+
|
639 |
+
// clean up the initial sync pointers
|
640 |
+
mailchimp_flush_sync_pointers();
|
641 |
+
|
642 |
+
delete_option('mailchimp-woocommerce');
|
643 |
+
delete_option('mailchimp-woocommerce-store_id');
|
644 |
+
delete_option('mailchimp-woocommerce-sync.syncing');
|
645 |
+
delete_option('mailchimp-woocommerce-sync.started_at');
|
646 |
+
delete_option('mailchimp-woocommerce-sync.completed_at');
|
647 |
+
delete_option('mailchimp-woocommerce-validation.api.ping');
|
648 |
+
delete_option('mailchimp-woocommerce-cached-api-lists');
|
649 |
+
delete_option('mailchimp-woocommerce-cached-api-ping-check');
|
650 |
+
delete_option('mailchimp-woocommerce-errors.store_info');
|
651 |
+
}
|
652 |
+
|
653 |
+
function run_mailchimp_woocommerce() {
|
654 |
+
$env = mailchimp_environment_variables();
|
655 |
+
$plugin = new MailChimp_WooCommerce($env->environment, $env->version);
|
656 |
+
$plugin->run();
|
657 |
+
}
|
658 |
+
|
659 |
+
function mailchimp_woocommerce_add_meta_tags() {
|
660 |
+
echo '<meta name="referrer" content="always"/>';
|
661 |
+
}
|
662 |
+
|
663 |
+
function mailchimp_on_all_plugins_loaded() {
|
664 |
+
if (mailchimp_check_woocommerce_plugin_status()) {
|
665 |
+
add_action('wp_head', 'mailchimp_woocommerce_add_meta_tags');
|
666 |
+
run_mailchimp_woocommerce();
|
667 |
+
}
|
668 |
+
}
|
includes/api/assets/class-mailchimp-address.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:22 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:22 PM
|
10 |
*/
|
includes/api/assets/class-mailchimp-cart.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/15/16
|
9 |
* Time: 1:26 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/15/16
|
9 |
* Time: 1:26 PM
|
10 |
*/
|
includes/api/assets/class-mailchimp-customer.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:16 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:16 PM
|
10 |
*/
|
includes/api/assets/class-mailchimp-line-item.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:16 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:16 PM
|
10 |
*/
|
includes/api/assets/class-mailchimp-order.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:16 PM
|
10 |
*/
|
@@ -29,7 +29,7 @@ class MailChimp_WooCommerce_Order
|
|
29 |
protected $billing_address = null;
|
30 |
protected $lines = array();
|
31 |
protected $confirm_and_paid = false;
|
32 |
-
protected $promos =
|
33 |
protected $is_amazon_order = false;
|
34 |
|
35 |
/**
|
@@ -152,11 +152,11 @@ class MailChimp_WooCommerce_Order
|
|
152 |
*/
|
153 |
public function addDiscount($code, $amount, $is_percentage = false)
|
154 |
{
|
155 |
-
$this->promos[] =
|
156 |
'code' => $code,
|
157 |
'amount_discounted' => $amount,
|
158 |
'type' => $is_percentage ? 'percent' : 'fixed'
|
159 |
-
|
160 |
|
161 |
return $this;
|
162 |
}
|
@@ -278,7 +278,9 @@ class MailChimp_WooCommerce_Order
|
|
278 |
*/
|
279 |
public function setOrderURL($url)
|
280 |
{
|
281 |
-
$
|
|
|
|
|
282 |
|
283 |
return $this;
|
284 |
}
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:16 PM
|
10 |
*/
|
29 |
protected $billing_address = null;
|
30 |
protected $lines = array();
|
31 |
protected $confirm_and_paid = false;
|
32 |
+
protected $promos = array();
|
33 |
protected $is_amazon_order = false;
|
34 |
|
35 |
/**
|
152 |
*/
|
153 |
public function addDiscount($code, $amount, $is_percentage = false)
|
154 |
{
|
155 |
+
$this->promos[] = array(
|
156 |
'code' => $code,
|
157 |
'amount_discounted' => $amount,
|
158 |
'type' => $is_percentage ? 'percent' : 'fixed'
|
159 |
+
);
|
160 |
|
161 |
return $this;
|
162 |
}
|
278 |
*/
|
279 |
public function setOrderURL($url)
|
280 |
{
|
281 |
+
if (($url = wp_http_validate_url($url))) {
|
282 |
+
$this->order_url = $url;
|
283 |
+
}
|
284 |
|
285 |
return $this;
|
286 |
}
|
includes/api/assets/class-mailchimp-product-variation.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:17 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:17 PM
|
10 |
*/
|
includes/api/assets/class-mailchimp-product.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:17 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 3/8/16
|
9 |
* Time: 2:17 PM
|
10 |
*/
|
includes/api/assets/class-mailchimp-promo-code.php
CHANGED
File without changes
|
includes/api/assets/class-mailchimp-promo-rule.php
CHANGED
File without changes
|
includes/api/assets/class-mailchimp-store.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 3/8/16
|
9 |
* Time: 3:13 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 3/8/16
|
9 |
* Time: 3:13 PM
|
10 |
*/
|
includes/api/class-mailchimp-api.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by PhpStorm.
|
5 |
*
|
6 |
* User: kingpin
|
7 |
-
* Email: ryan@
|
8 |
* Date: 11/4/15
|
9 |
* Time: 3:35 PM
|
10 |
*/
|
4 |
* Created by PhpStorm.
|
5 |
*
|
6 |
* User: kingpin
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 11/4/15
|
9 |
* Time: 3:35 PM
|
10 |
*/
|
includes/api/class-mailchimp-woocommerce-api.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/13/16
|
9 |
* Time: 2:32 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/13/16
|
9 |
* Time: 2:32 PM
|
10 |
*/
|
includes/api/class-mailchimp-woocommerce-create-list-submission.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/8/16
|
9 |
* Time: 4:16 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/8/16
|
9 |
* Time: 4:16 PM
|
10 |
*/
|
includes/api/class-mailchimp-woocommerce-transform-coupons.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 10/06/17
|
9 |
* Time: 8:29 AM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 10/06/17
|
9 |
* Time: 8:29 AM
|
10 |
*/
|
includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/13/16
|
9 |
* Time: 8:29 AM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/13/16
|
9 |
* Time: 8:29 AM
|
10 |
*/
|
includes/api/class-mailchimp-woocommerce-transform-products.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/13/16
|
9 |
* Time: 8:29 AM
|
10 |
*/
|
@@ -44,7 +44,9 @@ class MailChimp_WooCommerce_Transform_Products
|
|
44 |
*/
|
45 |
public function transform(WP_Post $post)
|
46 |
{
|
47 |
-
$woo = wc_get_product($post)
|
|
|
|
|
48 |
|
49 |
$variant_posts = $this->getProductVariantPosts($post->ID);
|
50 |
|
@@ -225,8 +227,7 @@ class MailChimp_WooCommerce_Transform_Products
|
|
225 |
*/
|
226 |
public function getProductImageKey()
|
227 |
{
|
228 |
-
|
229 |
-
return 'post-thumbnail';
|
230 |
}
|
231 |
|
232 |
/**
|
@@ -256,4 +257,27 @@ class MailChimp_WooCommerce_Transform_Products
|
|
256 |
|
257 |
return $product;
|
258 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
}
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/13/16
|
9 |
* Time: 8:29 AM
|
10 |
*/
|
44 |
*/
|
45 |
public function transform(WP_Post $post)
|
46 |
{
|
47 |
+
if (!($woo = wc_get_product($post))) {
|
48 |
+
return $this->wooProductNotLoadedCorrectly($post);
|
49 |
+
}
|
50 |
|
51 |
$variant_posts = $this->getProductVariantPosts($post->ID);
|
52 |
|
227 |
*/
|
228 |
public function getProductImageKey()
|
229 |
{
|
230 |
+
return mailchimp_get_option('mailchimp_product_image_key', 'medium');
|
|
|
231 |
}
|
232 |
|
233 |
/**
|
257 |
|
258 |
return $product;
|
259 |
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* @param \WP_Post $post
|
263 |
+
* @return MailChimp_WooCommerce_Product
|
264 |
+
*/
|
265 |
+
protected function wooProductNotLoadedCorrectly($post)
|
266 |
+
{
|
267 |
+
$product = new MailChimp_WooCommerce_Product();
|
268 |
+
$product->setId($post->ID);
|
269 |
+
$product->setHandle($post->post_name);
|
270 |
+
$product->setDescription($post->post_content);
|
271 |
+
$product->setImageUrl($this->getProductImage($post));
|
272 |
+
|
273 |
+
$variant = $this->variant(false, $post, $post->post_name);
|
274 |
+
|
275 |
+
if (!$variant->getImageUrl()) {
|
276 |
+
$variant->setImageUrl($product->getImageUrl());
|
277 |
+
}
|
278 |
+
|
279 |
+
$product->addVariant($variant);
|
280 |
+
|
281 |
+
return $product;
|
282 |
+
}
|
283 |
}
|
includes/api/errors/class-mailchimp-error.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by PhpStorm.
|
5 |
*
|
6 |
* User: kingpin
|
7 |
-
* Email: ryan@
|
8 |
* Date: 6/18/15
|
9 |
* Time: 11:13 AM
|
10 |
*/
|
4 |
* Created by PhpStorm.
|
5 |
*
|
6 |
* User: kingpin
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 6/18/15
|
9 |
* Time: 11:13 AM
|
10 |
*/
|
includes/api/errors/class-mailchimp-server-error.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by PhpStorm.
|
5 |
*
|
6 |
* User: kingpin
|
7 |
-
* Email: ryan@
|
8 |
* Date: 6/18/15
|
9 |
* Time: 11:13 AM
|
10 |
*/
|
4 |
* Created by PhpStorm.
|
5 |
*
|
6 |
* User: kingpin
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 6/18/15
|
9 |
* Time: 11:13 AM
|
10 |
*/
|
includes/api/helpers/class-mailchimp-woocommerce-api-currency-codes.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/12/16
|
9 |
* Time: 1:38 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/12/16
|
9 |
* Time: 1:38 PM
|
10 |
*/
|
includes/api/helpers/class-mailchimp-woocommerce-api-locales.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/12/16
|
9 |
* Time: 2:07 PM
|
10 |
*/
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/12/16
|
9 |
* Time: 2:07 PM
|
10 |
*/
|
includes/class-mailchimp-woocommerce-activator.php
CHANGED
@@ -5,11 +5,11 @@
|
|
5 |
* This class defines all code necessary to run during the plugin's activation.
|
6 |
*
|
7 |
* @since 1.0.1
|
8 |
-
* @package
|
9 |
-
* @subpackage
|
10 |
-
* @author Ryan Hungate <ryan@
|
11 |
*/
|
12 |
-
class
|
13 |
|
14 |
/**
|
15 |
* Short Description. (use period)
|
@@ -20,11 +20,6 @@ class MailChimp_Woocommerce_Activator {
|
|
20 |
*/
|
21 |
public static function activate() {
|
22 |
|
23 |
-
// only do this if the option has never been set before.
|
24 |
-
if (get_option('mailchimp_woocommerce_plugin_do_activation_redirect', null) === null) {
|
25 |
-
add_option('mailchimp_woocommerce_plugin_do_activation_redirect', true);
|
26 |
-
}
|
27 |
-
|
28 |
// create the queue tables because we need them for the sync jobs.
|
29 |
static::create_queue_tables();
|
30 |
|
@@ -33,7 +28,12 @@ class MailChimp_Woocommerce_Activator {
|
|
33 |
|
34 |
// if we haven't saved options previously, we will need to create the site id and update base options
|
35 |
if (empty($saved_options)) {
|
|
|
36 |
update_option('mailchimp-woocommerce', array());
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
// if we haven't saved the store id yet.
|
5 |
* This class defines all code necessary to run during the plugin's activation.
|
6 |
*
|
7 |
* @since 1.0.1
|
8 |
+
* @package MailChimp_WooCommerce
|
9 |
+
* @subpackage MailChimp_WooCommerce/includes
|
10 |
+
* @author Ryan Hungate <ryan@vextras.com>
|
11 |
*/
|
12 |
+
class MailChimp_WooCommerce_Activator {
|
13 |
|
14 |
/**
|
15 |
* Short Description. (use period)
|
20 |
*/
|
21 |
public static function activate() {
|
22 |
|
|
|
|
|
|
|
|
|
|
|
23 |
// create the queue tables because we need them for the sync jobs.
|
24 |
static::create_queue_tables();
|
25 |
|
28 |
|
29 |
// if we haven't saved options previously, we will need to create the site id and update base options
|
30 |
if (empty($saved_options)) {
|
31 |
+
mailchimp_clean_database();
|
32 |
update_option('mailchimp-woocommerce', array());
|
33 |
+
// only do this if the option has never been set before.
|
34 |
+
if (!is_multisite()) {
|
35 |
+
add_option('mailchimp_woocommerce_plugin_do_activation_redirect', true);
|
36 |
+
}
|
37 |
}
|
38 |
|
39 |
// if we haven't saved the store id yet.
|
includes/class-mailchimp-woocommerce-deactivator.php
CHANGED
@@ -6,8 +6,8 @@
|
|
6 |
* @link https://mailchimp.com
|
7 |
* @since 1.0.1
|
8 |
*
|
9 |
-
* @package
|
10 |
-
* @subpackage
|
11 |
*/
|
12 |
|
13 |
/**
|
@@ -16,11 +16,11 @@
|
|
16 |
* This class defines all code necessary to run during the plugin's deactivation.
|
17 |
*
|
18 |
* @since 1.0.1
|
19 |
-
* @package
|
20 |
-
* @subpackage
|
21 |
-
* @author Ryan Hungate <ryan@
|
22 |
*/
|
23 |
-
class
|
24 |
|
25 |
/**
|
26 |
* Short Description. (use period)
|
6 |
* @link https://mailchimp.com
|
7 |
* @since 1.0.1
|
8 |
*
|
9 |
+
* @package MailChimp_WooCommerce
|
10 |
+
* @subpackage MailChimp_WooCommerce/includes
|
11 |
*/
|
12 |
|
13 |
/**
|
16 |
* This class defines all code necessary to run during the plugin's deactivation.
|
17 |
*
|
18 |
* @since 1.0.1
|
19 |
+
* @package MailChimp_WooCommerce
|
20 |
+
* @subpackage MailChimp_WooCommerce/includes
|
21 |
+
* @author Ryan Hungate <ryan@vextras.com>
|
22 |
*/
|
23 |
+
class MailChimp_WooCommerce_Deactivator {
|
24 |
|
25 |
/**
|
26 |
* Short Description. (use period)
|
includes/class-mailchimp-woocommerce-i18n.php
CHANGED
@@ -9,8 +9,8 @@
|
|
9 |
* @link https://mailchimp.com
|
10 |
* @since 1.0.1
|
11 |
*
|
12 |
-
* @package
|
13 |
-
* @subpackage
|
14 |
*/
|
15 |
|
16 |
/**
|
@@ -20,11 +20,11 @@
|
|
20 |
* so that it is ready for translation.
|
21 |
*
|
22 |
* @since 1.0.1
|
23 |
-
* @package
|
24 |
-
* @subpackage
|
25 |
-
* @author Ryan Hungate <ryan@
|
26 |
*/
|
27 |
-
class
|
28 |
|
29 |
|
30 |
/**
|
9 |
* @link https://mailchimp.com
|
10 |
* @since 1.0.1
|
11 |
*
|
12 |
+
* @package MailChimp_WooCommerce
|
13 |
+
* @subpackage MailChimp_WooCommerce/includes
|
14 |
*/
|
15 |
|
16 |
/**
|
20 |
* so that it is ready for translation.
|
21 |
*
|
22 |
* @since 1.0.1
|
23 |
+
* @package MailChimp_WooCommerce
|
24 |
+
* @subpackage MailChimp_WooCommerce/includes
|
25 |
+
* @author Ryan Hungate <ryan@vextras.com>
|
26 |
*/
|
27 |
+
class MailChimp_WooCommerce_i18n {
|
28 |
|
29 |
|
30 |
/**
|
includes/class-mailchimp-woocommerce-loader.php
CHANGED
@@ -6,8 +6,8 @@
|
|
6 |
* @link https://mailchimp.com
|
7 |
* @since 1.0.1
|
8 |
*
|
9 |
-
* @package
|
10 |
-
* @subpackage
|
11 |
*/
|
12 |
|
13 |
/**
|
@@ -17,11 +17,11 @@
|
|
17 |
* the plugin, and register them with the WordPress API. Call the
|
18 |
* run function to execute the list of actions and filters.
|
19 |
*
|
20 |
-
* @package
|
21 |
-
* @subpackage
|
22 |
-
* @author Ryan Hungate <ryan@
|
23 |
*/
|
24 |
-
class
|
25 |
|
26 |
/**
|
27 |
* The array of actions registered with WordPress.
|
6 |
* @link https://mailchimp.com
|
7 |
* @since 1.0.1
|
8 |
*
|
9 |
+
* @package MailChimp_WooCommerce
|
10 |
+
* @subpackage MailChimp_WooCommerce/includes
|
11 |
*/
|
12 |
|
13 |
/**
|
17 |
* the plugin, and register them with the WordPress API. Call the
|
18 |
* run function to execute the list of actions and filters.
|
19 |
*
|
20 |
+
* @package MailChimp_WooCommerce
|
21 |
+
* @subpackage MailChimp_WooCommerce/includes
|
22 |
+
* @author Ryan Hungate <ryan@vextras.com>
|
23 |
*/
|
24 |
+
class MailChimp_WooCommerce_Loader {
|
25 |
|
26 |
/**
|
27 |
* The array of actions registered with WordPress.
|
includes/class-mailchimp-woocommerce-newsletter.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Created by MailChimp.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 2/22/16
|
9 |
* Time: 9:09 AM
|
10 |
*/
|
11 |
-
class MailChimp_Newsletter extends
|
12 |
{
|
13 |
/**
|
14 |
* @param WC_Checkout $checkout
|
@@ -27,16 +27,19 @@ class MailChimp_Newsletter extends MailChimp_Woocommerce_Options
|
|
27 |
|
28 |
// if the user chose 'check' or nothing at all, we default to true.
|
29 |
$default_checked = $default_setting === 'check';
|
|
|
30 |
|
31 |
// if the user is logged in, we will pull the 'is_subscribed' property out of the meta for the value.
|
32 |
// otherwise we use the default settings.
|
33 |
if (is_user_logged_in()) {
|
34 |
$status = get_user_meta(get_current_user_id(), 'mailchimp_woocommerce_is_subscribed', true);
|
|
|
|
|
|
|
|
|
35 |
if ($status === '' || $status === null) {
|
36 |
$status = $default_checked;
|
37 |
}
|
38 |
-
} else {
|
39 |
-
$status = $default_checked;
|
40 |
}
|
41 |
|
42 |
// echo out the checkbox.
|
@@ -98,7 +101,7 @@ class MailChimp_Newsletter extends MailChimp_Woocommerce_Options
|
|
98 |
|
99 |
if (is_user_logged_in()) {
|
100 |
update_user_meta(get_current_user_id(), 'mailchimp_woocommerce_is_subscribed', $status);
|
101 |
-
|
102 |
return $status;
|
103 |
}
|
104 |
|
4 |
* Created by MailChimp.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 2/22/16
|
9 |
* Time: 9:09 AM
|
10 |
*/
|
11 |
+
class MailChimp_Newsletter extends MailChimp_WooCommerce_Options
|
12 |
{
|
13 |
/**
|
14 |
* @param WC_Checkout $checkout
|
27 |
|
28 |
// if the user chose 'check' or nothing at all, we default to true.
|
29 |
$default_checked = $default_setting === 'check';
|
30 |
+
$status = $default_checked;
|
31 |
|
32 |
// if the user is logged in, we will pull the 'is_subscribed' property out of the meta for the value.
|
33 |
// otherwise we use the default settings.
|
34 |
if (is_user_logged_in()) {
|
35 |
$status = get_user_meta(get_current_user_id(), 'mailchimp_woocommerce_is_subscribed', true);
|
36 |
+
/// if the user is logged in - and is already subscribed - just ignore this checkbox.
|
37 |
+
if ((bool) $status) {
|
38 |
+
return;
|
39 |
+
}
|
40 |
if ($status === '' || $status === null) {
|
41 |
$status = $default_checked;
|
42 |
}
|
|
|
|
|
43 |
}
|
44 |
|
45 |
// echo out the checkbox.
|
101 |
|
102 |
if (is_user_logged_in()) {
|
103 |
update_user_meta(get_current_user_id(), 'mailchimp_woocommerce_is_subscribed', $status);
|
104 |
+
|
105 |
return $status;
|
106 |
}
|
107 |
|
includes/class-mailchimp-woocommerce-options.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Created by MailChimp.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 2/22/16
|
9 |
* Time: 3:45 PM
|
10 |
*/
|
11 |
-
abstract class
|
12 |
{
|
13 |
/**
|
14 |
* @var MailChimp_WooCommerce_MailChimpApi
|
@@ -223,6 +223,14 @@ abstract class MailChimp_Woocommerce_Options
|
|
223 |
//return $this->getOption('public_key', false) && $this->getOption('secret_key', false);
|
224 |
}
|
225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
/**
|
227 |
* @return MailChimp_WooCommerce_MailChimpApi
|
228 |
*/
|
4 |
* Created by MailChimp.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 2/22/16
|
9 |
* Time: 3:45 PM
|
10 |
*/
|
11 |
+
abstract class MailChimp_WooCommerce_Options
|
12 |
{
|
13 |
/**
|
14 |
* @var MailChimp_WooCommerce_MailChimpApi
|
223 |
//return $this->getOption('public_key', false) && $this->getOption('secret_key', false);
|
224 |
}
|
225 |
|
226 |
+
/**
|
227 |
+
* @return bool
|
228 |
+
*/
|
229 |
+
protected function doingAjax()
|
230 |
+
{
|
231 |
+
return defined('DOING_AJAX') && DOING_AJAX;
|
232 |
+
}
|
233 |
+
|
234 |
/**
|
235 |
* @return MailChimp_WooCommerce_MailChimpApi
|
236 |
*/
|
includes/class-mailchimp-woocommerce-service.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Created by MailChimp.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 2/17/16
|
9 |
* Time: 12:03 PM
|
10 |
*/
|
11 |
-
class MailChimp_Service extends
|
12 |
{
|
13 |
protected static $pushed_orders = array();
|
14 |
|
@@ -24,14 +24,6 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
24 |
*/
|
25 |
public function wooIsRunning()
|
26 |
{
|
27 |
-
$path = plugin_dir_path( dirname( __FILE__ ) );
|
28 |
-
|
29 |
-
if (function_exists('WC') && (int) WC()->version >= 3) {
|
30 |
-
require_once $path . 'includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php';
|
31 |
-
} else {
|
32 |
-
require_once $path . 'includes/api/class-mailchimp-woocommerce-transform-orders.php';
|
33 |
-
}
|
34 |
-
|
35 |
// make sure the site option for setting the mailchimp_carts has been saved.
|
36 |
$this->validated_cart_db = get_site_option('mailchimp_woocommerce_db_mailchimp_carts', false);
|
37 |
$this->is_admin = current_user_can('administrator');
|
@@ -62,6 +54,14 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
62 |
return isset($_COOKIE[$key]) ? $_COOKIE[$key] : $default;
|
63 |
}
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
/**
|
66 |
* This should only fire on a web based order so we can do real campaign tracking here.
|
67 |
*
|
@@ -69,24 +69,26 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
69 |
*/
|
70 |
public function onNewOrder($order_id)
|
71 |
{
|
72 |
-
if (
|
73 |
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
|
79 |
|
80 |
-
|
81 |
-
|
82 |
|
83 |
-
|
84 |
-
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
90 |
}
|
91 |
|
92 |
/**
|
@@ -95,15 +97,15 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
95 |
*/
|
96 |
public function handleOrderStatusChanged($order_id, $is_admin = false)
|
97 |
{
|
98 |
-
if (
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
}
|
108 |
|
109 |
/**
|
@@ -111,10 +113,20 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
111 |
*/
|
112 |
public function onPartiallyRefunded($order_id)
|
113 |
{
|
114 |
-
if (
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
}
|
120 |
|
@@ -124,7 +136,7 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
124 |
*/
|
125 |
public function handleCartUpdated($updated = null)
|
126 |
{
|
127 |
-
if ($updated === false || $this->is_admin || $this->cart_was_submitted ||
|
128 |
return !is_null($updated) ? $updated : false;
|
129 |
}
|
130 |
|
@@ -184,6 +196,8 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
184 |
*/
|
185 |
public function handleCouponSaved($post_id, $coupon = null)
|
186 |
{
|
|
|
|
|
187 |
if ($coupon instanceof WC_Coupon) {
|
188 |
wp_queue(new MailChimp_WooCommerce_SingleCoupon($post_id));
|
189 |
}
|
@@ -206,6 +220,8 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
206 |
*/
|
207 |
public function handlePostSaved($post_id, $post, $update)
|
208 |
{
|
|
|
|
|
209 |
if ($post->post_status !== 'auto-draft') {
|
210 |
if ('product' == $post->post_type) {
|
211 |
wp_queue(new MailChimp_WooCommerce_Single_Product($post_id), 5);
|
@@ -217,13 +233,10 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
217 |
|
218 |
/**
|
219 |
* @param $post_id
|
220 |
-
* @return bool
|
221 |
*/
|
222 |
public function handlePostTrashed($post_id)
|
223 |
{
|
224 |
-
if (
|
225 |
-
return false;
|
226 |
-
}
|
227 |
|
228 |
switch (get_post_type($post_id)) {
|
229 |
case 'shop_coupon':
|
@@ -238,6 +251,8 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
238 |
*/
|
239 |
public function handlePostRestored($post_id)
|
240 |
{
|
|
|
|
|
241 |
switch(get_post_type($post_id)) {
|
242 |
case 'shop_coupon':
|
243 |
return $this->handleCouponRestored($post_id);
|
@@ -250,6 +265,8 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
250 |
*/
|
251 |
public function handleUserRegistration($user_id)
|
252 |
{
|
|
|
|
|
253 |
$subscribed = (bool) isset($_POST['mailchimp_woocommerce_newsletter']) ?
|
254 |
$_POST['mailchimp_woocommerce_newsletter'] : false;
|
255 |
|
@@ -267,6 +284,8 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
267 |
*/
|
268 |
function handleUserUpdated($user_id, $old_user_data)
|
269 |
{
|
|
|
|
|
270 |
// only update this person if they were marked as subscribed before
|
271 |
$is_subscribed = get_user_meta($user_id, 'mailchimp_woocommerce_is_subscribed', true);
|
272 |
|
@@ -550,12 +569,11 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
550 |
*/
|
551 |
public function get_user_by_hash()
|
552 |
{
|
553 |
-
if (
|
554 |
if (($cart = $this->getCart($_GET['hash']))) {
|
555 |
$this->respondJSON(array('success' => true, 'email' => $cart->email));
|
556 |
}
|
557 |
}
|
558 |
-
|
559 |
$this->respondJSON(array('success' => false, 'email' => false));
|
560 |
}
|
561 |
|
@@ -568,7 +586,7 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
568 |
$this->respondJSON(array('success' => false));
|
569 |
}
|
570 |
|
571 |
-
if (
|
572 |
|
573 |
$cookie_duration = $this->getCookieDuration();
|
574 |
|
@@ -597,7 +615,6 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
|
|
597 |
$this->respondJSON(array('success' => false, 'email' => false));
|
598 |
}
|
599 |
|
600 |
-
|
601 |
/**
|
602 |
* @param string $time
|
603 |
* @return int
|
4 |
* Created by MailChimp.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 2/17/16
|
9 |
* Time: 12:03 PM
|
10 |
*/
|
11 |
+
class MailChimp_Service extends MailChimp_WooCommerce_Options
|
12 |
{
|
13 |
protected static $pushed_orders = array();
|
14 |
|
24 |
*/
|
25 |
public function wooIsRunning()
|
26 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
// make sure the site option for setting the mailchimp_carts has been saved.
|
28 |
$this->validated_cart_db = get_site_option('mailchimp_woocommerce_db_mailchimp_carts', false);
|
29 |
$this->is_admin = current_user_can('administrator');
|
54 |
return isset($_COOKIE[$key]) ? $_COOKIE[$key] : $default;
|
55 |
}
|
56 |
|
57 |
+
/**
|
58 |
+
* @param WC_Order $order
|
59 |
+
*/
|
60 |
+
public function onNewPayPalOrder($order)
|
61 |
+
{
|
62 |
+
$this->onNewOrder($order->get_id());
|
63 |
+
}
|
64 |
+
|
65 |
/**
|
66 |
* This should only fire on a web based order so we can do real campaign tracking here.
|
67 |
*
|
69 |
*/
|
70 |
public function onNewOrder($order_id)
|
71 |
{
|
72 |
+
if (!mailchimp_is_configured()) return;
|
73 |
|
74 |
+
// register this order is already in process..
|
75 |
+
static::$pushed_orders[$order_id] = true;
|
76 |
|
77 |
+
// see if we have a session id and a campaign id, also only do this when this user is not the admin.
|
78 |
+
$campaign_id = $this->getCampaignTrackingID();
|
79 |
|
80 |
+
// grab the landing site cookie if we have one here.
|
81 |
+
$landing_site = $this->getLandingSiteCookie();
|
82 |
|
83 |
+
// expire the landing site cookie so we can rinse and repeat tracking
|
84 |
+
$this->expireLandingSiteCookie();
|
85 |
|
86 |
+
// remove this record from the db.
|
87 |
+
$this->clearCartData();
|
88 |
+
|
89 |
+
// queue up the single order to be processed.
|
90 |
+
$handler = new MailChimp_WooCommerce_Single_Order($order_id, null, $campaign_id, $landing_site);
|
91 |
+
wp_queue($handler, 60);
|
92 |
}
|
93 |
|
94 |
/**
|
97 |
*/
|
98 |
public function handleOrderStatusChanged($order_id, $is_admin = false)
|
99 |
{
|
100 |
+
if (!mailchimp_is_configured()) return;
|
101 |
+
|
102 |
+
// register this order is already in process..
|
103 |
+
static::$pushed_orders[$order_id] = true;
|
104 |
+
// queue up the single order to be processed.
|
105 |
+
$handler = new MailChimp_WooCommerce_Single_Order($order_id, null, null, null);
|
106 |
+
$handler->is_update = true;
|
107 |
+
$handler->is_admin_save = $is_admin;
|
108 |
+
wp_queue($handler, 90);
|
109 |
}
|
110 |
|
111 |
/**
|
113 |
*/
|
114 |
public function onPartiallyRefunded($order_id)
|
115 |
{
|
116 |
+
if (!mailchimp_is_configured()) return;
|
117 |
+
|
118 |
+
$handler = new MailChimp_WooCommerce_Single_Order($order_id, null, null, null);
|
119 |
+
$handler->partially_refunded = true;
|
120 |
+
wp_queue($handler);
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Clear the card data for a user.
|
125 |
+
*/
|
126 |
+
public function clearCartData()
|
127 |
+
{
|
128 |
+
if ($user_email = $this->getCurrentUserEmail()) {
|
129 |
+
$this->deleteCart($user_email);
|
130 |
}
|
131 |
}
|
132 |
|
136 |
*/
|
137 |
public function handleCartUpdated($updated = null)
|
138 |
{
|
139 |
+
if ($updated === false || $this->is_admin || $this->cart_was_submitted || !mailchimp_is_configured()) {
|
140 |
return !is_null($updated) ? $updated : false;
|
141 |
}
|
142 |
|
196 |
*/
|
197 |
public function handleCouponSaved($post_id, $coupon = null)
|
198 |
{
|
199 |
+
if (!mailchimp_is_configured()) return;
|
200 |
+
|
201 |
if ($coupon instanceof WC_Coupon) {
|
202 |
wp_queue(new MailChimp_WooCommerce_SingleCoupon($post_id));
|
203 |
}
|
220 |
*/
|
221 |
public function handlePostSaved($post_id, $post, $update)
|
222 |
{
|
223 |
+
if (!mailchimp_is_configured()) return;
|
224 |
+
|
225 |
if ($post->post_status !== 'auto-draft') {
|
226 |
if ('product' == $post->post_type) {
|
227 |
wp_queue(new MailChimp_WooCommerce_Single_Product($post_id), 5);
|
233 |
|
234 |
/**
|
235 |
* @param $post_id
|
|
|
236 |
*/
|
237 |
public function handlePostTrashed($post_id)
|
238 |
{
|
239 |
+
if (!mailchimp_is_configured()) return;
|
|
|
|
|
240 |
|
241 |
switch (get_post_type($post_id)) {
|
242 |
case 'shop_coupon':
|
251 |
*/
|
252 |
public function handlePostRestored($post_id)
|
253 |
{
|
254 |
+
if (!mailchimp_is_configured()) return;
|
255 |
+
|
256 |
switch(get_post_type($post_id)) {
|
257 |
case 'shop_coupon':
|
258 |
return $this->handleCouponRestored($post_id);
|
265 |
*/
|
266 |
public function handleUserRegistration($user_id)
|
267 |
{
|
268 |
+
if (!mailchimp_is_configured()) return;
|
269 |
+
|
270 |
$subscribed = (bool) isset($_POST['mailchimp_woocommerce_newsletter']) ?
|
271 |
$_POST['mailchimp_woocommerce_newsletter'] : false;
|
272 |
|
284 |
*/
|
285 |
function handleUserUpdated($user_id, $old_user_data)
|
286 |
{
|
287 |
+
if (!mailchimp_is_configured()) return;
|
288 |
+
|
289 |
// only update this person if they were marked as subscribed before
|
290 |
$is_subscribed = get_user_meta($user_id, 'mailchimp_woocommerce_is_subscribed', true);
|
291 |
|
569 |
*/
|
570 |
public function get_user_by_hash()
|
571 |
{
|
572 |
+
if ($this->doingAjax() && isset($_GET['hash'])) {
|
573 |
if (($cart = $this->getCart($_GET['hash']))) {
|
574 |
$this->respondJSON(array('success' => true, 'email' => $cart->email));
|
575 |
}
|
576 |
}
|
|
|
577 |
$this->respondJSON(array('success' => false, 'email' => false));
|
578 |
}
|
579 |
|
586 |
$this->respondJSON(array('success' => false));
|
587 |
}
|
588 |
|
589 |
+
if ($this->doingAjax() && isset($_GET['email'])) {
|
590 |
|
591 |
$cookie_duration = $this->getCookieDuration();
|
592 |
|
615 |
$this->respondJSON(array('success' => false, 'email' => false));
|
616 |
}
|
617 |
|
|
|
618 |
/**
|
619 |
* @param string $time
|
620 |
* @return int
|
includes/class-mailchimp-woocommerce.php
CHANGED
@@ -9,8 +9,8 @@
|
|
9 |
* @link https://mailchimp.com
|
10 |
* @since 1.0.1
|
11 |
*
|
12 |
-
* @package
|
13 |
-
* @subpackage
|
14 |
*/
|
15 |
|
16 |
/**
|
@@ -23,11 +23,11 @@
|
|
23 |
* version of the plugin.
|
24 |
*
|
25 |
* @since 1.0.0
|
26 |
-
* @package
|
27 |
-
* @subpackage
|
28 |
-
* @author Ryan Hungate <ryan@
|
29 |
*/
|
30 |
-
class
|
31 |
|
32 |
/**
|
33 |
* The loader that's responsible for maintaining and registering all hooks that power
|
@@ -35,7 +35,7 @@ class MailChimp_Woocommerce {
|
|
35 |
*
|
36 |
* @since 1.0.0
|
37 |
* @access protected
|
38 |
-
* @var
|
39 |
*/
|
40 |
protected $loader;
|
41 |
|
@@ -133,10 +133,10 @@ class MailChimp_Woocommerce {
|
|
133 |
*
|
134 |
* Include the following files that make up the plugin:
|
135 |
*
|
136 |
-
* -
|
137 |
-
* -
|
138 |
-
* -
|
139 |
-
* -
|
140 |
*
|
141 |
* Create an instance of the loader which will be used to register the hooks
|
142 |
* with WordPress.
|
@@ -145,94 +145,47 @@ class MailChimp_Woocommerce {
|
|
145 |
* @access private
|
146 |
*/
|
147 |
private function load_dependencies() {
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
require_once $path . 'includes/class-mailchimp-woocommerce-options.php';
|
153 |
-
|
154 |
-
/** The class responsible for orchestrating the actions and filters of the core plugin.*/
|
155 |
-
require_once $path . 'includes/class-mailchimp-woocommerce-loader.php';
|
156 |
-
|
157 |
-
/** The class responsible for defining internationalization functionality of the plugin. */
|
158 |
-
require_once $path . 'includes/class-mailchimp-woocommerce-i18n.php';
|
159 |
-
|
160 |
-
/** The service class.*/
|
161 |
-
require_once $path . 'includes/class-mailchimp-woocommerce-service.php';
|
162 |
-
|
163 |
-
/** The newsletter class. */
|
164 |
-
require_once $path . 'includes/class-mailchimp-woocommerce-newsletter.php';
|
165 |
-
|
166 |
-
/** The class responsible for defining all actions that occur in the admin area.*/
|
167 |
-
require_once $path . 'admin/class-mailchimp-woocommerce-admin.php';
|
168 |
-
|
169 |
-
/** The class responsible for defining all actions that occur in the public-facing side of the site. */
|
170 |
-
require_once $path . 'public/class-mailchimp-woocommerce-public.php';
|
171 |
-
|
172 |
-
/** Require all the MailChimp Assets for the API */
|
173 |
-
require_once $path . 'includes/api/class-mailchimp-api.php';
|
174 |
-
require_once $path . 'includes/api/class-mailchimp-woocommerce-api.php';
|
175 |
-
require_once $path . 'includes/api/class-mailchimp-woocommerce-create-list-submission.php';
|
176 |
-
require_once $path . 'includes/api/class-mailchimp-woocommerce-transform-products.php';
|
177 |
-
require_once $path . 'includes/api/class-mailchimp-woocommerce-transform-coupons.php';
|
178 |
-
|
179 |
-
/** Require all the mailchimp api asset classes */
|
180 |
-
require_once $path . 'includes/api/assets/class-mailchimp-address.php';
|
181 |
-
require_once $path . 'includes/api/assets/class-mailchimp-cart.php';
|
182 |
-
require_once $path . 'includes/api/assets/class-mailchimp-customer.php';
|
183 |
-
require_once $path . 'includes/api/assets/class-mailchimp-line-item.php';
|
184 |
-
require_once $path . 'includes/api/assets/class-mailchimp-order.php';
|
185 |
-
require_once $path . 'includes/api/assets/class-mailchimp-product.php';
|
186 |
-
require_once $path . 'includes/api/assets/class-mailchimp-product-variation.php';
|
187 |
-
require_once $path . 'includes/api/assets/class-mailchimp-store.php';
|
188 |
-
require_once $path . 'includes/api/assets/class-mailchimp-promo-code.php';
|
189 |
-
require_once $path . 'includes/api/assets/class-mailchimp-promo-rule.php';
|
190 |
-
|
191 |
-
/** Require all the api error helpers */
|
192 |
-
require_once $path . 'includes/api/errors/class-mailchimp-error.php';
|
193 |
-
require_once $path . 'includes/api/errors/class-mailchimp-server-error.php';
|
194 |
-
|
195 |
-
/** Require the various helper scripts */
|
196 |
-
require_once $path . 'includes/api/helpers/class-mailchimp-woocommerce-api-currency-codes.php';
|
197 |
-
require_once $path . 'includes/api/helpers/class-mailchimp-woocommerce-api-locales.php';
|
198 |
-
|
199 |
-
/** Background job sync tools */
|
200 |
-
|
201 |
-
// make sure the queue exists first since the other files depend on it.
|
202 |
-
require_once $path . 'includes/vendor/queue.php';
|
203 |
-
|
204 |
-
// the abstract bulk sync class
|
205 |
-
require_once $path.'includes/processes/class-mailchimp-woocommerce-abstract-sync.php';
|
206 |
-
|
207 |
-
// bulk data sync
|
208 |
-
require_once $path.'includes/processes/class-mailchimp-woocommerce-process-orders.php';
|
209 |
-
require_once $path.'includes/processes/class-mailchimp-woocommerce-process-products.php';
|
210 |
-
require_once $path.'includes/processes/class-mailchimp-woocommerce-process-coupons.php';
|
211 |
-
|
212 |
-
// individual item sync
|
213 |
-
require_once $path.'includes/processes/class-mailchimp-woocommerce-cart-update.php';
|
214 |
-
require_once $path.'includes/processes/class-mailchimp-woocommerce-single-order.php';
|
215 |
-
require_once $path.'includes/processes/class-mailchimp-woocommerce-single-product.php';
|
216 |
-
require_once $path.'includes/processes/class-mailchimp-woocommerce-single-coupon.php';
|
217 |
-
require_once $path.'includes/processes/class-mailchimp-woocommerce-user-submit.php';
|
218 |
|
219 |
// fire up the loader
|
220 |
-
$this->loader = new
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
}
|
222 |
|
223 |
/**
|
224 |
* Define the locale for this plugin for internationalization.
|
225 |
*
|
226 |
-
* Uses the
|
227 |
* with WordPress.
|
228 |
*
|
229 |
* @since 1.0.0
|
230 |
* @access private
|
231 |
*/
|
232 |
private function set_locale() {
|
233 |
-
|
234 |
-
$plugin_i18n = new MailChimp_Woocommerce_i18n();
|
235 |
-
|
236 |
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
237 |
}
|
238 |
|
@@ -245,7 +198,7 @@ class MailChimp_Woocommerce {
|
|
245 |
*/
|
246 |
private function define_admin_hooks() {
|
247 |
|
248 |
-
$plugin_admin = new
|
249 |
|
250 |
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
|
251 |
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
|
@@ -275,7 +228,7 @@ class MailChimp_Woocommerce {
|
|
275 |
*/
|
276 |
private function define_public_hooks() {
|
277 |
|
278 |
-
$plugin_public = new
|
279 |
|
280 |
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
|
281 |
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
|
@@ -332,6 +285,7 @@ class MailChimp_Woocommerce {
|
|
332 |
// order hooks
|
333 |
$this->loader->add_action('woocommerce_thankyou', $service, 'onNewOrder', 10);
|
334 |
$this->loader->add_action('woocommerce_api_create_order', $service, 'onNewOrder', 10);
|
|
|
335 |
$this->loader->add_action('woocommerce_order_status_changed', $service, 'handleOrderStatusChanged', 10);
|
336 |
|
337 |
// partially refunded
|
@@ -394,7 +348,7 @@ class MailChimp_Woocommerce {
|
|
394 |
* The reference to the class that orchestrates the hooks with the plugin.
|
395 |
*
|
396 |
* @since 1.0.1
|
397 |
-
* @return
|
398 |
*/
|
399 |
public function get_loader() {
|
400 |
return $this->loader;
|
@@ -409,4 +363,81 @@ class MailChimp_Woocommerce {
|
|
409 |
public function get_version() {
|
410 |
return $this->version;
|
411 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
}
|
9 |
* @link https://mailchimp.com
|
10 |
* @since 1.0.1
|
11 |
*
|
12 |
+
* @package MailChimp_WooCommerce
|
13 |
+
* @subpackage MailChimp_WooCommerce/includes
|
14 |
*/
|
15 |
|
16 |
/**
|
23 |
* version of the plugin.
|
24 |
*
|
25 |
* @since 1.0.0
|
26 |
+
* @package MailChimp_WooCommerce
|
27 |
+
* @subpackage MailChimp_WooCommerce/includes
|
28 |
+
* @author Ryan Hungate <ryan@vextras.com>
|
29 |
*/
|
30 |
+
class MailChimp_WooCommerce {
|
31 |
|
32 |
/**
|
33 |
* The loader that's responsible for maintaining and registering all hooks that power
|
35 |
*
|
36 |
* @since 1.0.0
|
37 |
* @access protected
|
38 |
+
* @var MailChimp_WooCommerce_Loader $loader Maintains and registers all hooks for the plugin.
|
39 |
*/
|
40 |
protected $loader;
|
41 |
|
133 |
*
|
134 |
* Include the following files that make up the plugin:
|
135 |
*
|
136 |
+
* - MailChimp_WooCommerce_Loader. Orchestrates the hooks of the plugin.
|
137 |
+
* - MailChimp_WooCommerce_i18n. Defines internationalization functionality.
|
138 |
+
* - MailChimp_WooCommerce_Admin. Defines all hooks for the admin area.
|
139 |
+
* - MailChimp_WooCommerce_Public. Defines all hooks for the public side of the site.
|
140 |
*
|
141 |
* Create an instance of the loader which will be used to register the hooks
|
142 |
* with WordPress.
|
145 |
* @access private
|
146 |
*/
|
147 |
private function load_dependencies() {
|
148 |
+
global $wp_queue;
|
149 |
+
if (empty($wp_queue)) {
|
150 |
+
$wp_queue = new WP_Queue();
|
151 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
|
153 |
// fire up the loader
|
154 |
+
$this->loader = new MailChimp_WooCommerce_Loader();
|
155 |
+
|
156 |
+
if (!mailchimp_running_in_console() && mailchimp_is_configured()) {
|
157 |
+
// fire up the http worker container
|
158 |
+
new WP_Http_Worker($wp_queue);
|
159 |
+
}
|
160 |
+
|
161 |
+
// if we're not running in the console, and the http_worker is not running
|
162 |
+
if (mailchimp_should_init_queue()) {
|
163 |
+
try {
|
164 |
+
// if we do not have a site transient for the queue listener
|
165 |
+
if (!get_site_transient('http_worker_queue_listen')) {
|
166 |
+
// set the site transient to expire in 50 seconds so this will not happen too many times
|
167 |
+
// but still work for cron scripts on the minute mark.
|
168 |
+
set_site_transient( 'http_worker_queue_listen', microtime(), 50);
|
169 |
+
// if we have available jobs, call the http worker manually
|
170 |
+
if ($wp_queue->available_jobs()) {
|
171 |
+
mailchimp_call_http_worker_manually();
|
172 |
+
}
|
173 |
+
}
|
174 |
+
} catch (\Exception $e) {}
|
175 |
+
}
|
176 |
}
|
177 |
|
178 |
/**
|
179 |
* Define the locale for this plugin for internationalization.
|
180 |
*
|
181 |
+
* Uses the MailChimp_WooCommerce_i18n class in order to set the domain and to register the hook
|
182 |
* with WordPress.
|
183 |
*
|
184 |
* @since 1.0.0
|
185 |
* @access private
|
186 |
*/
|
187 |
private function set_locale() {
|
188 |
+
$plugin_i18n = new MailChimp_WooCommerce_i18n();
|
|
|
|
|
189 |
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
190 |
}
|
191 |
|
198 |
*/
|
199 |
private function define_admin_hooks() {
|
200 |
|
201 |
+
$plugin_admin = new MailChimp_WooCommerce_Admin( $this->get_plugin_name(), $this->get_version() );
|
202 |
|
203 |
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
|
204 |
$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');
|
228 |
*/
|
229 |
private function define_public_hooks() {
|
230 |
|
231 |
+
$plugin_public = new MailChimp_WooCommerce_Public( $this->get_plugin_name(), $this->get_version() );
|
232 |
|
233 |
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
|
234 |
$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
|
285 |
// order hooks
|
286 |
$this->loader->add_action('woocommerce_thankyou', $service, 'onNewOrder', 10);
|
287 |
$this->loader->add_action('woocommerce_api_create_order', $service, 'onNewOrder', 10);
|
288 |
+
$this->loader->add_action('woocommerce_ppe_do_payaction', $service, 'onNewPayPalOrder', 10, 1);
|
289 |
$this->loader->add_action('woocommerce_order_status_changed', $service, 'handleOrderStatusChanged', 10);
|
290 |
|
291 |
// partially refunded
|
348 |
* The reference to the class that orchestrates the hooks with the plugin.
|
349 |
*
|
350 |
* @since 1.0.1
|
351 |
+
* @return MailChimp_WooCommerce_Loader Orchestrates the hooks of the plugin.
|
352 |
*/
|
353 |
public function get_loader() {
|
354 |
return $this->loader;
|
363 |
public function get_version() {
|
364 |
return $this->version;
|
365 |
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* This is just in case we ever needed to revert back to the old loading
|
369 |
+
*/
|
370 |
+
protected function manual_file_loader()
|
371 |
+
{
|
372 |
+
$path = plugin_dir_path(dirname( __FILE__ ));
|
373 |
+
|
374 |
+
/** The abstract options class.*/
|
375 |
+
require_once $path . 'includes/class-mailchimp-woocommerce-options.php';
|
376 |
+
|
377 |
+
/** The class responsible for orchestrating the actions and filters of the core plugin.*/
|
378 |
+
require_once $path . 'includes/class-mailchimp-woocommerce-loader.php';
|
379 |
+
|
380 |
+
/** The class responsible for defining internationalization functionality of the plugin. */
|
381 |
+
require_once $path . 'includes/class-mailchimp-woocommerce-i18n.php';
|
382 |
+
|
383 |
+
/** The service class.*/
|
384 |
+
require_once $path . 'includes/class-mailchimp-woocommerce-service.php';
|
385 |
+
|
386 |
+
/** The newsletter class. */
|
387 |
+
require_once $path . 'includes/class-mailchimp-woocommerce-newsletter.php';
|
388 |
+
|
389 |
+
/** The class responsible for defining all actions that occur in the admin area.*/
|
390 |
+
require_once $path . 'admin/class-mailchimp-woocommerce-admin.php';
|
391 |
+
|
392 |
+
/** The class responsible for defining all actions that occur in the public-facing side of the site. */
|
393 |
+
require_once $path . 'public/class-mailchimp-woocommerce-public.php';
|
394 |
+
|
395 |
+
/** Require all the MailChimp Assets for the API */
|
396 |
+
require_once $path . 'includes/api/class-mailchimp-api.php';
|
397 |
+
require_once $path . 'includes/api/class-mailchimp-woocommerce-api.php';
|
398 |
+
require_once $path . 'includes/api/class-mailchimp-woocommerce-create-list-submission.php';
|
399 |
+
require_once $path . 'includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php';
|
400 |
+
require_once $path . 'includes/api/class-mailchimp-woocommerce-transform-products.php';
|
401 |
+
require_once $path . 'includes/api/class-mailchimp-woocommerce-transform-coupons.php';
|
402 |
+
|
403 |
+
/** Require all the mailchimp api asset classes */
|
404 |
+
require_once $path . 'includes/api/assets/class-mailchimp-address.php';
|
405 |
+
require_once $path . 'includes/api/assets/class-mailchimp-cart.php';
|
406 |
+
require_once $path . 'includes/api/assets/class-mailchimp-customer.php';
|
407 |
+
require_once $path . 'includes/api/assets/class-mailchimp-line-item.php';
|
408 |
+
require_once $path . 'includes/api/assets/class-mailchimp-order.php';
|
409 |
+
require_once $path . 'includes/api/assets/class-mailchimp-product.php';
|
410 |
+
require_once $path . 'includes/api/assets/class-mailchimp-product-variation.php';
|
411 |
+
require_once $path . 'includes/api/assets/class-mailchimp-store.php';
|
412 |
+
require_once $path . 'includes/api/assets/class-mailchimp-promo-code.php';
|
413 |
+
require_once $path . 'includes/api/assets/class-mailchimp-promo-rule.php';
|
414 |
+
|
415 |
+
/** Require all the api error helpers */
|
416 |
+
require_once $path . 'includes/api/errors/class-mailchimp-error.php';
|
417 |
+
require_once $path . 'includes/api/errors/class-mailchimp-server-error.php';
|
418 |
+
|
419 |
+
/** Require the various helper scripts */
|
420 |
+
require_once $path . 'includes/api/helpers/class-mailchimp-woocommerce-api-currency-codes.php';
|
421 |
+
require_once $path . 'includes/api/helpers/class-mailchimp-woocommerce-api-locales.php';
|
422 |
+
|
423 |
+
/** Background job sync tools */
|
424 |
+
|
425 |
+
// make sure the queue exists first since the other files depend on it.
|
426 |
+
require_once $path . 'includes/vendor/queue.php';
|
427 |
+
|
428 |
+
// the abstract bulk sync class
|
429 |
+
require_once $path.'includes/processes/class-mailchimp-woocommerce-abstract-sync.php';
|
430 |
+
|
431 |
+
// bulk data sync
|
432 |
+
require_once $path.'includes/processes/class-mailchimp-woocommerce-process-orders.php';
|
433 |
+
require_once $path.'includes/processes/class-mailchimp-woocommerce-process-products.php';
|
434 |
+
require_once $path.'includes/processes/class-mailchimp-woocommerce-process-coupons.php';
|
435 |
+
|
436 |
+
// individual item sync
|
437 |
+
require_once $path.'includes/processes/class-mailchimp-woocommerce-cart-update.php';
|
438 |
+
require_once $path.'includes/processes/class-mailchimp-woocommerce-single-order.php';
|
439 |
+
require_once $path.'includes/processes/class-mailchimp-woocommerce-single-product.php';
|
440 |
+
require_once $path.'includes/processes/class-mailchimp-woocommerce-single-coupon.php';
|
441 |
+
require_once $path.'includes/processes/class-mailchimp-woocommerce-user-submit.php';
|
442 |
+
}
|
443 |
}
|
includes/processes/class-mailchimp-woocommerce-abstract-sync.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/14/16
|
9 |
* Time: 11:54 AM
|
10 |
*/
|
11 |
-
abstract class
|
12 |
{
|
13 |
/**
|
14 |
* @var MailChimp_WooCommerce_Api
|
@@ -78,6 +78,11 @@ abstract class MailChimp_WooCommerce_Abtstract_Sync extends WP_Job
|
|
78 |
{
|
79 |
global $wpdb;
|
80 |
|
|
|
|
|
|
|
|
|
|
|
81 |
if (!($this->store_id = $this->getStoreID())) {
|
82 |
mailchimp_debug(get_called_class().'@handle', 'store id not loaded');
|
83 |
$this->delete();
|
@@ -235,7 +240,7 @@ abstract class MailChimp_WooCommerce_Abtstract_Sync extends WP_Job
|
|
235 |
/**
|
236 |
* @param $page
|
237 |
* @param null $resource
|
238 |
-
* @return
|
239 |
*/
|
240 |
public function setResourcePagePointer($page, $resource = null)
|
241 |
{
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/14/16
|
9 |
* Time: 11:54 AM
|
10 |
*/
|
11 |
+
abstract class MailChimp_WooCommerce_Abstract_Sync extends WP_Job
|
12 |
{
|
13 |
/**
|
14 |
* @var MailChimp_WooCommerce_Api
|
78 |
{
|
79 |
global $wpdb;
|
80 |
|
81 |
+
if (!mailchimp_is_configured()) {
|
82 |
+
mailchimp_debug(get_called_class(), 'mailchimp is not configured properly');
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
if (!($this->store_id = $this->getStoreID())) {
|
87 |
mailchimp_debug(get_called_class().'@handle', 'store id not loaded');
|
88 |
$this->delete();
|
240 |
/**
|
241 |
* @param $page
|
242 |
* @param null $resource
|
243 |
+
* @return MailChimp_WooCommerce_Abstract_Sync
|
244 |
*/
|
245 |
public function setResourcePagePointer($page, $resource = null)
|
246 |
{
|
includes/processes/class-mailchimp-woocommerce-cart-update.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
@@ -61,88 +61,89 @@ class MailChimp_WooCommerce_Cart_Update extends WP_Job
|
|
61 |
public function process()
|
62 |
{
|
63 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
$options = get_option('mailchimp-woocommerce', array());
|
65 |
$store_id = mailchimp_get_store_id();
|
66 |
|
67 |
-
|
68 |
|
69 |
-
|
|
|
70 |
|
71 |
-
|
|
|
|
|
|
|
72 |
|
73 |
-
|
74 |
-
$api->deleteCartByID($store_id, $this->unique_id);
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
80 |
|
81 |
-
|
|
|
|
|
|
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
$customer->setId($this->unique_id);
|
91 |
-
$customer->setEmailAddress($this->email);
|
92 |
-
$customer->setOptInStatus(false);
|
93 |
-
|
94 |
-
$cart = new MailChimp_WooCommerce_Cart();
|
95 |
-
$cart->setId($this->unique_id);
|
96 |
-
$cart->setCampaignID($this->campaign_id);
|
97 |
-
$cart->setCheckoutUrl($checkout_url);
|
98 |
-
$cart->setCurrencyCode(isset($options['store_currency_code']) ? $options['store_currency_code'] : 'USD');
|
99 |
-
|
100 |
-
$cart->setCustomer($customer);
|
101 |
-
|
102 |
-
$order_total = 0;
|
103 |
-
$products = array();
|
104 |
-
|
105 |
-
foreach ($this->cart_data as $hash => $item) {
|
106 |
-
try {
|
107 |
-
$line = $this->transformLineItem($hash, $item);
|
108 |
-
$cart->addItem($line);
|
109 |
-
$order_total += ($item['quantity'] * $line->getPrice());
|
110 |
-
$products[] = $line;
|
111 |
-
} catch (\Exception $e) {}
|
112 |
-
}
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
}
|
117 |
-
|
118 |
-
$cart->setOrderTotal($order_total);
|
119 |
|
|
|
120 |
try {
|
121 |
-
|
122 |
-
$
|
|
|
|
|
|
|
|
|
123 |
|
124 |
-
|
|
|
|
|
125 |
|
126 |
-
|
127 |
|
128 |
-
|
|
|
|
|
129 |
|
130 |
-
|
131 |
-
// let's loop through each item, verify that we have the product or not.
|
132 |
-
// if not, we will add it.
|
133 |
-
foreach ($products as $item) {
|
134 |
-
/** @var MailChimp_WooCommerce_LineItem $item */
|
135 |
-
$transformer = new MailChimp_WooCommerce_Single_Product($item->getProductID());
|
136 |
-
if (!$transformer->api()->getStoreProduct($store_id, $item->getProductId())) {
|
137 |
-
$transformer->handle();
|
138 |
-
}
|
139 |
-
}
|
140 |
|
141 |
-
|
142 |
-
$api->addCart($store_id, $cart, false);
|
143 |
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
|
148 |
} catch (\Exception $e) {
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
61 |
public function process()
|
62 |
{
|
63 |
try {
|
64 |
+
|
65 |
+
if (!mailchimp_is_configured() || !($api = mailchimp_get_api())) {
|
66 |
+
mailchimp_debug(get_called_class(), 'mailchimp is not configured properly');
|
67 |
+
return false;
|
68 |
+
}
|
69 |
+
|
70 |
$options = get_option('mailchimp-woocommerce', array());
|
71 |
$store_id = mailchimp_get_store_id();
|
72 |
|
73 |
+
$this->cart_data = json_decode($this->cart_data, true);
|
74 |
|
75 |
+
// delete it and the add it back.
|
76 |
+
$api->deleteCartByID($store_id, $this->unique_id);
|
77 |
|
78 |
+
// if they emptied the cart ignore it.
|
79 |
+
if (!is_array($this->cart_data) || empty($this->cart_data)) {
|
80 |
+
return false;
|
81 |
+
}
|
82 |
|
83 |
+
$checkout_url = wc_get_checkout_url();
|
|
|
84 |
|
85 |
+
if (mailchimp_string_contains($checkout_url, '?')) {
|
86 |
+
$checkout_url .= '&mc_cart_id='.$this->unique_id;
|
87 |
+
} else {
|
88 |
+
$checkout_url .= '?mc_cart_id='.$this->unique_id;
|
89 |
+
}
|
90 |
|
91 |
+
$customer = new MailChimp_WooCommerce_Customer();
|
92 |
+
$customer->setId($this->unique_id);
|
93 |
+
$customer->setEmailAddress($this->email);
|
94 |
+
$customer->setOptInStatus(false);
|
95 |
|
96 |
+
$cart = new MailChimp_WooCommerce_Cart();
|
97 |
+
$cart->setId($this->unique_id);
|
98 |
+
$cart->setCampaignID($this->campaign_id);
|
99 |
+
$cart->setCheckoutUrl($checkout_url);
|
100 |
+
$cart->setCurrencyCode(isset($options['store_currency_code']) ? $options['store_currency_code'] : 'USD');
|
101 |
|
102 |
+
$cart->setCustomer($customer);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
$order_total = 0;
|
105 |
+
$products = array();
|
|
|
|
|
|
|
106 |
|
107 |
+
foreach ($this->cart_data as $hash => $item) {
|
108 |
try {
|
109 |
+
$line = $this->transformLineItem($hash, $item);
|
110 |
+
$cart->addItem($line);
|
111 |
+
$order_total += ($item['quantity'] * $line->getPrice());
|
112 |
+
$products[] = $line;
|
113 |
+
} catch (\Exception $e) {}
|
114 |
+
}
|
115 |
|
116 |
+
if (empty($products)) {
|
117 |
+
return false;
|
118 |
+
}
|
119 |
|
120 |
+
$cart->setOrderTotal($order_total);
|
121 |
|
122 |
+
try {
|
123 |
+
// if the post is successful we're all good.
|
124 |
+
$api->addCart($store_id, $cart, false);
|
125 |
|
126 |
+
mailchimp_log('abandoned_cart.success', "email: {$customer->getEmailAddress()} :: checkout_url: $checkout_url");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
+
} catch (\Exception $e) {
|
|
|
129 |
|
130 |
+
mailchimp_error('abandoned_cart.error', "email: {$customer->getEmailAddress()} :: attempting product update :: {$e->getMessage()}");
|
131 |
+
|
132 |
+
// if we have an error it's most likely due to a product not being found.
|
133 |
+
// let's loop through each item, verify that we have the product or not.
|
134 |
+
// if not, we will add it.
|
135 |
+
foreach ($products as $item) {
|
136 |
+
/** @var MailChimp_WooCommerce_LineItem $item */
|
137 |
+
$transformer = new MailChimp_WooCommerce_Single_Product($item->getProductID());
|
138 |
+
if (!$transformer->api()->getStoreProduct($store_id, $item->getProductId())) {
|
139 |
+
$transformer->handle();
|
140 |
+
}
|
141 |
}
|
142 |
+
|
143 |
+
// if the post is successful we're all good.
|
144 |
+
$api->addCart($store_id, $cart, false);
|
145 |
+
|
146 |
+
mailchimp_log('abandoned_cart.success', "email: {$customer->getEmailAddress()}");
|
147 |
}
|
148 |
|
149 |
} catch (\Exception $e) {
|
includes/processes/class-mailchimp-woocommerce-process-coupons.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 10/06/17
|
9 |
* Time: 10:57 AM
|
10 |
*/
|
11 |
-
class MailChimp_WooCommerce_Process_Coupons extends
|
12 |
{
|
13 |
/**
|
14 |
* @var string
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 10/06/17
|
9 |
* Time: 10:57 AM
|
10 |
*/
|
11 |
+
class MailChimp_WooCommerce_Process_Coupons extends MailChimp_WooCommerce_Abstract_Sync
|
12 |
{
|
13 |
/**
|
14 |
* @var string
|
includes/processes/class-mailchimp-woocommerce-process-orders.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/14/16
|
9 |
* Time: 10:57 AM
|
10 |
*/
|
11 |
-
class MailChimp_WooCommerce_Process_Orders extends
|
12 |
{
|
13 |
/**
|
14 |
* @var string
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/14/16
|
9 |
* Time: 10:57 AM
|
10 |
*/
|
11 |
+
class MailChimp_WooCommerce_Process_Orders extends MailChimp_WooCommerce_Abstract_Sync
|
12 |
{
|
13 |
/**
|
14 |
* @var string
|
includes/processes/class-mailchimp-woocommerce-process-products.php
CHANGED
@@ -4,11 +4,11 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/14/16
|
9 |
* Time: 10:57 AM
|
10 |
*/
|
11 |
-
class MailChimp_WooCommerce_Process_Products extends
|
12 |
{
|
13 |
/**
|
14 |
* @var string
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/14/16
|
9 |
* Time: 10:57 AM
|
10 |
*/
|
11 |
+
class MailChimp_WooCommerce_Process_Products extends MailChimp_WooCommerce_Abstract_Sync
|
12 |
{
|
13 |
/**
|
14 |
* @var string
|
includes/processes/class-mailchimp-woocommerce-single-coupon.php
CHANGED
@@ -28,14 +28,20 @@ class MailChimp_WooCommerce_SingleCoupon extends WP_Job
|
|
28 |
public function handle()
|
29 |
{
|
30 |
try {
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
|
34 |
if (empty($this->post_id)) {
|
35 |
mailchimp_error('promo_code.failure', "could not process coupon {$this->post_id}");
|
36 |
return;
|
37 |
}
|
38 |
|
|
|
|
|
|
|
39 |
$transformer = new MailChimp_WooCommerce_Transform_Coupons();
|
40 |
$code = $transformer->transform($this->post_id);
|
41 |
|
28 |
public function handle()
|
29 |
{
|
30 |
try {
|
31 |
+
|
32 |
+
if (!mailchimp_is_configured()) {
|
33 |
+
mailchimp_debug(get_called_class(), 'mailchimp is not configured properly');
|
34 |
+
return false;
|
35 |
+
}
|
36 |
|
37 |
if (empty($this->post_id)) {
|
38 |
mailchimp_error('promo_code.failure', "could not process coupon {$this->post_id}");
|
39 |
return;
|
40 |
}
|
41 |
|
42 |
+
$api = mailchimp_get_api();
|
43 |
+
$store_id = mailchimp_get_store_id();
|
44 |
+
|
45 |
$transformer = new MailChimp_WooCommerce_Transform_Coupons();
|
46 |
$code = $transformer->transform($this->post_id);
|
47 |
|
includes/processes/class-mailchimp-woocommerce-single-order.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
@@ -45,154 +45,154 @@ class MailChimp_WooCommerce_Single_Order extends WP_Job
|
|
45 |
|
46 |
public function process()
|
47 |
{
|
48 |
-
$
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
if (!empty($store_id) && is_array($options) && isset($options['mailchimp_api_key'])) {
|
53 |
|
54 |
-
|
55 |
-
mailchimp_log('order_submit.failure', "There is no real order number to use.");
|
56 |
-
return false;
|
57 |
-
}
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
}
|
64 |
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
67 |
|
68 |
-
|
69 |
-
$job->campaign_id = $this->campaign_id;
|
70 |
|
71 |
-
|
|
|
72 |
|
73 |
-
|
74 |
-
return false;
|
75 |
-
}
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
$job->campaign_id = null;
|
81 |
-
$this->campaign_id = null;
|
82 |
-
$this->landing_site = null;
|
83 |
-
}
|
84 |
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
}
|
91 |
|
92 |
-
|
93 |
-
|
|
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
mailchimp_log('validation.amazon', "Order #{$woo_order_number} was placed through Amazon. Skipping!");
|
98 |
-
return false;
|
99 |
-
}
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
return false;
|
104 |
-
}
|
105 |
|
106 |
-
|
|
|
107 |
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
112 |
|
113 |
-
|
114 |
-
|
|
|
|
|
115 |
|
116 |
-
|
117 |
|
118 |
-
|
119 |
-
|
|
|
|
|
120 |
|
121 |
-
|
122 |
-
if (!empty($this->campaign_id)) {
|
123 |
-
$log .= ' :: campaign id ' . $this->campaign_id;
|
124 |
-
$order->setCampaignId($this->campaign_id);
|
125 |
-
}
|
126 |
|
127 |
-
|
128 |
-
|
129 |
-
$log .= ' :: landing site ' . $this->landing_site;
|
130 |
-
$order->setLandingSite($this->landing_site);
|
131 |
-
}
|
132 |
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
|
135 |
-
//
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
mailchimp_error('order_submit.failure', "$call :: #{$order->getId()} :: email: {$order->getCustomer()->getEmailAddress()} produced a blank response from MailChimp");
|
140 |
-
return $api_response;
|
141 |
}
|
142 |
|
143 |
-
|
144 |
-
if (!empty($this->cart_session_id)) {
|
145 |
-
$api->deleteCartByID($store_id, $this->cart_session_id);
|
146 |
-
$log .= " :: abandoned cart deleted [{$this->cart_session_id}]";
|
147 |
-
}
|
148 |
|
149 |
-
|
|
|
150 |
|
|
|
|
|
151 |
return $api_response;
|
|
|
152 |
|
153 |
-
|
|
|
|
|
154 |
|
155 |
-
|
156 |
|
157 |
-
|
158 |
|
159 |
-
|
160 |
-
// transform the order
|
161 |
-
$order = $job->transform(get_post($this->order_id));
|
162 |
-
$this->cart_session_id = $order->getCustomer()->getId();
|
163 |
-
}
|
164 |
|
165 |
-
|
166 |
-
if (isset($order) && strpos($message, 'not be changed')) {
|
167 |
|
168 |
-
|
169 |
|
170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
-
|
173 |
-
$api->deleteCustomer($store_id, $order->getCustomer()->getId());
|
174 |
|
175 |
-
|
176 |
-
$api_response = $api->$call($store_id, $order, false);
|
177 |
|
178 |
-
|
|
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
}
|
183 |
|
184 |
-
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
}
|
190 |
|
191 |
-
|
192 |
|
193 |
-
|
194 |
-
|
|
|
195 |
}
|
|
|
|
|
|
|
|
|
|
|
196 |
}
|
197 |
}
|
198 |
}
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
45 |
|
46 |
public function process()
|
47 |
{
|
48 |
+
if (!mailchimp_is_configured() || !($api = mailchimp_get_api())) {
|
49 |
+
mailchimp_debug(get_called_class(), 'mailchimp is not configured properly');
|
50 |
+
return false;
|
51 |
+
}
|
|
|
52 |
|
53 |
+
$store_id = mailchimp_get_store_id();
|
|
|
|
|
|
|
54 |
|
55 |
+
if (!($woo_order_number = $this->getRealOrderNumber())) {
|
56 |
+
mailchimp_log('order_submit.failure', "There is no real order number to use.");
|
57 |
+
return false;
|
58 |
+
}
|
|
|
59 |
|
60 |
+
// skip amazon orders
|
61 |
+
if ($this->isAmazonOrder()) {
|
62 |
+
mailchimp_log('validation.amazon', "Order #{$woo_order_number} was placed through Amazon. Skipping!");
|
63 |
+
return false;
|
64 |
+
}
|
65 |
|
66 |
+
$job = new MailChimp_WooCommerce_Transform_Orders();
|
|
|
67 |
|
68 |
+
// set the campaign ID
|
69 |
+
$job->campaign_id = $this->campaign_id;
|
70 |
|
71 |
+
$call = ($api_response = $api->getStoreOrder($store_id, $woo_order_number)) ? 'updateStoreOrder' : 'addStoreOrder';
|
|
|
|
|
72 |
|
73 |
+
if (!$this->is_admin_save && $call === 'addStoreOrder' && $this->is_update === true) {
|
74 |
+
return false;
|
75 |
+
}
|
|
|
|
|
|
|
|
|
76 |
|
77 |
+
// if we already pushed this order into the system, we need to unset it now just in case there
|
78 |
+
// was another campaign that had been sent and this was only an order update.
|
79 |
+
if ($call === 'updateStoreOrder') {
|
80 |
+
$job->campaign_id = null;
|
81 |
+
$this->campaign_id = null;
|
82 |
+
$this->landing_site = null;
|
83 |
+
}
|
84 |
|
85 |
+
// will either add or update the order
|
86 |
+
try {
|
|
|
87 |
|
88 |
+
if (!($order_post = get_post($this->order_id))) {
|
89 |
+
return false;
|
90 |
+
}
|
91 |
|
92 |
+
// transform the order
|
93 |
+
$order = $job->transform($order_post);
|
|
|
|
|
|
|
94 |
|
95 |
+
// will be the same as the customer id. an md5'd hash of a lowercased email.
|
96 |
+
$this->cart_session_id = $order->getCustomer()->getId();
|
|
|
|
|
97 |
|
98 |
+
// delete the AC cart record.
|
99 |
+
$deleted_abandoned_cart = !empty($this->cart_session_id) && $api->deleteCartByID($store_id, $this->cart_session_id);
|
100 |
|
101 |
+
// skip amazon orders
|
102 |
+
if ($order->isFlaggedAsAmazonOrder()) {
|
103 |
+
mailchimp_log('validation.amazon', "Order #{$woo_order_number} was placed through Amazon. Skipping!");
|
104 |
+
return false;
|
105 |
+
}
|
106 |
|
107 |
+
// if the order is in failed or cancelled status - and it's brand new, we shouldn't submit it.
|
108 |
+
if ($call === 'addStoreOrder' && in_array($order->getFinancialStatus(), array('failed', 'cancelled'))) {
|
109 |
+
return false;
|
110 |
+
}
|
111 |
|
112 |
+
mailchimp_debug('order_submit', "#{$woo_order_number}", $order->toArray());
|
113 |
|
114 |
+
// if we're overriding this we need to set it here.
|
115 |
+
if ($this->partially_refunded) {
|
116 |
+
$order->setFinancialStatus('partially_refunded');
|
117 |
+
}
|
118 |
|
119 |
+
$log = "$call :: #{$order->getId()} :: email: {$order->getCustomer()->getEmailAddress()}";
|
|
|
|
|
|
|
|
|
120 |
|
121 |
+
// only do this stuff on new orders
|
122 |
+
if ($call === 'addStoreOrder') {
|
|
|
|
|
|
|
123 |
|
124 |
+
// apply a campaign id if we have one.
|
125 |
+
if (!empty($this->campaign_id)) {
|
126 |
+
$log .= ' :: campaign id ' . $this->campaign_id;
|
127 |
+
$order->setCampaignId($this->campaign_id);
|
128 |
}
|
129 |
|
130 |
+
// apply the landing site if we have one.
|
131 |
+
if (!empty($this->landing_site)) {
|
132 |
+
$log .= ' :: landing site ' . $this->landing_site;
|
133 |
+
$order->setLandingSite($this->landing_site);
|
|
|
|
|
134 |
}
|
135 |
|
136 |
+
}
|
|
|
|
|
|
|
|
|
137 |
|
138 |
+
// update or create
|
139 |
+
$api_response = $api->$call($store_id, $order, false);
|
140 |
|
141 |
+
if (empty($api_response)) {
|
142 |
+
mailchimp_error('order_submit.failure', "$call :: #{$order->getId()} :: email: {$order->getCustomer()->getEmailAddress()} produced a blank response from MailChimp");
|
143 |
return $api_response;
|
144 |
+
}
|
145 |
|
146 |
+
if ($deleted_abandoned_cart) {
|
147 |
+
$log .= " :: abandoned cart deleted [{$this->cart_session_id}]";
|
148 |
+
}
|
149 |
|
150 |
+
mailchimp_log('order_submit.success', $log);
|
151 |
|
152 |
+
return $api_response;
|
153 |
|
154 |
+
} catch (\Exception $e) {
|
|
|
|
|
|
|
|
|
155 |
|
156 |
+
$message = strtolower($e->getMessage());
|
|
|
157 |
|
158 |
+
mailchimp_error('order_submit.tracing_error', $e);
|
159 |
|
160 |
+
if (!isset($order)) {
|
161 |
+
// transform the order
|
162 |
+
$order = $job->transform(get_post($this->order_id));
|
163 |
+
$this->cart_session_id = $order->getCustomer()->getId();
|
164 |
+
}
|
165 |
+
|
166 |
+
// this can happen when a customer changes their email.
|
167 |
+
if (isset($order) && strpos($message, 'not be changed')) {
|
168 |
|
169 |
+
try {
|
|
|
170 |
|
171 |
+
mailchimp_log('order_submit.deleting_customer', "#{$order->getId()} :: email: {$order->getCustomer()->getEmailAddress()}");
|
|
|
172 |
|
173 |
+
// delete the customer before adding it again.
|
174 |
+
$api->deleteCustomer($store_id, $order->getCustomer()->getId());
|
175 |
|
176 |
+
// update or create
|
177 |
+
$api_response = $api->$call($store_id, $order, false);
|
|
|
178 |
|
179 |
+
$log = "Deleted Customer :: $call :: #{$order->getId()} :: email: {$order->getCustomer()->getEmailAddress()}";
|
180 |
|
181 |
+
if (!empty($job->campaign_id)) {
|
182 |
+
$log .= ' :: campaign id '.$job->campaign_id;
|
183 |
+
}
|
|
|
184 |
|
185 |
+
mailchimp_log('order_submit.success', $log);
|
186 |
|
187 |
+
// if we're adding a new order and the session id is here, we need to delete the AC cart record.
|
188 |
+
if (!empty($this->cart_session_id)) {
|
189 |
+
$api->deleteCartByID($store_id, $this->cart_session_id);
|
190 |
}
|
191 |
+
|
192 |
+
return $api_response;
|
193 |
+
|
194 |
+
} catch (\Exception $e) {
|
195 |
+
mailchimp_error('order_submit.error', mailchimp_error_trace($e, 'deleting-customer-re-add :: #'.$this->order_id));
|
196 |
}
|
197 |
}
|
198 |
}
|
includes/processes/class-mailchimp-woocommerce-single-product.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
-
* Email: ryan@
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
@@ -45,6 +45,11 @@ class MailChimp_WooCommerce_Single_Product extends WP_Job
|
|
45 |
return false;
|
46 |
}
|
47 |
|
|
|
|
|
|
|
|
|
|
|
48 |
if ($this->api()->getStoreProduct($this->store_id, $this->product_id)) {
|
49 |
$this->api()->deleteStoreProduct($this->store_id, $this->product_id);
|
50 |
}
|
4 |
* Created by Vextras.
|
5 |
*
|
6 |
* Name: Ryan Hungate
|
7 |
+
* Email: ryan@vextras.com
|
8 |
* Date: 7/15/16
|
9 |
* Time: 11:42 AM
|
10 |
*/
|
45 |
return false;
|
46 |
}
|
47 |
|
48 |
+
if (!mailchimp_is_configured()) {
|
49 |
+
mailchimp_debug(get_called_class(), 'mailchimp is not configured properly');
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
if ($this->api()->getStoreProduct($this->store_id, $this->product_id)) {
|
54 |
$this->api()->deleteStoreProduct($this->store_id, $this->product_id);
|
55 |
}
|
includes/processes/class-mailchimp-woocommerce-user-submit.php
CHANGED
@@ -40,6 +40,11 @@ class MailChimp_WooCommerce_User_Submit extends WP_Job
|
|
40 |
*/
|
41 |
public function handle()
|
42 |
{
|
|
|
|
|
|
|
|
|
|
|
43 |
$options = get_option('mailchimp-woocommerce', array());
|
44 |
$store_id = mailchimp_get_store_id();
|
45 |
|
40 |
*/
|
41 |
public function handle()
|
42 |
{
|
43 |
+
if (!mailchimp_is_configured()) {
|
44 |
+
mailchimp_debug(get_called_class(), 'mailchimp is not configured properly');
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
|
48 |
$options = get_option('mailchimp-woocommerce', array());
|
49 |
$store_id = mailchimp_get_store_id();
|
50 |
|
mailchimp-woocommerce.php
CHANGED
@@ -10,13 +10,13 @@
|
|
10 |
*
|
11 |
* @link https://mailchimp.com
|
12 |
* @since 1.0.0
|
13 |
-
* @package
|
14 |
*
|
15 |
* @wordpress-plugin
|
16 |
* Plugin Name: MailChimp for WooCommerce
|
17 |
* Plugin URI: https://mailchimp.com/connect-your-store/
|
18 |
* Description: MailChimp - WooCommerce plugin
|
19 |
-
* Version: 2.1.
|
20 |
* Author: MailChimp
|
21 |
* Author URI: https://mailchimp.com
|
22 |
* License: GPL-2.0+
|
@@ -28,484 +28,18 @@
|
|
28 |
*/
|
29 |
|
30 |
// If this file is called directly, abort.
|
31 |
-
if (
|
32 |
die;
|
33 |
}
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
*/
|
38 |
-
function mailchimp_environment_variables() {
|
39 |
-
global $wp_version;
|
40 |
-
|
41 |
-
$o = get_option('mailchimp-woocommerce', false);
|
42 |
-
|
43 |
-
return (object) array(
|
44 |
-
'repo' => 'master',
|
45 |
-
'environment' => 'production',
|
46 |
-
'version' => '2.1.5',
|
47 |
-
'php_version' => phpversion(),
|
48 |
-
'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
|
49 |
-
'wc_version' => class_exists('WC') ? WC()->version : null,
|
50 |
-
'logging' => ($o && is_array($o) && isset($o['mailchimp_logging'])) ? $o['mailchimp_logging'] : 'none',
|
51 |
-
);
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* @return bool
|
56 |
-
*/
|
57 |
-
function mailchimp_should_init_queue() {
|
58 |
-
return mailchimp_detect_admin_ajax() && mailchimp_is_configured() && !mailchimp_running_in_console() && !mailchimp_http_worker_is_running();
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @return bool
|
63 |
-
*/
|
64 |
-
function mailchimp_is_configured() {
|
65 |
-
return (bool) (mailchimp_get_api_key() && mailchimp_get_list_id());
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* @return bool|int
|
70 |
-
*/
|
71 |
-
function mailchimp_get_api_key() {
|
72 |
-
return mailchimp_get_option('mailchimp_api_key', false);
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* @return bool|int
|
77 |
-
*/
|
78 |
-
function mailchimp_get_list_id() {
|
79 |
-
return mailchimp_get_option('mailchimp_list', false);
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @return string
|
84 |
-
*/
|
85 |
-
function mailchimp_get_store_id() {
|
86 |
-
$store_id = mailchimp_get_data('store_id', false);
|
87 |
-
if (empty($store_id)) {
|
88 |
-
mailchimp_set_data('store_id', $store_id = uniqid(), 'yes');
|
89 |
-
}
|
90 |
-
return $store_id;
|
91 |
-
}
|
92 |
-
|
93 |
-
|
94 |
-
/**
|
95 |
-
* @return bool|MailChimp_WooCommerce_MailChimpApi
|
96 |
-
*/
|
97 |
-
function mailchimp_get_api() {
|
98 |
-
if (($key = mailchimp_get_api_key())) {
|
99 |
-
return new MailChimp_WooCommerce_MailChimpApi($key);
|
100 |
-
}
|
101 |
-
return false;
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* @param $key
|
106 |
-
* @param null $default
|
107 |
-
* @return null
|
108 |
-
*/
|
109 |
-
function mailchimp_get_option($key, $default = null) {
|
110 |
-
$options = get_option('mailchimp-woocommerce');
|
111 |
-
if (!is_array($options)) {
|
112 |
-
return $default;
|
113 |
-
}
|
114 |
-
if (!array_key_exists($key, $options)) {
|
115 |
-
return $default;
|
116 |
-
}
|
117 |
-
return $options[$key];
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* @param $key
|
122 |
-
* @param null $default
|
123 |
-
* @return mixed
|
124 |
-
*/
|
125 |
-
function mailchimp_get_data($key, $default = null) {
|
126 |
-
return get_option('mailchimp-woocommerce-'.$key, $default);
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* @param $key
|
131 |
-
* @param $value
|
132 |
-
* @param string $autoload
|
133 |
-
* @return bool
|
134 |
-
*/
|
135 |
-
function mailchimp_set_data($key, $value, $autoload = 'yes') {
|
136 |
-
return update_option('mailchimp-woocommerce-'.$key, $value, $autoload);
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* @param $date
|
141 |
-
* @return DateTime
|
142 |
-
*/
|
143 |
-
function mailchimp_date_utc($date) {
|
144 |
-
$timezone = wc_timezone_string();
|
145 |
-
if (is_numeric($date)) {
|
146 |
-
$stamp = $date;
|
147 |
-
$date = new \DateTime('now', new DateTimeZone($timezone));
|
148 |
-
$date->setTimestamp($stamp);
|
149 |
-
} else {
|
150 |
-
$date = new \DateTime($date, new DateTimeZone($timezone));
|
151 |
-
}
|
152 |
-
|
153 |
-
$date->setTimezone(new DateTimeZone('UTC'));
|
154 |
-
return $date;
|
155 |
-
}
|
156 |
-
|
157 |
-
/**
|
158 |
-
* @param $date
|
159 |
-
* @return DateTime
|
160 |
-
*/
|
161 |
-
function mailchimp_date_local($date) {
|
162 |
-
$timezone = mailchimp_get_option('store_timezone', 'America/New_York');
|
163 |
-
if (is_numeric($date)) {
|
164 |
-
$stamp = $date;
|
165 |
-
$date = new \DateTime('now', new DateTimeZone('UTC'));
|
166 |
-
$date->setTimestamp($stamp);
|
167 |
-
} else {
|
168 |
-
$date = new \DateTime($date, new DateTimeZone('UTC'));
|
169 |
-
}
|
170 |
-
|
171 |
-
$date->setTimezone(new DateTimeZone($timezone));
|
172 |
-
return $date;
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* @param array $data
|
177 |
-
* @return mixed
|
178 |
-
*/
|
179 |
-
function mailchimp_array_remove_empty($data) {
|
180 |
-
if (empty($data) || !is_array($data)) {
|
181 |
-
return array();
|
182 |
-
}
|
183 |
-
foreach ($data as $key => $value) {
|
184 |
-
if ($value === null || $value === '' || (is_array($value) && empty($value))) {
|
185 |
-
unset($data[$key]);
|
186 |
-
}
|
187 |
-
}
|
188 |
-
return $data;
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* @return array
|
193 |
-
*/
|
194 |
-
function mailchimp_get_timezone_list() {
|
195 |
-
$zones_array = array();
|
196 |
-
$timestamp = time();
|
197 |
-
$current = date_default_timezone_get();
|
198 |
-
|
199 |
-
foreach(timezone_identifiers_list() as $key => $zone) {
|
200 |
-
date_default_timezone_set($zone);
|
201 |
-
$zones_array[$key]['zone'] = $zone;
|
202 |
-
$zones_array[$key]['diff_from_GMT'] = 'UTC/GMT ' . date('P', $timestamp);
|
203 |
-
}
|
204 |
-
|
205 |
-
date_default_timezone_set($current);
|
206 |
-
|
207 |
-
return $zones_array;
|
208 |
-
}
|
209 |
-
|
210 |
-
/**
|
211 |
-
* @return bool
|
212 |
-
*/
|
213 |
-
function mailchimp_check_woocommerce_plugin_status()
|
214 |
-
{
|
215 |
-
if (defined("RUNNING_CUSTOM_WOOCOMMERCE") && RUNNING_CUSTOM_WOOCOMMERCE === true) return true;
|
216 |
-
return in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option('active_plugins')));
|
217 |
}
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
* This action is documented in includes/class-mailchimp-woocommerce-activator.php
|
222 |
-
*/
|
223 |
-
function activate_mailchimp_woocommerce() {
|
224 |
-
// if we don't have woocommerce we need to display a horrible error message before the plugin is installed.
|
225 |
-
if (!mailchimp_check_woocommerce_plugin_status()) {
|
226 |
-
// Deactivate the plugin
|
227 |
-
deactivate_plugins(__FILE__);
|
228 |
-
$error_message = __('The MailChimp For WooCommerce plugin requires the <a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a> plugin to be active!', 'woocommerce');
|
229 |
-
wp_die($error_message);
|
230 |
-
}
|
231 |
-
|
232 |
-
// ok we can activate this thing.
|
233 |
-
require_once plugin_dir_path( __FILE__ ) . 'includes/class-mailchimp-woocommerce-activator.php';
|
234 |
-
|
235 |
-
MailChimp_Woocommerce_Activator::activate();
|
236 |
-
}
|
237 |
-
|
238 |
-
/**
|
239 |
-
* Create the queue tables
|
240 |
-
*/
|
241 |
-
function install_mailchimp_queue() {
|
242 |
-
require_once plugin_dir_path( __FILE__ ) . 'includes/class-mailchimp-woocommerce-activator.php';
|
243 |
-
MailChimp_Woocommerce_Activator::create_queue_tables();
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* The code that runs during plugin deactivation.
|
248 |
-
* This action is documented in includes/class-mailchimp-woocommerce-deactivator.php
|
249 |
-
*/
|
250 |
-
function deactivate_mailchimp_woocommerce() {
|
251 |
-
require_once plugin_dir_path( __FILE__ ) . 'includes/class-mailchimp-woocommerce-deactivator.php';
|
252 |
-
MailChimp_Woocommerce_Deactivator::deactivate();
|
253 |
-
}
|
254 |
-
|
255 |
-
/**
|
256 |
-
* @param $action
|
257 |
-
* @param $message
|
258 |
-
* @param null $data
|
259 |
-
*/
|
260 |
-
function mailchimp_debug($action, $message, $data = null) {
|
261 |
-
if (mailchimp_environment_variables()->logging === 'debug') {
|
262 |
-
if (is_array($data) && !empty($data)) $message .= " :: ".wc_print_r($data, true);
|
263 |
-
wc_get_logger()->debug("{$action} :: {$message}", array('source' => 'mailchimp_woocommerce'));
|
264 |
-
}
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* @param $action
|
269 |
-
* @param $message
|
270 |
-
* @param array $data
|
271 |
-
* @return array|WP_Error
|
272 |
-
*/
|
273 |
-
function mailchimp_log($action, $message, $data = array()) {
|
274 |
-
if (mailchimp_environment_variables()->logging !== 'none') {
|
275 |
-
if (is_array($data) && !empty($data)) $message .= " :: ".wc_print_r($data, true);
|
276 |
-
wc_get_logger()->notice("{$action} :: {$message}", array('source' => 'mailchimp_woocommerce'));
|
277 |
-
}
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* @param $action
|
282 |
-
* @param $message
|
283 |
-
* @param array $data
|
284 |
-
* @return array|WP_Error
|
285 |
-
*/
|
286 |
-
function mailchimp_error($action, $message, $data = array()) {
|
287 |
-
if (mailchimp_environment_variables()->logging !== 'none') {
|
288 |
-
if ($message instanceof \Exception) $message = mailchimp_error_trace($message);
|
289 |
-
if (is_array($data) && !empty($data)) $message .= " :: ".wc_print_r($data, true);
|
290 |
-
wc_get_logger()->error("{$action} :: {$message}", array('source' => 'mailchimp_woocommerce'));
|
291 |
-
}
|
292 |
-
}
|
293 |
-
|
294 |
-
/**
|
295 |
-
* @param Exception $e
|
296 |
-
* @param string $wrap
|
297 |
-
* @return string
|
298 |
-
*/
|
299 |
-
function mailchimp_error_trace(\Exception $e, $wrap = "") {
|
300 |
-
$error = "{$e->getMessage()} on {$e->getLine()} in {$e->getFile()}";
|
301 |
-
if (empty($wrap)) return $error;
|
302 |
-
return "{$wrap} :: {$error}";
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Determine if a given string contains a given substring.
|
307 |
-
*
|
308 |
-
* @param string $haystack
|
309 |
-
* @param string|array $needles
|
310 |
-
* @return bool
|
311 |
-
*/
|
312 |
-
function mailchimp_string_contains($haystack, $needles) {
|
313 |
-
foreach ((array) $needles as $needle) {
|
314 |
-
if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
|
315 |
-
return true;
|
316 |
-
}
|
317 |
-
}
|
318 |
-
|
319 |
-
return false;
|
320 |
-
}
|
321 |
-
|
322 |
-
|
323 |
-
/**
|
324 |
-
* @return int
|
325 |
-
*/
|
326 |
-
function mailchimp_get_product_count() {
|
327 |
-
$posts = mailchimp_count_posts('product');
|
328 |
-
unset($posts['auto-draft'], $posts['trash']);
|
329 |
-
$total = 0;
|
330 |
-
foreach ($posts as $status => $count) {
|
331 |
-
$total += $count;
|
332 |
-
}
|
333 |
-
return $total;
|
334 |
-
}
|
335 |
-
|
336 |
-
/**
|
337 |
-
* @return int
|
338 |
-
*/
|
339 |
-
function mailchimp_get_order_count() {
|
340 |
-
$posts = mailchimp_count_posts('shop_order');
|
341 |
-
unset($posts['auto-draft'], $posts['trash']);
|
342 |
-
$total = 0;
|
343 |
-
foreach ($posts as $status => $count) {
|
344 |
-
$total += $count;
|
345 |
-
}
|
346 |
-
return $total;
|
347 |
-
}
|
348 |
-
|
349 |
-
/**
|
350 |
-
* @param $type
|
351 |
-
* @return array|null|object
|
352 |
-
*/
|
353 |
-
function mailchimp_count_posts($type) {
|
354 |
-
global $wpdb;
|
355 |
-
$query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s GROUP BY post_status";
|
356 |
-
$posts = $wpdb->get_results( $wpdb->prepare($query, $type));
|
357 |
-
$response = array();
|
358 |
-
foreach ($posts as $post) {
|
359 |
-
$response[$post->post_status] = $post->num_posts;
|
360 |
-
}
|
361 |
-
return $response;
|
362 |
-
}
|
363 |
-
|
364 |
-
/**
|
365 |
-
* @return bool
|
366 |
-
*/
|
367 |
-
function mailchimp_update_connected_site_script() {
|
368 |
-
// pull the store ID
|
369 |
-
$store_id = mailchimp_get_store_id();
|
370 |
-
|
371 |
-
// if the api is configured
|
372 |
-
if ($store_id && ($api = mailchimp_get_api())) {
|
373 |
-
|
374 |
-
// if we have a store
|
375 |
-
if (($store = $api->getStore($store_id))) {
|
376 |
-
|
377 |
-
// handle the coupon sync if we don't have a flag that says otherwise.
|
378 |
-
$job = new MailChimp_WooCommerce_Process_Coupons();
|
379 |
-
if ($job->getData('sync.coupons.completed_at', false) === false) {
|
380 |
-
wp_queue($job);
|
381 |
-
}
|
382 |
-
|
383 |
-
// see if we have a connected site script url/fragment
|
384 |
-
$url = $store->getConnectedSiteScriptUrl();
|
385 |
-
$fragment = $store->getConnectedSiteScriptFragment();
|
386 |
-
|
387 |
-
// if it's not empty we need to set the values
|
388 |
-
if ($url && $fragment) {
|
389 |
-
|
390 |
-
// update the options for script_url and script_fragment
|
391 |
-
update_option('mailchimp-woocommerce-script_url', $url);
|
392 |
-
update_option('mailchimp-woocommerce-script_fragment', $fragment);
|
393 |
-
|
394 |
-
// check to see if the site is connected
|
395 |
-
if (!$api->checkConnectedSite($store_id)) {
|
396 |
-
|
397 |
-
// if it's not, connect it now.
|
398 |
-
$api->connectSite($store_id);
|
399 |
-
}
|
400 |
-
|
401 |
-
return true;
|
402 |
-
}
|
403 |
-
}
|
404 |
-
}
|
405 |
-
return false;
|
406 |
-
}
|
407 |
-
|
408 |
-
/**
|
409 |
-
* @return bool
|
410 |
-
*/
|
411 |
-
function mailchimp_detect_admin_ajax() {
|
412 |
-
if (defined('DOING_CRON') && DOING_CRON) return true;
|
413 |
-
if (!is_admin()) return false;
|
414 |
-
if (!defined('DOING_AJAX')) return false;
|
415 |
-
return DOING_AJAX;
|
416 |
-
}
|
417 |
-
|
418 |
-
/**
|
419 |
-
* @return string|false
|
420 |
-
*/
|
421 |
-
function mailchimp_get_connected_site_script_url() {
|
422 |
-
return get_option('mailchimp-woocommerce-script_url', false);
|
423 |
-
}
|
424 |
-
|
425 |
-
/**
|
426 |
-
* @return string|false
|
427 |
-
*/
|
428 |
-
function mailchimp_get_connected_site_script_fragment() {
|
429 |
-
return get_option('mailchimp-woocommerce-script_fragment', false);
|
430 |
-
}
|
431 |
-
|
432 |
-
/**
|
433 |
-
* @return bool
|
434 |
-
*/
|
435 |
-
function mailchimp_running_in_console() {
|
436 |
-
return (bool) (defined( 'DISABLE_WP_HTTP_WORKER' ) && true === DISABLE_WP_HTTP_WORKER);
|
437 |
-
}
|
438 |
-
|
439 |
-
/**
|
440 |
-
* @return bool
|
441 |
-
*/
|
442 |
-
function mailchimp_http_worker_is_running() {
|
443 |
-
return (bool) get_site_transient('http_worker_lock');
|
444 |
-
}
|
445 |
-
|
446 |
-
/**
|
447 |
-
* @return array|WP_Error
|
448 |
-
*/
|
449 |
-
function mailchimp_call_http_worker_manually() {
|
450 |
-
$action = 'http_worker';
|
451 |
-
$query_args = apply_filters('http_worker_query_args', array(
|
452 |
-
'action' => $action,
|
453 |
-
'nonce' => wp_create_nonce($action),
|
454 |
-
));
|
455 |
-
$query_url = apply_filters('http_worker_query_url', admin_url('admin-ajax.php'));
|
456 |
-
$post_args = apply_filters('http_worker_post_args', array(
|
457 |
-
'timeout' => 0.01,
|
458 |
-
'blocking' => false,
|
459 |
-
'cookies' => $_COOKIE,
|
460 |
-
'sslverify' => apply_filters('https_local_ssl_verify', false),
|
461 |
-
));
|
462 |
-
$url = add_query_arg($query_args, $query_url);
|
463 |
-
return wp_remote_post(esc_url_raw($url), $post_args);
|
464 |
-
}
|
465 |
-
|
466 |
-
register_activation_hook( __FILE__, 'activate_mailchimp_woocommerce' );
|
467 |
-
|
468 |
-
// cancelling out the deactivation hook code for now.
|
469 |
-
//register_deactivation_hook( __FILE__, 'deactivate_mailchimp_woocommerce' );
|
470 |
-
|
471 |
-
/**
|
472 |
-
*
|
473 |
-
* Begins execution of the plugin.
|
474 |
-
*
|
475 |
-
* Since everything within the plugin is registered via hooks,
|
476 |
-
* then kicking off the plugin from this point in the file does
|
477 |
-
* not affect the page life cycle.
|
478 |
-
*
|
479 |
-
* @since 1.0.0
|
480 |
-
*/
|
481 |
-
function run_mailchimp_woocommerce() {
|
482 |
-
$env = mailchimp_environment_variables();
|
483 |
-
$plugin = new MailChimp_Woocommerce($env->environment, $env->version);
|
484 |
-
$plugin->run();
|
485 |
-
}
|
486 |
|
487 |
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
488 |
$forwarded_address = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
|
489 |
$_SERVER['REMOTE_ADDR'] = $forwarded_address[0];
|
490 |
}
|
491 |
-
|
492 |
-
function mailchimp_woocommerce_add_meta_tags() {
|
493 |
-
echo '<meta name="referrer" content="always"/>';
|
494 |
-
}
|
495 |
-
|
496 |
-
function mailchimp_on_all_plugins_loaded() {
|
497 |
-
if (mailchimp_check_woocommerce_plugin_status()) {
|
498 |
-
|
499 |
-
/**
|
500 |
-
* The core plugin class that is used to define internationalization,
|
501 |
-
* admin-specific hooks, and public-facing site hooks.
|
502 |
-
*/
|
503 |
-
require plugin_dir_path( __FILE__ ) . 'includes/class-mailchimp-woocommerce.php';
|
504 |
-
|
505 |
-
add_action('wp_head', 'mailchimp_woocommerce_add_meta_tags');
|
506 |
-
/** Add all the MailChimp hooks. */
|
507 |
-
run_mailchimp_woocommerce();
|
508 |
-
}
|
509 |
-
}
|
510 |
-
|
511 |
-
add_action( 'plugins_loaded', 'mailchimp_on_all_plugins_loaded' );
|
10 |
*
|
11 |
* @link https://mailchimp.com
|
12 |
* @since 1.0.0
|
13 |
+
* @package MailChimp_WooCommerce
|
14 |
*
|
15 |
* @wordpress-plugin
|
16 |
* Plugin Name: MailChimp for WooCommerce
|
17 |
* Plugin URI: https://mailchimp.com/connect-your-store/
|
18 |
* Description: MailChimp - WooCommerce plugin
|
19 |
+
* Version: 2.1.6
|
20 |
* Author: MailChimp
|
21 |
* Author URI: https://mailchimp.com
|
22 |
* License: GPL-2.0+
|
28 |
*/
|
29 |
|
30 |
// If this file is called directly, abort.
|
31 |
+
if (!defined( 'WPINC')) {
|
32 |
die;
|
33 |
}
|
34 |
|
35 |
+
if (!isset($mailchimp_woocommerce_spl_autoloader) || $mailchimp_woocommerce_spl_autoloader === false) {
|
36 |
+
include_once "bootstrap.php";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
+
register_activation_hook( __FILE__, 'activate_mailchimp_woocommerce');
|
40 |
+
add_action('plugins_loaded', 'mailchimp_on_all_plugins_loaded');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
43 |
$forwarded_address = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
|
44 |
$_SERVER['REMOTE_ADDR'] = $forwarded_address[0];
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public/class-mailchimp-woocommerce-public.php
CHANGED
@@ -6,8 +6,8 @@
|
|
6 |
* @link https://mailchimp.com
|
7 |
* @since 1.0.1
|
8 |
*
|
9 |
-
* @package
|
10 |
-
* @subpackage
|
11 |
*/
|
12 |
|
13 |
/**
|
@@ -16,11 +16,11 @@
|
|
16 |
* Defines the plugin name, version, and two examples hooks for how to
|
17 |
* enqueue the admin-specific stylesheet and JavaScript.
|
18 |
*
|
19 |
-
* @package
|
20 |
-
* @subpackage
|
21 |
-
* @author Ryan Hungate <ryan@
|
22 |
*/
|
23 |
-
class
|
24 |
|
25 |
/**
|
26 |
* The ID of this plugin.
|
@@ -59,19 +59,6 @@ class MailChimp_Woocommerce_Public {
|
|
59 |
* @since 1.0.0
|
60 |
*/
|
61 |
public function enqueue_styles() {
|
62 |
-
|
63 |
-
/**
|
64 |
-
* This function is provided for demonstration purposes only.
|
65 |
-
*
|
66 |
-
* An instance of this class should be passed to the run() function
|
67 |
-
* defined in MailChimp_Woocommerce_Loader as all of the hooks are defined
|
68 |
-
* in that particular class.
|
69 |
-
*
|
70 |
-
* The MailChimp_Woocommerce_Loader will then create the relationship
|
71 |
-
* between the defined hooks and the functions defined in this
|
72 |
-
* class.
|
73 |
-
*/
|
74 |
-
|
75 |
//wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/mailchimp-woocommerce-public.css', array(), $this->version, 'all' );
|
76 |
}
|
77 |
|
@@ -81,30 +68,14 @@ class MailChimp_Woocommerce_Public {
|
|
81 |
* @since 1.0.0
|
82 |
*/
|
83 |
public function enqueue_scripts() {
|
84 |
-
|
85 |
-
/**
|
86 |
-
* This function is provided for demonstration purposes only.
|
87 |
-
*
|
88 |
-
* An instance of this class should be passed to the run() function
|
89 |
-
* defined in MailChimp_Woocommerce_Loader as all of the hooks are defined
|
90 |
-
* in that particular class.
|
91 |
-
*
|
92 |
-
* The MailChimp_Woocommerce_Loader will then create the relationship
|
93 |
-
* between the defined hooks and the functions defined in this
|
94 |
-
* class.
|
95 |
-
*/
|
96 |
-
|
97 |
wp_register_script($this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mailchimp-woocommerce-public.min.js', array(), $this->version, false);
|
98 |
-
|
99 |
wp_localize_script($this->plugin_name, 'mailchimp_public_data', array(
|
100 |
'site_url' => site_url(),
|
101 |
'ajax_url' => admin_url('admin-ajax.php'),
|
102 |
));
|
103 |
-
|
104 |
// Enqueued script with localized data.
|
105 |
wp_enqueue_script($this->plugin_name);
|
106 |
-
|
107 |
-
// if we have the connected_site script url saved, we need to inject it
|
108 |
if (($site = mailchimp_get_connected_site_script_url()) && !empty($site)) {
|
109 |
wp_enqueue_script($this->plugin_name.'_connected_site', $site, array(), $this->version, true);
|
110 |
}
|
6 |
* @link https://mailchimp.com
|
7 |
* @since 1.0.1
|
8 |
*
|
9 |
+
* @package MailChimp_WooCommerce
|
10 |
+
* @subpackage MailChimp_WooCommerce/public
|
11 |
*/
|
12 |
|
13 |
/**
|
16 |
* Defines the plugin name, version, and two examples hooks for how to
|
17 |
* enqueue the admin-specific stylesheet and JavaScript.
|
18 |
*
|
19 |
+
* @package MailChimp_WooCommerce
|
20 |
+
* @subpackage MailChimp_WooCommerce/public
|
21 |
+
* @author Ryan Hungate <ryan@vextras.com>
|
22 |
*/
|
23 |
+
class MailChimp_WooCommerce_Public {
|
24 |
|
25 |
/**
|
26 |
* The ID of this plugin.
|
59 |
* @since 1.0.0
|
60 |
*/
|
61 |
public function enqueue_styles() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
//wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/mailchimp-woocommerce-public.css', array(), $this->version, 'all' );
|
63 |
}
|
64 |
|
68 |
* @since 1.0.0
|
69 |
*/
|
70 |
public function enqueue_scripts() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
wp_register_script($this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/mailchimp-woocommerce-public.min.js', array(), $this->version, false);
|
|
|
72 |
wp_localize_script($this->plugin_name, 'mailchimp_public_data', array(
|
73 |
'site_url' => site_url(),
|
74 |
'ajax_url' => admin_url('admin-ajax.php'),
|
75 |
));
|
|
|
76 |
// Enqueued script with localized data.
|
77 |
wp_enqueue_script($this->plugin_name);
|
78 |
+
//if we have the connected_site script url saved, we need to inject it
|
|
|
79 |
if (($site = mailchimp_get_connected_site_script_url()) && !empty($site)) {
|
80 |
wp_enqueue_script($this->plugin_name.'_connected_site', $site, array(), $this->version, true);
|
81 |
}
|
public/js/mailchimp-woocommerce-public.js
CHANGED
@@ -1,59 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
function mailchimpGetCurrentUserByHash(a) {
|
2 |
try {
|
3 |
var b = mailchimp_public_data.ajax_url + "?action=mailchimp_get_user_by_hash&hash=" + a, c = new XMLHttpRequest;
|
4 |
c.open("POST", b, !0), c.onload = function () {
|
5 |
if (c.status >= 200 && c.status < 400) {
|
6 |
var a = JSON.parse(c.responseText);
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
10 |
console.log("mailchimp.get_email_by_hash.request.error", c.responseText)
|
11 |
-
}
|
|
|
|
|
|
|
12 |
} catch (a) {
|
13 |
console.log("mailchimp.get_email_by_hash.error", a)
|
14 |
}
|
15 |
}
|
16 |
function mailchimpHandleBillingEmail(selector) {
|
17 |
-
if (!selector) selector = "#billing_email";
|
18 |
-
var a = document.querySelector(selector);b = void 0 !== a ? a.value : "";
|
19 |
-
if (!mailchimp_cart.valueEmail(b)) { return false; }
|
20 |
-
if (mailchimp_submitted_email === b) { return "already submitted " + b; }
|
21 |
-
mailchimp_cart.setEmail(b);
|
22 |
try {
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
console.log("mailchimp.handle_billing_email.request.error", d.responseText)
|
28 |
-
}
|
|
|
|
|
|
|
29 |
return true;
|
30 |
} catch (a) {
|
31 |
-
console.log("mailchimp.handle_billing_email.error", a)
|
32 |
}
|
33 |
}
|
34 |
|
35 |
-
var mailchimp, mailchimp_cart, mailchimp_billing_email, mailchimp_username_email, mailchimp_registration_email, mailchimp_submitted_email = !1, mailchimpReady = function (a) {
|
36 |
-
/in/.test(document.readyState) ? setTimeout("mailchimpReady(" + a + ")", 9) : a()
|
37 |
-
};
|
38 |
-
|
39 |
!function () {
|
40 |
"use strict";
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
var a = mailchimp.storage.get("mailchimp.cart.current_email", !1);
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
|
59 |
var g = {
|
@@ -131,7 +168,7 @@ var mailchimp, mailchimp_cart, mailchimp_billing_email, mailchimp_username_email
|
|
131 |
}(document);
|
132 |
|
133 |
mailchimp = {storage: h, utils: g};
|
134 |
-
mailchimp_cart = new
|
135 |
}();
|
136 |
|
137 |
mailchimpReady(function () {
|
@@ -140,25 +177,29 @@ mailchimpReady(function () {
|
|
140 |
var a = { site_url: document.location.origin, defaulted: !0, ajax_url: document.location.origin + "/wp-admin?admin-ajax.php" };
|
141 |
}
|
142 |
|
143 |
-
|
144 |
-
|
|
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
163 |
}
|
164 |
});
|
1 |
+
var mailchimp,
|
2 |
+
mailchimp_cart,
|
3 |
+
mailchimp_billing_email,
|
4 |
+
mailchimp_username_email,
|
5 |
+
mailchimp_registration_email,
|
6 |
+
mailchimp_submitted_email = false,
|
7 |
+
mailchimpReady = function (a) { /in/.test(document.readyState) ? setTimeout("mailchimpReady(" + a + ")", 9) : a(); };
|
8 |
+
|
9 |
function mailchimpGetCurrentUserByHash(a) {
|
10 |
try {
|
11 |
var b = mailchimp_public_data.ajax_url + "?action=mailchimp_get_user_by_hash&hash=" + a, c = new XMLHttpRequest;
|
12 |
c.open("POST", b, !0), c.onload = function () {
|
13 |
if (c.status >= 200 && c.status < 400) {
|
14 |
var a = JSON.parse(c.responseText);
|
15 |
+
if (!a) return;
|
16 |
+
mailchimp_cart.valueEmail(a.email) && mailchimp_cart.setEmail(a.email);
|
17 |
+
}
|
18 |
+
};
|
19 |
+
c.onerror = function () {
|
20 |
console.log("mailchimp.get_email_by_hash.request.error", c.responseText)
|
21 |
+
};
|
22 |
+
c.setRequestHeader("Content-Type", "application/json");
|
23 |
+
c.setRequestHeader("Accept", "application/json");
|
24 |
+
c.send();
|
25 |
} catch (a) {
|
26 |
console.log("mailchimp.get_email_by_hash.error", a)
|
27 |
}
|
28 |
}
|
29 |
function mailchimpHandleBillingEmail(selector) {
|
|
|
|
|
|
|
|
|
|
|
30 |
try {
|
31 |
+
if (!selector) selector = "#billing_email";
|
32 |
+
var a = document.querySelector(selector);
|
33 |
+
var b = void 0 !== a ? a.value : "";
|
34 |
+
if (!mailchimp_cart.valueEmail(b) || mailchimp_submitted_email === b) { return false; }
|
35 |
+
mailchimp_cart.setEmail(b);
|
36 |
+
var c = mailchimp_public_data.ajax_url + "?action=mailchimp_set_user_by_email&email=" + b;
|
37 |
+
var d = new XMLHttpRequest;
|
38 |
+
d.open("POST", c, !0);
|
39 |
+
d.onload = function () {
|
40 |
+
var successful = d.status >= 200 && d.status < 400;
|
41 |
+
var msg = successful ? "mailchimp.handle_billing_email.request.success" : "mailchimp.handle_billing_email.request.error";
|
42 |
+
if (successful) {
|
43 |
+
mailchimp_submitted_email = b;
|
44 |
+
}
|
45 |
+
console.log(msg, d.responseText);
|
46 |
+
};
|
47 |
+
d.onerror = function () {
|
48 |
console.log("mailchimp.handle_billing_email.request.error", d.responseText)
|
49 |
+
};
|
50 |
+
d.setRequestHeader("Content-Type", "application/json");
|
51 |
+
d.setRequestHeader("Accept", "application/json");
|
52 |
+
d.send();
|
53 |
return true;
|
54 |
} catch (a) {
|
55 |
+
console.log("mailchimp.handle_billing_email.error", a); mailchimp_submitted_email = !1
|
56 |
}
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
59 |
!function () {
|
60 |
"use strict";
|
61 |
+
|
62 |
+
function mailchimpCart() {
|
63 |
+
|
64 |
+
this.email_types = "input[type=email]";
|
65 |
+
this.regex_email = /^([A-Za-z0-9_+\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
|
66 |
+
this.current_email = null;
|
67 |
+
this.previous_email = null;
|
68 |
+
this.expireUser = function () {
|
69 |
+
this.current_email = null;
|
70 |
+
mailchimp.storage.expire("mailchimp.cart.current_email");
|
71 |
+
};
|
72 |
+
this.expireSaved = function () {
|
73 |
+
mailchimp.storage.expire("mailchimp.cart.items");
|
74 |
+
};
|
75 |
+
this.setEmail = function (a) {
|
76 |
+
if (!this.valueEmail(a)) return false;
|
77 |
+
this.setPreviousEmail(this.getEmail());
|
78 |
+
mailchimp.storage.set("mailchimp.cart.current_email", this.current_email = a);
|
79 |
+
};
|
80 |
+
this.getEmail = function () {
|
81 |
+
if (this.current_email) return this.current_email;
|
82 |
var a = mailchimp.storage.get("mailchimp.cart.current_email", !1);
|
83 |
+
if (!a || !this.valueEmail(a)) return false;
|
84 |
+
return this.current_email = a;
|
85 |
+
};
|
86 |
+
this.setPreviousEmail = function (a) {
|
87 |
+
if (!this.valueEmail(a)) return false;
|
88 |
+
mailchimp.storage.set("mailchimp.cart.previous_email", this.previous_email = a);
|
89 |
+
};
|
90 |
+
this.valueEmail = function (a) {
|
91 |
+
return this.regex_email.test(a);
|
92 |
+
};
|
93 |
+
return this;
|
94 |
}
|
95 |
|
96 |
var g = {
|
168 |
}(document);
|
169 |
|
170 |
mailchimp = {storage: h, utils: g};
|
171 |
+
mailchimp_cart = new mailchimpCart;
|
172 |
}();
|
173 |
|
174 |
mailchimpReady(function () {
|
177 |
var a = { site_url: document.location.origin, defaulted: !0, ajax_url: document.location.origin + "/wp-admin?admin-ajax.php" };
|
178 |
}
|
179 |
|
180 |
+
try {
|
181 |
+
var b = mailchimp.utils.getQueryStringVars();
|
182 |
+
void 0 !== b.mc_cart_id && mailchimpGetCurrentUserByHash(b.mc_cart_id);
|
183 |
|
184 |
+
mailchimp_username_email = document.querySelector("#username");
|
185 |
+
mailchimp_billing_email = document.querySelector("#billing_email");
|
186 |
+
mailchimp_registration_email = document.querySelector("#reg_email");
|
187 |
|
188 |
+
if (mailchimp_billing_email) {
|
189 |
+
mailchimp_billing_email.onblur = function () { mailchimpHandleBillingEmail('#billing_email'); };
|
190 |
+
mailchimp_billing_email.onfocus = function () { mailchimpHandleBillingEmail('#billing_email'); }
|
191 |
+
}
|
192 |
|
193 |
+
if (mailchimp_username_email) {
|
194 |
+
mailchimp_username_email.onblur = function () { mailchimpHandleBillingEmail('#username'); };
|
195 |
+
mailchimp_username_email.onfocus = function () { mailchimpHandleBillingEmail('#username'); }
|
196 |
+
}
|
197 |
|
198 |
+
if (mailchimp_registration_email) {
|
199 |
+
mailchimp_registration_email.onblur = function () { mailchimpHandleBillingEmail('#reg_email'); };
|
200 |
+
mailchimp_registration_email.onfocus = function () { mailchimpHandleBillingEmail('#reg_email'); }
|
201 |
+
}
|
202 |
+
} catch (e) {
|
203 |
+
console.log('mailchimp ready error', e);
|
204 |
}
|
205 |
});
|
public/js/mailchimp-woocommerce-public.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function mailchimpGetCurrentUserByHash(e){try{var i=mailchimp_public_data.ajax_url+"?action=mailchimp_get_user_by_hash&hash="+e,a=new XMLHttpRequest;a.open("POST",i,!0),a.onload=function(){if(a.status>=200&&a.status<400){var e=JSON.parse(a.responseText);mailchimp_cart.valueEmail(e.email)&&
|
1 |
+
var mailchimp,mailchimp_cart,mailchimp_billing_email,mailchimp_username_email,mailchimp_registration_email,mailchimp_submitted_email=!1,mailchimpReady=function(e){/in/.test(document.readyState)?setTimeout("mailchimpReady("+e+")",9):e()};function mailchimpGetCurrentUserByHash(e){try{var i=mailchimp_public_data.ajax_url+"?action=mailchimp_get_user_by_hash&hash="+e,a=new XMLHttpRequest;a.open("POST",i,!0),a.onload=function(){if(a.status>=200&&a.status<400){var e=JSON.parse(a.responseText);if(!e)return;mailchimp_cart.valueEmail(e.email)&&mailchimp_cart.setEmail(e.email)}},a.onerror=function(){console.log("mailchimp.get_email_by_hash.request.error",a.responseText)},a.setRequestHeader("Content-Type","application/json"),a.setRequestHeader("Accept","application/json"),a.send()}catch(e){console.log("mailchimp.get_email_by_hash.error",e)}}function mailchimpHandleBillingEmail(e){try{e||(e="#billing_email");var i=document.querySelector(e),a=void 0!==i?i.value:"";if(!mailchimp_cart.valueEmail(a)||mailchimp_submitted_email===a)return!1;mailchimp_cart.setEmail(a);var t=mailchimp_public_data.ajax_url+"?action=mailchimp_set_user_by_email&email="+a,n=new XMLHttpRequest;return n.open("POST",t,!0),n.onload=function(){var e=n.status>=200&&n.status<400,i=e?"mailchimp.handle_billing_email.request.success":"mailchimp.handle_billing_email.request.error";e&&(mailchimp_submitted_email=a),console.log(i,n.responseText)},n.onerror=function(){console.log("mailchimp.handle_billing_email.request.error",n.responseText)},n.setRequestHeader("Content-Type","application/json"),n.setRequestHeader("Accept","application/json"),n.send(),!0}catch(i){console.log("mailchimp.handle_billing_email.error",i),mailchimp_submitted_email=!1}}!function(){"use strict";var e,i,a,t,n={extend:function(e,i){for(var a in i||{})i.hasOwnProperty(a)&&(e[a]=i[a]);return e},getQueryStringVars:function(){var e=window.location.search||"",i=[],a={};if((e=e.substr(1)).length){i=e.split("&");for(var t in i){var n=i[t];if("string"==typeof n){var l=n.split("="),r=l[0],m=l[1];r.length&&(void 0===a[r]&&(a[r]=[]),a[r].push(m))}}}return a},unEscape:function(e){return decodeURIComponent(e)},escape:function(e){return encodeURIComponent(e)},createDate:function(e,i){e||(e=0);var a=new Date,t=i?a.getDate()-e:a.getDate()+e;return a.setDate(t),a},arrayUnique:function(e){for(var i=e.concat(),a=0;a<i.length;++a)for(var t=a+1;t<i.length;++t)i[a]===i[t]&&i.splice(t,1);return i},objectCombineUnique:function(e){for(var i=e[0],a=1;a<e.length;a++){var t=e[a];for(var n in t)i[n]=t[n]}return i}},l=(e=document,(t=function(e,i,a){return 1===arguments.length?t.get(e):t.set(e,i,a)}).get=function(i,a){return e.cookie!==t._cacheString&&t._populateCache(),void 0==t._cache[i]?a:t._cache[i]},t.defaults={path:"/"},t.set=function(a,n,l){switch(l={path:l&&l.path||t.defaults.path,domain:l&&l.domain||t.defaults.domain,expires:l&&l.expires||t.defaults.expires,secure:l&&l.secure!==i?l.secure:t.defaults.secure},n===i&&(l.expires=-1),typeof l.expires){case"number":l.expires=new Date((new Date).getTime()+1e3*l.expires);break;case"string":l.expires=new Date(l.expires)}return a=encodeURIComponent(a)+"="+(n+"").replace(/[^!#-+\--:<-\[\]-~]/g,encodeURIComponent),a+=l.path?";path="+l.path:"",a+=l.domain?";domain="+l.domain:"",a+=l.expires?";expires="+l.expires.toGMTString():"",a+=l.secure?";secure":"",e.cookie=a,t},t.expire=function(e,a){return t.set(e,i,a)},t._populateCache=function(){t._cache={};try{t._cacheString=e.cookie;for(var a=t._cacheString.split("; "),n=0;n<a.length;n++){var l=a[n].indexOf("="),r=decodeURIComponent(a[n].substr(0,l));l=decodeURIComponent(a[n].substr(l+1)),t._cache[r]===i&&(t._cache[r]=l)}}catch(e){console.log(e)}},t.enabled=(a="1"===t.set("cookies.js","1").get("cookies.js"),t.expire("cookies.js"),a),t);mailchimp={storage:l,utils:n},mailchimp_cart=new function(){return this.email_types="input[type=email]",this.regex_email=/^([A-Za-z0-9_+\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,this.current_email=null,this.previous_email=null,this.expireUser=function(){this.current_email=null,mailchimp.storage.expire("mailchimp.cart.current_email")},this.expireSaved=function(){mailchimp.storage.expire("mailchimp.cart.items")},this.setEmail=function(e){if(!this.valueEmail(e))return!1;this.setPreviousEmail(this.getEmail()),mailchimp.storage.set("mailchimp.cart.current_email",this.current_email=e)},this.getEmail=function(){if(this.current_email)return this.current_email;var e=mailchimp.storage.get("mailchimp.cart.current_email",!1);return!(!e||!this.valueEmail(e))&&(this.current_email=e)},this.setPreviousEmail=function(e){if(!this.valueEmail(e))return!1;mailchimp.storage.set("mailchimp.cart.previous_email",this.previous_email=e)},this.valueEmail=function(e){return this.regex_email.test(e)},this}}(),mailchimpReady(function(){if(void 0===e)var e={site_url:document.location.origin,defaulted:!0,ajax_url:document.location.origin+"/wp-admin?admin-ajax.php"};try{var i=mailchimp.utils.getQueryStringVars();void 0!==i.mc_cart_id&&mailchimpGetCurrentUserByHash(i.mc_cart_id),mailchimp_username_email=document.querySelector("#username"),mailchimp_billing_email=document.querySelector("#billing_email"),mailchimp_registration_email=document.querySelector("#reg_email"),mailchimp_billing_email&&(mailchimp_billing_email.onblur=function(){mailchimpHandleBillingEmail("#billing_email")},mailchimp_billing_email.onfocus=function(){mailchimpHandleBillingEmail("#billing_email")}),mailchimp_username_email&&(mailchimp_username_email.onblur=function(){mailchimpHandleBillingEmail("#username")},mailchimp_username_email.onfocus=function(){mailchimpHandleBillingEmail("#username")}),mailchimp_registration_email&&(mailchimp_registration_email.onblur=function(){mailchimpHandleBillingEmail("#reg_email")},mailchimp_registration_email.onfocus=function(){mailchimpHandleBillingEmail("#reg_email")})}catch(e){console.log("mailchimp ready error",e)}});
|
public/partials/mailchimp-woocommerce-public-display.php
CHANGED
@@ -8,8 +8,8 @@
|
|
8 |
* @link https://mailchimp.com
|
9 |
* @since 1.0.1
|
10 |
*
|
11 |
-
* @package
|
12 |
-
* @subpackage
|
13 |
*/
|
14 |
?>
|
15 |
|
8 |
* @link https://mailchimp.com
|
9 |
* @since 1.0.1
|
10 |
*
|
11 |
+
* @package MailChimp_WooCommerce
|
12 |
+
* @subpackage MailChimp_WooCommerce/public/partials
|
13 |
*/
|
14 |
?>
|
15 |
|
uninstall.php
CHANGED
@@ -22,46 +22,23 @@
|
|
22 |
* @link https://mailchimp.com
|
23 |
* @since 1.0.1
|
24 |
*
|
25 |
-
* @package
|
26 |
*/
|
27 |
|
28 |
// If uninstall not called from WordPress, then exit.
|
29 |
-
if (
|
30 |
exit;
|
31 |
}
|
32 |
|
33 |
-
if (!
|
34 |
-
|
35 |
-
* @return object
|
36 |
-
*/
|
37 |
-
function mailchimp_environment_variables() {
|
38 |
-
global $wp_version;
|
39 |
-
|
40 |
-
$o = get_option('mailchimp-woocommerce', false);
|
41 |
-
|
42 |
-
return (object) array(
|
43 |
-
'repo' => 'master',
|
44 |
-
'environment' => 'production',
|
45 |
-
'version' => '2.1.4',
|
46 |
-
'php_version' => phpversion(),
|
47 |
-
'wp_version' => (empty($wp_version) ? 'Unknown' : $wp_version),
|
48 |
-
'wc_version' => class_exists('WC') ? WC()->version : null,
|
49 |
-
'logging' => ($o && is_array($o) && isset($o['mailchimp_logging'])) ? $o['mailchimp_logging'] : 'none',
|
50 |
-
);
|
51 |
-
}
|
52 |
}
|
53 |
|
54 |
try {
|
55 |
if (($options = get_option('mailchimp-woocommerce', false)) && is_array($options)) {
|
56 |
if (isset($options['mailchimp_api_key'])) {
|
57 |
$store_id = get_option('mailchimp-woocommerce-store_id', false);
|
58 |
-
|
59 |
if (!empty($store_id)) {
|
60 |
-
if (!class_exists('MailChimp_WooCommerce_MailChimpApi')) {
|
61 |
-
require_once 'includes/api/class-mailchimp-api.php';
|
62 |
-
require_once 'includes/api/errors/class-mailchimp-error.php';
|
63 |
-
require_once 'includes/api/errors/class-mailchimp-server-error.php';
|
64 |
-
}
|
65 |
$api = new MailChimp_WooCommerce_MailChimpApi($options['mailchimp_api_key']);
|
66 |
$result = $api->deleteStore($store_id) ? 'has been deleted' : 'did not delete';
|
67 |
error_log("store id {$store_id} {$result} MailChimp");
|
@@ -72,16 +49,4 @@ try {
|
|
72 |
error_log($e->getMessage().' on '.$e->getLine().' in '.$e->getFile());
|
73 |
}
|
74 |
|
75 |
-
|
76 |
-
delete_option('mailchimp-woocommerce');
|
77 |
-
delete_option('mailchimp-woocommerce-errors.store_info');
|
78 |
-
delete_option('mailchimp-woocommerce-sync.orders.completed_at');
|
79 |
-
delete_option('mailchimp-woocommerce-sync.orders.current_page');
|
80 |
-
delete_option('mailchimp-woocommerce-sync.products.completed_at');
|
81 |
-
delete_option('mailchimp-woocommerce-sync.products.current_page');
|
82 |
-
delete_option('mailchimp-woocommerce-sync.syncing');
|
83 |
-
delete_option('mailchimp-woocommerce-sync.started_at');
|
84 |
-
delete_option('mailchimp-woocommerce-sync.completed_at');
|
85 |
-
delete_option('mailchimp-woocommerce-validation.api.ping');
|
86 |
-
delete_option('mailchimp-woocommerce-cached-api-lists');
|
87 |
-
delete_option('mailchimp-woocommerce-cached-api-ping-check');
|
22 |
* @link https://mailchimp.com
|
23 |
* @since 1.0.1
|
24 |
*
|
25 |
+
* @package MailChimp_WooCommerce
|
26 |
*/
|
27 |
|
28 |
// If uninstall not called from WordPress, then exit.
|
29 |
+
if (!defined( 'WP_UNINSTALL_PLUGIN')) {
|
30 |
exit;
|
31 |
}
|
32 |
|
33 |
+
if (!isset($mailchimp_woocommerce_spl_autoloader) || $mailchimp_woocommerce_spl_autoloader === false) {
|
34 |
+
include_once "bootstrap.php";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
}
|
36 |
|
37 |
try {
|
38 |
if (($options = get_option('mailchimp-woocommerce', false)) && is_array($options)) {
|
39 |
if (isset($options['mailchimp_api_key'])) {
|
40 |
$store_id = get_option('mailchimp-woocommerce-store_id', false);
|
|
|
41 |
if (!empty($store_id)) {
|
|
|
|
|
|
|
|
|
|
|
42 |
$api = new MailChimp_WooCommerce_MailChimpApi($options['mailchimp_api_key']);
|
43 |
$result = $api->deleteStore($store_id) ? 'has been deleted' : 'did not delete';
|
44 |
error_log("store id {$store_id} {$result} MailChimp");
|
49 |
error_log($e->getMessage().' on '.$e->getLine().' in '.$e->getFile());
|
50 |
}
|
51 |
|
52 |
+
mailchimp_clean_database();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|