WooCommerce MailChimp - Version 1.2.1

Version Description

  • WooCommerce 2.1 integration: Change to use wc_enqueue_js instead of add_inline_js
  • WooCommerce 2.1 integration: Change to support new default checkout field filter for default opt-in checkbox status
Download this release

Release Info

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

Code changes from version 1.2 to 1.2.1

README.md CHANGED
@@ -64,6 +64,10 @@ If you need help, have problems, want to leave feedback or want to provide const
64
 
65
  ### Changelog
66
 
 
 
 
 
67
  ##### 1.2
68
  * Added new setting to control whether or not the double opt-in checkbox is checked/unchecked by default on the checkout page.
69
  * Added new setting to control display location of the double opt-in checkbox (under billing info or order info)
64
 
65
  ### Changelog
66
 
67
+ ##### 1.2.1
68
+ * WooCommerce 2.1 integration: Change to use wc_enqueue_js instead of add_inline_js
69
+ * WooCommerce 2.1 integration: Change to support new default checkout field filter for default opt-in checkbox status
70
+
71
  ##### 1.2
72
  * Added new setting to control whether or not the double opt-in checkbox is checked/unchecked by default on the checkout page.
73
  * Added new setting to control display location of the double opt-in checkbox (under billing info or order info)
classes/class-ss-wc-integration-mailchimp.php CHANGED
@@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
9
  *
10
  * @class SS_WC_Integration_MailChimp
11
  * @extends WC_Integration
12
- * @version 1.2
13
  * @package WooCommerce MailChimp
14
  * @author Saint Systems
15
  */
@@ -65,6 +65,7 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
65
 
66
  // Maybe add an "opt-in" field to the checkout
67
  add_filter( 'woocommerce_checkout_fields', array( &$this, 'maybe_add_checkout_fields' ) );
 
68
 
69
  // Maybe save the "opt-in" field on the checkout
70
  add_action( 'woocommerce_checkout_update_order_meta', array( &$this, 'maybe_save_checkout_fields' ) );
@@ -152,7 +153,6 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
152
  * @return void
153
  */
154
  function init_form_fields() {
155
- global $woocommerce;
156
 
157
  if ( is_admin() ) {
158
 
@@ -238,7 +238,7 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
238
  ),
239
  );
240
 
