MailChimp for WooCommerce - Version 2.1.3

Version Description

  • Fix subscriber status for repeat transactional customers to stay transactional.
  • Remove shipping and billing address requirements for order submission.
  • Do not unsubscribe someone who has previously subscribed when unchecking the newsletter sign up box.
  • Update newsletter checkbox style to be consistent with WooCommerce styles.
  • Make sure WooCommerce plugin is running before running any plugin code.
  • Fix compatibility issue with WP-Cron
Download this release

Release Info

Developer MailChimp
Plugin Icon wp plugin MailChimp for WooCommerce
Version 2.1.3
Comparing to
See all releases

Code changes from version 2.1.2 to 2.1.3

README.txt CHANGED
@@ -24,11 +24,13 @@ With MailChimp for WooCommerce, you’ll have the power to:
24
  - Automatically embed a pop-up form that converts your website visitors to subscribers.
25
  - Add discount codes created in WooCommerce to your emails and automations with a Promo Code content block
26
 
27
- ###A note for current WooCommerce integration users
28
  This plugin supports our most powerful API 3.0 features, and is intended for users who have not yet integrated their WooCommerce stores with MailChimp.
29
 
30
  You can run this new integration at the same time as your current WooCommerce integration for MailChimp. However, data from the older integration will display separately in subscriber profiles, and can’t be used with e-commerce features that require API 3.0.
31
 
 
 
32
  == Installation ==
33
  ###Before You Start
34
  Here are some things to know before you begin this process.
@@ -51,6 +53,14 @@ For more information on settings and configuration, please visit our Knowledge B
51
 
52
  == Changelog ==
53
 
 
 
 
 
 
 
 
 
54
  = 2.1.2 =
55
  * Fix store deletion on plugin deactivation
56
  * Correct shipping name is now used on order notifications.
24
  - Automatically embed a pop-up form that converts your website visitors to subscribers.
25
  - Add discount codes created in WooCommerce to your emails and automations with a Promo Code content block
26
 
27
+ ###Important Notes
28
  This plugin supports our most powerful API 3.0 features, and is intended for users who have not yet integrated their WooCommerce stores with MailChimp.
29
 
30
  You can run this new integration at the same time as your current WooCommerce integration for MailChimp. However, data from the older integration will display separately in subscriber profiles, and can’t be used with e-commerce features that require API 3.0.
31
 
32
+ This plugin is not compatible for WordPress.com users at this time.
33
+
34
  == Installation ==
35
  ###Before You Start
36
  Here are some things to know before you begin this process.
53
 
54
  == Changelog ==
55
 
56
+ = 2.1.3 =
57
+ * Fix subscriber status for repeat transactional customers to stay transactional.
58
+ * Remove shipping and billing address requirements for order submission.
59
+ * Do not unsubscribe someone who has previously subscribed when unchecking the newsletter sign up box.
60
+ * Update newsletter checkbox style to be consistent with WooCommerce styles.
61
+ * Make sure WooCommerce plugin is running before running any plugin code.
62
+ * Fix compatibility issue with WP-Cron
63
+
64
  = 2.1.2 =
65
  * Fix store deletion on plugin deactivation
66
  * Correct shipping name is now used on order notifications.
