MailChimp for WordPress - Version 4.0.6

Version Description

Download this release

Release Info

Developer DvanKooten
Plugin Icon 128x128 MailChimp for WordPress
Version 4.0.6
Comparing to
See all releases

Code changes from version 4.0.5 to 4.0.6

CHANGELOG.md CHANGED
@@ -1,6 +1,21 @@
1
  Changelog
2
  =========
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  #### 4.0.5 - September 29, 2016
5
 
6
  **Fixes**
1
  Changelog
2
  =========
3
 
4
+ #### 4.0.6 - October 10, 2016
5
+
6
+ **Fixes**
7
+
8
+ - Issue with lists not showing when using W3 Total Cache with APCu object cache enabled.
9
+
10
+ **Improvements**
11
+
12
+ - We're no longer stripping newlines from text fields.
13
+
14
+ **Additions**
15
+
16
+ - Added missing e-commerce related API methods to API class.
17
+
18
+
19
  #### 4.0.5 - September 29, 2016
20
 
21
  **Fixes**
includes/api/class-api-v3.php CHANGED
@@ -180,6 +180,20 @@ class MC4WP_API_v3 {
180
  return $data;
181
  }
182
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  /**
184
  * Add or update (!) a member to a MailChimp list.
185
  *
@@ -341,6 +355,20 @@ class MC4WP_API_v3 {
341
  return $this->client->put( $resource, $args );
342
  }
343
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  /**
345
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/customers/#delete-delete_ecommerce_stores_store_id_customers_customer_id
346
  *
@@ -367,6 +395,20 @@ class MC4WP_API_v3 {
367
  return $this->client->get( $resource, $args );
368
  }
369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
  /**
371
  * Add a product to a store
372
  *
@@ -382,20 +424,6 @@ class MC4WP_API_v3 {
382
  return $this->client->post( $resource, $args );
383
  }
384
 
385
- /**
386
- * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/#read-get_ecommerce_stores_store_id_products_product_id
387
- *
388
- * @param string $store_id
389
- * @param string $product_id
390
- * @param array $args
391
- *
392
- * @return object
393
- */
394
- public function get_ecommerce_store_product( $store_id, $product_id, array $args = array() ) {
395
- $resource = sprintf( '/ecommerce/stores/%s/products/%s', $store_id, $product_id );
396
- return $this->client->get( $resource, $args );
397
- }
398
-
399
  /**
400
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/#delete-delete_ecommerce_stores_store_id_products_product_id
401
  *
@@ -454,6 +482,21 @@ class MC4WP_API_v3 {
454
  return $this->client->put( $resource, $args );
455
  }
456
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  /**
458
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/variants/#delete-delete_ecommerce_stores_store_id_products_product_id_variants_variant_id
459
  *
@@ -548,6 +591,21 @@ class MC4WP_API_v3 {
548
  return $this->client->post( $resource, $args );
549
  }
550
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
  /**
552
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#read-get_ecommerce_stores_store_id_orders_order_id_lines_line_id
553
  *
@@ -563,6 +621,21 @@ class MC4WP_API_v3 {
563
  return $this->client->get( $resource, $args );
564
  }
565
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  /**
567
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#delete-delete_ecommerce_stores_store_id_orders_order_id_lines_line_id
568
  *
@@ -573,7 +646,146 @@ class MC4WP_API_v3 {
573
  * @return bool
574
  */
