WooCommerce MailChimp - Version 2.3.1

Version Description

Download this release

Release Info

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

Code changes from version 2.3.0 to 2.3.1

includes/class-ss-wc-mailchimp-handler.php CHANGED
@@ -397,6 +397,15 @@ if ( ! class_exists( 'SS_WC_MailChimp_Handler' ) ) {
397
 
398
  $tags = $this->sswcmc->tags();
399
 
 
 
 
 
 
 
 
 
 
400
  // Allow hooking into tags.
401
  $tags = apply_filters( 'ss_wc_mailchimp_subscribe_tags', $tags, $order_id, $email );
402
 
397
 
398
  $tags = $this->sswcmc->tags();
399
 
400
+ $mc_tags = $this->sswcmc->mailchimp()->get_tags( $list_id );
401
+
402
+ $tags = array_map( function( $tag ) use ( $mc_tags ) {
403
+ return array(
404
+ 'name' => $mc_tags[$tag],
405
+ 'status' => 'active',
406
+ );
407
+ }, $tags );
408
+
409
  // Allow hooking into tags.
410
  $tags = apply_filters( 'ss_wc_mailchimp_subscribe_tags', $tags, $order_id, $email );
411
 
includes/class-ss-wc-mailchimp-migrator.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
 
3
  /**
4
  * WooCommerce MailChimp plugin migrator class
@@ -6,28 +6,34 @@
6
  final class SS_WC_MailChimp_Migrator {
7
 
8
  const VERSION_KEY = 'ss_wc_mailchimp_version';
 
 
9
  const OLD_SETTINGS_KEY = 'woocommerce_mailchimp_settings';
10
 
11
  protected static $versions = array(
12
  '1.3.X',
13
  '2.0',
14
  '2.0.15',
 
 
15
  );
16
 
17
  public static function migrate( $target_version ) {
18
 
19
- $old_settings = get_option( self::OLD_SETTINGS_KEY );
20
  $current_version = get_option( self::VERSION_KEY );
 
 
21
 
22
- if ( ! $old_settings && ! $current_version ) {
23
  // This is a new install, so no need to migrate
 
24
  return;
25
  }
26
 
27
  if ( ! $current_version ) {
28
- $current_version = '1.3.X';
29
  }
30
-
31
  if ( $current_version !== $target_version ) {
32
 
33
  // error_log( 'Need to migrate from ' . $current_version . ' to ' . $target_version );
@@ -44,9 +50,11 @@ final class SS_WC_MailChimp_Migrator {
44
  $next_version = self::$versions[$next];
45
 
46
  // error_log( 'Migrating from ' . $current_version . ' to ' . $target_version );
47
- //
48
  if ( file_exists( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" ) ) {
49
 
 
 
50
  require_once( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" );
51
 
52
  $migration_name = 'SS_WC_MailChimp_Migration_From_'. self::clean_version( $current_version ) .'_To_'. self::clean_version( $next_version );
@@ -55,8 +63,14 @@ final class SS_WC_MailChimp_Migrator {
55
  if ( $migration->up() ) {
56
  // Update the current plugin version
57
  update_option( self::VERSION_KEY, $next_version );
 
58
  }
59
 
 
 
 
 
 
60
  }
61
  }
62
  //update_option( self::VERSION_KEY, $target_version );
@@ -69,4 +83,4 @@ final class SS_WC_MailChimp_Migrator {
69
  return str_replace( '.', '_', $version );
70
  }
71
 
72
- }
1
+ <?php
2
 
3
  /**
4
  * WooCommerce MailChimp plugin migrator class
6
  final class SS_WC_MailChimp_Migrator {
7
 
8
  const VERSION_KEY = 'ss_wc_mailchimp_version';
9
+ const API_KEY = 'ss_wc_mailchimp_api_key';
10
+ const LIST_KEY = 'ss_wc_mailchimp_list';
11
  const OLD_SETTINGS_KEY = 'woocommerce_mailchimp_settings';
12
 
13
  protected static $versions = array(
14
  '1.3.X',
15
  '2.0',
16
  '2.0.15',
17
+ '2.3.0',
18
+ '2.3.1',
19
  );
20
 
21
  public static function migrate( $target_version ) {
22
 
 
23
  $current_version = get_option( self::VERSION_KEY );
24
+ $api_key = get_option( self::API_KEY );
25
+ $list = get_option( self::LIST_KEY );
26
 
27
+ if ( ! $current_version && ! $api_key && ! $list ) {
28
  // This is a new install, so no need to migrate
29
+ update_option( self::VERSION_KEY, $target_version );
30
  return;
31
  }
32
 
33
  if ( ! $current_version ) {
34
+ $current_version = '2.3.0';
35
  }
36
+
37
  if ( $current_version !== $target_version ) {
38
 
39
  // error_log( 'Need to migrate from ' . $current_version . ' to ' . $target_version );
50
  $next_version = self::$versions[$next];
51
 
52
  // error_log( 'Migrating from ' . $current_version . ' to ' . $target_version );
53
+ //
54
  if ( file_exists( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" ) ) {
55
 
56
+ do_action( 'sswcmc_log', 'Migrating from ' . $current_version . ' to ' . $target_version );
57
+
58
  require_once( SS_WC_MAILCHIMP_DIR . "includes/migrations/class-ss-wc-migration-from-$current_version-to-$next_version.php" );
59
 
60
  $migration_name = 'SS_WC_MailChimp_Migration_From_'. self::clean_version( $current_version ) .'_To_'. self::clean_version( $next_version );
63
  if ( $migration->up() ) {
64
  // Update the current plugin version
65
  update_option( self::VERSION_KEY, $next_version );
66
+ do_action( 'sswcmc_log', 'Finished Migrating from ' . $current_version . ' to ' . $target_version );
67
  }
68
 
69
+ } else {
70
+ // Update the current plugin version
71
+ do_action( 'sswcmc_log', 'No migration found from ' . $current_version . ' to ' . $next_version . '. Setting current version to: ' . $next_version );
72
+
73
+ update_option( self::VERSION_KEY, $next_version );
74
  }
75
  }
76
  //update_option( self::VERSION_KEY, $target_version );
83
  return str_replace( '.', '_', $version );
84
  }
85
 
86
+ }
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.3.0';
19
 
20
  /**
21
  * Plugin singleton instance
15
  *
16
  * @var string
17
  */
18
+ private static $version = '2.3.1';
19
 
20
  /**
21
  * Plugin singleton instance
includes/class-ss-wc-mailchimp.php CHANGED
@@ -456,7 +456,7 @@ class SS_WC_MailChimp {
456
 
457
  foreach ( $tags as $tag ) {
458
 
459
- $results[ $tag['name'] ] = $tag['name'];
460
 
461
  }
462
 
456
 
457
  foreach ( $tags as $tag ) {
458
 
459
+ $results[ $tag['id'] ] = $tag['name'];
460
 
461
  }
462
 
includes/migrations/class-ss-wc-migration-from-2.3.0-to-2.3.1.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ final class SS_WC_MailChimp_Migration_From_2_3_0_To_2_3_1 extends SS_WC_MailChimp_Migration {
4
+
5
+ public function __construct( $current_version, $target_version ) {
6
+ parent::__construct( $current_version, $target_version );
7
+ }
8
+
9
+ /**
10
+ * [up description]
11
+ * @return [type] [description]
12
+ */
13
+ public function up() {
14
+
15
+ try {
16
+
17
+ $existing_tags = $this->settings['tags'];
18
+
19
+ if ( is_array( $existing_tags ) && ! empty( $existing_tags ) ) {
20
+
21
+ $list_id = $this->settings['list'];
22
+ if ( ! empty( $list_id ) ) {
23
+
24
+ $current_tags = $this->mailchimp->get_tags( $list_id );
25
+
26
+ if ( ! empty( $current_tags ) ) {
27
+
28
+ // Let's correct the tags
29
+ $new_tags = array_filter( $current_tags, function ( $tag_name ) use ( $existing_tags ) {
30
+ return in_array( $tag_name, $existing_tags );
31
+ });
32
+
33
+ $this->settings['tags'] = array_map('strval', array_keys( $new_tags ) );
34
+
35
+ // Save the settings
36
+ $this->save_settings();
37
+
38
+ }
39
+
40
+ }
41
+
42
+ }
43
+
44
+ } catch (Exception $e) {
45
+ return false;
46
+ }
47
+
48
+ return true;
49
+
50
+ }
51
+
52
+ /**
53
+ * [down description]
54
+ * @return [type] [description]
55
+ */
56
+ public function down() {
57
+
58
+ throw new Exception('Cannot rollback to versions prior to 2.3.1');
59
+
60
+ }
61
+
62
+ }
readme.txt CHANGED
@@ -4,9 +4,9 @@ Donate link: http://ssms.us/hVdk
4
  Tags: woocommerce, mailchimp, ecommerce, email
