MailChimp List Subscribe Form - Version 1.4

Version Description

Added Developer Mode "Kitchen Sink" to aid in styling without having to authenticate a MailChimp account.

Download this release

Release Info

Developer crowdfavorite
Plugin Icon wp plugin MailChimp List Subscribe Form
Version 1.4
Comparing to
See all releases

Code changes from version 1.3 to 1.4

Files changed (3) hide show
  1. mailchimp.php +301 -278
  2. mailchimp_widget.php +71 -5
  3. readme.txt +24 -2
mailchimp.php CHANGED
@@ -3,33 +3,38 @@
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.3
7
  Author: MailChimp and Crowd Favorite
8
  Author URI: http://mailchimp.com/api/
9
  */
10
  /* Copyright 2008-2012 MailChimp.com (email : api@mailchimp.com)
11
 
12
- This program is free software; you can redistribute it and/or modify
13
- it under the terms of the GNU General Public License as published by
14
- the Free Software Foundation; either version 2 of the License, or
15
- (at your option) any later version.
16
 
17
- This program is distributed in the hope that it will be useful,
18
- but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- GNU General Public License for more details.
21
 
22
- You should have received a copy of the GNU General Public License
23
- along with this program; if not, write to the Free Software
24
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
27
  // Version constant for easy CSS refreshes
28
- define('MCSF_VER', '1.3');
29
 
30
  // What's our permission (capability) threshold
31
  define('MCSF_CAP_THRESHOLD', 'manage_options');
32
 
 
 
 
 
 
33
  // Define our location constants, both MCSF_DIR and MCSF_URL
34
  mailchimpSF_where_am_i();
35
 
@@ -296,9 +301,9 @@ function mailchimpSF_request_handler() {
296
  }
297
 
298
  // erase auth information
299
- delete_option('mc_sopresto_user');
300
- delete_option('mc_sopresto_public_key');
301
- delete_option('mc_sopresto_secret_key');
302
  break;
303
  case 'reset_list':
304
  // Check capability & Verify nonce
@@ -332,10 +337,10 @@ function mailchimpSF_request_handler() {
332
  * global message left over from the signup_submit function */
333
  break;
334
  case 'js':
335
- if (!headers_sent()){ //just in case...
336
- header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT', true, 200);
337
- }
338
- echo mailchimpSF_global_msg(); // Don't esc_html this, b/c we've already escaped it
339
  exit;
340
  }
341
  }
@@ -490,11 +495,11 @@ function mailchimpSF_delete_setup() {
490
  delete_option('mc_interest_groups');
491
  $mv = get_option('mc_merge_vars');
492
  if (is_array($mv)){
493
- foreach($mv as $var){
494
- $opt = 'mc_mv_'.$var['tag'];
495
- delete_option($opt);
496
- }
497
- }
498
  delete_option('mc_merge_vars');
499
  }
500
 
