WooCommerce MailChimp - Version 2.1.3

Version Description

Download this release

Release Info

Developer anderly
Plugin Icon 128x128 WooCommerce MailChimp
Version 2.1.3
Comparing to
See all releases

Code changes from version 2.1.2 to 2.1.3

includes/class-ss-wc-mailchimp-plugin.php CHANGED
@@ -15,7 +15,7 @@ final class SS_WC_MailChimp_Plugin {
15
  *
16
  * @var string
17
  */
18
- private static $version = '2.1.2';
19
 
20
  /**
21
  * Plugin singleton instance
15
  *
16
  * @var string
17
  */
18
+ private static $version = '2.1.3';
19
 
20
  /**
21
  * Plugin singleton instance
includes/class-ss-wc-mailchimp.php CHANGED
@@ -38,7 +38,7 @@ class SS_WC_MailChimp {
38
 
39
  /**
40
  * Get account
41
- *
42
  * @access public
43
  * @return mixed
44
  */
@@ -55,6 +55,20 @@ class SS_WC_MailChimp {
55
  $account = $api->get( $resource );
56
 
57
  if ( ! $account ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  return false;
59
  }
60
 
@@ -64,7 +78,7 @@ class SS_WC_MailChimp {
64
 
65
  /**
66
  * Get list
67
- *
68
  * @access public
69
  * @return mixed
70
  */
@@ -181,7 +195,7 @@ class SS_WC_MailChimp {
181
 
182
  /**
183
  * Get merge fields
184
- *
185
  * @access public
186
  * @param string $list_id
187
  * @return mixed
38
 
39
  /**
40
  * Get account
41
+ *
42
  * @access public
43
  * @return mixed
44
  */
55
  $account = $api->get( $resource );
56
 
57
  if ( ! $account ) {
58
+ $last_response = $api->get_last_response();
59
+ if (floor( $last_response['response']['code'] ) / 100 >= 4) {
60
+ $body = $last_response['body'];
61
+ $errorMessage = $last_response['response']['code'] . ' ' . $last_response['response']['message'];
62
+ if (preg_match("'<h1>(.*)</h1>'si", $body, $matches)) {
63
+ $errorMessage .= '<br/>' . $matches[1] . ': ';
64
+ }
65
+ if (preg_match("'<p>(.*)</p>'si", $body, $matches)) {
66
+ $errorMessage .= $matches[1];
67
+ }
68
+ return array(
69
+ 'error' => $errorMessage
70
+ );
71
+ }
72
  return false;
73
  }
74
 
78
 
79
  /**
80
  * Get list
81
+ *
82
  * @access public
83
  * @return mixed
84
  */
195
 
196
  /**
197
  * Get merge fields
198
+ *
199
  * @access public
200
  * @param string $list_id
201
  * @return mixed
includes/class-ss-wc-settings-mailchimp.php CHANGED
@@ -197,7 +197,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
197
  // Check required fields
198
  if ( $this->is_enabled() && ! $this->has_api_key() ) {
199
  // Show notice
200
- echo $this->get_message( sprintf( __( 'WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter your api key <a href="%s">here</a>.', 'woocommerce-mailchimp' ), WOOCOMMERCE_MAILCHIMP_SETTINGS_URL )
201
  );
202
  }
203
  }
@@ -646,7 +646,7 @@ if ( ! class_exists( 'SS_WC_Settings_MailChimp' ) ) {
646
  public function mailchimp_api_error_msg() {
647
  echo $this->get_message(
648
  sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'woocommerce-mailchimp' ), $this->mailchimp()->get_error_code(), $this->mailchimp()->get_error_message() ) .
649
- sprintf( __( 'Please check your Settings %ssettings%s.', 'woocommerce-mailchimp' ), '<a href="' . WOOCOMMERCE_MAILCHIMP_SETTINGS_URL .'">', '</a>' )
650
  );
651
  } //end function mailchimp_api_error_msg
652
 
197
  // Check required fields
198
  if ( $this->is_enabled() && ! $this->has_api_key() ) {
199
  // Show notice
200
+ echo $this->get_message( sprintf( __( 'WooCommerce MailChimp error: Plugin is enabled but no api key provided. Please enter your api key <a href="%s">here</a>.', 'woocommerce-mailchimp' ), SS_WC_MAILCHIMP_SETTINGS_URL )
201
  );
202
  }
203
  }
646
  public function mailchimp_api_error_msg() {
647
  echo $this->get_message(
648
  sprintf( __( 'Unable to load lists from MailChimp: (%s) %s. ', 'woocommerce-mailchimp' ), $this->mailchimp()->get_error_code(), $this->mailchimp()->get_error_message() ) .
649
+ sprintf( __( 'Please check your Settings %ssettings%s.', 'woocommerce-mailchimp' ), '<a href="' . SS_WC_MAILCHIMP_SETTINGS_URL .'">', '</a>' )
650
  );
651
  } //end function mailchimp_api_error_msg
652
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://ssms.us/hVdk
4
  Tags: woocommerce, mailchimp
5
  Requires at least: 3.5.1
6
  Tested up to: 4.8.1
7
- Stable tag: 2.1.2
8
  License: GPLv3
9
 
10
  Simple and flexible MailChimp integration for WooCommerce.
@@ -113,6 +113,9 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
113
 
114
  == Changelog ==
115
 
 
 
 
116
  #### 2.1.2 - August 25, 2017
117
  - Fix retrieval of mailchimp lists with numeric ids.
118
 
4
  Tags: woocommerce, mailchimp
5
  Requires at least: 3.5.1
6
  Tested up to: 4.8.1
7
+ Stable tag: 2.1.3
8
  License: GPLv3
9
 
10
  Simple and flexible MailChimp integration for WooCommerce.
113
 
114
  == Changelog ==
115
 
116
+ #### 2.1.3 - December 19, 2017
117
+ - Small fix to show MailChimp API error message in UI.
118
+
119
  #### 2.1.2 - August 25, 2017
120
  - Fix retrieval of mailchimp lists with numeric ids.
121
 
woocommerce-mailchimp.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
6
  * Author: Saint Systems
7
  * Author URI: https://www.saintsystems.com
8
- * Version: 2.1.2
9
  * Text Domain: woocommerce-mailchimp
10
  * Domain Path: languages
11
  *
5
  * Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
6
  * Author: Saint Systems
7
  * Author URI: https://www.saintsystems.com
8
+ * Version: 2.1.3
9
  * Text Domain: woocommerce-mailchimp
10
  * Domain Path: languages
11
  *