Version Description
- Add link to edit profile within error when duplicate signup occurs
Download this release
Release Info
Developer | crowdfavorite |
Plugin | MailChimp List Subscribe Form |
Version | 1.2.14 |
Comparing to | |
See all releases |
Code changes from version 1.2.13 to 1.2.14
- mailchimp.php +129 -114
- readme.txt +5 -2
mailchimp.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: MailChimp
|
4 |
Plugin URI: http://www.mailchimp.com/plugins/mailchimp-wordpress-plugin/
|
5 |
Description: The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list.
|
6 |
-
Version: 1.2.
|
7 |
Author: MailChimp and Crowd Favorite
|
8 |
Author URI: http://mailchimp.com/api/
|
9 |
*/
|
@@ -25,7 +25,7 @@ Author URI: http://mailchimp.com/api/
|
|
25 |
*/
|
26 |
|
27 |
// Version constant for easy CSS refreshes
|
28 |
-
define('MCSF_VER', '1.2.
|
29 |
|
30 |
// What's our permission (capability) threshold
|
31 |
define('MCSF_CAP_THRESHOLD', 'manage_options');
|
@@ -57,8 +57,8 @@ function mailchimpSF_plugin_init() {
|
|
57 |
$textdomain = 'mailchimp_i18n';
|
58 |
$locale = apply_filters( 'plugin_locale', get_locale(), $textdomain);
|
59 |
load_textdomain('mailchimp_i18n', MCSF_LANG_DIR.$textdomain.'-'.$locale.'.mo');
|
60 |
-
|
61 |
-
// Bring in our appropriate JS and CSS resources
|
62 |
mailchimpSF_load_resources();
|
63 |
}
|
64 |
add_action( 'init', 'mailchimpSF_plugin_init' );
|
@@ -79,7 +79,7 @@ function mailchimpSD_plugin_action_links($links) {
|
|
79 |
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'mailchimpSD_plugin_action_links', 10, 1);
|
80 |
|
81 |
/**
|
82 |
-
* Loads the appropriate JS and CSS resources depending on
|
83 |
* settings and context (admin or not)
|
84 |
*
|
85 |
* @return void
|
@@ -97,14 +97,14 @@ function mailchimpSF_load_resources() {
|
|
97 |
));
|
98 |
}
|
99 |
}
|
100 |
-
|
101 |
if (get_option('mc_use_datepicker') == 'on' && !is_admin()) {
|
102 |
// Datepicker theme
|
103 |
wp_enqueue_style('flick', MCSF_URL.'/css/flick/flick.css');
|
104 |
// Datepicker JS
|
105 |
wp_enqueue_script('datepicker', MCSF_URL.'/js/datepicker.js', array('jquery','jquery-ui-core'));
|
106 |
}
|
107 |
-
|
108 |
wp_enqueue_style('mailchimpSF_main_css', home_url('?mcsf_action=main_css&ver='.MCSF_VER));
|
109 |
wp_enqueue_style('mailchimpSF_ie_css', MCSF_URL.'css/ie.css');
|
110 |
global $wp_styles;
|
@@ -137,8 +137,8 @@ function mc_datepicker_load() {
|
|
137 |
changeYear: true,
|
138 |
beforeShow: function(input, inst) { $('#ui-datepicker-div').addClass('show'); },
|
139 |
dateFormat: 'yy/mm/dd',
|
140 |
-
});
|
141 |
-
|
142 |
d = new Date();
|
143 |
$('.birthdate-pick').datepicker({
|
144 |
autoFocusNextInput: true,
|
@@ -150,11 +150,11 @@ function mc_datepicker_load() {
|
|
150 |
beforeShow: function(input, inst) { $('#ui-datepicker-div').removeClass('show'); },
|
151 |
dateFormat: 'mm/dd',
|
152 |
});
|
153 |
-
|
154 |
-
|
155 |
});
|
156 |
</script>
|
157 |
-
<?php
|
158 |
}
|
159 |
if (get_option('mc_use_datepicker') == 'on' && !is_admin()) {
|
160 |
add_action('wp_head', 'mc_datepicker_load');
|
@@ -178,18 +178,18 @@ add_action('init', 'mailchimpSF_early_request_handler', 0);
|
|
178 |
|
179 |
/**
|
180 |
* Outputs the front-end CSS. This checks several options, so it
|
181 |
-
* was best to put it in a Request-handled script, as opposed to
|
182 |
* a static file.
|
183 |
*/
|
184 |
function mailchimpSF_main_css() {
|
185 |
?>
|
186 |
-
.mc_error_msg {
|
187 |
color: red;
|
188 |
}
|
189 |
.mc_success_msg {
|
190 |
color: green;
|
191 |
}
|
192 |
-
.mc_merge_var{
|
193 |
padding:0;
|
194 |
margin:0;
|
195 |
}
|
@@ -197,7 +197,7 @@ function mailchimpSF_main_css() {
|
|
197 |
// If we're utilizing custom styles
|
198 |
if (get_option('mc_custom_style')=='on'){
|
199 |
?>
|
200 |
-
#mc_signup_form {
|
201 |
padding:5px;
|
202 |
border-width: <?php echo get_option('mc_form_border_width'); ?>px;
|
203 |
border-style: <?php echo (get_option('mc_form_border_width')==0) ? 'none' : 'solid'; ?>;
|
@@ -205,8 +205,8 @@ if (get_option('mc_custom_style')=='on'){
|
|
205 |
color: #<?php echo get_option('mc_form_text_color'); ?>;
|
206 |
background-color: #<?php echo get_option('mc_form_background'); ?>;
|
207 |
}
|
208 |
-
|
209 |
-
|
210 |
.mc_custom_border_hdr {
|
211 |
border-width: <?php echo get_option('mc_header_border_width'); ?>px;
|
212 |
border-style: <?php echo (get_option('mc_header_border_width')==0) ? 'none' : 'solid'; ?>;
|
@@ -224,11 +224,11 @@ if (get_option('mc_custom_style')=='on'){
|
|
224 |
#mc_signup_form {}
|
225 |
#mc_signup_form .mc_var_label {}
|
226 |
#mc_signup_form .mc_input {}
|
227 |
-
#mc-indicates-required {
|
228 |
width:100%;
|
229 |
}
|
230 |
#mc_display_rewards {}
|
231 |
-
.mc_interests_header {
|
232 |
font-weight:bold;
|
233 |
}
|
234 |
div.mc_interest{
|
@@ -236,11 +236,11 @@ if (get_option('mc_custom_style')=='on'){
|
|
236 |
}
|
237 |
#mc_signup_form input.mc_interest {}
|
238 |
#mc_signup_form select {}
|
239 |
-
#mc_signup_form label.mc_interest_label {
|
240 |
display:inline;
|
241 |
}
|
242 |
-
.mc_signup_submit {
|
243 |
-
text-align:center;
|
244 |
}
|
245 |
ul.mc_list {
|
246 |
list-style-type: none;
|
@@ -266,7 +266,7 @@ if (get_option('mc_custom_style')=='on'){
|
|
266 |
*/
|
267 |
function mailchimpSF_add_pages(){
|
268 |
// Add settings page for users who can edit plugins
|
269 |
-
add_options_page( __( 'MailChimp Setup', 'mailchimp_i18n' ), __( 'MailChimp Setup', 'mailchimp_i18n' ), MCSF_CAP_THRESHOLD, 'mailchimpSF_options', 'mailchimpSF_setup_page');
|
270 |
}
|
271 |
add_action('admin_menu', 'mailchimpSF_add_pages');
|
272 |
|
@@ -279,7 +279,7 @@ function mailchimpSF_request_handler() {
|
|
279 |
wp_die('Cheatin’ huh?');
|
280 |
}
|
281 |
|
282 |
-
// erase API Key
|
283 |
update_option('mc_apikey', '');
|
284 |
break;
|
285 |
case 'update_mc_apikey':
|
@@ -287,7 +287,7 @@ function mailchimpSF_request_handler() {
|
|
287 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_mc_api_key')) {
|
288 |
wp_die('Cheatin’ huh?');
|
289 |
}
|
290 |
-
|
291 |
mailchimpSF_set_api_key(strip_tags(stripslashes($_POST['mc_apikey'])));
|
292 |
break;
|
293 |
case 'reset_list':
|
@@ -295,14 +295,14 @@ function mailchimpSF_request_handler() {
|
|
295 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'reset_mailchimp_list')) {
|
296 |
wp_die('Cheatin’ huh?');
|
297 |
}
|
298 |
-
|
299 |
mailchimpSF_reset_list_settings();
|
300 |
break;
|
301 |
case 'change_form_settings':
|
302 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_general_form_settings')) {
|
303 |
wp_die('Cheatin’ huh?');
|
304 |
}
|
305 |
-
|
306 |
// Update the form settings
|
307 |
mailchimpSF_save_general_form_settings();
|
308 |
break;
|
@@ -311,14 +311,14 @@ function mailchimpSF_request_handler() {
|
|
311 |
if (!wp_verify_nonce($_POST['_mc_submit_signup_form_nonce'], 'mc_submit_signup_form')) {
|
312 |
wp_die('Cheatin’ huh?');
|
313 |
}
|
314 |
-
|
315 |
// Attempt the signup
|
316 |
mailchimpSF_signup_submit();
|
317 |
-
|
318 |
// Do a different action for html vs. js
|
319 |
switch ($_POST['mc_submit_type']) {
|
320 |
case 'html':
|
321 |
-
/* Allow to fall through. The widget will pick up the
|
322 |
* global message left over from the signup_submit function */
|
323 |
break;
|
324 |
case 'js':
|
@@ -335,9 +335,9 @@ add_action('init', 'mailchimpSF_request_handler');
|
|
335 |
|
336 |
/**
|
337 |
* Upgrades data if it needs to. Checks on admin_init
|
338 |
-
*
|
339 |
* @return void
|
340 |
-
*/
|
341 |
function mailchimpSF_upgrade() {
|
342 |
// See if we need an upgrade
|
343 |
if (mailchimpSF_needs_upgrade()) {
|
@@ -349,14 +349,14 @@ function mailchimpSF_upgrade() {
|
|
349 |
add_action('admin_init', 'mailchimpSF_upgrade');
|
350 |
|
351 |
/**
|
352 |
-
* Checks to see if we're storing a password, if so, we need
|
353 |
* to upgrade to the API key
|
354 |
*
|
355 |
* @return bool
|
356 |
**/
|
357 |
function mailchimpSF_needs_upgrade() {
|
358 |
$igs = get_option('mc_interest_groups');
|
359 |
-
|
360 |
if ($igs !== false // we have an option
|
361 |
&& (
|
362 |
empty($igs) || // it can be an empty array (no interest groups)
|
@@ -379,10 +379,10 @@ function mailchimpSF_do_upgrade() {
|
|
379 |
delete_option('mc_password');
|
380 |
$api = new mailchimpSF_MCAPI(get_option('mc_apikey'));
|
381 |
$igs = $api->listInterestGroupings(get_option('mc_list_id'));
|
382 |
-
|
383 |
// If we don't have any interest groups store an empty array, not (bool) false
|
384 |
$igs = !$igs ? array() : $igs;
|
385 |
-
|
386 |
update_option('mc_interest_groups', $igs);
|
387 |
}
|
388 |
|
@@ -410,7 +410,7 @@ function mailchimpSF_set_api_key($api_key = '') {
|
|
410 |
$delete_setup = true;
|
411 |
foreach($lists as $list) {
|
412 |
if ($list['id'] == $cur_list_id) {
|
413 |
-
$list_id = isset($_POST['mc_list_id']) ? $_POST['mc_list_id'] : '';
|
414 |
$delete_setup = false;
|
415 |
}
|
416 |
}
|
@@ -425,8 +425,8 @@ function mailchimpSF_set_api_key($api_key = '') {
|
|
425 |
}
|
426 |
|
427 |
// Set a global message
|
428 |
-
mailchimpSF_global_msg($msg);
|
429 |
-
|
430 |
// If we need to delete our setup, do it
|
431 |
if ($delete_setup){
|
432 |
mailchimpSF_delete_setup();
|
@@ -477,7 +477,7 @@ function mailchimpSF_reset_list_settings() {
|
|
477 |
delete_option('mc_use_javascript');
|
478 |
delete_option('mc_use_unsub_link');
|
479 |
delete_option('mc_use_datepicker');
|
480 |
-
|
481 |
delete_option('mc_header_content');
|
482 |
delete_option('mc_subheader_content');
|
483 |
delete_option('mc_submit_text');
|
@@ -493,7 +493,7 @@ function mailchimpSF_reset_list_settings() {
|
|
493 |
delete_option('mc_form_border_color');
|
494 |
delete_option('mc_form_background');
|
495 |
delete_option('mc_form_text_color');
|
496 |
-
|
497 |
$msg = '<p class="success_msg">'.esc_html(__('Successfully Reset your List selection... Now you get to pick again!', 'mailchimp_i18n')).'</p>';
|
498 |
mailchimpSF_global_msg($msg);
|
499 |
}
|
@@ -505,12 +505,12 @@ function mailchimpSF_reset_list_settings() {
|
|
505 |
**/
|
506 |
function mailchimpSF_global_msg($msg = null) {
|
507 |
global $mcsf_msgs;
|
508 |
-
|
509 |
// Make sure we're formed properly
|
510 |
if (!is_array($mcsf_msgs)) {
|
511 |
$mcsf_msgs = array();
|
512 |
}
|
513 |
-
|
514 |
// See if we're getting
|
515 |
if (is_null($msg)) {
|
516 |
return implode('', $mcsf_msgs);
|
@@ -527,7 +527,7 @@ function mailchimpSF_global_msg($msg = null) {
|
|
527 |
function mailchimpSF_set_form_defaults($list_name = '') {
|
528 |
update_option('mc_header_content',__( 'Sign up for', 'mailchimp_i18n' ).' '.$list_name);
|
529 |
update_option('mc_submit_text',__( 'Subscribe', 'mailchimp_i18n' ));
|
530 |
-
|
531 |
update_option('mc_use_datepicker', 'on');
|
532 |
update_option('mc_custom_style','on');
|
533 |
update_option('mc_use_javascript','on');
|
@@ -536,7 +536,7 @@ function mailchimpSF_set_form_defaults($list_name = '') {
|
|
536 |
update_option('mc_header_border_color','E3E3E3');
|
537 |
update_option('mc_header_background','FFFFFF');
|
538 |
update_option('mc_header_text_color','CC6600');
|
539 |
-
|
540 |
update_option('mc_form_border_width','1');
|
541 |
update_option('mc_form_border_color','C4D3EA');
|
542 |
update_option('mc_form_background','EEF3F8');
|
@@ -567,7 +567,7 @@ function mailchimpSF_save_general_form_settings() {
|
|
567 |
$msg = '<p class="success_msg">'.__('Fancy Javascript submission turned Off!', 'mailchimp_i18n').'</p>';
|
568 |
mailchimpSF_global_msg($msg);
|
569 |
}
|
570 |
-
|
571 |
if (isset($_POST['mc_use_datepicker'])){
|
572 |
update_option('mc_use_datepicker', 'on');
|
573 |
$msg = '<p class="success_msg">'.__('Datepicker turned On!', 'mailchimp_i18n').'</p>';
|
@@ -577,7 +577,7 @@ function mailchimpSF_save_general_form_settings() {
|
|
577 |
$msg = '<p class="success_msg">'.__('Datepicker turned Off!', 'mailchimp_i18n').'</p>';
|
578 |
mailchimpSF_global_msg($msg);
|
579 |
}
|
580 |
-
|
581 |
if (isset($_POST['mc_use_unsub_link'])){
|
582 |
update_option('mc_use_unsub_link', 'on');
|
583 |
$msg = '<p class="success_msg">'.__('Unsubscribe link turned On!', 'mailchimp_i18n').'</p>';
|
@@ -591,7 +591,7 @@ function mailchimpSF_save_general_form_settings() {
|
|
591 |
$content = stripslashes($_POST['mc_header_content']);
|
592 |
$content = str_replace("\r\n","<br/>", $content);
|
593 |
update_option('mc_header_content', $content );
|
594 |
-
|
595 |
$content = stripslashes($_POST['mc_subheader_content']);
|
596 |
$content = str_replace("\r\n","<br/>", $content);
|
597 |
update_option('mc_subheader_content', $content );
|
@@ -600,7 +600,7 @@ function mailchimpSF_save_general_form_settings() {
|
|
600 |
$submit_text = stripslashes($_POST['mc_submit_text']);
|
601 |
$submit_text = str_replace("\r\n","", $submit_text);
|
602 |
update_option('mc_submit_text', $submit_text);
|
603 |
-
|
604 |
// Set Custom Style option
|
605 |
update_option('mc_custom_style', isset($_POST['mc_custom_style']) ? 'on' : 'off');
|
606 |
|
@@ -648,38 +648,38 @@ function mailchimpSF_save_general_form_settings() {
|
|
648 |
function mailchimpSF_change_list_if_necessary($api_key) {
|
649 |
// Simple permission check before going through all this
|
650 |
if (!current_user_can(MCSF_CAP_THRESHOLD)) { return; }
|
651 |
-
|
652 |
$api = new mailchimpSF_MCAPI($api_key);
|
653 |
//we *could* support paging, but few users have that many lists (and shouldn't)
|
654 |
$lists = $api->lists(array(),0,100);
|
655 |
$lists = $lists['data'];
|
656 |
-
|
657 |
if (is_array($lists) && !empty($lists) && isset($_POST['mc_list_id'])) {
|
658 |
-
|
659 |
/* If our incoming list ID (the one chosen in the select dropdown)
|
660 |
is in our array of lists, the set it to be the active list */
|
661 |
-
foreach($lists as $key => $list) {
|
662 |
if ($list['id'] == $_POST['mc_list_id']) {
|
663 |
-
$list_id = $_POST['mc_list_id'];
|
664 |
-
$list_name = $list['name'];
|
665 |
$list_key = $key;
|
666 |
}
|
667 |
}
|
668 |
-
|
669 |
$orig_list = get_option('mc_list_id');
|
670 |
if ($list_id != '') {
|
671 |
update_option('mc_list_id', $list_id);
|
672 |
update_option('mc_list_name', $list_name);
|
673 |
update_option('mc_email_type_option', $lists[$list_key]['email_type_option']);
|
674 |
|
675 |
-
|
676 |
// See if the user changed the list
|
677 |
if ($orig_list != $list_id){
|
678 |
// The user changed the list, Reset the Form Defaults
|
679 |
mailchimpSF_set_form_defaults($list_name);
|
680 |
}
|
681 |
// email_type_option
|
682 |
-
|
683 |
// Grab the merge vars and interest groups
|
684 |
$mv = $api->listMergeVars($list_id);
|
685 |
$igs = $api->listInterestGroupings($list_id);
|
@@ -706,7 +706,7 @@ function mailchimpSF_change_list_if_necessary($api_key) {
|
|
706 |
if (is_array($igs)) {
|
707 |
$igs_text .= sprintf(__('and %s Sets of Interest Groups', 'mailchimp_i18n'), count($igs));
|
708 |
}
|
709 |
-
|
710 |
$msg = '<p class="success_msg">'.
|
711 |
sprintf(
|
712 |
__('Success! Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n').$igs_text,
|
@@ -756,19 +756,19 @@ if (get_option('mc_apikey') == '') {
|
|
756 |
<form method="post" action="options-general.php?page=mailchimpSF_options">
|
757 |
<h3><?php esc_html_e('Login Info', 'mailchimp_i18n');?></h3>
|
758 |
<?php esc_html_e('To start using the MailChimp plugin, we first need to login and get your API Key. Please enter your MailChimp API Key below.', 'mailchimp_i18n'); ?>
|
759 |
-
|
760 |
<br/>
|
761 |
-
|
762 |
-
<?php
|
763 |
echo sprintf(
|
764 |
-
'%1$s <a href="http://www.mailchimp.com/signup/" target="_blank">%2$s</a>',
|
765 |
-
esc_html(__("Don't have a MailChimp account?", 'mailchimp_i18n')),
|
766 |
esc_html(__('Try one for Free!', 'mailchimp_i18n'))
|
767 |
-
);
|
768 |
?>
|
769 |
-
|
770 |
<br/>
|
771 |
-
|
772 |
<table class="form-table">
|
773 |
<tr valign="top">
|
774 |
<th scope="row"><?php esc_html_e('API Key', 'mailchimp_i18n'); ?>:</th>
|
@@ -779,14 +779,14 @@ if (get_option('mc_apikey') == '') {
|
|
779 |
</td>
|
780 |
</tr>
|
781 |
</table>
|
782 |
-
|
783 |
<input type="hidden" name="mcsf_action" value="update_mc_apikey"/>
|
784 |
<input type="submit" name="Submit" value="<?php esc_attr_e('Save & Check', 'mailchimp_i18n');?>" class="button" />
|
785 |
<?php wp_nonce_field('update_mc_api_key', '_mcsf_nonce_action'); ?>
|
786 |
</form>
|
787 |
</div>
|
788 |
|
789 |
-
<?php
|
790 |
if (get_option('mc_username')!=''){
|
791 |
?>
|
792 |
<strong><?php esc_html_e('Notes', 'mailchimp_i18n'); ?>:</strong>
|
@@ -827,7 +827,7 @@ if (get_option('mc_apikey') == '') return;
|
|
827 |
if (get_option('mc_apikey')!=''){
|
828 |
?>
|
829 |
<h3><?php esc_html_e('Your Lists', 'mailchimp_i18n'); ?></h3>
|
830 |
-
|
831 |
<div>
|
832 |
|
833 |
<p><?php esc_html_e('Please select the List you wish to create a Signup Form for.', 'mailchimp_i18n'); ?></p>
|
@@ -842,11 +842,11 @@ if (get_option('mc_apikey')!=''){
|
|
842 |
if (count($lists) == 0) {
|
843 |
?>
|
844 |
<span class='error_msg'>
|
845 |
-
<?php
|
846 |
echo sprintf(
|
847 |
esc_html(__("Uh-oh, you don't have any lists defined! Please visit %s, login, and setup a list before using this tool!", 'mailchimp_i18n')),
|
848 |
"<a href='http://www.mailchimp.com/'>MailChimp</a>"
|
849 |
-
);
|
850 |
?>
|
851 |
</span>
|
852 |
<?php
|
@@ -888,7 +888,7 @@ if (get_option('mc_apikey')!=''){
|
|
888 |
<br/>
|
889 |
|
890 |
<?php
|
891 |
-
}
|
892 |
else {
|
893 |
//display the selected list...
|
894 |
?>
|
@@ -949,7 +949,7 @@ if (get_option('mc_list_id') == '') return;
|
|
949 |
<em><?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?></em>
|
950 |
</td>
|
951 |
</tr>
|
952 |
-
|
953 |
<tr valign="top">
|
954 |
<th scope="row"><?php esc_html_e('Sub-header content', 'mailchimp_i18n'); ?>:</th>
|
955 |
<td>
|
@@ -986,7 +986,7 @@ if (get_option('mc_list_id') == '') return;
|
|
986 |
<tr><th><?php esc_html_e('Background Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_header_background" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_header_background')); ?>"/><br/>
|
987 |
<em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
|
988 |
</td></tr>
|
989 |
-
|
990 |
<tr><th colspan="2"><?php esc_html_e('Form Settings', 'mailchimp_i18n'); ?>:</th></tr>
|
991 |
<tr><th><?php esc_html_e('Border Width', 'mailchimp_i18n'); ?>:</th><td><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo esc_attr(get_option('mc_form_border_width')); ?>"/> px<br/>
|
992 |
<em><?php esc_html_e('Set to 0 for no border, do not enter', 'mailchimp_i18n'); ?> <strong>px</strong>!</em>
|
@@ -1023,7 +1023,7 @@ if (count($mv) == 0 || !is_array($mv)){
|
|
1023 |
<?php
|
1024 |
} else {
|
1025 |
?>
|
1026 |
-
|
1027 |
<table class='widefat'>
|
1028 |
<tr valign="top">
|
1029 |
<th><?php esc_html_e('Name', 'mailchimp_i18n');?></th>
|
@@ -1149,8 +1149,8 @@ add_shortcode('mailchimpsf_form', 'mailchimpSF_shortcode');
|
|
1149 |
|
1150 |
/**
|
1151 |
* Attempts to signup a user, per the $_POST args.
|
1152 |
-
*
|
1153 |
-
* This sets a global message, that is then used in the widget
|
1154 |
* output to retrieve and display that message.
|
1155 |
*
|
1156 |
* @return bool
|
@@ -1158,20 +1158,20 @@ add_shortcode('mailchimpsf_form', 'mailchimpSF_shortcode');
|
|
1158 |
function mailchimpSF_signup_submit() {
|
1159 |
$mv = get_option('mc_merge_vars', array());
|
1160 |
$mv_tag_keys = array();
|
1161 |
-
|
1162 |
$igs = get_option('mc_interest_groups', array());
|
1163 |
-
|
1164 |
$success = true;
|
1165 |
$listId = get_option('mc_list_id');
|
1166 |
$email = isset($_POST['mc_mv_EMAIL']) ? strip_tags(stripslashes($_POST['mc_mv_EMAIL'])) : '';
|
1167 |
-
$merge = $errs = array(); // Set up some vars
|
1168 |
-
|
1169 |
// Loop through our Merge Vars, and if they're empty, but required, then print an error, and mark as failed
|
1170 |
foreach($mv as $var) {
|
1171 |
$opt = 'mc_mv_'.$var['tag'];
|
1172 |
-
|
1173 |
$opt_val = isset($_POST[$opt]) ? $_POST[$opt] : '';
|
1174 |
-
|
1175 |
if (is_array($opt_val) && isset($opt_val['area'])) {
|
1176 |
$opt_val = implode('-', $opt_val);
|
1177 |
}
|
@@ -1188,7 +1188,7 @@ function mailchimpSF_signup_submit() {
|
|
1188 |
else if (is_array($opt_val)) {
|
1189 |
$opt_val = implode($opt_val);
|
1190 |
}
|
1191 |
-
|
1192 |
if ($var['req'] == 'Y' && trim($opt_val) == '') {
|
1193 |
$success = false;
|
1194 |
$errs[] = sprintf(__("You must fill in %s.", 'mailchimp_i18n'), esc_html($var['name']));
|
@@ -1198,15 +1198,15 @@ function mailchimpSF_signup_submit() {
|
|
1198 |
$merge[$var['tag']] = $opt_val;
|
1199 |
}
|
1200 |
}
|
1201 |
-
|
1202 |
// We also want to create an array where the keys are the tags for easier validation later
|
1203 |
$mv_tag_keys[$var['tag']] = $var;
|
1204 |
|
1205 |
}
|
1206 |
-
|
1207 |
// Head back to the beginning of the merge vars array
|
1208 |
reset($mv);
|
1209 |
-
|
1210 |
// Ensure we have an array
|
1211 |
$igs = !is_array($igs) ? array() : $igs;
|
1212 |
foreach ($igs as $ig) {
|
@@ -1237,7 +1237,7 @@ function mailchimpSF_signup_submit() {
|
|
1237 |
);
|
1238 |
}
|
1239 |
break;
|
1240 |
-
default:
|
1241 |
// Nothing
|
1242 |
break;
|
1243 |
}
|
@@ -1251,7 +1251,7 @@ function mailchimpSF_signup_submit() {
|
|
1251 |
}
|
1252 |
|
1253 |
// If we're good
|
1254 |
-
if ($success) {
|
1255 |
// Clear out empty merge vars
|
1256 |
foreach ($merge as $k => $v) {
|
1257 |
if (is_array($v) && empty($v)) {
|
@@ -1261,7 +1261,7 @@ function mailchimpSF_signup_submit() {
|
|
1261 |
unset($merge[$k]);
|
1262 |
}
|
1263 |
}
|
1264 |
-
|
1265 |
// If we have an empty $merge, then assign empty string.
|
1266 |
if (count($merge) == 0 || $merge == '') {
|
1267 |
$merge = '';
|
@@ -1288,10 +1288,10 @@ function mailchimpSF_signup_submit() {
|
|
1288 |
}
|
1289 |
}
|
1290 |
break;
|
1291 |
-
|
1292 |
default:
|
1293 |
break;
|
1294 |
-
}
|
1295 |
}
|
1296 |
}
|
1297 |
}
|
@@ -1300,24 +1300,36 @@ function mailchimpSF_signup_submit() {
|
|
1300 |
$retval = $api->listSubscribe( $listId, $email, $merge, $email_type);
|
1301 |
if (!$retval) {
|
1302 |
switch($api->errorCode) {
|
1303 |
-
case '105' :
|
1304 |
-
$errs[] = __("Please try again later", 'mailchimp_i18n').'.';
|
1305 |
break;
|
1306 |
-
case '214' :
|
1307 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1308 |
break;
|
1309 |
-
case '250' :
|
1310 |
-
list($field, $rest) = explode(' ', $api->errorMessage, 2);
|
1311 |
$errs[] = sprintf(__("You must fill in %s.", 'mailchimp_i18n'), esc_html($mv_tag_keys[$field]['name']));
|
1312 |
break;
|
1313 |
-
case '254' :
|
1314 |
list($i1, $i2, $i3, $field, $rest) = explode(' ',$api->errorMessage,5);
|
1315 |
$errs[] = sprintf(__("%s has invalid content.", 'mailchimp_i18n'), esc_html($mv_tag_keys[$field]['name']));
|
1316 |
break;
|
1317 |
-
case '270' :
|
1318 |
$errs[] = __("An invalid Interest Group was selected", 'mailchimp_i18n').'.';
|
1319 |
break;
|
1320 |
-
case '502' :
|
1321 |
$errs[] = __("That email address is invalid", 'mailchimp_i18n').'.';
|
1322 |
break;
|
1323 |
default:
|
@@ -1328,22 +1340,25 @@ function mailchimpSF_signup_submit() {
|
|
1328 |
}
|
1329 |
}
|
1330 |
}
|
1331 |
-
|
1332 |
// If we have errors, then show them
|
1333 |
if (count($errs) > 0) {
|
1334 |
$msg = '<span class="mc_error_msg">';
|
1335 |
-
foreach($errs as $error){
|
1336 |
-
|
|
|
|
|
|
|
1337 |
}
|
1338 |
$msg .= '</span>';
|
1339 |
}
|
1340 |
else {
|
1341 |
$msg = "<strong class='mc_success_msg'>".esc_html(__("Success, you've been signed up! Please look for our confirmation email!", 'mailchimp_i18n'))."</strong>";
|
1342 |
}
|
1343 |
-
|
1344 |
// Set our global message
|
1345 |
mailchimpSF_global_msg($msg);
|
1346 |
-
|
1347 |
return $success;
|
1348 |
}
|
1349 |
|
@@ -1354,7 +1369,7 @@ function mailchimpSF_signup_submit() {
|
|
1354 |
**********************/
|
1355 |
/**
|
1356 |
* Utility function to allow placement of plugin in plugins, mu-plugins, child or parent theme's plugins folders
|
1357 |
-
*
|
1358 |
* This function must be ran _very early_ in the load process, as it sets up important constants for the rest of the plugin
|
1359 |
*/
|
1360 |
function mailchimpSF_where_am_i() {
|
@@ -1392,14 +1407,14 @@ function mailchimpSF_where_am_i() {
|
|
1392 |
break;
|
1393 |
}
|
1394 |
}
|
1395 |
-
|
1396 |
// Define our complete filesystem path
|
1397 |
define('MCSF_DIR', $mscf_dir);
|
1398 |
-
|
1399 |
-
/* Lang location needs to be relative *from* ABSPATH,
|
1400 |
so strip it out of our language dir location */
|
1401 |
-
define('MCSF_LANG_DIR', trailingslashit(MCSF_DIR).'po/');
|
1402 |
-
|
1403 |
// Define our complete URL to the plugin folder
|
1404 |
define('MCSF_URL', $mscf_url);
|
1405 |
}
|
3 |
Plugin Name: MailChimp
|
4 |
Plugin URI: http://www.mailchimp.com/plugins/mailchimp-wordpress-plugin/
|
5 |
Description: The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list.
|
6 |
+
Version: 1.2.14
|
7 |
Author: MailChimp and Crowd Favorite
|
8 |
Author URI: http://mailchimp.com/api/
|
9 |
*/
|
25 |
*/
|
26 |
|
27 |
// Version constant for easy CSS refreshes
|
28 |
+
define('MCSF_VER', '1.2.14');
|
29 |
|
30 |
// What's our permission (capability) threshold
|
31 |
define('MCSF_CAP_THRESHOLD', 'manage_options');
|
57 |
$textdomain = 'mailchimp_i18n';
|
58 |
$locale = apply_filters( 'plugin_locale', get_locale(), $textdomain);
|
59 |
load_textdomain('mailchimp_i18n', MCSF_LANG_DIR.$textdomain.'-'.$locale.'.mo');
|
60 |
+
|
61 |
+
// Bring in our appropriate JS and CSS resources
|
62 |
mailchimpSF_load_resources();
|
63 |
}
|
64 |
add_action( 'init', 'mailchimpSF_plugin_init' );
|
79 |
add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'mailchimpSD_plugin_action_links', 10, 1);
|
80 |
|
81 |
/**
|
82 |
+
* Loads the appropriate JS and CSS resources depending on
|
83 |
* settings and context (admin or not)
|
84 |
*
|
85 |
* @return void
|
97 |
));
|
98 |
}
|
99 |
}
|
100 |
+
|
101 |
if (get_option('mc_use_datepicker') == 'on' && !is_admin()) {
|
102 |
// Datepicker theme
|
103 |
wp_enqueue_style('flick', MCSF_URL.'/css/flick/flick.css');
|
104 |
// Datepicker JS
|
105 |
wp_enqueue_script('datepicker', MCSF_URL.'/js/datepicker.js', array('jquery','jquery-ui-core'));
|
106 |
}
|
107 |
+
|
108 |
wp_enqueue_style('mailchimpSF_main_css', home_url('?mcsf_action=main_css&ver='.MCSF_VER));
|
109 |
wp_enqueue_style('mailchimpSF_ie_css', MCSF_URL.'css/ie.css');
|
110 |
global $wp_styles;
|
137 |
changeYear: true,
|
138 |
beforeShow: function(input, inst) { $('#ui-datepicker-div').addClass('show'); },
|
139 |
dateFormat: 'yy/mm/dd',
|
140 |
+
});
|
141 |
+
|
142 |
d = new Date();
|
143 |
$('.birthdate-pick').datepicker({
|
144 |
autoFocusNextInput: true,
|
150 |
beforeShow: function(input, inst) { $('#ui-datepicker-div').removeClass('show'); },
|
151 |
dateFormat: 'mm/dd',
|
152 |
});
|
153 |
+
|
154 |
+
|
155 |
});
|
156 |
</script>
|
157 |
+
<?php
|
158 |
}
|
159 |
if (get_option('mc_use_datepicker') == 'on' && !is_admin()) {
|
160 |
add_action('wp_head', 'mc_datepicker_load');
|
178 |
|
179 |
/**
|
180 |
* Outputs the front-end CSS. This checks several options, so it
|
181 |
+
* was best to put it in a Request-handled script, as opposed to
|
182 |
* a static file.
|
183 |
*/
|
184 |
function mailchimpSF_main_css() {
|
185 |
?>
|
186 |
+
.mc_error_msg {
|
187 |
color: red;
|
188 |
}
|
189 |
.mc_success_msg {
|
190 |
color: green;
|
191 |
}
|
192 |
+
.mc_merge_var{
|
193 |
padding:0;
|
194 |
margin:0;
|
195 |
}
|
197 |
// If we're utilizing custom styles
|
198 |
if (get_option('mc_custom_style')=='on'){
|
199 |
?>
|
200 |
+
#mc_signup_form {
|
201 |
padding:5px;
|
202 |
border-width: <?php echo get_option('mc_form_border_width'); ?>px;
|
203 |
border-style: <?php echo (get_option('mc_form_border_width')==0) ? 'none' : 'solid'; ?>;
|
205 |
color: #<?php echo get_option('mc_form_text_color'); ?>;
|
206 |
background-color: #<?php echo get_option('mc_form_background'); ?>;
|
207 |
}
|
208 |
+
|
209 |
+
|
210 |
.mc_custom_border_hdr {
|
211 |
border-width: <?php echo get_option('mc_header_border_width'); ?>px;
|
212 |
border-style: <?php echo (get_option('mc_header_border_width')==0) ? 'none' : 'solid'; ?>;
|
224 |
#mc_signup_form {}
|
225 |
#mc_signup_form .mc_var_label {}
|
226 |
#mc_signup_form .mc_input {}
|
227 |
+
#mc-indicates-required {
|
228 |
width:100%;
|
229 |
}
|
230 |
#mc_display_rewards {}
|
231 |
+
.mc_interests_header {
|
232 |
font-weight:bold;
|
233 |
}
|
234 |
div.mc_interest{
|
236 |
}
|
237 |
#mc_signup_form input.mc_interest {}
|
238 |
#mc_signup_form select {}
|
239 |
+
#mc_signup_form label.mc_interest_label {
|
240 |
display:inline;
|
241 |
}
|
242 |
+
.mc_signup_submit {
|
243 |
+
text-align:center;
|
244 |
}
|
245 |
ul.mc_list {
|
246 |
list-style-type: none;
|
266 |
*/
|
267 |
function mailchimpSF_add_pages(){
|
268 |
// Add settings page for users who can edit plugins
|
269 |
+
add_options_page( __( 'MailChimp Setup', 'mailchimp_i18n' ), __( 'MailChimp Setup', 'mailchimp_i18n' ), MCSF_CAP_THRESHOLD, 'mailchimpSF_options', 'mailchimpSF_setup_page');
|
270 |
}
|
271 |
add_action('admin_menu', 'mailchimpSF_add_pages');
|
272 |
|
279 |
wp_die('Cheatin’ huh?');
|
280 |
}
|
281 |
|
282 |
+
// erase API Key
|
283 |
update_option('mc_apikey', '');
|
284 |
break;
|
285 |
case 'update_mc_apikey':
|
287 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_mc_api_key')) {
|
288 |
wp_die('Cheatin’ huh?');
|
289 |
}
|
290 |
+
|
291 |
mailchimpSF_set_api_key(strip_tags(stripslashes($_POST['mc_apikey'])));
|
292 |
break;
|
293 |
case 'reset_list':
|
295 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'reset_mailchimp_list')) {
|
296 |
wp_die('Cheatin’ huh?');
|
297 |
}
|
298 |
+
|
299 |
mailchimpSF_reset_list_settings();
|
300 |
break;
|
301 |
case 'change_form_settings':
|
302 |
if (!current_user_can(MCSF_CAP_THRESHOLD) || !wp_verify_nonce($_POST['_mcsf_nonce_action'], 'update_general_form_settings')) {
|
303 |
wp_die('Cheatin’ huh?');
|
304 |
}
|
305 |
+
|
306 |
// Update the form settings
|
307 |
mailchimpSF_save_general_form_settings();
|
308 |
break;
|
311 |
if (!wp_verify_nonce($_POST['_mc_submit_signup_form_nonce'], 'mc_submit_signup_form')) {
|
312 |
wp_die('Cheatin’ huh?');
|
313 |
}
|
314 |
+
|
315 |
// Attempt the signup
|
316 |
mailchimpSF_signup_submit();
|
317 |
+
|
318 |
// Do a different action for html vs. js
|
319 |
switch ($_POST['mc_submit_type']) {
|
320 |
case 'html':
|
321 |
+
/* Allow to fall through. The widget will pick up the
|
322 |
* global message left over from the signup_submit function */
|
323 |
break;
|
324 |
case 'js':
|
335 |
|
336 |
/**
|
337 |
* Upgrades data if it needs to. Checks on admin_init
|
338 |
+
*
|
339 |
* @return void
|
340 |
+
*/
|
341 |
function mailchimpSF_upgrade() {
|
342 |
// See if we need an upgrade
|
343 |
if (mailchimpSF_needs_upgrade()) {
|
349 |
add_action('admin_init', 'mailchimpSF_upgrade');
|
350 |
|
351 |
/**
|
352 |
+
* Checks to see if we're storing a password, if so, we need
|
353 |
* to upgrade to the API key
|
354 |
*
|
355 |
* @return bool
|
356 |
**/
|
357 |
function mailchimpSF_needs_upgrade() {
|
358 |
$igs = get_option('mc_interest_groups');
|
359 |
+
|
360 |
if ($igs !== false // we have an option
|
361 |
&& (
|
362 |
empty($igs) || // it can be an empty array (no interest groups)
|
379 |
delete_option('mc_password');
|
380 |
$api = new mailchimpSF_MCAPI(get_option('mc_apikey'));
|
381 |
$igs = $api->listInterestGroupings(get_option('mc_list_id'));
|
382 |
+
|
383 |
// If we don't have any interest groups store an empty array, not (bool) false
|
384 |
$igs = !$igs ? array() : $igs;
|
385 |
+
|
386 |
update_option('mc_interest_groups', $igs);
|
387 |
}
|
388 |
|
410 |
$delete_setup = true;
|
411 |
foreach($lists as $list) {
|
412 |
if ($list['id'] == $cur_list_id) {
|
413 |
+
$list_id = isset($_POST['mc_list_id']) ? $_POST['mc_list_id'] : '';
|
414 |
$delete_setup = false;
|
415 |
}
|
416 |
}
|
425 |
}
|
426 |
|
427 |
// Set a global message
|
428 |
+
mailchimpSF_global_msg($msg);
|
429 |
+
|
430 |
// If we need to delete our setup, do it
|
431 |
if ($delete_setup){
|
432 |
mailchimpSF_delete_setup();
|
477 |
delete_option('mc_use_javascript');
|
478 |
delete_option('mc_use_unsub_link');
|
479 |
delete_option('mc_use_datepicker');
|
480 |
+
|
481 |
delete_option('mc_header_content');
|
482 |
delete_option('mc_subheader_content');
|
483 |
delete_option('mc_submit_text');
|
493 |
delete_option('mc_form_border_color');
|
494 |
delete_option('mc_form_background');
|
495 |
delete_option('mc_form_text_color');
|
496 |
+
|
497 |
$msg = '<p class="success_msg">'.esc_html(__('Successfully Reset your List selection... Now you get to pick again!', 'mailchimp_i18n')).'</p>';
|
498 |
mailchimpSF_global_msg($msg);
|
499 |
}
|
505 |
**/
|
506 |
function mailchimpSF_global_msg($msg = null) {
|
507 |
global $mcsf_msgs;
|
508 |
+
|
509 |
// Make sure we're formed properly
|
510 |
if (!is_array($mcsf_msgs)) {
|
511 |
$mcsf_msgs = array();
|
512 |
}
|
513 |
+
|
514 |
// See if we're getting
|
515 |
if (is_null($msg)) {
|
516 |
return implode('', $mcsf_msgs);
|
527 |
function mailchimpSF_set_form_defaults($list_name = '') {
|
528 |
update_option('mc_header_content',__( 'Sign up for', 'mailchimp_i18n' ).' '.$list_name);
|
529 |
update_option('mc_submit_text',__( 'Subscribe', 'mailchimp_i18n' ));
|
530 |
+
|
531 |
update_option('mc_use_datepicker', 'on');
|
532 |
update_option('mc_custom_style','on');
|
533 |
update_option('mc_use_javascript','on');
|
536 |
update_option('mc_header_border_color','E3E3E3');
|
537 |
update_option('mc_header_background','FFFFFF');
|
538 |
update_option('mc_header_text_color','CC6600');
|
539 |
+
|
540 |
update_option('mc_form_border_width','1');
|
541 |
update_option('mc_form_border_color','C4D3EA');
|
542 |
update_option('mc_form_background','EEF3F8');
|
567 |
$msg = '<p class="success_msg">'.__('Fancy Javascript submission turned Off!', 'mailchimp_i18n').'</p>';
|
568 |
mailchimpSF_global_msg($msg);
|
569 |
}
|
570 |
+
|
571 |
if (isset($_POST['mc_use_datepicker'])){
|
572 |
update_option('mc_use_datepicker', 'on');
|
573 |
$msg = '<p class="success_msg">'.__('Datepicker turned On!', 'mailchimp_i18n').'</p>';
|
577 |
$msg = '<p class="success_msg">'.__('Datepicker turned Off!', 'mailchimp_i18n').'</p>';
|
578 |
mailchimpSF_global_msg($msg);
|
579 |
}
|
580 |
+
|
581 |
if (isset($_POST['mc_use_unsub_link'])){
|
582 |
update_option('mc_use_unsub_link', 'on');
|
583 |
$msg = '<p class="success_msg">'.__('Unsubscribe link turned On!', 'mailchimp_i18n').'</p>';
|
591 |
$content = stripslashes($_POST['mc_header_content']);
|
592 |
$content = str_replace("\r\n","<br/>", $content);
|
593 |
update_option('mc_header_content', $content );
|
594 |
+
|
595 |
$content = stripslashes($_POST['mc_subheader_content']);
|
596 |
$content = str_replace("\r\n","<br/>", $content);
|
597 |
update_option('mc_subheader_content', $content );
|
600 |
$submit_text = stripslashes($_POST['mc_submit_text']);
|
601 |
$submit_text = str_replace("\r\n","", $submit_text);
|
602 |
update_option('mc_submit_text', $submit_text);
|
603 |
+
|
604 |
// Set Custom Style option
|
605 |
update_option('mc_custom_style', isset($_POST['mc_custom_style']) ? 'on' : 'off');
|
606 |
|
648 |
function mailchimpSF_change_list_if_necessary($api_key) {
|
649 |
// Simple permission check before going through all this
|
650 |
if (!current_user_can(MCSF_CAP_THRESHOLD)) { return; }
|
651 |
+
|
652 |
$api = new mailchimpSF_MCAPI($api_key);
|
653 |
//we *could* support paging, but few users have that many lists (and shouldn't)
|
654 |
$lists = $api->lists(array(),0,100);
|
655 |
$lists = $lists['data'];
|
656 |
+
|
657 |
if (is_array($lists) && !empty($lists) && isset($_POST['mc_list_id'])) {
|
658 |
+
|
659 |
/* If our incoming list ID (the one chosen in the select dropdown)
|
660 |
is in our array of lists, the set it to be the active list */
|
661 |
+
foreach($lists as $key => $list) {
|
662 |
if ($list['id'] == $_POST['mc_list_id']) {
|
663 |
+
$list_id = $_POST['mc_list_id'];
|
664 |
+
$list_name = $list['name'];
|
665 |
$list_key = $key;
|
666 |
}
|
667 |
}
|
668 |
+
|
669 |
$orig_list = get_option('mc_list_id');
|
670 |
if ($list_id != '') {
|
671 |
update_option('mc_list_id', $list_id);
|
672 |
update_option('mc_list_name', $list_name);
|
673 |
update_option('mc_email_type_option', $lists[$list_key]['email_type_option']);
|
674 |
|
675 |
+
|
676 |
// See if the user changed the list
|
677 |
if ($orig_list != $list_id){
|
678 |
// The user changed the list, Reset the Form Defaults
|
679 |
mailchimpSF_set_form_defaults($list_name);
|
680 |
}
|
681 |
// email_type_option
|
682 |
+
|
683 |
// Grab the merge vars and interest groups
|
684 |
$mv = $api->listMergeVars($list_id);
|
685 |
$igs = $api->listInterestGroupings($list_id);
|
706 |
if (is_array($igs)) {
|
707 |
$igs_text .= sprintf(__('and %s Sets of Interest Groups', 'mailchimp_i18n'), count($igs));
|
708 |
}
|
709 |
+
|
710 |
$msg = '<p class="success_msg">'.
|
711 |
sprintf(
|
712 |
__('Success! Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n').$igs_text,
|
756 |
<form method="post" action="options-general.php?page=mailchimpSF_options">
|
757 |
<h3><?php esc_html_e('Login Info', 'mailchimp_i18n');?></h3>
|
758 |
<?php esc_html_e('To start using the MailChimp plugin, we first need to login and get your API Key. Please enter your MailChimp API Key below.', 'mailchimp_i18n'); ?>
|
759 |
+
|
760 |
<br/>
|
761 |
+
|
762 |
+
<?php
|
763 |
echo sprintf(
|
764 |
+
'%1$s <a href="http://www.mailchimp.com/signup/" target="_blank">%2$s</a>',
|
765 |
+
esc_html(__("Don't have a MailChimp account?", 'mailchimp_i18n')),
|
766 |
esc_html(__('Try one for Free!', 'mailchimp_i18n'))
|
767 |
+
);
|
768 |
?>
|
769 |
+
|
770 |
<br/>
|
771 |
+
|
772 |
<table class="form-table">
|
773 |
<tr valign="top">
|
774 |
<th scope="row"><?php esc_html_e('API Key', 'mailchimp_i18n'); ?>:</th>
|
779 |
</td>
|
780 |
</tr>
|
781 |
</table>
|
782 |
+
|
783 |
<input type="hidden" name="mcsf_action" value="update_mc_apikey"/>
|
784 |
<input type="submit" name="Submit" value="<?php esc_attr_e('Save & Check', 'mailchimp_i18n');?>" class="button" />
|
785 |
<?php wp_nonce_field('update_mc_api_key', '_mcsf_nonce_action'); ?>
|
786 |
</form>
|
787 |
</div>
|
788 |
|
789 |
+
<?php
|
790 |
if (get_option('mc_username')!=''){
|
791 |
?>
|
792 |
<strong><?php esc_html_e('Notes', 'mailchimp_i18n'); ?>:</strong>
|
827 |
if (get_option('mc_apikey')!=''){
|
828 |
?>
|
829 |
<h3><?php esc_html_e('Your Lists', 'mailchimp_i18n'); ?></h3>
|
830 |
+
|
831 |
<div>
|
832 |
|
833 |
<p><?php esc_html_e('Please select the List you wish to create a Signup Form for.', 'mailchimp_i18n'); ?></p>
|
842 |
if (count($lists) == 0) {
|
843 |
?>
|
844 |
<span class='error_msg'>
|
845 |
+
<?php
|
846 |
echo sprintf(
|
847 |
esc_html(__("Uh-oh, you don't have any lists defined! Please visit %s, login, and setup a list before using this tool!", 'mailchimp_i18n')),
|
848 |
"<a href='http://www.mailchimp.com/'>MailChimp</a>"
|
849 |
+
);
|
850 |
?>
|
851 |
</span>
|
852 |
<?php
|
888 |
<br/>
|
889 |
|
890 |
<?php
|
891 |
+
}
|
892 |
else {
|
893 |
//display the selected list...
|
894 |
?>
|
949 |
<em><?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?></em>
|
950 |
</td>
|
951 |
</tr>
|
952 |
+
|
953 |
<tr valign="top">
|
954 |
<th scope="row"><?php esc_html_e('Sub-header content', 'mailchimp_i18n'); ?>:</th>
|
955 |
<td>
|
986 |
<tr><th><?php esc_html_e('Background Color', 'mailchimp_i18n'); ?>:</th><td>#<input type="text" name="mc_header_background" size="7" maxlength="6" value="<?php echo esc_attr(get_option('mc_header_background')); ?>"/><br/>
|
987 |
<em><?php esc_html_e('do not enter initial', 'mailchimp_i18n'); ?> <strong>#</strong></em>
|
988 |
</td></tr>
|
989 |
+
|
990 |
<tr><th colspan="2"><?php esc_html_e('Form Settings', 'mailchimp_i18n'); ?>:</th></tr>
|
991 |
<tr><th><?php esc_html_e('Border Width', 'mailchimp_i18n'); ?>:</th><td><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo esc_attr(get_option('mc_form_border_width')); ?>"/> px<br/>
|
992 |
<em><?php esc_html_e('Set to 0 for no border, do not enter', 'mailchimp_i18n'); ?> <strong>px</strong>!</em>
|
1023 |
<?php
|
1024 |
} else {
|
1025 |
?>
|
1026 |
+
|
1027 |
<table class='widefat'>
|
1028 |
<tr valign="top">
|
1029 |
<th><?php esc_html_e('Name', 'mailchimp_i18n');?></th>
|
1149 |
|
1150 |
/**
|
1151 |
* Attempts to signup a user, per the $_POST args.
|
1152 |
+
*
|
1153 |
+
* This sets a global message, that is then used in the widget
|
1154 |
* output to retrieve and display that message.
|
1155 |
*
|
1156 |
* @return bool
|
1158 |
function mailchimpSF_signup_submit() {
|
1159 |
$mv = get_option('mc_merge_vars', array());
|
1160 |
$mv_tag_keys = array();
|
1161 |
+
|
1162 |
$igs = get_option('mc_interest_groups', array());
|
1163 |
+
|
1164 |
$success = true;
|
1165 |
$listId = get_option('mc_list_id');
|
1166 |
$email = isset($_POST['mc_mv_EMAIL']) ? strip_tags(stripslashes($_POST['mc_mv_EMAIL'])) : '';
|
1167 |
+
$merge = $errs = $html_errs = array(); // Set up some vars
|
1168 |
+
|
1169 |
// Loop through our Merge Vars, and if they're empty, but required, then print an error, and mark as failed
|
1170 |
foreach($mv as $var) {
|
1171 |
$opt = 'mc_mv_'.$var['tag'];
|
1172 |
+
|
1173 |
$opt_val = isset($_POST[$opt]) ? $_POST[$opt] : '';
|
1174 |
+
|
1175 |
if (is_array($opt_val) && isset($opt_val['area'])) {
|
1176 |
$opt_val = implode('-', $opt_val);
|
1177 |
}
|
1188 |
else if (is_array($opt_val)) {
|
1189 |
$opt_val = implode($opt_val);
|
1190 |
}
|
1191 |
+
|
1192 |
if ($var['req'] == 'Y' && trim($opt_val) == '') {
|
1193 |
$success = false;
|
1194 |
$errs[] = sprintf(__("You must fill in %s.", 'mailchimp_i18n'), esc_html($var['name']));
|
1198 |
$merge[$var['tag']] = $opt_val;
|
1199 |
}
|
1200 |
}
|
1201 |
+
|
1202 |
// We also want to create an array where the keys are the tags for easier validation later
|
1203 |
$mv_tag_keys[$var['tag']] = $var;
|
1204 |
|
1205 |
}
|
1206 |
+
|
1207 |
// Head back to the beginning of the merge vars array
|
1208 |
reset($mv);
|
1209 |
+
|
1210 |
// Ensure we have an array
|
1211 |
$igs = !is_array($igs) ? array() : $igs;
|
1212 |
foreach ($igs as $ig) {
|
1237 |
);
|
1238 |
}
|
1239 |
break;
|
1240 |
+
default:
|
1241 |
// Nothing
|
1242 |
break;
|
1243 |
}
|
1251 |
}
|
1252 |
|
1253 |
// If we're good
|
1254 |
+
if ($success) {
|
1255 |
// Clear out empty merge vars
|
1256 |
foreach ($merge as $k => $v) {
|
1257 |
if (is_array($v) && empty($v)) {
|
1261 |
unset($merge[$k]);
|
1262 |
}
|
1263 |
}
|
1264 |
+
|
1265 |
// If we have an empty $merge, then assign empty string.
|
1266 |
if (count($merge) == 0 || $merge == '') {
|
1267 |
$merge = '';
|
1288 |
}
|
1289 |
}
|
1290 |
break;
|
1291 |
+
|
1292 |
default:
|
1293 |
break;
|
1294 |
+
}
|
1295 |
}
|
1296 |
}
|
1297 |
}
|
1300 |
$retval = $api->listSubscribe( $listId, $email, $merge, $email_type);
|
1301 |
if (!$retval) {
|
1302 |
switch($api->errorCode) {
|
1303 |
+
case '105' :
|
1304 |
+
$errs[] = __("Please try again later", 'mailchimp_i18n').'.';
|
1305 |
break;
|
1306 |
+
case '214' :
|
1307 |
+
$msg = __("That email address is already subscribed to the list", 'mailchimp_i18n') . '.';
|
1308 |
+
|
1309 |
+
$account = $api->getAccountDetails(array("modules", "orders", "rewards-credits", "rewards-inspections", "rewards-referrals", "rewards-applied"));
|
1310 |
+
if (!$api->errorCode) {
|
1311 |
+
list($dummy, $dc) = explode('-',get_option('mc_apikey'));
|
1312 |
+
$uid = $account['user_id'];
|
1313 |
+
$username = $account['username'];
|
1314 |
+
$eid = base64_encode($email);
|
1315 |
+
$msg .= ' ' . sprintf(__('<a href="%s">Click here to update your profile.</a>', 'mailchimp_i18n'), "http://$username.$dc.list-manage.com/subscribe/send-email?u=$uid&id=$listId&e=$eid");
|
1316 |
+
}
|
1317 |
+
|
1318 |
+
$errs[] = $msg;
|
1319 |
+
$html_errs[] = count($errs)-1;
|
1320 |
break;
|
1321 |
+
case '250' :
|
1322 |
+
list($field, $rest) = explode(' ', $api->errorMessage, 2);
|
1323 |
$errs[] = sprintf(__("You must fill in %s.", 'mailchimp_i18n'), esc_html($mv_tag_keys[$field]['name']));
|
1324 |
break;
|
1325 |
+
case '254' :
|
1326 |
list($i1, $i2, $i3, $field, $rest) = explode(' ',$api->errorMessage,5);
|
1327 |
$errs[] = sprintf(__("%s has invalid content.", 'mailchimp_i18n'), esc_html($mv_tag_keys[$field]['name']));
|
1328 |
break;
|
1329 |
+
case '270' :
|
1330 |
$errs[] = __("An invalid Interest Group was selected", 'mailchimp_i18n').'.';
|
1331 |
break;
|
1332 |
+
case '502' :
|
1333 |
$errs[] = __("That email address is invalid", 'mailchimp_i18n').'.';
|
1334 |
break;
|
1335 |
default:
|
1340 |
}
|
1341 |
}
|
1342 |
}
|
1343 |
+
|
1344 |
// If we have errors, then show them
|
1345 |
if (count($errs) > 0) {
|
1346 |
$msg = '<span class="mc_error_msg">';
|
1347 |
+
foreach($errs as $error_index => $error){
|
1348 |
+
if (!in_array($error_index, $html_errs)) {
|
1349 |
+
$error = esc_html($error);
|
1350 |
+
}
|
1351 |
+
$msg .= '» '.$error.'<br />';
|
1352 |
}
|
1353 |
$msg .= '</span>';
|
1354 |
}
|
1355 |
else {
|
1356 |
$msg = "<strong class='mc_success_msg'>".esc_html(__("Success, you've been signed up! Please look for our confirmation email!", 'mailchimp_i18n'))."</strong>";
|
1357 |
}
|
1358 |
+
|
1359 |
// Set our global message
|
1360 |
mailchimpSF_global_msg($msg);
|
1361 |
+
|
1362 |
return $success;
|
1363 |
}
|
1364 |
|
1369 |
**********************/
|
1370 |
/**
|
1371 |
* Utility function to allow placement of plugin in plugins, mu-plugins, child or parent theme's plugins folders
|
1372 |
+
*
|
1373 |
* This function must be ran _very early_ in the load process, as it sets up important constants for the rest of the plugin
|
1374 |
*/
|
1375 |
function mailchimpSF_where_am_i() {
|
1407 |
break;
|
1408 |
}
|
1409 |
}
|
1410 |
+
|
1411 |
// Define our complete filesystem path
|
1412 |
define('MCSF_DIR', $mscf_dir);
|
1413 |
+
|
1414 |
+
/* Lang location needs to be relative *from* ABSPATH,
|
1415 |
so strip it out of our language dir location */
|
1416 |
+
define('MCSF_LANG_DIR', trailingslashit(MCSF_DIR).'po/');
|
1417 |
+
|
1418 |
// Define our complete URL to the plugin folder
|
1419 |
define('MCSF_URL', $mscf_url);
|
1420 |
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: mc_jesse, crowdfavorite
|
3 |
Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
|
4 |
Requires at least: 2.8
|
5 |
-
Tested up to: 3.
|
6 |
-
Stable tag: 1.2.
|
7 |
|
8 |
== Description ==
|
9 |
|
@@ -141,6 +141,9 @@ Added support for multiple interest groups, field formatting based on type and d
|
|
141 |
|
142 |
== Changelog ==
|
143 |
|
|
|
|
|
|
|
144 |
= 1.2.13 =
|
145 |
* Fixed bug preventing address fields from submitting correctly.
|
146 |
|
2 |
Contributors: mc_jesse, crowdfavorite
|
3 |
Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
|
4 |
Requires at least: 2.8
|
5 |
+
Tested up to: 3.5.1
|
6 |
+
Stable tag: 1.2.14
|
7 |
|
8 |
== Description ==
|
9 |
|
141 |
|
142 |
== Changelog ==
|
143 |
|
144 |
+
= 1.2.14 =
|
145 |
+
* Add link to edit profile within error when duplicate signup occurs
|
146 |
+
|
147 |
= 1.2.13 =
|
148 |
* Fixed bug preventing address fields from submitting correctly.
|
149 |
|