@@ -585,92 +590,99 @@ function mailchimpSF_set_form_defaults($list_name = '') {
585
  * @return void
586
  **/
587
  function mailchimpSF_save_general_form_settings() {
588
- if (isset($_POST['mc_rewards'])){
589
- update_option('mc_rewards', 'on');
590
- $msg = '<p class="success_msg">'.__('Monkey Rewards turned On!', 'mailchimp_i18n').'</p>';
591
- mailchimpSF_global_msg($msg);
592
- } else if (get_option('mc_rewards')!='off') {
593
- update_option('mc_rewards', 'off');
594
- $msg = '<p class="success_msg">'.__('Monkey Rewards turned Off!', 'mailchimp_i18n').'</p>';
595
- mailchimpSF_global_msg($msg);
596
- }
597
- if (isset($_POST['mc_use_javascript'])){
598
- update_option('mc_use_javascript', 'on');
599
- $msg = '<p class="success_msg">'.__('Fancy Javascript submission turned On!', 'mailchimp_i18n').'</p>';
600
- mailchimpSF_global_msg($msg);
601
- } else if (get_option('mc_use_javascript')!='off') {
602
- update_option('mc_use_javascript', 'off');
603
- $msg = '<p class="success_msg">'.__('Fancy Javascript submission turned Off!', 'mailchimp_i18n').'</p>';
604
- mailchimpSF_global_msg($msg);
605
- }
606
 
607
- if (isset($_POST['mc_use_datepicker'])){
608
- update_option('mc_use_datepicker', 'on');
609
- $msg = '<p class="success_msg">'.__('Datepicker turned On!', 'mailchimp_i18n').'</p>';
610
- mailchimpSF_global_msg($msg);
611
- } else if (get_option('mc_use_datepicker')!='off') {
612
- update_option('mc_use_datepicker', 'off');
613
- $msg = '<p class="success_msg">'.__('Datepicker turned Off!', 'mailchimp_i18n').'</p>';
614
- mailchimpSF_global_msg($msg);
615
- }
 
 
 
 
 
 
 
 
 
 
616
 
617
- if (isset($_POST['mc_use_unsub_link'])){
618
- update_option('mc_use_unsub_link', 'on');
619
- $msg = '<p class="success_msg">'.__('Unsubscribe link turned On!', 'mailchimp_i18n').'</p>';
620
- mailchimpSF_global_msg($msg);
621
- } else if (get_option('mc_use_unsub_link')!='off') {
622
- update_option('mc_use_unsub_link', 'off');
623
- $msg = '<p class="success_msg">'.__('Unsubscribe link turned Off!', 'mailchimp_i18n').'</p>';
624
- mailchimpSF_global_msg($msg);
625
- }
 
 
 
 
 
 
 
 
 
 
626
 
627
- $content = stripslashes($_POST['mc_header_content']);
628
- $content = str_replace("\r\n","<br/>", $content);
629
- update_option('mc_header_content', $content );
630
 
631
- $content = stripslashes($_POST['mc_subheader_content']);
632
- $content = str_replace("\r\n","<br/>", $content);
633
- update_option('mc_subheader_content', $content );
634
 
635
 
636
- $submit_text = stripslashes($_POST['mc_submit_text']);
637
- $submit_text = str_replace("\r\n","", $submit_text);
638
- update_option('mc_submit_text', $submit_text);
 
639
 
640
  // Set Custom Style option
641
  update_option('mc_custom_style', isset($_POST['mc_custom_style']) ? 'on' : 'off');
642
 
643
- //we told them not to put these things we are replacing in, but let's just make sure they are listening...
644
- update_option('mc_header_border_width',str_replace('px','',$_POST['mc_header_border_width']) );
645
- update_option('mc_header_border_color', str_replace('#','',$_POST['mc_header_border_color']));
646
- update_option('mc_header_background',str_replace('#','',$_POST['mc_header_background']));
647
- update_option('mc_header_text_color', str_replace('#','',$_POST['mc_header_text_color']));
 
 
648
 
649
  update_option('mc_form_border_width',str_replace('px','',$_POST['mc_form_border_width']) );
650
  update_option('mc_form_border_color', str_replace('#','',$_POST['mc_form_border_color']));
651
  update_option('mc_form_background',str_replace('#','',$_POST['mc_form_background']));
652
  update_option('mc_form_text_color', str_replace('#','',$_POST['mc_form_text_color']));
653
 
654
- $igs = get_option('mc_interest_groups');
655
- if (is_array($igs)) {
656
- foreach($igs as $var){
657
- $opt = 'mc_show_interest_groups_'.$var['id'];
658
- if (isset($_POST[$opt])){
659
- update_option($opt,'on');
660
- } else {
661
- update_option($opt,'off');
 
 
662
  }
663
  }
664
- }
665
 
666
- $mv = get_option('mc_merge_vars');
667
- if (is_array($mv)) {
668
- foreach($mv as $var){
669
- $opt = 'mc_mv_'.$var['tag'];
670
- if (isset($_POST[$opt]) || $var['req']=='Y'){
671
- update_option($opt,'on');
672
- } else {
673
- update_option($opt,'off');
 
674
  }
675
  }
676
  }
@@ -688,7 +700,7 @@ function mailchimpSF_change_list_if_necessary() {
688
  $api = mailchimpSF_get_api();
689
  if (!$api) { return; }
690
 
691
- //we *could* support paging, but few users have that many lists (and shouldn't)
692
  $lists = $api->lists(array(),0,100);
693
  $lists = $lists['data'];
694
 
@@ -706,52 +718,52 @@ function mailchimpSF_change_list_if_necessary() {
706
 
707
  $orig_list = get_option('mc_list_id');
708
  if ($list_id != '') {
709
- update_option('mc_list_id', $list_id);
710
- update_option('mc_list_name', $list_name);
711
  update_option('mc_email_type_option', $lists[$list_key]['email_type_option']);
712
 
713
 
714
  // See if the user changed the list
715
- if ($orig_list != $list_id){
716
  // The user changed the list, Reset the Form Defaults
717
  mailchimpSF_set_form_defaults($list_name);
718
- }
719
  // email_type_option
720
 
721
  // Grab the merge vars and interest groups
722
- $mv = $api->listMergeVars($list_id);
723
- $igs = $api->listInterestGroupings($list_id);
724
-
725
- update_option('mc_merge_vars', $mv);
726
- foreach($mv as $var){
727
- $opt = 'mc_mv_'.$var['tag'];
728
- //turn them all on by default
729
- if ($orig_list != $list_id) {
730
- update_option($opt, 'on' );
731
- }
732
- }
733
- update_option('mc_interest_groups', $igs);
734
  if (is_array($igs)) {
735
  foreach ($igs as $var){
736
- $opt = 'mc_show_interest_groups_'.$var['id'];
737
- //turn them all on by default
738
- if ($orig_list != $list_id) {
739
- update_option($opt, 'on' );
740
- }
741
- }
742
  }
743
  $igs_text = ' ';
744
  if (is_array($igs)) {
745
  $igs_text .= sprintf(__('and %s Sets of Interest Groups', 'mailchimp_i18n'), count($igs));
746
  }
747
 
748
- $msg = '<p class="success_msg">'.
749
- sprintf(
750
  __('<b>Success!</b> Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n').$igs_text,
751
  count($mv)
752
  ).' '.
753
  __('from your list').' "'.$list_name.'"<br/><br/>'.
754
- __('Now you should either Turn On the MailChimp Widget or change your options below, then turn it on.', 'mailchimp_i18n').'</p>';
755
  mailchimpSF_global_msg($msg);
756
  }
757
  }
@@ -769,6 +781,12 @@ function mailchimpSF_setup_page() {
769
  <h2><?php esc_html_e('MailChimp List Setup', 'mailchimp_i18n');?> </h2>
770
  </div>
771
  <?php
 
 
 
 
 
 
772
  $user = get_option('mc_sopresto_user');
773
 
774
  // If we have an API Key, see if we need to change the lists and its options
@@ -778,16 +796,13 @@ mailchimpSF_change_list_if_necessary();
778
  if (mailchimpSF_global_msg() != ''){
779
  // Message has already been html escaped, so we don't want to 2x escape it here
780
  ?>
781
- <div id="mc_message" class=""><?php echo mailchimpSF_global_msg(); ?></div>
782
  <?php
783
  }
784
 
785
-
786
  // If we don't have an API Key, do a login form
787
- if (!$user) {
788
  ?>
789
- <div>
790
- </div>
791
  <div>
792
  <h3 class="mc-h2"><?php esc_html_e('Log In', 'mailchimp_i18n');?></h3>
793
  <p class="mc-p" style="width: 40%;line-height: 21px;"><?php esc_html_e('To start using the MailChimp plugin, we first need to connect your MailChimp account. Click login below to connect.', 'mailchimp_i18n'); ?></p>
@@ -812,24 +827,25 @@ if (!$user) {
812
  </table>
813
  </div>
814
  </div>
 
815
  <br/>
816
- <!--<div class="notes_msg">
817
  <?php
818
- if ($user && $user['username'] != ''){
819
  ?>
 
820
  <strong><?php esc_html_e('Notes', 'mailchimp_i18n'); ?>:</strong>
821
  <ul>
822
- <li><?php esc_html_e('Changing your settings at MailChimp.com may cause this to stop working.', 'mailchimp_i18n'); ?></li>
823
- <li><?php esc_html_e('If you change your login to a different account, the info you have setup below will be erased.', 'mailchimp_i18n'); ?></li>
824
- <li><?php esc_html_e('If any of that happens, no biggie - just reconfigure your login and the items below...', 'mailchimp_i18n'); ?></li>
825
  </ul>
826
  </div>-->
827
  <?php
828
- }
829
  } // End of login form
830
 
831
  // Start logout form
832
- else {
833
  ?>
834
  <table style="min-width:400px;" class="mc-user" cellspacing="0">
835
  <tr>
@@ -847,11 +863,9 @@ else {
847
  <?php
848
  } // End Logout form
849
 
850
-
851
-
852
  //Just get out if nothing else matters...
853
  $api = mailchimpSF_get_api();
854
- if (!$api) { return; }
855
 
856
  if ($api){
857
  ?>
@@ -864,7 +878,7 @@ if ($api){
864
 
865
  <form method="post" action="options-general.php?page=mailchimpSF_options">
866
  <?php
867
- //we *could* support paging, but few users have that many lists (and shouldn't)
868
  $lists = $api->lists(array(),0,100);
869
  $lists = $lists['data'];
870
 
@@ -882,18 +896,18 @@ if ($api){
882
  }
883
  else {
884
  ?>
885
- <table style="min-width:400px" class="mc-list-select" cellspacing="0">
886
  <tr class="mc-list-row">
887
  <td>
888
- <select name="mc_list_id" style="min-width:200px;">
889
- <option value=""> &mdash; <?php esc_html_e('Select A List','mailchimp_i18n'); ?> &mdash; </option>
890
  <?php
891
- foreach ($lists as $list) {
892
  $option = get_option('mc_list_id');
893
  ?>
894
- <option value="<?php echo esc_attr($list['id']); ?>"<?php selected($list['id'], $option); ?>><?php echo esc_html($list['name']); ?></option>
895
  <?php
896
- }
897
  ?>
898
  </select>
899
  </td>
@@ -913,7 +927,7 @@ if ($api){
913
 
914
  <?php
915
  }
916
- else {
917
  //display the selected list...
918
  ?>
919
 
@@ -930,7 +944,7 @@ else {
930
  }
931
 
932
  //Just get out if nothing else matters...
933
- if (get_option('mc_list_id') == '') return;
934
 
935
 
936
  // The main Settings form
@@ -941,10 +955,12 @@ if (get_option('mc_list_id') == '') return;
941
  <div style="width:900px;">
942
  <input type="hidden" name="mcsf_action" value="change_form_settings">
943
  <?php wp_nonce_field('update_general_form_settings', '_mcsf_nonce_action'); ?>
 
 
944
  <!--<input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button" />-->
945
  <table class="widefat mc-widefat mc-label-options">
946
  <tr><th colspan="2">Content Options</th></tr>
947
- <tr valign="top">
948
  <th scope="row"><?php esc_html_e('Header', 'mailchimp_i18n'); ?></th>
949
  <td>
950
  <textarea name="mc_header_content" rows="2" cols="70"><?php echo esc_html(get_option('mc_header_content')); ?></textarea><br/>
@@ -952,12 +968,12 @@ if (get_option('mc_list_id') == '') return;
952
  </td>
953
  </tr>
954
 
955
- <tr valign="top">
956
  <th scope="row"><?php esc_html_e('Sub-header', 'mailchimp_i18n'); ?></th>
957
  <td>
958
  <textarea name="mc_subheader_content" rows="2" cols="70"><?php echo esc_html(get_option('mc_subheader_content')); ?></textarea><br/>
959
  <?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?>.<br/>
960
- <?php esc_html_e('This will be displayed under the heading and above the form.', 'mailchimp_i18n'); ?>
961
  </td>
962
  </tr>
963
 
@@ -970,12 +986,13 @@ if (get_option('mc_list_id') == '') return;
970
  </table>
971
 
972
  <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
 
973
 
974
  <table class="widefat mc-widefat mc-custom-styling">
975
  <tr><th colspan="2">Custom Styling</th></tr>
976
  <tr class="mc-turned-on"><th><label for="mc_custom_style"><?php esc_html_e('Enabled?', 'mailchimp_i18n'); ?></label></th><td><span class="mc-pre-input"></span><input type="checkbox" name="mc_custom_style" id="mc_custom_style"<?php checked(get_option('mc_custom_style'), 'on'); ?> /></td></tr>
977
 
978
- <tr class="mc-internal-heading"><th colspan="2"><?php esc_html_e('Form Settings', 'mailchimp_i18n'); ?></th></tr>
979
  <tr><th><?php esc_html_e('Border Width', 'mailchimp_i18n'); ?></th><td><span class="mc-pre-input"></span><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo esc_attr(get_option('mc_form_border_width')); ?>"/>
980
  <em>px •<?php esc_html_e('Set to 0 for no border, do not enter', 'mailchimp_i18n'); ?> <strong>px</strong>!</em>
981
  </td></tr>
@@ -992,45 +1009,44 @@ if (get_option('mc_list_id') == '') return;
992
 
993
  <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
994
 
 
995
  <table class="widefat mc-widefat">
996
  <tr><th colspan="2">List Options</th></tr>
997
- <tr valign="top">
998
- <th scope="row"><?php esc_html_e('Monkey Rewards', 'mailchimp_i18n'); ?>?</th>
999
- <td><input name="mc_rewards" type="checkbox"<?php if (get_option('mc_rewards')=='on' || get_option('mc_rewards')=='' ) { echo ' checked="checked"'; } ?> id="mc_rewards" class="code" />
1000
- <em><label for="mc_rewards"><?php esc_html_e('Turning this on will place a "powered by MailChimp" link in your form that will earn you credits with us. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em>
1001
- </td>
1002
- </tr>
1003
-
1004
- <tr valign="top">
1005
- <th scope="row"><?php esc_html_e('Use Javascript Support?', 'mailchimp_i18n'); ?></th>
1006
- <td><input name="mc_use_javascript" type="checkbox" <?php checked(get_option('mc_use_javascript'), 'on'); ?> id="mc_use_javascript" class="code" />
1007
- <em><label for="mc_use_javascript"><?php esc_html_e('Turning this on will use fancy javascript submission and should degrade gracefully for users not using javascript. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em>
1008
- </td>
1009
- </tr>
1010
 
1011
  <tr valign="top">
1012
- <th scope="row"><?php esc_html_e('Use Javascript Datepicker?', 'mailchimp_i18n'); ?></th>
1013
- <td><input name="mc_use_datepicker" type="checkbox" <?php checked(get_option('mc_use_datepicker'), 'on'); ?> id="mc_use_datepicker" class="code" />
1014
- <em><label for="mc_use_datepicker"><?php esc_html_e('Turning this on will use the jQuery UI Datepicker for dates.', 'mailchimp_i18n'); ?></label></em>
1015
- </td>
1016
- </tr>
1017
- <tr valign="top" class="last-row">
1018
- <th scope="row"><?php esc_html_e('Include Unsubscribe link?', 'mailchimp_i18n'); ?></th>
1019
- <td><input name="mc_use_unsub_link" type="checkbox"<?php checked(get_option('mc_use_unsub_link'), 'on'); ?> id="mc_use_unsub_link" class="code" />
1020
- <em><label for="mc_use_unsub_link"><?php esc_html_e('Turning this on will add a link to your host unsubscribe form', 'mailchimp_i18n'); ?></label></em>
1021
- </td>
1022
- </tr>
1023
-
1024
-
 
 
 
 
 
1025
  </table>
1026
 
1027
- </div>
1028
-
1029
 
 
1030
 
1031
  <?php
1032
  // Merge Variables Table
1033
- ?>
1034
  <div style="width:900px;">
1035
 
1036
  <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
@@ -1083,131 +1099,126 @@ if (get_option('mc_list_id') == '') return;
1083
  }
1084
  ?>
1085
  </table>
 
 
1086
  <?php
1087
  }
1088
-
1089
  ?>
1090
 
1091
- <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
1092
 
1093
  <?php
1094
- // Interest Groups Table
1095
- $igs = get_option('mc_interest_groups');
1096
- if (is_array($igs) && !isset($igs['id'])) { ?>
1097
- <h3 class="mc-h3"><?php esc_html_e('Group Settings', 'mailchimp_i18n'); ?></h3> <?php
1098
- // Determines whether or not to continue processing. Only false if there was an error.
1099
- $continue = true;
1100
- foreach ($igs as $ig) {
1101
- if ($continue) {
1102
- if (!is_array($ig) || empty($ig) || $ig == 'N' ) {
1103
- ?>
1104
- <em><?php esc_html_e('No Interest Groups Setup for this List', 'mailchimp_i18n'); ?></em>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1105
  <?php
1106
- $continue = false;
1107
  }
1108
- else {
1109
- ?>
1110
- <table class='mc-widefat mc-blue' width="450px" cellspacing="0">
 
 
 
 
1111
  <tr valign="top">
1112
- <th colspan="2"><?php echo esc_html($ig['name']); ?></th>
 
1113
  </tr>
1114
  <tr valign="top">
1115
- <th>
1116
- <label for="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>"><?php esc_html_e('Show?', 'mailchimp_i18n'); ?></label>
1117
- </th>
1118
- <th>
1119
- <input name="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>" id="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>" type="checkbox" class="code"<?php checked('on', get_option('mc_show_interest_groups_'.$ig['id'])); ?> />
1120
- </th>
1121
  </tr>
1122
  <tr valign="top">
1123
- <th><?php esc_html_e('Input Type', 'mailchimp_i18n'); ?></th>
1124
- <td><?php echo esc_html($ig['form_field']); ?></td>
1125
  </tr>
1126
- <tr valign="top" class="last-row">
1127
- <th><?php esc_html_e('Options', 'mailchimp_i18n'); ?></th>
1128
- <td>
1129
- <ul>
1130
- <?php
1131
- foreach($ig['groups'] as $interest){
1132
- ?>
1133
- <li><?php echo esc_html($interest['name']); ?></li>
1134
- <?php
1135
- }
1136
- ?>
1137
- </ul>
1138
- </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1139
  </tr>
1140
  </table>
1141
- <?php
1142
- }
1143
- }
1144
- }
1145
- }
1146
- ?>
1147
-
1148
- <table class="widefat mc-widefat mc-yellow">
1149
- <tr><th colspan="2">CSS Cheat Sheet</th></tr>
1150
- <tr valign="top">
1151
- <th scope="row">.widget_mailchimpsf_widget </th>
1152
- <td>This targets the entire widget container.</td>
1153
- </tr>
1154
- <tr valign="top">
1155
- <th scope="row">.widget-title</th>
1156
- <td>This styles the title of your MailChimp widget. <i>Modifying this class will affect your other widget titles.</i></td>
1157
- </tr>
1158
- <tr valign="top">
1159
- <th scope="row">#mc_signup</th>
1160
- <td>This targets the entirity of the widget beneath the widget title.</td>
1161
- </tr>
1162
- <tr valign="top">
1163
- <th scope="row">#mc_subheader</th>
1164
- <td>This styles the subheader text.</td>
1165
- </tr>
1166
- <tr valign="top">
1167
- <th scope="row">.mc_form_inside</th>
1168
- <td>The guts and main container for the all of the form elements (the entirety of the widget minus the header and the sub header).</td>
1169
- </tr>
1170
- <tr valign="top">
1171
- <th scope="row">.mc_header</th>
1172
- <td>This targets the label above the input fields.</td>
1173
- </tr>
1174
- <tr valign="top">
1175
- <th scope="row">.mc_input</th>
1176
- <td>This attaches to the input fields.</td>
1177
- </tr>
1178
- <tr valign="top">
1179
- <th scope="row">.mc_header_address</th>
1180
- <td>This is the label above an address group.</td>
1181
- </tr>
1182
- <tr valign="top">
1183
- <th scope="row">.mc_radio_label</th>
1184
- <td>These are the labels associated with radio buttons.</td>
1185
- </tr>
1186
- <tr valign="top">
1187
- <th scope="row">#mc-indicates-required</th>
1188
- <td>This targets the “Indicates Required Field” text.</td>
1189
- </tr>
1190
- <tr valign="top">
1191
- <th scope="row">#mc_signup_submit</th>
1192
- <td>Use this to style the submit button.</td>
1193
- </tr>
1194
-
1195
-
1196
- </table>
1197
-
1198
- </div>
1199
-
1200
-
1201
 
1202
  </form>
1203
- </div>
1204
- </div><!--wrap-->
1205
  <?php
1206
  }//mailchimpSF_setup_page()
1207
 
1208
 
1209
  function mailchimpSF_register_widgets() {
1210
- if (mailchimpSF_get_api()) {
1211
  register_widget('mailchimpSF_Widget');
1212
  }
1213
  }
@@ -1246,7 +1257,19 @@ function mailchimpSF_signup_submit() {
1246
  $opt_val = isset($_POST[$opt]) ? $_POST[$opt] : '';
1247
 
1248
  if (is_array($opt_val) && isset($opt_val['area'])) {
1249
- $opt_val = implode('-', $opt_val);
 
 
 
 
 
 
 
 
 
 
 
 
1250
  }
1251
  else if (is_array($opt_val) && $var['field_type'] == 'address') {
1252
  if ($var['req'] == 'Y') {
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.4
7
  Author: MailChimp and Crowd Favorite
8
  Author URI: http://mailchimp.com/api/
9
  */
10
  /* Copyright 2008-2012 MailChimp.com (email : api@mailchimp.com)
11
 
12
+ This program is free software; you can redistribute it and/or modify
13
+ it under the terms of the GNU General Public License as published by
14
+ the Free Software Foundation; either version 2 of the License, or
15
+ (at your option) any later version.
16
 
17
+ This program is distributed in the hope that it will be useful,
18
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ GNU General Public License for more details.
21
 
22
+ You should have received a copy of the GNU General Public License
23
+ along with this program; if not, write to the Free Software
24
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
27
  // Version constant for easy CSS refreshes
28
+ define('MCSF_VER', '1.4');
29
 
30
  // What's our permission (capability) threshold
31
  define('MCSF_CAP_THRESHOLD', 'manage_options');
32
 
33
+ // If Developer mode not defined, make it false
34
+ if (! defined('MAILCHIMP_DEV_MODE') ) {
35
+ define('MAILCHIMP_DEV_MODE', false);
36
+ }
37
+
38
  // Define our location constants, both MCSF_DIR and MCSF_URL
39
  mailchimpSF_where_am_i();
40
 
301
  }
302
 
303
  // erase auth information
304
+ delete_option('mc_sopresto_user');
305
+ delete_option('mc_sopresto_public_key');
306
+ delete_option('mc_sopresto_secret_key');
307
  break;
308
  case 'reset_list':
309
  // Check capability & Verify nonce
337
  * global message left over from the signup_submit function */
338
  break;
339
  case 'js':
340
+ if (!headers_sent()){ //just in case...
341
+ header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT', true, 200);
342
+ }
343
+ echo mailchimpSF_global_msg(); // Don't esc_html this, b/c we've already escaped it
344
  exit;
345
  }
346
  }
495
  delete_option('mc_interest_groups');
496
  $mv = get_option('mc_merge_vars');
497
  if (is_array($mv)){
498
+ foreach($mv as $var){
499
+ $opt = 'mc_mv_'.$var['tag'];
500
+ delete_option($opt);
501
+ }
502
+ }
503
  delete_option('mc_merge_vars');
504
  }
505
 
590
  * @return void
591
  **/
592
  function mailchimpSF_save_general_form_settings() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
593
 
594
+ if (MAILCHIMP_DEV_MODE == false) {
595
+ if (isset($_POST['mc_rewards'])){
596
+ update_option('mc_rewards', 'on');
597
+ $msg = '<p class="success_msg">'.__('Monkey Rewards turned On!', 'mailchimp_i18n').'</p>';
598
+ mailchimpSF_global_msg($msg);
599
+ } else if (get_option('mc_rewards')!='off') {
600
+ update_option('mc_rewards', 'off');
601
+ $msg = '<p class="success_msg">'.__('Monkey Rewards turned Off!', 'mailchimp_i18n').'</p>';
602
+ mailchimpSF_global_msg($msg);
603
+ }
604
+ if (isset($_POST['mc_use_javascript'])){
605
+ update_option('mc_use_javascript', 'on');
606
+ $msg = '<p class="success_msg">'.__('Fancy Javascript submission turned On!', 'mailchimp_i18n').'</p>';
607
+ mailchimpSF_global_msg($msg);
608
+ } else if (get_option('mc_use_javascript')!='off') {
609
+ update_option('mc_use_javascript', 'off');
610
+ $msg = '<p class="success_msg">'.__('Fancy Javascript submission turned Off!', 'mailchimp_i18n').'</p>';
611
+ mailchimpSF_global_msg($msg);
612
+ }
613
 
614
+ if (isset($_POST['mc_use_datepicker'])){
615
+ update_option('mc_use_datepicker', 'on');
616
+ $msg = '<p class="success_msg">'.__('Datepicker turned On!', 'mailchimp_i18n').'</p>';
617
+ mailchimpSF_global_msg($msg);
618
+ } else if (get_option('mc_use_datepicker')!='off') {
619
+ update_option('mc_use_datepicker', 'off');
620
+ $msg = '<p class="success_msg">'.__('Datepicker turned Off!', 'mailchimp_i18n').'</p>';
621
+ mailchimpSF_global_msg($msg);
622
+ }
623
+
624
+ if (isset($_POST['mc_use_unsub_link'])){
625
+ update_option('mc_use_unsub_link', 'on');
626
+ $msg = '<p class="success_msg">'.__('Unsubscribe link turned On!', 'mailchimp_i18n').'</p>';
627
+ mailchimpSF_global_msg($msg);
628
+ } else if (get_option('mc_use_unsub_link')!='off') {
629
+ update_option('mc_use_unsub_link', 'off');
630
+ $msg = '<p class="success_msg">'.__('Unsubscribe link turned Off!', 'mailchimp_i18n').'</p>';
631
+ mailchimpSF_global_msg($msg);
632
+ }
633
 
634
+ $content = stripslashes($_POST['mc_header_content']);
635
+ $content = str_replace("\r\n","<br/>", $content);
636
+ update_option('mc_header_content', $content );
637
 
638
+ $content = stripslashes($_POST['mc_subheader_content']);
639
+ $content = str_replace("\r\n","<br/>", $content);
640
+ update_option('mc_subheader_content', $content );
641
 
642
 
643
+ $submit_text = stripslashes($_POST['mc_submit_text']);
644
+ $submit_text = str_replace("\r\n","", $submit_text);
645
+ update_option('mc_submit_text', $submit_text);
646
+ }
647
 
648
  // Set Custom Style option
649
  update_option('mc_custom_style', isset($_POST['mc_custom_style']) ? 'on' : 'off');
650
 
651
+ if (MAILCHIMP_DEV_MODE == false) {
652
+ //we told them not to put these things we are replacing in, but let's just make sure they are listening...
653
+ update_option('mc_header_border_width',str_replace('px','',$_POST['mc_header_border_width']) );
654
+ update_option('mc_header_border_color', str_replace('#','',$_POST['mc_header_border_color']));
655
+ update_option('mc_header_background',str_replace('#','',$_POST['mc_header_background']));
656
+ update_option('mc_header_text_color', str_replace('#','',$_POST['mc_header_text_color']));
657
+ }
658
 
659
  update_option('mc_form_border_width',str_replace('px','',$_POST['mc_form_border_width']) );
660
  update_option('mc_form_border_color', str_replace('#','',$_POST['mc_form_border_color']));
661
  update_option('mc_form_background',str_replace('#','',$_POST['mc_form_background']));
662
  update_option('mc_form_text_color', str_replace('#','',$_POST['mc_form_text_color']));
663
 
664
+ if (MAILCHIMP_DEV_MODE == false) {
665
+ $igs = get_option('mc_interest_groups');
666
+ if (is_array($igs)) {
667
+ foreach($igs as $var){
668
+ $opt = 'mc_show_interest_groups_'.$var['id'];
669
+ if (isset($_POST[$opt])){
670
+ update_option($opt,'on');
671
+ } else {
672
+ update_option($opt,'off');
673
+ }
674
  }
675
  }
 
676
 
677
+ $mv = get_option('mc_merge_vars');
678
+ if (is_array($mv)) {
679
+ foreach($mv as $var){
680
+ $opt = 'mc_mv_'.$var['tag'];
681
+ if (isset($_POST[$opt]) || $var['req']=='Y'){
682
+ update_option($opt,'on');
683
+ } else {
684
+ update_option($opt,'off');
685
+ }
686
  }
687
  }
688
  }
700
  $api = mailchimpSF_get_api();
701
  if (!$api) { return; }
702
 
703
+ //we *could* support paging, but few users have that many lists (and shouldn't)
704
  $lists = $api->lists(array(),0,100);
705
  $lists = $lists['data'];
706
 
718
 
719
  $orig_list = get_option('mc_list_id');
720
  if ($list_id != '') {
721
+ update_option('mc_list_id', $list_id);
722
+ update_option('mc_list_name', $list_name);
723
  update_option('mc_email_type_option', $lists[$list_key]['email_type_option']);
724
 
725
 
726
  // See if the user changed the list
727
+ if ($orig_list != $list_id){
728
  // The user changed the list, Reset the Form Defaults
729
  mailchimpSF_set_form_defaults($list_name);
730
+ }
731
  // email_type_option
732
 
733
  // Grab the merge vars and interest groups
734
+ $mv = $api->listMergeVars($list_id);
735
+ $igs = $api->listInterestGroupings($list_id);
736
+
737
+ update_option('mc_merge_vars', $mv);
738
+ foreach($mv as $var){
739
+ $opt = 'mc_mv_'.$var['tag'];
740
+ //turn them all on by default
741
+ if ($orig_list != $list_id) {
742
+ update_option($opt, 'on' );
743
+ }
744
+ }
745
+ update_option('mc_interest_groups', $igs);
746
  if (is_array($igs)) {
747
  foreach ($igs as $var){
748
+ $opt = 'mc_show_interest_groups_'.$var['id'];
749
+ //turn them all on by default
750
+ if ($orig_list != $list_id) {
751
+ update_option($opt, 'on' );
752
+ }
753
+ }
754
  }
755
  $igs_text = ' ';
756
  if (is_array($igs)) {
757
  $igs_text .= sprintf(__('and %s Sets of Interest Groups', 'mailchimp_i18n'), count($igs));
758
  }
759
 
760
+ $msg = '<p class="success_msg">'.
761
+ sprintf(
762
  __('<b>Success!</b> Loaded and saved the info for %d Merge Variables', 'mailchimp_i18n').$igs_text,
763
  count($mv)
764
  ).' '.
765
  __('from your list').' "'.$list_name.'"<br/><br/>'.
766
+ __('Now you should either Turn On the MailChimp Widget or change your options below, then turn it on.', 'mailchimp_i18n').'</p>';
767
  mailchimpSF_global_msg($msg);
768
  }
769
  }
781
  <h2><?php esc_html_e('MailChimp List Setup', 'mailchimp_i18n');?> </h2>
782
  </div>
783
  <?php
784
+
785
+ // Display Developer mode active.
786
+ if (MAILCHIMP_DEV_MODE == true) { ?>
787
+ <p class="error_msg">Developer mode active.</p>
788
+ <?php }
789
+
790
  $user = get_option('mc_sopresto_user');
791
 
792
  // If we have an API Key, see if we need to change the lists and its options
796
  if (mailchimpSF_global_msg() != ''){
797
  // Message has already been html escaped, so we don't want to 2x escape it here
798
  ?>
799
+ <div id="mc_message" class=""><?php echo mailchimpSF_global_msg(); ?></div>
800
  <?php
801
  }
802
 
 
803
  // If we don't have an API Key, do a login form
804
+ if (!$user && MAILCHIMP_DEV_MODE == false) {
805
  ?>
 
 
806
  <div>
807
  <h3 class="mc-h2"><?php esc_html_e('Log In', 'mailchimp_i18n');?></h3>
808
  <p class="mc-p" style="width: 40%;line-height: 21px;"><?php esc_html_e('To start using the MailChimp plugin, we first need to connect your MailChimp account. Click login below to connect.', 'mailchimp_i18n'); ?></p>
827
  </table>
828
  </div>
829
  </div>
830
+
831
  <br/>
 
832
  <?php
833
+ if ($user && $user['username'] != '') {
834
  ?>
835
+ <!--<div class="notes_msg">
836
  <strong><?php esc_html_e('Notes', 'mailchimp_i18n'); ?>:</strong>
837
  <ul>
838
+ <li><?php esc_html_e('Changing your settings at MailChimp.com may cause this to stop working.', 'mailchimp_i18n'); ?></li>
839
+ <li><?php esc_html_e('If you change your login to a different account, the info you have setup below will be erased.', 'mailchimp_i18n'); ?></li>
840
+ <li><?php esc_html_e('If any of that happens, no biggie - just reconfigure your login and the items below...', 'mailchimp_i18n'); ?></li>
841
  </ul>
842
  </div>-->
843
  <?php
844
+ }
845
  } // End of login form
846
 
847
  // Start logout form
848
+ elseif (MAILCHIMP_DEV_MODE == false) {
849
  ?>
850
  <table style="min-width:400px;" class="mc-user" cellspacing="0">
851
  <tr>
863
  <?php
864
  } // End Logout form
865
 
 
 
866
  //Just get out if nothing else matters...
867
  $api = mailchimpSF_get_api();
868
+ if (!$api && MAILCHIMP_DEV_MODE == false) { return; }
869
 
870
  if ($api){
871
  ?>
878
 
879
  <form method="post" action="options-general.php?page=mailchimpSF_options">
880
  <?php
881
+ //we *could* support paging, but few users have that many lists (and shouldn't)
882
  $lists = $api->lists(array(),0,100);
883
  $lists = $lists['data'];
884
 
896
  }
897
  else {
898
  ?>
899
+ <table style="min-width:400px" class="mc-list-select" cellspacing="0">
900
  <tr class="mc-list-row">
901
  <td>
902
+ <select name="mc_list_id" style="min-width:200px;">
903
+ <option value=""> &mdash; <?php esc_html_e('Select A List','mailchimp_i18n'); ?> &mdash; </option>
904
  <?php
905
+ foreach ($lists as $list) {
906
  $option = get_option('mc_list_id');
907
  ?>
908
+ <option value="<?php echo esc_attr($list['id']); ?>"<?php selected($list['id'], $option); ?>><?php echo esc_html($list['name']); ?></option>
909
  <?php
910
+ }
911
  ?>
912
  </select>
913
  </td>
927
 
928
  <?php
929
  }
930
+ elseif (MAILCHIMP_DEV_MODE == false) {
931
  //display the selected list...
932
  ?>
933
 
944
  }
945
 
946
  //Just get out if nothing else matters...
947
+ if (get_option('mc_list_id') == '' && MAILCHIMP_DEV_MODE == false) return;
948
 
949
 
950
  // The main Settings form
955
  <div style="width:900px;">
956
  <input type="hidden" name="mcsf_action" value="change_form_settings">
957
  <?php wp_nonce_field('update_general_form_settings', '_mcsf_nonce_action'); ?>
958
+
959
+ <?php if (MAILCHIMP_DEV_MODE == false) { ?>
960
  <!--<input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button" />-->
961
  <table class="widefat mc-widefat mc-label-options">
962
  <tr><th colspan="2">Content Options</th></tr>
963
+ <tr valign="top">
964
  <th scope="row"><?php esc_html_e('Header', 'mailchimp_i18n'); ?></th>
965
  <td>
966
  <textarea name="mc_header_content" rows="2" cols="70"><?php echo esc_html(get_option('mc_header_content')); ?></textarea><br/>
968
  </td>
969
  </tr>
970
 
971
+ <tr valign="top">
972
  <th scope="row"><?php esc_html_e('Sub-header', 'mailchimp_i18n'); ?></th>
973
  <td>
974
  <textarea name="mc_subheader_content" rows="2" cols="70"><?php echo esc_html(get_option('mc_subheader_content')); ?></textarea><br/>
975
  <?php esc_html_e('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n'); ?>.<br/>
976
+ <?php esc_html_e('This will be displayed under the heading and above the form.', 'mailchimp_i18n'); ?>
977
  </td>
978
  </tr>
979
 
986
  </table>
987
 
988
  <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
989
+ <?php } ?>
990
 
991
  <table class="widefat mc-widefat mc-custom-styling">
992
  <tr><th colspan="2">Custom Styling</th></tr>
993
  <tr class="mc-turned-on"><th><label for="mc_custom_style"><?php esc_html_e('Enabled?', 'mailchimp_i18n'); ?></label></th><td><span class="mc-pre-input"></span><input type="checkbox" name="mc_custom_style" id="mc_custom_style"<?php checked(get_option('mc_custom_style'), 'on'); ?> /></td></tr>
994
 
995
+ <tr class="mc-internal-heading"><th colspan="2"><?php esc_html_e('Form Settings', 'mailchimp_i18n'); ?></th></tr>
996
  <tr><th><?php esc_html_e('Border Width', 'mailchimp_i18n'); ?></th><td><span class="mc-pre-input"></span><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo esc_attr(get_option('mc_form_border_width')); ?>"/>
997
  <em>px •<?php esc_html_e('Set to 0 for no border, do not enter', 'mailchimp_i18n'); ?> <strong>px</strong>!</em>
998
  </td></tr>
1009
 
1010
  <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
1011
 
1012
+ <?php if (MAILCHIMP_DEV_MODE == false) { ?>
1013
  <table class="widefat mc-widefat">
1014
  <tr><th colspan="2">List Options</th></tr>
1015
+ <tr valign="top">
1016
+ <th scope="row"><?php esc_html_e('Monkey Rewards', 'mailchimp_i18n'); ?>?</th>
1017
+ <td><input name="mc_rewards" type="checkbox"<?php if (get_option('mc_rewards')=='on' || get_option('mc_rewards')=='' ) { echo ' checked="checked"'; } ?> id="mc_rewards" class="code" />
1018
+ <em><label for="mc_rewards"><?php esc_html_e('Turning this on will place a "powered by MailChimp" link in your form that will earn you credits with us. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em>
1019
+ </td>
1020
+ </tr>
 
 
 
 
 
 
 
1021
 
1022
  <tr valign="top">
1023
+ <th scope="row"><?php esc_html_e('Use Javascript Support?', 'mailchimp_i18n'); ?></th>
1024
+ <td><input name="mc_use_javascript" type="checkbox" <?php checked(get_option('mc_use_javascript'), 'on'); ?> id="mc_use_javascript" class="code" />
1025
+ <em><label for="mc_use_javascript"><?php esc_html_e('Turning this on will use fancy javascript submission and should degrade gracefully for users not using javascript. It is optional and can be turned on or off at any time.', 'mailchimp_i18n'); ?></label></em>
1026
+ </td>
1027
+ </tr>
1028
+
1029
+ <tr valign="top">
1030
+ <th scope="row"><?php esc_html_e('Use Javascript Datepicker?', 'mailchimp_i18n'); ?></th>
1031
+ <td><input name="mc_use_datepicker" type="checkbox" <?php checked(get_option('mc_use_datepicker'), 'on'); ?> id="mc_use_datepicker" class="code" />
1032
+ <em><label for="mc_use_datepicker"><?php esc_html_e('Turning this on will use the jQuery UI Datepicker for dates.', 'mailchimp_i18n'); ?></label></em>
1033
+ </td>
1034
+ </tr>
1035
+ <tr valign="top" class="last-row">
1036
+ <th scope="row"><?php esc_html_e('Include Unsubscribe link?', 'mailchimp_i18n'); ?></th>
1037
+ <td><input name="mc_use_unsub_link" type="checkbox"<?php checked(get_option('mc_use_unsub_link'), 'on'); ?> id="mc_use_unsub_link" class="code" />
1038
+ <em><label for="mc_use_unsub_link"><?php esc_html_e('Turning this on will add a link to your host unsubscribe form', 'mailchimp_i18n'); ?></label></em>
1039
+ </td>
1040
+ </tr>
1041
  </table>
1042
 
1043
+ <?php } ?>
 
1044
 
1045
+ </div>
1046
 
1047
  <?php
1048
  // Merge Variables Table
1049
+ if (MAILCHIMP_DEV_MODE == false) { ?>
1050
  <div style="width:900px;">
1051
 
1052
  <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
1099
  }
1100
  ?>
1101
  </table>
1102
+ <input type="submit" value="<?php esc_attr_e('Update Subscribe Form Settings', 'mailchimp_i18n'); ?>" class="button mc-submit" /><br/>
1103
+ </div>
1104
  <?php
1105
  }
 
1106
  ?>
1107
 
1108
+
1109
 
1110
  <?php
1111
+ // Interest Groups Table
1112
+ $igs = get_option('mc_interest_groups');
1113
+ if (is_array($igs) && !isset($igs['id'])) { ?>
1114
+ <h3 class="mc-h3"><?php esc_html_e('Group Settings', 'mailchimp_i18n'); ?></h3> <?php
1115
+ // Determines whether or not to continue processing. Only false if there was an error.
1116
+ $continue = true;
1117
+ foreach ($igs as $ig) {
1118
+ if ($continue) {
1119
+ if (!is_array($ig) || empty($ig) || $ig == 'N' ) {
1120
+ ?>
1121
+ <em><?php esc_html_e('No Interest Groups Setup for this List', 'mailchimp_i18n'); ?></em>
1122
+ <?php
1123
+ $continue = false;
1124
+ }
1125
+ else {
1126
+ ?>
1127
+ <table class='mc-widefat mc-blue' width="450px" cellspacing="0">
1128
+ <tr valign="top">
1129
+ <th colspan="2"><?php echo esc_html($ig['name']); ?></th>
1130
+ </tr>
1131
+ <tr valign="top">
1132
+ <th>
1133
+ <label for="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>"><?php esc_html_e('Show?', 'mailchimp_i18n'); ?></label>
1134
+ </th>
1135
+ <th>
1136
+ <input name="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>" id="<?php echo esc_attr('mc_show_interest_groups_'.$ig['id']); ?>" type="checkbox" class="code"<?php checked('on', get_option('mc_show_interest_groups_'.$ig['id'])); ?> />
1137
+ </th>
1138
+ </tr>
1139
+ <tr valign="top">
1140
+ <th><?php esc_html_e('Input Type', 'mailchimp_i18n'); ?></th>
1141
+ <td><?php echo esc_html($ig['form_field']); ?></td>
1142
+ </tr>
1143
+ <tr valign="top" class="last-row">
1144
+ <th><?php esc_html_e('Options', 'mailchimp_i18n'); ?></th>
1145
+ <td>
1146
+ <ul>
1147
+ <?php
1148
+ foreach($ig['groups'] as $interest){
1149
+ ?>
1150
+ <li><?php echo esc_html($interest['name']); ?></li>
1151
+ <?php
1152
+ }
1153
+ ?>
1154
+ </ul>
1155
+ </td>
1156
+ </tr>
1157
+ </table>
1158
  <?php
1159
+ }
1160
  }
1161
+ }
1162
+ }
1163
+ } // end dev mode check
1164
+ ?>
1165
+ <div style="width: 900px; margin-top: 35px;">
1166
+ <table class="widefat mc-widefat mc-yellow">
1167
+ <tr><th colspan="2">CSS Cheat Sheet</th></tr>
1168
  <tr valign="top">
1169
+ <th scope="row">.widget_mailchimpsf_widget </th>
1170
+ <td>This targets the entire widget container.</td>
1171
  </tr>
1172
  <tr valign="top">
1173
+ <th scope="row">.widget-title</th>
1174
+ <td>This styles the title of your MailChimp widget. <i>Modifying this class will affect your other widget titles.</i></td>
 
 
 
 
1175
  </tr>
1176
  <tr valign="top">
1177
+ <th scope="row">#mc_signup</th>
1178
+ <td>This targets the entirity of the widget beneath the widget title.</td>
1179
  </tr>
1180
+ <tr valign="top">
1181
+ <th scope="row">#mc_subheader</th>
1182
+ <td>This styles the subheader text.</td>
1183
+ </tr>
1184
+ <tr valign="top">
1185
+ <th scope="row">.mc_form_inside</th>
1186
+ <td>The guts and main container for the all of the form elements (the entirety of the widget minus the header and the sub header).</td>
1187
+ </tr>
1188
+ <tr valign="top">
1189
+ <th scope="row">.mc_header</th>
1190
+ <td>This targets the label above the input fields.</td>
1191
+ </tr>
1192
+ <tr valign="top">
1193
+ <th scope="row">.mc_input</th>
1194
+ <td>This attaches to the input fields.</td>
1195
+ </tr>
1196
+ <tr valign="top">
1197
+ <th scope="row">.mc_header_address</th>
1198
+ <td>This is the label above an address group.</td>
1199
+ </tr>
1200
+ <tr valign="top">
1201
+ <th scope="row">.mc_radio_label</th>
1202
+ <td>These are the labels associated with radio buttons.</td>
1203
+ </tr>
1204
+ <tr valign="top">
1205
+ <th scope="row">#mc-indicates-required</th>
1206
+ <td>This targets the “Indicates Required Field” text.</td>
1207
+ </tr>
1208
+ <tr valign="top">
1209
+ <th scope="row">#mc_signup_submit</th>
1210
+ <td>Use this to style the submit button.</td>
1211
  </tr>
1212
  </table>
1213
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1214
 
1215
  </form>
 
 
1216
  <?php
1217
  }//mailchimpSF_setup_page()
1218
 
1219
 
1220
  function mailchimpSF_register_widgets() {
1221
+ if (mailchimpSF_get_api() || MAILCHIMP_DEV_MODE == true) {
1222
  register_widget('mailchimpSF_Widget');
1223
  }
1224
  }
1257
  $opt_val = isset($_POST[$opt]) ? $_POST[$opt] : '';
1258
 
1259
  if (is_array($opt_val) && isset($opt_val['area'])) {
1260
+ // This filters out all 'falsey' elements
1261
+ $opt_val = array_filter($opt_val);
1262
+
1263
+ // If they weren't all empty
1264
+ if ($opt_val) {
1265
+ $opt_val = implode('-', $opt_val);
1266
+ if (strlen($opt_val) < 12) {
1267
+ $opt_val = '';
1268
+ }
1269
+ }
1270
+ else {
1271
+ $opt_val = '';
1272
+ }
1273
  }
1274
  else if (is_array($opt_val) && $var['field_type'] == 'address') {
1275
  if ($var['req'] == 'Y') {
mailchimp_widget.php CHANGED
@@ -9,7 +9,7 @@ function mailchimpSF_signup_form($args = array()) {
9
  $igs = get_option('mc_interest_groups');
10
 
11
  // See if we have valid Merge Vars
12
- if (!is_array($mv)){
13
  echo $before_widget;
14
  ?>
15
  <div class="mc_error_msg">
@@ -19,12 +19,21 @@ function mailchimpSF_signup_form($args = array()) {
19
  echo $after_widget;
20
  return;
21
  }
 
 
 
 
 
22
 
23
  if (!empty($before_widget)) {
24
  echo $before_widget;
25
  }
26
 
27
  $header = get_option('mc_header_content');
 
 
 
 
28
  // See if we have custom header content
29
  if (!empty($header)) {
30
  // See if we need to wrap the header content in our own div
@@ -39,6 +48,10 @@ function mailchimpSF_signup_form($args = array()) {
39
  }
40
 
41
  $sub_heading = trim(get_option('mc_subheader_content'));
 
 
 
 
42
  ?>
43
 
44
  <style>
@@ -178,7 +191,7 @@ function mailchimpSF_signup_form($args = array()) {
178
  if (is_array($igs) && !empty($igs)) {
179
  foreach ($igs as $ig) {
180
  if (is_array($ig) && isset($ig['id'])) {
181
- if ($igs && get_option('mc_show_interest_groups_'.$ig['id']) == 'on') {
182
  if ($ig['form_field'] != 'hidden') {
183
  ?>
184
  <div class="mc_interests_header">
@@ -205,7 +218,7 @@ function mailchimpSF_signup_form($args = array()) {
205
  }
206
  }
207
 
208
- if (get_option('mc_email_type_option')) {
209
  ?>
210
  <div class="mergeRow">
211
  <label class="mc_email_format"><?php _e('Preferred Format', 'mailchimp_i18n'); ?></label>
@@ -219,10 +232,16 @@ function mailchimpSF_signup_form($args = array()) {
219
 
220
  <?php
221
  }
 
 
 
 
 
 
222
  ?>
223
 
224
  <div class="mc_signup_submit">
225
- <input type="submit" name="mc_signup_submit" id="mc_signup_submit" value="<?php echo esc_attr(get_option('mc_submit_text')); ?>" class="button" />
226
  </div><!-- /mc_signup_submit -->
227
 
228
 
@@ -675,4 +694,51 @@ function mailchimp_country_list() {
675
  '174' => __('Zimbabwe', 'mailchimp_i18n'),
676
  );
677
  }
678
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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">
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
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>
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">
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>
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
 
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
+ }
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.1
6
- Stable tag: 1.3
7
 
8
  == Description ==
9
 
@@ -47,6 +47,20 @@ Where ever you want it to show up.
47
  Note: in some environments you will need to install the Exec_PHP plugin to use that method of display. It can be found here:
48
  http://wordpress.org/extend/plugins/exec-php/
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  == Upgrading ==
52
 
@@ -124,6 +138,9 @@ Maybe! Look in the /po/ directory in our plugin package and see if your language
124
 
125
  == Upgrade Notice ==
126
 
 
 
 
127
  = 1.3 =
128
  Now using OAuth flow within plugin for user authentication
129
 
@@ -146,6 +163,11 @@ Added support for multiple interest groups, field formatting based on type and d
146
 
147
  == Changelog ==
148
 
 
 
 
 
 
149
  = 1.3 =
150
  * Now using OAuth flow for user authentication
151
  * Admin UI refresh
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.7.1
6
+ Stable tag: 1.4
7
 
8
  == Description ==
9
 
47
  Note: in some environments you will need to install the Exec_PHP plugin to use that method of display. It can be found here:
48
  http://wordpress.org/extend/plugins/exec-php/
49
 
50
+ == Developer Mode ==
51
+
52
+ You can enable "Devleoper Mode" by adding the following line to your `wp-config.php` file just above the "That's all, stope editing!" line.
53
+
54
+ define('MAILCHIMP_DEV_MODE', true);
55
+
56
+ This will enable the MailChimp List Subscribe plugin to operate without the need to connect an external MailChimp Account, and will provide a
57
+ subscription form widget that will not actually submit anywhere.
58
+
59
+ This will allow you to style and configure the widget in non-production environments that are not publicly accessible.
60
+
61
+ For more Developer Mode customization options see the following article:
62
+
63
+ http://connect.mailchimp.com/how-to/how-to-article-configuring-developer-mode-for-the-list-subscribe-wordpress-plugin
64
 
65
  == Upgrading ==
66
 
138
 
139
  == Upgrade Notice ==
140
 
141
+ = 1.4 =
142
+ Added Developer Mode "Kitchen Sink" to aid in styling without having to authenticate a MailChimp account.
143
+
144
  = 1.3 =
145
  Now using OAuth flow within plugin for user authentication
146
 
163
 
164
  == Changelog ==
165
 
166
+ = 1.4 =
167
+ * Developer Mode "Kitchen Sink" takes over plugin for local development
168
+ * Developer Mode has filters of changable content
169
+ * Fix bug related to required US phone validation
170
+
171
  = 1.3 =
172
  * Now using OAuth flow for user authentication
173
  * Admin UI refresh