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.6 4.8.7 4.8.8 4.8.9 4.9.0 4.9.1 4.9.10 4.9.11 4.9.12 4.9.13 4.9.14 4.9.15 4.9.16 4.9.17 4.9.18 4.9.19 4.9.2 4.9.20 4.9.21 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 4.9.9 trunk 1.1.5 1.2.1 1.2.3 1.2.4 1.2.5 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8
mailchimp-for-wp / includes / class-personal-data-exporter.php
mailchimp-for-wp / includes Last commit date
admin 3 days ago api 4 weeks ago campaigns 3 days ago forms 3 days ago integrations 3 days ago views 1 week ago class-container.php 3 days ago class-debug-log-reader.php 3 days ago class-debug-log.php 3 days ago class-dynamic-content-tags.php 3 days ago class-field-formatter.php 1 year ago class-field-guesser.php 1 week ago class-list-data-mapper.php 4 months ago class-mailchimp-subscriber.php 2 months ago class-mailchimp.php 3 days ago class-personal-data-exporter.php 4 weeks ago class-plugin.php 1 year ago class-queue-job.php 4 weeks ago class-queue.php 1 year ago class-tools.php 1 year ago class-tracking-pixel.php 3 days ago default-actions.php 1 year ago default-filters.php 1 year ago deprecated-functions.php 3 years ago functions.php 3 days ago
class-personal-data-exporter.php
87 lines
1 <?php
2
3 /**
4 * Class MC4WP_Exporter
5 */
6 class MC4WP_Personal_Data_Exporter
7 {
8 /**
9 * Registers the personal data exporter for comments.
10 *
11 * @param array[] $exporters An array of personal data exporters.
12 * @return array[] An array of personal data exporters.
13 */
14 public static function add_mailchimp_to_privacy_export($exporters)
15 {
16 $exporters['mailchimp-subscriptions'] = [
17 'exporter_friendly_name' => __('Mailchimp Subscriptions', 'mailchimp-for-wp'),
18 'callback' => [self::class, 'get_mailchimp_subscription_data']
19 ];
20
21 return $exporters;
22 }
23
24 /**
25 * Retrieves the Mailchimp subscription data for a given email address.
26 *
27 * This method uses the Mailchimp for WordPress (MC4WP) API to search for members based on the provided
28 * email address and returns a list of Mailchimp lists the user is subscribed to, if any.
29 *
30 * @param string $email_address The email address of the user to search for.
31 *
32 * @return array An array containing the user's Mailchimp subscription data:
33 * - 'data' (array): The subscription information, including:
34 * - 'group_id' (string): The group identifier for Mailchimp.
35 * - 'group_label' (string): The label for the group ('Mailchimp Subscriptions').
36 * - 'item_id' (string): The item identifier ('mailchimp-subscriptions').
37 * - 'data' (array): The subscription details, with:
38 * - 'name' (string): The label ('Mailchimp List').
39 * - 'value' (string): A comma-separated list of Mailchimp lists the user is subscribed to.
40 * - 'done' (bool): Indicates the completion of the process (always true).
41 */
42 public static function get_mailchimp_subscription_data($email_address)
43 {
44 $api = mc4wp_get_api_v3();
45 $client = $api->get_client();
46 $data = $client->get('search-members?query=' . urlencode($email_address));
47
48 // Parse the API response to get the lists the user is subscribed to.
49 $subscribed_lists = [];
50 $data_to_export = [];
51
52 if (!empty($data->exact_matches->members)) {
53 $lists = $api->get_lists();
54 foreach ($data->exact_matches->members as $member) {
55 // Fetch the user's subscribed lists.
56 if (isset($member->list_id)) {
57 foreach ($lists as $list) {
58 if ($list->id == $member->list_id) {
59 $subscribed_lists[] = $list->name;
60 continue;
61 }
62 }
63 }
64 }
65 }
66
67 if ($subscribed_lists) {
68 $data_to_export[] = [
69 'group_id' => 'mailchimp',
70 'group_label' => __('Mailchimp Subscriptions', 'mailchimp-for-wp'),
71 'item_id' => 'mailchimp-subscriptions',
72 'data' => [
73 [
74 'name' => __('Mailchimp Lists', 'mailchimp-for-wp'),
75 'value' => implode(', ', $subscribed_lists),
76 ]
77 ]
78 ];
79 }
80
81 return [
82 'data' => $data_to_export,
83 'done' => true,
84 ];
85 }
86 }
87