Version Description
Download this release
Release Info
Developer | ryanhungate |
Plugin | MailChimp for WooCommerce |
Version | 2.7.1 |
Comparing to | |
See all releases |
Code changes from version 2.7 to 2.7.1
- CHANGELOG.txt +4 -0
- README.txt +6 -12
- admin/class-mailchimp-woocommerce-admin.php +43 -5
- bootstrap.php +5 -8
- includes/api/class-mailchimp-woocommerce-tower.php +16 -1
- includes/class-mailchimp-woocommerce-rest-api.php +42 -6
- includes/processes/class-mailchimp-woocommerce-webhooks-sync.php +17 -10
- mailchimp-woocommerce.php +3 -3
CHANGELOG.txt
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
== Changelog ==
|
|
|
|
|
|
|
|
|
2 |
= 2.7 =
|
3 |
* adds support for WooCommerce Checkout block
|
4 |
* adds support for the tracking url from Mailchimp API
|
1 |
== Changelog ==
|
2 |
+
= 2.7.1 =
|
3 |
+
* Fixes the outgoing IP address defaults
|
4 |
+
* Fixes webhook creation on plugin install
|
5 |
+
* Enhancements to the support tool
|
6 |
= 2.7 =
|
7 |
* adds support for WooCommerce Checkout block
|
8 |
* adds support for the tracking url from Mailchimp API
|
README.txt
CHANGED
@@ -4,10 +4,10 @@ Tags: ecommerce,email,workflows,mailchimp
|
|
4 |
Donate link: https://mailchimp.com
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 6.0
|
7 |
-
Stable tag: 2.7
|
8 |
Requires PHP: 7.0
|
9 |
WC requires at least: 3.5
|
10 |
-
WC tested up to: 6.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
Connect your store to your Mailchimp audience to track sales, create targeted emails, send abandoned cart emails, and more.
|
@@ -78,15 +78,9 @@ At this time, the synchronization of product categories from WooCommerce to Mail
|
|
78 |
If you are unable to sync or connect with Mailchimp, you can open a ticket on our [Github plugin page](https://github.com/mailchimp/mc-woocommerce/issues). Please provide the version of the plugin and PHP you're using, any fatal errors in the WooCommerce logs (WooCommerce -> Status -> Logs) you're seeing, along with relevant information to the problem you're experiencing.
|
79 |
|
80 |
== Changelog ==
|
81 |
-
= 2.7 =
|
82 |
-
*
|
83 |
-
*
|
84 |
-
*
|
85 |
-
* support for new WooCommerce admin navigation
|
86 |
-
* adds opt-in preference on My Account page
|
87 |
-
* adds subscriber status to user (customer) in Wordpress
|
88 |
-
* now assigns double opt-in to all re-subscribers
|
89 |
-
* now support for loading plugin files from absolute path
|
90 |
-
* adds two way sync check for webhooks on unsubscribes to and from Mailchimp
|
91 |
|
92 |
[Historical Changelog](https://raw.githubusercontent.com/mailchimp/mc-woocommerce/master/CHANGELOG.txt)
|
4 |
Donate link: https://mailchimp.com
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 6.0
|
7 |
+
Stable tag: 2.7.1
|
8 |
Requires PHP: 7.0
|
9 |
WC requires at least: 3.5
|
10 |
+
WC tested up to: 6.7
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
Connect your store to your Mailchimp audience to track sales, create targeted emails, send abandoned cart emails, and more.
|
78 |
If you are unable to sync or connect with Mailchimp, you can open a ticket on our [Github plugin page](https://github.com/mailchimp/mc-woocommerce/issues). Please provide the version of the plugin and PHP you're using, any fatal errors in the WooCommerce logs (WooCommerce -> Status -> Logs) you're seeing, along with relevant information to the problem you're experiencing.
|
79 |
|
80 |
== Changelog ==
|
81 |
+
= 2.7.1 =
|
82 |
+
* Fixes the outgoing IP address defaults
|
83 |
+
* Fixes webhook creation on plugin install
|
84 |
+
* Enhancements to the support tool
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
[Historical Changelog](https://raw.githubusercontent.com/mailchimp/mc-woocommerce/master/CHANGELOG.txt)
|
admin/class-mailchimp-woocommerce-admin.php
CHANGED
@@ -773,7 +773,9 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
773 |
* Mailchimp OAuth connection start
|
774 |
*/
|
775 |
public function mailchimp_woocommerce_ajax_oauth_start()
|
776 |
-
{
|
|
|
|
|
777 |
$secret = uniqid();
|
778 |
$args = array(
|
779 |
'domain' => site_url(),
|
@@ -806,7 +808,9 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
806 |
* Mailchimp OAuth connection status
|
807 |
*/
|
808 |
public function mailchimp_woocommerce_ajax_oauth_status()
|
809 |
-
{
|
|
|
|
|
810 |
$url = $_POST['url'];
|
811 |
// set the default headers to NOTHING because the oauth server will block
|
812 |
// any non standard header that it was not expecting to receive and it was
|
@@ -832,7 +836,9 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
832 |
* Mailchimp OAuth connection finish
|
833 |
*/
|
834 |
public function mailchimp_woocommerce_ajax_oauth_finish()
|
835 |
-
{
|
|
|
|
|
836 |
$args = array(
|
837 |
'domain' => site_url(),
|
838 |
'secret' => get_site_transient('mailchimp-woocommerce-oauth-secret'),
|
@@ -864,6 +870,8 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
864 |
|
865 |
|
866 |
public function mailchimp_woocommerce_ajax_create_account_check_username () {
|
|
|
|
|
867 |
$user = $_POST['username'];
|
868 |
$response = wp_remote_get( 'https://woocommerce.mailchimpapp.com/api/usernames/available/' . $_POST['username']);
|
869 |
// need to return the error message if this is the problem.
|
@@ -892,6 +900,8 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
892 |
}
|
893 |
|
894 |
public function mailchimp_woocommerce_ajax_support_form() {
|
|
|
|
|
895 |
$data = $_POST['data'];
|
896 |
|
897 |
// try to figure out user IP address
|
@@ -964,6 +974,8 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
964 |
}
|
965 |
|
966 |
public function mailchimp_woocommerce_ajax_create_account_signup() {
|
|
|
|
|
967 |
$data = $_POST['data'];
|
968 |
|
969 |
// try to figure out user IP address
|
@@ -1867,6 +1879,8 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
1867 |
*/
|
1868 |
public function mailchimp_woocommerce_communication_status()
|
1869 |
{
|
|
|
|
|
1870 |
$original_opt = $this->getData('comm.opt',0);
|
1871 |
$opt = $_POST['opt'];
|
1872 |
$admin_email = $this->getOptions()['admin_email'];
|
@@ -1897,6 +1911,8 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
1897 |
*/
|
1898 |
public function mailchimp_woocommerce_tower_status()
|
1899 |
{
|
|
|
|
|
1900 |
$original_opt = $this->getData('tower.opt',0);
|
1901 |
$opt = $_POST['opt'];
|
1902 |
|
@@ -1924,6 +1940,8 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
1924 |
*/
|
1925 |
public function mailchimp_set_communications_status_on_server($opt, $admin_email, $remove = false)
|
1926 |
{
|
|
|
|
|
1927 |
$env = mailchimp_environment_variables();
|
1928 |
$audience = !empty(mailchimp_get_list_id()) ? 1 : 0;
|
1929 |
$synced = get_option('mailchimp-woocommerce-sync.completed_at') > 0 ? 1 : 0;
|
@@ -1960,6 +1978,8 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
1960 |
*/
|
1961 |
public function mailchimp_woocommerce_ajax_delete_log_file()
|
1962 |
{
|
|
|
|
|
1963 |
if (!isset($_POST['log_file']) || empty($_POST['log_file'])) {
|
1964 |
wp_send_json_error(__('No log file provided', 'mailchimp-for-woocommerce'));
|
1965 |
return;
|
@@ -1975,6 +1995,8 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
1975 |
*/
|
1976 |
public function mailchimp_woocommerce_ajax_load_log_file()
|
1977 |
{
|
|
|
|
|
1978 |
if (!isset($_POST['log_file']) || empty($_POST['log_file'])) {
|
1979 |
wp_send_json_error(__('No log file provided', 'mailchimp-for-woocommerce'));
|
1980 |
return;
|
@@ -2005,8 +2027,24 @@ class MailChimp_WooCommerce_Admin extends MailChimp_WooCommerce_Options {
|
|
2005 |
public function defineWebHooks()
|
2006 |
{
|
2007 |
// run this every time the store is saved to be sure we've got the hooks enabled.
|
2008 |
-
|
2009 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010 |
}
|
|
|
2011 |
}
|
2012 |
}
|
773 |
* Mailchimp OAuth connection start
|
774 |
*/
|
775 |
public function mailchimp_woocommerce_ajax_oauth_start()
|
776 |
+
{
|
777 |
+
$this->adminOnlyMiddleware();
|
778 |
+
|
779 |
$secret = uniqid();
|
780 |
$args = array(
|
781 |
'domain' => site_url(),
|
808 |
* Mailchimp OAuth connection status
|
809 |
*/
|
810 |
public function mailchimp_woocommerce_ajax_oauth_status()
|
811 |
+
{
|
812 |
+
$this->adminOnlyMiddleware();
|
813 |
+
|
814 |
$url = $_POST['url'];
|
815 |
// set the default headers to NOTHING because the oauth server will block
|
816 |
// any non standard header that it was not expecting to receive and it was
|
836 |
* Mailchimp OAuth connection finish
|
837 |
*/
|
838 |
public function mailchimp_woocommerce_ajax_oauth_finish()
|
839 |
+
{
|
840 |
+
$this->adminOnlyMiddleware();
|
841 |
+
|
842 |
$args = array(
|
843 |
'domain' => site_url(),
|
844 |
'secret' => get_site_transient('mailchimp-woocommerce-oauth-secret'),
|
870 |
|
871 |
|
872 |
public function mailchimp_woocommerce_ajax_create_account_check_username () {
|
873 |
+
$this->adminOnlyMiddleware();
|
874 |
+
|
875 |
$user = $_POST['username'];
|
876 |
$response = wp_remote_get( 'https://woocommerce.mailchimpapp.com/api/usernames/available/' . $_POST['username']);
|
877 |
// need to return the error message if this is the problem.
|
900 |
}
|
901 |
|
902 |
public function mailchimp_woocommerce_ajax_support_form() {
|
903 |
+
$this->adminOnlyMiddleware();
|
904 |
+
|
905 |
$data = $_POST['data'];
|
906 |
|
907 |
// try to figure out user IP address
|
974 |
}
|
975 |
|
976 |
public function mailchimp_woocommerce_ajax_create_account_signup() {
|
977 |
+
$this->adminOnlyMiddleware();
|
978 |
+
|
979 |
$data = $_POST['data'];
|
980 |
|
981 |
// try to figure out user IP address
|
1879 |
*/
|
1880 |
public function mailchimp_woocommerce_communication_status()
|
1881 |
{
|
1882 |
+
$this->adminOnlyMiddleware();
|
1883 |
+
|
1884 |
$original_opt = $this->getData('comm.opt',0);
|
1885 |
$opt = $_POST['opt'];
|
1886 |
$admin_email = $this->getOptions()['admin_email'];
|
1911 |
*/
|
1912 |
public function mailchimp_woocommerce_tower_status()
|
1913 |
{
|
1914 |
+
$this->adminOnlyMiddleware();
|
1915 |
+
|
1916 |
$original_opt = $this->getData('tower.opt',0);
|
1917 |
$opt = $_POST['opt'];
|
1918 |
|
1940 |
*/
|
1941 |
public function mailchimp_set_communications_status_on_server($opt, $admin_email, $remove = false)
|
1942 |
{
|
1943 |
+
$this->adminOnlyMiddleware();
|
1944 |
+
|
1945 |
$env = mailchimp_environment_variables();
|
1946 |
$audience = !empty(mailchimp_get_list_id()) ? 1 : 0;
|
1947 |
$synced = get_option('mailchimp-woocommerce-sync.completed_at') > 0 ? 1 : 0;
|
1978 |
*/
|
1979 |
public function mailchimp_woocommerce_ajax_delete_log_file()
|
1980 |
{
|
1981 |
+
$this->adminOnlyMiddleware();
|
1982 |
+
|
1983 |
if (!isset($_POST['log_file']) || empty($_POST['log_file'])) {
|
1984 |
wp_send_json_error(__('No log file provided', 'mailchimp-for-woocommerce'));
|
1985 |
return;
|
1995 |
*/
|
1996 |
public function mailchimp_woocommerce_ajax_load_log_file()
|
1997 |
{
|
1998 |
+
$this->adminOnlyMiddleware();
|
1999 |
+
|
2000 |
if (!isset($_POST['log_file']) || empty($_POST['log_file'])) {
|
2001 |
wp_send_json_error(__('No log file provided', 'mailchimp-for-woocommerce'));
|
2002 |
return;
|
2027 |
public function defineWebHooks()
|
2028 |
{
|
2029 |
// run this every time the store is saved to be sure we've got the hooks enabled.
|
2030 |
+
try {
|
2031 |
+
if (mailchimp_is_configured()) {
|
2032 |
+
mailchimp_handle_or_queue(new MailChimp_WooCommerce_WebHooks_Sync());
|
2033 |
+
}
|
2034 |
+
} catch (\Exception $e) {
|
2035 |
+
mailchimp_log('plugin', "defineWebhooks", array('message' => $e->getMessage()));
|
2036 |
+
}
|
2037 |
+
}
|
2038 |
+
|
2039 |
+
/**
|
2040 |
+
* @param string $message
|
2041 |
+
* @return bool
|
2042 |
+
*/
|
2043 |
+
protected function adminOnlyMiddleware($message = "You're not allowed to do this")
|
2044 |
+
{
|
2045 |
+
if (!current_user_can(mailchimp_get_allowed_capability())) {
|
2046 |
+
wp_send_json_error(array('message' => $message));
|
2047 |
}
|
2048 |
+
return true;
|
2049 |
}
|
2050 |
}
|
bootstrap.php
CHANGED
@@ -318,7 +318,7 @@ function mailchimp_get_list_id() {
|
|
318 |
* @return string $url Webhook url
|
319 |
*/
|
320 |
function mailchimp_build_webhook_url( $key ) {
|
321 |
-
|
322 |
$url = MailChimp_WooCommerce_Rest_Api::url('member-sync') . '?auth=' . $key;
|
323 |
return $url;
|
324 |
}
|
@@ -1418,12 +1418,8 @@ function mailchimp_allowed_to_use_cookie($cookie) {
|
|
1418 |
*/
|
1419 |
function mailchimp_get_outbound_ip() {
|
1420 |
// if we have a dedicated IP address, and have set a configuration for it, we'll use it here.
|
1421 |
-
if (defined('MAILCHIMP_USE_OUTBOUND_IP')) {
|
1422 |
return MAILCHIMP_USE_OUTBOUND_IP;
|
1423 |
-
} elseif (($server_address = mailchimp_get_data('SERVER_ADDR')) && !empty($server_address)) {
|
1424 |
-
return $server_address;
|
1425 |
-
} elseif (isset($_SERVER) && isset($_SERVER['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR'])) {
|
1426 |
-
return $_SERVER['SERVER_ADDR'];
|
1427 |
}
|
1428 |
return null;
|
1429 |
}
|
@@ -1432,9 +1428,10 @@ function mailchimp_get_outbound_ip() {
|
|
1432 |
* @return bool
|
1433 |
*/
|
1434 |
function mailchimp_render_gdpr_fields() {
|
|
|
|
|
|
|
1435 |
return true;
|
1436 |
-
return defined('MAILCHIMP_RENDER_GDPR_FIELDS') &&
|
1437 |
-
MAILCHIMP_RENDER_GDPR_FIELDS;
|
1438 |
}
|
1439 |
|
1440 |
// Add WP CLI commands
|
318 |
* @return string $url Webhook url
|
319 |
*/
|
320 |
function mailchimp_build_webhook_url( $key ) {
|
321 |
+
//$key = base64_encode($key);
|
322 |
$url = MailChimp_WooCommerce_Rest_Api::url('member-sync') . '?auth=' . $key;
|
323 |
return $url;
|
324 |
}
|
1418 |
*/
|
1419 |
function mailchimp_get_outbound_ip() {
|
1420 |
// if we have a dedicated IP address, and have set a configuration for it, we'll use it here.
|
1421 |
+
if (defined('MAILCHIMP_USE_OUTBOUND_IP') && !empty(MAILCHIMP_USE_OUTBOUND_IP)) {
|
1422 |
return MAILCHIMP_USE_OUTBOUND_IP;
|
|
|
|
|
|
|
|
|
1423 |
}
|
1424 |
return null;
|
1425 |
}
|
1428 |
* @return bool
|
1429 |
*/
|
1430 |
function mailchimp_render_gdpr_fields() {
|
1431 |
+
if (defined('MAILCHIMP_RENDER_GDPR_FIELDS') && !MAILCHIMP_RENDER_GDPR_FIELDS) {
|
1432 |
+
return false;
|
1433 |
+
}
|
1434 |
return true;
|
|
|
|
|
1435 |
}
|
1436 |
|
1437 |
// Add WP CLI commands
|
includes/api/class-mailchimp-woocommerce-tower.php
CHANGED
@@ -180,7 +180,7 @@ class MailChimp_WooCommerce_Tower extends Mailchimp_Woocommerce_Job
|
|
180 |
'phone' => isset($options['store_phone']) && $options['store_phone'] ? $options['store_phone'] : '',
|
181 |
),
|
182 |
'metrics' => array_values([
|
183 |
-
'shopify_hooks' => (object) array('key' => 'shopify_hooks', 'value' =>
|
184 |
'shop.products' => (object) array('key' => 'shop.products', 'value' => $product_count),
|
185 |
'shop.customers' => (object) array('key' => 'shop.customers', 'value' => $customer_count),
|
186 |
'shop.orders' => (object) array('key' => 'shop.orders', 'value' => $order_count),
|
@@ -260,6 +260,21 @@ class MailChimp_WooCommerce_Tower extends Mailchimp_Woocommerce_Job
|
|
260 |
];
|
261 |
}
|
262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
/**
|
264 |
* @param $domain
|
265 |
* @return string|string[]
|
180 |
'phone' => isset($options['store_phone']) && $options['store_phone'] ? $options['store_phone'] : '',
|
181 |
),
|
182 |
'metrics' => array_values([
|
183 |
+
'shopify_hooks' => (object) array('key' => 'shopify_hooks', 'value' => $this->hasWebhookInstalled()),
|
184 |
'shop.products' => (object) array('key' => 'shop.products', 'value' => $product_count),
|
185 |
'shop.customers' => (object) array('key' => 'shop.customers', 'value' => $customer_count),
|
186 |
'shop.orders' => (object) array('key' => 'shop.orders', 'value' => $order_count),
|
260 |
];
|
261 |
}
|
262 |
|
263 |
+
/**
|
264 |
+
* @return bool
|
265 |
+
*/
|
266 |
+
protected function hasWebhookInstalled()
|
267 |
+
{
|
268 |
+
if (!mailchimp_is_configured() || !mailchimp_get_data('webhook.token')) {
|
269 |
+
return false;
|
270 |
+
}
|
271 |
+
try {
|
272 |
+
return (bool) mailchimp_get_api()->hasWebhook(mailchimp_get_list_id(), mailchimp_get_webhook_url());
|
273 |
+
} catch (\Throwable $e) {
|
274 |
+
mailchimp_log('tower', 'could not get webhook URL', array('message' => $e->getMessage()));
|
275 |
+
return false;
|
276 |
+
}
|
277 |
+
}
|
278 |
/**
|
279 |
* @param $domain
|
280 |
* @return string|string[]
|
includes/class-mailchimp-woocommerce-rest-api.php
CHANGED
@@ -322,11 +322,47 @@ class MailChimp_WooCommerce_Rest_Api
|
|
322 |
];
|
323 |
break;
|
324 |
case 'activate_webhooks':
|
325 |
-
$
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
break;
|
331 |
case 'resync_all':
|
332 |
$service = new MailChimp_Service();
|
@@ -609,7 +645,7 @@ class MailChimp_WooCommerce_Rest_Api
|
|
609 |
|
610 |
// if we don't have a token - or we don't have the saved comparison
|
611 |
// or the token doesn't equal the saved token, throw an error.
|
612 |
-
if (empty($token) || empty($saved) || base64_decode($token) !== $saved) {
|
613 |
wp_send_json_error(array('message' => 'unauthorized'), 403);
|
614 |
}
|
615 |
return true;
|
322 |
];
|
323 |
break;
|
324 |
case 'activate_webhooks':
|
325 |
+
$api = mailchimp_get_api();
|
326 |
+
$list = mailchimp_get_list_id();
|
327 |
+
if (get_option('permalink_structure') === '') {
|
328 |
+
$response = [
|
329 |
+
'title' => "Store Webhooks",
|
330 |
+
'description' => "No store webhooks to apply",
|
331 |
+
'type' => 'error',
|
332 |
+
];
|
333 |
+
} else {
|
334 |
+
$previous_url = mailchimp_get_webhook_url();
|
335 |
+
if (mailchimp_get_data('webhook.token') && $previous_url && $api->hasWebhook($list, $previous_url)) {
|
336 |
+
$response = [
|
337 |
+
'title' => "Store Webhooks",
|
338 |
+
'description' => "Store already has webhooks enabled!",
|
339 |
+
'type' => 'success',
|
340 |
+
];
|
341 |
+
} else {
|
342 |
+
$key = mailchimp_create_webhook_token();
|
343 |
+
$url = mailchimp_build_webhook_url($key);
|
344 |
+
mailchimp_set_data('webhook.token', $key);
|
345 |
+
try {
|
346 |
+
$webhook = $api->webHookSubscribe($list, $url);
|
347 |
+
mailchimp_set_webhook_url($webhook['url']);
|
348 |
+
mailchimp_log('webhooks', "added webhook to audience");
|
349 |
+
$response = [
|
350 |
+
'title' => "Store Webhooks",
|
351 |
+
'description' => "Set up a new webhook at {$webhook['url']}",
|
352 |
+
'type' => 'success',
|
353 |
+
];
|
354 |
+
} catch (\Exception $e) {
|
355 |
+
$response = [
|
356 |
+
'title' => "Store Webhooks",
|
357 |
+
'description' => $e->getMessage(),
|
358 |
+
'type' => 'error',
|
359 |
+
];
|
360 |
+
mailchimp_set_data('webhook.token', false);
|
361 |
+
mailchimp_set_webhook_url(false);
|
362 |
+
mailchimp_error('webhook', $e->getMessage());
|
363 |
+
}
|
364 |
+
}
|
365 |
+
}
|
366 |
break;
|
367 |
case 'resync_all':
|
368 |
$service = new MailChimp_Service();
|
645 |
|
646 |
// if we don't have a token - or we don't have the saved comparison
|
647 |
// or the token doesn't equal the saved token, throw an error.
|
648 |
+
if (empty($token) || empty($saved) || ($token !== $saved && base64_decode($token) !== $saved)) {
|
649 |
wp_send_json_error(array('message' => 'unauthorized'), 403);
|
650 |
}
|
651 |
return true;
|
includes/processes/class-mailchimp-woocommerce-webhooks-sync.php
CHANGED
@@ -34,19 +34,22 @@ class MailChimp_WooCommerce_WebHooks_Sync extends Mailchimp_Woocommerce_Job
|
|
34 |
$key = mailchimp_get_data('webhook.token');
|
35 |
$url = mailchimp_get_webhook_url();
|
36 |
$api = mailchimp_get_api();
|
|
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
$
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
46 |
}
|
47 |
|
48 |
// for some reason the webhook url does not work with ?rest_route style, permalinks should be defined also
|
49 |
-
if (!$
|
50 |
$key = mailchimp_create_webhook_token();
|
51 |
$url = mailchimp_build_webhook_url($key);
|
52 |
mailchimp_set_data('webhook.token', $key);
|
@@ -55,11 +58,15 @@ class MailChimp_WooCommerce_WebHooks_Sync extends Mailchimp_Woocommerce_Job
|
|
55 |
//if no errors let save the url
|
56 |
mailchimp_set_webhook_url($webhook['url']);
|
57 |
mailchimp_log('webhooks', "added webhook to audience");
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
} catch (\Throwable $e) {
|
|
|
60 |
mailchimp_set_data('webhook.token', false);
|
61 |
mailchimp_set_webhook_url(false);
|
62 |
-
mailchimp_error('webhook', $e->getMessage());
|
63 |
}
|
64 |
return false;
|
65 |
}
|
34 |
$key = mailchimp_get_data('webhook.token');
|
35 |
$url = mailchimp_get_webhook_url();
|
36 |
$api = mailchimp_get_api();
|
37 |
+
$token = mailchimp_get_data('webhook.token');
|
38 |
|
39 |
+
$hooks = $api->getWebHooks($list);
|
40 |
+
foreach ($hooks['webhooks'] as $hook) {
|
41 |
+
$href = isset($hook['url']) ? $hook['url'] : (isset($hook['href']) ? $hook['href'] : null);
|
42 |
+
if (mailchimp_string_contains($href, 'mailchimp-for-woocommerce/v1/member-sync')) {
|
43 |
+
$api->webHookDelete($list, $hook['id']);
|
44 |
+
$url = null;
|
45 |
+
$key = null;
|
46 |
+
$token = null;
|
47 |
+
mailchimp_log('webhooks', "Deleted old plugin webhook {$hook['id']}");
|
48 |
+
}
|
49 |
}
|
50 |
|
51 |
// for some reason the webhook url does not work with ?rest_route style, permalinks should be defined also
|
52 |
+
if (!$token && get_option('permalink_structure') !== '') {
|
53 |
$key = mailchimp_create_webhook_token();
|
54 |
$url = mailchimp_build_webhook_url($key);
|
55 |
mailchimp_set_data('webhook.token', $key);
|
58 |
//if no errors let save the url
|
59 |
mailchimp_set_webhook_url($webhook['url']);
|
60 |
mailchimp_log('webhooks', "added webhook to audience");
|
61 |
+
} else {
|
62 |
+
mailchimp_log('webhooks', "could not add webhooks because of the permalink structure!", array(
|
63 |
+
'permalink_structure' => get_option('permalink_structure'),
|
64 |
+
));
|
65 |
}
|
66 |
} catch (\Throwable $e) {
|
67 |
+
mailchimp_error('webhook', $e->getMessage());
|
68 |
mailchimp_set_data('webhook.token', false);
|
69 |
mailchimp_set_webhook_url(false);
|
|
|
70 |
}
|
71 |
return false;
|
72 |
}
|
mailchimp-woocommerce.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
* Plugin Name: Mailchimp for WooCommerce
|
17 |
* Plugin URI: https://mailchimp.com/connect-your-store/
|
18 |
* Description: Connects WooCommerce to Mailchimp to sync your store data, send targeted campaigns to your customers, and sell more stuff.
|
19 |
-
* Version: 2.7
|
20 |
* Author: Mailchimp
|
21 |
* Author URI: https://mailchimp.com
|
22 |
* License: GPL-2.0+
|
@@ -24,9 +24,9 @@
|
|
24 |
* Text Domain: mailchimp-for-woocommerce
|
25 |
* Domain Path: /languages
|
26 |
* Requires at least: 4.9
|
27 |
-
* Tested up to:
|
28 |
* WC requires at least: 3.5
|
29 |
-
* WC tested up to: 6.
|
30 |
*/
|
31 |
|
32 |
// If this file is called directly, abort.
|
16 |
* Plugin Name: Mailchimp for WooCommerce
|
17 |
* Plugin URI: https://mailchimp.com/connect-your-store/
|
18 |
* Description: Connects WooCommerce to Mailchimp to sync your store data, send targeted campaigns to your customers, and sell more stuff.
|
19 |
+
* Version: 2.7.1
|
20 |
* Author: Mailchimp
|
21 |
* Author URI: https://mailchimp.com
|
22 |
* License: GPL-2.0+
|
24 |
* Text Domain: mailchimp-for-woocommerce
|
25 |
* Domain Path: /languages
|
26 |
* Requires at least: 4.9
|
27 |
+
* Tested up to: 6.0
|
28 |
* WC requires at least: 3.5
|
29 |
+
* WC tested up to: 6.7
|
30 |
*/
|
31 |
|
32 |
// If this file is called directly, abort.
|