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

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