admin/class-mailchimp-woocommerce-admin.php CHANGED
@@ -292,6 +292,9 @@ class MailChimp_Woocommerce_Admin extends MailChimp_Woocommerce_Options {
292
  if (empty($data['mailchimp_api_key']) || !($profile = $api->ping(true))) {
293
  unset($data['mailchimp_api_key']);
294
  $valid = false;
 
 
 
295
  }
296
 
297
  // tell our reporting system whether or not we had a valid ping.
292
  if (empty($data['mailchimp_api_key']) || !($profile = $api->ping(true))) {
293
  unset($data['mailchimp_api_key']);
294
  $valid = false;
295
+ if (!$profile) {
296
+ add_settings_error('mailchimp_store_settings', '', 'API Key Invalid');
297
+ }
298
  }
299
 
300
  // tell our reporting system whether or not we had a valid ping.
admin/partials/mailchimp-woocommerce-admin-tabs.php CHANGED
@@ -133,9 +133,10 @@ if (isset($options['mailchimp_api_key']) && $handler->hasValidApiKey()) {
133
  <?php if ($active_tab == 'sync'): ?>
134
  <h2 style="padding-top: 1em;">More Information</h2>
135
  <p>
136
- Need help troubleshooting or connecting your store? Visit our MailChimp for WooCommerce
137
- <a href="http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce/" target="_blank">knowledge base</a> at anytime. Also, be sure to
138
- <a href="https://wordpress.org/support/plugin/mailchimp-for-woocommerce/reviews/" target="_blank">leave a review</a> and let us know how we're doing.
 
139
  </p>
140
  <?php endif; ?>
141
 
133
  <?php if ($active_tab == 'sync'): ?>
134
  <h2 style="padding-top: 1em;">More Information</h2>
135
  <p>
136
+ Need help to connect your store? Visit the MailChimp
137
+ <a href="http://kb.mailchimp.com/integrations/e-commerce/connect-or-disconnect-mailchimp-for-woocommerce/" target="_blank">Knowledge Base</a>.<br/>
138
+ Want to tell us how we're doing?
139
+ <a href="https://wordpress.org/support/plugin/mailchimp-for-woocommerce/reviews/" target="_blank">Leave a review on Wordpress.org</a>.
140
  </p>
141
  <?php endif; ?>
142
 
admin/partials/tabs/newsletter_settings.php CHANGED
@@ -82,7 +82,7 @@ $list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mai
82
  </fieldset>
83
 
84
  <h2 style="padding-top: 1em;">Opt-in Settings</h2>
85
- <p>Add text to go along with the opt-in checkbox, and choose a default display option.</p>
86
 
87
  <fieldset>
88
  <legend class="screen-reader-text">
@@ -90,11 +90,11 @@ $list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mai
90
  </legend>
91
  <label for="<?php echo $this->plugin_name; ?>-newsletter-checkbox-label">
92
  <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-newsletter-checkbox-label" name="<?php echo $this->plugin_name; ?>[newsletter_label]" value="<?php echo isset($options['newsletter_label']) ? $options['newsletter_label'] : 'Subscribe to our newsletter' ?>" />
93
- <span><?php esc_attr_e('Write a subscribe message for customers at checkout.', $this->plugin_name); ?></span>
94
  </label>
95
  </fieldset>
96
 
97
- <h2 style="padding-top: 1em;">Checkbox Display Options</h2>
98
 
99
  <fieldset>
100
  <legend class="screen-reader-text">
@@ -104,11 +104,11 @@ $list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mai
104
  <?php $checkbox_default_settings = (array_key_exists('mailchimp_checkbox_defaults', $options) && !is_null($options['mailchimp_checkbox_defaults'])) ? $options['mailchimp_checkbox_defaults'] : 'check'; ?>
105
  <input type="radio" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_defaults]" value="check"<?php if($checkbox_default_settings === 'check') echo ' checked="checked" '; ?>>Visible, checked by default<br>
106
  <input type="radio" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_defaults]" value="uncheck"<?php if($checkbox_default_settings === 'uncheck') echo ' checked="checked" '; ?>>Visible, unchecked by default<br/>
107
- <input type="radio" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_defaults]" value="hide"<?php if($checkbox_default_settings === 'hide') echo ' checked="checked" '; ?>>Hidden, not opted by default<br/>
108
  </label>
109
  </fieldset>
110
 
111
- <h2 style="padding-top: 1em;">Advanced Checkbox Settings</h2>
112
  <p>
113
  To change the location of the opt-in checkbox at checkout, input one of the
