PluginProbe
Mailchimp List Subscribe Form / 1.6.0
Mailchimp List Subscribe Form v1.6.0
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.0, at includes/class-mailchimp-admin.php

802 lines 28.8 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( 'mailchimp_sf_access_token' );
303 delete_option( 'mailchimp_sf_auth_error' );
304 delete_option( 'mc_datacenter' );
305
306 update_option( 'mailchimp_sf_access_token', $data_encryption->encrypt( $access_token ) );
307 update_option( 'mc_datacenter', sanitize_text_field( $data_center ) );
308 update_option( 'mc_user', $this->sanitize_data( $user ) );
309 return true;
310
311 } else {
312 $msg = esc_html__( 'API Key must belong to "Owner", "Admin", or "Manager."', 'mailchimp' );
313 return new WP_Error( 'mailchimp-sf-invalid-role', $msg );
314 }
315 }
316
317 /**
318 * Display admin notices.
319 *
320 * @since 1.6.0
321 */
322 public function admin_notices() {
323 if ( ! current_user_can( 'manage_options' ) ) {
324 return;
325 }
326
327 // Display a deprecation notice if the user is using an API key to connect with Mailchimp.
328 if ( get_option( 'mc_api_key', '' ) && ! get_option( 'mailchimp_sf_access_token', '' ) && mailchimp_sf_should_display_form() ) {
329 ?>
330 <div class="notice notice-warning is-dismissible">
331 <p>
332 <?php
333 $message = sprintf(
334 /* translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag */
335 __( 'Heads up! It looks like you\'re using an API key to connect with Mailchimp, which is now deprecated. Please log out and reconnect your Mailchimp account using the new OAuth authentication by clicking the "Log in" button on the %1$splugin settings%2$s page.', 'mailchimp' ),
336 '<a href="' . esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ) . '">',
337 '</a>'
338 );
339
340 echo wp_kses( $message, array( 'a' => array( 'href' => array() ) ) );
341 ?>
342 </p>
343 </div>
344 <?php
345 }
346
347 // Display a notice if the user is waiting for the login to complete.
348 $current_screen = get_current_screen();
349 if ( $current_screen && 'toplevel_page_mailchimp_sf_options' === $current_screen->id ) {
350 $api = mailchimp_sf_get_api();
351 if ( $api && 'waiting' === get_option( 'mailchimp_sf_waiting_for_login' ) ) {
352 $profile = $api->get( '' );
353 if ( ! is_wp_error( $profile ) ) {
354 if ( ! empty( $profile['last_login'] ) ) {
355 // Clear the waiting flag if the user is logged in.
356 delete_option( 'mailchimp_sf_waiting_for_login' );
357 } else {
358 ?>
359 <div class="notice notice-warning is-dismissible">
360 <p>
361 <?php
362 esc_html_e( 'Please activate your Mailchimp account to complete the setup. Without activation, the connection to WordPress may be interrupted.', 'mailchimp' );
363 ?>
364 </p>
365 </div>
366 <?php
367 }
368 }
369 }
370 }
371
372 if (
373 ! get_option( 'mailchimp_sf_auth_error', false ) ||
374 ! get_option( 'mailchimp_sf_access_token', '' )
375 ) {
376 return;
377 }
378
379 // Display a notice if the access token is invalid/revoked.
380 ?>
381 <div class="notice notice-error is-dismissible">
382 <p>
383 <?php
384 $message = sprintf(
385 /* translators: Placeholders: %1$s - <a> tag, %2$s - </a> tag */
386 __( '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' ),
387 '<a href="' . esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ) . '">',
388 '</a>'
389 );
390
391 echo wp_kses( $message, array( 'a' => array( 'href' => array() ) ) );
392 ?>
393 </p>
394 </div>
395 <?php
396 }
397
398 /**
399 * Sanitize variables using sanitize_text_field.
400 *
401 * Arrays are sanitized recursively, non-scalar values are ignored.
402 *
403 * @param string|array $data Data to sanitize.
404 * @return string|array
405 */
406 public function sanitize_data( $data ) {
407 if ( is_array( $data ) ) {
408 return array_map( array( $this, 'sanitize_data' ), $data );
409 } else {
410 return is_scalar( $data ) ? sanitize_text_field( $data ) : $data;
411 }
412 }
413
414 /**
415 * Enqueue scripts/styles for the Mailchimp admin page
416 *
417 * @param string $hook_suffix The current admin page.
418 * @return void
419 */
420 public function enqueue_admin_page_scripts( $hook_suffix ) {
421 if ( 'toplevel_page_mailchimp_sf_options' !== $hook_suffix && 'admin_page_mailchimp_sf_create_account' !== $hook_suffix ) {
422 return;
423 }
424
425 wp_enqueue_style( 'mailchimp_sf_admin_css', MCSF_URL . 'assets/css/admin.css', array( 'wp-jquery-ui-dialog' ), true );
426 wp_enqueue_script( 'showMe', MCSF_URL . 'assets/js/hidecss.js', array( 'jquery' ), MCSF_VER, true );
427 wp_enqueue_script( 'mailchimp_sf_admin', MCSF_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-ui-dialog' ), MCSF_VER, true );
428
429 $data = array(
430 'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
431 'oauth_url' => esc_url( $this->oauth_url ),
432 'oauth_start_nonce' => wp_create_nonce( 'mailchimp_sf_oauth_start_nonce' ),
433 'oauth_finish_nonce' => wp_create_nonce( 'mailchimp_sf_oauth_finish_nonce' ),
434 'oauth_window_name' => esc_html__( 'Mailchimp For WordPress OAuth', 'mailchimp' ),
435 'generic_error' => esc_html__( 'An error occurred. Please try again.', 'mailchimp' ),
436 'modal_title' => esc_html__( 'Login Popup is blocked!', 'mailchimp' ),
437 'modal_button_try_again' => esc_html__( 'Try again', 'mailchimp' ),
438 'modal_button_cancel' => esc_html__( 'No, cancel!', 'mailchimp' ),
439 'admin_settings_url' => esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) ),
440 );
441
442 // Create account page specific data.
443 if ( 'admin_page_mailchimp_sf_create_account' === $hook_suffix ) {
444 $data['create_account_nonce'] = wp_create_nonce( 'mailchimp_sf_create_account_nonce' );
445 $data['check_login_session_nonce'] = wp_create_nonce( 'mailchimp_sf_check_login_session_nonce' );
446 /* translators: %s is field name. */
447 $data['required_error'] = esc_html__( '%s can\'t be blank.', 'mailchimp' );
448 $data['invalid_email_error'] = esc_html__( 'Insert correct email.', 'mailchimp' );
449 $data['confirm_email_match'] = esc_html__( 'Email confirmation must match confirmation email.', 'mailchimp' );
450 $data['confirm_email_match2'] = esc_html__( 'Email confirmation must match the field above.', 'mailchimp' );
451 }
452
453 wp_localize_script(
454 'mailchimp_sf_admin',
455 'mailchimp_sf_admin_params',
456 $data
457 );
458 }
459
460 /**
461 * Add the create account page.
462 *
463 * @since x.x.x
464 */
465 public function add_create_account_page() {
466 add_submenu_page(
467 'admin.php',
468 esc_html__( 'Create Mailchimp Account', 'mailchimp' ),
469 esc_html__( 'Create Mailchimp Account', 'mailchimp' ),
470 'manage_options',
471 'mailchimp_sf_create_account',
472 array( $this, 'create_account_page' )
473 );
474 }
475
476 /**
477 * Create account page.
478 *
479 * @since x.x.x
480 *
481 * @return void
482 */
483 public function create_account_page() {
484 $countries = $this->get_countries();
485 $timezones = $this->get_timezones();
486 ?>
487 <div id="mailchimp-sf-settings-page">
488 <?php
489 include_once MCSF_DIR . 'includes/admin/templates/create-account-page.php';
490 ?>
491 </div>
492 <?php
493 }
494
495 /**
496 * Get a list of timezones.
497 *
498 * @since x.x.x
499 *
500 * @return array
501 */
502 private function get_timezones() {
503 return timezone_identifiers_list();
504 }
505
506 /**
507 * Get a list of countries.
508 *
509 * @since x.x.x
510 *
511 * @return array
512 */
513 public function get_countries() {
514 return array(
515 'AF' => __( 'Afghanistan', 'mailchimp' ),
516 'AX' => __( '�
517 land Islands', 'mailchimp' ),
518 'AL' => __( 'Albania', 'mailchimp' ),
519 'DZ' => __( 'Algeria', 'mailchimp' ),
520 'AS' => __( 'American Samoa', 'mailchimp' ),
521 'AD' => __( 'Andorra', 'mailchimp' ),
522 'AO' => __( 'Angola', 'mailchimp' ),
523 'AI' => __( 'Anguilla', 'mailchimp' ),
524 'AQ' => __( 'Antarctica', 'mailchimp' ),
525 'AG' => __( 'Antigua and Barbuda', 'mailchimp' ),
526 'AR' => __( 'Argentina', 'mailchimp' ),
527 'AM' => __( 'Armenia', 'mailchimp' ),
528 'AW' => __( 'Aruba', 'mailchimp' ),
529 'AU' => __( 'Australia', 'mailchimp' ),
530 'AT' => __( 'Austria', 'mailchimp' ),
531 'AZ' => __( 'Azerbaijan', 'mailchimp' ),
532 'BS' => __( 'Bahamas', 'mailchimp' ),
533 'BH' => __( 'Bahrain', 'mailchimp' ),
534 'BD' => __( 'Bangladesh', 'mailchimp' ),
535 'BB' => __( 'Barbados', 'mailchimp' ),
536 'BY' => __( 'Belarus', 'mailchimp' ),
537 'BE' => __( 'Belgium', 'mailchimp' ),
538 'PW' => __( 'Belau', 'mailchimp' ),
539 'BZ' => __( 'Belize', 'mailchimp' ),
540 'BJ' => __( 'Benin', 'mailchimp' ),
541 'BM' => __( 'Bermuda', 'mailchimp' ),
542 'BT' => __( 'Bhutan', 'mailchimp' ),
543 'BO' => __( 'Bolivia', 'mailchimp' ),
544 'BQ' => __( 'Bonaire, Saint Eustatius and Saba', 'mailchimp' ),
545 'BA' => __( 'Bosnia and Herzegovina', 'mailchimp' ),
546 'BW' => __( 'Botswana', 'mailchimp' ),
547 'BV' => __( 'Bouvet Island', 'mailchimp' ),
548 'BR' => __( 'Brazil', 'mailchimp' ),
549 'IO' => __( 'British Indian Ocean Territory', 'mailchimp' ),
550 'BN' => __( 'Brunei', 'mailchimp' ),
551 'BG' => __( 'Bulgaria', 'mailchimp' ),
552 'BF' => __( 'Burkina Faso', 'mailchimp' ),
553 'BI' => __( 'Burundi', 'mailchimp' ),
554 'KH' => __( 'Cambodia', 'mailchimp' ),
555 'CM' => __( 'Cameroon', 'mailchimp' ),
556 'CA' => __( 'Canada', 'mailchimp' ),
557 'CV' => __( 'Cape Verde', 'mailchimp' ),
558 'KY' => __( 'Cayman Islands', 'mailchimp' ),
559 'CF' => __( 'Central African Republic', 'mailchimp' ),
560 'TD' => __( 'Chad', 'mailchimp' ),
561 'CL' => __( 'Chile', 'mailchimp' ),
562 'CN' => __( 'China', 'mailchimp' ),
563 'CX' => __( 'Christmas Island', 'mailchimp' ),
564 'CC' => __( 'Cocos (Keeling) Islands', 'mailchimp' ),
565 'CO' => __( 'Colombia', 'mailchimp' ),
566 'KM' => __( 'Comoros', 'mailchimp' ),
567 'CG' => __( 'Congo (Brazzaville)', 'mailchimp' ),
568 'CD' => __( 'Congo (Kinshasa)', 'mailchimp' ),
569 'CK' => __( 'Cook Islands', 'mailchimp' ),
570 'CR' => __( 'Costa Rica', 'mailchimp' ),
571 'HR' => __( 'Croatia', 'mailchimp' ),
572 'CU' => __( 'Cuba', 'mailchimp' ),
573 'CW' => __( 'Cura&ccedil;ao', 'mailchimp' ),
574 'CY' => __( 'Cyprus', 'mailchimp' ),
575 'CZ' => __( 'Czech Republic', 'mailchimp' ),
576 'DK' => __( 'Denmark', 'mailchimp' ),
577 'DJ' => __( 'Djibouti', 'mailchimp' ),
578 'DM' => __( 'Dominica', 'mailchimp' ),
579 'DO' => __( 'Dominican Republic', 'mailchimp' ),
580 'EC' => __( 'Ecuador', 'mailchimp' ),
581 'EG' => __( 'Egypt', 'mailchimp' ),
582 'SV' => __( 'El Salvador', 'mailchimp' ),
583 'GQ' => __( 'Equatorial Guinea', 'mailchimp' ),
584 'ER' => __( 'Eritrea', 'mailchimp' ),
585 'EE' => __( 'Estonia', 'mailchimp' ),
586 'ET' => __( 'Ethiopia', 'mailchimp' ),
587 'FK' => __( 'Falkland Islands', 'mailchimp' ),
588 'FO' => __( 'Faroe Islands', 'mailchimp' ),
589 'FJ' => __( 'Fiji', 'mailchimp' ),
590 'FI' => __( 'Finland', 'mailchimp' ),
591 'FR' => __( 'France', 'mailchimp' ),
592 'GF' => __( 'French Guiana', 'mailchimp' ),
593 'PF' => __( 'French Polynesia', 'mailchimp' ),
594 'TF' => __( 'French Southern Territories', 'mailchimp' ),
595 'GA' => __( 'Gabon', 'mailchimp' ),
596 'GM' => __( 'Gambia', 'mailchimp' ),
597 'GE' => __( 'Georgia', 'mailchimp' ),
598 'DE' => __( 'Germany', 'mailchimp' ),
599 'GH' => __( 'Ghana', 'mailchimp' ),
600 'GI' => __( 'Gibraltar', 'mailchimp' ),
601 'GR' => __( 'Greece', 'mailchimp' ),
602 'GL' => __( 'Greenland', 'mailchimp' ),
603 'GD' => __( 'Grenada', 'mailchimp' ),
604 'GP' => __( 'Guadeloupe', 'mailchimp' ),
605 'GU' => __( 'Guam', 'mailchimp' ),
606 'GT' => __( 'Guatemala', 'mailchimp' ),
607 'GG' => __( 'Guernsey', 'mailchimp' ),
608 'GN' => __( 'Guinea', 'mailchimp' ),
609 'GW' => __( 'Guinea-Bissau', 'mailchimp' ),
610 'GY' => __( 'Guyana', 'mailchimp' ),
611 'HT' => __( 'Haiti', 'mailchimp' ),
612 'HM' => __( 'Heard Island and McDonald Islands', 'mailchimp' ),
613 'HN' => __( 'Honduras', 'mailchimp' ),
614 'HK' => __( 'Hong Kong', 'mailchimp' ),
615 'HU' => __( 'Hungary', 'mailchimp' ),
616 'IS' => __( 'Iceland', 'mailchimp' ),
617 'IN' => __( 'India', 'mailchimp' ),
618 'ID' => __( 'Indonesia', 'mailchimp' ),
619 'IR' => __( 'Iran', 'mailchimp' ),
620 'IQ' => __( 'Iraq', 'mailchimp' ),
621 'IE' => __( 'Ireland', 'mailchimp' ),
622 'IM' => __( 'Isle of Man', 'mailchimp' ),
623 'IL' => __( 'Israel', 'mailchimp' ),
624 'IT' => __( 'Italy', 'mailchimp' ),
625 'CI' => __( 'Ivory Coast', 'mailchimp' ),
626 'JM' => __( 'Jamaica', 'mailchimp' ),
627 'JP' => __( 'Japan', 'mailchimp' ),
628 'JE' => __( 'Jersey', 'mailchimp' ),
629 'JO' => __( 'Jordan', 'mailchimp' ),
630 'KZ' => __( 'Kazakhstan', 'mailchimp' ),
631 'KE' => __( 'Kenya', 'mailchimp' ),
632 'KI' => __( 'Kiribati', 'mailchimp' ),
633 'KW' => __( 'Kuwait', 'mailchimp' ),
634 'KG' => __( 'Kyrgyzstan', 'mailchimp' ),
635 'LA' => __( 'Laos', 'mailchimp' ),
636 'LV' => __( 'Latvia', 'mailchimp' ),
637 'LB' => __( 'Lebanon', 'mailchimp' ),
638 'LS' => __( 'Lesotho', 'mailchimp' ),
639 'LR' => __( 'Liberia', 'mailchimp' ),
640 'LY' => __( 'Libya', 'mailchimp' ),
641 'LI' => __( 'Liechtenstein', 'mailchimp' ),
642 'LT' => __( 'Lithuania', 'mailchimp' ),
643 'LU' => __( 'Luxembourg', 'mailchimp' ),
644 'MO' => __( 'Macao', 'mailchimp' ),
645 'MK' => __( 'North Macedonia', 'mailchimp' ),
646 'MG' => __( 'Madagascar', 'mailchimp' ),
647 'MW' => __( 'Malawi', 'mailchimp' ),
648 'MY' => __( 'Malaysia', 'mailchimp' ),
649 'MV' => __( 'Maldives', 'mailchimp' ),
650 'ML' => __( 'Mali', 'mailchimp' ),
651 'MT' => __( 'Malta', 'mailchimp' ),
652 'MH' => __( 'Marshall Islands', 'mailchimp' ),
653 'MQ' => __( 'Martinique', 'mailchimp' ),
654 'MR' => __( 'Mauritania', 'mailchimp' ),
655 'MU' => __( 'Mauritius', 'mailchimp' ),
656 'YT' => __( 'Mayotte', 'mailchimp' ),
657 'MX' => __( 'Mexico', 'mailchimp' ),
658 'FM' => __( 'Micronesia', 'mailchimp' ),
659 'MD' => __( 'Moldova', 'mailchimp' ),
660 'MC' => __( 'Monaco', 'mailchimp' ),
661 'MN' => __( 'Mongolia', 'mailchimp' ),
662 'ME' => __( 'Montenegro', 'mailchimp' ),
663 'MS' => __( 'Montserrat', 'mailchimp' ),
664 'MA' => __( 'Morocco', 'mailchimp' ),
665 'MZ' => __( 'Mozambique', 'mailchimp' ),
666 'MM' => __( 'Myanmar', 'mailchimp' ),
667 'NA' => __( 'Namibia', 'mailchimp' ),
668 'NR' => __( 'Nauru', 'mailchimp' ),
669 'NP' => __( 'Nepal', 'mailchimp' ),
670 'NL' => __( 'Netherlands', 'mailchimp' ),
671 'NC' => __( 'New Caledonia', 'mailchimp' ),
672 'NZ' => __( 'New Zealand', 'mailchimp' ),
673 'NI' => __( 'Nicaragua', 'mailchimp' ),
674 'NE' => __( 'Niger', 'mailchimp' ),
675 'NG' => __( 'Nigeria', 'mailchimp' ),
676 'NU' => __( 'Niue', 'mailchimp' ),
677 'NF' => __( 'Norfolk Island', 'mailchimp' ),
678 'MP' => __( 'Northern Mariana Islands', 'mailchimp' ),
679 'KP' => __( 'North Korea', 'mailchimp' ),
680 'NO' => __( 'Norway', 'mailchimp' ),
681 'OM' => __( 'Oman', 'mailchimp' ),
682 'PK' => __( 'Pakistan', 'mailchimp' ),
683 'PS' => __( 'Palestinian Territory', 'mailchimp' ),
684 'PA' => __( 'Panama', 'mailchimp' ),
685 'PG' => __( 'Papua New Guinea', 'mailchimp' ),
686 'PY' => __( 'Paraguay', 'mailchimp' ),
687 'PE' => __( 'Peru', 'mailchimp' ),
688 'PH' => __( 'Philippines', 'mailchimp' ),
689 'PN' => __( 'Pitcairn', 'mailchimp' ),
690 'PL' => __( 'Poland', 'mailchimp' ),
691 'PT' => __( 'Portugal', 'mailchimp' ),
692 'PR' => __( 'Puerto Rico', 'mailchimp' ),
693 'QA' => __( 'Qatar', 'mailchimp' ),
694 'RE' => __( 'Reunion', 'mailchimp' ),
695 'RO' => __( 'Romania', 'mailchimp' ),
696 'RU' => __( 'Russia', 'mailchimp' ),
697 'RW' => __( 'Rwanda', 'mailchimp' ),
698 'BL' => __( 'Saint Barth&eacute;lemy', 'mailchimp' ),
699 'SH' => __( 'Saint Helena', 'mailchimp' ),
700 'KN' => __( 'Saint Kitts and Nevis', 'mailchimp' ),
701 'LC' => __( 'Saint Lucia', 'mailchimp' ),
702 'MF' => __( 'Saint Martin (French part)', 'mailchimp' ),
703 'SX' => __( 'Saint Martin (Dutch part)', 'mailchimp' ),
704 'PM' => __( 'Saint Pierre and Miquelon', 'mailchimp' ),
705 'VC' => __( 'Saint Vincent and the Grenadines', 'mailchimp' ),
706 'SM' => __( 'San Marino', 'mailchimp' ),
707 'ST' => __( 'S&atilde;o Tom&eacute; and Pr&iacute;ncipe', 'mailchimp' ),
708 'SA' => __( 'Saudi Arabia', 'mailchimp' ),
709 'SN' => __( 'Senegal', 'mailchimp' ),
710 'RS' => __( 'Serbia', 'mailchimp' ),
711 'SC' => __( 'Seychelles', 'mailchimp' ),
712 'SL' => __( 'Sierra Leone', 'mailchimp' ),
713 'SG' => __( 'Singapore', 'mailchimp' ),
714 'SK' => __( 'Slovakia', 'mailchimp' ),
715 'SI' => __( 'Slovenia', 'mailchimp' ),
716 'SB' => __( 'Solomon Islands', 'mailchimp' ),
717 'SO' => __( 'Somalia', 'mailchimp' ),
718 'ZA' => __( 'South Africa', 'mailchimp' ),
719 'GS' => __( 'South Georgia/Sandwich Islands', 'mailchimp' ),
720 'KR' => __( 'South Korea', 'mailchimp' ),
721 'SS' => __( 'South Sudan', 'mailchimp' ),
722 'ES' => __( 'Spain', 'mailchimp' ),
723 'LK' => __( 'Sri Lanka', 'mailchimp' ),
724 'SD' => __( 'Sudan', 'mailchimp' ),
725 'SR' => __( 'Suriname', 'mailchimp' ),
726 'SJ' => __( 'Svalbard and Jan Mayen', 'mailchimp' ),
727 'SZ' => __( 'Eswatini', 'mailchimp' ),
728 'SE' => __( 'Sweden', 'mailchimp' ),
729 'CH' => __( 'Switzerland', 'mailchimp' ),
730 'SY' => __( 'Syria', 'mailchimp' ),
731 'TW' => __( 'Taiwan', 'mailchimp' ),
732 'TJ' => __( 'Tajikistan', 'mailchimp' ),
733 'TZ' => __( 'Tanzania', 'mailchimp' ),
734 'TH' => __( 'Thailand', 'mailchimp' ),
735 'TL' => __( 'Timor-Leste', 'mailchimp' ),
736 'TG' => __( 'Togo', 'mailchimp' ),
737 'TK' => __( 'Tokelau', 'mailchimp' ),
738 'TO' => __( 'Tonga', 'mailchimp' ),
739 'TT' => __( 'Trinidad and Tobago', 'mailchimp' ),
740 'TN' => __( 'Tunisia', 'mailchimp' ),
741 'TR' => __( 'Turkey', 'mailchimp' ),
742 'TM' => __( 'Turkmenistan', 'mailchimp' ),
743 'TC' => __( 'Turks and Caicos Islands', 'mailchimp' ),
744 'TV' => __( 'Tuvalu', 'mailchimp' ),
745 'UG' => __( 'Uganda', 'mailchimp' ),
746 'UA' => __( 'Ukraine', 'mailchimp' ),
747 'AE' => __( 'United Arab Emirates', 'mailchimp' ),
748 'GB' => __( 'United Kingdom (UK)', 'mailchimp' ),
749 'US' => __( 'United States (US)', 'mailchimp' ),
750 'UM' => __( 'United States (US) Minor Outlying Islands', 'mailchimp' ),
751 'UY' => __( 'Uruguay', 'mailchimp' ),
752 'UZ' => __( 'Uzbekistan', 'mailchimp' ),
753 'VU' => __( 'Vanuatu', 'mailchimp' ),
754 'VA' => __( 'Vatican', 'mailchimp' ),
755 'VE' => __( 'Venezuela', 'mailchimp' ),
756 'VN' => __( 'Vietnam', 'mailchimp' ),
757 'VG' => __( 'Virgin Islands (British)', 'mailchimp' ),
758 'VI' => __( 'Virgin Islands (US)', 'mailchimp' ),
759 'WF' => __( 'Wallis and Futuna', 'mailchimp' ),
760 'EH' => __( 'Western Sahara', 'mailchimp' ),
761 'WS' => __( 'Samoa', 'mailchimp' ),
762 'YE' => __( 'Yemen', 'mailchimp' ),
763 'ZM' => __( 'Zambia', 'mailchimp' ),
764 'ZW' => __( 'Zimbabwe', 'mailchimp' ),
765 );
766 }
767
768 /**
769 * Display the Mailchimp footer text on the Mailchimp admin pages.
770 *
771 * @since x.x.x
772 *
773 * @param string $text The current footer text.
774 * @return string The modified footer text.
775 */
776 public function admin_footer_text( $text ) {
777 $current_screen = get_current_screen();
778 $current_screen_id = $current_screen ? $current_screen->id : '';
779 if ( ! in_array( $current_screen_id, array( 'toplevel_page_mailchimp_sf_options', 'admin_page_mailchimp_sf_create_account' ), true ) ) {
780 return $text;
781 }
782
783 return wp_kses(
784 sprintf(
785 /* translators: %d - Current year, %s - Mailchimp legal links */
786 __( '©%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' ),
787 gmdate( 'Y' ),
788 esc_url( 'https://mailchimp.com/legal/cookies/#optanon-toggle-display/' ),
789 esc_url( 'https://www.intuit.com/privacy/statement/' ),
790 esc_url( 'https://mailchimp.com/legal/terms' )
791 ),
792 array(
793 'a' => array(
794 'href' => array(),
795 'target' => array(),
796 'rel' => array(),
797 ),
798 )
799 );
800 }
801 }
802