| 1 |
<?php |
| 2 |
/** |
| 3 |
* Displays a MailChimp Signup Form |
| 4 |
**/ |
| 5 |
function mailchimpSF_signup_form($args = array()) { |
| 6 |
extract($args); |
| 7 |
|
| 8 |
$mv = get_option('mc_merge_vars'); |
| 9 |
$igs = get_option('mc_interest_groups'); |
| 10 |
|
| 11 |
// See if we have valid Merge Vars |
| 12 |
if (!is_array($mv) && MAILCHIMP_DEV_MODE == false) { |
| 13 |
echo $before_widget; |
| 14 |
?> |
| 15 |
<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'); ?> |
| 17 |
</div> |
| 18 |
<?php |
| 19 |
echo $after_widget; |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
if (!is_array($mv) && MAILCHIMP_DEV_MODE == true) { |
| 24 |
$mv = mailchimp_get_kitchen_sink_fields(); |
| 25 |
$igs = mailchimp_get_kitchen_sink_groups(); |
| 26 |
} |
| 27 |
|
| 28 |
if (!empty($before_widget)) { |
| 29 |
echo $before_widget; |
| 30 |
} |
| 31 |
|
| 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' ); |
| 35 |
} |
| 36 |
|
| 37 |
// See if we have custom header content |
| 38 |
if (!empty($header)) { |
| 39 |
// 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 -->'; |
| 44 |
} |
| 45 |
else { |
| 46 |
echo $header; // don't escape $header b/c it may have HTML allowed |
| 47 |
} |
| 48 |
} |
| 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.' ); |
| 53 |
} |
| 54 |
|
| 55 |
?> |
| 56 |
|
| 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> |
| 131 |
|
| 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) { |
| 140 |
?> |
| 141 |
<div id="mc_subheader"> |
| 142 |
<?php echo $sub_heading; ?> |
| 143 |
</div><!-- /mc_subheader --> |
| 144 |
<?php |
| 145 |
} |
| 146 |
?> |
| 147 |
|
| 148 |
<div class="mc_form_inside"> |
| 149 |
|
| 150 |
<div class="updated" id="mc_message"> |
| 151 |
<?php echo mailchimpSF_global_msg(); ?> |
| 152 |
</div><!-- /mc_message --> |
| 153 |
|
| 154 |
<?php |
| 155 |
//don't show the "required" stuff if there's only 1 field to display. |
| 156 |
$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++; |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
if (is_array($mv)) { |
| 165 |
// head on back to the beginning of the array |
| 166 |
reset($mv); |
| 167 |
} |
| 168 |
|
| 169 |
// 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>'; |
| 173 |
} |
| 174 |
else { |
| 175 |
echo mailchimp_form_field($var, $num_fields); |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
// Show an explanation of the * if there's more than one field |
| 181 |
if ($num_fields > 1) { |
| 182 |
?> |
| 183 |
<div id="mc-indicates-required"> |
| 184 |
* = <?php esc_html_e('required field', 'mailchimp_i18n'); ?> |
| 185 |
</div><!-- /mc-indicates-required --> |
| 186 |
<?php |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
// 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 |
?> |
| 197 |
<div class="mc_interests_header"> |
| 198 |
<?php echo esc_html($ig['name']); ?> |
| 199 |
</div><!-- /mc_interests_header --> |
| 200 |
<div class="mc_interest"> |
| 201 |
<?php |
| 202 |
} |
| 203 |
else { |
| 204 |
?> |
| 205 |
<div class="mc_interest" style="display: none;"> |
| 206 |
<?php |
| 207 |
} |
| 208 |
?> |
| 209 |
|
| 210 |
<?php |
| 211 |
mailchimp_interest_group_field($ig); |
| 212 |
?> |
| 213 |
</div><!-- /mc_interest --> |
| 214 |
|
| 215 |
<?php |
| 216 |
} |
| 217 |
} |
| 218 |
} |
| 219 |
} |
| 220 |
|
| 221 |
if (get_option('mc_email_type_option') || MAILCHIMP_DEV_MODE == true) { |
| 222 |
?> |
| 223 |
<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> |
| 230 |
</div> |
| 231 |
</div> |
| 232 |
|
| 233 |
<?php |
| 234 |
} |
| 235 |
|
| 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' ); |
| 239 |
} |
| 240 |
|
| 241 |
?> |
| 242 |
|
| 243 |
<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" /> |
| 245 |
</div><!-- /mc_signup_submit --> |
| 246 |
|
| 247 |
|
| 248 |
<?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'; |
| 253 |
?> |
| 254 |
<div id="mc_unsub_link" align="center"> |
| 255 |
<a href="<?php echo esc_url($host.'/unsubscribe/?u='.$user['user_id'].'&id='.get_option('mc_list_id')); ?>" target="_blank"><?php esc_html_e('unsubscribe from list', 'mailchimp_i18n'); ?></a> |
| 256 |
</div><!-- /mc_unsub_link --> |
| 257 |
<?php |
| 258 |
} |
| 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'].'&afl=1'); ?>">MailChimp</a>! |
| 264 |
</div><!-- /mc_display_rewards --> |
| 265 |
<?php |
| 266 |
} |
| 267 |
?> |
| 268 |
|
| 269 |
</div><!-- /mc_form_inside --> |
| 270 |
</form><!-- /mc_signup_form --> |
| 271 |
</div><!-- /mc_signup_container --> |
| 272 |
<?php |
| 273 |
if (!empty($after_widget)) { |
| 274 |
echo $after_widget; |
| 275 |
} |
| 276 |
} |
| 277 |
|
| 278 |
/** |
| 279 |
* Generate and display markup for Interest Groups |
| 280 |
* @param array $ig Set of Interest Groups to generate markup for |
| 281 |
* @return void |
| 282 |
*/ |
| 283 |
function mailchimp_interest_group_field($ig) { |
| 284 |
if (!is_array($ig)) { |
| 285 |
return; |
| 286 |
} |
| 287 |
$html = ''; |
| 288 |
$set_name = 'group['.$ig['id'].']'; |
| 289 |
switch ($ig['form_field']) { |
| 290 |
case 'checkbox': |
| 291 |
case 'checkboxes': |
| 292 |
$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> |
| 298 |
<br/>'; |
| 299 |
$i++; |
| 300 |
} |
| 301 |
break; |
| 302 |
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> |
| 308 |
<br/>'; |
| 309 |
} |
| 310 |
break; |
| 311 |
case 'select': |
| 312 |
case 'dropdown': |
| 313 |
$html .= ' |
| 314 |
<select name="'.esc_attr($set_name).'"> |
| 315 |
<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 |
} |
| 321 |
$html .= ' |
| 322 |
</select>'; |
| 323 |
break; |
| 324 |
case 'hidden': |
| 325 |
$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++; |
| 332 |
} |
| 333 |
break; |
| 334 |
} |
| 335 |
echo $html; |
| 336 |
} |
| 337 |
|
| 338 |
/** |
| 339 |
* 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 |
| 343 |
*/ |
| 344 |
function mailchimp_form_field($var, $num_fields) { |
| 345 |
$opt = 'mc_mv_'.$var['tag']; |
| 346 |
$html = ''; |
| 347 |
// 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) { |
| 351 |
$label .= '<span class="mc_required">*</span>'; |
| 352 |
} |
| 353 |
$label .= '</label>'; |
| 354 |
|
| 355 |
$html .= ' |
| 356 |
<div class="mc_merge_var"> |
| 357 |
'.$label; |
| 358 |
switch ($var['field_type']) { |
| 359 |
case 'date': |
| 360 |
$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"/>'; |
| 362 |
break; |
| 363 |
case 'radio': |
| 364 |
if (is_array($var['choices'])) { |
| 365 |
$html .= ' |
| 366 |
<ul class="mc_list">'; |
| 367 |
foreach ($var['choices'] as $key => $value) { |
| 368 |
$html .= ' |
| 369 |
<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> |
| 372 |
</li>'; |
| 373 |
} |
| 374 |
$html .= ' |
| 375 |
</ul>'; |
| 376 |
} |
| 377 |
break; |
| 378 |
case 'dropdown': |
| 379 |
if (is_array($var['choices'])) { |
| 380 |
$html .= ' |
| 381 |
<select id="'.esc_attr($opt).'" name="'.esc_attr($opt).'" class="mc_select">'; |
| 382 |
foreach ($var['choices'] as $value) { |
| 383 |
$html .= ' |
| 384 |
<option value="'.esc_attr($value).'"'.selected($value, $var['default'], false).'>'.esc_html($value).'</option>'; |
| 385 |
} |
| 386 |
$html .= ' |
| 387 |
</select>'; |
| 388 |
} |
| 389 |
break; |
| 390 |
case 'birthday': |
| 391 |
$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"/>'; |
| 393 |
break; |
| 394 |
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 |
|
| 398 |
$html .= ' |
| 399 |
<br /><select id="'.esc_attr($opt).'" name="'.esc_attr($opt.'[month]').'" class="mc_select">'; |
| 400 |
foreach ($months as $month_key => $month) { |
| 401 |
$html .= ' |
| 402 |
<option value="'.$month_key.'">'.$month.'</option>'; |
| 403 |
} |
| 404 |
$html .= ' |
| 405 |
</select>'; |
| 406 |
|
| 407 |
$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 |
} |
| 413 |
$html .= ' |
| 414 |
</select>'; |
| 415 |
break; |
| 416 |
case 'address': |
| 417 |
$countries = mailchimp_country_list(); |
| 418 |
$html .= ' |
| 419 |
|
| 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) { |
| 433 |
$html .= ' |
| 434 |
<option value="'.esc_attr($country_code).'"'.selected($country_code, $var['defaultcountry'], false).'>'.esc_html($country_name).'</option>'; |
| 435 |
} |
| 436 |
$html .= ' |
| 437 |
</select>'; |
| 438 |
break; |
| 439 |
case 'zip': |
| 440 |
$html .= ' |
| 441 |
<input type="text" size="18" maxlength="5" value="" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input" />'; |
| 442 |
break; |
| 443 |
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 |
} |
| 456 |
break; |
| 457 |
case 'email': |
| 458 |
case 'url': |
| 459 |
case 'imageurl': |
| 460 |
case 'text': |
| 461 |
case 'number': |
| 462 |
default: |
| 463 |
$html .= ' |
| 464 |
<input type="text" size="18" placeholder="'.esc_html($var['default']).'" name="'.esc_attr($opt).'" id="'.esc_attr($opt).'" class="mc_input"/>'; |
| 465 |
break; |
| 466 |
} |
| 467 |
if (!empty($var['helptext'])) { |
| 468 |
$html .= '<span class="mc_help">'.esc_html($var['helptext']).'</span>'; |
| 469 |
} |
| 470 |
$html .= ' |
| 471 |
</div><!-- /mc_merge_var -->'; |
| 472 |
} |
| 473 |
|
| 474 |
return $html; |
| 475 |
} |
| 476 |
|
| 477 |
/** |
| 478 |
* MailChimp Subscribe Box widget class |
| 479 |
*/ |
| 480 |
|
| 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') |
| 486 |
); |
| 487 |
parent::__construct('mailchimpSF_widget', __('MailChimp Widget', 'mailchimp_i18n'), $widget_ops); |
| 488 |
} |
| 489 |
function widget( $args, $instance ) { |
| 490 |
if (!is_array($instance)) { |
| 491 |
$instance = array(); |
| 492 |
} |
| 493 |
mailchimpSF_signup_form(array_merge($args, $instance)); |
| 494 |
} |
| 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 } |
| 498 |
} |
| 499 |
|
| 500 |
function mailchimp_country_list() { |
| 501 |
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 & 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'), |
| 695 |
); |
| 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 |
} |
| 745 |
|