WooCommerce MailChimp - Version 2.1.6

Version Description

Download this release

Release Info

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

Code changes from version 2.1.5 to 2.1.6

includes/class-ss-wc-mailchimp-handler.php CHANGED
@@ -70,8 +70,8 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
70
  $order_billing_first_name = method_exists($order, 'get_billing_first_name') ? $order->get_billing_first_name(): $order->billing_first_name;
71
  $order_billing_last_name = method_exists($order, 'get_billing_last_name') ? $order->get_billing_last_name(): $order->billing_last_name;
72
 
73
- // If the 'ss_wc_mailchimp_opt_in' meta value isn't set
74
- // (because 'display_opt_in' wasn't enabled at the time the order was placed)
75
  // or the 'ss_wc_mailchimp_opt_in' is yes, subscriber the customer
76
  if ( ! $subscribe_customer || empty( $subscribe_customer ) || 'yes' === $subscribe_customer ) {
77
  // log
@@ -131,7 +131,7 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
131
 
132
  /**
133
  * Return all lists from MailChimp to be used in select fields
134
- *
135
  * @access public
136
  * @return array
137
  */
@@ -139,6 +139,10 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
139
 
140
  try {
141
 
 
 
 
 
142
  if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
143
 
144
  throw new Exception( __( 'Please enter an api key.', 'woocommerce-mailchimp' ) );
@@ -164,7 +168,7 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
164
 
165
  /**
166
  * Return all lists from MailChimp to be used in select fields
167
- *
168
  * @access public
169
  * @return array
170
  */
@@ -197,7 +201,7 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
197
 
198
  /**
199
  * Return interest categories for the passed MailChimp List to be used in select fields
200
- *
201
  * @access public
202
  * @return array
203
  */
@@ -237,7 +241,7 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
237
 
238
  /**
239
  * Return merge fields (a.k.a. merge tags) for the passed MailChimp List
240
- *
241
  * @access public
242
  * @return array
243
  */
@@ -412,10 +416,20 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
412
  * @since 1.1
413
  */
414
  function maybe_add_checkout_fields() {
 
415
  if ( $this->sswcmc->is_valid() ) {
416
  if ( $this->sswcmc->display_opt_in() ) {
417
  do_action( $this->namespace_prefixed( 'before_opt_in_checkbox' ) );
418
- echo apply_filters( $this->namespace_prefixed( 'opt_in_checkbox' ), '<p class="form-row woocommerce-mailchimp-opt-in"><input type="checkbox" name="ss_wc_mailchimp_opt_in" id="ss_wc_mailchimp_opt_in" value="yes"' . ($this->sswcmc->opt_in_checkbox_default_status() == 'checked' ? ' checked="checked"' : '') . '/> <label for="ss_wc_mailchimp_opt_in">' . esc_html( $this->sswcmc->opt_in_label() ) . '</label></p>' . "\n", $this->sswcmc->opt_in_checkbox_default_status(), $this->sswcmc->opt_in_label() );
 
 
 
 
 
 
 
 
 
419
  do_action( $this->namespace_prefixed( 'after_opt_in_checkbox' ) );
420
  }
421
  }
@@ -454,4 +468,4 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
454
 
455
  } //end class SS_WC_MailChimp_Handler
456
 
457
- } //end if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) )
70
  $order_billing_first_name = method_exists($order, 'get_billing_first_name') ? $order->get_billing_first_name(): $order->billing_first_name;
71
  $order_billing_last_name = method_exists($order, 'get_billing_last_name') ? $order->get_billing_last_name(): $order->billing_last_name;
72
 
73
+ // If the 'ss_wc_mailchimp_opt_in' meta value isn't set
74
+ // (because 'display_opt_in' wasn't enabled at the time the order was placed)
75
  // or the 'ss_wc_mailchimp_opt_in' is yes, subscriber the customer
76
  if ( ! $subscribe_customer || empty( $subscribe_customer ) || 'yes' === $subscribe_customer ) {
77
  // log
131
 
132
  /**
133
  * Return all lists from MailChimp to be used in select fields
134
+ *
135
  * @access public
136
  * @return array
137
  */
139
 
140
  try {
141
 
142
+ if ( !isset($_POST['data']) ) {
143
+ throw new Exception( __( __METHOD__ . ': $_POST[\'data\'] not provided.', 'woocommerce-mailchimp' ) );
144
+ }
145
+
146
  if ( !$_POST['data']['api_key'] || empty( $_POST['data']['api_key'] ) ) {
147
 
148
  throw new Exception( __( 'Please enter an api key.', 'woocommerce-mailchimp' ) );
168
 
169
  /**
170
  * Return all lists from MailChimp to be used in select fields
171
+ *
172
  * @access public
173
  * @return array
174
  */
201
 
202
  /**
203
  * Return interest categories for the passed MailChimp List to be used in select fields
204
+ *
205
  * @access public
206
  * @return array
207
  */
241
 
242
  /**
243
  * Return merge fields (a.k.a. merge tags) for the passed MailChimp List
244
+ *
245
  * @access public
246
  * @return array
247
  */
416
  * @since 1.1
417
  */
418
  function maybe_add_checkout_fields() {
419
+
420
  if ( $this->sswcmc->is_valid() ) {
421
  if ( $this->sswcmc->display_opt_in() ) {
422
  do_action( $this->namespace_prefixed( 'before_opt_in_checkbox' ) );
423
+
424
+ echo apply_filters( $this->namespace_prefixed( 'opt_in_checkbox' ), '<p class="form-row woocommerce-mailchimp-opt-in"><label class="checkbox" for="ss_wc_mailchimp_opt_in"><input type="checkbox" name="ss_wc_mailchimp_opt_in" id="ss_wc_mailchimp_opt_in" class="input-checkbox" value="yes"' . ($this->sswcmc->opt_in_checkbox_default_status() == 'checked' ? ' checked="checked"' : '') . '/> ' . esc_html( $this->sswcmc->opt_in_label() ) . '</label></p>' . "\n", $this->sswcmc->opt_in_checkbox_default_status(), $this->sswcmc->opt_in_label(), $this->sswcmc->opt_in_checkbox_default_status(), $this->sswcmc->opt_in_label() );
425
+ // woocommerce_form_field( '2ss_wc_mailchimp_opt_in', array(
426
+ // 'type' => 'checkbox',
427
+ // 'class' => array('woocommerce-mailchimp-opt-in'),
428
+ // 'label' => esc_html( $this->sswcmc->opt_in_label() ),
429
+ // 'custom_attributes' => array(
430
+ // 'for' => '2ss_wc_mailchimp_opt_in',
431
+ // ),
432
+ // ), $this->sswcmc->opt_in_checkbox_default_status() == 'checked' );
433
  do_action( $this->namespace_prefixed( 'after_opt_in_checkbox' ) );
434
  }
435
  }
468
 
469
  } //end class SS_WC_MailChimp_Handler
470
 
471
+ } //end if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) )
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.5';
19
 
20
  /**
21
  * Plugin singleton instance
15
  *
16
  * @var string
17
  */
18
+ private static $version = '2.1.6';
19
 
20
  /**
21
  * Plugin singleton instance
includes/class-ss-wc-mailchimp.php CHANGED
@@ -182,6 +182,36 @@ class SS_WC_MailChimp {
182
 
183
  } //end function subscribe
184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  /**
186
  * Returns the MD5 hash of the email
187
  * @param string $email_address The email address to hash
182
 
183
  } //end function subscribe
184
 
185
+ /**
186
+ * Unsubscribe the user from the list
187
+ * @param string $list_id The MailChimp list ID
188
+ * @param string $email_address The user's email address
189
+ * @return mixed $response The MailChimp API response
190
+ */
191
+ public function unsubscribe( $list_id, $email_address ) {
192
+
193
+ $args = array(
194
+ 'status' => 'unsubscribed',
195
+ );
196
+
197
+ if ( ! $subscriber_status = $this->get_subscriber_status( $list_id, $email_address ) ) {
198
+ return false;
199
+ }
200
+
201
+ $subscriber_hash = $this->get_subscriber_hash( $email_address );
202
+
203
+ $resource = "lists/$list_id/members/$subscriber_hash";
204
+
205
+ $response = $this->api->put( $resource, $args );
206
+
207
+ if ( ! $response ) {
208
+ return false;
209
+ }
210
+
211
+ return $response;
212
+
213
+ } //end function subscribe
214
+
215
  /**
216
  * Returns the MD5 hash of the email
217
  * @param string $email_address The email address to hash
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.9.1
7
- Stable tag: 2.1.5
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.5 - January 25, 2018
117
  - Move opt-in checkbox before associated label
118
 
4
  Tags: woocommerce, mailchimp
5
  Requires at least: 3.5.1
6
  Tested up to: 4.9.1
7
+ Stable tag: 2.1.6
8
  License: GPLv3
9
 
10
  Simple and flexible MailChimp integration for WooCommerce.
113
 
114
  == Changelog ==
115
 
116
+ #### 2.1.6 - January 26, 2018
117
+ - Restore opt-in checkbox location and add params to filter to allow easier adjustment of its placement.
118
+
119
  #### 2.1.5 - January 25, 2018
120
  - Move opt-in checkbox before associated label
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.5
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.6
9
  * Text Domain: woocommerce-mailchimp
10
  * Domain Path: languages
11
  *