5
  Requires at least: 4.7.0
6
  Tested up to: 5.2.2
7
- WC tested up to: 3.6.5
8
  Requires PHP: 5.6
9
- Stable tag: 2.3.0
10
  License: GPLv3
11
 
12
  Simple and flexible Mailchimp integration for WooCommerce.
@@ -119,6 +119,11 @@ Also, if you enjoy using the software [we'd love it if you could give us a revie
119
 
120
  == Changelog ==
121
 
 
 
 
 
 
122
  #### 2.3.0 - July 25, 2019
123
  - Added support for tags on main list.
124
  - Improved integration with WooCommerce Mailchimp Pro.
4
  Tags: woocommerce, mailchimp, ecommerce, email
5
  Requires at least: 4.7.0
6
  Tested up to: 5.2.2
7
+ WC tested up to: 3.7.0
8
  Requires PHP: 5.6
9
+ Stable tag: 2.3.1
10
  License: GPLv3
11
 
12
  Simple and flexible Mailchimp integration for WooCommerce.
119
 
120
  == Changelog ==
121
 
122
+ #### 2.3.1 - August 26, 2019
123
+ - Fix tag retrieval to return tag IDs.
124
+ - Fix migrations.
125
+ - Tested up to WooCommerce 3.7.0
126
+
127
  #### 2.3.0 - July 25, 2019
128
  - Added support for tags on main list.
129
  - Improved integration with WooCommerce Mailchimp Pro.
woocommerce-mailchimp.php CHANGED
@@ -5,8 +5,8 @@
5
  * Description: WooCommerce Mailchimp provides simple and flexible Mailchimp integration for WooCommerce.
6
  * Author: Saint Systems
7
  * Author URI: https://www.saintsystems.com
8
- * Version: 2.3.0
9
- * WC tested up to: 3.6.5
10
  * Text Domain: woocommerce-mailchimp
11
  * Domain Path: languages
12
  *
5
  * Description: WooCommerce Mailchimp provides simple and flexible Mailchimp integration for WooCommerce.
6
  * Author: Saint Systems
7
  * Author URI: https://www.saintsystems.com
8
+ * Version: 2.3.1
9
+ * WC tested up to: 3.7.0
10
  * Text Domain: woocommerce-mailchimp
11
  * Domain Path: languages
12
  *