Permalink
Browse files

Support for non mailchimp named directory structure, multiple checkbo…

…x interest groups submit without failure
  • Loading branch information...
ejdanderson committed Apr 6, 2012
1 parent 4515fff commit 72c4b5e6b4b62b5101695c7042818542755a5602
Showing with 8 additions and 6 deletions.
  1. +8 −6 mailchimp.php
View
@@ -1199,8 +1199,8 @@ function mailchimpSF_signup_submit() {
// Ensure we have an array
$igs = !is_array($igs) ? array() : $igs;
- $groups = '';
foreach ($igs as $ig) {
+ $groups = '';
if (get_option('mc_show_interest_groups_'.$ig['id']) == 'on') {
$groupings = array();
switch ($ig['form_field']) {
@@ -1218,8 +1218,8 @@ function mailchimpSF_signup_submit() {
case 'checkbox':
if (isset($_POST['group'][$ig['id']])) {
foreach ($_POST['group'][$ig['id']] as $i => $value) {
+ // Escape
$groups .= str_replace(',', '\,', $value).',';
-
}
$groupings = array(
'id' => $ig['id'],
@@ -1287,6 +1287,7 @@ function mailchimpSF_signup_submit() {
}
if ($success) {
$api = new mailchimpSF_MCAPI(get_option('mc_apikey'));
+ error_log(print_r($merge,1));
$retval = $api->listSubscribe( $listId, $email, $merge, $email_type);
if (!$retval) {
switch($api->errorCode) {
@@ -1368,13 +1369,14 @@ function mailchimpSF_where_am_i() {
);
// Set defaults
- $mscf_dir = trailingslashit(WP_PLUGIN_DIR).'mailchimp/';
- $mscf_url = trailingslashit(WP_PLUGIN_URL).'mailchimp/';
+ $mscf_dirbase = trailingslashit(basename(dirname(__FILE__))); // Typically wp-mailchimp/ or mailchimp/
+ $mscf_dir = trailingslashit(WP_PLUGIN_DIR).$mscf_dirbase;
+ $mscf_url = trailingslashit(WP_PLUGIN_URL).$mscf_dirbase;
// Try our hands at finding the real location
foreach ($locations as $key => $loc) {
- $dir = trailingslashit($loc['dir']).'mailchimp/';
- $url = trailingslashit($loc['url']).'mailchimp/';
+ $dir = trailingslashit($loc['dir']).$mscf_dirbase;
+ $url = trailingslashit($loc['url']).$mscf_dirbase;
if (is_file($dir.basename(__FILE__))) {
$mscf_dir = $dir;
$mscf_url = $url;

0 comments on commit 72c4b5e

Please sign in to comment.