114
  <a href="https://docs.woocommerce.com/wc-apidocs/hook-docs.html" target="_blank">
@@ -122,7 +122,7 @@ $list_is_configured = isset($options['mailchimp_list']) && (!empty($options['mai
122
  </legend>
123
  <label for="<?php echo $this->plugin_name; ?>-newsletter-checkbox-action">
124
  <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-newsletter-checkbox-action" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_action]" value="<?php echo isset($options['mailchimp_checkbox_action']) ? $options['mailchimp_checkbox_action'] : 'woocommerce_after_checkout_billing_form' ?>" />
125
- <span><?php esc_attr_e('WooCommerce Action', $this->plugin_name); ?></span>
126
  </label>
127
  </fieldset>
128
 
82
  </fieldset>
83
 
84
  <h2 style="padding-top: 1em;">Opt-in Settings</h2>
85
+ <p>Add text to go along with the opt-in checkbox, and choose a default display option. Customers can click a box at checkout to opt in to your newsletter. Write a signup message and choose how you want this checkbox to appear. </p>
86
 
87
  <fieldset>
88
  <legend class="screen-reader-text">
90
  </legend>
91
  <label for="<?php echo $this->plugin_name; ?>-newsletter-checkbox-label">
92
  <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-newsletter-checkbox-label" name="<?php echo $this->plugin_name; ?>[newsletter_label]" value="<?php echo isset($options['newsletter_label']) ? $options['newsletter_label'] : 'Subscribe to our newsletter' ?>" />
93
+ <span><?php esc_attr_e('Enter text for the opt-in checkbox', $this->plugin_name); ?></span>
94
  </label>
95
  </fieldset>
96
 
97
+ <h4 style="padding-top: 1em;font-weight:normal;">Checkbox Display Options</h4>
98
 
99
  <fieldset>
100
  <legend class="screen-reader-text">
104
  <?php $checkbox_default_settings = (array_key_exists('mailchimp_checkbox_defaults', $options) && !is_null($options['mailchimp_checkbox_defaults'])) ? $options['mailchimp_checkbox_defaults'] : 'check'; ?>
105
  <input type="radio" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_defaults]" value="check"<?php if($checkbox_default_settings === 'check') echo ' checked="checked" '; ?>>Visible, checked by default<br>
106
  <input type="radio" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_defaults]" value="uncheck"<?php if($checkbox_default_settings === 'uncheck') echo ' checked="checked" '; ?>>Visible, unchecked by default<br/>
107
+ <input type="radio" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_defaults]" value="hide"<?php if($checkbox_default_settings === 'hide') echo ' checked="checked" '; ?>>Hidden, unchecked by default<br/>
108
  </label>
109
  </fieldset>
110
 
111
+ <h4 style="padding-top: 1em;font-weight:normal;">Advanced Checkbox Settings</h4>
112
  <p>
113
  To change the location of the opt-in checkbox at checkout, input one of the
114
  <a href="https://docs.woocommerce.com/wc-apidocs/hook-docs.html" target="_blank">
122
  </legend>
123
  <label for="<?php echo $this->plugin_name; ?>-newsletter-checkbox-action">
124
  <input style="width: 30%;" type="text" id="<?php echo $this->plugin_name; ?>-newsletter-checkbox-action" name="<?php echo $this->plugin_name; ?>[mailchimp_checkbox_action]" value="<?php echo isset($options['mailchimp_checkbox_action']) ? $options['mailchimp_checkbox_action'] : 'woocommerce_after_checkout_billing_form' ?>" />
125
+ <span><?php esc_attr_e('Enter a WooCommerce form action', $this->plugin_name); ?></span>
126
  </label>
127
  </fieldset>
128
 
