PluginProbe
Mailchimp List Subscribe Form / 1.6.1
Mailchimp List Subscribe Form v1.6.1
1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 All 55 releases
mailchimp / includes / class-mailchimp-admin.php

class-mailchimp-admin.php in Mailchimp List Subscribe Form 1.6.1, at includes/class-mailchimp-admin.php

838 lines 30.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class responsible for admin side functionalities.
4 *
5 * @package Mailchimp
6 */
7
8 // Exit if accessed directly.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * Class Mailchimp_Admin
15 *
16 * @since 1.6.0
17 */
18 class Mailchimp_Admin {
19
20 /**
21 * The OAuth base endpoint
22 *
23 * @since 1.6.0
24 * @var string
25 */
26 private $oauth_url = 'https://wordpress.mailchimpapp.com';
27
28 /**
29 * Initialize the class
30 */
31 public function init() {
32 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
33 add_action( 'wp_ajax_mailchimp_sf_oauth_start', array( $this, 'start_oauth_process' ) );
34 add_action( 'wp_ajax_mailchimp_sf_oauth_finish', array( $this, 'finish_oauth_process' ) );
35 add_action( 'wp_ajax_mailchimp_sf_create_account', array( $this, 'mailchimp_create_account' ) );
36 add_action( 'wp_ajax_mailchimp_sf_check_login_session', array( $this, 'check_login_session' ) );
37
38 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_page_scripts' ) );
39 add_action( 'admin_menu', array( $this, 'add_create_account_page' ) );
40 add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
41 }
42
43 /**
44 * Start the OAuth process.
45 *
46 * This function is called via AJAX.
47 *
48 * It starts the OAuth process by the calling the OAuth middleware
49 * server and sending the response to the front-end.
50 */
51 public function start_oauth_process() {
52 // Validate the nonce and permissions.
53 if (
54 ! current_user_can( 'manage_options' ) ||
55 ! isset( $_POST['nonce'] ) ||
56 ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'mailchimp_sf_oauth_start_nonce' )
57 ) {
58 wp_send_json_error( array( 'message' => esc_html__( 'You do not have permission to perform this action.', 'mailchimp' ) ) );
59 }
60
61 // Generate a secret and send it to the OAuth server.
62 $secret = uniqid( 'mailchimp_sf_' );
63 $args = array(
64 'domain' => site_url(),
65 'secret' => $secret,
66 );
67
68 $options = array(
69 'headers' => array(
70 'Content-type' => 'application/json',
71 ),
72 'body' => wp_json_encode( $args ),
73 );
74
75 $response = wp_remote_post( $this->oauth_url . '/api/start', $options );
76
77 // Check for errors.
78 if ( $response instanceof WP_Error ) {
79 wp_send_json_error( array( 'message' => $response->get_error_message() ) );
80 }
81
82 // Send the response to the front-end.
83 if ( 201 === $response['response']['code'] && ! empty( $response['body'] ) ) {
84 set_site_transient( 'mailchimp_sf_oauth_secret', $secret, 60 * 60 );
85 $result = json_decode( $response['body'], true );
86 wp_send_json_success( $result );
87 } else {
88 if ( ! empty( $response['response'] ) ) {
89 $response = $response['response'];
90 }
91 wp_send_json_error( $response );
92 }
93 }
94
95 /**
96 * Finish the OAuth process.
97 *
98 * This function is called via AJAX.
99 *
100 * This function finishes the OAuth process by the sending
101 * a temporary token back to the OAuth server.
102 */
103 public function finish_oauth_process() {
104 // Validate the nonce and permissions.
105 if (
106 ! current_user_can( 'manage_options' ) ||
107 ! isset( $_POST['nonce'] ) ||
108 ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'mailchimp_sf_oauth_finish_nonce' )
109 ) {
110 wp_send_json_error( array( 'message' => esc_html__( 'You do not have permission to perform this action.', 'mailchimp' ) ) );
111 }
112
113 $token = isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '';
114 $args = array(
115 'domain' => site_url(),
116 'secret' => get_site_transient( 'mailchimp_sf_oauth_secret' ),
117 'token' => $token,
118 );
119
120 $options = array(
121 'headers' => array(
122 'Content-type' => 'application/json',
123 ),
124 'body' => wp_json_encode( $args ),
125 );
126 $response = wp_remote_post( $this->oauth_url . '/api/finish', $options );
127
128 // Check for errors.
129 if ( $response instanceof WP_Error ) {
130 wp_send_json_error( array( 'message' => $response->get_error_message() ) );
131 }
132
133 if ( 200 === $response['response']['code'] ) {
134 // Save the access token and data center.
135 $result = json_decode( $response['body'], true );
136 if ( $result && ! empty( $result['access_token'] ) && ! empty( $result['data_center'] ) ) {
137 delete_site_transient( 'mailchimp_sf_oauth_secret' );
138
139 // Verify the token.
140 $verify = $this->verify_and_save_oauth_token( $result['access_token'], $result['data_center'] );
141
142 if ( is_wp_error( $verify ) ) {
143 // If there is an error, send it back to the front-end.
144 wp_send_json_error( array( 'message' => $verify->get_error_message() ) );
145 }
146
147 wp_send_json_success( true );
148 } else {
149 wp_send_json_error( array( 'message' => esc_html__( 'Invalid response from the server.', 'mailchimp' ) ) );
150 }
151 } else {
152 wp_send_json_error( $response );
153 }
154 }
155
156 /**
157 * Create a new Mailchimp account.
158 *
159 * This function is called via AJAX.
160 *
161 * This function creates a new Mailchimp account by sending the user data to the middleware server.
162 */
163 public function mailchimp_create_account() {
164 // Validate the nonce and permissions.
165 if (
166 ! current_user_can( 'manage_options' ) ||
167 ! isset( $_POST['nonce'] ) ||
168 ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'mailchimp_sf_create_account_nonce' )
169 ) {
170 wp_send_json_error( array( 'message' => esc_html__( 'You do not have permission to perform this action.', 'mailchimp' ) ) );
171 }
172
173 $data = isset( $_POST['data'] ) ? $this->sanitize_data( wp_unslash( $_POST['data'] ) ) : array(); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Data is sanitized in the sanitize_data method.
174 if ( empty( $data ) ) {
175 wp_send_json_error( array( 'message' => esc_html__( 'No data provided.', 'mailchimp' ) ) );
176 }
177
178 // Get the IP address.
179 if ( isset( $_SERVER['REMOTE_ADDR'] ) && ( '::1' === $_SERVER['REMOTE_ADDR'] || '127.0.0.1' === $_SERVER['REMOTE_ADDR'] ) ) {
180 $data['ip_address'] = '127.0.0.1';
181 } elseif ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
182 $data['ip_address'] = sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
183 } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
184 $data['ip_address'] = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) );
185 } else {
186 $data['ip_address'] = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
187 }
188
189 $request_data = array(
190 'headers' => array(
191 'Content-type' => 'application/json',
192 'Accept' => 'application/json',
193 ),
194 'body' => wp_json_encode( $data ),
195 'timeout' => 30,
196 );
197
198 $response = wp_remote_post( $this->oauth_url . '/api/signup/', $request_data );
199 // Return the error if there is one.
200 if ( $response instanceof WP_Error ) {
201 wp_send_json_error( array( 'message' => $response->get_error_message() ) );
202 }
203
204 $response_body = json_decode( $response['body'] );
205 if ( 200 === $response['response']['code'] && true === $response_body->success ) {
206 $result = json_decode( $response['body'], true );
207
208 // Verify and save the token.
209 $verify = $this->verify_and_save_oauth_token( $result['data']['oauth_token'], $result['data']['dc'] );
210
211 if ( is_wp_error( $verify ) ) {
212 // If there is an error, send it back to the front-end.
213 wp_send_json_error( array( 'message' => $verify->get_error_message() ) );
214 }
215 update_option( 'mailchimp_sf_waiting_for_login', 'waiting' );
216 wp_send_json_success( true );
217
218 } elseif ( 404 === $response['response']['code'] ) {
219 wp_send_json_error( array( 'success' => false ) );
220
221 } else {
222 $username = isset( $_POST['data']['username'] ) ? sanitize_email( wp_unslash( $_POST['data']['username'] ) ) : '';
223 $username = preg_replace( '/[^A-Za-z0-9\-\@\.]/', '', $username );
224 $suggestion = wp_remote_get( $this->oauth_url . '/api/usernames/suggestions/' . $username );
225 $suggested_username = json_decode( $suggestion['body'] )->data;
226 wp_send_json_error(
227 array(
228 'success' => false,
229 'suggest_login' => true,
230 'suggested_username' => $suggested_username,
231 )
232 );
233 }
234 }
235
236 /**
237 * Check the login session.
238 *
239 * This function is called via AJAX.
240 *
241 * This function checks if the user is logged in to Mailchimp which confirms the account activation.
242 */
243 public function check_login_session() {
244 // Validate the nonce and permissions.
245 if (
246 ! current_user_can( 'manage_options' ) ||
247 ! isset( $_POST['nonce'] ) ||
248 ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'mailchimp_sf_check_login_session_nonce' )
249 ) {
250 wp_send_json_error( array( 'message' => esc_html__( 'You do not have permission to perform this action.', 'mailchimp' ) ) );
251 }
252
253 $api = mailchimp_sf_get_api();
254 if ( $api ) {
255 $profile = $api->get( '' );
256 if ( is_wp_error( $profile ) ) {
257 wp_send_json_error( array( 'message' => $profile->get_error_message() ) );
258 }
259
260 $logged_in = ( ! empty( $profile['last_login'] ) );
261 if ( $logged_in ) {
262 delete_option( 'mailchimp_sf_waiting_for_login' );
263 }
264 wp_send_json_success(
265 array(
266 'success' => true,
267 'logged_in' => $logged_in,
268 'redirect' => admin_url( 'admin.php?page=mailchimp_sf_options' ),
269 )
270 );
271 } else {
272 wp_send_json_error( array( 'success' => false ) );
273 }
274 }
275
276 /**
277 * Verify and save the OAuth token.
278 *
279 * @param string $access_token The token to verify.
280 * @param string $data_center The data center to verify.
281 * @return mixed
282 */
283 public function verify_and_save_oauth_token( $access_token, $data_center ) {
284 try {
285 $api = new MailChimp_API( $access_token, $data_center );
286 } catch ( Exception $e ) {
287 $msg = $e->getMessage();
288 return new WP_Error( 'mailchimp-sf-invalid-token', $msg );
289 }
290
291 $user = $api->get( '' );
292 if ( is_wp_error( $user ) ) {
293 return $user;
294 }
295
296 // Might as well set this data if we have it already.
297 $valid_roles = array( 'owner', 'admin', 'manager' );
298 if ( isset( $user['role'] ) && in_array( $user['role'], $valid_roles, true ) ) {
299 $data_encryption = new Mailchimp_Data_Encryption();
300
301 // Clean up the old data.
302 delete_option( 'mc_api_key' ); // Deprecated API key, need to remove as part of the migration.
303 delete_option( 'mailchimp_sf_access_token' );
304 delete_option( 'mailchimp_sf_auth_error' );
305 delete_option( 'mc_datacenter' );
306
307 update_option( 'mailchimp_sf_access_token', $data_encryption->encrypt( $access_token ) );
308 update_option( 'mc_datacenter', sanitize_text_field( $data_center ) );
309 update_option( 'mc_user', $this->sanitize_data( $user ) );
310
311 // Clear Mailchimp List ID if saved list is not available.
312 $lists = $api->get( 'lists', 100, array( 'fields' => 'lists.id' ) );
313 if ( ! is_wp_error( $lists ) ) {
314 $lists = $lists['lists'] ?? array();
315 $saved_list_id = get_option( 'mc_list_id' );
316 $list_ids = array_map(
317 function ( $ele ) {
318 return $ele['id'];
319 },
320 $lists
321 );
322 if ( ! in_array( $saved_list_id, $list_ids, true ) ) {
323 delete_option( 'mc_list_id' );
324 }
325 }
326 return true;
327 } else {
328 $msg = esc_html__( 'API Key must belong to "Owner", "Admin", or "Manager."', 'mailchimp' );
329 return new WP_Error( 'mailchimp-sf-invalid-role', $msg );
330 }
331 }
332
333 /**
334 * Display admin notices.
335 *
336 * @since 1.6.0
337 */
338 public function admin_notices() {
339 if ( ! current_user_can( 'manage_options' ) ) {
340 return;
341 }
342 $current_screen = get_current_screen();
343
344 // Display a deprecation notice if the user is using an API key to connect with Mailchimp.
345 if ( get_option( 'mc_api_key', '' ) && ! get_option( 'mailchimp_sf_access_token', '' ) && mailchimp_sf_should_display_form() ) {
346
347 if ( $current_screen && 'toplevel_page_mailchimp_sf_options' === $current_screen->id ) {
348 ?>
349 <div class="notice notice-warning">
350 <p>
351 <?php
352 esc_html_e( 'You are using an outdated API Key connection to Mailchimp, please migrate to the new OAuth authentication method to continue accessing your Mailchimp account.', 'mailchimp' );
353 ?>
354 </p>
355 <div class="migrate-to-oauth-wrapper">
356 <?php
357 // Migrate button.
358 $login_button_text = __( 'Migrate to OAuth authentication', 'mailchimp' );
359 include_once MCSF_DIR . 'includes/admin/templates/login-button.php'; // phpcs:ignore PEAR.Files.IncludingFile.UseRequireOnce
360 ?>
361 </div>
362 </div>
363 <?php
364 } else {
365 ?>
366 <div class="notice notice-warning is-dismissible">
367 <p>
368 <?php
369 $message = sprintf(
370 /* translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag */
371 __( 'You are using an outdated API Key connection to Mailchimp, please migrate to the new OAuth authentication method to continue accessing your Mailchimp account by clicking the "Migrate to OAuth authentication" button on the %1$sMailchimp settings%2$s page.', 'mailchimp' ),
372 '<a href="' . esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ) . '">',
373 '</a>'
374 );
375
376 echo wp_kses( $message, array( 'a' => array( 'href' => array() ) ) );
377 ?>
378 </p>
379 </div>
380 <?php
381 }
382 }
383
384 // Display a notice if the user is waiting for the login to complete.
385 if ( $current_screen && 'toplevel_page_mailchimp_sf_options' === $current_screen->id ) {
386 $api = mailchimp_sf_get_api();
387 if ( $api && 'waiting' === get_option( 'mailchimp_sf_waiting_for_login' ) ) {
388 $profile = $api->get( '' );
389 if ( ! is_wp_error( $profile ) ) {
390 if ( ! empty( $profile['last_login'] ) ) {
391 // Clear the waiting flag if the user is logged in.
392 delete_option( 'mailchimp_sf_waiting_for_login' );
393 } else {
394 ?>
395 <div class="notice notice-warning is-dismissible">
396 <p>
397 <?php
398 esc_html_e( 'Please activate your Mailchimp account to complete the setup. Without activation, the connection to WordPress may be interrupted.', 'mailchimp' );
399 ?>
400 </p>
401 </div>
402 <?php
403 }
404 }
405 }
406 }
407
408 if (
409 ! get_option( 'mailchimp_sf_auth_error', false ) ||
410 ! get_option( 'mailchimp_sf_access_token', '' )
411 ) {
412 return;
413 }
414
415 // Display a notice if the access token is invalid/revoked.
416 ?>
417 <div class="notice notice-error is-dismissible">
418 <p>
419 <?php
420 $message = sprintf(
421 /* translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag */
422 __( 'Heads up! There may be a problem with your connection to Mailchimp. Please %1$sre-connect%2$s your Mailchimp account to fix the issue.', 'mailchimp' ),
423 '<a href="' . esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ) . '">',
424 '</a>'
425 );
426
427 echo wp_kses( $message, array( 'a' => array( 'href' => array() ) ) );
428 ?>
429 </p>
430 </div>
431 <?php
432 }
433
434 /**
435 * Sanitize variables using sanitize_text_field.
436 *
437 * Arrays are sanitized recursively, non-scalar values are ignored.
438 *
439 * @param string|array $data Data to sanitize.
440 * @return string|array
441 */
442 public function sanitize_data( $data ) {
443 if ( is_array( $data ) ) {
444 return array_map( array( $this, 'sanitize_data' ), $data );
445 } else {
446 return is_scalar( $data ) ? sanitize_text_field( $data ) : $data;
447 }
448 }
449
450 /**
451 * Enqueue scripts/styles for the Mailchimp admin page
452 *
453 * @param string $hook_suffix The current admin page.
454 * @return void
455 */
456 public function enqueue_admin_page_scripts( $hook_suffix ) {
457 if ( 'toplevel_page_mailchimp_sf_options' !== $hook_suffix && 'admin_page_mailchimp_sf_create_account' !== $hook_suffix ) {
458 return;
459 }
460
461 wp_enqueue_style( 'mailchimp_sf_admin_css', MCSF_URL . 'assets/css/admin.css', array( 'wp-jquery-ui-dialog' ), true );
462 wp_enqueue_script( 'showMe', MCSF_URL . 'assets/js/hidecss.js', array( 'jquery' ), MCSF_VER, true );
463 wp_enqueue_script( 'mailchimp_sf_admin', MCSF_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-ui-dialog' ), MCSF_VER, true );
464
465 $data = array(
466 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
467 'oauth_url' => esc_url( $this->oauth_url ),
468 'oauth_start_nonce' => wp_create_nonce( 'mailchimp_sf_oauth_start_nonce' ),
469 'oauth_finish_nonce' => wp_create_nonce( 'mailchimp_sf_oauth_finish_nonce' ),
470 'oauth_window_name' => esc_html__( 'Mailchimp For WordPress OAuth', 'mailchimp' ),
471 'generic_error' => esc_html__( 'An error occurred. Please try again.', 'mailchimp' ),
472 'modal_title' => esc_html__( 'Login Popup is blocked!', 'mailchimp' ),
473 'modal_button_try_again' => esc_html__( 'Try again', 'mailchimp' ),
474 'modal_button_cancel' => esc_html__( 'No, cancel!', 'mailchimp' ),
475 'admin_settings_url' => esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ),
476 );
477
478 // Create account page specific data.
479 if ( 'admin_page_mailchimp_sf_create_account' === $hook_suffix ) {
480 $data['create_account_nonce'] = wp_create_nonce( 'mailchimp_sf_create_account_nonce' );
481 $data['check_login_session_nonce'] = wp_create_nonce( 'mailchimp_sf_check_login_session_nonce' );
482 /* translators: %s is field name. */
483 $data['required_error'] = esc_html__( '%s can\'t be blank.', 'mailchimp' );
484 $data['invalid_email_error'] = esc_html__( 'Insert correct email.', 'mailchimp' );
485 $data['confirm_email_match'] = esc_html__( 'Email confirmation must match confirmation email.', 'mailchimp' );
486 $data['confirm_email_match2'] = esc_html__( 'Email confirmation must match the field above.', 'mailchimp' );
487 }
488
489 wp_localize_script(
490 'mailchimp_sf_admin',
491 'mailchimp_sf_admin_params',
492 $data
493 );
494 }
495
496 /**
497 * Add the create account page.
498 *
499 * @since x.x.x
500 */
501 public function add_create_account_page() {
502 add_submenu_page(
503 'admin.php',
504 esc_html__( 'Create Mailchimp Account', 'mailchimp' ),
505 esc_html__( 'Create Mailchimp Account', 'mailchimp' ),
506 'manage_options',
507 'mailchimp_sf_create_account',
508 array( $this, 'create_account_page' )
509 );
510 }
511
512 /**
513 * Create account page.
514 *
515 * @since x.x.x
516 *
517 * @return void
518 */
519 public function create_account_page() {
520 $countries = $this->get_countries();
521 $timezones = $this->get_timezones();
522 ?>
523 <div id="mailchimp-sf-settings-page">
524 <?php
525 include_once MCSF_DIR . 'includes/admin/templates/create-account-page.php';
526 ?>
527 </div>
528 <?php
529 }
530
531 /**
532 * Get a list of timezones.
533 *
534 * @since x.x.x
535 *
536 * @return array
537 */
538 private function get_timezones() {
539 return timezone_identifiers_list();
540 }
541
542 /**
543 * Get a list of countries.
544 *
545 * @since x.x.x
546 *
547 * @return array
548 */
549 public function get_countries() {
550 return array(
551 'AF' => __( 'Afghanistan', 'mailchimp' ),
552 'AX' => __( '�
553 land Islands', 'mailchimp' ),
554 'AL' => __( 'Albania', 'mailchimp' ),
555 'DZ' => __( 'Algeria', 'mailchimp' ),
556 'AS' => __( 'American Samoa', 'mailchimp' ),
557 'AD' => __( 'Andorra', 'mailchimp' ),
558 'AO' => __( 'Angola', 'mailchimp' ),
559 'AI' => __( 'Anguilla', 'mailchimp' ),
560 'AQ' => __( 'Antarctica', 'mailchimp' ),
561 'AG' => __( 'Antigua and Barbuda', 'mailchimp' ),
562 'AR' => __( 'Argentina', 'mailchimp' ),
563 'AM' => __( 'Armenia', 'mailchimp' ),
564 'AW' => __( 'Aruba', 'mailchimp' ),
565 'AU' => __( 'Australia', 'mailchimp' ),
566 'AT' => __( 'Austria', 'mailchimp' ),
567 'AZ' => __( 'Azerbaijan', 'mailchimp' ),
568 'BS' => __( 'Bahamas', 'mailchimp' ),
569 'BH' => __( 'Bahrain', 'mailchimp' ),
570 'BD' => __( 'Bangladesh', 'mailchimp' ),
571 'BB' => __( 'Barbados', 'mailchimp' ),
572 'BY' => __( 'Belarus', 'mailchimp' ),
573 'BE' => __( 'Belgium', 'mailchimp' ),
574 'PW' => __( 'Belau', 'mailchimp' ),
575 'BZ' => __( 'Belize', 'mailchimp' ),
576 'BJ' => __( 'Benin', 'mailchimp' ),
577 'BM' => __( 'Bermuda', 'mailchimp' ),
578 'BT' => __( 'Bhutan', 'mailchimp' ),
579 'BO' => __( 'Bolivia', 'mailchimp' ),
580 'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'mailchimp' ),
581 'BA' => __( 'Bosnia and Herzegovina', 'mailchimp' ),
582 'BW' => __( 'Botswana', 'mailchimp' ),
583 'BV' => __( 'Bouvet Island', 'mailchimp' ),
584 'BR' => __( 'Brazil', 'mailchimp' ),
585 'IO' => __( 'British Indian Ocean Territory', 'mailchimp' ),
586 'BN' => __( 'Brunei', 'mailchimp' ),
587 'BG' => __( 'Bulgaria', 'mailchimp' ),
588 'BF' => __( 'Burkina Faso', 'mailchimp' ),
589 'BI' => __( 'Burundi', 'mailchimp' ),
590 'KH' => __( 'Cambodia', 'mailchimp' ),
591 'CM' => __( 'Cameroon', 'mailchimp' ),
592 'CA' => __( 'Canada', 'mailchimp' ),
593 'CV' => __( 'Cape Verde', 'mailchimp' ),
594 'KY' => __( 'Cayman Islands', 'mailchimp' ),
595 'CF' => __( 'Central African Republic', 'mailchimp' ),
596 'TD' => __( 'Chad', 'mailchimp' ),
597 'CL' => __( 'Chile', 'mailchimp' ),
598 'CN' => __( 'China', 'mailchimp' ),
599 'CX' => __( 'Christmas Island', 'mailchimp' ),
600 'CC' => __( 'Cocos (Keeling) Islands', 'mailchimp' ),
601 'CO' => __( 'Colombia', 'mailchimp' ),
602 'KM' => __( 'Comoros', 'mailchimp' ),
603 'CG' => __( 'Congo (Brazzaville)', 'mailchimp' ),
604 'CD' => __( 'Congo (Kinshasa)', 'mailchimp' ),
605 'CK' => __( 'Cook Islands', 'mailchimp' ),
606 'CR' => __( 'Costa Rica', 'mailchimp' ),
607 'HR' => __( 'Croatia', 'mailchimp' ),
608 'CU' => __( 'Cuba', 'mailchimp' ),
609 'CW' => __( 'Cura&ccedil;ao', 'mailchimp' ),
610 'CY' => __( 'Cyprus', 'mailchimp' ),
611 'CZ' => __( 'Czech Republic', 'mailchimp' ),
612 'DK' => __( 'Denmark', 'mailchimp' ),
613 'DJ' => __( 'Djibouti', 'mailchimp' ),
614 'DM' => __( 'Dominica', 'mailchimp' ),
615 'DO' => __( 'Dominican Republic', 'mailchimp' ),
616 'EC' => __( 'Ecuador', 'mailchimp' ),
617 'EG' => __( 'Egypt', 'mailchimp' ),
618 'SV' => __( 'El Salvador', 'mailchimp' ),
619 'GQ' => __( 'Equatorial Guinea', 'mailchimp' ),
620 'ER' => __( 'Eritrea', 'mailchimp' ),
621 'EE' => __( 'Estonia', 'mailchimp' ),
622 'ET' => __( 'Ethiopia', 'mailchimp' ),
623 'FK' => __( 'Falkland Islands', 'mailchimp' ),
624 'FO' => __( 'Faroe Islands', 'mailchimp' ),
625 'FJ' => __( 'Fiji', 'mailchimp' ),
626 'FI' => __( 'Finland', 'mailchimp' ),
627 'FR' => __( 'France', 'mailchimp' ),
628 'GF' => __( 'French Guiana', 'mailchimp' ),
629 'PF' => __( 'French Polynesia', 'mailchimp' ),
630 'TF' => __( 'French Southern Territories', 'mailchimp' ),
631 'GA' => __( 'Gabon', 'mailchimp' ),
632 'GM' => __( 'Gambia', 'mailchimp' ),
633 'GE' => __( 'Georgia', 'mailchimp' ),
634 'DE' => __( 'Germany', 'mailchimp' ),
635 'GH' => __( 'Ghana', 'mailchimp' ),
636 'GI' => __( 'Gibraltar', 'mailchimp' ),
637 'GR' => __( 'Greece', 'mailchimp' ),
638 'GL' => __( 'Greenland', 'mailchimp' ),
639 'GD' => __( 'Grenada', 'mailchimp' ),
640 'GP' => __( 'Guadeloupe', 'mailchimp' ),
641 'GU' => __( 'Guam', 'mailchimp' ),
642 'GT' => __( 'Guatemala', 'mailchimp' ),
643 'GG' => __( 'Guernsey', 'mailchimp' ),
644 'GN' => __( 'Guinea', 'mailchimp' ),
645 'GW' => __( 'Guinea-Bissau', 'mailchimp' ),
646 'GY' => __( 'Guyana', 'mailchimp' ),
647 'HT' => __( 'Haiti', 'mailchimp' ),
648 'HM' => __( 'Heard Island and McDonald Islands', 'mailchimp' ),
649 'HN' => __( 'Honduras', 'mailchimp' ),
650 'HK' => __( 'Hong Kong', 'mailchimp' ),
651 'HU' => __( 'Hungary', 'mailchimp' ),
652 'IS' => __( 'Iceland', 'mailchimp' ),
653 'IN' => __( 'India', 'mailchimp' ),
654 'ID' => __( 'Indonesia', 'mailchimp' ),
655 'IR' => __( 'Iran', 'mailchimp' ),
656 'IQ' => __( 'Iraq', 'mailchimp' ),
657 'IE' => __( 'Ireland', 'mailchimp' ),
658 'IM' => __( 'Isle of Man', 'mailchimp' ),
659 'IL' => __( 'Israel', 'mailchimp' ),
660 'IT' => __( 'Italy', 'mailchimp' ),
661 'CI' => __( 'Ivory Coast', 'mailchimp' ),
662 'JM' => __( 'Jamaica', 'mailchimp' ),
663 'JP' => __( 'Japan', 'mailchimp' ),
664 'JE' => __( 'Jersey', 'mailchimp' ),
665 'JO' => __( 'Jordan', 'mailchimp' ),
666 'KZ' => __( 'Kazakhstan', 'mailchimp' ),
667 'KE' => __( 'Kenya', 'mailchimp' ),
668 'KI' => __( 'Kiribati', 'mailchimp' ),
669 'KW' => __( 'Kuwait', 'mailchimp' ),
670 'KG' => __( 'Kyrgyzstan', 'mailchimp' ),
671 'LA' => __( 'Laos', 'mailchimp' ),
672 'LV' => __( 'Latvia', 'mailchimp' ),
673 'LB' => __( 'Lebanon', 'mailchimp' ),
674 'LS' => __( 'Lesotho', 'mailchimp' ),
675 'LR' => __( 'Liberia', 'mailchimp' ),
676 'LY' => __( 'Libya', 'mailchimp' ),
677 'LI' => __( 'Liechtenstein', 'mailchimp' ),
678 'LT' => __( 'Lithuania', 'mailchimp' ),
679 'LU' => __( 'Luxembourg', 'mailchimp' ),
680 'MO' => __( 'Macao', 'mailchimp' ),
681 'MK' => __( 'North Macedonia', 'mailchimp' ),
682 'MG' => __( 'Madagascar', 'mailchimp' ),
683 'MW' => __( 'Malawi', 'mailchimp' ),
684 'MY' => __( 'Malaysia', 'mailchimp' ),
685 'MV' => __( 'Maldives', 'mailchimp' ),
686 'ML' => __( 'Mali', 'mailchimp' ),
687 'MT' => __( 'Malta', 'mailchimp' ),
688 'MH' => __( 'Marshall Islands', 'mailchimp' ),
689 'MQ' => __( 'Martinique', 'mailchimp' ),
690 'MR' => __( 'Mauritania', 'mailchimp' ),
691 'MU' => __( 'Mauritius', 'mailchimp' ),
692 'YT' => __( 'Mayotte', 'mailchimp' ),
693 'MX' => __( 'Mexico', 'mailchimp' ),
694 'FM' => __( 'Micronesia', 'mailchimp' ),
695 'MD' => __( 'Moldova', 'mailchimp' ),
696 'MC' => __( 'Monaco', 'mailchimp' ),
697 'MN' => __( 'Mongolia', 'mailchimp' ),
698 'ME' => __( 'Montenegro', 'mailchimp' ),
699 'MS' => __( 'Montserrat', 'mailchimp' ),
700 'MA' => __( 'Morocco', 'mailchimp' ),
701 'MZ' => __( 'Mozambique', 'mailchimp' ),
702 'MM' => __( 'Myanmar', 'mailchimp' ),
703 'NA' => __( 'Namibia', 'mailchimp' ),
704 'NR' => __( 'Nauru', 'mailchimp' ),
705 'NP' => __( 'Nepal', 'mailchimp' ),
706 'NL' => __( 'Netherlands', 'mailchimp' ),
707 'NC' => __( 'New Caledonia', 'mailchimp' ),
708 'NZ' => __( 'New Zealand', 'mailchimp' ),
709 'NI' => __( 'Nicaragua', 'mailchimp' ),
710 'NE' => __( 'Niger', 'mailchimp' ),
711 'NG' => __( 'Nigeria', 'mailchimp' ),
712 'NU' => __( 'Niue', 'mailchimp' ),
713 'NF' => __( 'Norfolk Island', 'mailchimp' ),
714 'MP' => __( 'Northern Mariana Islands', 'mailchimp' ),
715 'KP' => __( 'North Korea', 'mailchimp' ),
716 'NO' => __( 'Norway', 'mailchimp' ),
717 'OM' => __( 'Oman', 'mailchimp' ),
718 'PK' => __( 'Pakistan', 'mailchimp' ),
719 'PS' => __( 'Palestinian Territory', 'mailchimp' ),
720 'PA' => __( 'Panama', 'mailchimp' ),
721 'PG' => __( 'Papua New Guinea', 'mailchimp' ),
722 'PY' => __( 'Paraguay', 'mailchimp' ),
723 'PE' => __( 'Peru', 'mailchimp' ),
724 'PH' => __( 'Philippines', 'mailchimp' ),
725 'PN' => __( 'Pitcairn', 'mailchimp' ),
726 'PL' => __( 'Poland', 'mailchimp' ),
727 'PT' => __( 'Portugal', 'mailchimp' ),
728 'PR' => __( 'Puerto Rico', 'mailchimp' ),
729 'QA' => __( 'Qatar', 'mailchimp' ),
730 'RE' => __( 'Reunion', 'mailchimp' ),
731 'RO' => __( 'Romania', 'mailchimp' ),
732 'RU' => __( 'Russia', 'mailchimp' ),
733 'RW' => __( 'Rwanda', 'mailchimp' ),
734 'BL' => __( 'Saint Barth&eacute;lemy', 'mailchimp' ),
735 'SH' => __( 'Saint Helena', 'mailchimp' ),
736 'KN' => __( 'Saint Kitts and Nevis', 'mailchimp' ),
737 'LC' => __( 'Saint Lucia', 'mailchimp' ),
738 'MF' => __( 'Saint Martin (French part)', 'mailchimp' ),
739 'SX' => __( 'Saint Martin (Dutch part)', 'mailchimp' ),
740 'PM' => __( 'Saint Pierre and Miquelon', 'mailchimp' ),
741 'VC' => __( 'Saint Vincent and the Grenadines', 'mailchimp' ),
742 'SM' => __( 'San Marino', 'mailchimp' ),
743 'ST' => __( 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'mailchimp' ),
744 'SA' => __( 'Saudi Arabia', 'mailchimp' ),
745 'SN' => __( 'Senegal', 'mailchimp' ),
746 'RS' => __( 'Serbia', 'mailchimp' ),
747 'SC' => __( 'Seychelles', 'mailchimp' ),
748 'SL' => __( 'Sierra Leone', 'mailchimp' ),
749 'SG' => __( 'Singapore', 'mailchimp' ),
750 'SK' => __( 'Slovakia', 'mailchimp' ),
751 'SI' => __( 'Slovenia', 'mailchimp' ),
752 'SB' => __( 'Solomon Islands', 'mailchimp' ),
753 'SO' => __( 'Somalia', 'mailchimp' ),
754 'ZA' => __( 'South Africa', 'mailchimp' ),
755 'GS' => __( 'South Georgia/Sandwich Islands', 'mailchimp' ),
756 'KR' => __( 'South Korea', 'mailchimp' ),
757 'SS' => __( 'South Sudan', 'mailchimp' ),
758 'ES' => __( 'Spain', 'mailchimp' ),
759 'LK' => __( 'Sri Lanka', 'mailchimp' ),
760 'SD' => __( 'Sudan', 'mailchimp' ),
761 'SR' => __( 'Suriname', 'mailchimp' ),
762 'SJ' => __( 'Svalbard and Jan Mayen', 'mailchimp' ),
763 'SZ' => __( 'Eswatini', 'mailchimp' ),
764 'SE' => __( 'Sweden', 'mailchimp' ),
765 'CH' => __( 'Switzerland', 'mailchimp' ),
766 'SY' => __( 'Syria', 'mailchimp' ),
767 'TW' => __( 'Taiwan', 'mailchimp' ),
768 'TJ' => __( 'Tajikistan', 'mailchimp' ),
769 'TZ' => __( 'Tanzania', 'mailchimp' ),
770 'TH' => __( 'Thailand', 'mailchimp' ),
771 'TL' => __( 'Timor-Leste', 'mailchimp' ),
772 'TG' => __( 'Togo', 'mailchimp' ),
773 'TK' => __( 'Tokelau', 'mailchimp' ),
774 'TO' => __( 'Tonga', 'mailchimp' ),
775 'TT' => __( 'Trinidad and Tobago', 'mailchimp' ),
776 'TN' => __( 'Tunisia', 'mailchimp' ),
777 'TR' => __( 'Turkey', 'mailchimp' ),
778 'TM' => __( 'Turkmenistan', 'mailchimp' ),
779 'TC' => __( 'Turks and Caicos Islands', 'mailchimp' ),
780 'TV' => __( 'Tuvalu', 'mailchimp' ),
781 'UG' => __( 'Uganda', 'mailchimp' ),
782 'UA' => __( 'Ukraine', 'mailchimp' ),
783 'AE' => __( 'United Arab Emirates', 'mailchimp' ),
784 'GB' => __( 'United Kingdom (UK)', 'mailchimp' ),
785 'US' => __( 'United States (US)', 'mailchimp' ),
786 'UM' => __( 'United States (US) Minor Outlying Islands', 'mailchimp' ),
787 'UY' => __( 'Uruguay', 'mailchimp' ),
788 'UZ' => __( 'Uzbekistan', 'mailchimp' ),
789 'VU' => __( 'Vanuatu', 'mailchimp' ),
790 'VA' => __( 'Vatican', 'mailchimp' ),
791 'VE' => __( 'Venezuela', 'mailchimp' ),
792 'VN' => __( 'Vietnam', 'mailchimp' ),
793 'VG' => __( 'Virgin Islands (British)', 'mailchimp' ),
794 'VI' => __( 'Virgin Islands (US)', 'mailchimp' ),
795 'WF' => __( 'Wallis and Futuna', 'mailchimp' ),
796 'EH' => __( 'Western Sahara', 'mailchimp' ),
797 'WS' => __( 'Samoa', 'mailchimp' ),
798 'YE' => __( 'Yemen', 'mailchimp' ),
799 'ZM' => __( 'Zambia', 'mailchimp' ),
800 'ZW' => __( 'Zimbabwe', 'mailchimp' ),
801 );
802 }
803
804 /**
805 * Display the Mailchimp footer text on the Mailchimp admin pages.
806 *
807 * @since x.x.x
808 *
809 * @param string $text The current footer text.
810 * @return string The modified footer text.
811 */
812 public function admin_footer_text( $text ) {
813 $current_screen = get_current_screen();
814 $current_screen_id = $current_screen ? $current_screen->id : '';
815 if ( ! in_array( $current_screen_id, array( 'toplevel_page_mailchimp_sf_options', 'admin_page_mailchimp_sf_create_account' ), true ) ) {
816 return $text;
817 }
818
819 return wp_kses(
820 sprintf(
821 /* translators: %d - Current year, %s - Mailchimp legal links */
822 __( '©%1$d Intuit Inc. All rights reserved. Mailchimp® is a registered trademark of The Rocket Science Group, <a href="%2$s" target="_blank" rel="noopener noreferrer">Cookie Preferences</a>, <a href="%3$s" target="_blank" rel="noopener noreferrer">Privacy</a>, and <a href="%4$s" target="_blank" rel="noopener noreferrer">Terms</a>.', 'mailchimp' ),
823 gmdate( 'Y' ),
824 esc_url( 'https://mailchimp.com/legal/cookies/#optanon-toggle-display/' ),
825 esc_url( 'https://www.intuit.com/privacy/statement/' ),
826 esc_url( 'https://mailchimp.com/legal/terms' )
827 ),
828 array(
829 'a' => array(
830 'href' => array(),
831 'target' => array(),
832 'rel' => array(),
833 ),
834 )
835 );
836 }
837 }
838