PluginProbe
Mailchimp List Subscribe Form / trunk
Mailchimp List Subscribe Form vtrunk
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
← All changes | mailchimp_widget.php +555 -553 1.4trunk View file →
@@ -1,375 +1,379 @@
1 1 <?php
2 2 /**
3 - * Displays a MailChimp Signup Form
4 - **/
5 -function mailchimpSF_signup_form($args = array()) {
6 - extract($args);
3 + * Mailchimp widget
4 + *
5 + * @package Mailchimp
6 + */
7 7
8 - $mv = get_option('mc_merge_vars');
9 - $igs = get_option('mc_interest_groups');
10 -
8 +/**
9 + * Displays a Mailchimp Signup Form
10 + *
11 + * @param array $args Args
12 + * @return void
13 + */
14 +function mailchimp_sf_signup_form( $args = array() ) {
15 + // Check if we should display the form.
16 + if ( ! mailchimp_sf_should_display_form() ) {
17 + return;
18 + }
19 +
20 + $before_title = isset( $args['before_title'] ) ? $args['before_title'] : '';
21 + $after_title = isset( $args['after_title'] ) ? $args['after_title'] : '';
22 + $before_widget = isset( $args['before_widget'] ) ? $args['before_widget'] : '';
23 + $after_widget = isset( $args['after_widget'] ) ? $args['after_widget'] : '';
24 + $is_preview = isset( $args['is_preview'] ) ? (bool) $args['is_preview'] : false;
25 + $preview_data = isset( $args['preview_data'] ) ? $args['preview_data'] : array();
26 +
27 + $mv = get_option( 'mc_merge_vars' );
28 + $igs = get_option( 'mc_interest_groups' );
29 +
11 30 // See if we have valid Merge Vars
12 - if (!is_array($mv) && MAILCHIMP_DEV_MODE == false) {
13 - echo $before_widget;
31 + if ( ! is_array( $mv ) ) {
32 + if ( ! empty( $before_widget ) ) {
33 + echo wp_kses_post( $before_widget );
34 + } else {
35 + echo '<div class="mc_container">';
36 + }
14 37 ?>
15 38 <div class="mc_error_msg">
16 - <?php esc_html_e('There was a problem loading your MailChimp details. Please re-run the setup process under Settings->MailChimp Setup', 'mailchimp_i18n'); ?>
39 + <?php
40 + echo wp_kses(
41 + __(
42 + 'Sorry, there was a problem loading your Mailchimp details. Please navigate to <strong>Settings</strong> and click <strong>Mailchimp Setup</strong> to try again.',
43 + 'mailchimp'
44 + ),
45 + [
46 + 'strong' => [],
47 + ]
48 + );
49 + ?>
17 50 </div>
18 51 <?php
19 - echo $after_widget;
52 + if ( ! empty( $after_widget ) ) {
53 + echo wp_kses_post( $after_widget );
54 + }
55 +
56 + if ( empty( $before_widget ) ) {
57 + echo '</div>';
58 + }
59 +
20 60 return;
21 61 }
22 62
23 - if (!is_array($mv) && MAILCHIMP_DEV_MODE == true) {
24 - $mv = mailchimp_get_kitchen_sink_fields();
25 - $igs = mailchimp_get_kitchen_sink_groups();
63 + if ( ! empty( $before_widget ) ) {
64 + echo wp_kses_post( $before_widget );
65 + } else {
66 + echo '<div class="mc_container">';
26 67 }
27 -
28 - if (!empty($before_widget)) {
29 - echo $before_widget;
30 - }
31 68
32 - $header = get_option('mc_header_content');
33 - if (!$header && MAILCHIMP_DEV_MODE == true) {
34 - $header = apply_filters( 'mailchimp_dev_mode_header_text', 'MailChimp Developer' );
69 + $header = get_option( 'mc_header_content' );
70 + if ( $is_preview && ! empty( $preview_data ) ) {
71 + $header = $preview_data['header'] ?? $header;
35 72 }
36 73
37 74 // See if we have custom header content
38 - if (!empty($header)) {
75 + if ( ! empty( $header ) ) {
39 76 // See if we need to wrap the header content in our own div
40 - if (strlen($header) == strlen(strip_tags($header))){
41 - echo !empty($before_title) ? $before_title : '<div class="mc_custom_border_hdr">';
42 - echo $header; // don't escape $header b/c it may have HTML allowed
43 - echo !empty($after_title) ? $after_title : '</div><!-- /mc_custom_border_hdr -->';
77 + if ( strlen( $header ) === strlen( wp_strip_all_tags( $header ) ) ) {
78 + echo ! empty( $before_title ) ? wp_kses_post( $before_title ) : '<div class="mc_custom_border_hdr">';
79 + echo wp_kses_post( $header );
80 + echo ! empty( $after_title ) ? wp_kses_post( $after_title ) : '</div><!-- /mc_custom_border_hdr -->';
81 + } else {
82 + echo wp_kses_post( $header );
44 83 }
45 - else {
46 - echo $header; // don't escape $header b/c it may have HTML allowed
47 - }
48 84 }
49 -
50 - $sub_heading = trim(get_option('mc_subheader_content'));
51 - if (!$sub_heading && MAILCHIMP_DEV_MODE == true) {
52 - $sub_heading = apply_filters( 'mailchimp_dev_mode_subheading_text', 'This is the subheading text.' );
85 +
86 + $sub_heading = trim( get_option( 'mc_subheader_content' ) );
87 + $list_id = get_option( 'mc_list_id' );
88 + $form_id = wp_unique_id( $list_id . '_' );
89 + if ( $is_preview && ! empty( $preview_data ) ) {
90 + $sub_heading = $preview_data['sub_heading'] ?? $sub_heading;
53 91 }
54 -
55 92 ?>
56 93
57 -<style>
58 - .widget_mailchimpsf_widget .widget-title {
59 - line-height: 1.4em;
60 - margin-bottom: 0.75em;
61 - }
62 - #mc_subheader {
63 - line-height: 1.25em;
64 - margin-bottom: 18px;
65 - }
66 - .mc_merge_var {
67 - margin-bottom: 1.0em;
68 - }
69 - .mc_var_label,
70 - .mc_interest_label {
71 - display: block;
72 - margin-bottom: 0.5em;
73 - }
74 - .mc_input {
75 - -moz-box-sizing: border-box;
76 - -webkit-box-sizing: border-box;
77 - box-sizing: border-box;
78 - width: 100%;
79 - }
80 - .mc_input.mc_phone {
81 - width: auto;
82 - }
83 - select.mc_select {
84 - margin-top: 0.5em;
85 - width: 100%;
86 - }
87 - .mc_address_label {
88 - margin-top: 1.0em;
89 - margin-bottom: 0.5em;
90 - display: block;
91 - }
92 - .mc_address_label ~ select {
93 - width: 100%;
94 - }
95 - .mc_list li {
96 - list-style: none;
97 - background: none !important;
98 - }
99 - .mc_interests_header {
100 - margin-top: 1.0em;
101 - margin-bottom: 0.5em;
102 - }
103 - .mc_interest label,
104 - .mc_interest input {
105 - margin-bottom: 0.4em;
106 - }
107 - #mc_signup_submit {
108 - margin-top: 1.5em;
109 - width: 80%;
110 - }
111 - #mc_unsub_link a {
112 - font-size: 0.75em;
113 - }
114 - #mc_unsub_link {
115 - margin-top: 1.0em;
116 - }
117 - .mc_header_address,
118 - .mc_email_format {
119 - display: block;
120 - font-weight: bold;
121 - margin-top: 1.0em;
122 - margin-bottom: 0.5em;
123 - }
124 - .mc_email_options {
125 - margin-top: 0.5em;
126 - }
127 - .mc_email_type {
128 - padding-left: 4px;
129 - }
130 -</style>
94 +<div id="mc_signup_<?php echo esc_attr( $form_id ); ?>">
95 + <form method="post" action="#mc_signup_<?php echo esc_attr( $form_id ); ?>" id="mc_signup_form_<?php echo esc_attr( $form_id ); ?>" class="mc_signup_form" data-list-id="<?php echo esc_attr( $list_id ); ?>">
96 + <input type="hidden" class="mc_submit_type" name="mc_submit_type" value="html" />
97 + <input type="hidden" name="mcsf_action" value="mc_submit_signup_form" />
98 + <?php wp_nonce_field( 'mc_submit_signup_form', '_mc_submit_signup_form_nonce', false ); ?>
131 99
132 -<div id="mc_signup">
133 - <form method="post" action="#mc_signup" id="mc_signup_form">
134 - <input type="hidden" id="mc_submit_type" name="mc_submit_type" value="html" />
135 - <input type="hidden" name="mcsf_action" value="mc_submit_signup_form" />
136 - <?php wp_nonce_field('mc_submit_signup_form', '_mc_submit_signup_form_nonce', false); ?>
137 -
138 - <?php
139 - if ($sub_heading) {
100 + <?php
101 + if ( $sub_heading ) {
140 102 ?>
141 - <div id="mc_subheader">
142 - <?php echo $sub_heading; ?>
103 + <div class="mc_subheader">
104 + <?php echo wp_kses_post( $sub_heading ); ?>
143 105 </div><!-- /mc_subheader -->
144 106 <?php
145 - }
107 + }
146 108 ?>
147 -
109 +
148 110 <div class="mc_form_inside">
149 -
150 - <div class="updated" id="mc_message">
151 - <?php echo mailchimpSF_global_msg(); ?>
152 - </div><!-- /mc_message -->
153 111
112 + <div class="mc_message_wrapper">
113 + <?php echo wp_kses_post( mailchimp_sf_frontend_msg() ); ?>
114 + </div><!-- /mc_message_wrapper -->
115 +
154 116 <?php
155 - //don't show the "required" stuff if there's only 1 field to display.
117 + // don't show the "required" stuff if there's only 1 field to display.
156 118 $num_fields = 0;
157 - foreach((array)$mv as $var) {
158 - $opt = 'mc_mv_'.$var['tag'];
159 - if ($var['req'] || get_option($opt) == 'on') {
160 - $num_fields++;
119 + foreach ( (array) $mv as $mv_var ) {
120 + $opt = 'mc_mv_' . $mv_var['tag'];
121 + if ( $is_preview && ! empty( $preview_data ) ) {
122 + if ( $mv_var['required'] || ( isset( $preview_data['fields'][ $mv_var['tag'] ] ) && $preview_data['fields'][ $mv_var['tag'] ] ) ) {
123 + ++$num_fields;
124 + }
125 + } elseif ( $mv_var['required'] || get_option( $opt ) === 'on' ) {
126 + ++$num_fields;
161 127 }
162 128 }
163 129
164 - if (is_array($mv)) {
130 + if ( is_array( $mv ) ) {
165 131 // head on back to the beginning of the array
166 - reset($mv);
132 + reset( $mv );
167 133 }
168 -
134 +
169 135 // Loop over our vars, and output the ones that are set to display
170 - foreach($mv as $var) {
171 - if (!$var['public']) {
172 - echo '<div style="display:none;">'.mailchimp_form_field($var, $num_fields).'</div>';
136 + foreach ( $mv as $mv_var ) {
137 + $opt = 'mc_mv_' . $mv_var['tag'];
138 + $should_display = 'on' === get_option( $opt );
139 + if ( $is_preview && ! empty( $preview_data ) ) {
140 + $should_display = $preview_data['fields'][ $mv_var['tag'] ] ?? $should_display;
173 141 }
174 - else {
175 - echo mailchimp_form_field($var, $num_fields);
176 - }
142 +
143 + echo mailchimp_form_field( $mv_var, $num_fields, $should_display ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Ignoring because form field is escaped in function
177 144 }
178 -
179 -
145 +
180 146 // Show an explanation of the * if there's more than one field
181 - if ($num_fields > 1) {
147 + if ( $num_fields > 1 ) {
182 148 ?>
183 - <div id="mc-indicates-required">
184 - * = <?php esc_html_e('required field', 'mailchimp_i18n'); ?>
149 + <div class="mc-indicates-required">
150 + * = <?php esc_html_e( 'required field', 'mailchimp' ); ?>
185 151 </div><!-- /mc-indicates-required -->
186 152 <?php
187 153 }
188 -
189 -
154 +
190 155 // Show our Interest groups fields if we have them, and they're set to on
191 - if (is_array($igs) && !empty($igs)) {
192 - foreach ($igs as $ig) {
193 - if (is_array($ig) && isset($ig['id'])) {
194 - if (($igs && get_option('mc_show_interest_groups_'.$ig['id']) == 'on') || MAILCHIMP_DEV_MODE == true) {
195 - if ($ig['form_field'] != 'hidden') {
196 - ?>
156 + if ( is_array( $igs ) && ! empty( $igs ) ) {
157 + foreach ( $igs as $ig ) {
158 + if ( is_array( $ig ) && isset( $ig['id'] ) ) {
159 + $should_display = 'on' === get_option( 'mc_show_interest_groups_' . $ig['id'] );
160 + if ( $is_preview && ! empty( $preview_data ) ) {
161 + $should_display = $preview_data['groups'][ $ig['id'] ] ?? $should_display;
162 + }
163 + if ( ( $igs && $should_display ) ) {
164 + if ( 'hidden' !== $ig['type'] ) {
165 + ?>
197 166 <div class="mc_interests_header">
198 - <?php echo esc_html($ig['name']); ?>
167 + <?php echo esc_html( $ig['title'] ); ?>
199 168 </div><!-- /mc_interests_header -->
200 169 <div class="mc_interest">
201 - <?php
170 + <?php
171 + } else {
172 + ?>
173 + <div class="mc_interest" style="display: none;">
174 + <?php
202 175 }
203 - else {
204 176 ?>
205 - <div class="mc_interest" style="display: none;">
206 - <?php
207 - }
208 - ?>
209 177
210 - <?php
211 - mailchimp_interest_group_field($ig);
212 - ?>
178 + <?php
179 + mailchimp_interest_group_field( $ig );
180 + ?>
213 181 </div><!-- /mc_interest -->
214 -
215 - <?php
182 +
183 + <?php
216 184 }
217 185 }
218 186 }
219 187 }
220 188
221 - if (get_option('mc_email_type_option') || MAILCHIMP_DEV_MODE == true) {
222 - ?>
189 + if ( get_option( 'mc_email_type_option' ) ) {
190 + ?>
223 191 <div class="mergeRow">
224 - <label class="mc_email_format"><?php _e('Preferred Format', 'mailchimp_i18n'); ?></label>
225 - <div class="field-group groups mc_email_options">
226 - <ul class="mc_list">
227 - <li><input type="radio" name="email_type" id="email_type_html" value="html" checked="checked"><label for="email_type_html" class="mc_email_type"><?php _e('HTML', 'mailchimp_i18n'); ?></label></li>
228 - <li><input type="radio" name="email_type" id="email_type_text" value="text"><label for="email_type_text" class="mc_email_type"><?php _e('Text', 'mailchimp_i18n'); ?></label></li>
229 - </ul>
192 + <label class="mc_email_format"><?php esc_html_e( 'Preferred Format', 'mailchimp' ); ?></label>
193 + <div class="field-group groups mc_email_options">
194 + <ul class="mc_list">
195 + <li><input type="radio" name="email_type" id="email_type_html_<?php echo esc_attr( $form_id ); ?>" value="html" checked="checked"><label for="email_type_html_<?php echo esc_attr( $form_id ); ?>" class="mc_email_type"><?php esc_html_e( 'HTML', 'mailchimp' ); ?></label></li>
196 + <li><input type="radio" name="email_type" id="email_type_text_<?php echo esc_attr( $form_id ); ?>" value="text"><label for="email_type_text_<?php echo esc_attr( $form_id ); ?>" class="mc_email_type"><?php esc_html_e( 'Text', 'mailchimp' ); ?></label></li>
197 + </ul>
230 198 </div>
231 - </div>
199 + </div>
232 200
233 - <?php
201 + <?php
234 202 }
235 203
236 - $submit_text = get_option('mc_submit_text');
237 - if (!$submit_text && MAILCHIMP_DEV_MODE == true) {
238 - $submit_text = apply_filters( 'mailchimp_dev_mode_submit_text', 'Subscribe' );
204 + // Add a honeypot field.
205 + mailchimp_sf_honeypot_field();
206 +
207 + $submit_text = get_option( 'mc_submit_text' );
208 +
209 + // Preview.
210 + if ( $is_preview && ! empty( $preview_data ) ) {
211 + $submit_text = $preview_data['submit_text'] ?? $submit_text;
239 212 }
240 -
241 213 ?>
242 214
243 215 <div class="mc_signup_submit">
244 - <input type="submit" name="mc_signup_submit" id="mc_signup_submit" value="<?php echo esc_attr($submit_text); ?>" class="button" />
216 + <input type="submit" name="mc_signup_submit" class="mc_signup_submit_button" id="mc_signup_submit_<?php echo esc_attr( $form_id ); ?>" value="<?php echo esc_attr( $submit_text ); ?>" class="button" />
245 217 </div><!-- /mc_signup_submit -->
246 -
247 -
218 +
248 219 <?php
249 - $user = get_option('mc_sopresto_user');
250 - if ($user && get_option('mc_use_unsub_link') == 'on') {
251 - $dc = get_option('mc_sopresto_dc', 'us1');
252 - $host = 'http://'.$dc.'.list-manage.com';
220 + $user = get_option( 'mc_user' );
221 + $display_unsub_link = 'on' === get_option( 'mc_use_unsub_link' );
222 + if ( $is_preview && ! empty( $preview_data ) ) {
223 + $display_unsub_link = $preview_data['display_unsub_link'] ?? $display_unsub_link;
224 + }
225 +
226 + if ( $user && $display_unsub_link ) {
227 + $api = mailchimp_sf_get_api();
228 + $host = 'http://' . $api->datacenter . '.list-manage.com';
253 229 ?>
254 - <div id="mc_unsub_link" align="center">
255 - <a href="<?php echo esc_url($host.'/unsubscribe/?u='.$user['user_id'].'&amp;id='.get_option('mc_list_id')); ?>" target="_blank"><?php esc_html_e('unsubscribe from list', 'mailchimp_i18n'); ?></a>
230 + <div class="mc_unsub_link" align="center">
231 + <a href="<?php echo esc_url( $host . '/unsubscribe/?u=' . $user['account_id'] . '&amp;id=' . get_option( 'mc_list_id' ) ); ?>" target="_blank"><?php esc_html_e( 'unsubscribe from list', 'mailchimp' ); ?></a>
256 232 </div><!-- /mc_unsub_link -->
257 233 <?php
258 234 }
259 - if ($user && get_option('mc_rewards') == 'on') {
260 - ?>
261 - <br/>
262 - <div id="mc_display_rewards" align="center">
263 - <?php esc_html_e('powered by', 'mailchimp_i18n'); ?> <a href="<?php echo esc_url('http://www.mailchimp.com/affiliates/?aid='.$user['user_id'].'&amp;afl=1'); ?>">MailChimp</a>!
264 - </div><!-- /mc_display_rewards -->
265 - <?php
266 - }
267 235 ?>
268 -
236 +
269 237 </div><!-- /mc_form_inside -->
270 238 </form><!-- /mc_signup_form -->
271 239 </div><!-- /mc_signup_container -->
272 240 <?php
273 - if (!empty($before_widget)) {
274 - echo $after_widget;
241 + if ( ! empty( $after_widget ) ) {
242 + echo wp_kses_post( $after_widget );
275 243 }
244 +
245 + if ( empty( $before_widget ) ) {
246 + echo '</div>';
247 + }
276 248 }
277 249
278 250 /**
251 + * Add a hidden honeypot field
252 + *
253 + * @return void
254 + */
255 +function mailchimp_sf_honeypot_field() {
256 + ?>
257 + <div style="display: none; !important">
258 + <label for="mailchimp_sf_alt_email"><?php esc_html_e( 'Alternative Email:', 'mailchimp' ); ?></label>
259 + <input type="text" name="mailchimp_sf_alt_email" autocomplete="off"/>
260 + </div>
261 + <input type="hidden" class="mailchimp_sf_no_js" name="mailchimp_sf_no_js" value="1" />
262 + <?php
263 +}
264 +
265 +/**
279 266 * Generate and display markup for Interest Groups
267 + *
280 268 * @param array $ig Set of Interest Groups to generate markup for
281 269 * @return void
282 270 */
283 -function mailchimp_interest_group_field($ig) {
284 - if (!is_array($ig)) {
271 +function mailchimp_interest_group_field( $ig ) {
272 + if ( ! is_array( $ig ) ) {
285 273 return;
286 274 }
287 - $html = '';
288 - $set_name = 'group['.$ig['id'].']';
289 - switch ($ig['form_field']) {
290 - case 'checkbox':
275 + $html = '';
276 + $set_name = 'group[' . $ig['id'] . ']';
277 + switch ( $ig['type'] ) {
291 278 case 'checkboxes':
292 279 $i = 1;
293 - foreach($ig['groups'] as $interest){
294 - $interest = $interest['name'];
295 - $html .= '
296 - <input type="checkbox" name="'.esc_attr($set_name.'['.$i.']').'" id="'.esc_attr('mc_interest_'.$ig['id'].'_'.$interest).'" class="mc_interest" value="'.esc_attr($interest).'" />
297 - <label for="'. esc_attr('mc_interest_'.$ig['id'].'_'.$interest).'" class="mc_interest_label">'.esc_html($interest).'</label>
280 + foreach ( $ig['groups'] as $interest ) {
281 + $interest_name = $interest['name'];
282 + $interest_id = $interest['id'];
283 + $unique_id = wp_unique_id( 'mc_interest_' . $ig['id'] . '_' . $interest_id . '_' );
284 + $html .= '
285 +
286 + <input type="checkbox" name="' . esc_attr( $set_name . '[' . $interest_id . ']' ) . '" id="' . esc_attr( $unique_id ) . '" class="mc_interest" value="' . esc_attr( $interest_name ) . '" />
287 + <label for="' . esc_attr( $unique_id ) . '" class="mc_interest_label">' . esc_html( $interest_name ) . '</label>
298 288 <br/>';
299 - $i++;
289 + ++$i;
300 290 }
301 291 break;
302 292 case 'radio':
303 - foreach($ig['groups'] as $interest){
304 - $interest = $interest['name'];
305 - $html .= '
306 - <input type="radio" name="'.esc_attr($set_name).'" id="'.esc_attr('mc_interest_'.$ig['id'].'_'.$interest).'" class="mc_interest" value="'.esc_attr($interest).'"/>
307 - <label for="'.esc_attr('mc_interest_'.$ig['id'].'_'.$interest).'" class="mc_interest_label">'.esc_html($interest).'</label>
293 + foreach ( $ig['groups'] as $interest ) {
294 + $interest_name = $interest['name'];
295 + $interest_id = $interest['id'];
296 + $unique_id = wp_unique_id( 'mc_interest_' . $ig['id'] . '_' . $interest_id . '_' );
297 + $html .= '
298 + <input type="radio" name="' . esc_attr( $set_name ) . '" id="' . esc_attr( $unique_id ) . '" class="mc_interest" value="' . esc_attr( $interest_id ) . '"/>
299 + <label for="' . esc_attr( $unique_id ) . '" class="mc_interest_label">' . esc_html( $interest_name ) . '</label>
308 300 <br/>';
309 301 }
310 302 break;
311 - case 'select':
312 303 case 'dropdown':
313 304 $html .= '
314 - <select name="'.esc_attr($set_name).'">
305 + <select name="' . esc_attr( $set_name ) . '">
315 306 <option value=""></option>';
316 - foreach($ig['groups'] as $interest){
317 - $interest = $interest['name'];
318 - $html .= '
319 - <option value="'.esc_attr($interest).'">'.esc_html($interest).'</option>';
320 - }
307 + foreach ( $ig['groups'] as $interest ) {
308 + $interest_name = $interest['name'];
309 + $interest_id = $interest['id'];
310 + $html .= '
311 + <option value="' . esc_attr( $interest_id ) . '">' . esc_html( $interest_name ) . '</option>';
312 + }
321 313 $html .= '
322 314 </select>';
323 315 break;
324 - case 'hidden':
316 + case 'hidden':
325 317 $i = 1;
326 - foreach($ig['groups'] as $interest) {
327 - $interest = $interest['name'];
328 - $html .= '
329 - <input type="checkbox" name="'.esc_attr($set_name.'['.$i.']').'" id="'.esc_attr('mc_interest_'.$ig['id'].'_'.$interest).'" class="mc_interest" value="'.esc_attr($interest).'" />
330 - <label for="'. esc_attr('mc_interest_'.$ig['id'].'_'.$interest).'" class="mc_interest_label">'.esc_html($interest).'</label>';
331 - $i++;
318 + foreach ( $ig['groups'] as $interest ) {
319 + $interest_name = $interest['name'];
320 + $interest_id = $interest['id'];
321 + $unique_id = wp_unique_id( 'mc_interest_' . $ig['id'] . '_' . $interest_id . '_' );
322 + $html .= '
323 + <input type="checkbox" name="' . esc_attr( $set_name . '[' . $i . ']' ) . '" id="' . esc_attr( $unique_id ) . '" class="mc_interest" value="' . esc_attr( $interest_name ) . '" />
324 + <label for="' . esc_attr( $unique_id ) . '" class="mc_interest_label">' . esc_html( $interest_name ) . '</label>';
325 + ++$i;
332 326 }
333 327 break;
334 328 }
335 - echo $html;
329 + echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Ignoring because html is previously escaped
336 330 }
337 331
338 332 /**
339 333 * Generate and display markup for form fields
340 - * @param array $var Array containing informaoin about the field
341 - * @param int $num_fields The number of fields total we'll be generating markup for. Used in calculating required text logic
342 - * @return void
334 + *
335 + * @param array $data Array containing informaoin about the field.
336 + * @param int $num_fields The number of fields total we'll be generating markup for. Used in calculating required text logic.
337 + * @param bool $should_display Whether or not the field should be displayed.
338 + * @param string $label The label for the field.
339 + * @return string
343 340 */
344 -function mailchimp_form_field($var, $num_fields) {
345 - $opt = 'mc_mv_'.$var['tag'];
346 - $html = '';
341 +function mailchimp_form_field( $data, $num_fields, $should_display = null, $label = '' ) {
342 + $html = '';
343 + $opt = 'mc_mv_' . $data['tag'];
344 + $opt_id = wp_unique_id( $opt . '_' );
345 + if ( is_null( $should_display ) ) {
346 + $should_display = 'on' === get_option( $opt );
347 + }
348 +
349 + $label = ( ! empty( $label ) ) ? $label : $data['name'];
350 +
347 351 // See if that var is set as required, or turned on (for display)
348 - if ($var['req'] || get_option($opt) == 'on') {
349 - $label = '<label for="'.esc_attr($opt).'" class="mc_var_label mc_header mc_header_'.esc_attr($var['field_type']).'">'.esc_html($var['name']);
350 - if ($var['req'] && $num_fields > 1) {
352 + if ( $data['required'] || $should_display ) {
353 + $label = '<label for="' . esc_attr( $opt_id ) . '" class="mc_var_label mc_header mc_header_' . esc_attr( $data['type'] ) . '">' . wp_kses_post( $label );
354 + if ( $data['required'] && $num_fields > 1 ) {
351 355 $label .= '<span class="mc_required">*</span>';
352 356 }
353 357 $label .= '</label>';
354 -
358 +
355 359 $html .= '
356 360 <div class="mc_merge_var">
357 - '.$label;
358 - switch ($var['field_type']) {
359 - case 'date':
361 + ' . $label;
362 + switch ( $data['type'] ) {
363 + case 'date':
360 364 $html .= '
361 - <input type="text" size="18" placeholder="'.esc_attr($var['default']).'" data-format="'.esc_attr($var['dateformat']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="date-pick mc_input"/>';
365 + <input type="text" size="18" placeholder="' . esc_attr( $data['default_value'] ) . '" data-format="' . esc_attr( $data['options']['date_format'] ) . '" name="' . esc_attr( $opt ) . '" id="' . esc_attr( $opt_id ) . '" class="date-pick mc_input"/>';
362 366 break;
363 367 case 'radio':
364 - if (is_array($var['choices'])) {
368 + if ( is_array( $data['options']['choices'] ) ) {
365 369 $html .= '
366 370 <ul class="mc_list">';
367 - foreach ($var['choices'] as $key => $value) {
371 + foreach ( $data['options']['choices'] as $key => $value ) {
368 372 $html .= '
369 373 <li>
370 - <input type="radio" id="'.esc_attr($opt.'_'.$key).'" name="'.esc_attr($opt).'" class="mc_radio" value="'.$value.'"'.checked($var['default'], $value, false).' />
371 - <label for="'.esc_attr($opt.'_'.$key).'" class="mc_radio_label">'.esc_html($value).'</label>
374 + <input type="radio" id="' . esc_attr( $opt_id . '_' . $key ) . '" name="' . esc_attr( $opt ) . '" class="mc_radio" value="' . $value . '"' . checked( $data['default_value'], $value, false ) . ' />
375 + <label for="' . esc_attr( $opt_id . '_' . $key ) . '" class="mc_radio_label">' . esc_html( $value ) . '</label>
372 376 </li>';
373 377 }
374 378 $html .= '
375 379 </ul>';
@@ -375,14 +379,14 @@
375 379 </ul>';
376 380 }
377 381 break;
378 382 case 'dropdown':
379 - if (is_array($var['choices'])) {
383 + if ( is_array( $data['options']['choices'] ) ) {
380 384 $html .= '
381 - <select id="'.esc_attr($opt).'" name="'.esc_attr($opt).'" class="mc_select">';
382 - foreach ($var['choices'] as $value) {
385 + <select id="' . esc_attr( $opt_id ) . '" name="' . esc_attr( $opt ) . '" class="mc_select">';
386 + foreach ( $data['options']['choices'] as $value ) {
383 387 $html .= '
384 - <option value="'.esc_attr($value).'"'.selected($value, $var['default'], false).'>'.esc_html($value).'</option>';
388 + <option value="' . esc_attr( $value ) . '"' . selected( $value, $data['default_value'], false ) . '>' . esc_html( $value ) . '</option>';
385 389 }
386 390 $html .= '
387 391 </select>';
388 392 }
@@ -388,72 +392,76 @@
388 392 }
389 393 break;
390 394 case 'birthday':
391 395 $html .= '
392 - <input type="text" size="18" placeholder="'.esc_attr($var['default']).'" data-format="'.esc_attr($var['dateformat']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="birthdate-pick mc_input"/>';
396 + <input type="text" size="18" placeholder="' . esc_attr( $data['default_value'] ) . '" data-format="' . esc_attr( $data['options']['date_format'] ) . '" name="' . esc_attr( $opt ) . '" id="' . esc_attr( $opt_id ) . '" class="birthdate-pick mc_input"/>';
393 397 break;
394 398 case 'birthday-old':
395 - $days = range(1, 31);
396 - $months = array(__('January', 'mailchimp_i18n'), __('February', 'mailchimp_i18n'), __('March', 'mailchimp_i18n'), __('April', 'mailchimp_i18n'), __('May', 'mailchimp_i18n'), __('June', 'mailchimp_i18n'), __('July', 'mailchimp_i18n'), __('August', 'mailchimp_i18n'), __('September', 'mailchimp_i18n'), __('October', 'mailchimp_i18n'), __('November', 'mailchimp_i18n'), __('December', 'mailchimp_i18n'), );
397 -
399 + $days = range( 1, 31 );
400 + $months = array(
401 + esc_html__( 'January', 'mailchimp' ),
402 + esc_html__( 'February', 'mailchimp' ),
403 + esc_html__( 'March', 'mailchimp' ),
404 + esc_html__( 'April', 'mailchimp' ),
405 + esc_html__( 'May', 'mailchimp' ),
406 + esc_html__( 'June', 'mailchimp' ),
407 + esc_html__( 'July', 'mailchimp' ),
408 + esc_html__( 'August', 'mailchimp' ),
409 + esc_html__( 'September', 'mailchimp' ),
410 + esc_html__( 'October', 'mailchimp' ),
411 + esc_html__( 'November', 'mailchimp' ),
412 + esc_html__( 'December', 'mailchimp' ),
413 + );
414 +
398 415 $html .= '
399 - <br /><select id="'.esc_attr($opt).'" name="'.esc_attr($opt.'[month]').'" class="mc_select">';
400 - foreach ($months as $month_key => $month) {
416 + <br /><select id="' . esc_attr( $opt_id ) . '" name="' . esc_attr( $opt . '[month]' ) . '" class="mc_select">';
417 + foreach ( $months as $month_key => $month ) {
401 418 $html .= '
402 - <option value="'.$month_key.'">'.$month.'</option>';
419 + <option value="' . $month_key . '">' . $month . '</option>';
403 420 }
404 421 $html .= '
405 422 </select>';
406 -
423 +
407 424 $html .= '
408 - <select id="'.esc_attr($opt).'" name="'.esc_attr($opt.'[day]').'" class="mc_select">';
409 - foreach ($days as $day) {
410 - $html .= '
411 - <option value="'.$day.'">'.$day.'</option>';
412 - }
425 + <select id="' . esc_attr( $opt_id ) . '" name="' . esc_attr( $opt . '[day]' ) . '" class="mc_select">';
426 + foreach ( $days as $day ) {
427 + $html .= '
428 + <option value="' . $day . '">' . $day . '</option>';
429 + }
413 430 $html .= '
414 431 </select>';
415 432 break;
416 433 case 'address':
417 - $countries = mailchimp_country_list();
418 - $html .= '
434 + $countries = mailchimp_country_list();
435 + $html .= '
419 436
420 - <label for="'.esc_attr($opt.'-addr1').'" class="mc_address_label">'.__('Street Address', 'mailchimp_i18n').'</label>
421 - <input type="text" size="18" value="" name="'.esc_attr($opt.'[addr1]').'" id="'.esc_attr($opt.'-addr1').'" class="mc_input" />
422 - <label for="'.esc_attr($opt.'-addr2').'" class="mc_address_label">'.__('Address Line 2', 'mailchimp_i18n').'</label>
423 - <input type="text" size="18" value="" name="'.esc_attr($opt.'[addr2]').'" id="'.esc_attr($opt.'-addr2').'" class="mc_input" />
424 - <label for="'.esc_attr($opt.'-city').'" class="mc_address_label">'.__('City', 'mailchimp_i18n').'</label>
425 - <input type="text" size="18" value="" name="'.esc_attr($opt.'[city]').'" id="'.esc_attr($opt.'-city').'" class="mc_input" />
426 - <label for="'.esc_attr($opt.'-state').'" class="mc_address_label">'.__('State', 'mailchimp_i18n').'</label>
427 - <input type="text" size="18" value="" name="'.esc_attr($opt.'[state]').'" id="'.esc_attr($opt.'-state').'" class="mc_input" />
428 - <label for="'.esc_attr($opt.'-zip').'" class="mc_address_label">'.__('Zip / Postal', 'mailchimp_i18n').'</label>
429 - <input type="text" size="18" value="" maxlength="5" name="'.esc_attr($opt.'[zip]').'" id="'.esc_attr($opt.'-zip').'" class="mc_input" />
430 - <label for="'.esc_attr($opt.'-country').'" class="mc_address_label">'.__('Country', 'mailchimp_i18n').'</label>
431 - <select name="'.esc_attr($opt.'[country]').'" id="'.esc_attr($opt.'-country').'">';
432 - foreach ($countries as $country_code => $country_name) {
437 + <label for="' . esc_attr( $opt_id . '-addr1' ) . '" class="mc_address_label">' . esc_html__( 'Street Address', 'mailchimp' ) . '</label>
438 + <input type="text" size="18" value="" name="' . esc_attr( $opt . '[addr1]' ) . '" id="' . esc_attr( $opt_id . '-addr1' ) . '" class="mc_input" />
439 + <label for="' . esc_attr( $opt_id . '-addr2' ) . '" class="mc_address_label">' . esc_html__( 'Address Line 2', 'mailchimp' ) . '</label>
440 + <input type="text" size="18" value="" name="' . esc_attr( $opt . '[addr2]' ) . '" id="' . esc_attr( $opt_id . '-addr2' ) . '" class="mc_input" />
441 + <label for="' . esc_attr( $opt_id . '-city' ) . '" class="mc_address_label">' . esc_html__( 'City', 'mailchimp' ) . '</label>
442 + <input type="text" size="18" value="" name="' . esc_attr( $opt . '[city]' ) . '" id="' . esc_attr( $opt_id . '-city' ) . '" class="mc_input" />
443 + <label for="' . esc_attr( $opt_id . '-state' ) . '" class="mc_address_label">' . esc_html__( 'State', 'mailchimp' ) . '</label>
444 + <input type="text" size="18" value="" name="' . esc_attr( $opt . '[state]' ) . '" id="' . esc_attr( $opt_id . '-state' ) . '" class="mc_input" />
445 + <label for="' . esc_attr( $opt_id . '-zip' ) . '" class="mc_address_label">' . esc_html__( 'Zip / Postal', 'mailchimp' ) . '</label>
446 + <input type="text" size="18" value="" maxlength="5" name="' . esc_attr( $opt . '[zip]' ) . '" id="' . esc_attr( $opt_id . '-zip' ) . '" class="mc_input" />
447 + <label for="' . esc_attr( $opt_id . '-country' ) . '" class="mc_address_label">' . esc_html__( 'Country', 'mailchimp' ) . '</label>
448 + <select name="' . esc_attr( $opt . '[country]' ) . '" id="' . esc_attr( $opt_id . '-country' ) . '">';
449 + foreach ( $countries as $country_code => $country_name ) {
450 + $html .= '
451 + <option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $data['options']['default_country'], false ) . '>' . esc_html( $country_name ) . '</option>';
452 + }
433 453 $html .= '
434 - <option value="'.esc_attr($country_code).'"'.selected($country_code, $var['defaultcountry'], false).'>'.esc_html($country_name).'</option>';
435 - }
436 - $html .= '
437 454 </select>';
438 455 break;
439 456 case 'zip':
440 457 $html .= '
441 - <input type="text" size="18" maxlength="5" value="" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input" />';
458 + <input type="text" size="18" maxlength="5" value="" name="' . esc_attr( $opt ) . '" id="' . esc_attr( $opt_id ) . '" class="mc_input" />';
442 459 break;
443 460 case 'phone':
444 - if ($var['phoneformat'] == 'US') {
445 - $html .= '
446 - <input type="text" size="2" maxlength="3" value="" name="'.esc_attr($opt.'[area]').'" id="'.esc_attr($opt.'-area').'" class="mc_input mc_phone" />
447 - <input type="text" size="2" maxlength="3" value="" name="'.esc_attr($opt.'[detail1]').'" id="'.esc_attr($opt.'-detail1').'" class="mc_input mc_phone" />
448 - <input type="text" size="5" maxlength="4" value="" name="'.esc_attr($opt.'[detail2]').'" id="'.esc_attr($opt.'-detail2').'" class="mc_input mc_phone" />
449 - ';
450 - }
451 - else {
452 - $html .= '
453 - <input type="text" size="18" value="" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input" />
454 - ';
455 - }
461 + $is_us_phone = isset( $data['options']['phone_format'] ) && 'US' === $data['options']['phone_format'];
462 + $html .= '
463 + <input type="tel" size="20" minlength="6" maxlength="20" pattern="^\+?[\d\s\-\(\)\.]*$" value="" name="' . esc_attr( $opt ) . '" id="' . esc_attr( $opt_id ) . '" class="mc_input mailchimp-sf-phone" placeholder="' . esc_attr( $is_us_phone ? '(###) ### - ####' : '' ) . '" />';
456 464 break;
457 465 case 'email':
458 466 case 'url':
459 467 case 'imageurl':
@@ -460,285 +468,279 @@
460 468 case 'text':
461 469 case 'number':
462 470 default:
463 471 $html .= '
464 - <input type="text" size="18" placeholder="'.esc_html($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input"/>';
472 + <input type="text" size="18" placeholder="' . esc_attr( $data['default_value'] ) . '" name="' . esc_attr( $opt ) . '" id="' . esc_attr( $opt_id ) . '" class="mc_input"/>';
465 473 break;
466 474 }
467 - if (!empty($var['helptext'])) {
468 - $html .= '<span class="mc_help">'.esc_html($var['helptext']).'</span>';
475 + if ( ! empty( $data['help_text'] ) ) {
476 + $html .= '<span class="mc_help">' . esc_html( $data['help_text'] ) . '</span>';
469 477 }
470 478 $html .= '
471 479 </div><!-- /mc_merge_var -->';
472 480 }
473 -
481 +
474 482 return $html;
475 483 }
476 484
477 485 /**
478 - * MailChimp Subscribe Box widget class
486 + * Mailchimp Subscribe Box widget class
479 487 */
488 +class Mailchimp_SF_Widget extends WP_Widget /* phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed */ {
480 489
481 -class mailchimpSF_Widget extends WP_Widget {
482 -
483 - function mailchimpSF_Widget() {
484 - $widget_ops = array(
485 - 'description' => __('Displays a MailChimp Subscribe box', 'mailchimp_i18n')
490 + /**
491 + * Initialize class
492 + */
493 + public function __construct() {
494 + $widget_ops = array(
495 + 'description' => __( 'Displays a Mailchimp Subscribe box', 'mailchimp' ),
486 496 );
487 - $this->WP_Widget('mailchimpSF_widget', __('MailChimp Widget', 'mailchimp_i18n'), $widget_ops);
497 + parent::__construct( 'Mailchimp_SF_Widget', __( 'Mailchimp Widget', 'mailchimp' ), $widget_ops );
488 498 }
489 - function widget( $args, $instance ) {
490 - if (!is_array($instance)) {
499 +
500 + /**
501 + * Echoes the widget content.
502 + *
503 + * @param array $args Display arguments including 'before_title', 'after_title',
504 + * 'before_widget', and 'after_widget'.
505 + * @param array $instance The settings for the particular instance of the widget.
506 + * @return void
507 + */
508 + public function widget( $args, $instance ) {
509 + if ( ! is_array( $instance ) ) {
491 510 $instance = array();
492 511 }
493 - mailchimpSF_signup_form(array_merge($args, $instance));
512 + mailchimp_sf_signup_form( array_merge( $args, $instance ) );
494 513 }
495 - function form( $instance ) { ?>
496 -<p>Great work! Your widget is ready to go — just head <a href="<?php echo admin_url('options-general.php?page=mailchimpSF_options') ?>">over here</a> if you’d like to adjust your settings.</p>
497 -<?php }
514 +
515 + /**
516 + * Outputs the settings update form.
517 + *
518 + * @param array $instance Current settings.
519 + */
520 + public function form( $instance ) {
521 + ?>
522 +<p>
523 + <?php
524 + echo wp_kses(
525 + sprintf(
526 + /* translators: 1: admin url */
527 + __(
528 + 'Great work! Your widget is ready to go — just head <a href="%1$s">over here</a> if you\'d like to adjust your settings.',
529 + 'mailchimp'
530 + ),
531 + esc_url( admin_url( 'admin.php?page=mailchimp_sf_options' ) )
532 + ),
533 + [
534 + 'a' => [
535 + 'href' => [],
536 + ],
537 + ]
538 + );
539 + ?>
540 +</p>
541 + <?php
542 + }
498 543 }
499 544
545 +/**
546 + * Return country list
547 + *
548 + * @return array
549 + */
500 550 function mailchimp_country_list() {
501 551 return array(
502 - '164' => __('USA', 'mailchimp_i18n'),
503 - '286' => __('Aaland Islands', 'mailchimp_i18n'),
504 - '274' => __('Afghanistan', 'mailchimp_i18n'),
505 - '2' => __('Albania', 'mailchimp_i18n'),
506 - '3' => __('Algeria', 'mailchimp_i18n'),
507 - '178' => __('American Samoa', 'mailchimp_i18n'),
508 - '4' => __('Andorra', 'mailchimp_i18n'),
509 - '5' => __('Angola', 'mailchimp_i18n'),
510 - '176' => __('Anguilla', 'mailchimp_i18n'),
511 - '175' => __('Antigua And Barbuda', 'mailchimp_i18n'),
512 - '6' => __('Argentina', 'mailchimp_i18n'),
513 - '7' => __('Armenia', 'mailchimp_i18n'),
514 - '179' => __('Aruba', 'mailchimp_i18n'),
515 - '8' => __('Australia', 'mailchimp_i18n'),
516 - '9' => __('Austria', 'mailchimp_i18n'),
517 - '10' => __('Azerbaijan', 'mailchimp_i18n'),
518 - '11' => __('Bahamas', 'mailchimp_i18n'),
519 - '12' => __('Bahrain', 'mailchimp_i18n'),
520 - '13' => __('Bangladesh', 'mailchimp_i18n'),
521 - '14' => __('Barbados', 'mailchimp_i18n'),
522 - '15' => __('Belarus', 'mailchimp_i18n'),
523 - '16' => __('Belgium', 'mailchimp_i18n'),
524 - '17' => __('Belize', 'mailchimp_i18n'),
525 - '18' => __('Benin', 'mailchimp_i18n'),
526 - '19' => __('Bermuda', 'mailchimp_i18n'),
527 - '20' => __('Bhutan', 'mailchimp_i18n'),
528 - '21' => __('Bolivia', 'mailchimp_i18n'),
529 - '22' => __('Bosnia and Herzegovina', 'mailchimp_i18n'),
530 - '23' => __('Botswana', 'mailchimp_i18n'),
531 - '24' => __('Brazil', 'mailchimp_i18n'),
532 - '180' => __('Brunei Darussalam', 'mailchimp_i18n'),
533 - '25' => __('Bulgaria', 'mailchimp_i18n'),
534 - '26' => __('Burkina Faso', 'mailchimp_i18n'),
535 - '27' => __('Burundi', 'mailchimp_i18n'),
536 - '28' => __('Cambodia', 'mailchimp_i18n'),
537 - '29' => __('Cameroon', 'mailchimp_i18n'),
538 - '30' => __('Canada', 'mailchimp_i18n'),
539 - '31' => __('Cape Verde', 'mailchimp_i18n'),
540 - '32' => __('Cayman Islands', 'mailchimp_i18n'),
541 - '33' => __('Central African Republic', 'mailchimp_i18n'),
542 - '34' => __('Chad', 'mailchimp_i18n'),
543 - '35' => __('Chile', 'mailchimp_i18n'),
544 - '36' => __('China', 'mailchimp_i18n'),
545 - '37' => __('Colombia', 'mailchimp_i18n'),
546 - '38' => __('Congo', 'mailchimp_i18n'),
547 - '183' => __('Cook Islands', 'mailchimp_i18n'),
548 - '268' => __('Costa Rica', 'mailchimp_i18n'),
549 - '275' => __('Cote D\'Ivoire', 'mailchimp_i18n'),
550 - '40' => __('Croatia', 'mailchimp_i18n'),
551 - '276' => __('Cuba', 'mailchimp_i18n'),
552 - '41' => __('Cyprus', 'mailchimp_i18n'),
553 - '42' => __('Czech Republic', 'mailchimp_i18n'),
554 - '43' => __('Denmark', 'mailchimp_i18n'),
555 - '44' => __('Djibouti', 'mailchimp_i18n'),
556 - '289' => __('Dominica', 'mailchimp_i18n'),
557 - '187' => __('Dominican Republic', 'mailchimp_i18n'),
558 - '233' => __('East Timor', 'mailchimp_i18n'),
559 - '45' => __('Ecuador', 'mailchimp_i18n'),
560 - '46' => __('Egypt', 'mailchimp_i18n'),
561 - '47' => __('El Salvador', 'mailchimp_i18n'),
562 - '48' => __('Equatorial Guinea', 'mailchimp_i18n'),
563 - '49' => __('Eritrea', 'mailchimp_i18n'),
564 - '50' => __('Estonia', 'mailchimp_i18n'),
565 - '51' => __('Ethiopia', 'mailchimp_i18n'),
566 - '191' => __('Faroe Islands', 'mailchimp_i18n'),
567 - '52' => __('Fiji', 'mailchimp_i18n'),
568 - '53' => __('Finland', 'mailchimp_i18n'),
569 - '54' => __('France', 'mailchimp_i18n'),
570 - '277' => __('French Polynesia', 'mailchimp_i18n'),
571 - '59' => __('Germany', 'mailchimp_i18n'),
572 - '60' => __('Ghana', 'mailchimp_i18n'),
573 - '194' => __('Gibraltar', 'mailchimp_i18n'),
574 - '61' => __('Greece', 'mailchimp_i18n'),
575 - '195' => __('Greenland', 'mailchimp_i18n'),
576 - '192' => __('Grenada', 'mailchimp_i18n'),
577 - '62' => __('Guam', 'mailchimp_i18n'),
578 - '198' => __('Guatemala', 'mailchimp_i18n'),
579 - '270' => __('Guernsey', 'mailchimp_i18n'),
580 - '65' => __('Guyana', 'mailchimp_i18n'),
581 - '200' => __('Haiti', 'mailchimp_i18n'),
582 - '66' => __('Honduras', 'mailchimp_i18n'),
583 - '67' => __('Hong Kong', 'mailchimp_i18n'),
584 - '68' => __('Hungary', 'mailchimp_i18n'),
585 - '69' => __('Iceland', 'mailchimp_i18n'),
586 - '70' => __('India', 'mailchimp_i18n'),
587 - '71' => __('Indonesia', 'mailchimp_i18n'),
588 - '278' => __('Iran', 'mailchimp_i18n'),
589 - '279' => __('Iraq', 'mailchimp_i18n'),
590 - '74' => __('Ireland', 'mailchimp_i18n'),
591 - '75' => __('Israel', 'mailchimp_i18n'),
592 - '76' => __('Italy', 'mailchimp_i18n'),
593 - '202' => __('Jamaica', 'mailchimp_i18n'),
594 - '78' => __('Japan', 'mailchimp_i18n'),
595 - '288' => __('Jersey (Channel Islands)', 'mailchimp_i18n'),
596 - '79' => __('Jordan', 'mailchimp_i18n'),
597 - '80' => __('Kazakhstan', 'mailchimp_i18n'),
598 - '81' => __('Kenya', 'mailchimp_i18n'),
599 - '82' => __('Kuwait', 'mailchimp_i18n'),
600 - '83' => __('Kyrgyzstan', 'mailchimp_i18n'),
601 - '84' => __('Lao People\'s Democratic Republic', 'mailchimp_i18n'),
602 - '85' => __('Latvia', 'mailchimp_i18n'),
603 - '86' => __('Lebanon', 'mailchimp_i18n'),
604 - '281' => __('Libya', 'mailchimp_i18n'),
605 - '90' => __('Liechtenstein', 'mailchimp_i18n'),
606 - '91' => __('Lithuania', 'mailchimp_i18n'),
607 - '92' => __('Luxembourg', 'mailchimp_i18n'),
608 - '208' => __('Macau', 'mailchimp_i18n'),
609 - '93' => __('Macedonia', 'mailchimp_i18n'),
610 - '94' => __('Madagascar', 'mailchimp_i18n'),
611 - '95' => __('Malawi', 'mailchimp_i18n'),
612 - '96' => __('Malaysia', 'mailchimp_i18n'),
613 - '97' => __('Maldives', 'mailchimp_i18n'),
614 - '98' => __('Mali', 'mailchimp_i18n'),
615 - '99' => __('Malta', 'mailchimp_i18n'),
616 - '212' => __('Mauritius', 'mailchimp_i18n'),
617 - '101' => __('Mexico', 'mailchimp_i18n'),
618 - '102' => __('Moldova, Republic of', 'mailchimp_i18n'),
619 - '103' => __('Monaco', 'mailchimp_i18n'),
620 - '104' => __('Mongolia', 'mailchimp_i18n'),
621 - '290' => __('Montenegro', 'mailchimp_i18n'),
622 - '105' => __('Morocco', 'mailchimp_i18n'),
623 - '106' => __('Mozambique', 'mailchimp_i18n'),
624 - '242' => __('Myanmar', 'mailchimp_i18n'),
625 - '107' => __('Namibia', 'mailchimp_i18n'),
626 - '108' => __('Nepal', 'mailchimp_i18n'),
627 - '109' => __('Netherlands', 'mailchimp_i18n'),
628 - '110' => __('Netherlands Antilles', 'mailchimp_i18n'),
629 - '213' => __('New Caledonia', 'mailchimp_i18n'),
630 - '111' => __('New Zealand', 'mailchimp_i18n'),
631 - '112' => __('Nicaragua', 'mailchimp_i18n'),
632 - '113' => __('Niger', 'mailchimp_i18n'),
633 - '114' => __('Nigeria', 'mailchimp_i18n'),
634 - '272' => __('North Korea', 'mailchimp_i18n'),
635 - '116' => __('Norway', 'mailchimp_i18n'),
636 - '117' => __('Oman', 'mailchimp_i18n'),
637 - '118' => __('Pakistan', 'mailchimp_i18n'),
638 - '222' => __('Palau', 'mailchimp_i18n'),
639 - '282' => __('Palestine', 'mailchimp_i18n'),
640 - '119' => __('Panama', 'mailchimp_i18n'),
641 - '219' => __('Papua New Guinea', 'mailchimp_i18n'),
642 - '120' => __('Paraguay', 'mailchimp_i18n'),
643 - '121' => __('Peru', 'mailchimp_i18n'),
644 - '122' => __('Philippines', 'mailchimp_i18n'),
645 - '123' => __('Poland', 'mailchimp_i18n'),
646 - '124' => __('Portugal', 'mailchimp_i18n'),
647 - '126' => __('Qatar', 'mailchimp_i18n'),
648 - '58' => __('Republic of Georgia', 'mailchimp_i18n'),
649 - '128' => __('Romania', 'mailchimp_i18n'),
650 - '129' => __('Russia', 'mailchimp_i18n'),
651 - '130' => __('Rwanda', 'mailchimp_i18n'),
652 - '205' => __('Saint Kitts and Nevis', 'mailchimp_i18n'),
653 - '206' => __('Saint Lucia', 'mailchimp_i18n'),
654 - '132' => __('Samoa (Independent)', 'mailchimp_i18n'),
655 - '227' => __('San Marino', 'mailchimp_i18n'),
656 - '133' => __('Saudi Arabia', 'mailchimp_i18n'),
657 - '134' => __('Senegal', 'mailchimp_i18n'),
658 - '266' => __('Serbia', 'mailchimp_i18n'),
659 - '135' => __('Seychelles', 'mailchimp_i18n'),
660 - '137' => __('Singapore', 'mailchimp_i18n'),
661 - '138' => __('Slovakia', 'mailchimp_i18n'),
662 - '139' => __('Slovenia', 'mailchimp_i18n'),
663 - '223' => __('Solomon Islands', 'mailchimp_i18n'),
664 - '141' => __('South Africa', 'mailchimp_i18n'),
665 - '142' => __('South Korea', 'mailchimp_i18n'),
666 - '143' => __('Spain', 'mailchimp_i18n'),
667 - '144' => __('Sri Lanka', 'mailchimp_i18n'),
668 - '293' => __('Sudan', 'mailchimp_i18n'),
669 - '146' => __('Suriname', 'mailchimp_i18n'),
670 - '147' => __('Swaziland', 'mailchimp_i18n'),
671 - '148' => __('Sweden', 'mailchimp_i18n'),
672 - '149' => __('Switzerland', 'mailchimp_i18n'),
673 - '152' => __('Taiwan', 'mailchimp_i18n'),
674 - '153' => __('Tanzania', 'mailchimp_i18n'),
675 - '154' => __('Thailand', 'mailchimp_i18n'),
676 - '155' => __('Togo', 'mailchimp_i18n'),
677 - '232' => __('Tonga', 'mailchimp_i18n'),
678 - '234' => __('Trinidad and Tobago', 'mailchimp_i18n'),
679 - '156' => __('Tunisia', 'mailchimp_i18n'),
680 - '157' => __('Turkey', 'mailchimp_i18n'),
681 - '287' => __('Turks &amp; Caicos Islands', 'mailchimp_i18n'),
682 - '159' => __('Uganda', 'mailchimp_i18n'),
683 - '161' => __('Ukraine', 'mailchimp_i18n'),
684 - '162' => __('United Arab Emirates', 'mailchimp_i18n'),
685 - '262' => __('United Kingdom', 'mailchimp_i18n'),
686 - '163' => __('Uruguay', 'mailchimp_i18n'),
687 - '239' => __('Vanuatu', 'mailchimp_i18n'),
688 - '166' => __('Vatican City State (Holy See)', 'mailchimp_i18n'),
689 - '167' => __('Venezuela', 'mailchimp_i18n'),
690 - '168' => __('Vietnam', 'mailchimp_i18n'),
691 - '169' => __('Virgin Islands (British)', 'mailchimp_i18n'),
692 - '238' => __('Virgin Islands (U.S.)', 'mailchimp_i18n'),
693 - '173' => __('Zambia', 'mailchimp_i18n'),
694 - '174' => __('Zimbabwe', 'mailchimp_i18n'),
552 + '164' => __( 'USA', 'mailchimp' ),
553 + '286' => __( 'Aaland Islands', 'mailchimp' ),
554 + '274' => __( 'Afghanistan', 'mailchimp' ),
555 + '2' => __( 'Albania', 'mailchimp' ),
556 + '3' => __( 'Algeria', 'mailchimp' ),
557 + '178' => __( 'American Samoa', 'mailchimp' ),
558 + '4' => __( 'Andorra', 'mailchimp' ),
559 + '5' => __( 'Angola', 'mailchimp' ),
560 + '176' => __( 'Anguilla', 'mailchimp' ),
561 + '175' => __( 'Antigua And Barbuda', 'mailchimp' ),
562 + '6' => __( 'Argentina', 'mailchimp' ),
563 + '7' => __( 'Armenia', 'mailchimp' ),
564 + '179' => __( 'Aruba', 'mailchimp' ),
565 + '8' => __( 'Australia', 'mailchimp' ),
566 + '9' => __( 'Austria', 'mailchimp' ),
567 + '10' => __( 'Azerbaijan', 'mailchimp' ),
568 + '11' => __( 'Bahamas', 'mailchimp' ),
569 + '12' => __( 'Bahrain', 'mailchimp' ),
570 + '13' => __( 'Bangladesh', 'mailchimp' ),
571 + '14' => __( 'Barbados', 'mailchimp' ),
572 + '15' => __( 'Belarus', 'mailchimp' ),
573 + '16' => __( 'Belgium', 'mailchimp' ),
574 + '17' => __( 'Belize', 'mailchimp' ),
575 + '18' => __( 'Benin', 'mailchimp' ),
576 + '19' => __( 'Bermuda', 'mailchimp' ),
577 + '20' => __( 'Bhutan', 'mailchimp' ),
578 + '21' => __( 'Bolivia', 'mailchimp' ),
579 + '22' => __( 'Bosnia and Herzegovina', 'mailchimp' ),
580 + '23' => __( 'Botswana', 'mailchimp' ),
581 + '24' => __( 'Brazil', 'mailchimp' ),
582 + '180' => __( 'Brunei Darussalam', 'mailchimp' ),
583 + '25' => __( 'Bulgaria', 'mailchimp' ),
584 + '26' => __( 'Burkina Faso', 'mailchimp' ),
585 + '27' => __( 'Burundi', 'mailchimp' ),
586 + '28' => __( 'Cambodia', 'mailchimp' ),
587 + '29' => __( 'Cameroon', 'mailchimp' ),
588 + '30' => __( 'Canada', 'mailchimp' ),
589 + '31' => __( 'Cape Verde', 'mailchimp' ),
590 + '32' => __( 'Cayman Islands', 'mailchimp' ),
591 + '33' => __( 'Central African Republic', 'mailchimp' ),
592 + '34' => __( 'Chad', 'mailchimp' ),
593 + '35' => __( 'Chile', 'mailchimp' ),
594 + '36' => __( 'China', 'mailchimp' ),
595 + '37' => __( 'Colombia', 'mailchimp' ),
596 + '38' => __( 'Congo', 'mailchimp' ),
597 + '183' => __( 'Cook Islands', 'mailchimp' ),
598 + '268' => __( 'Costa Rica', 'mailchimp' ),
599 + '275' => __( 'Cote D\'Ivoire', 'mailchimp' ),
600 + '40' => __( 'Croatia', 'mailchimp' ),
601 + '276' => __( 'Cuba', 'mailchimp' ),
602 + '41' => __( 'Cyprus', 'mailchimp' ),
603 + '42' => __( 'Czech Republic', 'mailchimp' ),
604 + '43' => __( 'Denmark', 'mailchimp' ),
605 + '44' => __( 'Djibouti', 'mailchimp' ),
606 + '289' => __( 'Dominica', 'mailchimp' ),
607 + '187' => __( 'Dominican Republic', 'mailchimp' ),
608 + '233' => __( 'East Timor', 'mailchimp' ),
609 + '45' => __( 'Ecuador', 'mailchimp' ),
610 + '46' => __( 'Egypt', 'mailchimp' ),
611 + '47' => __( 'El Salvador', 'mailchimp' ),
612 + '48' => __( 'Equatorial Guinea', 'mailchimp' ),
613 + '49' => __( 'Eritrea', 'mailchimp' ),
614 + '50' => __( 'Estonia', 'mailchimp' ),
615 + '51' => __( 'Ethiopia', 'mailchimp' ),
616 + '191' => __( 'Faroe Islands', 'mailchimp' ),
617 + '52' => __( 'Fiji', 'mailchimp' ),
618 + '53' => __( 'Finland', 'mailchimp' ),
619 + '54' => __( 'France', 'mailchimp' ),
620 + '277' => __( 'French Polynesia', 'mailchimp' ),
621 + '59' => __( 'Germany', 'mailchimp' ),
622 + '60' => __( 'Ghana', 'mailchimp' ),
623 + '194' => __( 'Gibraltar', 'mailchimp' ),
624 + '61' => __( 'Greece', 'mailchimp' ),
625 + '195' => __( 'Greenland', 'mailchimp' ),
626 + '192' => __( 'Grenada', 'mailchimp' ),
627 + '62' => __( 'Guam', 'mailchimp' ),
628 + '198' => __( 'Guatemala', 'mailchimp' ),
629 + '270' => __( 'Guernsey', 'mailchimp' ),
630 + '65' => __( 'Guyana', 'mailchimp' ),
631 + '200' => __( 'Haiti', 'mailchimp' ),
632 + '66' => __( 'Honduras', 'mailchimp' ),
633 + '67' => __( 'Hong Kong', 'mailchimp' ),
634 + '68' => __( 'Hungary', 'mailchimp' ),
635 + '69' => __( 'Iceland', 'mailchimp' ),
636 + '70' => __( 'India', 'mailchimp' ),
637 + '71' => __( 'Indonesia', 'mailchimp' ),
638 + '278' => __( 'Iran', 'mailchimp' ),
639 + '279' => __( 'Iraq', 'mailchimp' ),
640 + '74' => __( 'Ireland', 'mailchimp' ),
641 + '75' => __( 'Israel', 'mailchimp' ),
642 + '76' => __( 'Italy', 'mailchimp' ),
643 + '202' => __( 'Jamaica', 'mailchimp' ),
644 + '78' => __( 'Japan', 'mailchimp' ),
645 + '288' => __( 'Jersey (Channel Islands)', 'mailchimp' ),
646 + '79' => __( 'Jordan', 'mailchimp' ),
647 + '80' => __( 'Kazakhstan', 'mailchimp' ),
648 + '81' => __( 'Kenya', 'mailchimp' ),
649 + '82' => __( 'Kuwait', 'mailchimp' ),
650 + '83' => __( 'Kyrgyzstan', 'mailchimp' ),
651 + '84' => __( 'Lao People\'s Democratic Republic', 'mailchimp' ),
652 + '85' => __( 'Latvia', 'mailchimp' ),
653 + '86' => __( 'Lebanon', 'mailchimp' ),
654 + '281' => __( 'Libya', 'mailchimp' ),
655 + '90' => __( 'Liechtenstein', 'mailchimp' ),
656 + '91' => __( 'Lithuania', 'mailchimp' ),
657 + '92' => __( 'Luxembourg', 'mailchimp' ),
658 + '208' => __( 'Macau', 'mailchimp' ),
659 + '93' => __( 'Macedonia', 'mailchimp' ),
660 + '94' => __( 'Madagascar', 'mailchimp' ),
661 + '95' => __( 'Malawi', 'mailchimp' ),
662 + '96' => __( 'Malaysia', 'mailchimp' ),
663 + '97' => __( 'Maldives', 'mailchimp' ),
664 + '98' => __( 'Mali', 'mailchimp' ),
665 + '99' => __( 'Malta', 'mailchimp' ),
666 + '212' => __( 'Mauritius', 'mailchimp' ),
667 + '101' => __( 'Mexico', 'mailchimp' ),
668 + '102' => __( 'Moldova, Republic of', 'mailchimp' ),
669 + '103' => __( 'Monaco', 'mailchimp' ),
670 + '104' => __( 'Mongolia', 'mailchimp' ),
671 + '290' => __( 'Montenegro', 'mailchimp' ),
672 + '105' => __( 'Morocco', 'mailchimp' ),
673 + '106' => __( 'Mozambique', 'mailchimp' ),
674 + '242' => __( 'Myanmar', 'mailchimp' ),
675 + '107' => __( 'Namibia', 'mailchimp' ),
676 + '108' => __( 'Nepal', 'mailchimp' ),
677 + '109' => __( 'Netherlands', 'mailchimp' ),
678 + '110' => __( 'Netherlands Antilles', 'mailchimp' ),
679 + '213' => __( 'New Caledonia', 'mailchimp' ),
680 + '111' => __( 'New Zealand', 'mailchimp' ),
681 + '112' => __( 'Nicaragua', 'mailchimp' ),
682 + '113' => __( 'Niger', 'mailchimp' ),
683 + '114' => __( 'Nigeria', 'mailchimp' ),
684 + '272' => __( 'North Korea', 'mailchimp' ),
685 + '116' => __( 'Norway', 'mailchimp' ),
686 + '117' => __( 'Oman', 'mailchimp' ),
687 + '118' => __( 'Pakistan', 'mailchimp' ),
688 + '222' => __( 'Palau', 'mailchimp' ),
689 + '282' => __( 'Palestine', 'mailchimp' ),
690 + '119' => __( 'Panama', 'mailchimp' ),
691 + '219' => __( 'Papua New Guinea', 'mailchimp' ),
692 + '120' => __( 'Paraguay', 'mailchimp' ),
693 + '121' => __( 'Peru', 'mailchimp' ),
694 + '122' => __( 'Philippines', 'mailchimp' ),
695 + '123' => __( 'Poland', 'mailchimp' ),
696 + '124' => __( 'Portugal', 'mailchimp' ),
697 + '126' => __( 'Qatar', 'mailchimp' ),
698 + '58' => __( 'Republic of Georgia', 'mailchimp' ),
699 + '128' => __( 'Romania', 'mailchimp' ),
700 + '129' => __( 'Russia', 'mailchimp' ),
701 + '130' => __( 'Rwanda', 'mailchimp' ),
702 + '205' => __( 'Saint Kitts and Nevis', 'mailchimp' ),
703 + '206' => __( 'Saint Lucia', 'mailchimp' ),
704 + '132' => __( 'Samoa (Independent)', 'mailchimp' ),
705 + '227' => __( 'San Marino', 'mailchimp' ),
706 + '133' => __( 'Saudi Arabia', 'mailchimp' ),
707 + '134' => __( 'Senegal', 'mailchimp' ),
708 + '266' => __( 'Serbia', 'mailchimp' ),
709 + '135' => __( 'Seychelles', 'mailchimp' ),
710 + '137' => __( 'Singapore', 'mailchimp' ),
711 + '138' => __( 'Slovakia', 'mailchimp' ),
712 + '139' => __( 'Slovenia', 'mailchimp' ),
713 + '223' => __( 'Solomon Islands', 'mailchimp' ),
714 + '141' => __( 'South Africa', 'mailchimp' ),
715 + '142' => __( 'South Korea', 'mailchimp' ),
716 + '143' => __( 'Spain', 'mailchimp' ),
717 + '144' => __( 'Sri Lanka', 'mailchimp' ),
718 + '293' => __( 'Sudan', 'mailchimp' ),
719 + '146' => __( 'Suriname', 'mailchimp' ),
720 + '147' => __( 'Swaziland', 'mailchimp' ),
721 + '148' => __( 'Sweden', 'mailchimp' ),
722 + '149' => __( 'Switzerland', 'mailchimp' ),
723 + '152' => __( 'Taiwan', 'mailchimp' ),
724 + '153' => __( 'Tanzania', 'mailchimp' ),
725 + '154' => __( 'Thailand', 'mailchimp' ),
726 + '155' => __( 'Togo', 'mailchimp' ),
727 + '232' => __( 'Tonga', 'mailchimp' ),
728 + '234' => __( 'Trinidad and Tobago', 'mailchimp' ),
729 + '156' => __( 'Tunisia', 'mailchimp' ),
730 + '157' => __( 'Turkey', 'mailchimp' ),
731 + '287' => __( 'Turks &amp; Caicos Islands', 'mailchimp' ),
732 + '159' => __( 'Uganda', 'mailchimp' ),
733 + '161' => __( 'Ukraine', 'mailchimp' ),
734 + '162' => __( 'United Arab Emirates', 'mailchimp' ),
735 + '262' => __( 'United Kingdom', 'mailchimp' ),
736 + '163' => __( 'Uruguay', 'mailchimp' ),
737 + '239' => __( 'Vanuatu', 'mailchimp' ),
738 + '166' => __( 'Vatican City State (Holy See)', 'mailchimp' ),
739 + '167' => __( 'Venezuela', 'mailchimp' ),
740 + '168' => __( 'Vietnam', 'mailchimp' ),
741 + '169' => __( 'Virgin Islands (British)', 'mailchimp' ),
742 + '238' => __( 'Virgin Islands (U.S.)', 'mailchimp' ),
743 + '173' => __( 'Zambia', 'mailchimp' ),
744 + '174' => __( 'Zimbabwe', 'mailchimp' ),
695 745 );
696 -}
697 -
698 -function mailchimp_get_kitchen_sink_fields() {
699 - $fields = array(
700 - 0 => array (
701 - 'name' => 'Email Address', 'req' => true, 'field_type' => 'email', 'public' => true, 'show' => true, 'order' => '1', 'default' => NULL, 'helptext' => NULL, 'size' => '25', 'tag' => 'EMAIL', 'id' => 0,
702 - ),
703 - 1 => array (
704 - 'name' => 'First Name', 'req' => true, 'field_type' => 'text', 'public' => true, 'show' => true, 'order' => '2', 'default' => '', 'helptext' => '', 'size' => '25', 'tag' => 'FNAME', 'id' => 1,
705 - ),
706 - 2 => array (
707 - 'name' => 'Last Name', 'req' => true, 'field_type' => 'text', 'public' => true, 'show' => true, 'order' => '3', 'default' => '', 'helptext' => '', 'size' => '25', 'tag' => 'LNAME', 'id' => 2,
708 - ),
709 - 3 => array (
710 - 'name' => 'Radio Buttons', 'req' => true, 'field_type' => 'radio', 'public' => true, 'show' => true, 'order' => '5', 'default' => '', 'helptext' => '', 'size' => '25', 'choices' => array ( 0 => 'First Choice', 1 => 'Second Choice', 2 => 'Third Choice' ), 'tag' => 'MMERGE3', 'id' => 3,
711 - ),
712 - 4 => array (
713 - 'name' => 'Drop Down','req' => true,'field_type' => 'dropdown','public' => true,'show' => true,'order' => '7','default' => '','helptext' => 'Help text','size' => '25','choices' => array (0 => 'First Choice', 1 => 'Second Choice', 2 => 'Third Choice', ),'tag' => 'MMERGE4','id' => 4,
714 - ),
715 - 5 => array (
716 - 'name' => 'Date','req' => true,'field_type' => 'date','public' => true,'show' => true,'order' => '8','default' => '','helptext' => '','size' => '25','dateformat' => 'MM/DD/YYYY','tag' => 'MMERGE5','id' => 5,
717 - ),
718 - );
719 - return apply_filters( 'mailchimp_dev_mode_fields', $fields );
720 -}
721 -
722 -function mailchimp_get_kitchen_sink_groups() {
723 - $groups = array (
724 - 0 => array (
725 - 'id' => 123,
726 - 'name' => 'Checkboxes',
727 - 'form_field' => 'checkboxes',
728 - 'display_order' => '0',
729 - 'groups' =>
730 - array (
731 - 0 => array (
732 - 'bit' => '1', 'name' => 'Checkbox Option 1', 'display_order' => '1', 'subscribers' => 0,
733 - ),
734 - 1 => array (
735 - 'bit' => '2', 'name' => 'Another Checkbox Option', 'display_order' => '2', 'subscribers' => 0,
736 - ),
737 - 2 => array (
738 - 'bit' => '4', 'name' => 'Third Option', 'display_order' => '3', 'subscribers' => 0,
739 - ),
740 - ),
741 - ),
742 - );
743 - return apply_filters( 'mailchimp_dev_mode_groups', $groups );
744 746 }