Version Description
Download this release
Release Info
Developer | mc_jesse |
Plugin | MailChimp List Subscribe Form |
Version | 1.0 |
Comparing to | |
See all releases |
Code changes from version 0.5 to 1.0
- MCAPI.class.php +11 -12
- mailchimp.php +166 -112
- readme.txt +1 -1
MCAPI.class.php
CHANGED
@@ -32,14 +32,14 @@ class MCAPI {
|
|
32 |
* @param string $password Your MailChimp login password - always required
|
33 |
*/
|
34 |
function MCAPI($username, $password) {
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
}
|
44 |
|
45 |
/**
|
@@ -230,7 +230,7 @@ class MCAPI {
|
|
230 |
|
231 |
For A/B Split campaigns, this array should contain:
|
232 |
string split_test The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaignSchedule() separately!
|
233 |
-
string
|
234 |
integer wait_units optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400.
|
235 |
integer wait_time optional the number of units to wait before auto-selecting a winner - defaults to 1, so if not set, a winner will be selected after 1 Day.
|
236 |
integer split_size optional this is a percentage of what size the Campaign's List plus any segmentation options results in. "schedule" type forces 50%, all others default to 10%
|
@@ -588,7 +588,7 @@ class MCAPI {
|
|
588 |
}
|
589 |
|
590 |
/**
|
591 |
-
*
|
592 |
*
|
593 |
* @section List Related
|
594 |
* @example xml-rpc_listMergeVarAdd.php
|
@@ -888,7 +888,7 @@ class MCAPI {
|
|
888 |
* @example xml-rpc_inlineCss.php
|
889 |
*
|
890 |
* @param string $html Your HTML content
|
891 |
-
* @param bool $strip_css Whether you want the CSS
|
892 |
* @return string Your HTML content with all CSS inlined, just like if we sent it.
|
893 |
*/
|
894 |
function inlineCss($html, $strip_css=false) {
|
@@ -963,7 +963,6 @@ class MCAPI {
|
|
963 |
* version 1.1, you should run this once anyways. Running this will *not* prevent you from using version 1.0 if you need to.
|
964 |
*
|
965 |
* @section Security Related
|
966 |
-
* @example xml-rpc_login.php
|
967 |
*
|
968 |
* @param string $username Your MailChimp user name
|
969 |
* @param string $password Your MailChimp password
|
32 |
* @param string $password Your MailChimp login password - always required
|
33 |
*/
|
34 |
function MCAPI($username, $password) {
|
35 |
+
//do more "caching" of the uuid for those people that keep instantiating this...
|
36 |
+
$this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
|
37 |
+
if (isset($GLOBALS["mc_api_key"]) && $GLOBALS["mc_api_key"]!=""){
|
38 |
+
$this->api_key = $GLOBALS["mc_api_key"];
|
39 |
+
} else {
|
40 |
+
$this->api_key = $this->callServer("login", array("username" => $username, "password" => $password));
|
41 |
+
$GLOBALS["mc_api_key"] = $this->api_key;
|
42 |
+
}
|
43 |
}
|
44 |
|
45 |
/**
|
230 |
|
231 |
For A/B Split campaigns, this array should contain:
|
232 |
string split_test The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaignSchedule() separately!
|
233 |
+
string pick_winner How the winner will be picked, one of: "opens" (by the open_rate), "clicks" (by the click rate), "manual" (you pick manually)
|
234 |
integer wait_units optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400.
|
235 |
integer wait_time optional the number of units to wait before auto-selecting a winner - defaults to 1, so if not set, a winner will be selected after 1 Day.
|
236 |
integer split_size optional this is a percentage of what size the Campaign's List plus any segmentation options results in. "schedule" type forces 50%, all others default to 10%
|
588 |
}
|
589 |
|
590 |
/**
|
591 |
+
* Add a new merge tag to a given list
|
592 |
*
|
593 |
* @section List Related
|
594 |
* @example xml-rpc_listMergeVarAdd.php
|
888 |
* @example xml-rpc_inlineCss.php
|
889 |
*
|
890 |
* @param string $html Your HTML content
|
891 |
+
* @param bool $strip_css optional Whether you want the CSS <style> tags stripped from the returned document. Defaults to false.
|
892 |
* @return string Your HTML content with all CSS inlined, just like if we sent it.
|
893 |
*/
|
894 |
function inlineCss($html, $strip_css=false) {
|
963 |
* version 1.1, you should run this once anyways. Running this will *not* prevent you from using version 1.0 if you need to.
|
964 |
*
|
965 |
* @section Security Related
|
|
|
966 |
*
|
967 |
* @param string $username Your MailChimp user name
|
968 |
* @param string $password Your MailChimp password
|
mailchimp.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: MailChimp
|
4 |
Plugin URI: http://mailchimp.com/api/plugins/wordpress
|
5 |
Description: The MailChimp plugin allows you to easily setup a Subscribe box for your MailChimp list - So easy a chimp could do it!
|
6 |
-
Version: 0
|
7 |
Author: MailChimp API Support Team
|
8 |
Author URI: http://mailchimp.com/api/
|
9 |
*/
|
@@ -77,101 +77,107 @@ function mc_add_pages() {
|
|
77 |
}
|
78 |
|
79 |
function mc_setup_page(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
?>
|
81 |
<div class="wrap">
|
82 |
<h2>MailChimp List Setup</h2>
|
83 |
<?php
|
|
|
|
|
|
|
84 |
//see if we need to set/change the username & password.
|
85 |
-
if (isset($_REQUEST['mc_username']) && isset($_REQUEST['
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
}
|
100 |
-
} else {
|
101 |
-
$msg = "<span class='error_msg'>Uh-oh, we were unable to login and verify your username & password. Please check them and try again!<br/>";
|
102 |
-
$msg .= "The server said: <i>".$api->errorMessage."</i></span>";
|
103 |
-
if (get_option('mc_username')==''){
|
104 |
-
$delete_setup = true;
|
105 |
-
}
|
106 |
}
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
delete_option('mc_list_id');
|
113 |
-
delete_option('mc_list_name');
|
114 |
-
delete_option('mc_interest_groups');
|
115 |
-
delete_option('mc_show_interest_groups');
|
116 |
-
$mv = unserialize(get_option('mc_merge_vars'));
|
117 |
-
foreach($mv as $var){
|
118 |
-
$opt = 'mc_mv_'.$var['tag'];
|
119 |
-
delete_option($opt);
|
120 |
-
}
|
121 |
-
delete_option('mc_merge_vars');
|
122 |
}
|
123 |
}
|
124 |
-
if (
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
}
|
133 |
//set these for the form fields below
|
134 |
$user = $_REQUEST['mc_username'];
|
135 |
-
$pass = $_REQUEST['mc_password'];
|
136 |
} else {
|
137 |
$user = get_option('mc_username');
|
138 |
$pass = get_option('mc_password');
|
139 |
}
|
140 |
-
if (
|
141 |
-
|
|
|
142 |
$lists = $api->lists();
|
|
|
143 |
foreach($lists as $list){ if ($list['id']==$_REQUEST['mc_list_id']){ $list_id = $_REQUEST['mc_list_id']; $list_name = $list['name']; } }
|
144 |
-
if ($list_id == ''){
|
145 |
-
$msg = '<span class="error_msg">Uh-oh, something went wrong while trying to load List with ID: '.$_REQUEST['mc_list_id'].'</span>';
|
146 |
-
|
147 |
-
} else {
|
148 |
-
update_option('mc_list_id', $list_id);
|
149 |
-
update_option('mc_list_name', $list_name);
|
150 |
-
|
151 |
-
update_option('mc_header_content','<h2>Sign up for '.$list_name.'</h2>');
|
152 |
-
update_option('mc_submit_text','Subscribe');
|
153 |
-
|
154 |
-
update_option('mc_custom_style','on');
|
155 |
-
update_option('mc_form_border_width','1');
|
156 |
-
update_option('mc_form_border_color','ccc');
|
157 |
-
update_option('mc_form_background','ffffcc');
|
158 |
-
update_option('mc_form_text_color','666666');
|
159 |
-
|
160 |
-
$mv = $api->listMergeVars($list_id);
|
161 |
-
$ig = $api->listInterestGroups($list_id);
|
162 |
-
update_option('mc_merge_vars', serialize( $mv ) );
|
163 |
-
foreach($mv as $var){
|
164 |
-
$opt = 'mc_mv_'.$var['tag'];
|
165 |
-
//turn them all on by default
|
166 |
-
update_option($opt, 'on' );
|
167 |
-
}
|
168 |
-
update_option('mc_interest_groups', serialize( $ig ) );
|
169 |
-
update_option('mc_show_interest_groups', 'on' );
|
170 |
-
$msg = '<span class="success_msg">Success! Loaded and saved the info for '.sizeof($mv).' Merge Variables and '.
|
171 |
-
sizeof($ig).' Interest Groups from your list "'.$list['name'].'"<br/><br/>
|
172 |
-
Now you should either Turn On the MailChimp Widget or change your options below, then turn it on.</span>';
|
173 |
-
}
|
174 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
176 |
if (isset($_REQUEST['reset_list'])){
|
177 |
delete_option('mc_list_id');
|
@@ -191,6 +197,16 @@ if (isset($_REQUEST['reset_list'])){
|
|
191 |
$msg = '<span class="success_msg">Successfully Reset your List selection... Now you get to pick again!</span>';
|
192 |
}
|
193 |
if (isset($_REQUEST['change_form_settings'])){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
$content = stripslashes($_REQUEST['mc_header_content']);
|
195 |
$content = str_replace("\r\n","<br/>", $content);
|
196 |
update_option('mc_header_content', $content );
|
@@ -236,7 +252,9 @@ if ($msg){
|
|
236 |
}
|
237 |
?>
|
238 |
<form method="post" action="options-general.php?page=mc_setup_page">
|
239 |
-
<?php wp_nonce_field('update-options');
|
|
|
|
|
240 |
<h3>Login Info</h3>
|
241 |
To start using the MailChimp plugin, we first need to store your MailChimp Username & Password<br/>
|
242 |
<table class="form-table">
|
@@ -248,60 +266,73 @@ To start using the MailChimp plugin, we first need to store your MailChimp Usern
|
|
248 |
<th scope="row">Password:</th>
|
249 |
<td><input name="mc_password" type="text" id="mc_password" class="code" value="<?php echo $pass; ?>" size="20" /></td>
|
250 |
</tr>
|
251 |
-
<tr valign="top">
|
252 |
-
<th scope="row">Monkey Rewards:</th>
|
253 |
-
<td><input name="mc_rewards" type="checkbox" <?php if (get_option('mc_rewards')=='on' || get_option('mc_rewards')=='' ) {echo 'checked';} ?> id="mc_rewards" class="code" />
|
254 |
-
<i>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.</i>
|
255 |
-
</td>
|
256 |
-
</tr>
|
257 |
</table>
|
258 |
-
|
259 |
-
<p class="submit">
|
260 |
<input type="hidden" name="action" value="update"/>
|
261 |
<input type="hidden" name="page_options" value="mc_username,mc_password" />
|
262 |
<input type="submit" name="Submit" value="Save & Check" class="button" />
|
|
|
263 |
<?php
|
264 |
-
if (get_option('mc_username')!=''){
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
}
|
|
|
|
|
272 |
?>
|
273 |
-
|
|
|
|
|
|
|
|
|
274 |
</form>
|
|
|
|
|
|
|
|
|
275 |
<?php
|
276 |
//Just get out if nothing else matters...
|
277 |
-
if (get_option('
|
278 |
|
279 |
-
if (get_option('
|
280 |
?>
|
281 |
-
<form method="post" action="options-general.php?page=mc_setup_page">
|
282 |
<?php wp_nonce_field('update-options'); ?>
|
283 |
<h3>Your Lists</h3>
|
284 |
Please select the List you wish to create a Signup Form for.<br/>
|
|
|
285 |
<?php
|
286 |
$api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
|
287 |
$lists = $api->lists();
|
288 |
rsort($lists);
|
289 |
-
foreach ($lists as $list){
|
290 |
-
echo '<input type="radio" name="mc_list_id" value="'.$list['id'].'"> <strong>'.$list['name'].'</strong><br/>';
|
291 |
-
}
|
292 |
if (sizeof($lists)==0){
|
293 |
echo "<span class='error_msg'>Uh-oh, you don't have any lists defined! Please visit <a href='http://www.mailchimp.com/'>MailChimp</a>, login, and setup a list before using this tool!</span>";
|
294 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
?>
|
296 |
-
|
|
|
297 |
<input type="hidden" name="action" value="update" />
|
298 |
<input type="hidden" name="page_options" value="mc_list_id" />
|
299 |
-
<input type="submit" name="Submit" value="
|
300 |
-
</
|
301 |
</form>
|
|
|
302 |
<?php
|
303 |
-
} //end select list
|
304 |
-
else {
|
305 |
//display the selected list...
|
306 |
?>
|
307 |
<form method="post" action="options-general.php?page=mc_setup_page">
|
@@ -334,7 +365,13 @@ if (!is_array($ig)){
|
|
334 |
<?php wp_nonce_field('update-options'); ?>
|
335 |
<div style="width:600px;">
|
336 |
<table class="widefat">
|
337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
<th scope="row">Header content:</th>
|
339 |
<td>
|
340 |
<textarea name="mc_header_content" cols="50"><?php echo get_option('mc_header_content');?></textarea><br/>
|
@@ -453,18 +490,34 @@ function mc_register_widgets(){
|
|
453 |
|
454 |
}
|
455 |
function mc_display_widget(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
$mv = get_option('mc_merge_vars');
|
457 |
$ig = get_option('mc_interest_groups');
|
458 |
if (!is_array($mv)){
|
459 |
//apparently in WP 2.6 get_option() unserializes arrays for us.
|
460 |
$mv = unserialize($mv);
|
|
|
|
|
461 |
$ig = unserialize($ig);
|
462 |
}
|
463 |
|
464 |
$msg = '';
|
465 |
if (isset($_REQUEST['mc_signup'])){
|
466 |
$failed = false;
|
467 |
-
|
468 |
$email = $_REQUEST['mc_mv_EMAIL'];
|
469 |
$merge = array();
|
470 |
$errs = array();
|
@@ -497,7 +550,8 @@ function mc_display_widget(){
|
|
497 |
}
|
498 |
if (sizeof($merge) == 0 || $merge==''){ $merge = ''; }
|
499 |
|
500 |
-
|
|
|
501 |
$retval = $api->listSubscribe( $listId, $email, $merge);
|
502 |
if (!$retval){
|
503 |
$failed = true;
|
@@ -534,7 +588,7 @@ function mc_display_widget(){
|
|
534 |
}
|
535 |
}
|
536 |
echo '<sup style="clear:both;">* = required field</sup>';
|
537 |
-
if (get_option('mc_show_interest_groups')=='on'){
|
538 |
echo '<br/><br/><strong>'.$ig['name'].'</strong><br/>';
|
539 |
if ($ig['form_field']=='checkbox'){
|
540 |
foreach($ig['groups'] as $interest){
|
3 |
Plugin Name: MailChimp
|
4 |
Plugin URI: http://mailchimp.com/api/plugins/wordpress
|
5 |
Description: The MailChimp plugin allows you to easily setup a Subscribe box for your MailChimp list - So easy a chimp could do it!
|
6 |
+
Version: 1.0
|
7 |
Author: MailChimp API Support Team
|
8 |
Author URI: http://mailchimp.com/api/
|
9 |
*/
|
77 |
}
|
78 |
|
79 |
function mc_setup_page(){
|
80 |
+
|
81 |
+
$msg = '';
|
82 |
+
if (get_option('mc_password')!=''){
|
83 |
+
//some upgrade code for < 0.5 users - we want to rip out the password we've been saving.
|
84 |
+
$api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
|
85 |
+
if ($api->errorCode == ''){
|
86 |
+
update_option('mc_apikey', $api->api_key);
|
87 |
+
//this should already be here, but let's make sure anyway
|
88 |
+
$req = $api->getAffiliateInfo();
|
89 |
+
update_option('mc_user_id', $req['user_id']);
|
90 |
+
} else {
|
91 |
+
$msg = "<span class='error_msg'>While upgrading the plugin setup, we were unable to login to your account. You will need to login again and setup your list.<br/>";
|
92 |
+
}
|
93 |
+
delete_option('mc_password');
|
94 |
+
}
|
95 |
?>
|
96 |
<div class="wrap">
|
97 |
<h2>MailChimp List Setup</h2>
|
98 |
<?php
|
99 |
+
if ($_REQUEST['action']==='logout'){
|
100 |
+
update_option('mc_apikey', '');
|
101 |
+
}
|
102 |
//see if we need to set/change the username & password.
|
103 |
+
if (isset($_REQUEST['mc_username']) && isset($_REQUEST['mc_password'])){
|
104 |
+
$delete_setup = false;
|
105 |
+
$api = new MCAPI($_REQUEST['mc_username'], $_REQUEST['mc_password']);
|
106 |
+
if ($api->errorCode == ''){
|
107 |
+
$msg = "<span class='success_msg'>Success! We were able to verify your username & password! Let's continue, shall we?</span>";
|
108 |
+
update_option('mc_username', $_REQUEST['mc_username']);
|
109 |
+
update_option('mc_apikey', $api->api_key);
|
110 |
+
$req = $api->getAffiliateInfo();
|
111 |
+
update_option('mc_user_id', $req['user_id']);
|
112 |
+
if (get_option('mc_list_id')!=''){
|
113 |
+
$lists = $api->lists();
|
114 |
+
$delete_setup = true;
|
115 |
+
//but don't delete if the list still exists...
|
116 |
+
foreach($lists as $list){ if ($list['id']==get_option('mc_list_id')){ $list_id = $_REQUEST['mc_list_id']; $delete_setup=false; } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
}
|
118 |
+
} else {
|
119 |
+
$msg .= "<span class='error_msg'>Uh-oh, we were unable to login and verify your username & password. Please check them and try again!<br/>";
|
120 |
+
$msg .= "The server said: <i>".$api->errorMessage."</i></span>";
|
121 |
+
if (get_option('mc_username')==''){
|
122 |
+
$delete_setup = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
}
|
125 |
+
if ($delete_setup){
|
126 |
+
delete_option('mc_user_id');
|
127 |
+
delete_option('mc_username');
|
128 |
+
delete_option('mc_apikey');
|
129 |
+
delete_option('mc_rewards');
|
130 |
+
delete_option('mc_list_id');
|
131 |
+
delete_option('mc_list_name');
|
132 |
+
delete_option('mc_interest_groups');
|
133 |
+
delete_option('mc_show_interest_groups');
|
134 |
+
$mv = unserialize(get_option('mc_merge_vars'));
|
135 |
+
foreach($mv as $var){
|
136 |
+
$opt = 'mc_mv_'.$var['tag'];
|
137 |
+
delete_option($opt);
|
138 |
+
}
|
139 |
+
delete_option('mc_merge_vars');
|
140 |
}
|
141 |
//set these for the form fields below
|
142 |
$user = $_REQUEST['mc_username'];
|
|
|
143 |
} else {
|
144 |
$user = get_option('mc_username');
|
145 |
$pass = get_option('mc_password');
|
146 |
}
|
147 |
+
if (get_option('mc_apikey')!=''){
|
148 |
+
$GLOBALS["mc_api_key"] = get_option('mc_apikey');
|
149 |
+
$api = new MCAPI('no_login','is_needed');
|
150 |
$lists = $api->lists();
|
151 |
+
|
152 |
foreach($lists as $list){ if ($list['id']==$_REQUEST['mc_list_id']){ $list_id = $_REQUEST['mc_list_id']; $list_name = $list['name']; } }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
+
if ($list_id != ''){
|
155 |
+
update_option('mc_list_id', $list_id);
|
156 |
+
update_option('mc_list_name', $list_name);
|
157 |
+
|
158 |
+
update_option('mc_header_content','<h2>Sign up for '.$list_name.'</h2>');
|
159 |
+
update_option('mc_submit_text','Subscribe');
|
160 |
+
|
161 |
+
update_option('mc_custom_style','on');
|
162 |
+
update_option('mc_form_border_width','1');
|
163 |
+
update_option('mc_form_border_color','ccc');
|
164 |
+
update_option('mc_form_background','ffffcc');
|
165 |
+
update_option('mc_form_text_color','666666');
|
166 |
+
|
167 |
+
$mv = $api->listMergeVars($list_id);
|
168 |
+
$ig = $api->listInterestGroups($list_id);
|
169 |
+
update_option('mc_merge_vars', serialize( $mv ) );
|
170 |
+
foreach($mv as $var){
|
171 |
+
$opt = 'mc_mv_'.$var['tag'];
|
172 |
+
//turn them all on by default
|
173 |
+
update_option($opt, 'on' );
|
174 |
+
}
|
175 |
+
update_option('mc_interest_groups', serialize( $ig ) );
|
176 |
+
update_option('mc_show_interest_groups', 'on' );
|
177 |
+
$msg = '<span class="success_msg">Success! Loaded and saved the info for '.sizeof($mv).' Merge Variables and '.
|
178 |
+
sizeof($ig).' Interest Groups from your list "'.$list_name.'"<br/><br/>
|
179 |
+
Now you should either Turn On the MailChimp Widget or change your options below, then turn it on.</span>';
|
180 |
+
}
|
181 |
}
|
182 |
if (isset($_REQUEST['reset_list'])){
|
183 |
delete_option('mc_list_id');
|
197 |
$msg = '<span class="success_msg">Successfully Reset your List selection... Now you get to pick again!</span>';
|
198 |
}
|
199 |
if (isset($_REQUEST['change_form_settings'])){
|
200 |
+
if (isset($_REQUEST['mc_rewards']) && $_REQUEST['mc_rewards'] != get_option('mc_rewards')){
|
201 |
+
update_option('mc_rewards', 'on');
|
202 |
+
if ($msg) $msg .= '<br/>';
|
203 |
+
$msg .= '<span class="success_msg">Monkey Rewards turned On!</span>';
|
204 |
+
} else if (get_option('mc_rewards')!='off') {
|
205 |
+
update_option('mc_rewards', 'off');
|
206 |
+
if ($msg) $msg .= '<br/>';
|
207 |
+
$msg .= '<span class="success_msg">Monkey Rewards turned Off!</span>';
|
208 |
+
}
|
209 |
+
|
210 |
$content = stripslashes($_REQUEST['mc_header_content']);
|
211 |
$content = str_replace("\r\n","<br/>", $content);
|
212 |
update_option('mc_header_content', $content );
|
252 |
}
|
253 |
?>
|
254 |
<form method="post" action="options-general.php?page=mc_setup_page">
|
255 |
+
<?php wp_nonce_field('update-options');
|
256 |
+
if (get_option('mc_apikey')==''){
|
257 |
+
?>
|
258 |
<h3>Login Info</h3>
|
259 |
To start using the MailChimp plugin, we first need to store your MailChimp Username & Password<br/>
|
260 |
<table class="form-table">
|
266 |
<th scope="row">Password:</th>
|
267 |
<td><input name="mc_password" type="text" id="mc_password" class="code" value="<?php echo $pass; ?>" size="20" /></td>
|
268 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
</table>
|
|
|
|
|
270 |
<input type="hidden" name="action" value="update"/>
|
271 |
<input type="hidden" name="page_options" value="mc_username,mc_password" />
|
272 |
<input type="submit" name="Submit" value="Save & Check" class="button" />
|
273 |
+
</form>
|
274 |
<?php
|
275 |
+
if (get_option('mc_username')!=''){
|
276 |
+
echo '<strong>Notes:</strong><ul>
|
277 |
+
<li><i>Changing your settings at MailChimp.com may cause this to stop working.</i></li>
|
278 |
+
<li><i>Changing your username & password at MailChimp.com will cause this plugin to stop working!</i></li>
|
279 |
+
<li><i>If you change your login to a different account, the info you have setup below will be erased.</i></li>
|
280 |
+
<li><i>If any of that happens, no biggie - just reconfigure your login and the items below...</i></li></ul>
|
281 |
+
<br/>';
|
282 |
+
}
|
283 |
+
echo '</p>';
|
284 |
+
} else {
|
285 |
?>
|
286 |
+
<table style="min-width:400px;"><tr><td><h3>Logged in as: <?=get_option('mc_username')?></h3>
|
287 |
+
</td><td>
|
288 |
+
<form method="post" action="options-general.php?page=mc_setup_page">
|
289 |
+
<input type="hidden" name="action" value="logout"/>
|
290 |
+
<input type="submit" name="Submit" value="Logout" class="button" />
|
291 |
</form>
|
292 |
+
</td></tr></table>
|
293 |
+
<?
|
294 |
+
}
|
295 |
+
?>
|
296 |
<?php
|
297 |
//Just get out if nothing else matters...
|
298 |
+
if (get_option('mc_apikey') == '') return;
|
299 |
|
300 |
+
if (get_option('mc_apikey')!=''){
|
301 |
?>
|
|
|
302 |
<?php wp_nonce_field('update-options'); ?>
|
303 |
<h3>Your Lists</h3>
|
304 |
Please select the List you wish to create a Signup Form for.<br/>
|
305 |
+
<form method="post" action="options-general.php?page=mc_setup_page">
|
306 |
<?php
|
307 |
$api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
|
308 |
$lists = $api->lists();
|
309 |
rsort($lists);
|
|
|
|
|
|
|
310 |
if (sizeof($lists)==0){
|
311 |
echo "<span class='error_msg'>Uh-oh, you don't have any lists defined! Please visit <a href='http://www.mailchimp.com/'>MailChimp</a>, login, and setup a list before using this tool!</span>";
|
312 |
+
} else {
|
313 |
+
|
314 |
+
echo '<table style="min-width:400px"><tr><td>
|
315 |
+
<select name="mc_list_id" height="100px" style="min-width:200px;">';
|
316 |
+
foreach ($lists as $list){
|
317 |
+
if ($list['id'] == get_option('mc_list_id')){
|
318 |
+
$sel = ' selected ';
|
319 |
+
} else {
|
320 |
+
$sel = '';
|
321 |
+
}
|
322 |
+
echo '<option value="'.$list['id'].'"'.$sel.'>'.$list['name'].'</option>';
|
323 |
+
}
|
324 |
?>
|
325 |
+
</select></td><td>
|
326 |
+
|
327 |
<input type="hidden" name="action" value="update" />
|
328 |
<input type="hidden" name="page_options" value="mc_list_id" />
|
329 |
+
<input type="submit" name="Submit" value="Change List" class="button" />
|
330 |
+
</td></tr></table>
|
331 |
</form>
|
332 |
+
<br/>
|
333 |
<?php
|
334 |
+
} //end select list
|
335 |
+
} else {
|
336 |
//display the selected list...
|
337 |
?>
|
338 |
<form method="post" action="options-general.php?page=mc_setup_page">
|
365 |
<?php wp_nonce_field('update-options'); ?>
|
366 |
<div style="width:600px;">
|
367 |
<table class="widefat">
|
368 |
+
<tr valign="top">
|
369 |
+
<th scope="row">Monkey Rewards:</th>
|
370 |
+
<td><input name="mc_rewards" type="checkbox" <?php if (get_option('mc_rewards')=='on' || get_option('mc_rewards')=='' ) {echo 'checked';} ?> id="mc_rewards" class="code" />
|
371 |
+
<i>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.</i>
|
372 |
+
</td>
|
373 |
+
</tr>
|
374 |
+
<tr valign="top">
|
375 |
<th scope="row">Header content:</th>
|
376 |
<td>
|
377 |
<textarea name="mc_header_content" cols="50"><?php echo get_option('mc_header_content');?></textarea><br/>
|
490 |
|
491 |
}
|
492 |
function mc_display_widget(){
|
493 |
+
if (get_option('mc_password')!=''){
|
494 |
+
//some upgrade code for < 0.5 users - we want to rip out the password we've been saving.
|
495 |
+
$api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
|
496 |
+
if ($api->errorCode == ''){
|
497 |
+
update_option('mc_apikey', $api->api_key);
|
498 |
+
//this should already be here, but let's make sure anyway
|
499 |
+
$req = $api->getAffiliateInfo();
|
500 |
+
update_option('mc_user_id', $req['user_id']);
|
501 |
+
} else {
|
502 |
+
$msg = "<span class='error_msg'>While upgrading the plugin setup, we were unable to login to your account. You will need to login again and setup your list.<br/>";
|
503 |
+
}
|
504 |
+
delete_option('mc_password');
|
505 |
+
}
|
506 |
+
|
507 |
$mv = get_option('mc_merge_vars');
|
508 |
$ig = get_option('mc_interest_groups');
|
509 |
if (!is_array($mv)){
|
510 |
//apparently in WP 2.6 get_option() unserializes arrays for us.
|
511 |
$mv = unserialize($mv);
|
512 |
+
}
|
513 |
+
if (!is_array($ig)){
|
514 |
$ig = unserialize($ig);
|
515 |
}
|
516 |
|
517 |
$msg = '';
|
518 |
if (isset($_REQUEST['mc_signup'])){
|
519 |
$failed = false;
|
520 |
+
$listId = get_option('mc_list_id');
|
521 |
$email = $_REQUEST['mc_mv_EMAIL'];
|
522 |
$merge = array();
|
523 |
$errs = array();
|
550 |
}
|
551 |
if (sizeof($merge) == 0 || $merge==''){ $merge = ''; }
|
552 |
|
553 |
+
$GLOBALS["mc_api_key"] = get_option('mc_apikey');
|
554 |
+
$api = new MCAPI('no_login','is_needed');
|
555 |
$retval = $api->listSubscribe( $listId, $email, $merge);
|
556 |
if (!$retval){
|
557 |
$failed = true;
|
588 |
}
|
589 |
}
|
590 |
echo '<sup style="clear:both;">* = required field</sup>';
|
591 |
+
if (get_option('mc_show_interest_groups')=='on' && $ig){
|
592 |
echo '<br/><br/><strong>'.$ig['name'].'</strong><br/>';
|
593 |
if ($ig['form_field']=='checkbox'){
|
594 |
foreach($ig['groups'] as $interest){
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: mc_jesse
|
|
3 |
Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
|
4 |
Requires at least: 2.3
|
5 |
Tested up to: 2.6
|
6 |
-
Stable tag: 0
|
7 |
Author URI: http://www.mailchimp.com/api/
|
8 |
Plugin URI: http://www.mailchimp.com/plugins/wordpress.phtml
|
9 |
|
3 |
Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
|
4 |
Requires at least: 2.3
|
5 |
Tested up to: 2.6
|
6 |
+
Stable tag: 1.0
|
7 |
Author URI: http://www.mailchimp.com/api/
|
8 |
Plugin URI: http://www.mailchimp.com/plugins/wordpress.phtml
|
9 |
|