241
- $woocommerce->add_inline_js("
242
  jQuery('#woocommerce_mailchimp_display_opt_in').change(function(){
243
 
244
  jQuery('#mainform [id^=woocommerce_mailchimp_opt_in]').closest('tr').hide('fast');
@@ -256,6 +256,26 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
256
 
257
  } // End init_form_fields()
258
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  /**
260
  * get_lists function.
261
  *
@@ -409,13 +429,23 @@ class SS_WC_Integration_MailChimp extends WC_Integration {
409
  $checkout_fields[$opt_in_checkbox_display_location]['ss_wc_mailchimp_opt_in'] = array(
410
  'type' => 'checkbox',
411
  'label' => esc_attr( $this->opt_in_label ),
412
- 'default' => ( $this->opt_in_checkbox_default_status == 'checked' ? true : false ),
413
  );
414
  }
415
 
416
  return $checkout_fields;
417
  }
418
 
 
 
 
 
 
 
 
 
 
 
419
  /**
420
  * When the checkout form is submitted, save opt-in value.
421
  *
9
  *
10
  * @class SS_WC_Integration_MailChimp
11
  * @extends WC_Integration
12
+ * @version 1.2.1
13
  * @package WooCommerce MailChimp
14
  * @author Saint Systems
15
  */
65
 
66
  // Maybe add an "opt-in" field to the checkout
67
  add_filter( 'woocommerce_checkout_fields', array( &$this, 'maybe_add_checkout_fields' ) );
68
+ add_filter( 'default_checkout_ss_wc_mailchimp_opt_in', array( &$this, 'checkbox_default_status' ) );
69
 
70
  // Maybe save the "opt-in" field on the checkout
71
  add_action( 'woocommerce_checkout_update_order_meta', array( &$this, 'maybe_save_checkout_fields' ) );
153
  * @return void
154
  */
155
  function init_form_fields() {
 
156
 
157
  if ( is_admin() ) {
158
 
238
  ),
239
  );
240
 
241
+ $this->wc_enqueue_js("
242
  jQuery('#woocommerce_mailchimp_display_opt_in').change(function(){
243
 
244
  jQuery('#mainform [id^=woocommerce_mailchimp_opt_in]').closest('tr').hide('fast');
256
 
257
  } // End init_form_fields()
258
 
259
+ /**
260
+ * WooCommerce 2.1 support for wc_enqueue_js
261
+ *
262
+ * @since 1.2.1
263
+ *
264
+ * @access private
265
+ * @param string $code
266
+ * @return void
267
+ */
268
+ private function wc_enqueue_js( $code ) {
269
+
270
+ if ( function_exists( 'wc_enqueue_js' ) ) {
271
+ wc_enqueue_js( $code );
272
+ } else {
273
+ global $woocommerce;
274
+ $woocommerce->add_inline_js( $code );
275
+ }
276
+
277
+ }
278
+
279
  /**
280
  * get_lists function.
281
  *
429
  $checkout_fields[$opt_in_checkbox_display_location]['ss_wc_mailchimp_opt_in'] = array(
430
  'type' => 'checkbox',
431
  'label' => esc_attr( $this->opt_in_label ),
432
+ 'default' => ( $this->opt_in_checkbox_default_status == 'checked' ? 1 : 0 ),
433
  );
434
  }
435
 
436
  return $checkout_fields;
437
  }
438
 
439
+ /**
440
+ * Opt-in checkbox default support for WooCommerce 2.1
441
+ *
442
+ * @since 1.2.1
443
+ */
444
+ function checkbox_default_status( $input ) {
445
+
446
+ return $this->opt_in_checkbox_default_status == 'checked' ? 1 : 0;
447
+ }
448
+
449
  /**
450
  * When the checkout form is submitted, save opt-in value.
451
  *
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: anderly, saintsystems
3
  Tags: woocommerce, mailchimp
4
  Requires at least: 3.6
5
- Tested up to: 3.8
6
- Stable tag: 1.2
7
  License: GPLv3
8
 
9
  Simple and flexible MailChimp integration for WooCommerce.
@@ -78,6 +78,10 @@ If you need help, have problems, want to leave feedback or want to provide const
78
 
79
  == Changelog ==
80
 
 
 
 
 
81
  = 1.2 =
82
  * Added new setting to control whether or not the double opt-in checkbox is checked/unchecked by default on the checkout page.
83
  * Added new setting to control display location of the double opt-in checkbox (under billing info or order info)
2
  Contributors: anderly, saintsystems
3
  Tags: woocommerce, mailchimp
4
  Requires at least: 3.6
5
+ Tested up to: 3.8.1
6
+ Stable tag: 1.2.1
7
  License: GPLv3
8
 
9
  Simple and flexible MailChimp integration for WooCommerce.
78
 
79
  == Changelog ==
80
 
81
+ = 1.2.1 =
82
+ * WooCommerce 2.1 integration: Change to use wc_enqueue_js instead of add_inline_js
83
+ * WooCommerce 2.1 integration: Change to support new default checkout field filter for default opt-in checkbox status
84
+
85
  = 1.2 =
86
  * Added new setting to control whether or not the double opt-in checkbox is checked/unchecked by default on the checkout page.
87
  * Added new setting to control display location of the double opt-in checkbox (under billing info or order info)
woocommerce-mailchimp.php CHANGED
@@ -5,11 +5,11 @@
5
  * Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
6
  * Author: Adam Anderly
7
  * Author URI: http://anderly.com
8
- * Version: 1.2
9
  * Text Domain: ss_wc_mailchimp
10
  * Domain Path: languages
11
  *
12
- * Copyright: � 2013 Adam Anderly
13
  * License: GNU General Public License v3.0
14
  * License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
  *
5
  * Description: WooCommerce MailChimp provides simple MailChimp integration for WooCommerce.
6
  * Author: Adam Anderly
7
  * Author URI: http://anderly.com
8
+ * Version: 1.2.1
9
  * Text Domain: ss_wc_mailchimp
10
  * Domain Path: languages
11
  *
12
+ * Copyright: � 2014 Adam Anderly
13
  * License: GNU General Public License v3.0
14
  * License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
  *