admin/partials/tabs/store_sync.php CHANGED
@@ -70,7 +70,7 @@ if (($mailchimp_api = mailchimp_get_api()) && ($store = $mailchimp_api->getStore
70
  <?php if($mailchimp_api && (!$store_syncing || isset($_GET['resync']) && $_GET['resync'] === '1')): ?>
71
  <h2 style="padding-top: 1em;">Advanced</h2>
72
  <p>
73
- You may sync your list again if necessary. When this is done, all ecommerce data will be reset in your MailChimp list - including products and transaction data.
74
  </p>
75
  <?php submit_button('Resync', 'primary','submit', TRUE); ?>
76
  <?php endif; ?>
70
  <?php if($mailchimp_api && (!$store_syncing || isset($_GET['resync']) && $_GET['resync'] === '1')): ?>
71
  <h2 style="padding-top: 1em;">Advanced</h2>
72
  <p>
73
+ You can resync your list at any time without losing any of your e-commerce data.
74
  </p>
75
  <?php submit_button('Resync', 'primary','submit', TRUE); ?>
76
  <?php endif; ?>
includes/api/class-mailchimp-woocommerce-transform-orders-wc3.php CHANGED
@@ -186,7 +186,8 @@ class MailChimp_WooCommerce_Transform_Orders
186
  if (!$subscribed_on_order) {
187
  try {
188
  $subscriber = mailchimp_get_api()->member(mailchimp_get_list_id(), $customer->getEmailAddress());
189
- $customer->setOptInStatus(($subscriber['status'] !== 'unsubscribed'));
 
190
  } catch (\Exception $e) {}
191
  }
192
 
186
  if (!$subscribed_on_order) {
187
  try {
188
  $subscriber = mailchimp_get_api()->member(mailchimp_get_list_id(), $customer->getEmailAddress());
189
+ $status = !in_array($subscriber['status'], array('unsubscribed', 'transactional'));
190
+ $customer->setOptInStatus($status);
191
  } catch (\Exception $e) {}
192
  }
193
 
includes/api/class-mailchimp-woocommerce-transform-orders.php CHANGED
@@ -169,7 +169,7 @@ class MailChimp_WooCommerce_Transform_Orders
169
  }
170
 
171
  // apply the coupon discounts
172
- if (($used_coupons = $woo->get_used_coupons()) && is_array($used_coupons)) {
173
  foreach ($used_coupons as $coupon_code) {
174
  if (($coupon_id = wc_get_coupon_id_by_code($coupon_code))) {
175
  $coupon = new WC_Coupon($coupon_id);
@@ -212,7 +212,8 @@ class MailChimp_WooCommerce_Transform_Orders
212
  if (!$subscribed_on_order) {
213
  try {
214
  $subscriber = mailchimp_get_api()->member(mailchimp_get_list_id(), $customer->getEmailAddress());
215
- $customer->setOptInStatus(($subscriber['status'] !== 'unsubscribed'));
 
216
  } catch (\Exception $e) {}
217
  }
218
 
169
  }
170
 
171
  // apply the coupon discounts
172
+ if (function_exists('wc_get_coupon_id_by_code') && ($used_coupons = $woo->get_used_coupons()) && is_array($used_coupons)) {
173
  foreach ($used_coupons as $coupon_code) {
174
  if (($coupon_id = wc_get_coupon_id_by_code($coupon_code))) {
175
  $coupon = new WC_Coupon($coupon_id);
212
  if (!$subscribed_on_order) {
213
  try {
214
  $subscriber = mailchimp_get_api()->member(mailchimp_get_list_id(), $customer->getEmailAddress());
215
+ $status = !in_array($subscriber['status'], array('unsubscribed', 'transactional'));
216
+ $customer->setOptInStatus($status);
217
  } catch (\Exception $e) {}
218
  }
219
 
includes/class-mailchimp-woocommerce-newsletter.php CHANGED
@@ -41,9 +41,12 @@ class MailChimp_Newsletter extends MailChimp_Woocommerce_Options
41
 
42
  // echo out the checkbox.
43
  $checkbox = '<p class="form-row form-row-wide create-account">';
44
- $checkbox .= '<input class="input-checkbox" id="mailchimp_woocommerce_newsletter" type="checkbox" ';
45
- $checkbox .= 'name="mailchimp_woocommerce_newsletter" value="1"'.($status ? ' checked="checked"' : '').'>';
46
- $checkbox .= '<label for="mailchimp_woocommerce_newsletter" class="checkbox">'.$label.'</label></p>';
 
 
 
47
  $checkbox .= '<div class="clear"></div>';
48
 
49
  echo $checkbox;
@@ -74,10 +77,10 @@ class MailChimp_Newsletter extends MailChimp_Woocommerce_Options
74
  */
75
  public function processRegistrationForm($sanitized_user_login, $user_email, $reg_errors)
76
  {
77
-
78
  if (defined('WOOCOMMERCE_CHECKOUT')) {
79
  return; // Ship checkout
80
  }
 
81
  $this->handleStatus();
82
  }
83
 
41
 
42
  // echo out the checkbox.
43
  $checkbox = '<p class="form-row form-row-wide create-account">';
44
+ $checkbox .= '<label for="mailchimp_woocommerce_newsletter" class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">';
45
+ $checkbox .= '<input class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" id="mailchimp_woocommerce_newsletter" type="checkbox" ';
46
+ $checkbox .= 'name="mailchimp_woocommerce_newsletter" value="1"'.($status ? ' checked="checked"' : '').'> ';
47
+ $checkbox .= '<span>' . $label . '</span>';
48
+ $checkbox .= '</label>';
49
+ $checkbox .= '</p>';
50
  $checkbox .= '<div class="clear"></div>';
51
 
52
  echo $checkbox;
77
  */
78
  public function processRegistrationForm($sanitized_user_login, $user_email, $reg_errors)
79
  {
 
80
  if (defined('WOOCOMMERCE_CHECKOUT')) {
81
  return; // Ship checkout
82
  }
83
+
84
  $this->handleStatus();
85
  }
86
 
includes/class-mailchimp-woocommerce-service.php CHANGED
@@ -325,7 +325,7 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
325
  public function getCartItems()
326
  {
327
  if (!($this->cart = $this->getWooSession('cart', false))) {
328
- $this->cart = WC()->cart->get_cart();
329
  } else {
330
  $cart_session = array();
331
  foreach ( $this->cart as $key => $values ) {
@@ -503,6 +503,8 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
503
  */
504
  public function getWooSession($key, $default = null)
505
  {
 
 
506
  if (!($woo = WC()) || empty($woo->session)) {
507
  return $default;
508
  }
@@ -516,6 +518,8 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
516
  */
517
  public function setWooSession($key, $value)
518
  {
 
 
519
  if (!($woo = WC()) || empty($woo->session)) {
520
  return $this;
521
  }
@@ -531,6 +535,8 @@ class MailChimp_Service extends MailChimp_Woocommerce_Options
531
  */
532
  public function removeWooSession($key)
533
  {
 
 
534
  if (!($woo = WC()) || empty($woo->session)) {
535
  return $this;
536
  }
325
  public function getCartItems()
326
  {
327
  if (!($this->cart = $this->getWooSession('cart', false))) {
328
+ $this->cart = function_exists('WC') ? false : WC()->cart->get_cart();
329
  } else {
330
  $cart_session = array();
331
  foreach ( $this->cart as $key => $values ) {
503
  */
504
  public function getWooSession($key, $default = null)
505
  {
506
+ if (!function_exists('WC')) return $default;
507
+
508
  if (!($woo = WC()) || empty($woo->session)) {
509
  return $default;
510
  }
518
  */
519
  public function setWooSession($key, $value)
520
  {
521
+ if (!function_exists('WC')) return $this;
522
+
523
  if (!($woo = WC()) || empty($woo->session)) {
524
  return $this;
525
  }
535
  */
536
  public function removeWooSession($key)
537
  {
538
+ if (!function_exists('WC')) return $this;
539
+
540
  if (!($woo = WC()) || empty($woo->session)) {
541
  return $this;
542
  }
includes/processes/class-mailchimp-woocommerce-process-orders.php CHANGED
@@ -38,7 +38,7 @@ class MailChimp_WooCommerce_Process_Orders extends MailChimp_WooCommerce_Abtstra
38
  if (!($status = $item->getCustomer()->getOptInStatus())) {
39
  try {
40
  $subscriber = $this->mailchimp()->member(mailchimp_get_list_id(), $item->getCustomer()->getEmailAddress());
41
- $status = $subscriber['status'] !== 'unsubscribed';
42
  } catch (\Exception $e) {
43
  $status = (bool) $this->getOption('mailchimp_auto_subscribe', true);
44
  }
38
  if (!($status = $item->getCustomer()->getOptInStatus())) {
39
  try {
40
  $subscriber = $this->mailchimp()->member(mailchimp_get_list_id(), $item->getCustomer()->getEmailAddress());
41
+ $status = !in_array($subscriber['status'], array('unsubscribed', 'transactional'));
42
  } catch (\Exception $e) {
43
  $status = (bool) $this->getOption('mailchimp_auto_subscribe', true);
44
  }
includes/processes/class-mailchimp-woocommerce-user-submit.php CHANGED
@@ -84,6 +84,12 @@ class MailChimp_WooCommerce_User_Submit extends WP_Job
84
  return false;
85
  }
86
 
 
 
 
 
 
 
87
  $api = new MailChimp_WooCommerce_MailChimpApi($api_key);
88
 
89
  $merge_vars = array();
84
  return false;
85
  }
86
 
87
+ // don't let anyone be unsubscribed from the list - that should only happen on email campaigns
88
+ // and someone clicking the unsubscribe linkage.
89
+ if (!$this->subscribed) {
90
+ return false;
91
+ }
92
+
93
  $api = new MailChimp_WooCommerce_MailChimpApi($api_key);
94
 
95
  $merge_vars = array();
includes/vendor/queue/classes/worker/wp-http-worker.php CHANGED
@@ -253,27 +253,21 @@ if ( ! class_exists( 'WP_Http_Worker' ) ) {
253
  return wp_remote_post( esc_url_raw( $url ), $post_args );
254
  }
255
 
256
- /**
257
- * Handle cron
258
- *
259
- * Restart the HTTP worker if not already running
260
- * and data exists in the queue.
261
- */
262
- public function handle_cron() {
263
- if ( $this->is_worker_running() ) {
264
- // Worker already running, die
265
- wp_die();
266
- }
267
-
268
- if ( ! $this->queue->available_jobs() ) {
269
- // No jobs on the queue to process, die
270
- wp_die();
271
- }
272
-
273
- $this->dispatch();
274
-
275
- exit;
276
- }
277
 
278
  /**
279
  * Cron schedules
253
  return wp_remote_post( esc_url_raw( $url ), $post_args );
254
  }
255
 
256
+ /**
257
+ * @return bool
258
+ */
259
+ public function handle_cron() {
260
+ if ($this->is_worker_running()) {
261
+ wp_die();
262
+ }
263
+
264
+ if ($this->queue->available_jobs()) {
265
+ $this->dispatch();
266
+ return true;
267
+ }
268
+
269
+ return false;
270
+ }
 
 
 
 
 
 
271
 
272
  /**
273
  * Cron schedules
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: MailChimp - WooCommerce plugin
19
- * Version: 2.1.2
20
  * Author: MailChimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
@@ -43,7 +43,7 @@ function mailchimp_environment_variables() {
43
  return (object) array(
44
  'repo' => 'master',
45
  'environment' => 'production',
46
- 'version' => '2.1.2',
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',
@@ -165,7 +165,7 @@ function mailchimp_array_remove_empty($data) {
165
  return array();
166
  }
167
  foreach ($data as $key => $value) {
168
- if ($value === null || $value === '') {
169
  unset($data[$key]);
170
  }
171
  }
@@ -191,30 +191,26 @@ function mailchimp_get_timezone_list() {
191
  return $zones_array;
192
  }
193
 
 
 
 
 
 
 
 
 
 
194
  /**
195
  * The code that runs during plugin activation.
196
  * This action is documented in includes/class-mailchimp-woocommerce-activator.php
197
  */
198
  function activate_mailchimp_woocommerce() {
199
  // if we don't have woocommerce we need to display a horrible error message before the plugin is installed.
200
- if (!is_plugin_active('woocommerce/woocommerce.php')) {
201
-
202
- $active = false;
203
-
204
- // some people may have uploaded a specific version of woo, so we need a fallback checker here.
205
- foreach (array_keys(get_plugins()) as $plugin) {
206
- if (mailchimp_string_contains($plugin, 'woocommerce.php')) {
207
- $active = true;
208
- break;
209
- }
210
- }
211
-
212
- if (!$active) {
213
- // Deactivate the plugin
214
- deactivate_plugins(__FILE__);
215
- $error_message = __('The MailChimp For WooCommerce plugin requires the <a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a> plugin to be active!', 'woocommerce');
216
- wp_die($error_message);
217
- }
218
  }
219
 
220
  // ok we can activate this thing.
@@ -443,7 +439,8 @@ function mailchimp_woocommerce_add_meta_tags() {
443
  echo '<meta name="referrer" content="always"/>';
444
  }
445
 
446
- add_action('wp_head', 'mailchimp_woocommerce_add_meta_tags');
447
-
448
- /** Add all the MailChimp hooks. */
449
- run_mailchimp_woocommerce();
 
16
  * Plugin Name: MailChimp for WooCommerce
17
  * Plugin URI: https://mailchimp.com/connect-your-store/
18
  * Description: MailChimp - WooCommerce plugin
19
+ * Version: 2.1.3
20
  * Author: MailChimp
21
  * Author URI: https://mailchimp.com
22
  * License: GPL-2.0+
43
  return (object) array(
44
  'repo' => 'master',
45
  'environment' => 'production',
46
+ 'version' => '2.1.3',
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',
165
  return array();
166
  }
167
  foreach ($data as $key => $value) {
168
+ if ($value === null || $value === '' || (is_array($value) && empty($value))) {
169
  unset($data[$key]);
170
  }
171
  }
191
  return $zones_array;
192
  }
193
 
194
+ /**
195
+ * @return bool
196
+ */
197
+ function mailchimp_check_woocommerce_plugin_status()
198
+ {
199
+ if (defined("RUNNING_CUSTOM_WOOCOMMERCE") && RUNNING_CUSTOM_WOOCOMMERCE === true) return true;
200
+ return in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option('active_plugins')));
201
+ }
202
+
203
  /**
204
  * The code that runs during plugin activation.
205
  * This action is documented in includes/class-mailchimp-woocommerce-activator.php
206
  */
207
  function activate_mailchimp_woocommerce() {
208
  // if we don't have woocommerce we need to display a horrible error message before the plugin is installed.
209
+ if (!mailchimp_check_woocommerce_plugin_status()) {
210
+ // Deactivate the plugin
211
+ deactivate_plugins(__FILE__);
212
+ $error_message = __('The MailChimp For WooCommerce plugin requires the <a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a> plugin to be active!', 'woocommerce');
213
+ wp_die($error_message);
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
 
216
  // ok we can activate this thing.
439
  echo '<meta name="referrer" content="always"/>';
440
  }
441
 
442
+ if (mailchimp_check_woocommerce_plugin_status()) {
443
+ add_action('wp_head', 'mailchimp_woocommerce_add_meta_tags');
444
+ /** Add all the MailChimp hooks. */
445
+ run_mailchimp_woocommerce();
446
+ }