MailChimp List Subscribe Form - Version 0.1

Version Description

Download this release

Release Info

Developer mc_jesse
Plugin Icon wp plugin MailChimp List Subscribe Form
Version 0.1
Comparing to
See all releases

Code changes from version 1.0.2 to 0.1

Files changed (5) hide show
  1. MCAPI.class.php +99 -427
  2. mailchimp.php +192 -276
  3. po/mailchimp_i18n-en_US.mo +0 -0
  4. po/mailchimp_i18n-en_US.po +0 -269
  5. readme.txt +7 -36
MCAPI.class.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  class MCAPI {
4
- var $version = "1.1";
5
  var $errorMessage;
6
  var $errorCode;
7
 
@@ -21,9 +21,9 @@ class MCAPI {
21
  var $chunkSize = 8192;
22
 
23
  /**
24
- * Cache the user api_key so we only have to log in once per client instantiation
25
  */
26
- var $api_key;
27
 
28
  /**
29
  * Connect to the MailChimp API for a given list. All MCAPI calls require login before functioning
@@ -32,14 +32,8 @@ class MCAPI {
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
  /**
@@ -48,7 +42,7 @@ class MCAPI {
48
  * @section Campaign Related
49
  * @example xml-rpc_campaignUnschedule.php
50
  *
51
- * @param string $cid the id of the campaign to unschedule
52
  * @return boolean true on success
53
  */
54
  function campaignUnschedule($cid) {
@@ -63,53 +57,24 @@ class MCAPI {
63
  * @section Campaign Related
64
  * @example xml-rpc_campaignSchedule.php
65
  *
66
- * @param string $cid the id of the campaign to schedule
67
- * @param string $schedule_time the time to schedule the campaign. For A/B Split "schedule" campaigns, the time for Group A - in YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
68
- * @param string $schedule_time_b optional -the time to schedule Group B of an A/B Split "schedule" campaign - in YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
69
  * @return boolean true on success
70
  */
71
- function campaignSchedule($cid, $schedule_time, $schedule_time_b=NULL) {
72
  $params = array();
73
  $params["cid"] = $cid;
74
  $params["schedule_time"] = $schedule_time;
75
- $params["schedule_time_b"] = $schedule_time_b;
76
  return $this->callServer("campaignSchedule", $params);
77
  }
78
 
79
- /**
80
- * Resume sending a RSS campaign
81
- *
82
- * @section Campaign Related
83
- *
84
- * @param string $cid the id of the campaign to pause
85
- * @return boolean true on success
86
- */
87
- function campaignResume($cid) {
88
- $params = array();
89
- $params["cid"] = $cid;
90
- return $this->callServer("campaignResume", $params);
91
- }
92
-
93
- /**
94
- * Pause a RSS campaign from sending
95
- *
96
- * @section Campaign Related
97
- *
98
- * @param string $cid the id of the campaign to pause
99
- * @return boolean true on success
100
- */
101
- function campaignPause($cid) {
102
- $params = array();
103
- $params["cid"] = $cid;
104
- return $this->callServer("campaignPause", $params);
105
- }
106
-
107
  /**
108
  * Send a given campaign immediately
109
  *
110
  * @section Campaign Related
 
111
  *
112
- * @param string $cid the id of the campaign to resume
113
  * @return boolean true on success
114
  */
115
  function campaignSendNow($cid) {
@@ -124,9 +89,9 @@ class MCAPI {
124
  * @section Campaign Related
125
  * @example xml-rpc_campaignSendTest.php
126
  *
127
- * @param string $cid the id of the campaign to test
128
- * @param array $test_emails an array of email address to receive the test message
129
- * @param string $send_type optional by default (null) both formats are sent - "html" or "text" send just that format
130
  * @return boolean true on success
131
  */
132
  function campaignSendTest($cid, $test_emails=array (
@@ -155,134 +120,49 @@ class MCAPI {
155
  return $this->callServer("campaignTemplates", $params);
156
  }
157
 
158
- /**
159
- * Allows one to test their segmentation rules before creating a campaign using them
160
- *
161
- * @section Campaign Related
162
- * @example xml-rpc_campaignSegmentTest.php
163
- *
164
- * @param string $list_id the list to test segmentation on - get lists using lists()
165
- * @param array $options with 2 keys:
166
- string "match" controls whether to use AND or OR when applying your options - expects "<strong>any</strong>" (for OR) or "<strong>all</strong>" (for AND)
167
- array "conditions" - up to 10 different criteria to apply while segmenting. Each criteria row should contain 3 keys - "<strong>field</strong>", "<strong>op</strong>", or "<strong>value</strong>" based on these definitions:
168
-
169
- Field = "<strong>date</strong>" : Select based on various dates we track
170
- Valid Op(eration): <strong>eq</strong> (is) / <strong>gt</strong> (after) / <strong>lt</strong> (before)
171
- Valid Values:
172
- string last_campaign_sent uses the date of the last campaign sent
173
- string campaign_id - uses the send date of the campaign that carriers the Id submitted - see campaigns()
174
- string YYYY-MM-DD - ny date in the form of YYYY-MM-DD - <i>note:</i> anything that appears to start with YYYY will be treated as a date
175
-
176
- Field = "<strong>interests</strong>":
177
- Valid Op(erations): <strong>one</strong> / <strong>none</strong> / <strong>all</strong>
178
- Valid Values: a comma delimited of interest groups for the list - see listInterestGroups()
179
-
180
- Field = "<strong>aim</strong>"
181
- Valid Op(erations): <strong>open</strong> / <strong>noopen</strong> / <strong>click</strong> / <strong>noclick</strong>
182
- Valid Values: "<strong>any</strong>" or a valid AIM-enabled Campaign that has been sent
183
-
184
- Default Field = A Merge Var. Use <strong>Merge0-Merge15</strong> or the <strong>Custom Tag</strong> you've setup for your merge field - see listMergeVars()
185
- Valid Op(erations):
186
- <strong>eq</strong> (=)/<strong>ne</strong>(!=)/<strong>gt</strong>(>)/<strong>lt</strong>(<)/<strong>like</strong>(like '%blah%')/<strong>nlike</strong>(not like '%blah%')/<strong>starts</strong>(like 'blah%')/<strong>ends</strong>(like '%blah')
187
- Valid Values: any string
188
- * @return integer total The total number of subscribers matching your segmentation options
189
- */
190
- function campaignSegmentTest($list_id, $options) {
191
- $params = array();
192
- $params["list_id"] = $list_id;
193
- $params["options"] = $options;
194
- return $this->callServer("campaignSegmentTest", $params);
195
- }
196
-
197
  /**
198
  * Create a new draft campaign to send
199
  *
200
  * @section Campaign Related
201
- * @example mcapi_campaignCreate.php
202
- * @example xml-rpc_campaignCreate.php
203
- * @example xml-rpc_campaignCreateABSplit.php
204
- * @example xml-rpc_campaignCreateRss.php
205
- *
206
- * @param string $type the Campaign Type to create - one of "regular", "plaintext", "absplit", "rss"
207
- * @param array $opts a hash of the standard options for this campaign :
208
- string list_id the list to send this campaign to- get lists using lists()
209
- string subject the subject line for your campaign message
210
- string from_email the From: email address for your campaign message
211
- string from_name the From: name for your campaign message (not an email address)
212
- integer template_id optional - use this template to generate the HTML content of the campaign
213
- array tracking optional - set which recipient actions will be tracked, as a struct of boolean values with the following keys: "opens", "html_clicks", and "text_clicks". By default, opens and HTML clicks will be tracked.
214
- string title optional - an internal name to use for this campaign. By default, the campaign subject will be used.
215
- boolean authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false.
216
- array analytics optional - if provided, use a struct with "service type" as a key and the "service tag" as a value. For Google, this should be "google"=>"your_google_analytics_key_here". Note that only "google" is currently supported - a Google Analytics tags will be added to all links in the campaign with this string attached. Others may be added in the future
217
- boolean inline_css optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false.
218
- boolean generate_text optional Whether of not to auto-generate your Text content from the HTML content. Note that this will be ignored if the Text part of the content passed is not empty, defaults to false.
219
-
220
- * @param array $content the content for this campaign - use a struct with the following keys:
221
- "html" for pasted HTML content
222
- "text" for the plain-text version
223
- "url" to have us pull in content from a URL (will replace any "html" content you pass in - can be used with "generate_text" option as well).
224
-
225
- If you chose a template instead of pasting in your HTML content, then use "html_" followed by the template sections as keys - for example, use a key of "html_MAIN" to fill in the "MAIN" section of a template. Supported template sections include: "html_HEADER", "html_MAIN", "html_SIDECOLUMN", and "html_FOOTER"
226
- * @param array $segment_opts optional - if you wish to do Segmentation with this campaign this array should contain: see campaignSegmentTest(). You should test your options against campaignSegmentTest() as campaignCreate() will not allow you to set a segment that includes no members.
227
- * @param array $type_opts optional -
228
- For RSS Campaigns this, array should contain:
229
- string url the URL to pull RSS content from - it will be verified and must exist
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%
237
- string from_name_a optional sort of, required when split_test is "from_name"
238
- string from_name_b optional sort of, required when split_test is "from_name"
239
- string from_email_a optional sort of, required when split_test is "from_name"
240
- string from_email_b optional sort of, required when split_test is "from_name"
241
- string subject_a optional sort of, required when split_test is "subject"
242
- string subject_b optional sort of, required when split_test is "subject"
243
- *
244
  * @return string the ID for the created campaign
245
  */
246
- function campaignCreate($type, $options, $content, $segment_opts=NULL, $type_opts=NULL) {
 
 
 
 
247
  $params = array();
248
- $params["type"] = $type;
249
- $params["options"] = $options;
 
 
250
  $params["content"] = $content;
251
- $params["segment_opts"] = $segment_opts;
252
- $params["type_opts"] = $type_opts;
 
 
 
253
  return $this->callServer("campaignCreate", $params);
254
  }
255
 
256
- /** Update just about any setting for a campaign that has <i>not</i> been sent. See campaignCreate() for details
257
- *
258
- * Caveats:<br/><ul>
259
- * <li>If you set list_id, all segmentation options will be deleted and must be re-added.</li>
260
- * <li>If you set template_id, you need to follow that up by setting it's 'content'</li>
261
- * <li>If you set segment_opts, you should have tested your options against campaignSegmentTest() as campaignUpdate() will not allow you to set a segment that includes no members.</li></ul>
262
- * @section Campaign Related
263
- * @example xml-rpc_campaignUpdate.php
264
- * @example xml-rpc_campaignUpdateAB.php
265
- *
266
- * @param string $cid the Campaign Id to update
267
- * @param string $name the parameter name ( see campaignCreate() )
268
- * @param mixed $value an appropriate value for the parameter ( see campaignCreate() )
269
- * @return boolean true if the update succeeds, otherwise an error will be thrown
270
- */
271
- function campaignUpdate($cid, $name, $value) {
272
- $params = array();
273
- $params["cid"] = $cid;
274
- $params["name"] = $name;
275
- $params["value"] = $value;
276
- return $this->callServer("campaignUpdate", $params);
277
- }
278
-
279
  /**
280
- * Get the list of campaigns and their details matching the specified filters
281
  *
282
  * @section Campaign Related
283
- * @example xml-rpc_campaigns.php
284
  *
285
- * @param string $filter_id optional - only show campaigns from this list id - get lists using lists()
286
  * @param integer $filter_folder optional - only show campaigns from this folder id - get folders using campaignFolders()
287
  * @param string $filter_fromname optional - only show campaigns that have this "From Name"
288
  * @param string $filter_fromemail optional - only show campaigns that have this "Reply-to Email"
@@ -291,22 +171,20 @@ class MCAPI {
291
  * @param string $filter_sendtimestart optional - only show campaigns that have been sent since this date/time
292
  * @param string $filter_sendtimeend optional - only show campaigns that have been sent before this date/time
293
  * @param boolean $filter_exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values
294
- * @param integer $start optional - control paging of campaigns, start results at this campaign #, defaults to 1st page of data (page 0)
295
  * @param integer $limit optional - control paging of campaigns, number of campaigns to return with each call, defaults to 25 (max=5000)
296
  * @return array list of campaigns and their associated information (see Returned Fields for description)
297
  * @returnf string id Campaign Id (used for all other campaign functions)
298
  * @returnf string title Title of the campaign
299
- * @returnf string type The type of campaign this is (regular, plaintext, absplit, rss, etc.)
300
  * @returnf date create_time Creation time for the campaign
301
  * @returnf date send_time Send time for the campaign
302
- * @returnf integer emails_sent Number of emails email was sent to
303
  * @returnf string status Status of the given campaign (sent,scheduled,etc.)
304
  * @returnf string from_name From name of the given campaign
305
  * @returnf string from_email Reply-to email of the given campaign
306
  * @returnf string subject Subject of the given campaign
307
- * @returnf string to_email Custom "To:" email string using merge variables
308
  * @returnf string archive_url Archive link for the given campaign
309
- * @returnf boolean inline_css Whether or not the campaigns content auto-css-lined
310
  */
311
  function campaigns($filter_id=NULL, $filter_folder=NULL, $filter_fromname=NULL, $filter_fromemail=NULL, $filter_title=NULL, $filter_subject=NULL, $filter_sendtimestart=NULL, $filter_sendtimeend=NULL, $filter_exact=true, $start=0, $limit=25) {
312
  $params = array();
@@ -328,7 +206,6 @@ class MCAPI {
328
  * List all the folders for a user account
329
  *
330
  * @section Campaign Related
331
- * @example xml-rpc_campaignFolders.php
332
  *
333
  * @return array Array of folder structs (see Returned Fields for details)
334
  * @returnf integer folder_id Folder Id for the given folder, this can be used in the campaigns() function to filter on.
@@ -343,9 +220,8 @@ class MCAPI {
343
  * Given a list and a campaign, get all the relevant campaign statistics (opens, bounces, clicks, etc.)
344
  *
345
  * @section Campaign Stats
346
- * @example xml-rpc_campaignStats.php
347
  *
348
- * @param string $cid the campaign id to pull stats for (can be gathered using campaigns())
349
  * @return array struct of the statistics for this campaign
350
  * @returnf integer syntax_errors Number of email addresses in campaign that had syntactical errors.
351
  * @returnf integer hard_bounces Number of email addresses in campaign that hard bounced.
@@ -374,7 +250,7 @@ class MCAPI {
374
  *
375
  * @section Campaign Stats
376
  *
377
- * @param string $cid the campaign id to pull stats for (can be gathered using campaigns())
378
  * @return struct list of urls and their associated statistics
379
  * @returnf integer clicks Number of times the specific link was clicked
380
  * @returnf integer unique Number of unique people who clicked on the specific link
@@ -385,14 +261,33 @@ class MCAPI {
385
  return $this->callServer("campaignClickStats", $params);
386
  }
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  /**
389
  * Get all email addresses with Hard Bounces for a given campaign
390
  *
391
  * @section Campaign Stats
392
  *
393
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
394
- * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
395
- * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
396
  * @return array Arrays of email addresses with Hard Bounces
397
  */
398
  function campaignHardBounces($cid, $start=0, $limit=1000) {
@@ -408,9 +303,9 @@ class MCAPI {
408
  *
409
  * @section Campaign Stats
410
  *
411
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
412
- * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
413
- * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
414
  * @return array Arrays of email addresses with Soft Bounces
415
  */
416
  function campaignSoftBounces($cid, $start=0, $limit=1000) {
@@ -426,9 +321,9 @@ class MCAPI {
426
  *
427
  * @section Campaign Stats
428
  *
429
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
430
- * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
431
- * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
432
  * @return array list of email addresses that unsubscribed from this campaign
433
  */
434
  function campaignUnsubscribes($cid, $start=0, $limit=1000) {
@@ -444,9 +339,9 @@ class MCAPI {
444
  *
445
  * @section Campaign Stats
446
  *
447
- * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
448
- * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
449
- * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
450
  * @return array list of email addresses that complained (filed abuse reports) about this campaign
451
  */
452
  function campaignAbuseReports($cid, $start=0, $limit=1000) {
@@ -462,7 +357,7 @@ class MCAPI {
462
  *
463
  * @section Campaign Related
464
  *
465
- * @param string $cid the campaign id to get content for (can be gathered using campaigns())
466
  * @return struct Struct containing all content for the campaign (see Returned Fields for details
467
  * @returnf string html The HTML content used for the campgain with merge tags intact
468
  * @returnf string text The Text content used for the campgain with merge tags intact
@@ -478,9 +373,9 @@ class MCAPI {
478
  *
479
  * @section Campaign AIM
480
  *
481
- * @param string $cid the campaign id to get opens for (can be gathered using campaigns())
482
- * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
483
- * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
484
  * @return array Array of structs containing email addresses and open counts
485
  * @returnf string email Email address that opened the campaign
486
  * @returnf integer open_count Total number of times the campaign was opened by this email address
@@ -498,9 +393,9 @@ class MCAPI {
498
  *
499
  * @section Campaign AIM
500
  *
501
- * @param string $cid the campaign id to get no opens for (can be gathered using campaigns())
502
- * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
503
- * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
504
  * @return array list of email addresses that did not open a campaign
505
  */
506
  function campaignNotOpenedAIM($cid, $start=0, $limit=1000) {
@@ -516,10 +411,10 @@ class MCAPI {
516
  *
517
  * @section Campaign AIM
518
  *
519
- * @param string $cid the campaign id to get click stats for (can be gathered using campaigns())
520
  * @param string $url the URL of the link that was clicked on
521
- * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
522
- * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
523
  * @return array Array of structs containing email addresses and click counts
524
  * @returnf string email Email address that opened the campaign
525
  * @returnf integer clicks Total number of times the URL was clicked on by this email address
@@ -538,7 +433,7 @@ class MCAPI {
538
  *
539
  * @section Campaign AIM
540
  *
541
- * @param string $cid the campaign id to get stats for (can be gathered using campaigns())
542
  * @param string $email_address the email address to get activity history for
543
  * @return array Array of structs containing actions (opens and clicks) that the email took, with timestamps
544
  * @returnf string action The action taken (open or click)
@@ -573,7 +468,6 @@ class MCAPI {
573
  * Get the list of merge tags for a given list, including their name, tag, and required setting
574
  *
575
  * @section List Related
576
- * @example xml-rpc_listMergeVars.php
577
  *
578
  * @param string $id the list id to connect to
579
  * @return array list of merge tags for the list
@@ -587,50 +481,10 @@ class MCAPI {
587
  return $this->callServer("listMergeVars", $params);
588
  }
589
 
590
- /**
591
- * Add a new merge tag to a given list
592
- *
593
- * @section List Related
594
- * @example xml-rpc_listMergeVarAdd.php
595
- *
596
- * @param string $id the list id to connect to
597
- * @param string $tag The merge tag to add, e.g. FNAME
598
- * @param string $name The long description of the tag being added, used for user displays
599
- * @param boolean $req optional Whether or not to require this field to be filled in, defaults to false
600
- * @return bool true if the request succeeds, otherwise an error will be thrown
601
- */
602
- function listMergeVarAdd($id, $tag, $name, $req=false) {
603
- $params = array();
604
- $params["id"] = $id;
605
- $params["tag"] = $tag;
606
- $params["name"] = $name;
607
- $params["req"] = $req;
608
- return $this->callServer("listMergeVarAdd", $params);
609
- }
610
-
611
- /**
612
- * Delete a merge tag from a given list and all it's members. Note that on large lists this method
613
- * may seem a bit slower than calls you typical make.
614
- *
615
- * @section List Related
616
- * @example xml-rpc_listMergeVarDel.php
617
- *
618
- * @param string $id the list id to connect to
619
- * @param string $tag The merge tag to delete
620
- * @return bool true if the request succeeds, otherwise an error will be thrown
621
- */
622
- function listMergeVarDel($id, $tag) {
623
- $params = array();
624
- $params["id"] = $id;
625
- $params["tag"] = $tag;
626
- return $this->callServer("listMergeVarDel", $params);
627
- }
628
-
629
  /**
630
  * Get the list of interest groups for a given list, including the label and form information
631
  *
632
  * @section List Related
633
- * @example xml-rpc_listInterestGroups.php
634
  *
635
  * @param string $id the list id to connect to
636
  * @return struct list of interest groups for the list
@@ -644,38 +498,6 @@ class MCAPI {
644
  return $this->callServer("listInterestGroups", $params);
645
  }
646
 
647
- /** Add a single Interest Group
648
- *
649
- * @section List Related
650
- * @example xml-rpc_listInterestGroupAdd.php
651
- *
652
- * @param string $id the list id to connect to
653
- * @param string $group_name the interest group to add
654
- * @return bool true if the request succeeds, otherwise an error will be thrown
655
- */
656
- function listInterestGroupAdd($id, $group_name) {
657
- $params = array();
658
- $params["id"] = $id;
659
- $params["group_name"] = $group_name;
660
- return $this->callServer("listInterestGroupAdd", $params);
661
- }
662
-
663
- /** Delete a single Interest Group
664
- *
665
- * @section List Related
666
- * @example xml-rpc_listInterestGroupDel.php
667
- *
668
- * @param string $id the list id to connect to
669
- * @param string $group_name the interest group to delete
670
- * @return bool true if the request succeeds, otherwise an error will be thrown
671
- */
672
- function listInterestGroupDel($id, $group_name) {
673
- $params = array();
674
- $params["id"] = $id;
675
- $params["group_name"] = $group_name;
676
- return $this->callServer("listInterestGroupDel", $params);
677
- }
678
-
679
  /**
680
  * Subscribe the provided email to a list
681
  *
@@ -686,11 +508,9 @@ class MCAPI {
686
  *
687
  * @param string $id the list id to connect to
688
  * @param string $email_address the email address to subscribe
689
- * @param array $merge_vars array of merges for the email (FNAME, LNAME, etc.) (see examples below for handling "blank" arrays). 2 "special" keys:
690
- string INTERESTS Set Interest Groups by passing a field named "INTERESTS" that contains a comma delimited list of Interest Groups to add.
691
- string OPTINIP Set the Opt-in IP fields. <i>Abusing this may cause your account to be suspended.</i>
692
  * @param string $email_type optional - email type preference for the email (html or text, defaults to html)
693
- * @param boolean $double_optin optional - flag to control whether a double opt-in confirmation message is sent, defaults to true. <i>Abusing this may cause your account to be suspended.</i>
694
  * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below)
695
  */
696
  function listSubscribe($id, $email_address, $merge_vars, $email_type='html', $double_optin=true) {
@@ -708,7 +528,6 @@ class MCAPI {
708
  *
709
  * @section List Related
710
  * @example mcapi_listUnsubscribe.php
711
- * @example xml-rpc_listUnsubscribe.php
712
  *
713
  * @param string $id the list id to connect to
714
  * @param string $email_address the email address to unsubscribe
@@ -731,7 +550,6 @@ class MCAPI {
731
  * Edit the email address, merge fields, and interest groups for a list member
732
  *
733
  * @section List Related
734
- * @example mcapi_listUpdateMember.php
735
  *
736
  * @param string $id the list id to connect to
737
  * @param string $email_address the current email address of the member to update
@@ -764,7 +582,7 @@ class MCAPI {
764
  * @return struct Array of result counts and any errors that occurred
765
  * @returnf integer success_count Number of email addresses that were succesfully added/updated
766
  * @returnf integer error_count Number of email addresses that failed during addition/updating
767
- * @returnf array errors Array of error structs. Each error struct will contain "code", "message", and the full struct that failed
768
  */
769
  function listBatchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) {
770
  $params = array();
@@ -780,7 +598,6 @@ class MCAPI {
780
  * Unsubscribe a batch of email addresses to a list
781
  *
782
  * @section List Related
783
- * @example mcapi_listBatchUnsubscribe.php
784
  *
785
  * @param string $id the list id to connect to
786
  * @param array $emails array of email addresses to unsubscribe
@@ -790,7 +607,7 @@ class MCAPI {
790
  * @return struct Array of result counts and any errors that occurred
791
  * @returnf integer success_count Number of email addresses that were succesfully added/updated
792
  * @returnf integer error_count Number of email addresses that failed during addition/updating
793
- * @returnf array errors Array of error structs. Each error struct will contain "code", "message", and "email"
794
  */
795
  function listBatchUnsubscribe($id, $emails, $delete_member=false, $send_goodbye=true, $send_notify=false) {
796
  $params = array();
@@ -803,15 +620,15 @@ class MCAPI {
803
  }
804
 
805
  /**
806
- * Get all of the list members for a list that are of a particular status
807
  *
808
  * @section List Related
809
  * @example mcapi_listMembers.php
810
  *
811
  * @param string $id the list id to connect to
812
  * @param string $status the status to get members for - one of(subscribed, unsubscribed, or cleaned), defaults to subscribed
813
- * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
814
- * @param integer $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 15000
815
  * @return array Array of list member structs (see Returned Fields for details)
816
  * @returnf string email Member email address
817
  * @returnf date timestamp timestamp of their associated status(date subscribed, unsubscribed, or cleaned)
@@ -830,8 +647,6 @@ class MCAPI {
830
  *
831
  * @section List Related
832
  * @example mcapi_listMemberInfo.php
833
- * @example xml-rpc_listMemberInfo.php
834
- *
835
  * @param string $id the list id to connect to
836
  * @param string $email_address the member email address to get information for
837
  * @return array array of list member info (see Returned Fields for details)
@@ -839,8 +654,6 @@ class MCAPI {
839
  * @returnf string email_type The type of emails this customer asked to get: html or text
840
  * @returnf array merges An associative array of all the merge tags and the data for those tags for this email address
841
  * @returnf string status The subscription status for this email address, either subscribed, unsubscribed or cleaned
842
- * @returnf string ip_opt IP Address this address opted in from.
843
- * @returnf string ip_signup IP Address this address signed up from.
844
  * @returnf date timestamp The time this email address was added to the list
845
  */
846
  function listMemberInfo($id, $email_address) {
@@ -850,146 +663,6 @@ class MCAPI {
850
  return $this->callServer("listMemberInfo", $params);
851
  }
852
 
853
- /**
854
- * Retrieve your User Unique Id and your Affiliate link to display/use for <a href="/monkeyrewards/" target="_blank">Monkey Rewards</a>. While
855
- * we don't use the User Id for any API functions, it can be useful if building up URL strings for things such as the profile editor and sub/unsub links.
856
- * @section Helper
857
- *
858
- * @return array containing your Affilliate Id and full link.
859
- * @returnf string user_id Your User Unique Id.
860
- * @returnf string url Your Monkey Rewards link for our Affiliate program
861
- */
862
- function getAffiliateInfo() {
863
- $params = array();
864
- return $this->callServer("getAffiliateInfo", $params);
865
- }
866
-
867
- /**
868
- * Have HTML content auto-converted to a text-only format. You can send: plain HTML, an array of Template content, an existing Campaign Id, or an existing Template Id. Note that this will <b>not</b> save anything to or update any of your lists, campaigns, or templates.
869
- *
870
- * @section Helper
871
- * @example xml-rpc_generateText.php
872
- *
873
- * @param string $type The type of content to parse. Must be one of: "html", "template", "url", "cid" (Campaign Id), or "tid" (Template Id)
874
- * @param mixed $content The content to use. For "html" expects a single string value, "template" expects an array like you send to campaignCreate, "url" expects a valid & public URL to pull from, "cid" expects a valid Campaign Id, and "tid" expects a valid Template Id on your account.
875
- * @return string the content pass in converted to text.
876
- */
877
- function generateText($type, $content) {
878
- $params = array();
879
- $params["type"] = $type;
880
- $params["content"] = $content;
881
- return $this->callServer("generateText", $params);
882
- }
883
-
884
- /**
885
- * Send your HTML content to have the CSS inlined and optionally remove the original styles.
886
- *
887
- * @section Helper
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 &lt;style&gt; 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) {
895
- $params = array();
896
- $params["html"] = $html;
897
- $params["strip_css"] = $strip_css;
898
- return $this->callServer("inlineCss", $params);
899
- }
900
-
901
- /**
902
- * Retrieve a list of all MailChimp API Keys for this User
903
- *
904
- * @section Security Related
905
- * @example xml-rpc_apikeyAdd.php
906
- *
907
- * @param string $username Your MailChimp user name
908
- * @param string $password Your MailChimp password
909
- * @param boolean $expired optional - whether or not to include expired keys, defaults to false
910
- * @return array an array of API keys including:
911
- * @returnf string apikey The api key that can be used
912
- * @returnf string created_at The date the key was created
913
- * @returnf string expired_at The date the key was expired
914
- */
915
- function apikeys($username, $password, $expired=false) {
916
- $params = array();
917
- $params["username"] = $username;
918
- $params["password"] = $password;
919
- $params["expired"] = $expired;
920
- return $this->callServer("apikeys", $params);
921
- }
922
-
923
- /**
924
- * Add an API Key to your account. We will generate a new key for you and return it.
925
- *
926
- * @section Security Related
927
- * @example xml-rpc_apikeyAdd.php
928
- *
929
- * @param string $username Your MailChimp user name
930
- * @param string $password Your MailChimp password
931
- * @return string a new API Key that can be immediately used.
932
- */
933
- function apikeyAdd($username, $password) {
934
- $params = array();
935
- $params["username"] = $username;
936
- $params["password"] = $password;
937
- return $this->callServer("apikeyAdd", $params);
938
- }
939
-
940
- /**
941
- * Expire a Specific API Key. Note that if you expire all of your keys, a new, valid one will be created and returned
942
- * next time you call login(). If you are trying to shut off access to your account for an old developer, change your
943
- * MailChimp password, then expire all of the keys they had access to. Note that this takes effect immediately, so make
944
- * sure you replace the keys in any working application before expiring them! Consider yourself warned...
945
- *
946
- * @section Security Related
947
- * @example xml-rpc_apikeyExpire.php
948
- *
949
- * @param string $username Your MailChimp user name
950
- * @param string $password Your MailChimp password
951
- * @return boolean true if it worked, otherwise an error is thrown.
952
- */
953
- function apikeyExpire($username, $password) {
954
- $params = array();
955
- $params["username"] = $username;
956
- $params["password"] = $password;
957
- return $this->callServer("apikeyExpire", $params);
958
- }
959
-
960
- /**
961
- * Disable a pretty bad security hole that exists in our 1.0 version of the API. If you have never used
962
- * the API, we close this hole for you automatically. If you are an existing user, even if you upgraded to
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
969
- * @return boolean true if it works, otherwise an exception is thrown
970
- */
971
- function closeOneOhSecurityHole($username, $password) {
972
- $params = array();
973
- $params["username"] = $username;
974
- $params["password"] = $password;
975
- return $this->callServer("closeOneOhSecurityHole", $params);
976
- }
977
-
978
- /**
979
- * "Ping" the MailChimp API - a simple method you can call that will return a constant value as long as everything is good. Note
980
- * than unlike most all of our methods, we don't throw an Exception if we are having issues. You will simply receive a different
981
- * string back that will explain our view on what is going on.
982
- *
983
- * @section Helper
984
- * @example xml-rpc_ping.php
985
- *
986
- * @return string returns "Everything's Chimpy!" if everything is chimpy, otherwise returns an error message
987
- */
988
- function ping() {
989
- $params = array();
990
- return $this->callServer("ping", $params);
991
- }
992
-
993
  /**
994
  * Internal function - proxy method for certain XML-RPC calls | DO NOT CALL
995
  * @param mixed Method to call, with any parameters to pass along
@@ -1007,14 +680,13 @@ class MCAPI {
1007
  function callServer($method, $params) {
1008
  //Always include the user id if we're not loggin in
1009
  if($method != "login") {
1010
- $params["apikey"] = $this->api_key;
1011
  }
1012
 
1013
  $post_vars = $this->httpBuildQuery($params);
1014
 
1015
  $payload = "POST " . $this->apiUrl["path"] . "?" . $this->apiUrl["query"] . "&method=" . $method . " HTTP/1.0\r\n";
1016
  $payload .= "Host: " . $this->apiUrl["host"] . "\r\n";
1017
- $payload .= "User-Agent: MCAPI-Wordpress/" . $this->version ."\r\n";
1018
  $payload .= "Content-type: application/x-www-form-urlencoded\r\n";
1019
  $payload .= "Content-length: " . strlen($post_vars) . "\r\n";
1020
  $payload .= "Connection: close \r\n\r\n";
@@ -1024,7 +696,7 @@ class MCAPI {
1024
  $sock = fsockopen($this->apiUrl["host"], 80, $errno, $errstr, $this->timeout);
1025
  if(!$sock) {
1026
  $this->errorMessage = "Could not connect (ERR $errno: $errstr)";
1027
- $this->errorCode = "-99";
1028
  ob_end_clean();
1029
  return false;
1030
  }
@@ -1043,7 +715,7 @@ class MCAPI {
1043
 
1044
  $serial = unserialize($response);
1045
  if($response && $serial === false) {
1046
- $response = array("error" => "Bad Response. Got This: " . $response, "code" => "-99");
1047
  } else {
1048
  $response = $serial;
1049
  }
@@ -1079,4 +751,4 @@ class MCAPI {
1079
  }
1080
  }
1081
 
1082
- ?>
1
  <?php
2
 
3
  class MCAPI {
4
+ var $version = "1.0";
5
  var $errorMessage;
6
  var $errorCode;
7
 
21
  var $chunkSize = 8192;
22
 
23
  /**
24
+ * Cache the user id so we only have to log in once per client instantiation
25
  */
26
+ var $uuid;
27
 
28
  /**
29
  * Connect to the MailChimp API for a given list. All MCAPI calls require login before functioning
32
  * @param string $password Your MailChimp login password - always required
33
  */
34
  function MCAPI($username, $password) {
 
35
  $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
36
+ $this->uuid = $this->callServer("login", array("username" => $username, "password" => $password));
 
 
 
 
 
37
  }
38
 
39
  /**
42
  * @section Campaign Related
43
  * @example xml-rpc_campaignUnschedule.php
44
  *
45
+ * @param string $cid the id for the campaign to unschedule
46
  * @return boolean true on success
47
  */
48
  function campaignUnschedule($cid) {
57
  * @section Campaign Related
58
  * @example xml-rpc_campaignSchedule.php
59
  *
60
+ * @param string $cid the id for the campaign to schedule
61
+ * @param string $schedule_time the time to schedule the campaign - in YYYY-MM-DD HH:II:SS format in GMT
 
62
  * @return boolean true on success
63
  */
64
+ function campaignSchedule($cid, $schedule_time) {
65
  $params = array();
66
  $params["cid"] = $cid;
67
  $params["schedule_time"] = $schedule_time;
 
68
  return $this->callServer("campaignSchedule", $params);
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  /**
72
  * Send a given campaign immediately
73
  *
74
  * @section Campaign Related
75
+ * @example xml-rpc_campaignSend.php
76
  *
77
+ * @param string $cid the id for the campaign to send
78
  * @return boolean true on success
79
  */
80
  function campaignSendNow($cid) {
89
  * @section Campaign Related
90
  * @example xml-rpc_campaignSendTest.php
91
  *
92
+ * @param string $cid the id for the campaign to test
93
+ * @param string $test_emails an array of email address to receive the test message
94
+ * @param string $send_type optional default (null) sends both, "html" or "text" send just that format
95
  * @return boolean true on success
96
  */
97
  function campaignSendTest($cid, $test_emails=array (
120
  return $this->callServer("campaignTemplates", $params);
121
  }
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  /**
124
  * Create a new draft campaign to send
125
  *
126
  * @section Campaign Related
127
+ * @example xml-rpc_createCampaign.php
128
+ *
129
+ * @param string $list_id the list to send this campaign to- get lists using getLists()
130
+ * @param string $subject the subject line for your campaign message
131
+ * @param string $from_email the From: email address for your campaign message
132
+ * @param string $from_name the From: name for your campaign message
133
+ * @param array $content the content for this campaign - use a struct with the following keys: "html" for pasted HTML content and "text" for the plain-text version. If you chose a template instead of pasting in your HTML content, then use "html_" followed by the template sections as keys - for example, use a key of "html_MAIN" to fill in the "MAIN" section of a template.
134
+ * @param integer $template_id optional - use this template to generate the HTML content of the campaign
135
+ * @param array $tracking optional - set which recipient actions will be tracked, as a struct of boolean values with the following keys: "opens", "html_clicks", and "text_clicks". By default, opens and HTML clicks will be tracked.
136
+ * @param string $title optional - an internal name to use for this campaign. By default, the campaign subject will be used.
137
+ * @param boolean $authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false
138
+ * @param string $analytics optional - if provided, use a struct with "service type" as a key and the "service tag" as a value. For Google, this should be "google"=>"your_google_analytics_key_here". Note that only "google" is currently supported - a Google Analytics tags will be added to all links in the campaign with this string attached. Others may be added in the future
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  * @return string the ID for the created campaign
140
  */
141
+ function campaignCreate($list_id, $subject, $from_email, $from_name, $content, $template_id=NULL, $tracking=array (
142
+ 'opens' => true,
143
+ 'html_clicks' => true,
144
+ 'text_clicks' => false,
145
+ ), $title=NULL, $authenticate=false, $analytics=NULL) {
146
  $params = array();
147
+ $params["list_id"] = $list_id;
148
+ $params["subject"] = $subject;
149
+ $params["from_email"] = $from_email;
150
+ $params["from_name"] = $from_name;
151
  $params["content"] = $content;
152
+ $params["template_id"] = $template_id;
153
+ $params["tracking"] = $tracking;
154
+ $params["title"] = $title;
155
+ $params["authenticate"] = $authenticate;
156
+ $params["analytics"] = $analytics;
157
  return $this->callServer("campaignCreate", $params);
158
  }
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  /**
161
+ * Get the list of campaigns and associated information for a list
162
  *
163
  * @section Campaign Related
 
164
  *
165
+ * @param string $filter_id optional - only show campaigns from this list id - get lists using getLists()
166
  * @param integer $filter_folder optional - only show campaigns from this folder id - get folders using campaignFolders()
167
  * @param string $filter_fromname optional - only show campaigns that have this "From Name"
168
  * @param string $filter_fromemail optional - only show campaigns that have this "Reply-to Email"
171
  * @param string $filter_sendtimestart optional - only show campaigns that have been sent since this date/time
172
  * @param string $filter_sendtimeend optional - only show campaigns that have been sent before this date/time
173
  * @param boolean $filter_exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values
174
+ * @param integer $start optional - control paging of campaigns, start results at this campaign #, defaults to 0 (beginning)
175
  * @param integer $limit optional - control paging of campaigns, number of campaigns to return with each call, defaults to 25 (max=5000)
176
  * @return array list of campaigns and their associated information (see Returned Fields for description)
177
  * @returnf string id Campaign Id (used for all other campaign functions)
178
  * @returnf string title Title of the campaign
 
179
  * @returnf date create_time Creation time for the campaign
180
  * @returnf date send_time Send time for the campaign
181
+ * @returnf int emails_sent Number of emails email was sent to
182
  * @returnf string status Status of the given campaign (sent,scheduled,etc.)
183
  * @returnf string from_name From name of the given campaign
184
  * @returnf string from_email Reply-to email of the given campaign
185
  * @returnf string subject Subject of the given campaign
186
+ * @returnf string to_email To email string
187
  * @returnf string archive_url Archive link for the given campaign
 
188
  */
189
  function campaigns($filter_id=NULL, $filter_folder=NULL, $filter_fromname=NULL, $filter_fromemail=NULL, $filter_title=NULL, $filter_subject=NULL, $filter_sendtimestart=NULL, $filter_sendtimeend=NULL, $filter_exact=true, $start=0, $limit=25) {
190
  $params = array();
206
  * List all the folders for a user account
207
  *
208
  * @section Campaign Related
 
209
  *
210
  * @return array Array of folder structs (see Returned Fields for details)
211
  * @returnf integer folder_id Folder Id for the given folder, this can be used in the campaigns() function to filter on.
220
  * Given a list and a campaign, get all the relevant campaign statistics (opens, bounces, clicks, etc.)
221
  *
222
  * @section Campaign Stats
 
223
  *
224
+ * @param string $cid the campaign id to pull stats for (can be gathered using campaigns($id))
225
  * @return array struct of the statistics for this campaign
226
  * @returnf integer syntax_errors Number of email addresses in campaign that had syntactical errors.
227
  * @returnf integer hard_bounces Number of email addresses in campaign that hard bounced.
250
  *
251
  * @section Campaign Stats
252
  *
253
+ * @param string $cid the campaign id to pull stats for (can be gathered using campaigns($id))
254
  * @return struct list of urls and their associated statistics
255
  * @returnf integer clicks Number of times the specific link was clicked
256
  * @returnf integer unique Number of unique people who clicked on the specific link
261
  return $this->callServer("campaignClickStats", $params);
262
  }
263
 
264
+ /**
265
+ * Get all bounced email addresses for a given campaign<br/>
266
+ * <strong>DEPRECATED:</strong> campaignBounces() has been deprecated and will be removed completely in a future release. see campaignHardBounces() and campaignSoftBounces() for replacements.
267
+ *
268
+ * @section Campaign Stats
269
+ *
270
+ * @deprecated See campaignHardBounces() and campaignSoftBounces() for replacements
271
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
272
+ * @return struct Struct of arrays of bounced email addresses (hard and soft)
273
+ * @returnf array hard Array of all email addresses that had Hard bounces for this campaign
274
+ * @returnf array soft Array of all email addresses that had Soft bounces for this campaign
275
+ * @returnf array syntax Array of all email addresses that had syntax errors in them (historical - always empty)
276
+ */
277
+ function campaignBounces($cid) {
278
+ $params = array();
279
+ $params["cid"] = $cid;
280
+ return $this->callServer("campaignBounces", $params);
281
+ }
282
+
283
  /**
284
  * Get all email addresses with Hard Bounces for a given campaign
285
  *
286
  * @section Campaign Stats
287
  *
288
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
289
+ * @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
290
+ * @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
291
  * @return array Arrays of email addresses with Hard Bounces
292
  */
293
  function campaignHardBounces($cid, $start=0, $limit=1000) {
303
  *
304
  * @section Campaign Stats
305
  *
306
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
307
+ * @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
308
+ * @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
309
  * @return array Arrays of email addresses with Soft Bounces
310
  */
311
  function campaignSoftBounces($cid, $start=0, $limit=1000) {
321
  *
322
  * @section Campaign Stats
323
  *
324
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
325
+ * @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
326
+ * @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
327
  * @return array list of email addresses that unsubscribed from this campaign
328
  */
329
  function campaignUnsubscribes($cid, $start=0, $limit=1000) {
339
  *
340
  * @section Campaign Stats
341
  *
342
+ * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
343
+ * @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
344
+ * @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
345
  * @return array list of email addresses that complained (filed abuse reports) about this campaign
346
  */
347
  function campaignAbuseReports($cid, $start=0, $limit=1000) {
357
  *
358
  * @section Campaign Related
359
  *
360
+ * @param string $cid the campaign id to get content for (can be gathered using campaigns($id))
361
  * @return struct Struct containing all content for the campaign (see Returned Fields for details
362
  * @returnf string html The HTML content used for the campgain with merge tags intact
363
  * @returnf string text The Text content used for the campgain with merge tags intact
373
  *
374
  * @section Campaign AIM
375
  *
376
+ * @param string $cid the campaign id to get opens for (can be gathered using campaigns($id))
377
+ * @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
378
+ * @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
379
  * @return array Array of structs containing email addresses and open counts
380
  * @returnf string email Email address that opened the campaign
381
  * @returnf integer open_count Total number of times the campaign was opened by this email address
393
  *
394
  * @section Campaign AIM
395
  *
396
+ * @param string $cid the campaign id to get no opens for (can be gathered using campaigns($id))
397
+ * @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
398
+ * @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
399
  * @return array list of email addresses that did not open a campaign
400
  */
401
  function campaignNotOpenedAIM($cid, $start=0, $limit=1000) {
411
  *
412
  * @section Campaign AIM
413
  *
414
+ * @param string $cid the campaign id to get click stats for (can be gathered using campaigns($id))
415
  * @param string $url the URL of the link that was clicked on
416
+ * @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
417
+ * @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
418
  * @return array Array of structs containing email addresses and click counts
419
  * @returnf string email Email address that opened the campaign
420
  * @returnf integer clicks Total number of times the URL was clicked on by this email address
433
  *
434
  * @section Campaign AIM
435
  *
436
+ * @param string $cid the campaign id to get stats for (can be gathered using campaigns($id))
437
  * @param string $email_address the email address to get activity history for
438
  * @return array Array of structs containing actions (opens and clicks) that the email took, with timestamps
439
  * @returnf string action The action taken (open or click)
468
  * Get the list of merge tags for a given list, including their name, tag, and required setting
469
  *
470
  * @section List Related
 
471
  *
472
  * @param string $id the list id to connect to
473
  * @return array list of merge tags for the list
481
  return $this->callServer("listMergeVars", $params);
482
  }
483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  /**
485
  * Get the list of interest groups for a given list, including the label and form information
486
  *
487
  * @section List Related
 
488
  *
489
  * @param string $id the list id to connect to
490
  * @return struct list of interest groups for the list
498
  return $this->callServer("listInterestGroups", $params);
499
  }
500
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
  /**
502
  * Subscribe the provided email to a list
503
  *
508
  *
509
  * @param string $id the list id to connect to
510
  * @param string $email_address the email address to subscribe
511
+ * @param array $merge_vars array of merges for the email (FNAME, LNAME, etc.) (see examples below for handling "blank" arrays)
 
 
512
  * @param string $email_type optional - email type preference for the email (html or text, defaults to html)
513
+ * @param boolean $double_optin optional - flag to control whether a double opt-in confirmation message is sent, defaults to true
514
  * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below)
515
  */
516
  function listSubscribe($id, $email_address, $merge_vars, $email_type='html', $double_optin=true) {
528
  *
529
  * @section List Related
530
  * @example mcapi_listUnsubscribe.php
 
531
  *
532
  * @param string $id the list id to connect to
533
  * @param string $email_address the email address to unsubscribe
550
  * Edit the email address, merge fields, and interest groups for a list member
551
  *
552
  * @section List Related
 
553
  *
554
  * @param string $id the list id to connect to
555
  * @param string $email_address the current email address of the member to update
582
  * @return struct Array of result counts and any errors that occurred
583
  * @returnf integer success_count Number of email addresses that were succesfully added/updated
584
  * @returnf integer error_count Number of email addresses that failed during addition/updating
585
+ * @returnf array errors Array of error structs. Each error struct will contain "code", "message", and "email_address"
586
  */
587
  function listBatchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) {
588
  $params = array();
598
  * Unsubscribe a batch of email addresses to a list
599
  *
600
  * @section List Related
 
601
  *
602
  * @param string $id the list id to connect to
603
  * @param array $emails array of email addresses to unsubscribe
607
  * @return struct Array of result counts and any errors that occurred
608
  * @returnf integer success_count Number of email addresses that were succesfully added/updated
609
  * @returnf integer error_count Number of email addresses that failed during addition/updating
610
+ * @returnf array errors Array of error structs. Each error struct will contain "code", "message", and "email_address"
611
  */
612
  function listBatchUnsubscribe($id, $emails, $delete_member=false, $send_goodbye=true, $send_notify=false) {
613
  $params = array();
620
  }
621
 
622
  /**
623
+ * Get all of the list members of a list that are of a particular status
624
  *
625
  * @section List Related
626
  * @example mcapi_listMembers.php
627
  *
628
  * @param string $id the list id to connect to
629
  * @param string $status the status to get members for - one of(subscribed, unsubscribed, or cleaned), defaults to subscribed
630
+ * @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
631
+ * @param int $limit optional, for large data sets, the number of results to return - defaults to 100, upper limit set at 15000
632
  * @return array Array of list member structs (see Returned Fields for details)
633
  * @returnf string email Member email address
634
  * @returnf date timestamp timestamp of their associated status(date subscribed, unsubscribed, or cleaned)
647
  *
648
  * @section List Related
649
  * @example mcapi_listMemberInfo.php
 
 
650
  * @param string $id the list id to connect to
651
  * @param string $email_address the member email address to get information for
652
  * @return array array of list member info (see Returned Fields for details)
654
  * @returnf string email_type The type of emails this customer asked to get: html or text
655
  * @returnf array merges An associative array of all the merge tags and the data for those tags for this email address
656
  * @returnf string status The subscription status for this email address, either subscribed, unsubscribed or cleaned
 
 
657
  * @returnf date timestamp The time this email address was added to the list
658
  */
659
  function listMemberInfo($id, $email_address) {
663
  return $this->callServer("listMemberInfo", $params);
664
  }
665
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
666
  /**
667
  * Internal function - proxy method for certain XML-RPC calls | DO NOT CALL
668
  * @param mixed Method to call, with any parameters to pass along
680
  function callServer($method, $params) {
681
  //Always include the user id if we're not loggin in
682
  if($method != "login") {
683
+ $params["uid"] = $this->uuid;
684
  }
685
 
686
  $post_vars = $this->httpBuildQuery($params);
687
 
688
  $payload = "POST " . $this->apiUrl["path"] . "?" . $this->apiUrl["query"] . "&method=" . $method . " HTTP/1.0\r\n";
689
  $payload .= "Host: " . $this->apiUrl["host"] . "\r\n";
 
690
  $payload .= "Content-type: application/x-www-form-urlencoded\r\n";
691
  $payload .= "Content-length: " . strlen($post_vars) . "\r\n";
692
  $payload .= "Connection: close \r\n\r\n";
696
  $sock = fsockopen($this->apiUrl["host"], 80, $errno, $errstr, $this->timeout);
697
  if(!$sock) {
698
  $this->errorMessage = "Could not connect (ERR $errno: $errstr)";
699
+ $this->errorCode = "SERVER_ERROR";
700
  ob_end_clean();
701
  return false;
702
  }
715
 
716
  $serial = unserialize($response);
717
  if($response && $serial === false) {
718
+ $response = array("error" => "Bad Response. Got This: " . $response, "code" => "SERVER_ERROR");
719
  } else {
720
  $response = $serial;
721
  }
751
  }
752
  }
753
 
754
+ ?>
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: 1.0.2
7
  Author: MailChimp API Support Team
8
  Author URI: http://mailchimp.com/api/
9
  */
@@ -63,141 +63,115 @@ echo "
63
  ";
64
  }//mc_main_css
65
 
66
- // Hook for initializing the plugins, mostly for i18n
67
- add_action( 'init', 'mc_plugin_init' );
68
-
69
- // Hook for our css
70
  add_action('admin_head', 'mc_admin_css');
71
  add_action('wp_head', 'mc_main_css');
72
 
73
-
74
  // Hook for adding admin menus
75
  add_action('admin_menu', 'mc_add_pages');
76
 
77
- // Initialize this plugin. Called by 'init' hook.
78
- function mc_plugin_init(){
79
- //the "complicate" path is so people can use this with WPMU or just move things around
80
- load_plugin_textdomain( 'mailchimp_i18n', str_replace(ABSPATH,'',dirname(__FILE__).'/po') );
81
- }
82
-
83
  // action function for above hook
84
- function mc_add_pages(){
85
 
86
  //7 is lowest w/ Plugin Editing capability
87
- add_options_page( __( 'MailChimp Setup', 'mailchimp_i18n' ), __( 'MailChimp Setup', 'mailchimp_i18n' ), 7, 'mc_setup_page', 'mc_setup_page');
88
  }
89
 
90
-
91
- // __( '', 'mailchimp_i18n' )
92
-
93
  function mc_setup_page(){
94
-
95
- $msg = '';
96
- if (get_option('mc_password')!=''){
97
- //some upgrade code for < 0.5 users - we want to rip out the password we've been saving.
98
- $api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
99
- if ($api->errorCode == ''){
100
- update_option('mc_apikey', $api->api_key);
101
- //this should already be here, but let's make sure anyway
102
- $req = $api->getAffiliateInfo();
103
- update_option('mc_user_id', $req['user_id']);
104
- } else {
105
- $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.", 'mailchimp_i18n' )."<br/>";
106
- }
107
- delete_option('mc_password');
108
- }
109
  ?>
110
  <div class="wrap">
111
- <h2><?php echo __( 'MailChimp List Setup', 'mailchimp_i18n');?> </h2>
112
  <?php
113
- if ($_REQUEST['action']==='logout'){
114
- update_option('mc_apikey', '');
115
- }
116
  //see if we need to set/change the username & password.
117
- if (isset($_REQUEST['mc_username']) && isset($_REQUEST['mc_password'])){
118
- $delete_setup = false;
119
- $api = new MCAPI($_REQUEST['mc_username'], $_REQUEST['mc_password']);
120
- if ($api->errorCode == ''){
121
- $msg = "<span class='success_msg'>".__( "Success! We were able to verify your username &amp; password! Let's continue, shall we?", 'mailchimp_i18n' )."</span>";
122
- update_option('mc_username', $_REQUEST['mc_username']);
123
- update_option('mc_apikey', $api->api_key);
124
- $req = $api->getAffiliateInfo();
125
- update_option('mc_user_id', $req['user_id']);
126
- if (get_option('mc_list_id')!=''){
127
- $lists = $api->lists();
128
- //but don't delete if the list still exists...
129
- $delete_setup = true;
130
- foreach($lists as $list){ if ($list['id']==get_option('mc_list_id')){ $list_id = $_REQUEST['mc_list_id']; $delete_setup=false; } }
 
 
 
 
 
 
 
131
  }
132
- } else {
133
- $msg .= "<span class='error_msg'>".__( 'Uh-oh, we were unable to login and verify your username &amp; password. Please check them and try again!', 'mailchimp_i18n' )."<br/>";
134
- $msg .= __( 'The server said:', 'mailchimp_i18n' )."<i>".$api->errorMessage."</i></span>";
135
- if (get_option('mc_username')==''){
136
- $delete_setup = true;
 
 
 
 
 
 
 
 
 
 
137
  }
138
  }
139
- if ($delete_setup){
140
- delete_option('mc_user_id');
141
- delete_option('mc_rewards');
142
- delete_option('mc_list_id');
143
- delete_option('mc_list_name');
144
- delete_option('mc_interest_groups');
145
- delete_option('mc_show_interest_groups');
146
- $mv = get_option('mc_merge_vars');
147
- if (!is_array($mv)){
148
- $mv = unserialize($mv);
149
- }
150
- if (is_array($mv)){
151
- foreach($mv as $var){
152
- $opt = 'mc_mv_'.$var['tag'];
153
- delete_option($opt);
154
- }
155
- }
156
- delete_option('mc_merge_vars');
157
  }
158
  //set these for the form fields below
159
  $user = $_REQUEST['mc_username'];
 
160
  } else {
161
  $user = get_option('mc_username');
162
  $pass = get_option('mc_password');
163
  }
164
- if (get_option('mc_apikey')!=''){
165
- $GLOBALS["mc_api_key"] = get_option('mc_apikey');
166
- $api = new MCAPI('no_login','is_needed');
167
  $lists = $api->lists();
168
-
169
  foreach($lists as $list){ if ($list['id']==$_REQUEST['mc_list_id']){ $list_id = $_REQUEST['mc_list_id']; $list_name = $list['name']; } }
170
-
171
- if ($list_id != ''){
172
- update_option('mc_list_id', $list_id);
173
- update_option('mc_list_name', $list_name);
174
-
175
- update_option('mc_header_content','<h2>'.__( 'Sign up for', 'mailchimp_i18n' ).' '.$list_name.'</h2>');
176
- update_option('mc_submit_text',__( 'Subscribe', 'mailchimp_i18n' ));
177
-
178
- update_option('mc_custom_style','on');
179
- update_option('mc_form_border_width','1');
180
- update_option('mc_form_border_color','ccc');
181
- update_option('mc_form_background','ffffcc');
182
- update_option('mc_form_text_color','666666');
183
-
184
- $mv = $api->listMergeVars($list_id);
185
- $ig = $api->listInterestGroups($list_id);
186
- update_option('mc_merge_vars', serialize( $mv ) );
187
- foreach($mv as $var){
188
- $opt = 'mc_mv_'.$var['tag'];
189
- //turn them all on by default
190
- update_option($opt, 'on' );
191
- }
192
- update_option('mc_interest_groups', serialize( $ig ) );
193
- update_option('mc_show_interest_groups', 'on' );
194
- $msg = '<span class="success_msg">'.
195
- sprintf(__( 'Success! Loaded and saved the info for %d Merge Variables and %d Interest Groups from your list'),
196
- sizeof($mv) , sizeof($ig) ).
197
- ' "'.$list_name.'"<br/><br/>'.
198
- __('Now you should either Turn On the MailChimp Widget or change your options below, then turn it on.', 'mailchimp_i18n').'</span>';
199
- }
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  }
202
  if (isset($_REQUEST['reset_list'])){
203
  delete_option('mc_list_id');
@@ -214,19 +188,9 @@ if (isset($_REQUEST['reset_list'])){
214
  delete_option('mc_form_background');
215
  delete_option('mc_form_text_color');
216
 
217
- $msg = '<span class="success_msg">'.__('Successfully Reset your List selection... Now you get to pick again!', 'mailchimp_i18n').'</span>';
218
  }
219
  if (isset($_REQUEST['change_form_settings'])){
220
- if (isset($_REQUEST['mc_rewards']) && $_REQUEST['mc_rewards'] != get_option('mc_rewards')){
221
- update_option('mc_rewards', 'on');
222
- if ($msg) $msg .= '<br/>';
223
- $msg .= '<span class="success_msg">'.__('Monkey Rewards turned On!', 'mailchimp_i18n').'</span>';
224
- } else if (get_option('mc_rewards')!='off') {
225
- update_option('mc_rewards', 'off');
226
- if ($msg) $msg .= '<br/>';
227
- $msg .= '<span class="success_msg">'.__('Monkey Rewards turned Off!', 'mailchimp_i18n').'</span>';
228
- }
229
-
230
  $content = stripslashes($_REQUEST['mc_header_content']);
231
  $content = str_replace("\r\n","<br/>", $content);
232
  update_option('mc_header_content', $content );
@@ -252,10 +216,7 @@ if (isset($_REQUEST['change_form_settings'])){
252
  } else {
253
  update_option('mc_show_interest_groups','off');
254
  }
255
- $mv = get_option('mc_merge_vars');
256
- if (!is_array($mv)){
257
- $mv = unserialize(get_option('mc_merge_vars'));
258
- }
259
  foreach($mv as $var){
260
  $opt = 'mc_mv_'.$var['tag'];
261
  if (isset($_REQUEST[$opt]) || $var['req']=='Y'){
@@ -264,7 +225,7 @@ if (isset($_REQUEST['change_form_settings'])){
264
  update_option($opt,'off');
265
  }
266
  }
267
- $msg = '<span class="success_msg">'.__('Successfully Updated your List Subscribe Form Settings!', 'mailchimp_i18n').'</span>';
268
 
269
  }
270
  if ($msg){
@@ -272,91 +233,72 @@ if ($msg){
272
  }
273
  ?>
274
  <form method="post" action="options-general.php?page=mc_setup_page">
275
- <?php wp_nonce_field('update-options');
276
- if (get_option('mc_apikey')==''){
277
- ?>
278
- <h3><?php echo __('Login Info', 'mailchimp_i18n');?></h3>
279
- <?php echo __('To start using the MailChimp plugin, we first need to login and get your API Key. Please enter your MailChimp username and password below.', 'mailchimp_i18n'); ?>
280
- <br/>
281
- <?php echo __("Don't have a MailChimp account? <a href='http://www.mailchimp.com/tryit.phtml' target='_blank'>Try one for Free</a>!", 'mailchimp_i18n'); ?>
282
- <br/>
283
  <table class="form-table">
284
  <tr valign="top">
285
- <th scope="row"><?php echo __('Username', 'mailchimp_i18n');?>:</th>
286
  <td><input name="mc_username" type="text" id="mc_username" class="code" value="<?php echo $user; ?>" size="20" /></td>
287
  </tr>
288
  <tr valign="top">
289
- <th scope="row"><?php echo __('Password', 'mailchimp_i18n');?>:</th>
290
  <td><input name="mc_password" type="text" id="mc_password" class="code" value="<?php echo $pass; ?>" size="20" /></td>
291
  </tr>
 
 
 
 
 
 
292
  </table>
 
 
293
  <input type="hidden" name="action" value="update"/>
294
  <input type="hidden" name="page_options" value="mc_username,mc_password" />
295
- <input type="submit" name="Submit" value="<?php echo __('Save & Check');?>" class="button" />
296
- </form>
297
  <?php
298
- if (get_option('mc_username')!=''){
299
- echo '<strong>'.__('Notes', 'mailchimp_i18n').':</strong><ul>
300
- <li><i>'.__('Changing your settings at MailChimp.com may cause this to stop working.', 'mailchimp_i18n').'</i></li>
301
- <li><i>'.__('If you change your login to a different account, the info you have setup below will be erased.', 'mailchimp_i18n').'</i></li>
302
- <li><i>'.__('If any of that happens, no biggie - just reconfigure your login and the items below...', 'mailchimp_i18n').'</i></li></ul>
303
- <br/>';
304
- }
305
- echo '</p>';
306
- } else {
307
- ?>
308
- <table style="min-width:400px;"><tr><td><h3><?php echo __('Logged in as', 'mailchimp_i18n');?>: <?=get_option('mc_username')?></h3>
309
- </td><td>
310
- <form method="post" action="options-general.php?page=mc_setup_page">
311
- <input type="hidden" name="action" value="logout"/>
312
- <input type="submit" name="Submit" value="<?php echo __('Logout', 'mailchimp_i18n');?>" class="button" />
313
- </form>
314
- </td></tr></table>
315
- <?php
316
  }
317
  ?>
 
 
318
  <?php
319
  //Just get out if nothing else matters...
320
- if (get_option('mc_apikey') == '') return;
321
 
322
- if (get_option('mc_apikey')!=''){
323
  ?>
324
- <?php wp_nonce_field('update-options'); ?>
325
- <h3><?php echo __('Your Lists', 'mailchimp_i18n')?></h3>
326
- <?php echo __('Please select the List you wish to create a Signup Form for.', 'mailchimp_i18n');?><br/>
327
  <form method="post" action="options-general.php?page=mc_setup_page">
 
 
 
328
  <?php
329
  $api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
330
  $lists = $api->lists();
331
  rsort($lists);
 
 
 
332
  if (sizeof($lists)==0){
333
- echo "<span class='error_msg'>".
334
- sprintf(__("Uh-oh, you don't have any lists defined! Please visit %s, login, and setup a list before using this tool!", 'mailchimp_i18n'),
335
- "<a href='http://www.mailchimp.com/'>MailChimp</a>")."</span>";
336
- } else {
337
- echo '<table style="min-width:400px"><tr><td>
338
- <select name="mc_list_id" height="100px" style="min-width:200px;">
339
- <option value=""> --- '.__('Select A List','mailchimp_i18n').' --- </option>';
340
- foreach ($lists as $list){
341
- if ($list['id'] == get_option('mc_list_id')){
342
- $sel = ' selected ';
343
- } else {
344
- $sel = '';
345
- }
346
- echo '<option value="'.$list['id'].'" '.$sel.'>'.$list['name'].'</option>';
347
- }
348
  ?>
349
- </select></td><td>
350
-
351
  <input type="hidden" name="action" value="update" />
352
  <input type="hidden" name="page_options" value="mc_list_id" />
353
- <input type="submit" name="Submit" value="<?php echo __('Update List', 'mailchimp_i18n');?>" class="button" />
354
- </td></tr></table>
355
  </form>
356
- <br/>
357
  <?php
358
- } //end select list
359
- } else {
360
  //display the selected list...
361
  ?>
362
  <form method="post" action="options-general.php?page=mc_setup_page">
@@ -364,89 +306,77 @@ if (get_option('mc_apikey')!=''){
364
  <p class="submit">
365
  <input type="hidden" name="action" value="update" />
366
  <input type="hidden" name="page_options" value="mc_list_id" />
367
- <input type="submit" name="reset_list" value="<?php echo __('Reset List Options and Select again', 'mailchimp_i18n');?>" class="button" />
368
  </p>
369
  </form>
370
- <h3><?php echo __('Subscribe Form Widget Settings for this List', 'mailchimp_i18n');?>:</h3>
371
- <h4><?php echo __('Selected MailChimp List', 'mailchimp_i18n');?>: <?php echo get_option('mc_list_name'); ?></h4>
372
  <?php
373
  }
374
  //Just get out if nothing else matters...
375
  if (get_option('mc_list_id') == '') return;
376
- $mv = get_option('mc_merge_vars');
377
- $ig = get_option('mc_interest_groups');
378
- if (!is_array($mv)){
379
- //apparently in WP 2.6 get_option() unserializes arrays for us.
380
- $mv = unserialize($mv);
381
- $ig = unserialize($ig);
382
- }
383
- if (!is_array($ig)){
384
- //means we got false returned
385
- $ig = unserialize($ig);
386
- }
387
  ?>
388
  <form method="post" action="options-general.php?page=mc_setup_page">
389
  <?php wp_nonce_field('update-options'); ?>
390
  <div style="width:600px;">
391
  <table class="widefat">
392
- <tr valign="top">
393
- <th scope="row"><?php echo __('Monkey Rewards', 'mailchimp_i18n');?>:</th>
394
- <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" />
395
- <i><?php echo __('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>
396
- </td>
397
- </tr>
398
- <tr valign="top">
399
- <th scope="row"><?php echo __('Header content', 'mailchimp_i18n');?>:</th>
400
- <td>
401
- <textarea name="mc_header_content" cols="50"><?php echo get_option('mc_header_content');?></textarea><br/>
402
- <i><?php echo __('You can fill this with your own Text, HTML markup (including image links), or Nothing!', 'mailchimp_i18n');?></i>
403
- </td>
404
- </tr>
405
-
406
- <tr valign="top">
407
- <th scope="row"><?php echo __('Submit Button text', 'mailchimp_i18n');?>:</th>
408
- <td>
409
- <input type="text" name="mc_submit_text" size="30" value="<?php echo get_option('mc_submit_text');?>"/>
410
- </td>
411
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
 
413
- <tr valign="top">
414
- <th scope="row"><?php echo __('Custom Styling', 'mailchimp_i18n');?>:</th>
415
- <td>
416
- <table class="widefat">
417
- <tr><th><?php echo __('Turned On?', 'mailchimp_i18n');?></th><td><input type="checkbox" name="mc_custom_style" <?php if (get_option('mc_custom_style')=='on'){echo 'checked';}?> ></td></tr>
418
- <tr><th><?php echo __('Border Width', 'mailchimp_i18n');?>:</th><td><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo get_option('mc_form_border_width');?>"> px<br/>
419
- <i><?php echo __('Set to 0 for no border, do not enter <strong>px</strong>!', 'mailchimp_i18n');?></i>
420
- </td></tr>
421
- <tr><th><?php echo __('Border Color', 'mailchimp_i18n');?>:</th><td>#<input type="text" name="mc_form_border_color" size="7" maxlength="6" value="<?php echo get_option('mc_form_border_color');?>"><br/>
422
- <i><?php echo __('do not enter initial <strong>#</strong>', 'mailchimp_i18n');?></i>
423
- </td></tr>
424
- <tr><th>Text Color:</th><td>#<input type="text" name="mc_form_text_color" size="7" maxlength="6" value="<?php echo get_option('mc_form_text_color');?>"><br/>
425
- <i><?php echo __('do not enter initial <strong>#</strong>', 'mailchimp_i18n');?></i>
426
- </td></tr>
427
- <tr><th>Background Color:</th><td>#<input type="text" name="mc_form_background" size="7" maxlength="6" value="<?php echo get_option('mc_form_background');?>"><br/>
428
- <i><?php echo __('do not enter initial <strong>#</strong>', 'mailchimp_i18n');?></i>
429
- </td></tr>
430
- </table>
431
  </td>
432
  </tr>
433
  </table>
434
  </div>
435
 
436
  <div style="width:400px;">
437
- <h4><?php echo __('Merge Variables Included', 'mailchimp_i18n');?></h4>
438
  <?php
439
  if (sizeof($mv)==0){
440
- echo "<i>".__('No Merge Variables found.', 'mailchimp_i18n')."</i>";
441
  } else {
442
  ?>
443
 
444
  <table class='widefat'>
445
  <tr valign="top">
446
- <th><?php echo __('Name', 'mailchimp_i18n');?></th>
447
- <th><?php echo __('Tag', 'mailchimp_i18n');?></th>
448
- <th><?php echo __('Required?', 'mailchimp_i18n');?></th>
449
- <th><?php echo __('Include?', 'mailchimp_i18n');?></th>
450
  </tr>
451
  <?php
452
  foreach($mv as $var){
@@ -466,24 +396,25 @@ if (sizeof($mv)==0){
466
  }
467
  echo '</table>';
468
  }
469
- echo '<h4>'.__('Interest Groups', 'mailchimp_i18n').'</h4>';
470
- if (!$ig || $ig=='' || $ig=='N'){
471
- echo "<i>".__('No Interest Groups Setup for this List', 'mailchimp_i18n')."</i>";
 
472
  } else {
473
  ?>
474
  <table class='widefat'>
475
  <tr valign="top">
476
- <th width="75px"><?php echo __('Show?', 'mailchimp_i18n');?></th><th>
477
- <input name="mc_show_interest_groups" type="checkbox" <?php if (get_option('mc_show_interest_groups')=='on') { echo 'checked'; } ?> id="mc_show_interest_groups" class="code" />
 
478
  </th></tr>
479
- <tr valign="top">
480
- <th><?php echo __('Name', 'mailchimp_i18n');?>:</th><th><?php echo $ig['name']; ?></th>
481
  </tr>
482
  <tr valign="top">
483
- <th><?php echo __('Input Type', 'mailchimp_i18n');?>:</th><td><?php echo $ig['form_field']; ?></td>
484
  </tr>
485
  <tr valign="top">
486
- <th><?php echo __('Options', 'mailchimp_i18n');?>:</th><td><ul>
487
  <?php
488
  foreach($ig['groups'] as $interest){
489
  echo '<li>'.$interest;
@@ -494,7 +425,7 @@ echo '</div>';
494
  ?>
495
  <p class="submit">
496
  <input type="hidden" name="action" value="update" />
497
- <input type="submit" name="change_form_settings" value="<?php echo __('Update Subscribe Form Settings', 'mailchimp_i18n');?>" class="button" />
498
  </p>
499
  </form>
500
  </div>
@@ -508,24 +439,16 @@ function mc_register_widgets(){
508
  if (!function_exists('register_sidebar_widget')) {
509
  return;
510
  }
511
- register_sidebar_widget(__('MailChimp Widget', 'mailchimp_i18n'), 'mc_display_widget');
512
 
513
  }
514
  function mc_display_widget(){
515
- $mv = get_option('mc_merge_vars');
516
- $ig = get_option('mc_interest_groups');
517
- if (!is_array($mv)){
518
- //apparently in WP 2.6 get_option() unserializes arrays for us.
519
- $mv = unserialize($mv);
520
- }
521
- if (!is_array($ig)){
522
- $ig = unserialize($ig);
523
- }
524
-
525
  $msg = '';
526
  if (isset($_REQUEST['mc_signup'])){
527
  $failed = false;
528
- $listId = get_option('mc_list_id');
529
  $email = $_REQUEST['mc_mv_EMAIL'];
530
  $merge = array();
531
  $errs = array();
@@ -551,25 +474,18 @@ function mc_display_widget(){
551
  }
552
  }
553
  if (!$failed){
554
- foreach($merge as $k=>$v){
555
- if (trim($v)===''){
556
- unset($merge[$k]);
557
- }
558
- }
559
- if (sizeof($merge) == 0 || $merge==''){ $merge = ''; }
560
-
561
- $GLOBALS["mc_api_key"] = get_option('mc_apikey');
562
- $api = new MCAPI('no_login','is_needed');
563
  $retval = $api->listSubscribe( $listId, $email, $merge);
564
  if (!$retval){
565
  $failed = true;
566
  $errs[] = $api->errorMessage;
567
  } else {
568
- $msg = "<br/><strong class='success_msg'>".__("Success, you've been signed up! Please look for our confirmation email!", 'mailchimp_i18n')."</strong><br/>";
569
  }
570
  }
571
  if (sizeof($errs)>0){
572
- $msg = '<br/>'.__('Uhoh, we had problems!', 'mailchimp_i18n').'<ul>';
573
  foreach($errs as $error){
574
  $msg .= '<li class="error_msg">'.$error.'</li>';
575
  }
@@ -582,7 +498,7 @@ function mc_display_widget(){
582
  <div class="mc_custom_border">
583
  <a name="mc_signup_form"></a>
584
  <?php echo get_option('mc_header_content');?>
585
- <form method="POST" action="<?php echo $_SERVER['REQUEST_URI']; ?>#mc_signup_form">
586
  <?php
587
  if ($msg != ''){
588
  echo '<span class="updated">'.$msg.'</span>';
@@ -590,13 +506,13 @@ function mc_display_widget(){
590
  foreach($mv as $var){
591
  $opt = 'mc_mv_'.$var['tag'];
592
  if ($var['req'] || get_option($opt)=='on'){
593
- echo ''.$var['name'].':<br/><input type="text" size="18" value="" name="'.$opt.'">';
594
  if ($var['req']){ echo '*'; }
595
  echo '<br/>';
596
  }
597
  }
598
- echo '<sup style="clear:both;">* = '.__('required field', 'mailchimp_i18n').'</sup>';
599
- if (get_option('mc_show_interest_groups')=='on' && $ig){
600
  echo '<br/><br/><strong>'.$ig['name'].'</strong><br/>';
601
  if ($ig['form_field']=='checkbox'){
602
  foreach($ig['groups'] as $interest){
@@ -621,7 +537,7 @@ function mc_display_widget(){
621
  </form>
622
  <?php
623
  if ( get_option('mc_rewards')=='on') {
624
- echo '<div align="center">'.__('powered by', 'mailchimp_i18n').'<a href="http://www.mailchimp.com/affiliates/?aid='.get_option('mc_user_id').'&afl=1">MailChimp</a>!</div>';
625
  }
626
  ?>
627
  </div>
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.1
7
  Author: MailChimp API Support Team
8
  Author URI: http://mailchimp.com/api/
9
  */
63
  ";
64
  }//mc_main_css
65
 
 
 
 
 
66
  add_action('admin_head', 'mc_admin_css');
67
  add_action('wp_head', 'mc_main_css');
68
 
 
69
  // Hook for adding admin menus
70
  add_action('admin_menu', 'mc_add_pages');
71
 
 
 
 
 
 
 
72
  // action function for above hook
73
+ function mc_add_pages() {
74
 
75
  //7 is lowest w/ Plugin Editing capability
76
+ add_options_page('MailChimp Setup', 'MailChimp Setup', 7, 'mc_setup_page', 'mc_setup_page');
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['mc_username'])){
86
+ if ($_REQUEST['mc_username']!=get_option('mc_username') || $_REQUEST['mc_password']!=get_option('mc_password')){
87
+ $delete_setup = false;
88
+ $api = new MCAPI($_REQUEST['mc_username'], $_REQUEST['mc_password']);
89
+ if ($api->errorCode == ''){
90
+ $msg = "<span class='success_msg'>Success! We were able to verify your username &amp; password! Let's continue, shall we?</span>";
91
+ update_option('mc_username', $_REQUEST['mc_username']);
92
+ update_option('mc_password', $_REQUEST['mc_password']);
93
+ update_option('mc_user_id', $api->uuid);
94
+ if (get_option('mc_list_id')!=''){
95
+ $lists = $api->lists();
96
+ $delete_setup = true;
97
+ //but don't delete if the list still exists...
98
+ foreach($lists as $list){ if ($list['id']==get_option('mc_list_id')){ $list_id = $_REQUEST['mc_list_id']; $delete_setup=false; } }
99
+ }
100
+ } else {
101
+ $msg = "<span class='error_msg'>Uh-oh, we were unable to login and verify your username &amp; 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
+ if ($delete_setup){
108
+ delete_option('mc_user_id');
109
+ delete_option('mc_username');
110
+ delete_option('mc_password');
111
+ delete_option('mc_rewards');
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 (isset($_REQUEST['mc_rewards']) && $_REQUEST['mc_rewards'] != get_option('mc_rewards')){
125
+ update_option('mc_rewards', 'on');
126
+ if ($msg) $msg .= '<br/>';
127
+ $msg .= '<span class="success_msg">Monkey Rewards turned On!</span>';
128
+ } else if (get_option('mc_rewards')!='off') {
129
+ update_option('mc_rewards', 'off');
130
+ if ($msg) $msg .= '<br/>';
131
+ $msg .= '<span class="success_msg">Monkey Rewards turned Off!</span>';
 
 
 
 
 
 
 
 
 
 
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 (isset($_REQUEST['mc_list_id'])){
141
+ $api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
 
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');
188
  delete_option('mc_form_background');
189
  delete_option('mc_form_text_color');
190
 
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 );
216
  } else {
217
  update_option('mc_show_interest_groups','off');
218
  }
219
+ $mv = unserialize(get_option('mc_merge_vars'));
 
 
 
220
  foreach($mv as $var){
221
  $opt = 'mc_mv_'.$var['tag'];
222
  if (isset($_REQUEST[$opt]) || $var['req']=='Y'){
225
  update_option($opt,'off');
226
  }
227
  }
228
+ $msg = '<span class="success_msg">Successfully Updated your List Subscribe Form Settings!</span>';
229
 
230
  }
231
  if ($msg){
233
  }
234
  ?>
235
  <form method="post" action="options-general.php?page=mc_setup_page">
236
+ <?php wp_nonce_field('update-options'); ?>
237
+ <h3>Login Info</h3>
238
+ To start using the MailChimp plugin, we first need to store your MailChimp Username & Password<br/>
 
 
 
 
 
239
  <table class="form-table">
240
  <tr valign="top">
241
+ <th scope="row">Username:</th>
242
  <td><input name="mc_username" type="text" id="mc_username" class="code" value="<?php echo $user; ?>" size="20" /></td>
243
  </tr>
244
  <tr valign="top">
245
+ <th scope="row">Password:</th>
246
  <td><input name="mc_password" type="text" id="mc_password" class="code" value="<?php echo $pass; ?>" size="20" /></td>
247
  </tr>
248
+ <tr valign="top">
249
+ <th scope="row">Monkey Rewards:</th>
250
+ <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" />
251
+ <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>
252
+ </td>
253
+ </tr>
254
  </table>
255
+
256
+ <p class="submit">
257
  <input type="hidden" name="action" value="update"/>
258
  <input type="hidden" name="page_options" value="mc_username,mc_password" />
259
+ <input type="submit" name="Submit" value="Save & Check" class="button" />
 
260
  <?php
261
+ if (get_option('mc_username')!=''){
262
+ echo '<strong>Notes:</strong><ul>
263
+ <li><i>Changing your settings at MailChimp.com may cause this to stop working.</i></li>
264
+ <li><i>Changing your username &amp; password at MailChimp.com will cause this plugin to stop working!</i></li>
265
+ <li><i>If you change your login to a different account, the info you have setup below will be erased.</i></li>
266
+ <li><i>If any of that happens, no biggie - just reconfigure your login and the items below...</i></li></ul>
267
+ <br/>';
 
 
 
 
 
 
 
 
 
 
 
268
  }
269
  ?>
270
+ </p>
271
+ </form>
272
  <?php
273
  //Just get out if nothing else matters...
274
+ if (get_option('mc_username') == '') return;
275
 
276
+ if (get_option('mc_list_id')==''){
277
  ?>
 
 
 
278
  <form method="post" action="options-general.php?page=mc_setup_page">
279
+ <?php wp_nonce_field('update-options'); ?>
280
+ <h3>Your Lists</h3>
281
+ Please select the List you wish to create a Signup Form for.<br/>
282
  <?php
283
  $api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
284
  $lists = $api->lists();
285
  rsort($lists);
286
+ foreach ($lists as $list){
287
+ echo '<input type="radio" name="mc_list_id" value="'.$list['id'].'"> &nbsp; <strong>'.$list['name'].'</strong><br/>';
288
+ }
289
  if (sizeof($lists)==0){
290
+ 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>";
291
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  ?>
293
+ <p class="submit">
 
294
  <input type="hidden" name="action" value="update" />
295
  <input type="hidden" name="page_options" value="mc_list_id" />
296
+ <input type="submit" name="Submit" value="Select List!" class="button" />
297
+ </p>
298
  </form>
 
299
  <?php
300
+ } //end select list
301
+ else {
302
  //display the selected list...
303
  ?>
304
  <form method="post" action="options-general.php?page=mc_setup_page">
306
  <p class="submit">
307
  <input type="hidden" name="action" value="update" />
308
  <input type="hidden" name="page_options" value="mc_list_id" />
309
+ <input type="submit" name="reset_list" value="Reset List Options and Select again" class="button" />
310
  </p>
311
  </form>
312
+ <h3>Subscribe Form Widget Settings for this List:</h3>
313
+ <h4>Selected MailChimp List: <?php echo get_option('mc_list_name'); ?></h4>
314
  <?php
315
  }
316
  //Just get out if nothing else matters...
317
  if (get_option('mc_list_id') == '') return;
318
+
319
+ $mv = unserialize(get_option('mc_merge_vars'));
320
+ $ig = unserialize(get_option('mc_interest_groups'));
 
 
 
 
 
 
 
 
321
  ?>
322
  <form method="post" action="options-general.php?page=mc_setup_page">
323
  <?php wp_nonce_field('update-options'); ?>
324
  <div style="width:600px;">
325
  <table class="widefat">
326
+ <tr valign="top">
327
+ <th scope="row">Header content:</th>
328
+ <td>
329
+ <textarea name="mc_header_content" cols="50"><?php echo get_option('mc_header_content');?></textarea><br/>
330
+ <i>You can fill this with your own Text, HTML markup (including image links), or Nothing!</i>
331
+ </td>
332
+ </tr>
333
+ <tr valign="top">
334
+ <th scope="row">Submit Button text:</th>
335
+ <td>
336
+ <input type="text" name="mc_submit_text" size="30" value="<?php echo get_option('mc_submit_text');?>"/><br/>
337
+ <i>You can fill this with your own Text, HTML markup (including image links), or Nothing!</i>
338
+ </td>
339
+ </tr>
340
+ <tr valign="top">
341
+ <th scope="row">Custom Styling:</th>
342
+ <td>
343
+ <table class="widefat">
344
+ <tr><th>Turned On?</th><td><input type="checkbox" name="mc_custom_style" <?php if (get_option('mc_custom_style')=='on'){echo 'checked';}?> ></td></tr>
345
+ <tr><th>Border Width:</th><td><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo get_option('mc_form_border_width');?>"> px<br/>
346
+ <i>Set to 0 for no border, do not enter <strong>px</strong>!</i>
347
+ </td></tr>
348
+ <tr><th>Border Color:</th><td>#<input type="text" name="mc_form_border_color" size="7" maxlength="6" value="<?php echo get_option('mc_form_border_color');?>"><br/>
349
+ <i>do not enter initial <strong>#</strong></i>
350
+ </td></tr>
351
+ <tr><th>Text Color:</th><td>#<input type="text" name="mc_form_text_color" size="7" maxlength="6" value="<?php echo get_option('mc_form_text_color');?>"><br/>
352
+ <i>do not enter initial <strong>#</strong></i>
353
+ </td></tr>
354
+ <tr><th>Background Color:</th><td>#<input type="text" name="mc_form_background" size="7" maxlength="6" value="<?php echo get_option('mc_form_background');?>"><br/>
355
+ <i>do not enter initial <strong>#</strong></i>
356
+ </td></tr>
357
+ </td>
358
+ </tr>
359
+ </table>
360
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  </td>
362
  </tr>
363
  </table>
364
  </div>
365
 
366
  <div style="width:400px;">
367
+ <h4>Merge Variables Included</h4>
368
  <?php
369
  if (sizeof($mv)==0){
370
+ echo "<i>No Merge Variables found.</i>";
371
  } else {
372
  ?>
373
 
374
  <table class='widefat'>
375
  <tr valign="top">
376
+ <th>Name</th>
377
+ <th>Tag</th>
378
+ <th>Required?</th>
379
+ <th>Include?</th>
380
  </tr>
381
  <?php
382
  foreach($mv as $var){
396
  }
397
  echo '</table>';
398
  }
399
+ echo '<h4>Interest Groups</h4>';
400
+ if ($ig=='' && $ig=='N'){
401
+ echo "<i>No Interest Groups Setup</i>";
402
+ echo ">>".get_option('mc_interest_groups');
403
  } else {
404
  ?>
405
  <table class='widefat'>
406
  <tr valign="top">
407
+
408
+ <th width="75px">Show?</th><th>
409
+ <input name="mc_show_interest_groups" type="checkbox" ' <?php if (get_option('mc_show_interest_groups')=='on') { echo 'checked'; } ?> id="mc_show_interest_groups" class="code" />
410
  </th></tr>
411
+ <th>Name:</th><th><?php echo $ig['name']; ?></th>
 
412
  </tr>
413
  <tr valign="top">
414
+ <th>Input Type:</th><td><?php echo $ig['form_field']; ?>
415
  </tr>
416
  <tr valign="top">
417
+ <th>Options:</th><td><ul>
418
  <?php
419
  foreach($ig['groups'] as $interest){
420
  echo '<li>'.$interest;
425
  ?>
426
  <p class="submit">
427
  <input type="hidden" name="action" value="update" />
428
+ <input type="submit" name="change_form_settings" value="Update Subscribe Form Settings" class="button" />
429
  </p>
430
  </form>
431
  </div>
439
  if (!function_exists('register_sidebar_widget')) {
440
  return;
441
  }
442
+ register_sidebar_widget('MailChimp Widget', 'mc_display_widget');
443
 
444
  }
445
  function mc_display_widget(){
446
+ $mv = unserialize(get_option('mc_merge_vars'));
447
+ $ig = unserialize(get_option('mc_interest_groups'));
 
 
 
 
 
 
 
 
448
  $msg = '';
449
  if (isset($_REQUEST['mc_signup'])){
450
  $failed = false;
451
+ $listId = get_option('mc_list_id');
452
  $email = $_REQUEST['mc_mv_EMAIL'];
453
  $merge = array();
454
  $errs = array();
474
  }
475
  }
476
  if (!$failed){
477
+ if (sizeof($merge) == 0){ $merge = array(''); }
478
+ $api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
 
 
 
 
 
 
 
479
  $retval = $api->listSubscribe( $listId, $email, $merge);
480
  if (!$retval){
481
  $failed = true;
482
  $errs[] = $api->errorMessage;
483
  } else {
484
+ $msg = "<br/><strong class='success_msg'>Success, you've been signed up! Please look for our confirmation email!</strong><br/>";
485
  }
486
  }
487
  if (sizeof($errs)>0){
488
+ $msg = '<br/>Uhoh, we had problems!<ul>';
489
  foreach($errs as $error){
490
  $msg .= '<li class="error_msg">'.$error.'</li>';
491
  }
498
  <div class="mc_custom_border">
499
  <a name="mc_signup_form"></a>
500
  <?php echo get_option('mc_header_content');?>
501
+ <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>#mc_signup_form">
502
  <?php
503
  if ($msg != ''){
504
  echo '<span class="updated">'.$msg.'</span>';
506
  foreach($mv as $var){
507
  $opt = 'mc_mv_'.$var['tag'];
508
  if ($var['req'] || get_option($opt)=='on'){
509
+ echo ''.$var['name'].':<br/><input type="text" size="20" value="" name="'.$opt.'">';
510
  if ($var['req']){ echo '*'; }
511
  echo '<br/>';
512
  }
513
  }
514
+ echo '<sup style="clear:both;">* = required field</sup>';
515
+ if (get_option('mc_show_interest_groups')=='on'){
516
  echo '<br/><br/><strong>'.$ig['name'].'</strong><br/>';
517
  if ($ig['form_field']=='checkbox'){
518
  foreach($ig['groups'] as $interest){
537
  </form>
538
  <?php
539
  if ( get_option('mc_rewards')=='on') {
540
+ echo '<div align="center">powered by <a href="http://www.mailchimp.com/affiliates/?aid='.get_option('mc_user_id').'&afl=1">MailChimp</a>!</div>';
541
  }
542
  ?>
543
  </div>
po/mailchimp_i18n-en_US.mo DELETED
Binary file
po/mailchimp_i18n-en_US.po DELETED
@@ -1,269 +0,0 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
- #
6
- msgid ""
7
- msgstr ""
8
- "Project-Id-Version: MailChimp Wordpress Plugin\n"
9
- "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2008-10-14 11:15-0400\n"
11
- "PO-Revision-Date: 2008-10-14 11:18-0500\n"
12
- "Last-Translator: MailChimp API <api@mailchimp.com>\n"
13
- "Language-Team: MailChimp API <api@mailchimp.com>\n"
14
- "MIME-Version: 1.0\n"
15
- "Content-Type: text/plain; charset=utf-8\n"
16
- "Content-Transfer-Encoding: 8bit\n"
17
- "X-Poedit-Language: English\n"
18
- "X-Poedit-Country: UNITED STATES\n"
19
-
20
- #: mailchimp.php:87
21
- msgid "MailChimp Setup"
22
- msgstr ""
23
-
24
- #: mailchimp.php:105
25
- msgid "While upgrading the plugin setup, we were unable to login to your account. You will need to login again and setup your list."
26
- msgstr ""
27
-
28
- #: mailchimp.php:111
29
- msgid "MailChimp List Setup"
30
- msgstr ""
31
-
32
- #: mailchimp.php:121
33
- msgid "Success! We were able to verify your username &amp; password! Let's continue, shall we?"
34
- msgstr ""
35
-
36
- #: mailchimp.php:133
37
- msgid "Uh-oh, we were unable to login and verify your username &amp; password. Please check them and try again!"
38
- msgstr ""
39
-
40
- #: mailchimp.php:134
41
- msgid "The server said:"
42
- msgstr ""
43
-
44
- #: mailchimp.php:175
45
- msgid "Sign up for"
46
- msgstr ""
47
-
48
- #: mailchimp.php:176
49
- msgid "Subscribe"
50
- msgstr ""
51
-
52
- #: mailchimp.php:195
53
- #, php-format
54
- msgid "Success! Loaded and saved the info for %d Merge Variables and %d Interest Groups from your list"
55
- msgstr ""
56
-
57
- #: mailchimp.php:198
58
- msgid "Now you should either Turn On the MailChimp Widget or change your options below, then turn it on."
59
- msgstr ""
60
-
61
- #: mailchimp.php:217
62
- msgid "Successfully Reset your List selection... Now you get to pick again!"
63
- msgstr ""
64
-
65
- #: mailchimp.php:223
66
- msgid "Monkey Rewards turned On!"
67
- msgstr ""
68
-
69
- #: mailchimp.php:227
70
- msgid "Monkey Rewards turned Off!"
71
- msgstr ""
72
-
73
- #: mailchimp.php:267
74
- msgid "Successfully Updated your List Subscribe Form Settings!"
75
- msgstr ""
76
-
77
- #: mailchimp.php:278
78
- msgid "Login Info"
79
- msgstr ""
80
-
81
- #: mailchimp.php:279
82
- msgid "To start using the MailChimp plugin, we first need to login and get your API Key. Please enter your MailChimp username and password below."
83
- msgstr ""
84
-
85
- #: mailchimp.php:283
86
- msgid "Username"
87
- msgstr ""
88
-
89
- #: mailchimp.php:287
90
- msgid "Password"
91
- msgstr ""
92
-
93
- #: mailchimp.php:293
94
- msgid "Save & Check"
95
- msgstr ""
96
-
97
- #: mailchimp.php:297
98
- msgid "Notes"
99
- msgstr ""
100
-
101
- #: mailchimp.php:298
102
- msgid "Changing your settings at MailChimp.com may cause this to stop working."
103
- msgstr ""
104
-
105
- #: mailchimp.php:299
106
- msgid "If you change your login to a different account, the info you have setup below will be erased."
107
- msgstr ""
108
-
109
- #: mailchimp.php:300
110
- msgid "If any of that happens, no biggie - just reconfigure your login and the items below..."
111
- msgstr ""
112
-
113
- #: mailchimp.php:306
114
- msgid "Logged in as"
115
- msgstr ""
116
-
117
- #: mailchimp.php:310
118
- msgid "Logout"
119
- msgstr ""
120
-
121
- #: mailchimp.php:323
122
- msgid "Your Lists"
123
- msgstr ""
124
-
125
- #: mailchimp.php:324
126
- msgid "Please select the List you wish to create a Signup Form for."
127
- msgstr ""
128
-
129
- #: mailchimp.php:332
130
- #, php-format
131
- msgid "Uh-oh, you don't have any lists defined! Please visit %s, login, and setup a list before using this tool!"
132
- msgstr ""
133
-
134
- #: mailchimp.php:337
135
- msgid "Select A List"
136
- msgstr ""
137
-
138
- #: mailchimp.php:351
139
- msgid "Update List"
140
- msgstr ""
141
-
142
- #: mailchimp.php:365
143
- msgid "Reset List Options and Select again"
144
- msgstr ""
145
-
146
- #: mailchimp.php:368
147
- msgid "Subscribe Form Widget Settings for this List"
148
- msgstr ""
149
-
150
- #: mailchimp.php:369
151
- msgid "Selected MailChimp List"
152
- msgstr ""
153
-
154
- #: mailchimp.php:391
155
- msgid "Monkey Rewards"
156
- msgstr ""
157
-
158
- #: mailchimp.php:393
159
- msgid "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."
160
- msgstr ""
161
-
162
- #: mailchimp.php:397
163
- msgid "Header content"
164
- msgstr ""
165
-
166
- #: mailchimp.php:400
167
- #: mailchimp.php:408
168
- msgid "You can fill this with your own Text, HTML markup (including image links), or Nothing!"
169
- msgstr ""
170
-
171
- #: mailchimp.php:405
172
- msgid "Submit Button text"
173
- msgstr ""
174
-
175
- #: mailchimp.php:413
176
- msgid "Custom Styling"
177
- msgstr ""
178
-
179
- #: mailchimp.php:416
180
- msgid "Turned On?"
181
- msgstr ""
182
-
183
- #: mailchimp.php:417
184
- msgid "Border Width"
185
- msgstr ""
186
-
187
- #: mailchimp.php:418
188
- msgid "Set to 0 for no border, do not enter <strong>px</strong>!"
189
- msgstr ""
190
-
191
- #: mailchimp.php:420
192
- msgid "Border Color"
193
- msgstr ""