575
  public function delete_ecommerce_store_order_line( $store_id, $order_id, $line_id ) {
576
- return !! $this->client->delete( sprintf( '/ecommerce/stores/%s/orders/%s/lines/%s', $store_id, $order_id, $line_id ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
577
  }
578
 
579
  /**
180
  return $data;
181
  }
182
 
183
+ /**
184
+ * Batch subscribe / unsubscribe list members.
185
+ *
186
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#create-post_lists_list_id
187
+ *
188
+ * @param string $list_id
189
+ * @param array $args
190
+ * @return object
191
+ */
192
+ public function add_list_members( $list_id, array $args ) {
193
+ $resource = sprintf( '/lists/%s', $list_id );
194
+ return $this->client->post( $resource, $args );
195
+ }
196
+
197
  /**
198
  * Add or update (!) a member to a MailChimp list.
199
  *
355
  return $this->client->put( $resource, $args );
356
  }
357
 
358
+ /**
359
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/customers/#edit-patch_ecommerce_stores_store_id_customers_customer_id
360
+ *
361
+ * @param string $store_id
362
+ * @param string $customer_id
363
+ * @param array $args
364
+ *
365
+ * @return object
366
+ */
367
+ public function update_ecommerce_store_customer( $store_id, $customer_id, array $args ) {
368
+ $resource = sprintf( '/ecommerce/stores/%s/customers/%s', $store_id, $customer_id );
369
+ return $this->client->patch( $resource, $args );
370
+ }
371
+
372
  /**
373
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/customers/#delete-delete_ecommerce_stores_store_id_customers_customer_id
374
  *
395
  return $this->client->get( $resource, $args );
396
  }
397
 
398
+ /**
399
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/#read-get_ecommerce_stores_store_id_products_product_id
400
+ *
401
+ * @param string $store_id
402
+ * @param string $product_id
403
+ * @param array $args
404
+ *
405
+ * @return object
406
+ */
407
+ public function get_ecommerce_store_product( $store_id, $product_id, array $args = array() ) {
408
+ $resource = sprintf( '/ecommerce/stores/%s/products/%s', $store_id, $product_id );
409
+ return $this->client->get( $resource, $args );
410
+ }
411
+
412
  /**
413
  * Add a product to a store
414
  *
424
  return $this->client->post( $resource, $args );
425
  }
426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
  /**
428
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/#delete-delete_ecommerce_stores_store_id_products_product_id
429
  *
482
  return $this->client->put( $resource, $args );
483
  }
484
 
485
+ /**
486
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/variants/#edit-patch_ecommerce_stores_store_id_products_product_id_variants_variant_id
487
+ *
488
+ * @param string $store_id
489
+ * @param string $product_id
490
+ * @param string $variant_id
491
+ * @param array $args
492
+ *
493
+ * @return object
494
+ */
495
+ public function update_ecommerce_store_product_variant( $store_id, $product_id, $variant_id, array $args ) {
496
+ $resource = sprintf( '/ecommerce/stores/%s/products/%s/variants/%s', $store_id, $product_id, $variant_id );
497
+ return $this->client->patch( $resource, $args );
498
+ }
499
+
500
  /**
501
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/products/variants/#delete-delete_ecommerce_stores_store_id_products_product_id_variants_variant_id
502
  *
591
  return $this->client->post( $resource, $args );
592
  }
593
 
594
+
595
+ /**
596
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#read-get_ecommerce_stores_store_id_orders_order_id_lines
597
+ *
598
+ * @param string $store_id
599
+ * @param string $order_id
600
+ * @param array $args
601
+ *
602
+ * @return object
603
+ */
604
+ public function get_ecommerce_store_order_lines( $store_id, $order_id, array $args = array() ) {
605
+ $resource = sprintf( '/ecommerce/stores/%s/orders/%s/lines', $store_id, $order_id );
606
+ return $this->client->get( $resource, $args );
607
+ }
608
+
609
  /**
610
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#read-get_ecommerce_stores_store_id_orders_order_id_lines_line_id
611
  *
621
  return $this->client->get( $resource, $args );
622
  }
623
 
624
+ /**
625
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#edit-patch_ecommerce_stores_store_id_orders_order_id_lines_line_id
626
+ *
627
+ * @param string $store_id
628
+ * @param string $order_id
629
+ * @param string $line_id
630
+ * @param array $args
631
+ *
632
+ * @return object
633
+ */
634
+ public function update_ecommerce_store_order_line( $store_id, $order_id, $line_id, array $args ) {
635
+ $resource = sprintf( '/ecommerce/stores/%s/orders/%s/lines/%s', $store_id, $order_id, $line_id );
636
+ return $this->client->patch( $resource, $args );
637
+ }
638
+
639
  /**
640
  * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/orders/lines/#delete-delete_ecommerce_stores_store_id_orders_order_id_lines_line_id
641
  *
646
  * @return bool
647
  */
648
  public function delete_ecommerce_store_order_line( $store_id, $order_id, $line_id ) {
649
+ $resource = sprintf( '/ecommerce/stores/%s/orders/%s/lines/%s', $store_id, $order_id, $line_id );
650
+ return !! $this->client->delete( $resource );
651
+ }
652
+
653
+ /**
654
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/#read-get_ecommerce_stores_store_id_carts
655
+ *
656
+ * @param string $store_id
657
+ * @param array $args
658
+ *
659
+ * @return object
660
+ */
661
+ public function get_ecommerce_store_carts( $store_id, array $args = array() ) {
662
+ $resource = sprintf( '/ecommerce/stores/%s/carts', $store_id );
663
+ return $this->client->get( $resource, $args );
664
+ }
665
+
666
+ /**
667
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/#read-get_ecommerce_stores_store_id_carts_cart_id
668
+ *
669
+ * @param string $store_id
670
+ * @param string $cart_id
671
+ * @param array $args
672
+ *
673
+ * @return object
674
+ */
675
+ public function get_ecommerce_store_cart( $store_id, $cart_id, array $args = array() ) {
676
+ $resource = sprintf( '/ecommerce/stores/%s/carts/%s', $store_id, $cart_id );
677
+ return $this->client->get( $resource, $args );
678
+ }
679
+
680
+ /**
681
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/#create-post_ecommerce_stores_store_id_carts
682
+ *
683
+ * @param string $store_id
684
+ * @param array $args
685
+ *
686
+ * @return object
687
+ */
688
+ public function add_ecommerce_store_cart( $store_id, array $args ) {
689
+ $resource = sprintf( '/ecommerce/stores/%s/carts', $store_id );
690
+ return $this->client->post( $resource, $args );
691
+ }
692
+
693
+ /**
694
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/#edit-patch_ecommerce_stores_store_id_carts_cart_id
695
+ *
696
+ * @param string $store_id
697
+ * @param string $cart_id
698
+ * @param array $args
699
+ *
700
+ * @return object
701
+ */
702
+ public function update_ecommerce_store_cart( $store_id, $cart_id, array $args ) {
703
+ $resource = sprintf( '/ecommerce/stores/%s/carts/%s', $store_id, $cart_id );
704
+ return $this->client->patch( $resource, $args );
705
+ }
706
+
707
+ /**
708
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/#delete-delete_ecommerce_stores_store_id_carts_cart_id
709
+ *
710
+ * @param string $store_id
711
+ * @param string $cart_id
712
+ *
713
+ * @return bool
714
+ */
715
+ public function delete_ecommerce_store_cart( $store_id, $cart_id ) {
716
+ return !! $this->client->delete( sprintf( '/ecommerce/stores/%s/carts/%s', $store_id, $cart_id ) );
717
+ }
718
+
719
+ /**
720
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#read-get_ecommerce_stores_store_id_carts_cart_id_lines
721
+ *
722
+ * @param string $store_id
723
+ * @param string $cart_id
724
+ * @param array $args
725
+ *
726
+ * @return object
727
+ */
728
+ public function get_ecommerce_store_cart_lines( $store_id, $cart_id, array $args = array() ) {
729
+ $resource = sprintf( '/ecommerce/stores/%s/carts/%/lines', $store_id, $cart_id);
730
+ return $this->client->get( $resource, $args );
731
+ }
732
+
733
+ /**
734
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#read-get_ecommerce_stores_store_id_carts_cart_id_lines_line_id
735
+ *
736
+ * @param string $store_id
737
+ * @param string $cart_id
738
+ * @param string $line_id
739
+ * @param array $args
740
+ *
741
+ * @return object
742
+ */
743
+ public function get_ecommerce_store_cart_line( $store_id, $cart_id, $line_id, array $args = array() ) {
744
+ $resource = sprintf( '/ecommerce/stores/%s/carts/%s/lines/%s', $store_id, $cart_id, $line_id );
745
+ return $this->client->get( $resource, $args );
746
+ }
747
+
748
+ /**
749
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#create-post_ecommerce_stores_store_id_carts_cart_id_lines
750
+ *
751
+ * @param string $store_id
752
+ * @param string $cart_id
753
+ * @param array $args
754
+ *
755
+ * @return object
756
+ */
757
+ public function add_ecommerce_store_cart_line( $store_id, $cart_id, array $args ) {
758
+ $resource = sprintf( '/ecommerce/stores/%s/carts/%s/lines', $store_id, $cart_id );
759
+ return $this->client->post( $resource, $args );
760
+ }
761
+
762
+ /**
763
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#edit-patch_ecommerce_stores_store_id_carts_cart_id_lines_line_id
764
+ *
765
+ * @param string $store_id
766
+ * @param string $cart_id
767
+ * @param string $line_id
768
+ * @param array $args
769
+ *
770
+ * @return object
771
+ */
772
+ public function update_ecommerce_store_cart_line( $store_id, $cart_id, $line_id, array $args ) {
773
+ $resource = sprintf( '/ecommerce/stores/%s/carts/%s/lines/%s', $store_id, $cart_id, $line_id );
774
+ return $this->client->patch( $resource, $args );
775
+ }
776
+
777
+ /**
778
+ * @link http://developer.mailchimp.com/documentation/mailchimp/reference/ecommerce/stores/carts/lines/#delete-delete_ecommerce_stores_store_id_carts_cart_id_lines_line_id
779
+ *
780
+ * @param string $store_id
781
+ * @param string $cart_id
782
+ * @param string $line_id
783
+ *
784
+ * @return bool
785
+ */
786
+ public function delete_ecommerce_store_cart_line( $store_id, $cart_id, $line_id ) {
787
+ $resource = sprintf( '/ecommerce/stores/%s/carts/%s/lines/%s', $store_id, $cart_id, $line_id );
788
+ return !! $this->client->delete( $resource );
789
  }
790
 
791
  /**
includes/class-list-data-mapper.php CHANGED
@@ -46,7 +46,7 @@ class MC4WP_List_Data_Mapper {
46
  $map = array();
47
 
48
  foreach( $this->list_ids as $list_id ) {
49
- $list = $mailchimp->get_list( $list_id, true );
50
 
51
  if( $list instanceof MC4WP_MailChimp_List ) {
52
  $map[ $list_id ] = $this->map_list( $list );
46
  $map = array();
47
 
48
  foreach( $this->list_ids as $list_id ) {
49
+ $list = $mailchimp->get_list( $list_id );
50
 
51
  if( $list instanceof MC4WP_MailChimp_List ) {
52
  $map[ $list_id ] = $this->map_list( $list );
includes/class-mailchimp.php CHANGED
@@ -155,22 +155,24 @@ class MC4WP_MailChimp {
155
  public function empty_cache() {
156
  delete_transient( 'mc4wp_mailchimp_lists_v3' );
157
  delete_transient( 'mc4wp_list_counts' );
158
- delete_transient( 'mc4wp_mailchimp_lists_v3_fallback' );
159
  }
160
 
161
  /**
162
- * Get MailChimp lists from cache, never triggering a remote API call.
163
  *
 
164
  * @return array
165
  */
166
- public function get_cached_lists() {
167
- $cached_lists = get_transient( 'mc4wp_mailchimp_lists_v3_fallback' );
168
 
 
 
169
  if( is_array( $cached_lists ) ) {
170
  return $cached_lists;
171
  }
172
 
173
- return array();
174
  }
175
 
176
  /**
@@ -178,30 +180,80 @@ class MC4WP_MailChimp {
178
  *
179
  * The following data sources are tried in the following order.
180
  *
181
- * - Cache (2 days)
182
- * - API
183
- * - Cache (14 days)
184
  *
185
  * @return array
186
  */
187
  public function get_lists() {
188
 
189
- // first, try to get from 3-day transient.
190
  $lists = get_transient( 'mc4wp_mailchimp_lists_v3' );
191
  if( is_array( $lists ) ) {
192
  return $lists;
193
  }
194
 
195
- // then, fetch from MailChimp API.
196
- $lists = $this->fetch_lists();
197
  if( ! empty( $lists ) ) {
198
  return $lists;
199
  }
200
 
201
- // if that failed, get from 2-week transient.
202
  return $this->get_cached_lists();
203
  }
204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  /**
206
  * @return array
207
  */
@@ -222,52 +274,9 @@ class MC4WP_MailChimp {
222
  * @var MC4WP_MailChimp_List[]
223
  */
224
  $lists = array();
225
-
226
  foreach ( $list_ids as $list_id ) {
227
-
228
- // if any API call for this list fails, simply move on to next list.
229
  try {
230
- $list_data = $this->api->get_list( $list_id, array( 'fields' => 'id,name,stats' ) );
231
-
232
- // create local object
233
- $list = new MC4WP_MailChimp_List( $list_data->id, $list_data->name );
234
- $list->subscriber_count = $list_data->stats->member_count;
235
-
236
- // parse web_id from the "link" response header
237
- $headers = $this->api->get_last_response_headers();
238
- $link_header = $headers['link'];
239
- preg_match( '/\?id=(\d+)/', $link_header, $matches );
240
- if( ! empty( $matches[1] ) ) {
241
- $list->web_id = $matches[1];
242
- };
243
-
244
- // get merge fields (if any)
245
- if( $list_data->stats->merge_field_count > 0 ) {
246
- $field_data = $this->api->get_list_merge_fields( $list->id, array( 'count' => 100, 'fields' => 'merge_fields.name,merge_fields.tag,merge_fields.type,merge_fields.required,merge_fields.default_value,merge_fields.options,merge_fields.public' ) );
247
-
248
- // hydrate data into object
249
- foreach( $field_data as $data ) {
250
- $object = MC4WP_MailChimp_Merge_Field::from_data( $data );
251
- $list->merge_fields[] = $object;
252
- }
253
- }
254
-
255
- // get interest categories
256
- $interest_categories_data = $this->api->get_list_interest_categories( $list->id, array( 'count' => 100, 'fields' => 'categories.id,categories.title,categories.type' ) );
257
- foreach( $interest_categories_data as $interest_category_data ) {
258
- $interest_category = MC4WP_MailChimp_Interest_Category::from_data( $interest_category_data );
259
-
260
- // fetch groups for this interest
261
- $interests_data = $this->api->get_list_interest_category_interests( $list->id, $interest_category->id, array( 'count' => 100, 'fields' => 'interests.id,interests.name') );
262
- foreach( $interests_data as $interest_data ) {
263
- $interest_category->interests[ $interest_data->id ] = $interest_data->name;
264
- }
265
-
266
- $list->interest_categories[] = $interest_category;
267
- }
268
-
269
- // add to array
270
- $lists["{$list->id}"] = $list;
271
  } catch( MC4WP_API_Exception $e ) {
272
  continue;
273
  }
@@ -275,8 +284,8 @@ class MC4WP_MailChimp {
275
 
276
  // store lists in transients
277
  if( ! empty( $lists ) ) {
278
- set_transient( 'mc4wp_mailchimp_lists_v3', $lists, ( 60 * 60 * 24 * 3 ) ); // 3 days
279
- set_transient( 'mc4wp_mailchimp_lists_v3_fallback', $lists, 60 * 60 * 24 * 30 ); // 30 days
280
  }
281
 
282
  return $lists;
@@ -290,13 +299,12 @@ class MC4WP_MailChimp {
290
  * @return MC4WP_MailChimp_List
291
  */
292
  public function get_list( $list_id ) {
293
- $lists = $this->get_cached_lists();
294
 
295
  if( isset( $lists[$list_id] ) ) {
296
  return $lists[$list_id];
297
  }
298
 
299
- // return dummy list object
300
  return new MC4WP_MailChimp_List( '', 'Unknown List' );
301
  }
302
 
155
  public function empty_cache() {
156
  delete_transient( 'mc4wp_mailchimp_lists_v3' );
157
  delete_transient( 'mc4wp_list_counts' );
158
+ delete_option( 'mc4wp_mailchimp_lists_v3_fallback' );
159
  }
160
 
161
  /**
162
+ * Get MailChimp lists from cache.
163
  *
164
+ * @param boolean $force Force a result, by hitting remote API.
165
  * @return array
166
  */
167
+ public function get_cached_lists( $force = false ) {
 
168
 
169
+ // then, get from option cache
170
+ $cached_lists = get_option( 'mc4wp_mailchimp_lists_v3_fallback' );
171
  if( is_array( $cached_lists ) ) {
172
  return $cached_lists;
173
  }
174
 
175
+ return $force ? $this->fetch_lists() : array();
176
  }
177
 
178
  /**
180
  *
181
  * The following data sources are tried in the following order.
182
  *
183
+ * - Transient Cache (5 days)
184
+ * - Remote MailChimp API
185
+ * - Option Cache (forever)
186
  *
187
  * @return array
188
  */
189
  public function get_lists() {
190
 
191
+ // first, try to get from transient.
192
  $lists = get_transient( 'mc4wp_mailchimp_lists_v3' );
193
  if( is_array( $lists ) ) {
194
  return $lists;
195
  }
196
 
197
+ // then, fetch from MailChimp API.
198
+ $lists = $this->fetch_lists();
199
  if( ! empty( $lists ) ) {
200
  return $lists;
201
  }
202
 
203
+ // if that failed, get from option cache.
204
  return $this->get_cached_lists();
205
  }
206
 
207
+ /**
208
+ * @param string $list_id
209
+ *
210
+ * @return MC4WP_MailChimp_List
211
+ */
212
+ private function fetch_list( $list_id ) {
213
+ $list_data = $this->api->get_list( $list_id, array( 'fields' => 'id,name,stats' ) );
214
+
215
+ // create local object
216
+ $list = new MC4WP_MailChimp_List( $list_data->id, $list_data->name );
217
+ $list->subscriber_count = $list_data->stats->member_count;
218
+
219
+ // parse web_id from the "link" response header
220
+ $headers = $this->api->get_last_response_headers();
221
+ $link_header = $headers['link'];
222
+ preg_match( '/\?id=(\d+)/', $link_header, $matches );
223
+ if( ! empty( $matches[1] ) ) {
224
+ $list->web_id = $matches[1];
225
+ };
226
+
227
+ // get merge fields (if any)
228
+ if( $list_data->stats->merge_field_count > 0 ) {
229
+ $field_data = $this->api->get_list_merge_fields( $list->id, array( 'count' => 100, 'fields' => 'merge_fields.name,merge_fields.tag,merge_fields.type,merge_fields.required,merge_fields.default_value,merge_fields.options,merge_fields.public' ) );
230
+
231
+ // hydrate data into object
232
+ foreach( $field_data as $data ) {
233
+ $object = MC4WP_MailChimp_Merge_Field::from_data( $data );
234
+ $list->merge_fields[] = $object;
235
+ }
236
+ }
237
+
238
+ // get interest categories
239
+ $interest_categories_data = $this->api->get_list_interest_categories( $list->id, array( 'count' => 100, 'fields' => 'categories.id,categories.title,categories.type' ) );
240
+ foreach( $interest_categories_data as $interest_category_data ) {
241
+ $interest_category = MC4WP_MailChimp_Interest_Category::from_data( $interest_category_data );
242
+
243
+ // fetch groups for this interest
244
+ $interests_data = $this->api->get_list_interest_category_interests( $list->id, $interest_category->id, array( 'count' => 100, 'fields' => 'interests.id,interests.name') );
245
+ foreach( $interests_data as $interest_data ) {
246
+ $interest_category->interests[ $interest_data->id ] = $interest_data->name;
247
+ }
248
+
249
+ $list->interest_categories[] = $interest_category;
250
+ }
251
+
252
+ return $list;
253
+ }
254
+
255
+
256
+
257
  /**
258
  * @return array
259
  */
274
  * @var MC4WP_MailChimp_List[]
275
  */
276
  $lists = array();
 
277
  foreach ( $list_ids as $list_id ) {
 
 
278
  try {
279
+ $lists["{$list_id}"] = $this->fetch_list( $list_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  } catch( MC4WP_API_Exception $e ) {
281
  continue;
282
  }
284
 
285
  // store lists in transients
286
  if( ! empty( $lists ) ) {
287
+ set_transient( 'mc4wp_mailchimp_lists_v3', $lists, ( 60 * 60 * 24 * 5 ) ); // 5 days
288
+ update_option( 'mc4wp_mailchimp_lists_v3_fallback', $lists, false ); // forever
289
  }
290
 
291
  return $lists;
299
  * @return MC4WP_MailChimp_List
300
  */
301
  public function get_list( $list_id ) {
302
+ $lists = $this->get_cached_lists( true );
303
 
304
  if( isset( $lists[$list_id] ) ) {
305
  return $lists[$list_id];
306
  }
307
 
 
308
  return new MC4WP_MailChimp_List( '', 'Unknown List' );
309
  }
310
 
includes/functions.php CHANGED
@@ -148,10 +148,9 @@ function mc4wp_get_current_url() {
148
  }
149
 
150
  /**
151
- * Sanitizes all values in a mixed variable.
152
  *
153
  * @access public
154
- *
155
  * @param mixed $value
156
  *
157
  * @return mixed
@@ -159,7 +158,7 @@ function mc4wp_get_current_url() {
159
  function mc4wp_sanitize_deep( $value ) {
160
 
161
  if ( is_scalar( $value ) ) {
162
- $value = sanitize_text_field( $value );
163
  } elseif( is_array( $value ) ) {
164
  $value = array_map( 'mc4wp_sanitize_deep', $value );
165
  } elseif ( is_object($value) ) {
148
  }
149
 
150
  /**
151
+ * Strips all HTML tags from all values in a mixed variable, then trims the result.
152
  *
153
  * @access public
 
154
  * @param mixed $value
155
  *
156
  * @return mixed
158
  function mc4wp_sanitize_deep( $value ) {
159
 
160
  if ( is_scalar( $value ) ) {
161
+ $value = trim( strip_tags( $value ) );
162
  } elseif( is_array( $value ) ) {
163
  $value = array_map( 'mc4wp_sanitize_deep', $value );
164
  } elseif ( is_object($value) ) {
languages/mailchimp-for-wp-ja_JP.mo CHANGED
Binary file
languages/mailchimp-for-wp-ja_JP.po CHANGED
@@ -4,13 +4,14 @@
4
  # Kappei Nakano <nakano.kappei@gmail.com>, 2016
5
  # kihoshin <kiho7777@gmail.com>, 2015
6
  # monaye win <winmonaye@gmail.com>, 2016
 
7
  msgid ""
8
  msgstr ""
9
  "Project-Id-Version: MailChimp for WordPress\n"
10
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mailchimp-for-wp\n"
11
  "POT-Creation-Date: 2015-11-30 10:15:18+00:00\n"
12
- "PO-Revision-Date: 2016-05-05 23:20+0000\n"
13
- "Last-Translator: Kappei Nakano <nakano.kappei@gmail.com>\n"
14
  "Language-Team: Japanese (Japan) (http://www.transifex.com/ibericode/mailchimp-for-wordpress/language/ja_JP/)\n"
15
  "MIME-Version: 1.0\n"
16
  "Content-Type: text/plain; charset=UTF-8\n"
@@ -62,7 +63,7 @@ msgstr "このメールアドレスは未登録です。"
62
 
63
  #: config/default-form-messages.php:33
64
  msgid "Please select at least one list."
65
- msgstr "必ず1つのリストを選んでください。"
66
 
67
  #: config/default-integration-options.php:5
68
  msgid "Sign me up for the newsletter!"
@@ -115,7 +116,7 @@ msgstr "購読者を増やして、よいニュースレターを作ろう"
115
  msgid ""
116
  "Learn how to best grow your lists & write better emails by subscribing to "
117
  "our monthly tips."
118
- msgstr "リストを増やたり、よいメールを書く一番の方法は、当社の毎月のTIPSを購読すると学べます。"
119
 
120
  #: includes/admin/class-ads.php:66
121
  msgid "Email Address"
@@ -148,11 +149,11 @@ msgstr "フォーム"
148
 
149
  #: includes/forms/class-admin.php:101 includes/forms/class-admin.php:176
150
  msgid "<strong>Success!</strong> Form successfully saved."
151
- msgstr "<strong>成功!</strong> フォームを保存は完了しました。"
152
 
153
  #: includes/forms/class-admin.php:176
154
  msgid "Preview form"
155
- msgstr "プレビューフォーム"
156
 
157
  #: includes/forms/class-admin.php:279
158
  msgid "Form not found."
4
  # Kappei Nakano <nakano.kappei@gmail.com>, 2016
5
  # kihoshin <kiho7777@gmail.com>, 2015
6
  # monaye win <winmonaye@gmail.com>, 2016
7
+ # Sugahara Masayuki <brindflontia@gmail.com>, 2016
8
  msgid ""
9
  msgstr ""
10
  "Project-Id-Version: MailChimp for WordPress\n"
11
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mailchimp-for-wp\n"
12
  "POT-Creation-Date: 2015-11-30 10:15:18+00:00\n"
13
+ "PO-Revision-Date: 2016-09-30 15:37+0000\n"
14
+ "Last-Translator: Sugahara Masayuki <brindflontia@gmail.com>\n"
15
  "Language-Team: Japanese (Japan) (http://www.transifex.com/ibericode/mailchimp-for-wordpress/language/ja_JP/)\n"
16
  "MIME-Version: 1.0\n"
17
  "Content-Type: text/plain; charset=UTF-8\n"
63
 
64
  #: config/default-form-messages.php:33
65
  msgid "Please select at least one list."
66
+ msgstr "少なくとも1つのリストを選んでください。"
67
 
68
  #: config/default-integration-options.php:5
69
  msgid "Sign me up for the newsletter!"
116
  msgid ""
117
  "Learn how to best grow your lists & write better emails by subscribing to "
118
  "our monthly tips."
119
+ msgstr "リストのユーザーを増やしたり、よいメールを書いたりする一番の方法は、当社の毎月のTIPSを購読すると学べます。"
120
 
121
  #: includes/admin/class-ads.php:66
122
  msgid "Email Address"
149
 
150
  #: includes/forms/class-admin.php:101 includes/forms/class-admin.php:176
151
  msgid "<strong>Success!</strong> Form successfully saved."
152
+ msgstr "<strong>成功!</strong> フォームを保存しました。"
153
 
154
  #: includes/forms/class-admin.php:176
155
  msgid "Preview form"
156
+ msgstr "フォームをプレビュー"
157
 
158
  #: includes/forms/class-admin.php:279
159
  msgid "Form not found."
mailchimp-for-wp.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: MailChimp for WordPress
4
  Plugin URI: https://mc4wp.com/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=plugins-page
5
  Description: MailChimp for WordPress by ibericode. Adds various highly effective sign-up methods to your site.
6
- Version: 4.0.5
7
  Author: ibericode
8
  Author URI: https://ibericode.com/
9
  Text Domain: mailchimp-for-wp
@@ -47,7 +47,7 @@ function _mc4wp_load_plugin() {
47
  }
48
 
49
  // bootstrap the core plugin
50
- define( 'MC4WP_VERSION', '4.0.5' );
51
  define( 'MC4WP_PLUGIN_DIR', dirname( __FILE__ ) . '/' );
52
  define( 'MC4WP_PLUGIN_URL', plugins_url( '/' , __FILE__ ) );
53
  define( 'MC4WP_PLUGIN_FILE', __FILE__ );
3
  Plugin Name: MailChimp for WordPress
4
  Plugin URI: https://mc4wp.com/#utm_source=wp-plugin&utm_medium=mailchimp-for-wp&utm_campaign=plugins-page
5
  Description: MailChimp for WordPress by ibericode. Adds various highly effective sign-up methods to your site.
6
+ Version: 4.0.6
7
  Author: ibericode
8
  Author URI: https://ibericode.com/
9
  Text Domain: mailchimp-for-wp
47
  }
48
 
49
  // bootstrap the core plugin
50
+ define( 'MC4WP_VERSION', '4.0.6' );
51
  define( 'MC4WP_PLUGIN_DIR', dirname( __FILE__ ) . '/' );
52
  define( 'MC4WP_PLUGIN_URL', plugins_url( '/' , __FILE__ ) );
53
  define( 'MC4WP_PLUGIN_FILE', __FILE__ );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://mc4wp.com/#utm_source=wp-plugin-repo&utm_medium=mailchimp-f
4
  Tags: mailchimp, mc4wp, email, marketing, newsletter, subscribe, widget, mc4wp, contact form 7, woocommerce, buddypress, ibericode, mailchimp forms, mailchimp integrations
5
  Requires at least: 3.8
6
  Tested up to: 4.6.1
7
- Stable tag: 4.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -57,7 +57,7 @@ MailChimp for WordPress helps you add more subscribers to your MailChimp lists u
57
  <p>MailChimp for WordPress has a Premium add-on which comes with several additional benefits.</p>
58
  <ul>
59
  <li>Multiple forms (with AJAX)</li>
60
- <li>eCommerce360 integration for WooCommerce and Easy Digital Downloads</li>
61
  <li>Email notifications</li>
62
  <li>An easy way to style your forms</li>
63
  <li>Detailed reports & statistics</li>
@@ -190,6 +190,21 @@ MailChimp for WordPress is being developed on GitHub. If you want to collaborate
190
  == Changelog ==
191
 
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  #### 4.0.5 - September 29, 2016
194
 
195
  **Fixes**
4
  Tags: mailchimp, mc4wp, email, marketing, newsletter, subscribe, widget, mc4wp, contact form 7, woocommerce, buddypress, ibericode, mailchimp forms, mailchimp integrations
5
  Requires at least: 3.8
6
  Tested up to: 4.6.1
7
+ Stable tag: 4.0.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
57
  <p>MailChimp for WordPress has a Premium add-on which comes with several additional benefits.</p>
58
  <ul>
59
  <li>Multiple forms (with AJAX)</li>
60
+ <li>Advanced MailChimp e-commerce integration for WooCommerce</li>
61
  <li>Email notifications</li>
62
  <li>An easy way to style your forms</li>
63
  <li>Detailed reports & statistics</li>
190
  == Changelog ==
191
 
192
 
193
+ #### 4.0.6 - October 10, 2016
194
+
195
+ **Fixes**
196
+
197
+ - Issue with lists not showing when using W3 Total Cache with APCu object cache enabled.
198
+
199
+ **Improvements**
200
+
201
+ - We're no longer stripping newlines from text fields.
202
+
203
+ **Additions**
204
+
205
+ - Added missing e-commerce related API methods to API class.
206
+
207
+
208
  #### 4.0.5 - September 29, 2016
209
 
210
  **Fixes**
vendor/autoload_52.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
- return ComposerAutoloaderInitdeff78cf13068cc4cc1044ae5bff7bfd::getLoader();
4
 
5
  require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
 
7
+ return ComposerAutoloaderInit5b5deb0f17904fb946f3d55dcdda6e86::getLoader();
vendor/composer/autoload_real_52.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
- class ComposerAutoloaderInitdeff78cf13068cc4cc1044ae5bff7bfd {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
@@ -19,9 +19,9 @@ class ComposerAutoloaderInitdeff78cf13068cc4cc1044ae5bff7bfd {
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitdeff78cf13068cc4cc1044ae5bff7bfd', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitdeff78cf13068cc4cc1044ae5bff7bfd', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);
2
 
3
  // autoload_real_52.php generated by xrstf/composer-php52
4
 
5
+ class ComposerAutoloaderInit5b5deb0f17904fb946f3d55dcdda6e86 {
6
  private static $loader;
7
 
8
  public static function loadClassLoader($class) {
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit5b5deb0f17904fb946f3d55dcdda6e86', 'loadClassLoader'), true /*, true */);
23
  self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit5b5deb0f17904fb946f3d55dcdda6e86', 'loadClassLoader'));
25
 
26
  $vendorDir = dirname(dirname(__FILE__));
27
  $baseDir = dirname($vendorDir);