-
Notifications
You must be signed in to change notification settings - Fork 22
/
class-newspack-newsletters-mailchimp-cached-data.php
744 lines (673 loc) · 21.5 KB
/
class-newspack-newsletters-mailchimp-cached-data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
<?php
/**
* Mailchimp Cached data
*
* @package Newspack
*/
defined( 'ABSPATH' ) || exit;
use DrewM\MailChimp\MailChimp;
/**
* Mailchimp cached class data
*
* This class handles fetching and caching segments and interests data from Mailchimp
*
* The purpose of this class is to implement a non-obstrusive cache, in which refreshing the cache will happen in the background in async requests
* and will never keep the user waiting.
*
* The cache is stored in an option, and will be considered expired after 20 minutes. Every time we retrieve the cache, we check its age,
* if it's expired, we trigger an async request to refresh it.
*
* Also, as a redundant strategy, we have a CRON job that will trigger the async requests to refresh the cache for all lists every 10 minutes.
*
* If the cache refresh fails, we will store the error in a separate option, and will only surface it to the user after 20 minutes.
* In every admin page we will display a generic Warning message, telling the user to go to Newsletters > Settings to see the errors.
* In Newsletters > Settings we will output the errors details.
*/
final class Newspack_Newsletters_Mailchimp_Cached_Data {
/**
* The cache option name
*
* @var string
*/
const OPTION_PREFIX = 'newspack_nl_mailchimp_cache';
/**
* The name of the option where we store errors
*
* @var string
*/
const ERRORS_OPTION = 'newspack_nl_mailchimp_cache_errors';
/**
* The ajax action name used to dispatch the cache refresh
*
* @var string
*/
const AJAX_ACTION = 'newspack_nl_mailchimp_refresh_cached_data';
/**
* The cron hook name that trigger the cache refresh on the background
*
* @var string
*/
const CRON_HOOK = 'newspack_nl_mailchimp_refresh_cache';
/**
* We store errors when an API request fails, but we will only surface these errors to the user after this time
*
* @var int
*/
const SURFACE_ERRORS_AFTER = 20 * HOUR_IN_SECONDS;
/**
* Memoized data to be served across the same request
*
* @var array
*/
private static $memoized_data = [];
/**
* Initializes this class
*/
public static function init() {
if ( 'mailchimp' !== Newspack_Newsletters::service_provider() ) {
return;
}
add_action( 'wp_ajax_' . self::AJAX_ACTION, [ __CLASS__, 'handle_dispatch_refresh' ] );
add_action( 'wp_ajax_nopriv_' . self::AJAX_ACTION, [ __CLASS__, 'handle_dispatch_refresh' ] );
add_action( self::CRON_HOOK, [ __CLASS__, 'handle_cron' ] );
add_filter( 'cron_schedules', [ __CLASS__, 'add_cron_interval' ] ); // phpcs:ignore
if ( ! wp_next_scheduled( self::CRON_HOOK ) ) {
wp_schedule_event( time(), 'every_10_minutes', self::CRON_HOOK );
}
add_action( 'admin_notices', [ __CLASS__, 'maybe_show_error' ] );
}
/**
* Adds a custom interval to WP Cron
*
* @param array $schedules The current schedules.
*
* @return array
*/
public static function add_cron_interval( $schedules ) {
$schedules['every_10_minutes'] = [
'interval' => 10 * MINUTE_IN_SECONDS,
'display' => __( 'Every ten minutes', 'newspack_newsletters' ),
];
return $schedules;
}
/**
* Retrieves an instance of the Mailchimp api
*
* @return DrewM\MailChimp\MailChimp|WP_Error
*/
private static function get_mc_api() {
$api_key = self::get_mc_instance()->api_key();
if ( empty( $api_key ) ) {
return new WP_Error(
'newspack_newsletters_mailchimp_error',
__( 'Missing Mailchimp API key.', 'newspack-newsletters' )
);
}
try {
return new Mailchimp( $api_key );
} catch ( Exception $e ) {
return new WP_Error(
'newspack_newsletters_mailchimp_error',
$e->getMessage()
);
}
}
/**
* Get audiences (lists).
*
* @param int|null $limit (Optional) The maximum number of items to return. If not given, will get all items.
*
* @throws Exception In case of errors while fetching data from the server.
* @return array|WP_Error The audiences, or WP_Error if there was an error.
*/
public static function get_lists( $limit = null ) {
// If we've already gotten or fetched lists in this request, return those.
if ( ! empty( self::$memoized_data['lists'] ) ) {
return self::$memoized_data['lists'];
}
$data = get_option( self::get_lists_cache_key() );
if ( ! $data || self::is_cache_expired() ) {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: No data found. Fetching lists from ESP.' );
$data = self::fetch_lists( $limit );
} else {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: serving from cache' );
}
self::$memoized_data['lists'] = $data;
if ( $limit ) {
$data = array_slice( $data, 0, $limit );
}
return $data;
}
/**
* Get segments of a given audience (list)
*
* @param string $list_id The audience (list) ID.
* @throws Exception In case of errors while fetching data from the server.
* @return array The audience segments
*/
public static function get_segments( $list_id ) {
$data = self::get_data( $list_id );
return $data['segments'] ?? null;
}
/**
* Get Interest Categories (aka Groups) of a given audience
*
* @param string $list_id The audience (list) ID.
* @throws Exception In case of errors while fetching data from the server.
* @return array The audience interest categories
*/
public static function get_interest_categories( $list_id ) {
$data = self::get_data( $list_id );
return $data['interest_categories'] ?? null;
}
/**
* Get tags for a given audience
*
* @param string $list_id The audience (list) ID.
* @throws Exception In case of errors while fetching data from the server.
* @return array The audience tags
*/
public static function get_tags( $list_id ) {
$data = self::get_data( $list_id );
return $data['tags'] ?? null;
}
/**
* Get folders.
*
* TODO: This is not cached because the cache structure requires a list ID,
* which shouldn't be required for folders.
*
* @throws Exception In case of errors while fetching data from the server.
* @return array The list folders
*/
public static function get_folders() {
return self::fetch_folders();
}
/**
* Get merge_fields of a given list
*
* @param string $list_id The audience (list) ID.
* @throws Exception In case of errors while fetching data from the server.
* @return array The list merge_fields
*/
public static function get_merge_fields( $list_id ) {
$data = self::get_data( $list_id );
return $data['merge_fields'] ?? null;
}
/**
* Retrieves the main Mailchimp instance
*
* @return Newspack_Newsletters_Mailchimp
*/
private static function get_mc_instance() {
return Newspack_Newsletters_Mailchimp::instance();
}
/**
* Get the cache key for the cached lists data.
*/
private static function get_lists_cache_key() {
return self::OPTION_PREFIX . '_lists';
}
/**
* Get the cache key for a given list
*
* @param string $list_id The List ID.
* @return string The cache key
*/
private static function get_cache_key( $list_id ) {
return self::OPTION_PREFIX . '_' . $list_id;
}
/**
* Get the cache date key for a given list or all lists
*
* @param string $list_id The List ID, or 'lists' for the cached lists data.
* @return string The cache key
*/
private static function get_cache_date_key( $list_id = 'lists' ) {
return self::OPTION_PREFIX . '_date_' . $list_id;
}
/**
* Checks if the cache is expired for a given list
*
* @param string $list_id The List ID.
* @return boolean
*/
private static function is_cache_expired( $list_id = 'lists' ) {
$cache_date = get_option( self::get_cache_date_key( $list_id ) );
return $cache_date && ( time() - $cache_date ) > 20 * MINUTE_IN_SECONDS;
}
/**
* Updates the cache for a given list
*
* @param string $list_id The List ID.
* @param array $data The data to cache.
* @return void
*/
private static function update_cache( $list_id, $data ) {
update_option( self::get_cache_key( $list_id ), $data, false ); // auto-load false.
update_option( self::get_cache_date_key( $list_id ), time(), false ); // auto-load false.
self::$memoized_data[ $list_id ] = $data;
self::clear_errors( $list_id );
Newspack_Newsletters_Logger::log( 'Mailchimp cache: Cache for list ' . $list_id . ' updated' );
}
/**
* Clears the cache errors for a given list
*
* @param string $list_id The List ID.
* @return void
*/
private static function clear_errors( $list_id ) {
$errors = get_option( self::ERRORS_OPTION, [] );
if ( isset( $errors[ $list_id ] ) ) {
unset( $errors[ $list_id ] );
update_option( self::ERRORS_OPTION, $errors );
Newspack_Newsletters_Logger::log( 'Mailchimp cache: Clearing errors for ' . $list_id );
}
}
/**
* Stores the last error for a given list, if the cache is older than self::SURFACE_ERRORS_AFTER
*
* @param string $list_id The List ID.
* @param string $error The error message.
*/
private static function maybe_add_error( $list_id, $error ) {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: handling error while fetching cache for list ' . $list_id );
$cache_date = get_option( self::get_cache_date_key( $list_id ) );
if ( $cache_date && ( time() - $cache_date ) > self::SURFACE_ERRORS_AFTER ) {
$errors = get_option( self::ERRORS_OPTION, [] );
$errors[ $list_id ] = $error;
update_option( self::ERRORS_OPTION, $errors );
Newspack_Newsletters_Logger::log( 'Mailchimp cache: error stored' );
}
}
/**
* Shows an error message to the user if we have errors in the cache
*
* @return void
*/
public static function maybe_show_error() {
$errors = get_option( self::ERRORS_OPTION, [] );
if ( ! empty( $errors ) ) {
$screen = get_current_screen();
if ( ! $screen ) {
return;
}
if ( 'newspack_nl_cpt_page_newspack-newsletters-settings-admin' !== $screen->base ) {
self::show_generic_warning();
return;
}
$hours = (int) self::SURFACE_ERRORS_AFTER / HOUR_IN_SECONDS;
?>
<div class="notice notice-error">
<p>
<?php
echo esc_html(
sprintf(
/* translators: %s is the number of hours a cache must be expired for us to surface this error */
__(
'Error retrieving data from Mailchimp. We were not able to refresh the list of Audiences and groups in the last %s hours.',
'newspack_newsletters'
),
$hours
)
);
?>
</p>
<ul>
<?php foreach ( $errors as $list_id => $error ) : ?>
<li>
<?php
echo esc_html(
sprintf(
/* translators: %1$s is the list ID, %2$s is the error message */
__( 'List %1$s: %2$s', 'newspack_newsletters' ),
$list_id,
$error
)
);
?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php
}
}
/**
* Shows a generic warning when we can't fetch data from Mailchimp
*
* @return void
*/
private static function show_generic_warning() {
?>
<div class="notice notice-warning">
<p>
<?php
echo esc_html(
__(
'Newspack Newsletters is having trouble to fetch data from Mailchimp Audiences. Please visit Newsletters > Settings for more details.',
'newspack_newsletters'
)
);
?>
</p>
</div>
<?php
}
/**
* Gets the raw data for a given List
*
* @param string $list_id The List ID.
* @throws Exception In case of errors while fetching data from the server.
* @return array The list data with segments and interest_categories
*/
private static function get_data( $list_id ) {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: getting data for list ' . $list_id );
if ( ! empty( self::$memoized_data[ $list_id ] ) ) {
return self::$memoized_data[ $list_id ];
}
$data = get_option( self::get_cache_key( $list_id ) );
if ( $data ) {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: serving from cache' );
self::$memoized_data[ $list_id ] = $data;
if ( self::is_cache_expired( $list_id ) ) {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: cache expired. Dispatching refresh' );
self::dispatch_refresh( $list_id );
}
return $data;
}
Newspack_Newsletters_Logger::log( 'Mailchimp cache: No data found. Dispatching refresh' );
self::dispatch_refresh( $list_id );
return [];
}
/**
* Dispatches a new request to refresh the cache
*
* @param string $list_id The List ID or null for the cache for all lists.
* @return void
*/
private static function dispatch_refresh( $list_id = null ) {
// If no list_id is provided, refresh the lists cache.
if ( ! $list_id ) {
self::fetch_lists();
return;
}
if ( ! function_exists( 'wp_create_nonce' ) ) {
require_once ABSPATH . WPINC . '/pluggable.php';
}
$url = add_query_arg(
[
'action' => self::AJAX_ACTION,
'_wpnonce' => wp_create_nonce( self::AJAX_ACTION ),
],
admin_url( 'admin-ajax.php' )
);
$body = [
'list_id' => $list_id,
];
wp_remote_post(
$url,
[
'timeout' => 0.01,
'blocking' => false,
'body' => $body,
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
'cookies' => $_COOKIE, // phpcs:ignore
]
);
}
/**
* Handles the ajax action to refresh the cache
*
* @throws Exception In case of errors while fetching data from the server.
* @return void
*/
public static function handle_dispatch_refresh() {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: Handling ajax request to refresh cache' );
check_admin_referer( self::AJAX_ACTION );
$list_id = isset( $_POST['list_id'] ) ? sanitize_text_field( $_POST['list_id'] ) : null;
if ( ! $list_id ) {
die;
}
try {
self::refresh_cached_data( $list_id );
} catch ( Exception $e ) {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: Error refreshing cache: ' . $e->getMessage() );
}
die;
}
/**
* Fetches data from the server and updates the cache
*
* @param string $list_id The List ID.
* @throws Exception In case of errors while fetching data from the server.
* @return array The list data with segments and interest_categories
*/
private static function refresh_cached_data( $list_id ) {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: Refreshing cache' );
try {
$segments = self::fetch_segments( $list_id );
$interest_categories = self::fetch_interest_categories( $list_id );
$tags = self::fetch_tags( $list_id );
$folders = self::fetch_folders();
$merge_fields = self::fetch_merge_fields( $list_id );
$list_data = [
'segments' => $segments,
'interest_categories' => $interest_categories,
'tags' => $tags,
'folders' => $folders,
'merge_fields' => $merge_fields,
];
// Update the cache.
self::update_cache( $list_id, $list_data );
return $list_data;
} catch ( Exception $e ) {
self::maybe_add_error( $list_id, $e->getMessage() );
throw $e;
}
}
/**
* Handles the cron job and triggers the async requests to refresh the cache for all lists
*
* @return void
*/
public static function handle_cron() {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: Handling cron request to refresh cache' );
try {
$lists = self::fetch_lists(); // Force a cache refresh.
} catch ( Exception $e ) {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: Error refreshing lists cache: ' . $e->getMessage() );
return;
}
foreach ( $lists as $list ) {
Newspack_Newsletters_Logger::log( 'Mailchimp cache: Dispatching request to refresh cache for list ' . $list['id'] );
self::dispatch_refresh( $list['id'] );
}
}
/**
* Fetches all audiences (lists) from the Mailchimp server
*
* @param int|null $limit (Optional) The maximum number of items to return. If not given, will get all items.
*
* @throws Exception In case of errors while fetching data from the server.
* @return array|WP_Error The audiences, or WP_Error if there was an error.
*/
public static function fetch_lists( $limit = null ) {
$mc = self::get_mc_api();
if ( \is_wp_error( $mc ) ) {
return [];
}
$lists_response = ( self::get_mc_instance() )->validate(
$mc->get(
'lists',
[
'count' => $limit ?? 1000,
'fields' => 'lists.name,lists.id,lists.web_id,lists.stats.member_count',
]
),
__( 'Error retrieving Mailchimp lists.', 'newspack_newsletters' )
);
// Cache the lists (only if we got them all).
if ( ! $limit ) {
update_option( self::get_lists_cache_key(), $lists_response['lists'], false ); // auto-load false.
update_option( self::get_cache_date_key(), time(), false ); // auto-load false.
}
return $lists_response['lists'];
}
/**
* Fetches a single segment by segment ID + list ID.
*
* @param string $segment_id The segment ID.
* @param string $list_id The audience (list) ID.
*
* @throws Exception In case of errors while fetching data from the server.
* @return array The audience segment
*/
public static function fetch_segment( $segment_id, $list_id ) {
$mc = self::get_mc_api();
if ( \is_wp_error( $mc ) ) {
return $mc;
}
$response = ( self::get_mc_instance() )->validate(
$mc->get(
"lists/$list_id/segments/$segment_id",
[
'fields' => 'id,name,member_count,type,options,list_id',
],
60
),
__( 'Error retrieving Mailchimp segment with ID: ', 'newspack_newsletters' ) . $segment_id
);
return $response;
}
/**
* Fetches the segments for a given List from the Mailchimp server
*
* @param string $list_id The audience (list) ID.
* @param int|null $limit (Optional) The maximum number of items to return. If not given, will get all items.
*
* @throws Exception In case of errors while fetching data from the server.
* @return array The audience segments
*/
public static function fetch_segments( $list_id, $limit = null ) {
$segments = [];
$mc = self::get_mc_api();
if ( \is_wp_error( $mc ) ) {
return $segments;
}
$saved_segments_response = ( self::get_mc_instance() )->validate(
$mc->get(
"lists/$list_id/segments",
[
'type' => 'saved', // 'saved' or 'static' segments. 'static' segments are actually the same thing as tags, so we can exclude them from this request as we fetch tags separately.
'count' => $limit ?? 1000,
],
60
),
__( 'Error retrieving Mailchimp segments.', 'newspack_newsletters' )
);
$segments = $saved_segments_response['segments'];
return $segments;
}
/**
* Fetches the interest_categories (aka Groups) for a given List from the Mailchimp server
*
* @param string $list_id The audience (list) ID.
* @param int|null $limit (Optional) The maximum number of items to return. If not given, will get all items.
*
* @throws Exception In case of errors while fetching data from the server.
* @return array The audience interest_categories
*/
private static function fetch_interest_categories( $list_id, $limit = null ) {
$mc = self::get_mc_api();
if ( \is_wp_error( $mc ) ) {
return [];
}
$interest_categories = $list_id ? ( self::get_mc_instance() )->validate(
$mc->get( "lists/$list_id/interest-categories", [ 'count' => $limit ?? 1000 ], 60 ),
__( 'Error retrieving Mailchimp groups.', 'newspack_newsletters' )
) : null;
if ( $interest_categories && count( $interest_categories['categories'] ) ) {
foreach ( $interest_categories['categories'] as &$category ) {
$category_id = $category['id'];
$category['interests'] = ( self::get_mc_instance() )->validate(
$mc->get( "lists/$list_id/interest-categories/$category_id/interests", [ 'count' => $limit ?? 1000 ], 60 ),
__( 'Error retrieving Mailchimp groups.', 'newspack_newsletters' )
);
}
}
return $interest_categories;
}
/**
* Fetches the tags for a given audience (list) from the Mailchimp server
*
* @param string $list_id The audience (list) ID.
* @param int|null $limit (Optional) The maximum number of items to return. If not given, will get all items.
*
* @throws Exception In case of errors while fetching data from the server.
* @return array The audience tags
*/
public static function fetch_tags( $list_id, $limit = null ) {
$mc = self::get_mc_api();
if ( \is_wp_error( $mc ) ) {
return [];
}
$tags = $list_id ? ( self::get_mc_instance() )->validate(
$mc->get(
"lists/$list_id/segments",
[
'type' => 'static', // 'saved' or 'static' segments. Tags are called 'static' segments in Mailchimp's API.
'count' => $limit ?? 1000,
],
60
),
__( 'Error retrieving Mailchimp tags.', 'newspack_newsletters' )
) : null;
if ( $tags && count( $tags['segments'] ) ) {
return $tags['segments'];
}
return [];
}
/**
* Fetches the campaign folders.
*
* @throws Exception In case of errors while fetching data from the server.
* @return array The list folders
*/
private static function fetch_folders() {
$mc = self::get_mc_api();
if ( \is_wp_error( $mc ) ) {
return [];
}
$response = ( self::get_mc_instance() )->validate(
$mc->get( 'campaign-folders', [ 'count' => 1000 ], 60 ),
__( 'Error retrieving Mailchimp folders.', 'newspack_newsletters' )
);
return $response['folders'];
}
/**
* Fetches the merge fields for a given List from the Mailchimp server
*
* @param string $list_id The List ID.
* @throws Exception In case of errors while fetching data from the server.
* @return array The list interest_categories
*/
private static function fetch_merge_fields( $list_id ) {
$mc = self::get_mc_api();
if ( \is_wp_error( $mc ) ) {
return [];
}
$response = ( self::get_mc_instance() )->validate(
$mc->get(
"lists/$list_id/merge-fields",
[
'count' => 1000,
],
60
),
__( 'Error retrieving Mailchimp list merge fields.', 'newspack_newsletters' )
);
return $response['merge_fields'];
}
}
Newspack_Newsletters_Mailchimp_Cached_Data::init();