Version Description
- Whole plugin is re-written in OOP
- Huge performance Improvements
- Moved JS and CSS folders inside assets folder
- Enhanced: Functions are more organized in wps-helpers and wps-functions-options file.
- Fixed: Missing and in-correct textdomain
Download this release
Release Info
Developer | MyThemeShop |
Plugin | WP Subscribe |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.4 to 1.2.0
- Gruntfile.js +69 -0
- Mailchimp.php +0 -261
- Mailchimp/Campaigns.php +0 -378
- Mailchimp/Conversations.php +0 -80
- Mailchimp/Ecomm.php +0 -86
- Mailchimp/Exceptions.php +0 -471
- Mailchimp/Folders.php +0 -62
- Mailchimp/Gallery.php +0 -106
- Mailchimp/Goal.php +0 -49
- Mailchimp/Helper.php +0 -237
- Mailchimp/Lists.php +0 -904
- Mailchimp/Mobile.php +0 -8
- Mailchimp/Neapolitan.php +0 -10
- Mailchimp/Reports.php +0 -459
- Mailchimp/Templates.php +0 -114
- Mailchimp/Users.php +0 -105
- Mailchimp/Vip.php +0 -111
- assets/css/wp-subscribe-form.css +31 -0
- assets/css/wp-subscribe-options.css +69 -0
- assets/js/jquery.cookie.js +117 -0
- assets/js/jquery.exitIntent.js +64 -0
- assets/js/magnificpopup.js +4 -0
- assets/js/wp-subscribe-admin.js +146 -0
- assets/js/wp-subscribe-form.js +101 -0
- assets/js/wp-subscribe-options.js +512 -0
- css/wp-subscribe-admin.css +0 -12
- css/wp-subscribe.css +0 -24
- includes/class-wps-base.php +87 -0
- includes/subscription/class-wps-aweber.php +210 -0
- includes/subscription/class-wps-base.php +140 -0
- includes/subscription/class-wps-feedburner.php +45 -0
- includes/subscription/class-wps-mailchimp.php +84 -0
- includes/subscription/libs/aweber_api/aweber.php +307 -0
- includes/subscription/libs/aweber_api/aweber_api.php +8 -0
- includes/subscription/libs/aweber_api/aweber_collection.php +273 -0
- includes/subscription/libs/aweber_api/aweber_entry.php +350 -0
- includes/subscription/libs/aweber_api/aweber_entry_data_array.php +65 -0
- includes/subscription/libs/aweber_api/aweber_response.php +75 -0
- includes/subscription/libs/aweber_api/curl_object.php +103 -0
- includes/subscription/libs/aweber_api/curl_response.php +51 -0
- includes/subscription/libs/aweber_api/exceptions.php +152 -0
- includes/subscription/libs/aweber_api/oauth_adapter.php +10 -0
- includes/subscription/libs/aweber_api/oauth_application.php +689 -0
- includes/subscription/libs/mailchimp.php +306 -0
- includes/wps-functions-options.php +42 -0
- includes/wps-helpers.php +365 -0
- includes/wps-widget.php +380 -0
- js/wp-subscribe-admin.js +0 -43
- languages/default.po +0 -138
- languages/{default.mo → wp-subscribe.mo} +0 -0
- languages/wp-subscribe.po +370 -0
- package.json +19 -0
- readme.txt +11 -4
- wp-subscribe.php +303 -453
Gruntfile.js
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
module.exports = function(grunt) {
|
2 |
+
|
3 |
+
// Project configuration.
|
4 |
+
grunt.initConfig({
|
5 |
+
pkg: grunt.file.readJSON('package.json'),
|
6 |
+
|
7 |
+
// Generate POT files.
|
8 |
+
makepot: {
|
9 |
+
dist: {
|
10 |
+
options: {
|
11 |
+
type: 'wp-plugin',
|
12 |
+
mainFile: 'wp-subscribe-pro.php',
|
13 |
+
domainPath: 'languages',
|
14 |
+
potHeaders: {
|
15 |
+
'report-msgid-bugs-to': 'https://community.mythemeshop.com/',
|
16 |
+
'language-team': 'MyThemeShop <support-team@mythemeshop.com>'
|
17 |
+
},
|
18 |
+
potFilename: 'wp-subscribe-pro.pot',
|
19 |
+
exclude: [
|
20 |
+
'node_modules/.*'
|
21 |
+
]
|
22 |
+
}
|
23 |
+
}
|
24 |
+
},
|
25 |
+
|
26 |
+
// Check textdomain errors.
|
27 |
+
checktextdomain: {
|
28 |
+
options: {
|
29 |
+
// Keywords specs wordpress
|
30 |
+
keywords: [
|
31 |
+
'__:1,2d',
|
32 |
+
'_e:1,2d',
|
33 |
+
'_x:1,2c,3d',
|
34 |
+
'esc_html__:1,2d',
|
35 |
+
'esc_html_e:1,2d',
|
36 |
+
'esc_html_x:1,2c,3d',
|
37 |
+
'esc_attr__:1,2d',
|
38 |
+
'esc_attr_e:1,2d',
|
39 |
+
'esc_attr_x:1,2c,3d',
|
40 |
+
'_ex:1,2c,3d',
|
41 |
+
'_n:1,2,4d',
|
42 |
+
'_nx:1,2,4c,5d',
|
43 |
+
'_n_noop:1,2,3d',
|
44 |
+
'_nx_noop:1,2,3c,4d'
|
45 |
+
]
|
46 |
+
},
|
47 |
+
|
48 |
+
plugin: {
|
49 |
+
//cwd: '/',
|
50 |
+
src: ['**/*.php', '!node_modules/**'],
|
51 |
+
expand: true,
|
52 |
+
options: {
|
53 |
+
text_domain: ['wp-subscribe']
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
});
|
58 |
+
|
59 |
+
// Default task(s).
|
60 |
+
grunt.registerTask('default', [
|
61 |
+
'checktextdomain', 'makepot'
|
62 |
+
]);
|
63 |
+
|
64 |
+
// Load the plugin that provides the tasks.
|
65 |
+
grunt.loadNpmTasks( 'grunt-wp-i18n' );
|
66 |
+
|
67 |
+
// Quality Assurance
|
68 |
+
grunt.loadNpmTasks( 'grunt-checktextdomain' );
|
69 |
+
};
|
Mailchimp.php
DELETED
@@ -1,261 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once 'Mailchimp/Folders.php';
|
4 |
-
require_once 'Mailchimp/Templates.php';
|
5 |
-
require_once 'Mailchimp/Users.php';
|
6 |
-
require_once 'Mailchimp/Helper.php';
|
7 |
-
require_once 'Mailchimp/Mobile.php';
|
8 |
-
require_once 'Mailchimp/Conversations.php';
|
9 |
-
require_once 'Mailchimp/Ecomm.php';
|
10 |
-
require_once 'Mailchimp/Neapolitan.php';
|
11 |
-
require_once 'Mailchimp/Lists.php';
|
12 |
-
require_once 'Mailchimp/Campaigns.php';
|
13 |
-
require_once 'Mailchimp/Vip.php';
|
14 |
-
require_once 'Mailchimp/Reports.php';
|
15 |
-
require_once 'Mailchimp/Gallery.php';
|
16 |
-
require_once 'Mailchimp/Goal.php';
|
17 |
-
require_once 'Mailchimp/Exceptions.php';
|
18 |
-
|
19 |
-
class Mailchimp {
|
20 |
-
|
21 |
-
public $apikey;
|
22 |
-
public $ch;
|
23 |
-
public $root = 'https://api.mailchimp.com/2.0';
|
24 |
-
public $debug = false;
|
25 |
-
|
26 |
-
public static $error_map = array(
|
27 |
-
"ValidationError" => "Mailchimp_ValidationError",
|
28 |
-
"ServerError_MethodUnknown" => "Mailchimp_ServerError_MethodUnknown",
|
29 |
-
"ServerError_InvalidParameters" => "Mailchimp_ServerError_InvalidParameters",
|
30 |
-
"Unknown_Exception" => "Mailchimp_Unknown_Exception",
|
31 |
-
"Request_TimedOut" => "Mailchimp_Request_TimedOut",
|
32 |
-
"Zend_Uri_Exception" => "Mailchimp_Zend_Uri_Exception",
|
33 |
-
"PDOException" => "Mailchimp_PDOException",
|
34 |
-
"Avesta_Db_Exception" => "Mailchimp_Avesta_Db_Exception",
|
35 |
-
"XML_RPC2_Exception" => "Mailchimp_XML_RPC2_Exception",
|
36 |
-
"XML_RPC2_FaultException" => "Mailchimp_XML_RPC2_FaultException",
|
37 |
-
"Too_Many_Connections" => "Mailchimp_Too_Many_Connections",
|
38 |
-
"Parse_Exception" => "Mailchimp_Parse_Exception",
|
39 |
-
"User_Unknown" => "Mailchimp_User_Unknown",
|
40 |
-
"User_Disabled" => "Mailchimp_User_Disabled",
|
41 |
-
"User_DoesNotExist" => "Mailchimp_User_DoesNotExist",
|
42 |
-
"User_NotApproved" => "Mailchimp_User_NotApproved",
|
43 |
-
"Invalid_ApiKey" => "Mailchimp_Invalid_ApiKey",
|
44 |
-
"User_UnderMaintenance" => "Mailchimp_User_UnderMaintenance",
|
45 |
-
"Invalid_AppKey" => "Mailchimp_Invalid_AppKey",
|
46 |
-
"Invalid_IP" => "Mailchimp_Invalid_IP",
|
47 |
-
"User_DoesExist" => "Mailchimp_User_DoesExist",
|
48 |
-
"User_InvalidRole" => "Mailchimp_User_InvalidRole",
|
49 |
-
"User_InvalidAction" => "Mailchimp_User_InvalidAction",
|
50 |
-
"User_MissingEmail" => "Mailchimp_User_MissingEmail",
|
51 |
-
"User_CannotSendCampaign" => "Mailchimp_User_CannotSendCampaign",
|
52 |
-
"User_MissingModuleOutbox" => "Mailchimp_User_MissingModuleOutbox",
|
53 |
-
"User_ModuleAlreadyPurchased" => "Mailchimp_User_ModuleAlreadyPurchased",
|
54 |
-
"User_ModuleNotPurchased" => "Mailchimp_User_ModuleNotPurchased",
|
55 |
-
"User_NotEnoughCredit" => "Mailchimp_User_NotEnoughCredit",
|
56 |
-
"MC_InvalidPayment" => "Mailchimp_MC_InvalidPayment",
|
57 |
-
"List_DoesNotExist" => "Mailchimp_List_DoesNotExist",
|
58 |
-
"List_InvalidInterestFieldType" => "Mailchimp_List_InvalidInterestFieldType",
|
59 |
-
"List_InvalidOption" => "Mailchimp_List_InvalidOption",
|
60 |
-
"List_InvalidUnsubMember" => "Mailchimp_List_InvalidUnsubMember",
|
61 |
-
"List_InvalidBounceMember" => "Mailchimp_List_InvalidBounceMember",
|
62 |
-
"List_AlreadySubscribed" => "Mailchimp_List_AlreadySubscribed",
|
63 |
-
"List_NotSubscribed" => "Mailchimp_List_NotSubscribed",
|
64 |
-
"List_InvalidImport" => "Mailchimp_List_InvalidImport",
|
65 |
-
"MC_PastedList_Duplicate" => "Mailchimp_MC_PastedList_Duplicate",
|
66 |
-
"MC_PastedList_InvalidImport" => "Mailchimp_MC_PastedList_InvalidImport",
|
67 |
-
"Email_AlreadySubscribed" => "Mailchimp_Email_AlreadySubscribed",
|
68 |
-
"Email_AlreadyUnsubscribed" => "Mailchimp_Email_AlreadyUnsubscribed",
|
69 |
-
"Email_NotExists" => "Mailchimp_Email_NotExists",
|
70 |
-
"Email_NotSubscribed" => "Mailchimp_Email_NotSubscribed",
|
71 |
-
"List_MergeFieldRequired" => "Mailchimp_List_MergeFieldRequired",
|
72 |
-
"List_CannotRemoveEmailMerge" => "Mailchimp_List_CannotRemoveEmailMerge",
|
73 |
-
"List_Merge_InvalidMergeID" => "Mailchimp_List_Merge_InvalidMergeID",
|
74 |
-
"List_TooManyMergeFields" => "Mailchimp_List_TooManyMergeFields",
|
75 |
-
"List_InvalidMergeField" => "Mailchimp_List_InvalidMergeField",
|
76 |
-
"List_InvalidInterestGroup" => "Mailchimp_List_InvalidInterestGroup",
|
77 |
-
"List_TooManyInterestGroups" => "Mailchimp_List_TooManyInterestGroups",
|
78 |
-
"Campaign_DoesNotExist" => "Mailchimp_Campaign_DoesNotExist",
|
79 |
-
"Campaign_StatsNotAvailable" => "Mailchimp_Campaign_StatsNotAvailable",
|
80 |
-
"Campaign_InvalidAbsplit" => "Mailchimp_Campaign_InvalidAbsplit",
|
81 |
-
"Campaign_InvalidContent" => "Mailchimp_Campaign_InvalidContent",
|
82 |
-
"Campaign_InvalidOption" => "Mailchimp_Campaign_InvalidOption",
|
83 |
-
"Campaign_InvalidStatus" => "Mailchimp_Campaign_InvalidStatus",
|
84 |
-
"Campaign_NotSaved" => "Mailchimp_Campaign_NotSaved",
|
85 |
-
"Campaign_InvalidSegment" => "Mailchimp_Campaign_InvalidSegment",
|
86 |
-
"Campaign_InvalidRss" => "Mailchimp_Campaign_InvalidRss",
|
87 |
-
"Campaign_InvalidAuto" => "Mailchimp_Campaign_InvalidAuto",
|
88 |
-
"MC_ContentImport_InvalidArchive" => "Mailchimp_MC_ContentImport_InvalidArchive",
|
89 |
-
"Campaign_BounceMissing" => "Mailchimp_Campaign_BounceMissing",
|
90 |
-
"Campaign_InvalidTemplate" => "Mailchimp_Campaign_InvalidTemplate",
|
91 |
-
"Invalid_EcommOrder" => "Mailchimp_Invalid_EcommOrder",
|
92 |
-
"Absplit_UnknownError" => "Mailchimp_Absplit_UnknownError",
|
93 |
-
"Absplit_UnknownSplitTest" => "Mailchimp_Absplit_UnknownSplitTest",
|
94 |
-
"Absplit_UnknownTestType" => "Mailchimp_Absplit_UnknownTestType",
|
95 |
-
"Absplit_UnknownWaitUnit" => "Mailchimp_Absplit_UnknownWaitUnit",
|
96 |
-
"Absplit_UnknownWinnerType" => "Mailchimp_Absplit_UnknownWinnerType",
|
97 |
-
"Absplit_WinnerNotSelected" => "Mailchimp_Absplit_WinnerNotSelected",
|
98 |
-
"Invalid_Analytics" => "Mailchimp_Invalid_Analytics",
|
99 |
-
"Invalid_DateTime" => "Mailchimp_Invalid_DateTime",
|
100 |
-
"Invalid_Email" => "Mailchimp_Invalid_Email",
|
101 |
-
"Invalid_SendType" => "Mailchimp_Invalid_SendType",
|
102 |
-
"Invalid_Template" => "Mailchimp_Invalid_Template",
|
103 |
-
"Invalid_TrackingOptions" => "Mailchimp_Invalid_TrackingOptions",
|
104 |
-
"Invalid_Options" => "Mailchimp_Invalid_Options",
|
105 |
-
"Invalid_Folder" => "Mailchimp_Invalid_Folder",
|
106 |
-
"Invalid_URL" => "Mailchimp_Invalid_URL",
|
107 |
-
"Module_Unknown" => "Mailchimp_Module_Unknown",
|
108 |
-
"MonthlyPlan_Unknown" => "Mailchimp_MonthlyPlan_Unknown",
|
109 |
-
"Order_TypeUnknown" => "Mailchimp_Order_TypeUnknown",
|
110 |
-
"Invalid_PagingLimit" => "Mailchimp_Invalid_PagingLimit",
|
111 |
-
"Invalid_PagingStart" => "Mailchimp_Invalid_PagingStart",
|
112 |
-
"Max_Size_Reached" => "Mailchimp_Max_Size_Reached",
|
113 |
-
"MC_SearchException" => "Mailchimp_MC_SearchException",
|
114 |
-
"Goal_SaveFailed" => "Mailchimp_Goal_SaveFailed",
|
115 |
-
"Conversation_DoesNotExist" => "Mailchimp_Conversation_DoesNotExist",
|
116 |
-
"Conversation_ReplySaveFailed" => "Mailchimp_Conversation_ReplySaveFailed",
|
117 |
-
"File_Not_Found_Exception" => "Mailchimp_File_Not_Found_Exception",
|
118 |
-
"Folder_Not_Found_Exception" => "Mailchimp_Folder_Not_Found_Exception",
|
119 |
-
"Folder_Exists_Exception" => "Mailchimp_Folder_Exists_Exception"
|
120 |
-
);
|
121 |
-
|
122 |
-
public function __construct($apikey=null, $opts=array()) {
|
123 |
-
if (!$apikey) {
|
124 |
-
$apikey = getenv('MAILCHIMP_APIKEY');
|
125 |
-
}
|
126 |
-
|
127 |
-
if (!$apikey) {
|
128 |
-
$apikey = $this->readConfigs();
|
129 |
-
}
|
130 |
-
|
131 |
-
if (!$apikey) {
|
132 |
-
throw new Mailchimp_Error('You must provide a MailChimp API key');
|
133 |
-
}
|
134 |
-
|
135 |
-
$this->apikey = $apikey;
|
136 |
-
$dc = "us1";
|
137 |
-
|
138 |
-
if (strstr($this->apikey, "-")){
|
139 |
-
list($key, $dc) = explode("-", $this->apikey, 2);
|
140 |
-
if (!$dc) {
|
141 |
-
$dc = "us1";
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
$this->root = str_replace('https://api', 'https://' . $dc . '.api', $this->root);
|
146 |
-
$this->root = rtrim($this->root, '/') . '/';
|
147 |
-
|
148 |
-
if (!isset($opts['timeout']) || !is_int($opts['timeout'])){
|
149 |
-
$opts['timeout'] = 600;
|
150 |
-
}
|
151 |
-
if (isset($opts['debug'])){
|
152 |
-
$this->debug = true;
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
$this->ch = curl_init();
|
157 |
-
|
158 |
-
if ( isset($opts['CURLOPT_FOLLOWLOCATION']) && $opts['CURLOPT_FOLLOWLOCATION'] === true) {
|
159 |
-
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
|
160 |
-
}
|
161 |
-
|
162 |
-
curl_setopt($this->ch, CURLOPT_USERAGENT, 'MailChimp-PHP/2.0.5');
|
163 |
-
curl_setopt($this->ch, CURLOPT_POST, true);
|
164 |
-
curl_setopt($this->ch, CURLOPT_HEADER, false);
|
165 |
-
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
|
166 |
-
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 30);
|
167 |
-
curl_setopt($this->ch, CURLOPT_TIMEOUT, $opts['timeout']);
|
168 |
-
|
169 |
-
|
170 |
-
$this->folders = new Mailchimp_Folders($this);
|
171 |
-
$this->templates = new Mailchimp_Templates($this);
|
172 |
-
$this->users = new Mailchimp_Users($this);
|
173 |
-
$this->helper = new Mailchimp_Helper($this);
|
174 |
-
$this->mobile = new Mailchimp_Mobile($this);
|
175 |
-
$this->conversations = new Mailchimp_Conversations($this);
|
176 |
-
$this->ecomm = new Mailchimp_Ecomm($this);
|
177 |
-
$this->neapolitan = new Mailchimp_Neapolitan($this);
|
178 |
-
$this->lists = new Mailchimp_Lists($this);
|
179 |
-
$this->campaigns = new Mailchimp_Campaigns($this);
|
180 |
-
$this->vip = new Mailchimp_Vip($this);
|
181 |
-
$this->reports = new Mailchimp_Reports($this);
|
182 |
-
$this->gallery = new Mailchimp_Gallery($this);
|
183 |
-
$this->goal = new Mailchimp_Goal($this);
|
184 |
-
}
|
185 |
-
|
186 |
-
public function __destruct() {
|
187 |
-
curl_close($this->ch);
|
188 |
-
}
|
189 |
-
|
190 |
-
public function call($url, $params) {
|
191 |
-
$params['apikey'] = $this->apikey;
|
192 |
-
|
193 |
-
$params = json_encode($params);
|
194 |
-
$ch = $this->ch;
|
195 |
-
|
196 |
-
curl_setopt($ch, CURLOPT_URL, $this->root . $url . '.json');
|
197 |
-
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
|
198 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
199 |
-
curl_setopt($ch, CURLOPT_VERBOSE, $this->debug);
|
200 |
-
|
201 |
-
$start = microtime(true);
|
202 |
-
$this->log('Call to ' . $this->root . $url . '.json: ' . $params);
|
203 |
-
if($this->debug) {
|
204 |
-
$curl_buffer = fopen('php://memory', 'w+');
|
205 |
-
curl_setopt($ch, CURLOPT_STDERR, $curl_buffer);
|
206 |
-
}
|
207 |
-
|
208 |
-
$response_body = curl_exec($ch);
|
209 |
-
|
210 |
-
$info = curl_getinfo($ch);
|
211 |
-
$time = microtime(true) - $start;
|
212 |
-
if($this->debug) {
|
213 |
-
rewind($curl_buffer);
|
214 |
-
$this->log(stream_get_contents($curl_buffer));
|
215 |
-
fclose($curl_buffer);
|
216 |
-
}
|
217 |
-
$this->log('Completed in ' . number_format($time * 1000, 2) . 'ms');
|
218 |
-
$this->log('Got response: ' . $response_body);
|
219 |
-
|
220 |
-
if(curl_error($ch)) {
|
221 |
-
throw new Mailchimp_HttpError("API call to $url failed: " . curl_error($ch));
|
222 |
-
}
|
223 |
-
$result = json_decode($response_body, true);
|
224 |
-
|
225 |
-
if(floor($info['http_code'] / 100) >= 4) {
|
226 |
-
throw $this->castError($result);
|
227 |
-
}
|
228 |
-
|
229 |
-
return $result;
|
230 |
-
}
|
231 |
-
|
232 |
-
public function readConfigs() {
|
233 |
-
$paths = array('~/.mailchimp.key', '/etc/mailchimp.key');
|
234 |
-
foreach($paths as $path) {
|
235 |
-
if(file_exists($path)) {
|
236 |
-
$apikey = trim(file_get_contents($path));
|
237 |
-
if ($apikey) {
|
238 |
-
return $apikey;
|
239 |
-
}
|
240 |
-
}
|
241 |
-
}
|
242 |
-
return false;
|
243 |
-
}
|
244 |
-
|
245 |
-
public function castError($result) {
|
246 |
-
if ($result['status'] !== 'error' || !$result['name']) {
|
247 |
-
throw new Mailchimp_Error('We received an unexpected error: ' . json_encode($result));
|
248 |
-
}
|
249 |
-
|
250 |
-
$class = (isset(self::$error_map[$result['name']])) ? self::$error_map[$result['name']] : 'Mailchimp_Error';
|
251 |
-
return new $class($result['error'], $result['code']);
|
252 |
-
}
|
253 |
-
|
254 |
-
public function log($msg) {
|
255 |
-
if ($this->debug) {
|
256 |
-
error_log($msg);
|
257 |
-
}
|
258 |
-
}
|
259 |
-
}
|
260 |
-
|
261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Campaigns.php
DELETED
@@ -1,378 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Campaigns {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content
|
10 |
-
* @param string $cid
|
11 |
-
* @param associative_array $options
|
12 |
-
* - view string optional one of "archive" (default), "preview" (like our popup-preview) or "raw"
|
13 |
-
* - email associative_array optional if provided, view is "archive" or "preview", the campaign's list still exists, and the requested record is subscribed to the list. the returned content will be populated with member data populated. a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. If multiple keys are provided, the first one from the following list that we find will be used, the rest will be ignored.
|
14 |
-
* - email string an email address
|
15 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
16 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
17 |
-
* @return associative_array containing all content for the campaign
|
18 |
-
* - html string The HTML content used for the campaign with merge tags intact
|
19 |
-
* - text string The Text content used for the campaign with merge tags intact
|
20 |
-
*/
|
21 |
-
public function content($cid, $options=array()) {
|
22 |
-
$_params = array("cid" => $cid, "options" => $options);
|
23 |
-
return $this->master->call('campaigns/content', $_params);
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Create a new draft campaign to send. You <strong>can not</strong> have more than 32,000 campaigns in your account.
|
28 |
-
* @param string $type
|
29 |
-
* @param associative_array $options
|
30 |
-
* - list_id string the list to send this campaign to- get lists using lists/list()
|
31 |
-
* - subject string the subject line for your campaign message
|
32 |
-
* - from_email string the From: email address for your campaign message
|
33 |
-
* - from_name string the From: name for your campaign message (not an email address)
|
34 |
-
* - to_name string the To: name recipients will see (not email address)
|
35 |
-
* - template_id int optional - use this user-created template to generate the HTML content of the campaign (takes precendence over other template options)
|
36 |
-
* - gallery_template_id int optional - use a template from the public gallery to generate the HTML content of the campaign (takes precendence over base template options)
|
37 |
-
* - base_template_id int optional - use this a base/start-from-scratch template to generate the HTML content of the campaign
|
38 |
-
* - folder_id int optional - automatically file the new campaign in the folder_id passed. Get using folders/list() - note that Campaigns and Autoresponders have separate folder setups
|
39 |
-
* - tracking associative_array optional - set which recipient actions will be tracked. Click tracking can not be disabled for Free accounts.
|
40 |
-
* - opens bool whether to track opens, defaults to true
|
41 |
-
* - html_clicks bool whether to track clicks in HTML content, defaults to true
|
42 |
-
* - text_clicks bool whether to track clicks in Text content, defaults to false
|
43 |
-
* - title string optional - an internal name to use for this campaign. By default, the campaign subject will be used.
|
44 |
-
* - authenticate boolean optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false.
|
45 |
-
* - analytics associative_array optional - one or more of these keys set to the tag to use - that can be any custom text (up to 50 bytes)
|
46 |
-
* - google string for Google Analytics tracking
|
47 |
-
* - clicktale string for ClickTale tracking
|
48 |
-
* - gooal string for Goal tracking (the extra 'o' in the param name is not a typo)
|
49 |
-
* - auto_footer boolean optional Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports
|
50 |
-
* - inline_css boolean optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false.
|
51 |
-
* - generate_text boolean 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.
|
52 |
-
* - auto_tweet boolean optional If set, this campaign will be auto-tweeted when it is sent - defaults to false. Note that if a Twitter account isn't linked, this will be silently ignored.
|
53 |
-
* - auto_fb_post array optional If set, this campaign will be auto-posted to the page_ids contained in the array. If a Facebook account isn't linked or the account does not have permission to post to the page_ids requested, those failures will be silently ignored.
|
54 |
-
* - fb_comments boolean optional If true, the Facebook comments (and thus the <a href="http://kb.mailchimp.com/article/i-dont-want-an-archiave-of-my-campaign-can-i-turn-it-off/" target="_blank">archive bar</a> will be displayed. If false, Facebook comments will not be enabled (does not imply no archive bar, see previous link). Defaults to "true".
|
55 |
-
* - timewarp boolean optional If set, this campaign must be scheduled 24 hours in advance of sending - default to false. Only valid for "regular" campaigns and "absplit" campaigns that split on schedule_time.
|
56 |
-
* - ecomm360 boolean optional If set, our <a href="http://www.mailchimp.com/blog/ecommerce-tracking-plugin/" target="_blank">Ecommerce360 tracking</a> will be enabled for links in the campaign
|
57 |
-
* - crm_tracking array optional If set, an array of structs to enable CRM tracking for:
|
58 |
-
* - salesforce associative_array optional Enable SalesForce push back
|
59 |
-
* - campaign bool optional - if true, create a Campaign object and update it with aggregate stats
|
60 |
-
* - notes bool optional - if true, attempt to update Contact notes based on email address
|
61 |
-
* - highrise associative_array optional Enable Highrise push back
|
62 |
-
* - campaign bool optional - if true, create a Kase object and update it with aggregate stats
|
63 |
-
* - notes bool optional - if true, attempt to update Contact notes based on email address
|
64 |
-
* - capsule associative_array optional Enable Capsule push back (only notes are supported)
|
65 |
-
* - notes bool optional - if true, attempt to update Contact notes based on email address
|
66 |
-
* @param associative_array $content
|
67 |
-
* - html string for raw/pasted HTML content
|
68 |
-
* - sections associative_array when using a template instead of raw HTML, each key should be the unique mc:edit area name from the template.
|
69 |
-
* - text string for the plain-text version
|
70 |
-
* - url string to have us pull in content from a URL. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
|
71 |
-
* - archive string to send a Base64 encoded archive file for us to import all media from. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well
|
72 |
-
* - archive_type string optional - only necessary for the "archive" option. Supported formats are: zip, tar.gz, tar.bz2, tar, tgz, tbz . If not included, we will default to zip
|
73 |
-
* @param associative_array $segment_opts
|
74 |
-
* @param associative_array $type_opts
|
75 |
-
* - rss associative_array For RSS Campaigns this, struct should contain:
|
76 |
-
* - url string the URL to pull RSS content from - it will be verified and must exist
|
77 |
-
* - schedule string optional one of "daily", "weekly", "monthly" - defaults to "daily"
|
78 |
-
* - schedule_hour string optional an hour between 0 and 24 - default to 4 (4am <em>local time</em>) - applies to all schedule types
|
79 |
-
* - schedule_weekday string optional for "weekly" only, a number specifying the day of the week to send: 0 (Sunday) - 6 (Saturday) - defaults to 1 (Monday)
|
80 |
-
* - schedule_monthday string optional for "monthly" only, a number specifying the day of the month to send (1 - 28) or "last" for the last day of a given month. Defaults to the 1st day of the month
|
81 |
-
* - days associative_array optional used for "daily" schedules only, an array of the <a href="http://en.wikipedia.org/wiki/ISO-8601#Week_dates" target="_blank">ISO-8601 weekday numbers</a> to send on
|
82 |
-
* - 1 bool optional Monday, defaults to true
|
83 |
-
* - 2 bool optional Tuesday, defaults to true
|
84 |
-
* - 3 bool optional Wednesday, defaults to true
|
85 |
-
* - 4 bool optional Thursday, defaults to true
|
86 |
-
* - 5 bool optional Friday, defaults to true
|
87 |
-
* - 6 bool optional Saturday, defaults to true
|
88 |
-
* - 7 bool optional Sunday, defaults to true
|
89 |
-
* - absplit associative_array For A/B Split campaigns, this struct should contain:
|
90 |
-
* - split_test string The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaigns/schedule() separately!
|
91 |
-
* - pick_winner string How the winner will be picked, one of: "opens" (by the open_rate), "clicks" (by the click rate), "manual" (you pick manually)
|
92 |
-
* - wait_units int optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400.
|
93 |
-
* - wait_time int 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.
|
94 |
-
* - split_size int 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%
|
95 |
-
* - from_name_a string optional sort of, required when split_test is "from_name"
|
96 |
-
* - from_name_b string optional sort of, required when split_test is "from_name"
|
97 |
-
* - from_email_a string optional sort of, required when split_test is "from_name"
|
98 |
-
* - from_email_b string optional sort of, required when split_test is "from_name"
|
99 |
-
* - subject_a string optional sort of, required when split_test is "subject"
|
100 |
-
* - subject_b string optional sort of, required when split_test is "subject"
|
101 |
-
* - auto associative_array For AutoResponder campaigns, this struct should contain:
|
102 |
-
* - offset-units string one of "hourly", "day", "week", "month", "year" - required
|
103 |
-
* - offset-time string optional, sort of - the number of units must be a number greater than 0 for signup based autoresponders, ignored for "hourly"
|
104 |
-
* - offset-dir string either "before" or "after", ignored for "hourly"
|
105 |
-
* - event string optional "signup" (default) to base this members added to a list, "date", "annual", or "birthday" to base this on merge field in the list, "campaignOpen" or "campaignClicka" to base this on any activity for a campaign, "campaignClicko" to base this on clicks on a specific URL in a campaign, "mergeChanged" to base this on a specific merge field being changed to a specific value
|
106 |
-
* - event-datemerge string optional sort of, this is required if the event is "date", "annual", "birthday", or "mergeChanged"
|
107 |
-
* - campaign_id string optional sort of, required for "campaignOpen", "campaignClicka", or "campaignClicko"
|
108 |
-
* - campaign_url string optional sort of, required for "campaignClicko"
|
109 |
-
* - schedule_hour int The hour of the day - 24 hour format in GMT - the autoresponder should be triggered, ignored for "hourly"
|
110 |
-
* - use_import_time boolean whether or not imported subscribers (ie, <em>any</em> non-double optin subscribers) will receive
|
111 |
-
* - days associative_array optional used for "daily" schedules only, an array of the <a href="http://en.wikipedia.org/wiki/ISO-8601#Week_dates" target="_blank">ISO-8601 weekday numbers</a> to send on<
|
112 |
-
* - 1 bool optional Monday, defaults to true
|
113 |
-
* - 2 bool optional Tuesday, defaults to true
|
114 |
-
* - 3 bool optional Wednesday, defaults to true
|
115 |
-
* - 4 bool optional Thursday, defaults to true
|
116 |
-
* - 5 bool optional Friday, defaults to true
|
117 |
-
* - 6 bool optional Saturday, defaults to true
|
118 |
-
* - 7 bool optional Sunday, defaults to true
|
119 |
-
* @return associative_array the new campaign's details - will return same data as single campaign from campaigns/list()
|
120 |
-
*/
|
121 |
-
public function create($type, $options, $content, $segment_opts=null, $type_opts=null) {
|
122 |
-
$_params = array("type" => $type, "options" => $options, "content" => $content, "segment_opts" => $segment_opts, "type_opts" => $type_opts);
|
123 |
-
return $this->master->call('campaigns/create', $_params);
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Delete a campaign. Seriously, "poof, gone!" - be careful! Seriously, no one can undelete these.
|
128 |
-
* @param string $cid
|
129 |
-
* @return associative_array with a single entry:
|
130 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
131 |
-
*/
|
132 |
-
public function delete($cid) {
|
133 |
-
$_params = array("cid" => $cid);
|
134 |
-
return $this->master->call('campaigns/delete', $_params);
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* Get the list of campaigns and their details matching the specified filters
|
139 |
-
* @param associative_array $filters
|
140 |
-
* - campaign_id string optional - return the campaign using a know campaign_id. Accepts multiples separated by commas when not using exact matching.
|
141 |
-
* - parent_id string optional - return the child campaigns using a known parent campaign_id. Accepts multiples separated by commas when not using exact matching.
|
142 |
-
* - list_id string optional - the list to send this campaign to - get lists using lists/list(). Accepts multiples separated by commas when not using exact matching.
|
143 |
-
* - folder_id int optional - only show campaigns from this folder id - get folders using folders/list(). Accepts multiples separated by commas when not using exact matching.
|
144 |
-
* - template_id int optional - only show campaigns using this template id - get templates using templates/list(). Accepts multiples separated by commas when not using exact matching.
|
145 |
-
* - status string optional - return campaigns of a specific status - one of "sent", "save", "paused", "schedule", "sending". Accepts multiples separated by commas when not using exact matching.
|
146 |
-
* - type string optional - return campaigns of a specific type - one of "regular", "plaintext", "absplit", "rss", "auto". Accepts multiples separated by commas when not using exact matching.
|
147 |
-
* - from_name string optional - only show campaigns that have this "From Name"
|
148 |
-
* - from_email string optional - only show campaigns that have this "Reply-to Email"
|
149 |
-
* - title string optional - only show campaigns that have this title
|
150 |
-
* - subject string optional - only show campaigns that have this subject
|
151 |
-
* - sendtime_start string optional - only show campaigns that have been sent since this date/time (in GMT) - - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00" - if this is invalid the whole call fails
|
152 |
-
* - sendtime_end string optional - only show campaigns that have been sent before this date/time (in GMT) - - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00" - if this is invalid the whole call fails
|
153 |
-
* - uses_segment boolean - whether to return just campaigns with or without segments
|
154 |
-
* - exact boolean optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true. Using this disables the use of any filters that accept multiples.
|
155 |
-
* @param int $start
|
156 |
-
* @param int $limit
|
157 |
-
* @param string $sort_field
|
158 |
-
* @param string $sort_dir
|
159 |
-
* @return associative_array containing a count of all matching campaigns, the specific ones for the current page, and any errors from the filters provided
|
160 |
-
* - total int the total number of campaigns matching the filters passed in
|
161 |
-
* - data array structs for each campaign being returned
|
162 |
-
* - id string Campaign Id (used for all other campaign functions)
|
163 |
-
* - web_id int The Campaign id used in our web app, allows you to create a link directly to it
|
164 |
-
* - list_id string The List used for this campaign
|
165 |
-
* - folder_id int The Folder this campaign is in
|
166 |
-
* - template_id int The Template this campaign uses
|
167 |
-
* - content_type string How the campaign's content is put together - one of 'template', 'html', 'url'
|
168 |
-
* - title string Title of the campaign
|
169 |
-
* - type string The type of campaign this is (regular,plaintext,absplit,rss,inspection,auto)
|
170 |
-
* - create_time string Creation time for the campaign
|
171 |
-
* - send_time string Send time for the campaign - also the scheduled time for scheduled campaigns.
|
172 |
-
* - emails_sent int Number of emails email was sent to
|
173 |
-
* - status string Status of the given campaign (save,paused,schedule,sending,sent)
|
174 |
-
* - from_name string From name of the given campaign
|
175 |
-
* - from_email string Reply-to email of the given campaign
|
176 |
-
* - subject string Subject of the given campaign
|
177 |
-
* - to_name string Custom "To:" email string using merge variables
|
178 |
-
* - archive_url string Archive link for the given campaign
|
179 |
-
* - inline_css boolean Whether or not the campaign content's css was auto-inlined
|
180 |
-
* - analytics string Either "google" if enabled or "N" if disabled
|
181 |
-
* - analytics_tag string The name/tag the campaign's links were tagged with if analytics were enabled.
|
182 |
-
* - authenticate boolean Whether or not the campaign was authenticated
|
183 |
-
* - ecomm360 boolean Whether or not ecomm360 tracking was appended to links
|
184 |
-
* - auto_tweet boolean Whether or not the campaign was auto tweeted after sending
|
185 |
-
* - auto_fb_post string A comma delimited list of Facebook Profile/Page Ids the campaign was posted to after sending. If not used, blank.
|
186 |
-
* - auto_footer boolean Whether or not the auto_footer was manually turned on
|
187 |
-
* - timewarp boolean Whether or not the campaign used Timewarp
|
188 |
-
* - timewarp_schedule string The time, in GMT, that the Timewarp campaign is being sent. For A/B Split campaigns, this is blank and is instead in their schedule_a and schedule_b in the type_opts array
|
189 |
-
* - parent_id string the unique id of the parent campaign (currently only valid for rss children). Will be blank for non-rss child campaigns or parent campaign has been deleted.
|
190 |
-
* - is_child boolean true if this is an RSS child campaign. Will return true even if the parent campaign has been deleted.
|
191 |
-
* - tests_sent string tests sent
|
192 |
-
* - tests_remain int test sends remaining
|
193 |
-
* - tracking associative_array the various tracking options used
|
194 |
-
* - html_clicks boolean whether or not tracking for html clicks was enabled.
|
195 |
-
* - text_clicks boolean whether or not tracking for text clicks was enabled.
|
196 |
-
* - opens boolean whether or not opens tracking was enabled.
|
197 |
-
* - segment_text string a string marked-up with HTML explaining the segment used for the campaign in plain English
|
198 |
-
* - segment_opts array the segment used for the campaign - can be passed to campaigns/segment-test or campaigns/create()
|
199 |
-
* - saved_segment associative_array if a saved segment was used (match+conditions returned above):
|
200 |
-
* - id int the saved segment id
|
201 |
-
* - type string the saved segment type
|
202 |
-
* - name string the saved segment name
|
203 |
-
* - type_opts associative_array the type-specific options for the campaign - can be passed to campaigns/create()
|
204 |
-
* - comments_total int total number of comments left on this campaign
|
205 |
-
* - comments_unread int total number of unread comments for this campaign based on the login the apikey belongs to
|
206 |
-
* - summary associative_array if available, the basic aggregate stats returned by reports/summary
|
207 |
-
* - errors array structs of any errors found while loading lists - usually just from providing invalid list ids
|
208 |
-
* - filter string the filter that caused the failure
|
209 |
-
* - value string the filter value that caused the failure
|
210 |
-
* - code int the error code
|
211 |
-
* - error string the error message
|
212 |
-
*/
|
213 |
-
public function getList($filters=array(), $start=0, $limit=25, $sort_field='create_time', $sort_dir='DESC') {
|
214 |
-
$_params = array("filters" => $filters, "start" => $start, "limit" => $limit, "sort_field" => $sort_field, "sort_dir" => $sort_dir);
|
215 |
-
return $this->master->call('campaigns/list', $_params);
|
216 |
-
}
|
217 |
-
|
218 |
-
/**
|
219 |
-
* Pause an AutoResponder or RSS campaign from sending
|
220 |
-
* @param string $cid
|
221 |
-
* @return associative_array with a single entry:
|
222 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
223 |
-
*/
|
224 |
-
public function pause($cid) {
|
225 |
-
$_params = array("cid" => $cid);
|
226 |
-
return $this->master->call('campaigns/pause', $_params);
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Returns information on whether a campaign is ready to send and possible issues we may have detected with it - very similar to the confirmation step in the app.
|
231 |
-
* @param string $cid
|
232 |
-
* @return associative_array containing:
|
233 |
-
* - is_ready bool whether or not you're going to be able to send this campaign
|
234 |
-
* - items array an array of structs explaining basically what the app's confirmation step would
|
235 |
-
* - type string the item type - generally success, warning, or error
|
236 |
-
* - heading string the item's heading in the app
|
237 |
-
* - details string the item's details from the app, sans any html tags/links
|
238 |
-
*/
|
239 |
-
public function ready($cid) {
|
240 |
-
$_params = array("cid" => $cid);
|
241 |
-
return $this->master->call('campaigns/ready', $_params);
|
242 |
-
}
|
243 |
-
|
244 |
-
/**
|
245 |
-
* Replicate a campaign.
|
246 |
-
* @param string $cid
|
247 |
-
* @return associative_array the matching campaign's details - will return same data as single campaign from campaigns/list()
|
248 |
-
*/
|
249 |
-
public function replicate($cid) {
|
250 |
-
$_params = array("cid" => $cid);
|
251 |
-
return $this->master->call('campaigns/replicate', $_params);
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* Resume sending an AutoResponder or RSS campaign
|
256 |
-
* @param string $cid
|
257 |
-
* @return associative_array with a single entry:
|
258 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
259 |
-
*/
|
260 |
-
public function resume($cid) {
|
261 |
-
$_params = array("cid" => $cid);
|
262 |
-
return $this->master->call('campaigns/resume', $_params);
|
263 |
-
}
|
264 |
-
|
265 |
-
/**
|
266 |
-
* Schedule a campaign to be sent in the future
|
267 |
-
* @param string $cid
|
268 |
-
* @param string $schedule_time
|
269 |
-
* @param string $schedule_time_b
|
270 |
-
* @return associative_array with a single entry:
|
271 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
272 |
-
*/
|
273 |
-
public function schedule($cid, $schedule_time, $schedule_time_b=null) {
|
274 |
-
$_params = array("cid" => $cid, "schedule_time" => $schedule_time, "schedule_time_b" => $schedule_time_b);
|
275 |
-
return $this->master->call('campaigns/schedule', $_params);
|
276 |
-
}
|
277 |
-
|
278 |
-
/**
|
279 |
-
* Schedule a campaign to be sent in batches sometime in the future. Only valid for "regular" campaigns
|
280 |
-
* @param string $cid
|
281 |
-
* @param string $schedule_time
|
282 |
-
* @param int $num_batches
|
283 |
-
* @param int $stagger_mins
|
284 |
-
* @return associative_array with a single entry:
|
285 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
286 |
-
*/
|
287 |
-
public function scheduleBatch($cid, $schedule_time, $num_batches=2, $stagger_mins=5) {
|
288 |
-
$_params = array("cid" => $cid, "schedule_time" => $schedule_time, "num_batches" => $num_batches, "stagger_mins" => $stagger_mins);
|
289 |
-
return $this->master->call('campaigns/schedule-batch', $_params);
|
290 |
-
}
|
291 |
-
|
292 |
-
/**
|
293 |
-
* Allows one to test their segmentation rules before creating a campaign using them.
|
294 |
-
* @param string $list_id
|
295 |
-
* @param associative_array $options
|
296 |
-
* - saved_segment_id string a saved segment id from lists/segments() - this will take precendence, otherwise the match+conditions are required.
|
297 |
-
* - match string controls whether to use AND or OR when applying your options - expects "<strong>any</strong>" (for OR) or "<strong>all</strong>" (for AND)
|
298 |
-
* - conditions array of up to 5 structs for different criteria to apply while segmenting. Each criteria row must contain 3 keys - "<strong>field</strong>", "<strong>op</strong>", and "<strong>value</strong>" - and possibly a fourth, "<strong>extra</strong>", based on these definitions:
|
299 |
-
* @return associative_array with a single entry:
|
300 |
-
* - total int The total number of subscribers matching your segmentation options
|
301 |
-
*/
|
302 |
-
public function segmentTest($list_id, $options) {
|
303 |
-
$_params = array("list_id" => $list_id, "options" => $options);
|
304 |
-
return $this->master->call('campaigns/segment-test', $_params);
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Send a given campaign immediately. For RSS campaigns, this will "start" them.
|
309 |
-
* @param string $cid
|
310 |
-
* @return associative_array with a single entry:
|
311 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
312 |
-
*/
|
313 |
-
public function send($cid) {
|
314 |
-
$_params = array("cid" => $cid);
|
315 |
-
return $this->master->call('campaigns/send', $_params);
|
316 |
-
}
|
317 |
-
|
318 |
-
/**
|
319 |
-
* Send a test of this campaign to the provided email addresses
|
320 |
-
* @param string $cid
|
321 |
-
* @param array $test_emails
|
322 |
-
* @param string $send_type
|
323 |
-
* @return associative_array with a single entry:
|
324 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
325 |
-
*/
|
326 |
-
public function sendTest($cid, $test_emails=array(), $send_type='html') {
|
327 |
-
$_params = array("cid" => $cid, "test_emails" => $test_emails, "send_type" => $send_type);
|
328 |
-
return $this->master->call('campaigns/send-test', $_params);
|
329 |
-
}
|
330 |
-
|
331 |
-
/**
|
332 |
-
* Get the HTML template content sections for a campaign. Note that this <strong>will</strong> return very jagged, non-standard results based on the template
|
333 |
-
a campaign is using. You only want to use this if you want to allow editing template sections in your application.
|
334 |
-
* @param string $cid
|
335 |
-
* @return associative_array content containing all content section for the campaign - section name are dependent upon the template used and thus can't be documented
|
336 |
-
*/
|
337 |
-
public function templateContent($cid) {
|
338 |
-
$_params = array("cid" => $cid);
|
339 |
-
return $this->master->call('campaigns/template-content', $_params);
|
340 |
-
}
|
341 |
-
|
342 |
-
/**
|
343 |
-
* Unschedule a campaign that is scheduled to be sent in the future
|
344 |
-
* @param string $cid
|
345 |
-
* @return associative_array with a single entry:
|
346 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
347 |
-
*/
|
348 |
-
public function unschedule($cid) {
|
349 |
-
$_params = array("cid" => $cid);
|
350 |
-
return $this->master->call('campaigns/unschedule', $_params);
|
351 |
-
}
|
352 |
-
|
353 |
-
/**
|
354 |
-
* Update just about any setting besides type for a campaign that has <em>not</em> been sent. See campaigns/create() for details.
|
355 |
-
Caveats:<br/><ul class='bullets'>
|
356 |
-
<li>If you set a new list_id, all segmentation options will be deleted and must be re-added.</li>
|
357 |
-
<li>If you set template_id, you need to follow that up by setting it's 'content'</li>
|
358 |
-
<li>If you set segment_opts, you should have tested your options against campaigns/segment-test().</li>
|
359 |
-
<li>To clear/unset segment_opts, pass an empty string or array as the value. Various wrappers may require one or the other.</li>
|
360 |
-
</ul>
|
361 |
-
* @param string $cid
|
362 |
-
* @param string $name
|
363 |
-
* @param array $value
|
364 |
-
* @return associative_array updated campaign details and any errors
|
365 |
-
* - data associative_array the update campaign details - will return same data as single campaign from campaigns/list()
|
366 |
-
* - errors array for "options" only - structs containing:
|
367 |
-
* - code int the error code
|
368 |
-
* - message string the full error message
|
369 |
-
* - name string the parameter name that failed
|
370 |
-
*/
|
371 |
-
public function update($cid, $name, $value) {
|
372 |
-
$_params = array("cid" => $cid, "name" => $name, "value" => $value);
|
373 |
-
return $this->master->call('campaigns/update', $_params);
|
374 |
-
}
|
375 |
-
|
376 |
-
}
|
377 |
-
|
378 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Conversations.php
DELETED
@@ -1,80 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Conversations {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Retrieve conversation metadata, includes message data for the most recent message in the conversation
|
10 |
-
* @param string $list_id
|
11 |
-
* @param string $leid
|
12 |
-
* @param string $campaign_id
|
13 |
-
* @param int $start
|
14 |
-
* @param int $limit
|
15 |
-
* @return associative_array Conversation data and metadata
|
16 |
-
* - count int Total number of conversations, irrespective of pagination.
|
17 |
-
* - data array An array of structs representing individual conversations
|
18 |
-
* - unique_id string A string identifying this particular conversation
|
19 |
-
* - message_count int The total number of messages in this conversation
|
20 |
-
* - campaign_id string The unique identifier of the campaign this conversation is associated with
|
21 |
-
* - list_id string The unique identifier of the list this conversation is associated with
|
22 |
-
* - unread_messages int The number of messages in this conversation which have not yet been read.
|
23 |
-
* - from_label string A label representing the sender of this message.
|
24 |
-
* - from_email string The email address of the sender of this message.
|
25 |
-
* - subject string The subject of the message.
|
26 |
-
* - timestamp string Date the message was either sent or received.
|
27 |
-
* - last_message associative_array The most recent message in the conversation
|
28 |
-
* - from_label string A label representing the sender of this message.
|
29 |
-
* - from_email string The email address of the sender of this message.
|
30 |
-
* - subject string The subject of the message.
|
31 |
-
* - message string The plain-text content of the message.
|
32 |
-
* - read boolean Whether or not this message has been marked as read.
|
33 |
-
* - timestamp string Date the message was either sent or received.
|
34 |
-
*/
|
35 |
-
public function getList($list_id=null, $leid=null, $campaign_id=null, $start=0, $limit=25) {
|
36 |
-
$_params = array("list_id" => $list_id, "leid" => $leid, "campaign_id" => $campaign_id, "start" => $start, "limit" => $limit);
|
37 |
-
return $this->master->call('conversations/list', $_params);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Retrieve conversation messages
|
42 |
-
* @param string $conversation_id
|
43 |
-
* @param boolean $mark_as_read
|
44 |
-
* @param int $start
|
45 |
-
* @param int $limit
|
46 |
-
* @return associative_array Message data and metadata
|
47 |
-
* - count int The number of messages in this conversation, irrespective of paging.
|
48 |
-
* - data array An array of structs representing each message in a conversation
|
49 |
-
* - from_label string A label representing the sender of this message.
|
50 |
-
* - from_email string The email address of the sender of this message.
|
51 |
-
* - subject string The subject of the message.
|
52 |
-
* - message string The plain-text content of the message.
|
53 |
-
* - read boolean Whether or not this message has been marked as read.
|
54 |
-
* - timestamp string Date the message was either sent or received.
|
55 |
-
*/
|
56 |
-
public function messages($conversation_id, $mark_as_read=false, $start=0, $limit=25) {
|
57 |
-
$_params = array("conversation_id" => $conversation_id, "mark_as_read" => $mark_as_read, "start" => $start, "limit" => $limit);
|
58 |
-
return $this->master->call('conversations/messages', $_params);
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Retrieve conversation messages
|
63 |
-
* @param string $conversation_id
|
64 |
-
* @param string $message
|
65 |
-
* @return associative_array Message data from the created message
|
66 |
-
* - from_label string A label representing the sender of this message.
|
67 |
-
* - from_email string The email address of the sender of this message.
|
68 |
-
* - subject string The subject of the message.
|
69 |
-
* - message string The plain-text content of the message.
|
70 |
-
* - read boolean Whether or not this message has been marked as read.
|
71 |
-
* - timestamp string Date the message was either sent or received.
|
72 |
-
*/
|
73 |
-
public function reply($conversation_id, $message) {
|
74 |
-
$_params = array("conversation_id" => $conversation_id, "message" => $message);
|
75 |
-
return $this->master->call('conversations/reply', $_params);
|
76 |
-
}
|
77 |
-
|
78 |
-
}
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Ecomm.php
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Ecomm {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Import Ecommerce Order Information to be used for Segmentation. This will generally be used by ecommerce package plugins
|
10 |
-
<a href="http://connect.mailchimp.com/category/ecommerce" target="_blank">provided by us or by 3rd part system developers</a>.
|
11 |
-
* @param associative_array $order
|
12 |
-
* - id string the Order Id
|
13 |
-
* - campaign_id string optional the Campaign Id to track this order against (see the "mc_cid" query string variable a campaign passes)
|
14 |
-
* - email_id string optional (kind of) the Email Id of the subscriber we should attach this order to (see the "mc_eid" query string variable a campaign passes) - required if campaign_id is passed, otherwise either this or <strong>email</strong> is required. If both are provided, email_id takes precedence
|
15 |
-
* - email string optional (kind of) the Email Address we should attach this order to - either this or <strong>email_id</strong> is required. If both are provided, email_id takes precedence
|
16 |
-
* - total double The Order Total (ie, the full amount the customer ends up paying)
|
17 |
-
* - order_date string optional the date of the order - if this is not provided, we will default the date to now. Should be in the format of 2012-12-30
|
18 |
-
* - shipping double optional the total paid for Shipping Fees
|
19 |
-
* - tax double optional the total tax paid
|
20 |
-
* - store_id string a unique id for the store sending the order in (32 bytes max)
|
21 |
-
* - store_name string optional a "nice" name for the store - typically the base web address (ie, "store.mailchimp.com"). We will automatically update this if it changes (based on store_id)
|
22 |
-
* - items array structs for each individual line item including:
|
23 |
-
* - line_num int optional the line number of the item on the order. We will generate these if they are not passed
|
24 |
-
* - product_id int the store's internal Id for the product. Lines that do no contain this will be skipped
|
25 |
-
* - sku string optional the store's internal SKU for the product. (max 30 bytes)
|
26 |
-
* - product_name string the product name for the product_id associated with this item. We will auto update these as they change (based on product_id)
|
27 |
-
* - category_id int (required) the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario
|
28 |
-
* - category_name string (required) the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc.
|
29 |
-
* - qty double optional the quantity of the item ordered - defaults to 1
|
30 |
-
* - cost double optional the cost of a single item (ie, not the extended cost of the line) - defaults to 0
|
31 |
-
* @return associative_array with a single entry:
|
32 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
33 |
-
*/
|
34 |
-
public function orderAdd($order) {
|
35 |
-
$_params = array("order" => $order);
|
36 |
-
return $this->master->call('ecomm/order-add', $_params);
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Delete Ecommerce Order Information used for segmentation. This will generally be used by ecommerce package plugins
|
41 |
-
<a href="/plugins/ecomm360.phtml">that we provide</a> or by 3rd part system developers.
|
42 |
-
* @param string $store_id
|
43 |
-
* @param string $order_id
|
44 |
-
* @return associative_array with a single entry:
|
45 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
46 |
-
*/
|
47 |
-
public function orderDel($store_id, $order_id) {
|
48 |
-
$_params = array("store_id" => $store_id, "order_id" => $order_id);
|
49 |
-
return $this->master->call('ecomm/order-del', $_params);
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Retrieve the Ecommerce Orders for an account
|
54 |
-
* @param string $cid
|
55 |
-
* @param int $start
|
56 |
-
* @param int $limit
|
57 |
-
* @param string $since
|
58 |
-
* @return associative_array the total matching orders and the specific orders for the requested page
|
59 |
-
* - total int the total matching orders
|
60 |
-
* - data array structs for each order being returned
|
61 |
-
* - store_id string the store id generated by the plugin used to uniquely identify a store
|
62 |
-
* - store_name string the store name collected by the plugin - often the domain name
|
63 |
-
* - order_id string the internal order id the store tracked this order by
|
64 |
-
* - email string the email address that received this campaign and is associated with this order
|
65 |
-
* - order_total double the order total
|
66 |
-
* - tax_total double the total tax for the order (if collected)
|
67 |
-
* - ship_total double the shipping total for the order (if collected)
|
68 |
-
* - order_date string the date the order was tracked - from the store if possible, otherwise the GMT time we received it
|
69 |
-
* - items array structs for each line item on this order.:
|
70 |
-
* - line_num int the line number
|
71 |
-
* - product_id int the product id
|
72 |
-
* - product_name string the product name
|
73 |
-
* - product_sku string the sku for the product
|
74 |
-
* - product_category_id int the category id for the product
|
75 |
-
* - product_category_name string the category name for the product
|
76 |
-
* - qty int the quantity ordered
|
77 |
-
* - cost double the cost of the item
|
78 |
-
*/
|
79 |
-
public function orders($cid=null, $start=0, $limit=100, $since=null) {
|
80 |
-
$_params = array("cid" => $cid, "start" => $start, "limit" => $limit, "since" => $since);
|
81 |
-
return $this->master->call('ecomm/orders', $_params);
|
82 |
-
}
|
83 |
-
|
84 |
-
}
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Exceptions.php
DELETED
@@ -1,471 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Error extends Exception {}
|
4 |
-
class Mailchimp_HttpError extends Mailchimp_Error {}
|
5 |
-
|
6 |
-
/**
|
7 |
-
* The parameters passed to the API call are invalid or not provided when required
|
8 |
-
*/
|
9 |
-
class Mailchimp_ValidationError extends Mailchimp_Error {}
|
10 |
-
|
11 |
-
/**
|
12 |
-
* None
|
13 |
-
*/
|
14 |
-
class Mailchimp_ServerError_MethodUnknown extends Mailchimp_Error {}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* None
|
18 |
-
*/
|
19 |
-
class Mailchimp_ServerError_InvalidParameters extends Mailchimp_Error {}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* None
|
23 |
-
*/
|
24 |
-
class Mailchimp_Unknown_Exception extends Mailchimp_Error {}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* None
|
28 |
-
*/
|
29 |
-
class Mailchimp_Request_TimedOut extends Mailchimp_Error {}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* None
|
33 |
-
*/
|
34 |
-
class Mailchimp_Zend_Uri_Exception extends Mailchimp_Error {}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* None
|
38 |
-
*/
|
39 |
-
class Mailchimp_PDOException extends Mailchimp_Error {}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* None
|
43 |
-
*/
|
44 |
-
class Mailchimp_Avesta_Db_Exception extends Mailchimp_Error {}
|
45 |
-
|
46 |
-
/**
|
47 |
-
* None
|
48 |
-
*/
|
49 |
-
class Mailchimp_XML_RPC2_Exception extends Mailchimp_Error {}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* None
|
53 |
-
*/
|
54 |
-
class Mailchimp_XML_RPC2_FaultException extends Mailchimp_Error {}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* None
|
58 |
-
*/
|
59 |
-
class Mailchimp_Too_Many_Connections extends Mailchimp_Error {}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* None
|
63 |
-
*/
|
64 |
-
class Mailchimp_Parse_Exception extends Mailchimp_Error {}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* None
|
68 |
-
*/
|
69 |
-
class Mailchimp_User_Unknown extends Mailchimp_Error {}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* None
|
73 |
-
*/
|
74 |
-
class Mailchimp_User_Disabled extends Mailchimp_Error {}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* None
|
78 |
-
*/
|
79 |
-
class Mailchimp_User_DoesNotExist extends Mailchimp_Error {}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* None
|
83 |
-
*/
|
84 |
-
class Mailchimp_User_NotApproved extends Mailchimp_Error {}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* None
|
88 |
-
*/
|
89 |
-
class Mailchimp_Invalid_ApiKey extends Mailchimp_Error {}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* None
|
93 |
-
*/
|
94 |
-
class Mailchimp_User_UnderMaintenance extends Mailchimp_Error {}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* None
|
98 |
-
*/
|
99 |
-
class Mailchimp_Invalid_AppKey extends Mailchimp_Error {}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* None
|
103 |
-
*/
|
104 |
-
class Mailchimp_Invalid_IP extends Mailchimp_Error {}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* None
|
108 |
-
*/
|
109 |
-
class Mailchimp_User_DoesExist extends Mailchimp_Error {}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* None
|
113 |
-
*/
|
114 |
-
class Mailchimp_User_InvalidRole extends Mailchimp_Error {}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* None
|
118 |
-
*/
|
119 |
-
class Mailchimp_User_InvalidAction extends Mailchimp_Error {}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* None
|
123 |
-
*/
|
124 |
-
class Mailchimp_User_MissingEmail extends Mailchimp_Error {}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* None
|
128 |
-
*/
|
129 |
-
class Mailchimp_User_CannotSendCampaign extends Mailchimp_Error {}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* None
|
133 |
-
*/
|
134 |
-
class Mailchimp_User_MissingModuleOutbox extends Mailchimp_Error {}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* None
|
138 |
-
*/
|
139 |
-
class Mailchimp_User_ModuleAlreadyPurchased extends Mailchimp_Error {}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* None
|
143 |
-
*/
|
144 |
-
class Mailchimp_User_ModuleNotPurchased extends Mailchimp_Error {}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* None
|
148 |
-
*/
|
149 |
-
class Mailchimp_User_NotEnoughCredit extends Mailchimp_Error {}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* None
|
153 |
-
*/
|
154 |
-
class Mailchimp_MC_InvalidPayment extends Mailchimp_Error {}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* None
|
158 |
-
*/
|
159 |
-
class Mailchimp_List_DoesNotExist extends Mailchimp_Error {}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* None
|
163 |
-
*/
|
164 |
-
class Mailchimp_List_InvalidInterestFieldType extends Mailchimp_Error {}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* None
|
168 |
-
*/
|
169 |
-
class Mailchimp_List_InvalidOption extends Mailchimp_Error {}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* None
|
173 |
-
*/
|
174 |
-
class Mailchimp_List_InvalidUnsubMember extends Mailchimp_Error {}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* None
|
178 |
-
*/
|
179 |
-
class Mailchimp_List_InvalidBounceMember extends Mailchimp_Error {}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* None
|
183 |
-
*/
|
184 |
-
class Mailchimp_List_AlreadySubscribed extends Mailchimp_Error {}
|
185 |
-
|
186 |
-
/**
|
187 |
-
* None
|
188 |
-
*/
|
189 |
-
class Mailchimp_List_NotSubscribed extends Mailchimp_Error {}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* None
|
193 |
-
*/
|
194 |
-
class Mailchimp_List_InvalidImport extends Mailchimp_Error {}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* None
|
198 |
-
*/
|
199 |
-
class Mailchimp_MC_PastedList_Duplicate extends Mailchimp_Error {}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* None
|
203 |
-
*/
|
204 |
-
class Mailchimp_MC_PastedList_InvalidImport extends Mailchimp_Error {}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* None
|
208 |
-
*/
|
209 |
-
class Mailchimp_Email_AlreadySubscribed extends Mailchimp_Error {}
|
210 |
-
|
211 |
-
/**
|
212 |
-
* None
|
213 |
-
*/
|
214 |
-
class Mailchimp_Email_AlreadyUnsubscribed extends Mailchimp_Error {}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* None
|
218 |
-
*/
|
219 |
-
class Mailchimp_Email_NotExists extends Mailchimp_Error {}
|
220 |
-
|
221 |
-
/**
|
222 |
-
* None
|
223 |
-
*/
|
224 |
-
class Mailchimp_Email_NotSubscribed extends Mailchimp_Error {}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* None
|
228 |
-
*/
|
229 |
-
class Mailchimp_List_MergeFieldRequired extends Mailchimp_Error {}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* None
|
233 |
-
*/
|
234 |
-
class Mailchimp_List_CannotRemoveEmailMerge extends Mailchimp_Error {}
|
235 |
-
|
236 |
-
/**
|
237 |
-
* None
|
238 |
-
*/
|
239 |
-
class Mailchimp_List_Merge_InvalidMergeID extends Mailchimp_Error {}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* None
|
243 |
-
*/
|
244 |
-
class Mailchimp_List_TooManyMergeFields extends Mailchimp_Error {}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* None
|
248 |
-
*/
|
249 |
-
class Mailchimp_List_InvalidMergeField extends Mailchimp_Error {}
|
250 |
-
|
251 |
-
/**
|
252 |
-
* None
|
253 |
-
*/
|
254 |
-
class Mailchimp_List_InvalidInterestGroup extends Mailchimp_Error {}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* None
|
258 |
-
*/
|
259 |
-
class Mailchimp_List_TooManyInterestGroups extends Mailchimp_Error {}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* None
|
263 |
-
*/
|
264 |
-
class Mailchimp_Campaign_DoesNotExist extends Mailchimp_Error {}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* None
|
268 |
-
*/
|
269 |
-
class Mailchimp_Campaign_StatsNotAvailable extends Mailchimp_Error {}
|
270 |
-
|
271 |
-
/**
|
272 |
-
* None
|
273 |
-
*/
|
274 |
-
class Mailchimp_Campaign_InvalidAbsplit extends Mailchimp_Error {}
|
275 |
-
|
276 |
-
/**
|
277 |
-
* None
|
278 |
-
*/
|
279 |
-
class Mailchimp_Campaign_InvalidContent extends Mailchimp_Error {}
|
280 |
-
|
281 |
-
/**
|
282 |
-
* None
|
283 |
-
*/
|
284 |
-
class Mailchimp_Campaign_InvalidOption extends Mailchimp_Error {}
|
285 |
-
|
286 |
-
/**
|
287 |
-
* None
|
288 |
-
*/
|
289 |
-
class Mailchimp_Campaign_InvalidStatus extends Mailchimp_Error {}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* None
|
293 |
-
*/
|
294 |
-
class Mailchimp_Campaign_NotSaved extends Mailchimp_Error {}
|
295 |
-
|
296 |
-
/**
|
297 |
-
* None
|
298 |
-
*/
|
299 |
-
class Mailchimp_Campaign_InvalidSegment extends Mailchimp_Error {}
|
300 |
-
|
301 |
-
/**
|
302 |
-
* None
|
303 |
-
*/
|
304 |
-
class Mailchimp_Campaign_InvalidRss extends Mailchimp_Error {}
|
305 |
-
|
306 |
-
/**
|
307 |
-
* None
|
308 |
-
*/
|
309 |
-
class Mailchimp_Campaign_InvalidAuto extends Mailchimp_Error {}
|
310 |
-
|
311 |
-
/**
|
312 |
-
* None
|
313 |
-
*/
|
314 |
-
class Mailchimp_MC_ContentImport_InvalidArchive extends Mailchimp_Error {}
|
315 |
-
|
316 |
-
/**
|
317 |
-
* None
|
318 |
-
*/
|
319 |
-
class Mailchimp_Campaign_BounceMissing extends Mailchimp_Error {}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* None
|
323 |
-
*/
|
324 |
-
class Mailchimp_Campaign_InvalidTemplate extends Mailchimp_Error {}
|
325 |
-
|
326 |
-
/**
|
327 |
-
* None
|
328 |
-
*/
|
329 |
-
class Mailchimp_Invalid_EcommOrder extends Mailchimp_Error {}
|
330 |
-
|
331 |
-
/**
|
332 |
-
* None
|
333 |
-
*/
|
334 |
-
class Mailchimp_Absplit_UnknownError extends Mailchimp_Error {}
|
335 |
-
|
336 |
-
/**
|
337 |
-
* None
|
338 |
-
*/
|
339 |
-
class Mailchimp_Absplit_UnknownSplitTest extends Mailchimp_Error {}
|
340 |
-
|
341 |
-
/**
|
342 |
-
* None
|
343 |
-
*/
|
344 |
-
class Mailchimp_Absplit_UnknownTestType extends Mailchimp_Error {}
|
345 |
-
|
346 |
-
/**
|
347 |
-
* None
|
348 |
-
*/
|
349 |
-
class Mailchimp_Absplit_UnknownWaitUnit extends Mailchimp_Error {}
|
350 |
-
|
351 |
-
/**
|
352 |
-
* None
|
353 |
-
*/
|
354 |
-
class Mailchimp_Absplit_UnknownWinnerType extends Mailchimp_Error {}
|
355 |
-
|
356 |
-
/**
|
357 |
-
* None
|
358 |
-
*/
|
359 |
-
class Mailchimp_Absplit_WinnerNotSelected extends Mailchimp_Error {}
|
360 |
-
|
361 |
-
/**
|
362 |
-
* None
|
363 |
-
*/
|
364 |
-
class Mailchimp_Invalid_Analytics extends Mailchimp_Error {}
|
365 |
-
|
366 |
-
/**
|
367 |
-
* None
|
368 |
-
*/
|
369 |
-
class Mailchimp_Invalid_DateTime extends Mailchimp_Error {}
|
370 |
-
|
371 |
-
/**
|
372 |
-
* None
|
373 |
-
*/
|
374 |
-
class Mailchimp_Invalid_Email extends Mailchimp_Error {}
|
375 |
-
|
376 |
-
/**
|
377 |
-
* None
|
378 |
-
*/
|
379 |
-
class Mailchimp_Invalid_SendType extends Mailchimp_Error {}
|
380 |
-
|
381 |
-
/**
|
382 |
-
* None
|
383 |
-
*/
|
384 |
-
class Mailchimp_Invalid_Template extends Mailchimp_Error {}
|
385 |
-
|
386 |
-
/**
|
387 |
-
* None
|
388 |
-
*/
|
389 |
-
class Mailchimp_Invalid_TrackingOptions extends Mailchimp_Error {}
|
390 |
-
|
391 |
-
/**
|
392 |
-
* None
|
393 |
-
*/
|
394 |
-
class Mailchimp_Invalid_Options extends Mailchimp_Error {}
|
395 |
-
|
396 |
-
/**
|
397 |
-
* None
|
398 |
-
*/
|
399 |
-
class Mailchimp_Invalid_Folder extends Mailchimp_Error {}
|
400 |
-
|
401 |
-
/**
|
402 |
-
* None
|
403 |
-
*/
|
404 |
-
class Mailchimp_Invalid_URL extends Mailchimp_Error {}
|
405 |
-
|
406 |
-
/**
|
407 |
-
* None
|
408 |
-
*/
|
409 |
-
class Mailchimp_Module_Unknown extends Mailchimp_Error {}
|
410 |
-
|
411 |
-
/**
|
412 |
-
* None
|
413 |
-
*/
|
414 |
-
class Mailchimp_MonthlyPlan_Unknown extends Mailchimp_Error {}
|
415 |
-
|
416 |
-
/**
|
417 |
-
* None
|
418 |
-
*/
|
419 |
-
class Mailchimp_Order_TypeUnknown extends Mailchimp_Error {}
|
420 |
-
|
421 |
-
/**
|
422 |
-
* None
|
423 |
-
*/
|
424 |
-
class Mailchimp_Invalid_PagingLimit extends Mailchimp_Error {}
|
425 |
-
|
426 |
-
/**
|
427 |
-
* None
|
428 |
-
*/
|
429 |
-
class Mailchimp_Invalid_PagingStart extends Mailchimp_Error {}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* None
|
433 |
-
*/
|
434 |
-
class Mailchimp_Max_Size_Reached extends Mailchimp_Error {}
|
435 |
-
|
436 |
-
/**
|
437 |
-
* None
|
438 |
-
*/
|
439 |
-
class Mailchimp_MC_SearchException extends Mailchimp_Error {}
|
440 |
-
|
441 |
-
/**
|
442 |
-
* None
|
443 |
-
*/
|
444 |
-
class Mailchimp_Goal_SaveFailed extends Mailchimp_Error {}
|
445 |
-
|
446 |
-
/**
|
447 |
-
* None
|
448 |
-
*/
|
449 |
-
class Mailchimp_Conversation_DoesNotExist extends Mailchimp_Error {}
|
450 |
-
|
451 |
-
/**
|
452 |
-
* None
|
453 |
-
*/
|
454 |
-
class Mailchimp_Conversation_ReplySaveFailed extends Mailchimp_Error {}
|
455 |
-
|
456 |
-
/**
|
457 |
-
* None
|
458 |
-
*/
|
459 |
-
class Mailchimp_File_Not_Found_Exception extends Mailchimp_Error {}
|
460 |
-
|
461 |
-
/**
|
462 |
-
* None
|
463 |
-
*/
|
464 |
-
class Mailchimp_Folder_Not_Found_Exception extends Mailchimp_Error {}
|
465 |
-
|
466 |
-
/**
|
467 |
-
* None
|
468 |
-
*/
|
469 |
-
class Mailchimp_Folder_Exists_Exception extends Mailchimp_Error {}
|
470 |
-
|
471 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Folders.php
DELETED
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Folders {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Add a new folder to file campaigns, autoresponders, or templates in
|
10 |
-
* @param string $name
|
11 |
-
* @param string $type
|
12 |
-
* @return associative_array with a single value:
|
13 |
-
* - folder_id int the folder_id of the newly created folder.
|
14 |
-
*/
|
15 |
-
public function add($name, $type) {
|
16 |
-
$_params = array("name" => $name, "type" => $type);
|
17 |
-
return $this->master->call('folders/add', $_params);
|
18 |
-
}
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Delete a campaign, autoresponder, or template folder. Note that this will simply make whatever was in the folder appear unfiled, no other data is removed
|
22 |
-
* @param int $fid
|
23 |
-
* @param string $type
|
24 |
-
* @return associative_array with a single entry:
|
25 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
26 |
-
*/
|
27 |
-
public function del($fid, $type) {
|
28 |
-
$_params = array("fid" => $fid, "type" => $type);
|
29 |
-
return $this->master->call('folders/del', $_params);
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* List all the folders of a certain type
|
34 |
-
* @param string $type
|
35 |
-
* @return array structs for each folder, including:
|
36 |
-
* - folder_id int Folder Id for the given folder, this can be used in the campaigns/list() function to filter on.
|
37 |
-
* - name string Name of the given folder
|
38 |
-
* - date_created string The date/time the folder was created
|
39 |
-
* - type string The type of the folders being returned, just to make sure you know.
|
40 |
-
* - cnt int number of items in the folder.
|
41 |
-
*/
|
42 |
-
public function getList($type) {
|
43 |
-
$_params = array("type" => $type);
|
44 |
-
return $this->master->call('folders/list', $_params);
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Update the name of a folder for campaigns, autoresponders, or templates
|
49 |
-
* @param int $fid
|
50 |
-
* @param string $name
|
51 |
-
* @param string $type
|
52 |
-
* @return associative_array with a single entry:
|
53 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
54 |
-
*/
|
55 |
-
public function update($fid, $name, $type) {
|
56 |
-
$_params = array("fid" => $fid, "name" => $name, "type" => $type);
|
57 |
-
return $this->master->call('folders/update', $_params);
|
58 |
-
}
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Gallery.php
DELETED
@@ -1,106 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Gallery {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Return a section of the image gallery
|
10 |
-
* @param associative_array $opts
|
11 |
-
* - type string optional the gallery type to return - images or files - default to images
|
12 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
13 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
14 |
-
* - sort_by string optional field to sort by - one of size, time, name - defaults to time
|
15 |
-
* - sort_dir string optional field to sort by - one of asc, desc - defaults to desc
|
16 |
-
* - search_term string optional a term to search for in names
|
17 |
-
* - folder_id int optional to return files that are in a specific folder. id returned by the list-folders call
|
18 |
-
* @return associative_array the matching gallery items
|
19 |
-
* - total int the total matching items
|
20 |
-
* - data array structs for each item included in the set, including:
|
21 |
-
* - id int the id of the file
|
22 |
-
* - name string the file name
|
23 |
-
* - time string the creation date for the item
|
24 |
-
* - size int the file size in bytes
|
25 |
-
* - full string the url to the actual item in the gallery
|
26 |
-
* - thumb string a url for a thumbnail that can be used to represent the item, generally an image thumbnail or an icon for a file type
|
27 |
-
*/
|
28 |
-
public function getList($opts=array()) {
|
29 |
-
$_params = array("opts" => $opts);
|
30 |
-
return $this->master->call('gallery/list', $_params);
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Return a list of the folders available to the file gallery
|
35 |
-
* @param associative_array $opts
|
36 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
37 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
38 |
-
* - search_term string optional a term to search for in names
|
39 |
-
* @return associative_array the matching gallery folders
|
40 |
-
* - total int the total matching folders
|
41 |
-
* - data array structs for each folder included in the set, including:
|
42 |
-
* - id int the id of the folder
|
43 |
-
* - name string the file name
|
44 |
-
* - file_count int the number of files in the folder
|
45 |
-
*/
|
46 |
-
public function listFolders($opts=array()) {
|
47 |
-
$_params = array("opts" => $opts);
|
48 |
-
return $this->master->call('gallery/list-folders', $_params);
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Adds a folder to the file gallery
|
53 |
-
* @param string $name
|
54 |
-
* @return associative_array the new data for the created folder
|
55 |
-
* - data.id int the id of the new folder
|
56 |
-
*/
|
57 |
-
public function addFolder($name) {
|
58 |
-
$_params = array("name" => $name);
|
59 |
-
return $this->master->call('gallery/add-folder', $_params);
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Remove a folder
|
64 |
-
* @param int $folder_id
|
65 |
-
* @return boolean true/false for success/failure
|
66 |
-
*/
|
67 |
-
public function removeFolder($folder_id) {
|
68 |
-
$_params = array("folder_id" => $folder_id);
|
69 |
-
return $this->master->call('gallery/remove-folder', $_params);
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Add a file to a folder
|
74 |
-
* @param int $file_id
|
75 |
-
* @param int $folder_id
|
76 |
-
* @return boolean true/false for success/failure
|
77 |
-
*/
|
78 |
-
public function addFileToFolder($file_id, $folder_id) {
|
79 |
-
$_params = array("file_id" => $file_id, "folder_id" => $folder_id);
|
80 |
-
return $this->master->call('gallery/add-file-to-folder', $_params);
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Remove a file from a folder
|
85 |
-
* @param int $file_id
|
86 |
-
* @param int $folder_id
|
87 |
-
* @return boolean true/false for success/failure
|
88 |
-
*/
|
89 |
-
public function removeFileFromFolder($file_id, $folder_id) {
|
90 |
-
$_params = array("file_id" => $file_id, "folder_id" => $folder_id);
|
91 |
-
return $this->master->call('gallery/remove-file-from-folder', $_params);
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Remove all files from a folder (Note that the files are not deleted, they are only removed from the folder)
|
96 |
-
* @param int $folder_id
|
97 |
-
* @return boolean true/false for success/failure
|
98 |
-
*/
|
99 |
-
public function removeAllFilesFromFolder($folder_id) {
|
100 |
-
$_params = array("folder_id" => $folder_id);
|
101 |
-
return $this->master->call('gallery/remove-all-files-from-folder', $_params);
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Goal.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Goal {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Retrieve goal event data for a particular list member. Note: only unique events are returned. If a user triggers
|
10 |
-
a particular event multiple times, you will still only receive one entry for that event.
|
11 |
-
* @param string $list_id
|
12 |
-
* @param associative_array $email
|
13 |
-
* - email string an email address
|
14 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
15 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
16 |
-
* @param int $start
|
17 |
-
* @param int $limit
|
18 |
-
* @return associative_array Event data and metadata
|
19 |
-
* - data array An array of goal data structs for the specified list member in the following format
|
20 |
-
* - event string The URL or name of the event that was triggered
|
21 |
-
* - last_visited_at string A timestamp in the format 'YYYY-MM-DD HH:MM:SS' that represents the last time this event was seen.
|
22 |
-
* - total int The total number of events that match your criteria.
|
23 |
-
*/
|
24 |
-
public function events($list_id, $email, $start=0, $limit=25) {
|
25 |
-
$_params = array("list_id" => $list_id, "email" => $email, "start" => $start, "limit" => $limit);
|
26 |
-
return $this->master->call('goal/events', $_params);
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* This allows programmatically trigger goal event collection without the use of front-end code.
|
31 |
-
* @param string $list_id
|
32 |
-
* @param associative_array $email
|
33 |
-
* - email string an email address
|
34 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
35 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
36 |
-
* @param string $campaign_id
|
37 |
-
* @param string $event
|
38 |
-
* @return associative_array Event data for the submitted event
|
39 |
-
* - event string The URL or name of the event that was triggered
|
40 |
-
* - last_visited_at string A timestamp in the format 'YYYY-MM-DD HH:MM:SS' that represents the last time this event was seen.
|
41 |
-
*/
|
42 |
-
public function recordEvent($list_id, $email, $campaign_id, $event) {
|
43 |
-
$_params = array("list_id" => $list_id, "email" => $email, "campaign_id" => $campaign_id, "event" => $event);
|
44 |
-
return $this->master->call('goal/record-event', $_params);
|
45 |
-
}
|
46 |
-
|
47 |
-
}
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Helper.php
DELETED
@@ -1,237 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Helper {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Retrieve lots of account information including payments made, plan info, some account stats, installed modules,
|
10 |
-
contact info, and more. No private information like Credit Card numbers is available.
|
11 |
-
* @param array $exclude
|
12 |
-
* @return associative_array containing the details for the account tied to this API Key
|
13 |
-
* - username string The company name associated with the account
|
14 |
-
* - user_id string The Account user unique id (for building some links)
|
15 |
-
* - is_trial bool Whether the Account is in Trial mode (can only send campaigns to less than 100 emails)
|
16 |
-
* - is_approved bool Whether the Account has been approved for purchases
|
17 |
-
* - has_activated bool Whether the Account has been activated
|
18 |
-
* - timezone string The timezone for the Account - default is "US/Eastern"
|
19 |
-
* - plan_type string Plan Type - "monthly", "payasyougo", or "free"
|
20 |
-
* - plan_low int <em>only for Monthly plans</em> - the lower tier for list size
|
21 |
-
* - plan_high int <em>only for Monthly plans</em> - the upper tier for list size
|
22 |
-
* - plan_start_date string <em>only for Monthly plans</em> - the start date for a monthly plan
|
23 |
-
* - emails_left int <em>only for Free and Pay-as-you-go plans</em> emails credits left for the account
|
24 |
-
* - pending_monthly bool Whether the account is finishing Pay As You Go credits before switching to a Monthly plan
|
25 |
-
* - first_payment string date of first payment
|
26 |
-
* - last_payment string date of most recent payment
|
27 |
-
* - times_logged_in int total number of times the account has been logged into via the web
|
28 |
-
* - last_login string date/time of last login via the web
|
29 |
-
* - affiliate_link string Monkey Rewards link for our Affiliate program
|
30 |
-
* - industry string the user's selected industry
|
31 |
-
* - contact associative_array Contact details for the account
|
32 |
-
* - fname string First Name
|
33 |
-
* - lname string Last Name
|
34 |
-
* - email string Email Address
|
35 |
-
* - company string Company Name
|
36 |
-
* - address1 string Address Line 1
|
37 |
-
* - address2 string Address Line 2
|
38 |
-
* - city string City
|
39 |
-
* - state string State or Province
|
40 |
-
* - zip string Zip or Postal Code
|
41 |
-
* - country string Country name
|
42 |
-
* - url string Website URL
|
43 |
-
* - phone string Phone number
|
44 |
-
* - fax string Fax number
|
45 |
-
* - modules array a struct for each addon module installed in the account
|
46 |
-
* - id string An internal module id
|
47 |
-
* - name string The module name
|
48 |
-
* - added string The date the module was added
|
49 |
-
* - data associative_array Any extra data associated with this module as key=>value pairs
|
50 |
-
* - orders array a struct for each order for the account
|
51 |
-
* - order_id int The order id
|
52 |
-
* - type string The order type - either "monthly" or "credits"
|
53 |
-
* - amount double The order amount
|
54 |
-
* - date string The order date
|
55 |
-
* - credits_used double The total credits used
|
56 |
-
* - rewards associative_array Rewards details for the account including credits & inspections earned, number of referrals, referral details, and rewards used
|
57 |
-
* - referrals_this_month int the total number of referrals this month
|
58 |
-
* - notify_on string whether or not we notify the user when rewards are earned
|
59 |
-
* - notify_email string the email address address used for rewards notifications
|
60 |
-
* - credits associative_array Email credits earned:
|
61 |
-
* - this_month int credits earned this month
|
62 |
-
* - total_earned int credits earned all time
|
63 |
-
* - remaining int credits remaining
|
64 |
-
* - inspections associative_array Inbox Inspections earned:
|
65 |
-
* - this_month int credits earned this month
|
66 |
-
* - total_earned int credits earned all time
|
67 |
-
* - remaining int credits remaining
|
68 |
-
* - referrals array a struct for each referral, including:
|
69 |
-
* - name string the name of the account
|
70 |
-
* - email string the email address associated with the account
|
71 |
-
* - signup_date string the signup date for the account
|
72 |
-
* - type string the source for the referral
|
73 |
-
* - applied array a struct for each applied rewards, including:
|
74 |
-
* - value int the number of credits user
|
75 |
-
* - date string the date applied
|
76 |
-
* - order_id int the order number credits were applied to
|
77 |
-
* - order_desc string the order description
|
78 |
-
* - integrations array a struct for each connected integrations that can be used with campaigns, including:
|
79 |
-
* - id int an internal id for the integration
|
80 |
-
* - name string the integration name
|
81 |
-
* - list_id string either "_any_" when globally accessible or the list id it's valid for use against
|
82 |
-
* - user_id string if applicable, the user id for the integrated system
|
83 |
-
* - account string if applicable, the user/account name for the integrated system
|
84 |
-
* - profiles array For Facebook, users/page that can be posted to.
|
85 |
-
* - id string the user or page id
|
86 |
-
* - name string the user or page name
|
87 |
-
* - is_page bool whether this is a user or a page
|
88 |
-
*/
|
89 |
-
public function accountDetails($exclude=array()) {
|
90 |
-
$_params = array("exclude" => $exclude);
|
91 |
-
return $this->master->call('helper/account-details', $_params);
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Retrieve minimal data for all Campaigns a member was sent
|
96 |
-
* @param associative_array $email
|
97 |
-
* - email string an email address
|
98 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
99 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
100 |
-
* @param associative_array $options
|
101 |
-
* - list_id string optional A list_id to limit the campaigns to
|
102 |
-
* @return array an array of structs containing campaign data for each matching campaign (ordered by send time ascending), including:
|
103 |
-
* - id string the campaign unique id
|
104 |
-
* - title string the campaign's title
|
105 |
-
* - subject string the campaign's subject
|
106 |
-
* - send_time string the time the campaign was sent
|
107 |
-
* - type string the campaign type
|
108 |
-
*/
|
109 |
-
public function campaignsForEmail($email, $options=null) {
|
110 |
-
$_params = array("email" => $email, "options" => $options);
|
111 |
-
return $this->master->call('helper/campaigns-for-email', $_params);
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Return the current Chimp Chatter messages for an account.
|
116 |
-
* @return array An array of structs containing data for each chatter message
|
117 |
-
* - message string The chatter message
|
118 |
-
* - type string The type of the message - one of lists:new-subscriber, lists:unsubscribes, lists:profile-updates, campaigns:facebook-likes, campaigns:facebook-comments, campaigns:forward-to-friend, lists:imports, or campaigns:inbox-inspections
|
119 |
-
* - url string a url into the web app that the message could link to, if applicable
|
120 |
-
* - list_id string the list_id a message relates to, if applicable. Deleted lists will return -DELETED-
|
121 |
-
* - campaign_id string the list_id a message relates to, if applicable. Deleted campaigns will return -DELETED-
|
122 |
-
* - update_time string The date/time the message was last updated
|
123 |
-
*/
|
124 |
-
public function chimpChatter() {
|
125 |
-
$_params = array();
|
126 |
-
return $this->master->call('helper/chimp-chatter', $_params);
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Have HTML content auto-converted to a text-only format. You can send: plain HTML, an existing Campaign Id, or an existing Template Id. Note that this will <strong>not</strong> save anything to or update any of your lists, campaigns, or templates.
|
131 |
-
It's also not just Lynx and is very fine tuned for our template layouts - your mileage may vary.
|
132 |
-
* @param string $type
|
133 |
-
* @param associative_array $content
|
134 |
-
* - html string optional a single string value,
|
135 |
-
* - cid string a valid Campaign Id
|
136 |
-
* - user_template_id string the id of a user template
|
137 |
-
* - base_template_id string the id of a built in base/basic template
|
138 |
-
* - gallery_template_id string the id of a built in gallery template
|
139 |
-
* - url string a valid & public URL to pull html content from
|
140 |
-
* @return associative_array the content pass in converted to text.
|
141 |
-
* - text string the converted html
|
142 |
-
*/
|
143 |
-
public function generateText($type, $content) {
|
144 |
-
$_params = array("type" => $type, "content" => $content);
|
145 |
-
return $this->master->call('helper/generate-text', $_params);
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
* Send your HTML content to have the CSS inlined and optionally remove the original styles.
|
150 |
-
* @param string $html
|
151 |
-
* @param bool $strip_css
|
152 |
-
* @return associative_array with a "html" key
|
153 |
-
* - html string Your HTML content with all CSS inlined, just like if we sent it.
|
154 |
-
*/
|
155 |
-
public function inlineCss($html, $strip_css=false) {
|
156 |
-
$_params = array("html" => $html, "strip_css" => $strip_css);
|
157 |
-
return $this->master->call('helper/inline-css', $_params);
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Retrieve minimal List data for all lists a member is subscribed to.
|
162 |
-
* @param associative_array $email
|
163 |
-
* - email string an email address
|
164 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
165 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
166 |
-
* @return array An array of structs with info on the list_id the member is subscribed to.
|
167 |
-
* - id string the list unique id
|
168 |
-
* - web_id int the id referenced in web interface urls
|
169 |
-
* - name string the list name
|
170 |
-
*/
|
171 |
-
public function listsForEmail($email) {
|
172 |
-
$_params = array("email" => $email);
|
173 |
-
return $this->master->call('helper/lists-for-email', $_params);
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* "Ping" the MailChimp API - a simple method you can call that will return a constant value as long as everything is good. Note
|
178 |
-
than unlike most all of our methods, we don't throw an Exception if we are having issues. You will simply receive a different
|
179 |
-
string back that will explain our view on what is going on.
|
180 |
-
* @return associative_array a with a "msg" key
|
181 |
-
* - msg string containing "Everything's Chimpy!" if everything is chimpy, otherwise returns an error message
|
182 |
-
*/
|
183 |
-
public function ping() {
|
184 |
-
$_params = array();
|
185 |
-
return $this->master->call('helper/ping', $_params);
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Search all campaigns for the specified query terms
|
190 |
-
* @param string $query
|
191 |
-
* @param int $offset
|
192 |
-
* @param string $snip_start
|
193 |
-
* @param string $snip_end
|
194 |
-
* @return associative_array containing the total matches and current results
|
195 |
-
* - total int total campaigns matching
|
196 |
-
* - results array matching campaigns and snippets
|
197 |
-
* - snippet string the matching snippet for the campaign
|
198 |
-
* - campaign associative_array the matching campaign's details - will return same data as single campaign from campaigns/list()
|
199 |
-
*/
|
200 |
-
public function searchCampaigns($query, $offset=0, $snip_start=null, $snip_end=null) {
|
201 |
-
$_params = array("query" => $query, "offset" => $offset, "snip_start" => $snip_start, "snip_end" => $snip_end);
|
202 |
-
return $this->master->call('helper/search-campaigns', $_params);
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Search account wide or on a specific list using the specified query terms
|
207 |
-
* @param string $query
|
208 |
-
* @param string $id
|
209 |
-
* @param int $offset
|
210 |
-
* @return associative_array An array of both exact matches and partial matches over a full search
|
211 |
-
* - exact_matches associative_array containing the exact email address matches and current results
|
212 |
-
* - total int total members matching
|
213 |
-
* - members array each entry will be struct matching the data format for a single member as returned by lists/member-info()
|
214 |
-
* - full_search associative_array containing the total matches and current results
|
215 |
-
* - total int total members matching
|
216 |
-
* - members array each entry will be struct matching the data format for a single member as returned by lists/member-info()
|
217 |
-
*/
|
218 |
-
public function searchMembers($query, $id=null, $offset=0) {
|
219 |
-
$_params = array("query" => $query, "id" => $id, "offset" => $offset);
|
220 |
-
return $this->master->call('helper/search-members', $_params);
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* Retrieve all domain verification records for an account
|
225 |
-
* @return array structs for each domain verification has been attempted for
|
226 |
-
* - domain string the verified domain
|
227 |
-
* - status string the status of the verification - either "verified" or "pending"
|
228 |
-
* - email string the email address used for verification - "pre-existing" if we automatically backfilled it at some point
|
229 |
-
*/
|
230 |
-
public function verifiedDomains() {
|
231 |
-
$_params = array();
|
232 |
-
return $this->master->call('helper/verified-domains', $_params);
|
233 |
-
}
|
234 |
-
|
235 |
-
}
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Lists.php
DELETED
@@ -1,904 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Lists {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Get all email addresses that complained about a campaign sent to a list
|
10 |
-
* @param string $id
|
11 |
-
* @param int $start
|
12 |
-
* @param int $limit
|
13 |
-
* @param string $since
|
14 |
-
* @return associative_array the total of all reports and the specific reports reports this page
|
15 |
-
* - total int the total number of matching abuse reports
|
16 |
-
* - data array structs for the actual data for each reports, including:
|
17 |
-
* - date string date+time the abuse report was received and processed
|
18 |
-
* - email string the email address that reported abuse
|
19 |
-
* - campaign_id string the unique id for the campaign that report was made against
|
20 |
-
* - type string an internal type generally specifying the originating mail provider - may not be useful outside of filling report views
|
21 |
-
*/
|
22 |
-
public function abuseReports($id, $start=0, $limit=500, $since=null) {
|
23 |
-
$_params = array("id" => $id, "start" => $start, "limit" => $limit, "since" => $since);
|
24 |
-
return $this->master->call('lists/abuse-reports', $_params);
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Access up to the previous 180 days of daily detailed aggregated activity stats for a given list. Does not include AutoResponder activity.
|
29 |
-
* @param string $id
|
30 |
-
* @return array of structs containing daily values, each containing:
|
31 |
-
*/
|
32 |
-
public function activity($id) {
|
33 |
-
$_params = array("id" => $id);
|
34 |
-
return $this->master->call('lists/activity', $_params);
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Subscribe a batch of email addresses to a list at once. If you are using a serialized version of the API, we strongly suggest that you
|
39 |
-
only run this method as a POST request, and <em>not</em> a GET request. Maximum batch sizes vary based on the amount of data in each record,
|
40 |
-
though you should cap them at 5k - 10k records, depending on your experience. These calls are also long, so be sure you increase your timeout values.
|
41 |
-
* @param string $id
|
42 |
-
* @param array $batch
|
43 |
-
* - email associative_array a struct with one of the following keys - failing to provide anything will produce an error relating to the email address. Provide multiples and we'll use the first we see in this same order.
|
44 |
-
* - email string an email address
|
45 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
46 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
47 |
-
* - email_type string for the email type option (html or text)
|
48 |
-
* - merge_vars associative_array data for the various list specific and special merge vars documented in lists/subscribe
|
49 |
-
* @param boolean $double_optin
|
50 |
-
* @param boolean $update_existing
|
51 |
-
* @param boolean $replace_interests
|
52 |
-
* @return associative_array struct of result counts and associated data
|
53 |
-
* - add_count int Number of email addresses that were successfully added
|
54 |
-
* - adds array array of structs for each add
|
55 |
-
* - email string the email address added
|
56 |
-
* - euid string the email unique id
|
57 |
-
* - leid string the list member's truly unique id
|
58 |
-
* - update_count int Number of email addresses that were successfully updated
|
59 |
-
* - updates array array of structs for each update
|
60 |
-
* - email string the email address added
|
61 |
-
* - euid string the email unique id
|
62 |
-
* - leid string the list member's truly unique id
|
63 |
-
* - error_count int Number of email addresses that failed during addition/updating
|
64 |
-
* - errors array array of error structs including:
|
65 |
-
* - email string whatever was passed in the batch record's email parameter
|
66 |
-
* - email string the email address added
|
67 |
-
* - euid string the email unique id
|
68 |
-
* - leid string the list member's truly unique id
|
69 |
-
* - code int the error code
|
70 |
-
* - error string the full error message
|
71 |
-
* - row associative_array the row from the batch that caused the error
|
72 |
-
*/
|
73 |
-
public function batchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) {
|
74 |
-
$_params = array("id" => $id, "batch" => $batch, "double_optin" => $double_optin, "update_existing" => $update_existing, "replace_interests" => $replace_interests);
|
75 |
-
return $this->master->call('lists/batch-subscribe', $_params);
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Unsubscribe a batch of email addresses from a list
|
80 |
-
* @param string $id
|
81 |
-
* @param array $batch
|
82 |
-
* - email string an email address
|
83 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
84 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
85 |
-
* @param boolean $delete_member
|
86 |
-
* @param boolean $send_goodbye
|
87 |
-
* @param boolean $send_notify
|
88 |
-
* @return array Array of structs containing results and any errors that occurred
|
89 |
-
* - success_count int Number of email addresses that were successfully removed
|
90 |
-
* - error_count int Number of email addresses that failed during addition/updating
|
91 |
-
* - errors array array of error structs including:
|
92 |
-
* - email string whatever was passed in the batch record's email parameter
|
93 |
-
* - email string the email address added
|
94 |
-
* - euid string the email unique id
|
95 |
-
* - leid string the list member's truly unique id
|
96 |
-
* - code int the error code
|
97 |
-
* - error string the full error message
|
98 |
-
*/
|
99 |
-
public function batchUnsubscribe($id, $batch, $delete_member=false, $send_goodbye=true, $send_notify=false) {
|
100 |
-
$_params = array("id" => $id, "batch" => $batch, "delete_member" => $delete_member, "send_goodbye" => $send_goodbye, "send_notify" => $send_notify);
|
101 |
-
return $this->master->call('lists/batch-unsubscribe', $_params);
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Retrieve the clients that the list's subscribers have been tagged as being used based on user agents seen. Made possible by <a href="http://user-agent-string.info" target="_blank">user-agent-string.info</a>
|
106 |
-
* @param string $id
|
107 |
-
* @return associative_array the desktop and mobile user agents in use on the list
|
108 |
-
* - desktop associative_array desktop user agents and percentages
|
109 |
-
* - penetration double the percent of desktop clients in use
|
110 |
-
* - clients array array of structs for each client including:
|
111 |
-
* - client string the common name for the client
|
112 |
-
* - icon string a url to an image representing this client
|
113 |
-
* - percent string percent of list using the client
|
114 |
-
* - members string total members using the client
|
115 |
-
* - mobile associative_array mobile user agents and percentages
|
116 |
-
* - penetration double the percent of mobile clients in use
|
117 |
-
* - clients array array of structs for each client including:
|
118 |
-
* - client string the common name for the client
|
119 |
-
* - icon string a url to an image representing this client
|
120 |
-
* - percent string percent of list using the client
|
121 |
-
* - members string total members using the client
|
122 |
-
*/
|
123 |
-
public function clients($id) {
|
124 |
-
$_params = array("id" => $id);
|
125 |
-
return $this->master->call('lists/clients', $_params);
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Access the Growth History by Month in aggregate or for a given list.
|
130 |
-
* @param string $id
|
131 |
-
* @return array array of structs containing months and growth data
|
132 |
-
* - month string The Year and Month in question using YYYY-MM format
|
133 |
-
* - existing int number of existing subscribers to start the month
|
134 |
-
* - imports int number of subscribers imported during the month
|
135 |
-
* - optins int number of subscribers who opted-in during the month
|
136 |
-
*/
|
137 |
-
public function growthHistory($id=null) {
|
138 |
-
$_params = array("id" => $id);
|
139 |
-
return $this->master->call('lists/growth-history', $_params);
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Get the list of interest groupings for a given list, including the label, form information, and included groups for each
|
144 |
-
* @param string $id
|
145 |
-
* @param bool $counts
|
146 |
-
* @return array array of structs of the interest groupings for the list
|
147 |
-
* - id int The id for the Grouping
|
148 |
-
* - name string Name for the Interest groups
|
149 |
-
* - form_field string Gives the type of interest group: checkbox,radio,select
|
150 |
-
* - groups array Array structs of the grouping options (interest groups) including:
|
151 |
-
* - bit string the bit value - not really anything to be done with this
|
152 |
-
* - name string the name of the group
|
153 |
-
* - display_order string the display order of the group, if set
|
154 |
-
* - subscribers int total number of subscribers who have this group if "counts" is true. otherwise empty
|
155 |
-
*/
|
156 |
-
public function interestGroupings($id, $counts=false) {
|
157 |
-
$_params = array("id" => $id, "counts" => $counts);
|
158 |
-
return $this->master->call('lists/interest-groupings', $_params);
|
159 |
-
}
|
160 |
-
|
161 |
-
/**
|
162 |
-
* Add a single Interest Group - if interest groups for the List are not yet enabled, adding the first
|
163 |
-
group will automatically turn them on.
|
164 |
-
* @param string $id
|
165 |
-
* @param string $group_name
|
166 |
-
* @param int $grouping_id
|
167 |
-
* @return associative_array with a single entry:
|
168 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
169 |
-
*/
|
170 |
-
public function interestGroupAdd($id, $group_name, $grouping_id=null) {
|
171 |
-
$_params = array("id" => $id, "group_name" => $group_name, "grouping_id" => $grouping_id);
|
172 |
-
return $this->master->call('lists/interest-group-add', $_params);
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Delete a single Interest Group - if the last group for a list is deleted, this will also turn groups for the list off.
|
177 |
-
* @param string $id
|
178 |
-
* @param string $group_name
|
179 |
-
* @param int $grouping_id
|
180 |
-
* @return associative_array with a single entry:
|
181 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
182 |
-
*/
|
183 |
-
public function interestGroupDel($id, $group_name, $grouping_id=null) {
|
184 |
-
$_params = array("id" => $id, "group_name" => $group_name, "grouping_id" => $grouping_id);
|
185 |
-
return $this->master->call('lists/interest-group-del', $_params);
|
186 |
-
}
|
187 |
-
|
188 |
-
/**
|
189 |
-
* Change the name of an Interest Group
|
190 |
-
* @param string $id
|
191 |
-
* @param string $old_name
|
192 |
-
* @param string $new_name
|
193 |
-
* @param int $grouping_id
|
194 |
-
* @return associative_array with a single entry:
|
195 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
196 |
-
*/
|
197 |
-
public function interestGroupUpdate($id, $old_name, $new_name, $grouping_id=null) {
|
198 |
-
$_params = array("id" => $id, "old_name" => $old_name, "new_name" => $new_name, "grouping_id" => $grouping_id);
|
199 |
-
return $this->master->call('lists/interest-group-update', $_params);
|
200 |
-
}
|
201 |
-
|
202 |
-
/**
|
203 |
-
* Add a new Interest Grouping - if interest groups for the List are not yet enabled, adding the first
|
204 |
-
grouping will automatically turn them on.
|
205 |
-
* @param string $id
|
206 |
-
* @param string $name
|
207 |
-
* @param string $type
|
208 |
-
* @param array $groups
|
209 |
-
* @return associative_array with a single entry:
|
210 |
-
* - id int the new grouping id if the request succeeds, otherwise an error will be thrown
|
211 |
-
*/
|
212 |
-
public function interestGroupingAdd($id, $name, $type, $groups) {
|
213 |
-
$_params = array("id" => $id, "name" => $name, "type" => $type, "groups" => $groups);
|
214 |
-
return $this->master->call('lists/interest-grouping-add', $_params);
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Delete an existing Interest Grouping - this will permanently delete all contained interest groups and will remove those selections from all list members
|
219 |
-
* @param int $grouping_id
|
220 |
-
* @return associative_array with a single entry:
|
221 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
222 |
-
*/
|
223 |
-
public function interestGroupingDel($grouping_id) {
|
224 |
-
$_params = array("grouping_id" => $grouping_id);
|
225 |
-
return $this->master->call('lists/interest-grouping-del', $_params);
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Update an existing Interest Grouping
|
230 |
-
* @param int $grouping_id
|
231 |
-
* @param string $name
|
232 |
-
* @param string $value
|
233 |
-
* @return associative_array with a single entry:
|
234 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
235 |
-
*/
|
236 |
-
public function interestGroupingUpdate($grouping_id, $name, $value) {
|
237 |
-
$_params = array("grouping_id" => $grouping_id, "name" => $name, "value" => $value);
|
238 |
-
return $this->master->call('lists/interest-grouping-update', $_params);
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Retrieve the locations (countries) that the list's subscribers have been tagged to based on geocoding their IP address
|
243 |
-
* @param string $id
|
244 |
-
* @return array array of locations
|
245 |
-
* - country string the country name
|
246 |
-
* - cc string the ISO 3166 2 digit country code
|
247 |
-
* - percent double the percent of subscribers in the country
|
248 |
-
* - total double the total number of subscribers in the country
|
249 |
-
*/
|
250 |
-
public function locations($id) {
|
251 |
-
$_params = array("id" => $id);
|
252 |
-
return $this->master->call('lists/locations', $_params);
|
253 |
-
}
|
254 |
-
|
255 |
-
/**
|
256 |
-
* Get the most recent 100 activities for particular list members (open, click, bounce, unsub, abuse, sent to, etc.)
|
257 |
-
* @param string $id
|
258 |
-
* @param array $emails
|
259 |
-
* - email string an email address - for new subscribers obviously this should be used
|
260 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
261 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
262 |
-
* @return associative_array of data and success/error counts
|
263 |
-
* - success_count int the number of subscribers successfully found on the list
|
264 |
-
* - error_count int the number of subscribers who were not found on the list
|
265 |
-
* - errors array array of error structs including:
|
266 |
-
* - email string whatever was passed in the email parameter
|
267 |
-
* - email string the email address added
|
268 |
-
* - euid string the email unique id
|
269 |
-
* - leid string the list member's truly unique id
|
270 |
-
* - error string the error message
|
271 |
-
* - code string the error code
|
272 |
-
* - data array an array of structs where each activity record has:
|
273 |
-
* - email string whatever was passed in the email parameter
|
274 |
-
* - email string the email address added
|
275 |
-
* - euid string the email unique id
|
276 |
-
* - leid string the list member's truly unique id
|
277 |
-
* - activity array an array of structs containing the activity, including:
|
278 |
-
* - action string The action name, one of: open, click, bounce, unsub, abuse, sent, queued, ecomm, mandrill_send, mandrill_hard_bounce, mandrill_soft_bounce, mandrill_open, mandrill_click, mandrill_spam, mandrill_unsub, mandrill_reject
|
279 |
-
* - timestamp string The date+time of the action (GMT)
|
280 |
-
* - url string For click actions, the url clicked, otherwise this is empty
|
281 |
-
* - type string If there's extra bounce, unsub, etc data it will show up here.
|
282 |
-
* - campaign_id string The campaign id the action was related to, if it exists - otherwise empty (ie, direct unsub from list)
|
283 |
-
* - campaign_data associative_array If not deleted, the campaigns/list data for the campaign
|
284 |
-
*/
|
285 |
-
public function memberActivity($id, $emails) {
|
286 |
-
$_params = array("id" => $id, "emails" => $emails);
|
287 |
-
return $this->master->call('lists/member-activity', $_params);
|
288 |
-
}
|
289 |
-
|
290 |
-
/**
|
291 |
-
* Get all the information for particular members of a list
|
292 |
-
* @param string $id
|
293 |
-
* @param array $emails
|
294 |
-
* - email string an email address - for new subscribers obviously this should be used
|
295 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
296 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
297 |
-
* @return associative_array of data and success/error counts
|
298 |
-
* - success_count int the number of subscribers successfully found on the list
|
299 |
-
* - error_count int the number of subscribers who were not found on the list
|
300 |
-
* - errors array array of error structs including:
|
301 |
-
* - email associative_array whatever was passed in the email parameter
|
302 |
-
* - email string the email address added
|
303 |
-
* - euid string the email unique id
|
304 |
-
* - leid string the list member's truly unique id
|
305 |
-
* - error string the error message
|
306 |
-
* - data array array of structs for each valid list member
|
307 |
-
* - id string The unique id (euid) for this email address on an account
|
308 |
-
* - email string The email address associated with this record
|
309 |
-
* - email_type string The type of emails this customer asked to get: html or text
|
310 |
-
* - merges associative_array a struct containing a key for each merge tags and the data for those tags for this email address, plus:
|
311 |
-
* - GROUPINGS array if Interest groupings are enabled, this will exist with structs for each grouping:
|
312 |
-
* - id int the grouping id
|
313 |
-
* - name string the interest group name
|
314 |
-
* - groups array structs for each group in the grouping
|
315 |
-
* - name string the group name
|
316 |
-
* - interested bool whether the member has this group selected
|
317 |
-
* - status string The subscription status for this email address, either pending, subscribed, unsubscribed, or cleaned
|
318 |
-
* - ip_signup string IP Address this address signed up from. This may be blank if single optin is used.
|
319 |
-
* - timestamp_signup string The date+time the double optin was initiated. This may be blank if single optin is used.
|
320 |
-
* - ip_opt string IP Address this address opted in from.
|
321 |
-
* - timestamp_opt string The date+time the optin completed
|
322 |
-
* - member_rating int the rating of the subscriber. This will be 1 - 5 as described <a href="http://eepurl.com/f-2P" target="_blank">here</a>
|
323 |
-
* - campaign_id string If the user is unsubscribed and they unsubscribed from a specific campaign, that campaign_id will be listed, otherwise this is not returned.
|
324 |
-
* - lists array An array of structs for the other lists this member belongs to
|
325 |
-
* - id string the list id
|
326 |
-
* - status string the members status on that list
|
327 |
-
* - timestamp string The date+time this email address entered it's current status
|
328 |
-
* - info_changed string The last time this record was changed. If the record is old enough, this may be blank.
|
329 |
-
* - web_id int The Member id used in our web app, allows you to create a link directly to it
|
330 |
-
* - leid int The Member id used in our web app, allows you to create a link directly to it
|
331 |
-
* - list_id string The list id the for the member record being returned
|
332 |
-
* - list_name string The list name the for the member record being returned
|
333 |
-
* - language string if set/detected, a language code from <a href="http://kb.mailchimp.com/article/can-i-see-what-languages-my-subscribers-use#code" target="_blank">here</a>
|
334 |
-
* - is_gmonkey bool Whether the member is a <a href="http://mailchimp.com/features/golden-monkeys/" target="_blank">Golden Monkey</a> or not.
|
335 |
-
* - geo associative_array the geographic information if we have it. including:
|
336 |
-
* - latitude string the latitude
|
337 |
-
* - longitude string the longitude
|
338 |
-
* - gmtoff string GMT offset
|
339 |
-
* - dstoff string GMT offset during daylight savings (if DST not observered, will be same as gmtoff)
|
340 |
-
* - timezone string the timezone we've place them in
|
341 |
-
* - cc string 2 digit ISO-3166 country code
|
342 |
-
* - region string generally state, province, or similar
|
343 |
-
* - clients associative_array the client we've tracked the address as using with two keys:
|
344 |
-
* - name string the common name of the client
|
345 |
-
* - icon_url string a url representing a path to an icon representing this client
|
346 |
-
* - static_segments array structs for each static segments the member is a part of including:
|
347 |
-
* - id int the segment id
|
348 |
-
* - name string the name given to the segment
|
349 |
-
* - added string the date the member was added
|
350 |
-
* - notes array structs for each note entered for this member. For each note:
|
351 |
-
* - id int the note id
|
352 |
-
* - note string the text entered
|
353 |
-
* - created string the date the note was created
|
354 |
-
* - updated string the date the note was last updated
|
355 |
-
* - created_by_name string the name of the user who created the note. This can change as users update their profile.
|
356 |
-
*/
|
357 |
-
public function memberInfo($id, $emails) {
|
358 |
-
$_params = array("id" => $id, "emails" => $emails);
|
359 |
-
return $this->master->call('lists/member-info', $_params);
|
360 |
-
}
|
361 |
-
|
362 |
-
/**
|
363 |
-
* Get all of the list members for a list that are of a particular status and potentially matching a segment. This will cause locking, so don't run multiples at once. Are you trying to get a dump including lots of merge
|
364 |
-
data or specific members of a list? If so, checkout the <a href="/export/1.0/list.func.php">List Export API</a>
|
365 |
-
* @param string $id
|
366 |
-
* @param string $status
|
367 |
-
* @param associative_array $opts
|
368 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
369 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
370 |
-
* - sort_field string optional the data field to sort by - mergeX (1-30), your custom merge tags, "email", "rating","last_update_time", or "optin_time" - invalid fields will be ignored
|
371 |
-
* - sort_dir string optional the direct - ASC or DESC. defaults to ASC (case insensitive)
|
372 |
-
* - segment associative_array a properly formatted segment that works with campaigns/segment-test
|
373 |
-
* @return associative_array of the total records matched and limited list member data for this page
|
374 |
-
* - total int the total matching records
|
375 |
-
* - data array structs for each member as returned by member-info
|
376 |
-
*/
|
377 |
-
public function members($id, $status='subscribed', $opts=array()) {
|
378 |
-
$_params = array("id" => $id, "status" => $status, "opts" => $opts);
|
379 |
-
return $this->master->call('lists/members', $_params);
|
380 |
-
}
|
381 |
-
|
382 |
-
/**
|
383 |
-
* Add a new merge tag to a given list
|
384 |
-
* @param string $id
|
385 |
-
* @param string $tag
|
386 |
-
* @param string $name
|
387 |
-
* @param associative_array $options
|
388 |
-
* - field_type string optional one of: text, number, radio, dropdown, date, address, phone, url, imageurl, zip, birthday - defaults to text
|
389 |
-
* - req boolean optional indicates whether the field is required - defaults to false
|
390 |
-
* - public boolean optional indicates whether the field is displayed in public - defaults to true
|
391 |
-
* - show boolean optional indicates whether the field is displayed in the app's list member view - defaults to true
|
392 |
-
* - order int The order this merge tag should be displayed in - this will cause existing values to be reset so this fits
|
393 |
-
* - default_value string optional the default value for the field. See lists/subscribe() for formatting info. Defaults to blank - max 255 bytes
|
394 |
-
* - helptext string optional the help text to be used with some newer forms. Defaults to blank - max 255 bytes
|
395 |
-
* - choices array optional kind of - an array of strings to use as the choices for radio and dropdown type fields
|
396 |
-
* - dateformat string optional only valid for birthday and date fields. For birthday type, must be "MM/DD" (default) or "DD/MM". For date type, must be "MM/DD/YYYY" (default) or "DD/MM/YYYY". Any other values will be converted to the default.
|
397 |
-
* - phoneformat string optional "US" is the default - any other value will cause them to be unformatted (international)
|
398 |
-
* - defaultcountry string optional the <a href="http://www.iso.org/iso/english_country_names_and_code_elements" target="_blank">ISO 3166 2 digit character code</a> for the default country. Defaults to "US". Anything unrecognized will be converted to the default.
|
399 |
-
* @return associative_array the full data for the new merge var, just like merge-vars returns
|
400 |
-
* - name string Name/description of the merge field
|
401 |
-
* - req bool Denotes whether the field is required (true) or not (false)
|
402 |
-
* - field_type string The "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl
|
403 |
-
* - public bool Whether or not this field is visible to list subscribers
|
404 |
-
* - show bool Whether the field is displayed in thelist dashboard
|
405 |
-
* - order string The order this field displays in on forms
|
406 |
-
* - default string The default value for this field
|
407 |
-
* - helptext string The helptext for this field
|
408 |
-
* - size string The width of the field to be used
|
409 |
-
* - tag string The merge tag that's used for forms and lists/subscribe() and lists/update-member()
|
410 |
-
* - choices array the options available for radio and dropdown field types
|
411 |
-
* - id int an unchanging id for the merge var
|
412 |
-
*/
|
413 |
-
public function mergeVarAdd($id, $tag, $name, $options=array()) {
|
414 |
-
$_params = array("id" => $id, "tag" => $tag, "name" => $name, "options" => $options);
|
415 |
-
return $this->master->call('lists/merge-var-add', $_params);
|
416 |
-
}
|
417 |
-
|
418 |
-
/**
|
419 |
-
* Delete a merge tag from a given list and all its members. Seriously - the data is removed from all members as well!
|
420 |
-
Note that on large lists this method may seem a bit slower than calls you typically make.
|
421 |
-
* @param string $id
|
422 |
-
* @param string $tag
|
423 |
-
* @return associative_array with a single entry:
|
424 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
425 |
-
*/
|
426 |
-
public function mergeVarDel($id, $tag) {
|
427 |
-
$_params = array("id" => $id, "tag" => $tag);
|
428 |
-
return $this->master->call('lists/merge-var-del', $_params);
|
429 |
-
}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* Completely resets all data stored in a merge var on a list. All data is removed and this action can not be undone.
|
433 |
-
* @param string $id
|
434 |
-
* @param string $tag
|
435 |
-
* @return associative_array with a single entry:
|
436 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
437 |
-
*/
|
438 |
-
public function mergeVarReset($id, $tag) {
|
439 |
-
$_params = array("id" => $id, "tag" => $tag);
|
440 |
-
return $this->master->call('lists/merge-var-reset', $_params);
|
441 |
-
}
|
442 |
-
|
443 |
-
/**
|
444 |
-
* Sets a particular merge var to the specified value for every list member. Only merge var ids 1 - 30 may be modified this way. This is generally a dirty method
|
445 |
-
unless you're fixing data since you should probably be using default_values and/or conditional content. as with lists/merge-var-reset(), this can not be undone.
|
446 |
-
* @param string $id
|
447 |
-
* @param string $tag
|
448 |
-
* @param string $value
|
449 |
-
* @return associative_array with a single entry:
|
450 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
451 |
-
*/
|
452 |
-
public function mergeVarSet($id, $tag, $value) {
|
453 |
-
$_params = array("id" => $id, "tag" => $tag, "value" => $value);
|
454 |
-
return $this->master->call('lists/merge-var-set', $_params);
|
455 |
-
}
|
456 |
-
|
457 |
-
/**
|
458 |
-
* Update most parameters for a merge tag on a given list. You cannot currently change the merge type
|
459 |
-
* @param string $id
|
460 |
-
* @param string $tag
|
461 |
-
* @param associative_array $options
|
462 |
-
* @return associative_array the full data for the new merge var, just like merge-vars returns
|
463 |
-
* - name string Name/description of the merge field
|
464 |
-
* - req bool Denotes whether the field is required (true) or not (false)
|
465 |
-
* - field_type string The "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl
|
466 |
-
* - public bool Whether or not this field is visible to list subscribers
|
467 |
-
* - show bool Whether the field is displayed in thelist dashboard
|
468 |
-
* - order string The order this field to displays in on forms
|
469 |
-
* - default string The default value for this field
|
470 |
-
* - helptext string The helptext for this field
|
471 |
-
* - size string The width of the field to be used
|
472 |
-
* - tag string The merge tag that's used for forms and lists/subscribe() and lists/update-member()
|
473 |
-
* - choices array the options available for radio and dropdown field types
|
474 |
-
* - id int an unchanging id for the merge var
|
475 |
-
*/
|
476 |
-
public function mergeVarUpdate($id, $tag, $options) {
|
477 |
-
$_params = array("id" => $id, "tag" => $tag, "options" => $options);
|
478 |
-
return $this->master->call('lists/merge-var-update', $_params);
|
479 |
-
}
|
480 |
-
|
481 |
-
/**
|
482 |
-
* Get the list of merge tags for a given list, including their name, tag, and required setting
|
483 |
-
* @param array $id
|
484 |
-
* @return associative_array of data and success/error counts
|
485 |
-
* - success_count int the number of subscribers successfully found on the list
|
486 |
-
* - error_count int the number of subscribers who were not found on the list
|
487 |
-
* - data array of structs for the merge tags on each list
|
488 |
-
* - id string the list id
|
489 |
-
* - name string the list name
|
490 |
-
* - merge_vars array of structs for each merge var
|
491 |
-
* - name string Name of the merge field
|
492 |
-
* - req bool Denotes whether the field is required (true) or not (false)
|
493 |
-
* - field_type string The "data type" of this merge var. One of the options accepted by field_type in lists/merge-var-add
|
494 |
-
* - public bool Whether or not this field is visible to list subscribers
|
495 |
-
* - show bool Whether the list owner has this field displayed on their list dashboard
|
496 |
-
* - order string The order the list owner has set this field to display in
|
497 |
-
* - default string The default value the list owner has set for this field
|
498 |
-
* - helptext string The helptext for this field
|
499 |
-
* - size string The width of the field to be used
|
500 |
-
* - tag string The merge tag that's used for forms and lists/subscribe() and listUpdateMember()
|
501 |
-
* - choices array For radio and dropdown field types, an array of the options available
|
502 |
-
* - id int an unchanging id for the merge var
|
503 |
-
* - errors array of error structs
|
504 |
-
* - id string the passed list id that failed
|
505 |
-
* - code int the resulting error code
|
506 |
-
* - msg string the resulting error message
|
507 |
-
*/
|
508 |
-
public function mergeVars($id) {
|
509 |
-
$_params = array("id" => $id);
|
510 |
-
return $this->master->call('lists/merge-vars', $_params);
|
511 |
-
}
|
512 |
-
|
513 |
-
/**
|
514 |
-
* Retrieve all of Segments for a list.
|
515 |
-
* @param string $id
|
516 |
-
* @param string $type
|
517 |
-
* @return associative_array with 2 keys:
|
518 |
-
* - static array of structs with data for each segment
|
519 |
-
* - id int the id of the segment
|
520 |
-
* - name string the name for the segment
|
521 |
-
* - created_date string the date+time the segment was created
|
522 |
-
* - last_update string the date+time the segment was last updated (add or del)
|
523 |
-
* - last_reset string the date+time the segment was last reset (ie had all members cleared from it)
|
524 |
-
* - saved array of structs with data for each segment
|
525 |
-
* - id int the id of the segment
|
526 |
-
* - name string the name for the segment
|
527 |
-
* - segment_opts string same match+conditions struct typically used
|
528 |
-
* - segment_text string a textual description of the segment match/conditions
|
529 |
-
* - created_date string the date+time the segment was created
|
530 |
-
* - last_update string the date+time the segment was last updated (add or del)
|
531 |
-
*/
|
532 |
-
public function segments($id, $type=null) {
|
533 |
-
$_params = array("id" => $id, "type" => $type);
|
534 |
-
return $this->master->call('lists/segments', $_params);
|
535 |
-
}
|
536 |
-
|
537 |
-
/**
|
538 |
-
* Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments <strong>are not</strong> tied
|
539 |
-
to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance.
|
540 |
-
When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation
|
541 |
-
options), though performance may degrade at that point. Saved Segments (called "auto-updating" in the app) are essentially just the match+conditions typically
|
542 |
-
used.
|
543 |
-
* @param string $id
|
544 |
-
* @param associative_array $opts
|
545 |
-
* - type string either "static" or "saved"
|
546 |
-
* - name string a unique name per list for the segment - 100 byte maximum length, anything longer will throw an error
|
547 |
-
* - segment_opts associative_array for "saved" only, the standard segment match+conditions, just like campaigns/segment-test
|
548 |
-
* - match string "any" or "all"
|
549 |
-
* - conditions array structs for each condition, just like campaigns/segment-test
|
550 |
-
* @return associative_array with a single entry:
|
551 |
-
* - id int the id of the new segment, otherwise an error will be thrown.
|
552 |
-
*/
|
553 |
-
public function segmentAdd($id, $opts) {
|
554 |
-
$_params = array("id" => $id, "opts" => $opts);
|
555 |
-
return $this->master->call('lists/segment-add', $_params);
|
556 |
-
}
|
557 |
-
|
558 |
-
/**
|
559 |
-
* Delete a segment. Note that this will, of course, remove any member affiliations with any static segments deleted
|
560 |
-
* @param string $id
|
561 |
-
* @param int $seg_id
|
562 |
-
* @return associative_array with a single entry:
|
563 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
564 |
-
*/
|
565 |
-
public function segmentDel($id, $seg_id) {
|
566 |
-
$_params = array("id" => $id, "seg_id" => $seg_id);
|
567 |
-
return $this->master->call('lists/segment-del', $_params);
|
568 |
-
}
|
569 |
-
|
570 |
-
/**
|
571 |
-
* Allows one to test their segmentation rules before creating a campaign using them - this is no different from campaigns/segment-test() and will eventually replace it.
|
572 |
-
For the time being, the crazy segmenting condition documentation will continue to live over there.
|
573 |
-
* @param string $list_id
|
574 |
-
* @param associative_array $options
|
575 |
-
* @return associative_array with a single entry:
|
576 |
-
* - total int The total number of subscribers matching your segmentation options
|
577 |
-
*/
|
578 |
-
public function segmentTest($list_id, $options) {
|
579 |
-
$_params = array("list_id" => $list_id, "options" => $options);
|
580 |
-
return $this->master->call('lists/segment-test', $_params);
|
581 |
-
}
|
582 |
-
|
583 |
-
/**
|
584 |
-
* Update an existing segment. The list and type can not be changed.
|
585 |
-
* @param string $id
|
586 |
-
* @param int $seg_id
|
587 |
-
* @param associative_array $opts
|
588 |
-
* - name string a unique name per list for the segment - 100 byte maximum length, anything longer will throw an error
|
589 |
-
* - segment_opts associative_array for "saved" only, the standard segment match+conditions, just like campaigns/segment-test
|
590 |
-
* - match string "any" or "all"
|
591 |
-
* - conditions array structs for each condition, just like campaigns/segment-test
|
592 |
-
* @return associative_array with a single entry:
|
593 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
594 |
-
*/
|
595 |
-
public function segmentUpdate($id, $seg_id, $opts) {
|
596 |
-
$_params = array("id" => $id, "seg_id" => $seg_id, "opts" => $opts);
|
597 |
-
return $this->master->call('lists/segment-update', $_params);
|
598 |
-
}
|
599 |
-
|
600 |
-
/**
|
601 |
-
* Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments <strong>are not</strong> tied
|
602 |
-
to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance.
|
603 |
-
When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation
|
604 |
-
options), though performance may degrade at that point.
|
605 |
-
* @param string $id
|
606 |
-
* @param string $name
|
607 |
-
* @return associative_array with a single entry:
|
608 |
-
* - id int the id of the new segment, otherwise an error will be thrown.
|
609 |
-
*/
|
610 |
-
public function staticSegmentAdd($id, $name) {
|
611 |
-
$_params = array("id" => $id, "name" => $name);
|
612 |
-
return $this->master->call('lists/static-segment-add', $_params);
|
613 |
-
}
|
614 |
-
|
615 |
-
/**
|
616 |
-
* Delete a static segment. Note that this will, of course, remove any member affiliations with the segment
|
617 |
-
* @param string $id
|
618 |
-
* @param int $seg_id
|
619 |
-
* @return associative_array with a single entry:
|
620 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
621 |
-
*/
|
622 |
-
public function staticSegmentDel($id, $seg_id) {
|
623 |
-
$_params = array("id" => $id, "seg_id" => $seg_id);
|
624 |
-
return $this->master->call('lists/static-segment-del', $_params);
|
625 |
-
}
|
626 |
-
|
627 |
-
/**
|
628 |
-
* Add list members to a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
|
629 |
-
in order to be included - this <strong>will not</strong> subscribe them to the list!
|
630 |
-
* @param string $id
|
631 |
-
* @param int $seg_id
|
632 |
-
* @param array $batch
|
633 |
-
* - email string an email address
|
634 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
635 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
636 |
-
* @return associative_array an array with the results of the operation
|
637 |
-
* - success_count int the total number of successful updates (will include members already in the segment)
|
638 |
-
* - errors array structs for each error including:
|
639 |
-
* - email string whatever was passed in the email parameter
|
640 |
-
* - email string the email address added
|
641 |
-
* - euid string the email unique id
|
642 |
-
* - leid string the list member's truly unique id
|
643 |
-
* - code string the error code
|
644 |
-
* - error string the full error message
|
645 |
-
*/
|
646 |
-
public function staticSegmentMembersAdd($id, $seg_id, $batch) {
|
647 |
-
$_params = array("id" => $id, "seg_id" => $seg_id, "batch" => $batch);
|
648 |
-
return $this->master->call('lists/static-segment-members-add', $_params);
|
649 |
-
}
|
650 |
-
|
651 |
-
/**
|
652 |
-
* Remove list members from a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list
|
653 |
-
in order to be removed - this <strong>will not</strong> unsubscribe them from the list!
|
654 |
-
* @param string $id
|
655 |
-
* @param int $seg_id
|
656 |
-
* @param array $batch
|
657 |
-
* - email string an email address
|
658 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
659 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
660 |
-
* @return associative_array an array with the results of the operation
|
661 |
-
* - success_count int the total number of successful removals
|
662 |
-
* - error_count int the total number of unsuccessful removals
|
663 |
-
* - errors array structs for each error including:
|
664 |
-
* - email string whatever was passed in the email parameter
|
665 |
-
* - email string the email address added
|
666 |
-
* - euid string the email unique id
|
667 |
-
* - leid string the list member's truly unique id
|
668 |
-
* - code string the error code
|
669 |
-
* - error string the full error message
|
670 |
-
*/
|
671 |
-
public function staticSegmentMembersDel($id, $seg_id, $batch) {
|
672 |
-
$_params = array("id" => $id, "seg_id" => $seg_id, "batch" => $batch);
|
673 |
-
return $this->master->call('lists/static-segment-members-del', $_params);
|
674 |
-
}
|
675 |
-
|
676 |
-
/**
|
677 |
-
* Resets a static segment - removes <strong>all</strong> members from the static segment. Note: does not actually affect list member data
|
678 |
-
* @param string $id
|
679 |
-
* @param int $seg_id
|
680 |
-
* @return associative_array with a single entry:
|
681 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
682 |
-
*/
|
683 |
-
public function staticSegmentReset($id, $seg_id) {
|
684 |
-
$_params = array("id" => $id, "seg_id" => $seg_id);
|
685 |
-
return $this->master->call('lists/static-segment-reset', $_params);
|
686 |
-
}
|
687 |
-
|
688 |
-
/**
|
689 |
-
* Retrieve all of the Static Segments for a list.
|
690 |
-
* @param string $id
|
691 |
-
* @param boolean $get_counts
|
692 |
-
* @param int $start
|
693 |
-
* @param int $limit
|
694 |
-
* @return array an of structs with data for each static segment
|
695 |
-
* - id int the id of the segment
|
696 |
-
* - name string the name for the segment
|
697 |
-
* - member_count int the total number of subscribed members currently in a segment
|
698 |
-
* - created_date string the date+time the segment was created
|
699 |
-
* - last_update string the date+time the segment was last updated (add or del)
|
700 |
-
* - last_reset string the date+time the segment was last reset (ie had all members cleared from it)
|
701 |
-
*/
|
702 |
-
public function staticSegments($id, $get_counts=true, $start=0, $limit=null) {
|
703 |
-
$_params = array("id" => $id, "get_counts" => $get_counts, "start" => $start, "limit" => $limit);
|
704 |
-
return $this->master->call('lists/static-segments', $_params);
|
705 |
-
}
|
706 |
-
|
707 |
-
/**
|
708 |
-
* Subscribe the provided email to a list. By default this sends a confirmation email - you will not see new members until the link contained in it is clicked!
|
709 |
-
* @param string $id
|
710 |
-
* @param associative_array $email
|
711 |
-
* - email string an email address - for new subscribers obviously this should be used
|
712 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
713 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
714 |
-
* @param associative_array $merge_vars
|
715 |
-
* - new-email string set this to change the email address. This is only respected on calls using update_existing or when passed to lists/update.
|
716 |
-
* - groupings array of Interest Grouping structs. Each should contain:
|
717 |
-
* - id int Grouping "id" from lists/interest-groupings (either this or name must be present) - this id takes precedence and can't change (unlike the name)
|
718 |
-
* - name string Grouping "name" from lists/interest-groupings (either this or id must be present)
|
719 |
-
* - groups array an array of valid group names for this grouping.
|
720 |
-
* - optin_ip string Set the Opt-in IP field. <em>Abusing this may cause your account to be suspended.</em> We do validate this and it must not be a private IP address.
|
721 |
-
* - optin_time string Set the Opt-in Time field. <em>Abusing this may cause your account to be suspended.</em> We do validate this and it must be a valid date. Use - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00" to be safe. Generally, though, anything strtotime() understands we'll understand - <a href="http://us2.php.net/strtotime" target="_blank">http://us2.php.net/strtotime</a>
|
722 |
-
* - mc_location associative_array Set the member's geographic location either by optin_ip or geo data.
|
723 |
-
* - latitude string use the specified latitude (longitude must exist for this to work)
|
724 |
-
* - longitude string use the specified longitude (latitude must exist for this to work)
|
725 |
-
* - anything string if this (or any other key exists here) we'll try to use the optin ip. NOTE - this will slow down each subscribe call a bit, especially for lat/lng pairs in sparsely populated areas. Currently our automated background processes can and will overwrite this based on opens and clicks.
|
726 |
-
* - mc_language string Set the member's language preference. Supported codes are fully case-sensitive and can be found <a href="http://kb.mailchimp.com/article/can-i-see-what-languages-my-subscribers-use#code" target="_new">here</a>.
|
727 |
-
* - mc_notes array of structs for managing notes - it may contain:
|
728 |
-
* - note string the note to set. this is required unless you're deleting a note
|
729 |
-
* - id int the note id to operate on. not including this (or using an invalid id) causes a new note to be added
|
730 |
-
* - action string if the "id" key exists and is valid, an "update" key may be set to "append" (default), "prepend", "replace", or "delete" to handle how we should update existing notes. "delete", obviously, will only work with a valid "id" - passing that along with "note" and an invalid "id" is wrong and will be ignored.
|
731 |
-
* @param string $email_type
|
732 |
-
* @param bool $double_optin
|
733 |
-
* @param bool $update_existing
|
734 |
-
* @param bool $replace_interests
|
735 |
-
* @param bool $send_welcome
|
736 |
-
* @return associative_array the ids for this subscriber
|
737 |
-
* - email string the email address added
|
738 |
-
* - euid string the email unique id
|
739 |
-
* - leid string the list member's truly unique id
|
740 |
-
*/
|
741 |
-
public function subscribe($id, $email, $merge_vars=null, $email_type='html', $double_optin=true, $update_existing=false, $replace_interests=true, $send_welcome=false) {
|
742 |
-
$_params = array("id" => $id, "email" => $email, "merge_vars" => $merge_vars, "email_type" => $email_type, "double_optin" => $double_optin, "update_existing" => $update_existing, "replace_interests" => $replace_interests, "send_welcome" => $send_welcome);
|
743 |
-
return $this->master->call('lists/subscribe', $_params);
|
744 |
-
}
|
745 |
-
|
746 |
-
/**
|
747 |
-
* Unsubscribe the given email address from the list
|
748 |
-
* @param string $id
|
749 |
-
* @param associative_array $email
|
750 |
-
* - email string an email address
|
751 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
752 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
753 |
-
* @param boolean $delete_member
|
754 |
-
* @param boolean $send_goodbye
|
755 |
-
* @param boolean $send_notify
|
756 |
-
* @return associative_array with a single entry:
|
757 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
758 |
-
*/
|
759 |
-
public function unsubscribe($id, $email, $delete_member=false, $send_goodbye=true, $send_notify=true) {
|
760 |
-
$_params = array("id" => $id, "email" => $email, "delete_member" => $delete_member, "send_goodbye" => $send_goodbye, "send_notify" => $send_notify);
|
761 |
-
return $this->master->call('lists/unsubscribe', $_params);
|
762 |
-
}
|
763 |
-
|
764 |
-
/**
|
765 |
-
* Edit the email address, merge fields, and interest groups for a list member. If you are doing a batch update on lots of users,
|
766 |
-
consider using lists/batch-subscribe() with the update_existing and possible replace_interests parameter.
|
767 |
-
* @param string $id
|
768 |
-
* @param associative_array $email
|
769 |
-
* - email string an email address
|
770 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
771 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
772 |
-
* @param array $merge_vars
|
773 |
-
* @param string $email_type
|
774 |
-
* @param boolean $replace_interests
|
775 |
-
* @return associative_array the ids for this subscriber
|
776 |
-
* - email string the email address added
|
777 |
-
* - euid string the email unique id
|
778 |
-
* - leid string the list member's truly unique id
|
779 |
-
*/
|
780 |
-
public function updateMember($id, $email, $merge_vars, $email_type='', $replace_interests=true) {
|
781 |
-
$_params = array("id" => $id, "email" => $email, "merge_vars" => $merge_vars, "email_type" => $email_type, "replace_interests" => $replace_interests);
|
782 |
-
return $this->master->call('lists/update-member', $_params);
|
783 |
-
}
|
784 |
-
|
785 |
-
/**
|
786 |
-
* Add a new Webhook URL for the given list
|
787 |
-
* @param string $id
|
788 |
-
* @param string $url
|
789 |
-
* @param associative_array $actions
|
790 |
-
* - subscribe bool optional as subscribes occur, defaults to true
|
791 |
-
* - unsubscribe bool optional as subscribes occur, defaults to true
|
792 |
-
* - profile bool optional as profile updates occur, defaults to true
|
793 |
-
* - cleaned bool optional as emails are cleaned from the list, defaults to true
|
794 |
-
* - upemail bool optional when subscribers change their email address, defaults to true
|
795 |
-
* - campaign bool option when a campaign is sent or canceled, defaults to true
|
796 |
-
* @param associative_array $sources
|
797 |
-
* - user bool optional user/subscriber initiated actions, defaults to true
|
798 |
-
* - admin bool optional admin actions in our web app, defaults to true
|
799 |
-
* - api bool optional actions that happen via API calls, defaults to false
|
800 |
-
* @return associative_array with a single entry:
|
801 |
-
* - id int the id of the new webhook, otherwise an error will be thrown.
|
802 |
-
*/
|
803 |
-
public function webhookAdd($id, $url, $actions=array(), $sources=array()) {
|
804 |
-
$_params = array("id" => $id, "url" => $url, "actions" => $actions, "sources" => $sources);
|
805 |
-
return $this->master->call('lists/webhook-add', $_params);
|
806 |
-
}
|
807 |
-
|
808 |
-
/**
|
809 |
-
* Delete an existing Webhook URL from a given list
|
810 |
-
* @param string $id
|
811 |
-
* @param string $url
|
812 |
-
* @return associative_array with a single entry:
|
813 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
814 |
-
*/
|
815 |
-
public function webhookDel($id, $url) {
|
816 |
-
$_params = array("id" => $id, "url" => $url);
|
817 |
-
return $this->master->call('lists/webhook-del', $_params);
|
818 |
-
}
|
819 |
-
|
820 |
-
/**
|
821 |
-
* Return the Webhooks configured for the given list
|
822 |
-
* @param string $id
|
823 |
-
* @return array of structs for each webhook
|
824 |
-
* - url string the URL for this Webhook
|
825 |
-
* - actions associative_array the possible actions and whether they are enabled
|
826 |
-
* - subscribe bool triggered when subscribes happen
|
827 |
-
* - unsubscribe bool triggered when unsubscribes happen
|
828 |
-
* - profile bool triggered when profile updates happen
|
829 |
-
* - cleaned bool triggered when a subscriber is cleaned (bounced) from a list
|
830 |
-
* - upemail bool triggered when a subscriber's email address is changed
|
831 |
-
* - campaign bool triggered when a campaign is sent or canceled
|
832 |
-
* - sources associative_array the possible sources and whether they are enabled
|
833 |
-
* - user bool whether user/subscriber triggered actions are returned
|
834 |
-
* - admin bool whether admin (manual, in-app) triggered actions are returned
|
835 |
-
* - api bool whether api triggered actions are returned
|
836 |
-
*/
|
837 |
-
public function webhooks($id) {
|
838 |
-
$_params = array("id" => $id);
|
839 |
-
return $this->master->call('lists/webhooks', $_params);
|
840 |
-
}
|
841 |
-
|
842 |
-
/**
|
843 |
-
* Retrieve all of the lists defined for your user account
|
844 |
-
* @param associative_array $filters
|
845 |
-
* - list_id string optional - return a single list using a known list_id. Accepts multiples separated by commas when not using exact matching
|
846 |
-
* - list_name string optional - only lists that match this name
|
847 |
-
* - from_name string optional - only lists that have a default from name matching this
|
848 |
-
* - from_email string optional - only lists that have a default from email matching this
|
849 |
-
* - from_subject string optional - only lists that have a default from email matching this
|
850 |
-
* - created_before string optional - only show lists that were created before this date+time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
|
851 |
-
* - created_after string optional - only show lists that were created since this date+time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
|
852 |
-
* - exact boolean optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true
|
853 |
-
* @param int $start
|
854 |
-
* @param int $limit
|
855 |
-
* @param string $sort_field
|
856 |
-
* @param string $sort_dir
|
857 |
-
* @return associative_array result of the operation including valid data and any errors
|
858 |
-
* - total int the total number of lists which matched the provided filters
|
859 |
-
* - data array structs for the lists which matched the provided filters, including the following
|
860 |
-
* - id string The list id for this list. This will be used for all other list management functions.
|
861 |
-
* - web_id int The list id used in our web app, allows you to create a link directly to it
|
862 |
-
* - name string The name of the list.
|
863 |
-
* - date_created string The date that this list was created.
|
864 |
-
* - email_type_option boolean Whether or not the List supports multiple formats for emails or just HTML
|
865 |
-
* - use_awesomebar boolean Whether or not campaigns for this list use the Awesome Bar in archives by default
|
866 |
-
* - default_from_name string Default From Name for campaigns using this list
|
867 |
-
* - default_from_email string Default From Email for campaigns using this list
|
868 |
-
* - default_subject string Default Subject Line for campaigns using this list
|
869 |
-
* - default_language string Default Language for this list's forms
|
870 |
-
* - list_rating double An auto-generated activity score for the list (0 - 5)
|
871 |
-
* - subscribe_url_short string Our eepurl shortened version of this list's subscribe form (will not change)
|
872 |
-
* - subscribe_url_long string The full version of this list's subscribe form (host will vary)
|
873 |
-
* - beamer_address string The email address to use for this list's <a href="http://kb.mailchimp.com/article/how-do-i-import-a-campaign-via-email-email-beamer/">Email Beamer</a>
|
874 |
-
* - visibility string Whether this list is Public (pub) or Private (prv). Used internally for projects like <a href="http://blog.mailchimp.com/introducing-wavelength/" target="_blank">Wavelength</a>
|
875 |
-
* - stats associative_array various stats and counts for the list - many of these are cached for at least 5 minutes
|
876 |
-
* - member_count double The number of active members in the given list.
|
877 |
-
* - unsubscribe_count double The number of members who have unsubscribed from the given list.
|
878 |
-
* - cleaned_count double The number of members cleaned from the given list.
|
879 |
-
* - member_count_since_send double The number of active members in the given list since the last campaign was sent
|
880 |
-
* - unsubscribe_count_since_send double The number of members who have unsubscribed from the given list since the last campaign was sent
|
881 |
-
* - cleaned_count_since_send double The number of members cleaned from the given list since the last campaign was sent
|
882 |
-
* - campaign_count double The number of campaigns in any status that use this list
|
883 |
-
* - grouping_count double The number of Interest Groupings for this list
|
884 |
-
* - group_count double The number of Interest Groups (regardless of grouping) for this list
|
885 |
-
* - merge_var_count double The number of merge vars for this list (not including the required EMAIL one)
|
886 |
-
* - avg_sub_rate double the average number of subscribe per month for the list (empty value if we haven't calculated this yet)
|
887 |
-
* - avg_unsub_rate double the average number of unsubscribe per month for the list (empty value if we haven't calculated this yet)
|
888 |
-
* - target_sub_rate double the target subscription rate for the list to keep it growing (empty value if we haven't calculated this yet)
|
889 |
-
* - open_rate double the average open rate per campaign for the list (empty value if we haven't calculated this yet)
|
890 |
-
* - click_rate double the average click rate per campaign for the list (empty value if we haven't calculated this yet)
|
891 |
-
* - modules array Any list specific modules installed for this list (example is SocialPro)
|
892 |
-
* - errors array structs of any errors found while loading lists - usually just from providing invalid list ids
|
893 |
-
* - param string the data that caused the failure
|
894 |
-
* - code int the error code
|
895 |
-
* - error string the error message
|
896 |
-
*/
|
897 |
-
public function getList($filters=array(), $start=0, $limit=25, $sort_field='created', $sort_dir='DESC') {
|
898 |
-
$_params = array("filters" => $filters, "start" => $start, "limit" => $limit, "sort_field" => $sort_field, "sort_dir" => $sort_dir);
|
899 |
-
return $this->master->call('lists/list', $_params);
|
900 |
-
}
|
901 |
-
|
902 |
-
}
|
903 |
-
|
904 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Mobile.php
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Mobile {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Neapolitan.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Neapolitan {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
}
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Reports.php
DELETED
@@ -1,459 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Reports {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Get all email addresses that complained about a given campaign
|
10 |
-
* @param string $cid
|
11 |
-
* @param associative_array $opts
|
12 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
13 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
14 |
-
* - since string optional pull only messages since this time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
|
15 |
-
* @return associative_array abuse report data for this campaign
|
16 |
-
* - total int the total reports matched
|
17 |
-
* - data array a struct for the each report, including:
|
18 |
-
* - date string date/time the abuse report was received and processed
|
19 |
-
* - member string the email address that reported abuse - will only contain email if the list or member has been removed
|
20 |
-
* - type string an internal type generally specifying the originating mail provider - may not be useful outside of filling report views
|
21 |
-
*/
|
22 |
-
public function abuse($cid, $opts=array()) {
|
23 |
-
$_params = array("cid" => $cid, "opts" => $opts);
|
24 |
-
return $this->master->call('reports/abuse', $_params);
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Retrieve the text presented in our app for how a campaign performed and any advice we may have for you - best
|
29 |
-
suited for display in customized reports pages. Note: some messages will contain HTML - clean tags as necessary
|
30 |
-
* @param string $cid
|
31 |
-
* @return array of structs for advice on the campaign's performance, each containing:
|
32 |
-
* - msg string the advice message
|
33 |
-
* - type string the "type" of the message. one of: negative, positive, or neutral
|
34 |
-
*/
|
35 |
-
public function advice($cid) {
|
36 |
-
$_params = array("cid" => $cid);
|
37 |
-
return $this->master->call('reports/advice', $_params);
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Retrieve the most recent full bounce message for a specific email address on the given campaign.
|
42 |
-
Messages over 30 days old are subject to being removed
|
43 |
-
* @param string $cid
|
44 |
-
* @param associative_array $email
|
45 |
-
* - email string an email address - this is recommended for this method
|
46 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
47 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
48 |
-
* @return associative_array the full bounce message for this email+campaign along with some extra data.
|
49 |
-
* - date string date the bounce was received and processed
|
50 |
-
* - member associative_array the member record as returned by lists/member-info()
|
51 |
-
* - message string the entire bounce message received
|
52 |
-
*/
|
53 |
-
public function bounceMessage($cid, $email) {
|
54 |
-
$_params = array("cid" => $cid, "email" => $email);
|
55 |
-
return $this->master->call('reports/bounce-message', $_params);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Retrieve the full bounce messages for the given campaign. Note that this can return very large amounts
|
60 |
-
of data depending on how large the campaign was and how much cruft the bounce provider returned. Also,
|
61 |
-
messages over 30 days old are subject to being removed
|
62 |
-
* @param string $cid
|
63 |
-
* @param associative_array $opts
|
64 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
65 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
66 |
-
* - since string optional pull only messages since this time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
|
67 |
-
* @return associative_array data for the full bounce messages for this campaign
|
68 |
-
* - total int that total number of bounce messages for the campaign
|
69 |
-
* - data array structs containing the data for this page
|
70 |
-
* - date string date the bounce was received and processed
|
71 |
-
* - member associative_array the member record as returned by lists/member-info()
|
72 |
-
* - message string the entire bounce message received
|
73 |
-
*/
|
74 |
-
public function bounceMessages($cid, $opts=array()) {
|
75 |
-
$_params = array("cid" => $cid, "opts" => $opts);
|
76 |
-
return $this->master->call('reports/bounce-messages', $_params);
|
77 |
-
}
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Return the list of email addresses that clicked on a given url, and how many times they clicked
|
81 |
-
* @param string $cid
|
82 |
-
* @param int $tid
|
83 |
-
* @param associative_array $opts
|
84 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
85 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
86 |
-
* - sort_field string optional the data to sort by - "clicked" (order clicks occurred, default) or "clicks" (total number of opens). Invalid fields will fall back on the default.
|
87 |
-
* - sort_dir string optional the direct - ASC or DESC. defaults to ASC (case insensitive)
|
88 |
-
* @return associative_array containing the total records matched and the specific records for this page
|
89 |
-
* - total int the total number of records matched
|
90 |
-
* - data array structs for each email addresses that click the requested url
|
91 |
-
* - member associative_array the member record as returned by lists/member-info()
|
92 |
-
* - clicks int Total number of times the URL was clicked by this email address
|
93 |
-
*/
|
94 |
-
public function clickDetail($cid, $tid, $opts=array()) {
|
95 |
-
$_params = array("cid" => $cid, "tid" => $tid, "opts" => $opts);
|
96 |
-
return $this->master->call('reports/click-detail', $_params);
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* The urls tracked and their click counts for a given campaign.
|
101 |
-
* @param string $cid
|
102 |
-
* @return associative_array including:
|
103 |
-
* - total array structs for each url tracked for the full campaign
|
104 |
-
* - url string the url being tracked - urls are tracked individually, so duplicates can exist with vastly different stats
|
105 |
-
* - clicks int Number of times the specific link was clicked
|
106 |
-
* - clicks_percent double the percentage of total clicks "clicks" represents
|
107 |
-
* - unique int Number of unique people who clicked on the specific link
|
108 |
-
* - unique_percent double the percentage of unique clicks "unique" represents
|
109 |
-
* - tid int the tracking id used in campaign links - used primarily for reports/click-activity. also can be used to order urls by the order they appeared in the campaign to recreate our heat map.
|
110 |
-
* - a array if this was an absplit campaign, stat structs for the a group
|
111 |
-
* - url string the url being tracked - urls are tracked individually, so duplicates can exist with vastly different stats
|
112 |
-
* - clicks int Number of times the specific link was clicked
|
113 |
-
* - clicks_percent double the percentage of total clicks "clicks" represents
|
114 |
-
* - unique int Number of unique people who clicked on the specific link
|
115 |
-
* - unique_percent double the percentage of unique clicks "unique" represents
|
116 |
-
* - tid int the tracking id used in campaign links - used primarily for reports/click-activity. also can be used to order urls by the order they appeared in the campaign to recreate our heat map.
|
117 |
-
* - b array if this was an absplit campaign, stat structs for the b group
|
118 |
-
* - url string the url being tracked - urls are tracked individually, so duplicates can exist with vastly different stats
|
119 |
-
* - clicks int Number of times the specific link was clicked
|
120 |
-
* - clicks_percent double the percentage of total clicks "clicks" represents
|
121 |
-
* - unique int Number of unique people who clicked on the specific link
|
122 |
-
* - unique_percent double the percentage of unique clicks "unique" represents
|
123 |
-
* - tid int the tracking id used in campaign links - used primarily for reports/click-activity. also can be used to order urls by the order they appeared in the campaign to recreate our heat map.
|
124 |
-
*/
|
125 |
-
public function clicks($cid) {
|
126 |
-
$_params = array("cid" => $cid);
|
127 |
-
return $this->master->call('reports/clicks', $_params);
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Retrieve the Ecommerce Orders tracked by ecomm/order-add()
|
132 |
-
* @param string $cid
|
133 |
-
* @param associative_array $opts
|
134 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
135 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
136 |
-
* - since string optional pull only messages since this time - 24 hour format in <strong>GMT</strong>, eg "2013-12-30 20:30:00"
|
137 |
-
* @return associative_array the total matching orders and the specific orders for the requested page
|
138 |
-
* - total int the total matching orders
|
139 |
-
* - data array structs for the actual data for each order being returned
|
140 |
-
* - store_id string the store id generated by the plugin used to uniquely identify a store
|
141 |
-
* - store_name string the store name collected by the plugin - often the domain name
|
142 |
-
* - order_id string the internal order id the store tracked this order by
|
143 |
-
* - member associative_array the member record as returned by lists/member-info() that received this campaign and is associated with this order
|
144 |
-
* - order_total double the order total
|
145 |
-
* - tax_total double the total tax for the order (if collected)
|
146 |
-
* - ship_total double the shipping total for the order (if collected)
|
147 |
-
* - order_date string the date the order was tracked - from the store if possible, otherwise the GMT time we received it
|
148 |
-
* - lines array structs containing details of the order:
|
149 |
-
* - line_num int the line number assigned to this line
|
150 |
-
* - product_id int the product id assigned to this item
|
151 |
-
* - product_name string the product name
|
152 |
-
* - product_sku string the sku for the product
|
153 |
-
* - product_category_id int the id for the product category
|
154 |
-
* - product_category_name string the product category name
|
155 |
-
* - qty double optional the quantity of the item ordered - defaults to 1
|
156 |
-
* - cost double optional the cost of a single item (ie, not the extended cost of the line) - defaults to 0
|
157 |
-
*/
|
158 |
-
public function ecommOrders($cid, $opts=array()) {
|
159 |
-
$_params = array("cid" => $cid, "opts" => $opts);
|
160 |
-
return $this->master->call('reports/ecomm-orders', $_params);
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Retrieve the eepurl stats from the web/Twitter mentions for this campaign
|
165 |
-
* @param string $cid
|
166 |
-
* @return associative_array containing tweets, retweets, clicks, and referrer related to using the campaign's eepurl
|
167 |
-
* - twitter associative_array various Twitter related stats
|
168 |
-
* - tweets int Total number of tweets seen
|
169 |
-
* - first_tweet string date and time of the first tweet seen
|
170 |
-
* - last_tweet string date and time of the last tweet seen
|
171 |
-
* - retweets int Total number of retweets seen
|
172 |
-
* - first_retweet string date and time of the first retweet seen
|
173 |
-
* - last_retweet string date and time of the last retweet seen
|
174 |
-
* - statuses array an structs for statuses recorded including:
|
175 |
-
* - status string the text of the tweet/update
|
176 |
-
* - screen_name string the screen name as recorded when first seen
|
177 |
-
* - status_id string the status id of the tweet (they are really unsigned 64 bit ints)
|
178 |
-
* - datetime string the date/time of the tweet
|
179 |
-
* - is_retweet bool whether or not this was a retweet
|
180 |
-
* - clicks associative_array stats related to click-throughs on the eepurl
|
181 |
-
* - clicks int Total number of clicks seen
|
182 |
-
* - first_click string date and time of the first click seen
|
183 |
-
* - last_click string date and time of the first click seen
|
184 |
-
* - locations array structs for geographic locations including:
|
185 |
-
* - country string the country name the click was tracked to
|
186 |
-
* - region string the region in the country the click was tracked to (if available)
|
187 |
-
* - referrers array structs for referrers, including
|
188 |
-
* - referrer string the referrer, truncated to 100 bytes
|
189 |
-
* - clicks int Total number of clicks seen from this referrer
|
190 |
-
* - first_click string date and time of the first click seen from this referrer
|
191 |
-
* - last_click string date and time of the first click seen from this referrer
|
192 |
-
*/
|
193 |
-
public function eepurl($cid) {
|
194 |
-
$_params = array("cid" => $cid);
|
195 |
-
return $this->master->call('reports/eepurl', $_params);
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Given a campaign and email address, return the entire click and open history with timestamps, ordered by time. If you need to dump the full activity for a campaign
|
200 |
-
and/or get incremental results, you should use the <a href="http://apidocs.mailchimp.com/export/1.0/campaignsubscriberactivity.func.php" targret="_new">campaignSubscriberActivity Export API method</a>,
|
201 |
-
<strong>not</strong> this, especially for large campaigns.
|
202 |
-
* @param string $cid
|
203 |
-
* @param array $emails
|
204 |
-
* - email string an email address
|
205 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
206 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
207 |
-
* @return associative_array of data and success/error counts
|
208 |
-
* - success_count int the number of subscribers successfully found on the list
|
209 |
-
* - error_count int the number of subscribers who were not found on the list
|
210 |
-
* - errors array array of error structs including:
|
211 |
-
* - email string whatever was passed in the email parameter
|
212 |
-
* - email string the email address added
|
213 |
-
* - euid string the email unique id
|
214 |
-
* - leid string the list member's truly unique id
|
215 |
-
* - msg string the error message
|
216 |
-
* - data array an array of structs where each activity record has:
|
217 |
-
* - email string whatever was passed in the email parameter
|
218 |
-
* - email string the email address added
|
219 |
-
* - euid string the email unique id
|
220 |
-
* - leid string the list member's truly unique id
|
221 |
-
* - member associative_array the member record as returned by lists/member-info()
|
222 |
-
* - activity array an array of structs containing the activity, including:
|
223 |
-
* - action string The action name - either open or click
|
224 |
-
* - timestamp string The date/time of the action (GMT)
|
225 |
-
* - url string For click actions, the url clicked, otherwise this is empty
|
226 |
-
* - ip string The IP address the activity came from
|
227 |
-
*/
|
228 |
-
public function memberActivity($cid, $emails) {
|
229 |
-
$_params = array("cid" => $cid, "emails" => $emails);
|
230 |
-
return $this->master->call('reports/member-activity', $_params);
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Retrieve the list of email addresses that did not open a given campaign
|
235 |
-
* @param string $cid
|
236 |
-
* @param associative_array $opts
|
237 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
238 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
239 |
-
* @return associative_array a total of all matching emails and the specific emails for this page
|
240 |
-
* - total int the total number of members who didn't open the campaign
|
241 |
-
* - data array structs for each campaign member matching as returned by lists/member-info()
|
242 |
-
*/
|
243 |
-
public function notOpened($cid, $opts=array()) {
|
244 |
-
$_params = array("cid" => $cid, "opts" => $opts);
|
245 |
-
return $this->master->call('reports/not-opened', $_params);
|
246 |
-
}
|
247 |
-
|
248 |
-
/**
|
249 |
-
* Retrieve the list of email addresses that opened a given campaign with how many times they opened
|
250 |
-
* @param string $cid
|
251 |
-
* @param associative_array $opts
|
252 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
253 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
254 |
-
* - sort_field string optional the data to sort by - "opened" (order opens occurred, default) or "opens" (total number of opens). Invalid fields will fall back on the default.
|
255 |
-
* - sort_dir string optional the direct - ASC or DESC. defaults to ASC (case insensitive)
|
256 |
-
* @return associative_array containing the total records matched and the specific records for this page
|
257 |
-
* - total int the total number of records matched
|
258 |
-
* - data array structs for the actual opens data, including:
|
259 |
-
* - member associative_array the member record as returned by lists/member-info()
|
260 |
-
* - opens int Total number of times the campaign was opened by this email address
|
261 |
-
*/
|
262 |
-
public function opened($cid, $opts=array()) {
|
263 |
-
$_params = array("cid" => $cid, "opts" => $opts);
|
264 |
-
return $this->master->call('reports/opened', $_params);
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Get the top 5 performing email domains for this campaign. Users wanting more than 5 should use campaign reports/member-activity()
|
269 |
-
or campaignEmailStatsAIMAll() and generate any additional stats they require.
|
270 |
-
* @param string $cid
|
271 |
-
* @return array domains structs for each email domains and their associated stats
|
272 |
-
* - domain string Domain name or special "Other" to roll-up stats past 5 domains
|
273 |
-
* - total_sent int Total Email across all domains - this will be the same in every row
|
274 |
-
* - emails int Number of emails sent to this domain
|
275 |
-
* - bounces int Number of bounces
|
276 |
-
* - opens int Number of opens
|
277 |
-
* - clicks int Number of clicks
|
278 |
-
* - unsubs int Number of unsubs
|
279 |
-
* - delivered int Number of deliveries
|
280 |
-
* - emails_pct int Percentage of emails that went to this domain (whole number)
|
281 |
-
* - bounces_pct int Percentage of bounces from this domain (whole number)
|
282 |
-
* - opens_pct int Percentage of opens from this domain (whole number)
|
283 |
-
* - clicks_pct int Percentage of clicks from this domain (whole number)
|
284 |
-
* - unsubs_pct int Percentage of unsubs from this domain (whole number)
|
285 |
-
*/
|
286 |
-
public function domainPerformance($cid) {
|
287 |
-
$_params = array("cid" => $cid);
|
288 |
-
return $this->master->call('reports/domain-performance', $_params);
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* Retrieve the countries/regions and number of opens tracked for each. Email address are not returned.
|
293 |
-
* @param string $cid
|
294 |
-
* @return array an array of country structs where opens occurred
|
295 |
-
* - code string The ISO3166 2 digit country code
|
296 |
-
* - name string A version of the country name, if we have it
|
297 |
-
* - opens int The total number of opens that occurred in the country
|
298 |
-
* - regions array structs of data for each sub-region in the country
|
299 |
-
* - code string An internal code for the region. When this is blank, it indicates we know the country, but not the region
|
300 |
-
* - name string The name of the region, if we have one. For blank "code" values, this will be "Rest of Country"
|
301 |
-
* - opens int The total number of opens that occurred in the country
|
302 |
-
*/
|
303 |
-
public function geoOpens($cid) {
|
304 |
-
$_params = array("cid" => $cid);
|
305 |
-
return $this->master->call('reports/geo-opens', $_params);
|
306 |
-
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* Retrieve the Google Analytics data we've collected for this campaign. Note, requires Google Analytics Add-on to be installed and configured.
|
310 |
-
* @param string $cid
|
311 |
-
* @return array of structs for analytics we've collected for the passed campaign.
|
312 |
-
* - visits int number of visits
|
313 |
-
* - pages int number of page views
|
314 |
-
* - new_visits int new visits recorded
|
315 |
-
* - bounces int vistors who "bounced" from your site
|
316 |
-
* - time_on_site double the total time visitors spent on your sites
|
317 |
-
* - goal_conversions int number of goals converted
|
318 |
-
* - goal_value double value of conversion in dollars
|
319 |
-
* - revenue double revenue generated by campaign
|
320 |
-
* - transactions int number of transactions tracked
|
321 |
-
* - ecomm_conversions int number Ecommerce transactions tracked
|
322 |
-
* - goals array structs containing goal names and number of conversions
|
323 |
-
* - name string the name of the goal
|
324 |
-
* - conversions int the number of conversions for the goal
|
325 |
-
*/
|
326 |
-
public function googleAnalytics($cid) {
|
327 |
-
$_params = array("cid" => $cid);
|
328 |
-
return $this->master->call('reports/google-analytics', $_params);
|
329 |
-
}
|
330 |
-
|
331 |
-
/**
|
332 |
-
* Get email addresses the campaign was sent to
|
333 |
-
* @param string $cid
|
334 |
-
* @param associative_array $opts
|
335 |
-
* - status string optional the status to pull - one of 'sent', 'hard' (bounce), or 'soft' (bounce). By default, all records are returned
|
336 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
337 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
338 |
-
* @return associative_array a total of all matching emails and the specific emails for this page
|
339 |
-
* - total int the total number of members for the campaign and status
|
340 |
-
* - data array structs for each campaign member matching
|
341 |
-
* - member associative_array the member record as returned by lists/member-info()
|
342 |
-
* - status string the status of the send - one of 'sent', 'hard', 'soft'
|
343 |
-
* - absplit_group string if this was an absplit campaign, one of 'a','b', or 'winner'
|
344 |
-
* - tz_group string if this was an timewarp campaign the timezone GMT offset the member was included in
|
345 |
-
*/
|
346 |
-
public function sentTo($cid, $opts=array()) {
|
347 |
-
$_params = array("cid" => $cid, "opts" => $opts);
|
348 |
-
return $this->master->call('reports/sent-to', $_params);
|
349 |
-
}
|
350 |
-
|
351 |
-
/**
|
352 |
-
* Get the URL to a customized <a href="http://eepurl.com/gKmL" target="_blank">VIP Report</a> for the specified campaign and optionally send an email to someone with links to it. Note subsequent calls will overwrite anything already set for the same campign (eg, the password)
|
353 |
-
* @param string $cid
|
354 |
-
* @param array $opts
|
355 |
-
* - to_email string optional - optional, comma delimited list of email addresses to share the report with - no value means an email will not be sent
|
356 |
-
* - theme_id int optional - either a global or a user-specific theme id. Currently this needs to be pulled out of either the Share Report or Cobranding web views by grabbing the "theme" attribute from the list presented.
|
357 |
-
* - css_url string optional - a link to an external CSS file to be included after our default CSS (http://vip-reports.net/css/vip.css) <strong>only if</strong> loaded via the "secure_url" - max 255 bytes
|
358 |
-
* @return associative_array details for the shared report, including:
|
359 |
-
* - title string The Title of the Campaign being shared
|
360 |
-
* - url string The URL to the shared report
|
361 |
-
* - secure_url string The URL to the shared report, including the password (good for loading in an IFRAME). For non-secure reports, this will not be returned
|
362 |
-
* - password string If secured, the password for the report, otherwise this field will not be returned
|
363 |
-
*/
|
364 |
-
public function share($cid, $opts=array()) {
|
365 |
-
$_params = array("cid" => $cid, "opts" => $opts);
|
366 |
-
return $this->master->call('reports/share', $_params);
|
367 |
-
}
|
368 |
-
|
369 |
-
/**
|
370 |
-
* Retrieve relevant aggregate campaign statistics (opens, bounces, clicks, etc.)
|
371 |
-
* @param string $cid
|
372 |
-
* @return associative_array the statistics for this campaign
|
373 |
-
* - syntax_errors int Number of email addresses in campaign that had syntactical errors.
|
374 |
-
* - hard_bounces int Number of email addresses in campaign that hard bounced.
|
375 |
-
* - soft_bounces int Number of email addresses in campaign that soft bounced.
|
376 |
-
* - unsubscribes int Number of email addresses in campaign that unsubscribed.
|
377 |
-
* - abuse_reports int Number of email addresses in campaign that reported campaign for abuse.
|
378 |
-
* - forwards int Number of times email was forwarded to a friend.
|
379 |
-
* - forwards_opens int Number of times a forwarded email was opened.
|
380 |
-
* - opens int Number of times the campaign was opened.
|
381 |
-
* - last_open string Date of the last time the email was opened.
|
382 |
-
* - unique_opens int Number of people who opened the campaign.
|
383 |
-
* - clicks int Number of times a link in the campaign was clicked.
|
384 |
-
* - unique_clicks int Number of unique recipient/click pairs for the campaign.
|
385 |
-
* - last_click string Date of the last time a link in the email was clicked.
|
386 |
-
* - users_who_clicked int Number of unique recipients who clicked on a link in the campaign.
|
387 |
-
* - emails_sent int Number of email addresses campaign was sent to.
|
388 |
-
* - unique_likes int total number of unique likes (Facebook)
|
389 |
-
* - recipient_likes int total number of recipients who liked (Facebook) the campaign
|
390 |
-
* - facebook_likes int total number of likes (Facebook) that came from Facebook
|
391 |
-
* - industry associative_array Various rates/percentages for the account's selected industry - empty otherwise. These will vary across calls, do not use them for anything important.
|
392 |
-
* - type string the selected industry
|
393 |
-
* - open_rate float industry open rate
|
394 |
-
* - click_rate float industry click rate
|
395 |
-
* - bounce_rate float industry bounce rate
|
396 |
-
* - unopen_rate float industry unopen rate
|
397 |
-
* - unsub_rate float industry unsub rate
|
398 |
-
* - abuse_rate float industry abuse rate
|
399 |
-
* - absplit associative_array If this was an absplit campaign, stats for the A and B groups will be returned - otherwise this is empty
|
400 |
-
* - bounces_a int bounces for the A group
|
401 |
-
* - bounces_b int bounces for the B group
|
402 |
-
* - forwards_a int forwards for the A group
|
403 |
-
* - forwards_b int forwards for the B group
|
404 |
-
* - abuse_reports_a int abuse reports for the A group
|
405 |
-
* - abuse_reports_b int abuse reports for the B group
|
406 |
-
* - unsubs_a int unsubs for the A group
|
407 |
-
* - unsubs_b int unsubs for the B group
|
408 |
-
* - recipients_click_a int clicks for the A group
|
409 |
-
* - recipients_click_b int clicks for the B group
|
410 |
-
* - forwards_opens_a int opened forwards for the A group
|
411 |
-
* - forwards_opens_b int opened forwards for the B group
|
412 |
-
* - opens_a int total opens for the A group
|
413 |
-
* - opens_b int total opens for the B group
|
414 |
-
* - last_open_a string date/time of last open for the A group
|
415 |
-
* - last_open_b string date/time of last open for the BG group
|
416 |
-
* - unique_opens_a int unique opens for the A group
|
417 |
-
* - unique_opens_b int unique opens for the B group
|
418 |
-
* - timewarp array If this campaign was a Timewarp campaign, an array of structs from each timezone stats exist for. Each will contain:
|
419 |
-
* - opens int opens for this timezone
|
420 |
-
* - last_open string the date/time of the last open for this timezone
|
421 |
-
* - unique_opens int the unique opens for this timezone
|
422 |
-
* - clicks int the total clicks for this timezone
|
423 |
-
* - last_click string the date/time of the last click for this timezone
|
424 |
-
* - unique_opens int the unique clicks for this timezone
|
425 |
-
* - bounces int the total bounces for this timezone
|
426 |
-
* - total int the total number of members sent to in this timezone
|
427 |
-
* - sent int the total number of members delivered to in this timezone
|
428 |
-
* - timeseries array structs for the first 24 hours of the campaign, per-hour stats:
|
429 |
-
* - timestamp string The timestemp in Y-m-d H:00:00 format
|
430 |
-
* - emails_sent int the total emails sent during the hour
|
431 |
-
* - unique_opens int unique opens seen during the hour
|
432 |
-
* - recipients_click int unique clicks seen during the hour
|
433 |
-
*/
|
434 |
-
public function summary($cid) {
|
435 |
-
$_params = array("cid" => $cid);
|
436 |
-
return $this->master->call('reports/summary', $_params);
|
437 |
-
}
|
438 |
-
|
439 |
-
/**
|
440 |
-
* Get all unsubscribed email addresses for a given campaign
|
441 |
-
* @param string $cid
|
442 |
-
* @param associative_array $opts
|
443 |
-
* - start int optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
|
444 |
-
* - limit int optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100
|
445 |
-
* @return associative_array a total of all unsubscribed emails and the specific members for this page
|
446 |
-
* - total int the total number of unsubscribes for the campaign
|
447 |
-
* - data array structs for the email addresses that unsubscribed
|
448 |
-
* - member string the member that unsubscribed as returned by lists/member-info()
|
449 |
-
* - reason string the reason collected for the unsubscribe. If populated, one of 'NORMAL','NOSIGNUP','INAPPROPRIATE','SPAM','OTHER'
|
450 |
-
* - reason_text string if the reason is OTHER, the text entered.
|
451 |
-
*/
|
452 |
-
public function unsubscribes($cid, $opts=array()) {
|
453 |
-
$_params = array("cid" => $cid, "opts" => $opts);
|
454 |
-
return $this->master->call('reports/unsubscribes', $_params);
|
455 |
-
}
|
456 |
-
|
457 |
-
}
|
458 |
-
|
459 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Templates.php
DELETED
@@ -1,114 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Templates {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Create a new user template, <strong>NOT</strong> campaign content. These templates can then be applied while creating campaigns.
|
10 |
-
* @param string $name
|
11 |
-
* @param string $html
|
12 |
-
* @param int $folder_id
|
13 |
-
* @return associative_array with a single element:
|
14 |
-
* - template_id int the new template id, otherwise an error is thrown.
|
15 |
-
*/
|
16 |
-
public function add($name, $html, $folder_id=null) {
|
17 |
-
$_params = array("name" => $name, "html" => $html, "folder_id" => $folder_id);
|
18 |
-
return $this->master->call('templates/add', $_params);
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Delete (deactivate) a user template
|
23 |
-
* @param int $template_id
|
24 |
-
* @return associative_array with a single entry:
|
25 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
26 |
-
*/
|
27 |
-
public function del($template_id) {
|
28 |
-
$_params = array("template_id" => $template_id);
|
29 |
-
return $this->master->call('templates/del', $_params);
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Pull details for a specific template to help support editing
|
34 |
-
* @param int $template_id
|
35 |
-
* @param string $type
|
36 |
-
* @return associative_array info to be used when editing
|
37 |
-
* - default_content associative_array the default content broken down into the named editable sections for the template - dependant upon template, so not documented
|
38 |
-
* - sections associative_array the valid editable section names - dependant upon template, so not documented
|
39 |
-
* - source string the full source of the template as if you exported it via our template editor
|
40 |
-
* - preview string similar to the source, but the rendered version of the source from our popup preview
|
41 |
-
*/
|
42 |
-
public function info($template_id, $type='user') {
|
43 |
-
$_params = array("template_id" => $template_id, "type" => $type);
|
44 |
-
return $this->master->call('templates/info', $_params);
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Retrieve various templates available in the system, allowing some thing similar to our template gallery to be created.
|
49 |
-
* @param associative_array $types
|
50 |
-
* - user boolean Custom templates for this user account. Defaults to true.
|
51 |
-
* - gallery boolean Templates from our Gallery. Note that some templates that require extra configuration are withheld. (eg, the Etsy template). Defaults to false.
|
52 |
-
* - base boolean Our "start from scratch" extremely basic templates. Defaults to false. As of the 9.0 update, "base" templates are no longer available via the API because they are now all saved Drag & Drop templates.
|
53 |
-
* @param associative_array $filters
|
54 |
-
* - category string optional for Gallery templates only, limit to a specific template category
|
55 |
-
* - folder_id string user templates, limit to this folder_id
|
56 |
-
* - include_inactive boolean user templates are not deleted, only set inactive. defaults to false.
|
57 |
-
* - inactive_only boolean only include inactive user templates. defaults to false.
|
58 |
-
* - include_drag_and_drop boolean Include templates created and saved using the new Drag & Drop editor. <strong>Note:</strong> You will not be able to edit or create new drag & drop templates via this API. This is useful only for creating a new campaign based on a drag & drop template.
|
59 |
-
* @return associative_array for each type
|
60 |
-
* - user array matching user templates, if requested.
|
61 |
-
* - id int Id of the template
|
62 |
-
* - name string Name of the template
|
63 |
-
* - layout string General description of the layout of the template
|
64 |
-
* - category string The category for the template, if there is one.
|
65 |
-
* - preview_image string If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available
|
66 |
-
* - date_created string The date/time the template was created
|
67 |
-
* - active boolean whether or not the template is active and available for use.
|
68 |
-
* - edit_source boolean Whether or not you are able to edit the source of a template.
|
69 |
-
* - folder_id boolean if it's in one, the folder id
|
70 |
-
* - gallery array matching gallery templates, if requested.
|
71 |
-
* - id int Id of the template
|
72 |
-
* - name string Name of the template
|
73 |
-
* - layout string General description of the layout of the template
|
74 |
-
* - category string The category for the template, if there is one.
|
75 |
-
* - preview_image string If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available
|
76 |
-
* - date_created string The date/time the template was created
|
77 |
-
* - active boolean whether or not the template is active and available for use.
|
78 |
-
* - edit_source boolean Whether or not you are able to edit the source of a template.
|
79 |
-
* - base array matching base templates, if requested. (Will always be empty as of 9.0)
|
80 |
-
*/
|
81 |
-
public function getList($types=array(), $filters=array()) {
|
82 |
-
$_params = array("types" => $types, "filters" => $filters);
|
83 |
-
return $this->master->call('templates/list', $_params);
|
84 |
-
}
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Undelete (reactivate) a user template
|
88 |
-
* @param int $template_id
|
89 |
-
* @return associative_array with a single entry:
|
90 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
91 |
-
*/
|
92 |
-
public function undel($template_id) {
|
93 |
-
$_params = array("template_id" => $template_id);
|
94 |
-
return $this->master->call('templates/undel', $_params);
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* Replace the content of a user template, <strong>NOT</strong> campaign content.
|
99 |
-
* @param int $template_id
|
100 |
-
* @param associative_array $values
|
101 |
-
* - name string the name for the template - names must be unique and a max of 50 bytes
|
102 |
-
* - html string a string specifying the entire template to be created. This is <strong>NOT</strong> campaign content. They are intended to utilize our <a href="http://www.mailchimp.com/resources/email-template-language/" target="_blank">template language</a>.
|
103 |
-
* - folder_id int the folder to put this template in - 0 or a blank values will remove it from a folder.
|
104 |
-
* @return associative_array with a single entry:
|
105 |
-
* - complete bool whether the call worked. reallistically this will always be true as errors will be thrown otherwise.
|
106 |
-
*/
|
107 |
-
public function update($template_id, $values) {
|
108 |
-
$_params = array("template_id" => $template_id, "values" => $values);
|
109 |
-
return $this->master->call('templates/update', $_params);
|
110 |
-
}
|
111 |
-
|
112 |
-
}
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Users.php
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Users {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Invite a user to your account
|
10 |
-
* @param string $email
|
11 |
-
* @param string $role
|
12 |
-
* @param string $msg
|
13 |
-
* @return associative_array the method completion status
|
14 |
-
* - status string The status (success) of the call if it completed. Otherwise an error is thrown.
|
15 |
-
*/
|
16 |
-
public function invite($email, $role='viewer', $msg='') {
|
17 |
-
$_params = array("email" => $email, "role" => $role, "msg" => $msg);
|
18 |
-
return $this->master->call('users/invite', $_params);
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Resend an invite a user to your account. Note, if the same address has been invited multiple times, this will simpy re-send the most recent invite
|
23 |
-
* @param string $email
|
24 |
-
* @return associative_array the method completion status
|
25 |
-
* - status string The status (success) of the call if it completed. Otherwise an error is thrown.
|
26 |
-
*/
|
27 |
-
public function inviteResend($email) {
|
28 |
-
$_params = array("email" => $email);
|
29 |
-
return $this->master->call('users/invite-resend', $_params);
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Revoke an invitation sent to a user to your account. Note, if the same address has been invited multiple times, this will simpy revoke the most recent invite
|
34 |
-
* @param string $email
|
35 |
-
* @return associative_array the method completion status
|
36 |
-
* - status string The status (success) of the call if it completed. Otherwise an error is thrown.
|
37 |
-
*/
|
38 |
-
public function inviteRevoke($email) {
|
39 |
-
$_params = array("email" => $email);
|
40 |
-
return $this->master->call('users/invite-revoke', $_params);
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Retrieve the list of pending users invitations have been sent for.
|
45 |
-
* @return array structs for each invitation, including:
|
46 |
-
* - email string the email address the invitation was sent to
|
47 |
-
* - role string the role that will be assigned if they accept
|
48 |
-
* - sent_at string the time the invitation was sent. this will change if it's resent.
|
49 |
-
* - expiration string the expiration time for the invitation. this will change if it's resent.
|
50 |
-
* - msg string the welcome message included with the invitation
|
51 |
-
*/
|
52 |
-
public function invites() {
|
53 |
-
$_params = array();
|
54 |
-
return $this->master->call('users/invites', $_params);
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Revoke access for a specified login
|
59 |
-
* @param string $username
|
60 |
-
* @return associative_array the method completion status
|
61 |
-
* - status string The status (success) of the call if it completed. Otherwise an error is thrown.
|
62 |
-
*/
|
63 |
-
public function loginRevoke($username) {
|
64 |
-
$_params = array("username" => $username);
|
65 |
-
return $this->master->call('users/login-revoke', $_params);
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Retrieve the list of active logins.
|
70 |
-
* @return array structs for each user, including:
|
71 |
-
* - id int the login id for this login
|
72 |
-
* - username string the username used to log in
|
73 |
-
* - name string a display name for the account - empty first/last names will return the username
|
74 |
-
* - email string the email tied to the account used for passwords resets and the ilk
|
75 |
-
* - role string the role assigned to the account
|
76 |
-
* - avatar string if available, the url for the login's avatar
|
77 |
-
* - global_user_id int the globally unique user id for the user account connected to
|
78 |
-
* - dc_unique_id string the datacenter unique id for the user account connected to, like helper/account-details
|
79 |
-
*/
|
80 |
-
public function logins() {
|
81 |
-
$_params = array();
|
82 |
-
return $this->master->call('users/logins', $_params);
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Retrieve the profile for the login owning the provided API Key
|
87 |
-
* @return associative_array the current user's details, including:
|
88 |
-
* - id int the login id for this login
|
89 |
-
* - username string the username used to log in
|
90 |
-
* - name string a display name for the account - empty first/last names will return the username
|
91 |
-
* - email string the email tied to the account used for passwords resets and the ilk
|
92 |
-
* - role string the role assigned to the account
|
93 |
-
* - avatar string if available, the url for the login's avatar
|
94 |
-
* - global_user_id int the globally unique user id for the user account connected to
|
95 |
-
* - dc_unique_id string the datacenter unique id for the user account connected to, like helper/account-details
|
96 |
-
* - account_name string The name of the account to which the API key belongs
|
97 |
-
*/
|
98 |
-
public function profile() {
|
99 |
-
$_params = array();
|
100 |
-
return $this->master->call('users/profile', $_params);
|
101 |
-
}
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Mailchimp/Vip.php
DELETED
@@ -1,111 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Mailchimp_Vip {
|
4 |
-
public function __construct(Mailchimp $master) {
|
5 |
-
$this->master = $master;
|
6 |
-
}
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Retrieve all Activity (opens/clicks) for VIPs over the past 10 days
|
10 |
-
* @return array structs for each activity recorded.
|
11 |
-
* - action string The action taken - either "open" or "click"
|
12 |
-
* - timestamp string The datetime the action occurred in GMT
|
13 |
-
* - url string IF the action is a click, the url that was clicked
|
14 |
-
* - unique_id string The campaign_id of the List the Member appears on
|
15 |
-
* - title string The campaign title
|
16 |
-
* - list_name string The name of the List the Member appears on
|
17 |
-
* - list_id string The id of the List the Member appears on
|
18 |
-
* - email string The email address of the member
|
19 |
-
* - fname string IF a FNAME merge field exists on the list, that value for the member
|
20 |
-
* - lname string IF a LNAME merge field exists on the list, that value for the member
|
21 |
-
* - member_rating int the rating of the subscriber. This will be 1 - 5 as described <a href="http://eepurl.com/f-2P" target="_blank">here</a>
|
22 |
-
* - member_since string the datetime the member was added and/or confirmed
|
23 |
-
* - geo associative_array the geographic information if we have it. including:
|
24 |
-
* - latitude string the latitude
|
25 |
-
* - longitude string the longitude
|
26 |
-
* - gmtoff string GMT offset
|
27 |
-
* - dstoff string GMT offset during daylight savings (if DST not observered, will be same as gmtoff
|
28 |
-
* - timezone string the timezone we've place them in
|
29 |
-
* - cc string 2 digit ISO-3166 country code
|
30 |
-
* - region string generally state, province, or similar
|
31 |
-
*/
|
32 |
-
public function activity() {
|
33 |
-
$_params = array();
|
34 |
-
return $this->master->call('vip/activity', $_params);
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Add VIPs (previously called Golden Monkeys)
|
39 |
-
* @param string $id
|
40 |
-
* @param array $emails
|
41 |
-
* - email string an email address - for new subscribers obviously this should be used
|
42 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
43 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
44 |
-
* @return associative_array of data and success/error counts
|
45 |
-
* - success_count int the number of successful adds
|
46 |
-
* - error_count int the number of unsuccessful adds
|
47 |
-
* - errors array array of error structs including:
|
48 |
-
* - email associative_array whatever was passed in the email parameter
|
49 |
-
* - email string the email address added
|
50 |
-
* - euid string the email unique id
|
51 |
-
* - leid string the list member's truly unique id
|
52 |
-
* - code string the error code
|
53 |
-
* - error string the error message
|
54 |
-
* - data array array of structs for each member added
|
55 |
-
* - email associative_array whatever was passed in the email parameter
|
56 |
-
* - email string the email address added
|
57 |
-
* - euid string the email unique id
|
58 |
-
* - leid string the list member's truly unique id
|
59 |
-
*/
|
60 |
-
public function add($id, $emails) {
|
61 |
-
$_params = array("id" => $id, "emails" => $emails);
|
62 |
-
return $this->master->call('vip/add', $_params);
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Remove VIPs - this does not affect list membership
|
67 |
-
* @param string $id
|
68 |
-
* @param array $emails
|
69 |
-
* - email string an email address - for new subscribers obviously this should be used
|
70 |
-
* - euid string the unique id for an email address (not list related) - the email "id" returned from listMemberInfo, Webhooks, Campaigns, etc.
|
71 |
-
* - leid string the list email id (previously called web_id) for a list-member-info type call. this doesn't change when the email address changes
|
72 |
-
* @return associative_array of data and success/error counts
|
73 |
-
* - success_count int the number of successful deletions
|
74 |
-
* - error_count int the number of unsuccessful deletions
|
75 |
-
* - errors array array of error structs including:
|
76 |
-
* - email associative_array whatever was passed in the email parameter
|
77 |
-
* - email string the email address
|
78 |
-
* - euid string the email unique id
|
79 |
-
* - leid string the list member's truly unique id
|
80 |
-
* - code string the error code
|
81 |
-
* - msg string the error message
|
82 |
-
* - data array array of structs for each member deleted
|
83 |
-
* - email associative_array whatever was passed in the email parameter
|
84 |
-
* - email string the email address
|
85 |
-
* - euid string the email unique id
|
86 |
-
* - leid string the list member's truly unique id
|
87 |
-
*/
|
88 |
-
public function del($id, $emails) {
|
89 |
-
$_params = array("id" => $id, "emails" => $emails);
|
90 |
-
return $this->master->call('vip/del', $_params);
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Retrieve all Golden Monkey(s) for an account
|
95 |
-
* @return array structs for each Golden Monkey, including:
|
96 |
-
* - list_id string The id of the List the Member appears on
|
97 |
-
* - list_name string The name of the List the Member appears on
|
98 |
-
* - email string The email address of the member
|
99 |
-
* - fname string IF a FNAME merge field exists on the list, that value for the member
|
100 |
-
* - lname string IF a LNAME merge field exists on the list, that value for the member
|
101 |
-
* - member_rating int the rating of the subscriber. This will be 1 - 5 as described <a href="http://eepurl.com/f-2P" target="_blank">here</a>
|
102 |
-
* - member_since string the datetime the member was added and/or confirmed
|
103 |
-
*/
|
104 |
-
public function members() {
|
105 |
-
$_params = array();
|
106 |
-
return $this->master->call('vip/members', $_params);
|
107 |
-
}
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/css/wp-subscribe-form.css
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Plugin Name: WP Subscribe Pro
|
3 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe-pro/
|
4 |
+
Description: WP Subscribe is a simple but powerful subscription plugin which supports MailChimp, Aweber and Feedburner.
|
5 |
+
Author: MyThemeShop
|
6 |
+
Author URI: http://mythemeshop.com/
|
7 |
+
*/
|
8 |
+
.wp-subscribe-wrap { padding: 20px; background: #f47555; text-align: center;}
|
9 |
+
.wp-subscribe-wrap h4.title { font-size: 22px; color: #FFFFFF; line-height: 1; text-transform: uppercase; margin-bottom: 0; }
|
10 |
+
.wp-subscribe-wrap h4.title span { display: inline-block; font-weight: bold; font-size: 38px; margin-top: 15px; }
|
11 |
+
.wp-subscribe-wrap p { color: #FFFFFF; margin: 0; }
|
12 |
+
.wp-subscribe-wrap p.text { margin: 15px 0; opacity: 0.8; }
|
13 |
+
.wp-subscribe-wrap input { border: none; width: 100%; box-sizing: border-box; padding: 10px 0; margin: 0; box-shadow: none; border-radius: 0; height: 45px; text-indent: 10px; text-align: center;}
|
14 |
+
.wp-subscribe-wrap .email-field { margin-top: 10px }
|
15 |
+
.wp-subscribe-wrap input.email-field, .wp-subscribe-wrap input.name-field { color: #FFFFFF; background: #d56144; }
|
16 |
+
.wp-subscribe-wrap input::-webkit-input-placeholder { color: inherit; opacity: 0.8; }
|
17 |
+
.wp-subscribe-wrap input:-moz-input-placeholder { color: inherit; opacity: 0.8; }
|
18 |
+
.wp-subscribe-wrap input::-moz-input-placeholder { color: inherit; opacity: 0.8; }
|
19 |
+
.wp-subscribe-wrap input::-ms-input-placeholder { color: inherit; opacity: 0.8; }
|
20 |
+
.wp-subscribe-wrap input:focus::-webkit-input-placeholder {color: transparent !important;}
|
21 |
+
.wp-subscribe-wrap input:focus::-moz-input-placeholder {color: transparent !important;}
|
22 |
+
.wp-subscribe-wrap input:focus:-moz-input-placeholder {color: transparent !important;}
|
23 |
+
.wp-subscribe-wrap input:focus::input-placeholder {color: transparent !important;}
|
24 |
+
.wp-subscribe-wrap input.submit { background: #FFFFFF; color: #f47555; margin-top: 20px; font-size: 18px; text-transform: uppercase; font-weight: 500; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.05); cursor: pointer;}
|
25 |
+
.wp-subscribe-wrap p.footer-text { margin-top: 10px; font-size: 12px; }
|
26 |
+
#wp_subscribe_popup .wp-subscribe-wrap h4.title { margin-top: 0 }
|
27 |
+
.wp-subscribe.loading { position: relative }
|
28 |
+
.wp-subscribe.loading:after { content: ""; display: block; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255, 255, 255, 0.3); }
|
29 |
+
.wp-subscribe-single .wp-subscribe-wrap {text-align: left; margin: 10px 0; clear: both;}
|
30 |
+
.wp-subscribe-single .wp-subscribe-wrap input {text-align: left;}
|
31 |
+
.wp-subscribe-wrap .error, .wp-subscribe-wrap .thanks {margin-top: 10px;}
|
assets/css/wp-subscribe-options.css
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Plugin Name: WP Subscribe Pro
|
3 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe-pro/
|
4 |
+
Description: WP Subscribe is a simple but powerful subscription plugin which supports MailChimp, Aweber and Feedburner.
|
5 |
+
Author: MyThemeShop
|
6 |
+
Author URI: http://mythemeshop.com/
|
7 |
+
*/
|
8 |
+
.wp_subscribe_options_form label { vertical-align: top }
|
9 |
+
.wp_subscribe_colors, .wp_subscribe_labels { }
|
10 |
+
.wp_subscribe_options_form .wp-picker-container { position: absolute; right: 0; }
|
11 |
+
.wp_subscribe_colors > div { position: relative; margin: 20px 0; }
|
12 |
+
.wp_subscribe_colors label { display: inline-block; margin-top: 2px; }
|
13 |
+
.wp_subscribe_options_form .wp-picker-container > a { margin-right: 0 }
|
14 |
+
.wp-subscribe h2 { margin-bottom: 1em }
|
15 |
+
.wp-subscribe-preview-popup:before { content: "\f177"; display: inline-block; width: 20px; height: 20px; font-size: 20px; margin-right: 5px; margin-top: 2px; line-height: 1; font-family: dashicons; text-decoration: inherit; font-weight: 400; font-style: normal; vertical-align: top; text-align: center; transition: color .1s ease-in 0; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
|
16 |
+
.wp-subscribe-preview-popup.disabled { pointer-events: none }
|
17 |
+
#cookies-cleared { display: none; line-height: 27px; margin-left: 4px; color: #777; float: left; margin-top: 8px; }
|
18 |
+
#cookies-cleared .dashicons { vertical-align: middle }
|
19 |
+
.wp-subscribe-field h4 { margin-top: 0; float: left; width: 100%; margin-bottom: .5em; }
|
20 |
+
.wp-subscribe-field p { margin: 0; float: left; width: 100%; }
|
21 |
+
.wp-subscribe-field select { margin-left: 0 }
|
22 |
+
h3.wp-subscribe-field { margin-top: 1em; margin-bottom: 1.8em; }
|
23 |
+
.wp-subscribe-field { clear: both; margin: 0 0 1em 0; overflow: hidden; float: left; width: 100%; }
|
24 |
+
.wp-subscribe-color-field { width: 181px; float: left; margin-top: 7px; margin-right: 7px; }
|
25 |
+
.wp-picker-holder { position: absolute; z-index: 10; }
|
26 |
+
.wp-picker-input-wrap { position: absolute; z-index: 1; }
|
27 |
+
.wp-subscribe-color-field label { display: block; margin-bottom: .8em; font-weight: bold; }
|
28 |
+
.wp-subscribe-label-field { float: left; margin-right: 14px; margin-bottom: 10px; }
|
29 |
+
.wp-subscribe-label-field label { width: 168px; display: inline-block; font-weight: bold; vertical-align: top; padding-top: 7px; }
|
30 |
+
.wp-subscribe-label-field .wps-input-wrapper { display: inline-block; }
|
31 |
+
.wp-subscribe-label-field .wps-desc {display: block;font-size: 12px;color: #787878;font-style: italic;margin-top: 3px;}
|
32 |
+
.wp-subscribe-label-field .list-selectbox { display: inline-block; width: auto; }
|
33 |
+
.wps-tabs-wrapper > div { margin-top: 12px }
|
34 |
+
p.submit { clear: both; float: left; margin-top: 0; }
|
35 |
+
.postmeta-label { clear: both; float: left; }
|
36 |
+
.wps-popup-content-options .wp-subscribe-label-field, .wps-post-options .wp-subscribe-label-field { width: 100% }
|
37 |
+
.wps-popup-content-options .wp-subscribe-label-field input, .wps-post-options .wp-subscribe-label-field input { width: 400px }
|
38 |
+
.wps-popup-content-options h4 { width: 100%; float: left; clear: both; }
|
39 |
+
#wp-subscribe-opacity-slider, #wp-subscribe-popup-width-slider { width: 300px; margin: 10px 20px 10px 0; float: left; }
|
40 |
+
#wp_subscribe_overlay_opacity, #wp_subscribe_popup_width { float: left }
|
41 |
+
.wp-subscribe-content-colors { float: left; width: 100%; margin-top: 30px; margin-bottom: 20px; }
|
42 |
+
.wp-subscribe-content-colors .wp-subscribe-color-field:nth-child(5) { clear: left }
|
43 |
+
label[for="wp_subscribe_overlay_opacity"], label[for="wp_subscribe_popup_width"] { width: 100%; display: block; font-weight: bold; margin-bottom: .1em; }
|
44 |
+
.wp_subscribe_account_details { clear: both; float: left; width: 100%; margin-bottom: 10px; }
|
45 |
+
#wp_subscribe_regenerate_cookie { margin-top: 7px; margin-bottom: 15px; float: left; }
|
46 |
+
.wps-colors-loader { margin-bottom: 12px }
|
47 |
+
.wps-palettes { display: none }
|
48 |
+
.wps-colors-loader .color-palette { max-width: 300px; height: 40px; margin-top: 12px; border: 1px solid #ccc; }
|
49 |
+
.wps-colors-loader a { background: #D56144; color: #FFF; padding: 5px 10px; border-radius: 3px; text-decoration: none; }
|
50 |
+
.wps-colors-loader a:hover,.wps-colors-loader a:hover {color: #fff;}
|
51 |
+
.single-palette { position: relative; clear: both; }
|
52 |
+
.single-palette .wps-load-palette { display: none }
|
53 |
+
.single-palette:hover .wps-load-palette { display: block; position: absolute; top: 6px; left: 6px; }
|
54 |
+
span.width-px-label { line-height: 27px }
|
55 |
+
.description { color: #666; font-size: 13px; font-style: italic; }
|
56 |
+
.clear { clear: both }
|
57 |
+
|
58 |
+
.widget .wp-subscribe-label-field { float: none }
|
59 |
+
.widget .wp-subscribe-label-field label { display: block; width: auto; padding: 0 0 7px; }
|
60 |
+
.widget .wp-subscribe-label-field .wps-input-wrapper { display: block; }
|
61 |
+
.widget .wps-account-details input.widefat { width: 75% }
|
62 |
+
.widget .wp-subscribe-service-field .list-selectbox { display: block; width: 100%; }
|
63 |
+
.widget .wp-subscribe-service-field { padding-top: 10px; }
|
64 |
+
|
65 |
+
.widget .wp-subscribe-color-field { width: 100%; float: none }
|
66 |
+
.widget .wp-picker-container { position: absolute; right: 0; }
|
67 |
+
.widget .wp_subscribe_colors > div { position: relative; margin: 20px 0 }
|
68 |
+
.widget .wp_subscribe_colors label { display: inline-block; margin-top: 2px }
|
69 |
+
.widget .wp_subscribe_options_form .wp-picker-container > a { margin-right: 0 }
|
assets/js/jquery.cookie.js
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* jQuery Cookie Plugin v1.4.1
|
3 |
+
* https://github.com/carhartl/jquery-cookie
|
4 |
+
*
|
5 |
+
* Copyright 2006, 2014 Klaus Hartl
|
6 |
+
* Released under the MIT license
|
7 |
+
*/
|
8 |
+
(function (factory) {
|
9 |
+
if (typeof define === 'function' && define.amd) {
|
10 |
+
// AMD
|
11 |
+
define(['jquery'], factory);
|
12 |
+
} else if (typeof exports === 'object') {
|
13 |
+
// CommonJS
|
14 |
+
factory(require('jquery'));
|
15 |
+
} else {
|
16 |
+
// Browser globals
|
17 |
+
factory(jQuery);
|
18 |
+
}
|
19 |
+
}(function ($) {
|
20 |
+
|
21 |
+
var pluses = /\+/g;
|
22 |
+
|
23 |
+
function encode(s) {
|
24 |
+
return config.raw ? s : encodeURIComponent(s);
|
25 |
+
}
|
26 |
+
|
27 |
+
function decode(s) {
|
28 |
+
return config.raw ? s : decodeURIComponent(s);
|
29 |
+
}
|
30 |
+
|
31 |
+
function stringifyCookieValue(value) {
|
32 |
+
return encode(config.json ? JSON.stringify(value) : String(value));
|
33 |
+
}
|
34 |
+
|
35 |
+
function parseCookieValue(s) {
|
36 |
+
if (s.indexOf('"') === 0) {
|
37 |
+
// This is a quoted cookie as according to RFC2068, unescape...
|
38 |
+
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
39 |
+
}
|
40 |
+
|
41 |
+
try {
|
42 |
+
// Replace server-side written pluses with spaces.
|
43 |
+
// If we can't decode the cookie, ignore it, it's unusable.
|
44 |
+
// If we can't parse the cookie, ignore it, it's unusable.
|
45 |
+
s = decodeURIComponent(s.replace(pluses, ' '));
|
46 |
+
return config.json ? JSON.parse(s) : s;
|
47 |
+
} catch(e) {}
|
48 |
+
}
|
49 |
+
|
50 |
+
function read(s, converter) {
|
51 |
+
var value = config.raw ? s : parseCookieValue(s);
|
52 |
+
return $.isFunction(converter) ? converter(value) : value;
|
53 |
+
}
|
54 |
+
|
55 |
+
var config = $.cookie = function (key, value, options) {
|
56 |
+
|
57 |
+
// Write
|
58 |
+
|
59 |
+
if (arguments.length > 1 && !$.isFunction(value)) {
|
60 |
+
options = $.extend({}, config.defaults, options);
|
61 |
+
|
62 |
+
if (typeof options.expires === 'number') {
|
63 |
+
var days = options.expires, t = options.expires = new Date();
|
64 |
+
t.setTime(+t + days * 864e+5);
|
65 |
+
}
|
66 |
+
|
67 |
+
return (document.cookie = [
|
68 |
+
encode(key), '=', stringifyCookieValue(value),
|
69 |
+
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
70 |
+
options.path ? '; path=' + options.path : '',
|
71 |
+
options.domain ? '; domain=' + options.domain : '',
|
72 |
+
options.secure ? '; secure' : ''
|
73 |
+
].join(''));
|
74 |
+
}
|
75 |
+
|
76 |
+
// Read
|
77 |
+
|
78 |
+
var result = key ? undefined : {};
|
79 |
+
|
80 |
+
// To prevent the for loop in the first place assign an empty array
|
81 |
+
// in case there are no cookies at all. Also prevents odd result when
|
82 |
+
// calling $.cookie().
|
83 |
+
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
84 |
+
|
85 |
+
for (var i = 0, l = cookies.length; i < l; i++) {
|
86 |
+
var parts = cookies[i].split('=');
|
87 |
+
var name = decode(parts.shift());
|
88 |
+
var cookie = parts.join('=');
|
89 |
+
|
90 |
+
if (key && key === name) {
|
91 |
+
// If second argument (value) is a function it's a converter...
|
92 |
+
result = read(cookie, value);
|
93 |
+
break;
|
94 |
+
}
|
95 |
+
|
96 |
+
// Prevent storing a cookie that we couldn't decode.
|
97 |
+
if (!key && (cookie = read(cookie)) !== undefined) {
|
98 |
+
result[name] = cookie;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
return result;
|
103 |
+
};
|
104 |
+
|
105 |
+
config.defaults = {};
|
106 |
+
|
107 |
+
$.removeCookie = function (key, options) {
|
108 |
+
if ($.cookie(key) === undefined) {
|
109 |
+
return false;
|
110 |
+
}
|
111 |
+
|
112 |
+
// Must not alter options, thus extending a fresh object...
|
113 |
+
$.cookie(key, '', $.extend({}, options, { expires: -1 }));
|
114 |
+
return !$.cookie(key);
|
115 |
+
};
|
116 |
+
|
117 |
+
}));
|
assets/js/jquery.exitIntent.js
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Plugin Name: WP Subscribe Pro
|
3 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe-pro/
|
4 |
+
Description: WP Subscribe is a simple but powerful subscription plugin which supports MailChimp, Aweber and Feedburner.
|
5 |
+
Author: MyThemeShop
|
6 |
+
Author URI: http://mythemeshop.com/
|
7 |
+
*/
|
8 |
+
|
9 |
+
(function($){
|
10 |
+
$.exitIntent = function(el, callback, options){
|
11 |
+
var base = this;
|
12 |
+
base.delayTimer = null;
|
13 |
+
base.$el = $(el);
|
14 |
+
base.el = el;
|
15 |
+
base.disabled = false;
|
16 |
+
|
17 |
+
base.$el.data("exitIntent", base);
|
18 |
+
|
19 |
+
base.init = function(){
|
20 |
+
base.options = $.extend({},$.exitIntent.defaultOptions, options);
|
21 |
+
|
22 |
+
base.$el.mouseleave(function(e) {
|
23 |
+
if (e.clientY > 0 || Math.abs(e.clientY) < base.options.minexitspeed || (base.disabled && !base.options.repeat)) return;
|
24 |
+
|
25 |
+
base.delayTimer = setTimeout(base.runCallback, base.options.delay);
|
26 |
+
}).mouseenter(function(event) {
|
27 |
+
if (base.delayTimer) {
|
28 |
+
clearTimeout(base.delayTimer);
|
29 |
+
base.delayTimer = null;
|
30 |
+
}
|
31 |
+
});
|
32 |
+
if (base.options.keyboard) {
|
33 |
+
base.$el.keydown(function(e) {
|
34 |
+
if (base.disabled && !base.options.repeat) return;
|
35 |
+
else if (e.keyCode !== 8 && (!e.metaKey || e.keyCode !== 76)) return;
|
36 |
+
|
37 |
+
base.runCallback();
|
38 |
+
});
|
39 |
+
}
|
40 |
+
};
|
41 |
+
base.runCallback = function() {
|
42 |
+
if (typeof callback == 'function') {
|
43 |
+
callback.call(this);
|
44 |
+
}
|
45 |
+
base.disabled = true;
|
46 |
+
};
|
47 |
+
|
48 |
+
base.init();
|
49 |
+
};
|
50 |
+
|
51 |
+
$.exitIntent.defaultOptions = {
|
52 |
+
minexitspeed: 0,
|
53 |
+
delay: 0,
|
54 |
+
repeat: false,
|
55 |
+
keyboard: true // capture ctrl + L
|
56 |
+
};
|
57 |
+
|
58 |
+
$.fn.exitIntent = function(callback, options){
|
59 |
+
return this.each(function(){
|
60 |
+
(new $.exitIntent(this, callback, options));
|
61 |
+
});
|
62 |
+
};
|
63 |
+
|
64 |
+
})(jQuery);
|
assets/js/magnificpopup.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
/*! Magnific Popup - v0.9.9 - 2014-09-06
|
2 |
+
* http://dimsemenov.com/plugins/magnific-popup/
|
3 |
+
* Copyright (c) 2014 Dmitry Semenov; */
|
4 |
+
(function(e){var t,n,i,o,r,a,s,l="Close",c="BeforeClose",d="AfterClose",u="BeforeAppend",p="MarkupParse",f="Open",m="Change",g="mfp",h="."+g,v="mfp-ready",C="mfp-removing",y="mfp-prevent-close",w=function(){},b=!!window.jQuery,I=e(window),x=function(e,n){t.ev.on(g+e+h,n)},k=function(t,n,i,o){var r=document.createElement("div");return r.className="mfp-"+t,i&&(r.innerHTML=i),o?n&&n.appendChild(r):(r=e(r),n&&r.appendTo(n)),r},T=function(n,i){t.ev.triggerHandler(g+n,i),t.st.callbacks&&(n=n.charAt(0).toLowerCase()+n.slice(1),t.st.callbacks[n]&&t.st.callbacks[n].apply(t,e.isArray(i)?i:[i]))},E=function(n){return n===s&&t.currTemplate.closeBtn||(t.currTemplate.closeBtn=e(t.st.closeMarkup.replace("%title%",t.st.tClose)),s=n),t.currTemplate.closeBtn},_=function(){e.magnificPopup.instance||(t=new w,t.init(),e.magnificPopup.instance=t)},S=function(){var e=document.createElement("p").style,t=["ms","O","Moz","Webkit"];if(void 0!==e.transition)return!0;for(;t.length;)if(t.pop()+"Transition"in e)return!0;return!1};w.prototype={constructor:w,init:function(){var n=navigator.appVersion;t.isIE7=-1!==n.indexOf("MSIE 7."),t.isIE8=-1!==n.indexOf("MSIE 8."),t.isLowIE=t.isIE7||t.isIE8,t.isAndroid=/android/gi.test(n),t.isIOS=/iphone|ipad|ipod/gi.test(n),t.supportsTransition=S(),t.probablyMobile=t.isAndroid||t.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),o=e(document),t.popupsCache={}},open:function(n){i||(i=e(document.body));var r;if(n.isObj===!1){t.items=n.items.toArray(),t.index=0;var s,l=n.items;for(r=0;l.length>r;r++)if(s=l[r],s.parsed&&(s=s.el[0]),s===n.el[0]){t.index=r;break}}else t.items=e.isArray(n.items)?n.items:[n.items],t.index=n.index||0;if(t.isOpen)return t.updateItemHTML(),void 0;t.types=[],a="",t.ev=n.mainEl&&n.mainEl.length?n.mainEl.eq(0):o,n.key?(t.popupsCache[n.key]||(t.popupsCache[n.key]={}),t.currTemplate=t.popupsCache[n.key]):t.currTemplate={},t.st=e.extend(!0,{},e.magnificPopup.defaults,n),t.fixedContentPos="auto"===t.st.fixedContentPos?!t.probablyMobile:t.st.fixedContentPos,t.st.modal&&(t.st.closeOnContentClick=!1,t.st.closeOnBgClick=!1,t.st.showCloseBtn=!1,t.st.enableEscapeKey=!1),t.bgOverlay||(t.bgOverlay=k("bg").on("click"+h,function(){t.close()}),t.wrap=k("wrap").attr("tabindex",-1).on("click"+h,function(e){t._checkIfClose(e.target)&&t.close()}),t.container=k("container",t.wrap)),t.contentContainer=k("content"),t.st.preloader&&(t.preloader=k("preloader",t.container,t.st.tLoading));var c=e.magnificPopup.modules;for(r=0;c.length>r;r++){var d=c[r];d=d.charAt(0).toUpperCase()+d.slice(1),t["init"+d].call(t)}T("BeforeOpen"),t.st.showCloseBtn&&(t.st.closeBtnInside?(x(p,function(e,t,n,i){n.close_replaceWith=E(i.type)}),a+=" mfp-close-btn-in"):t.wrap.append(E())),t.st.alignTop&&(a+=" mfp-align-top"),t.fixedContentPos?t.wrap.css({overflow:t.st.overflowY,overflowX:"hidden",overflowY:t.st.overflowY}):t.wrap.css({top:I.scrollTop(),position:"absolute"}),(t.st.fixedBgPos===!1||"auto"===t.st.fixedBgPos&&!t.fixedContentPos)&&t.bgOverlay.css({height:o.height(),position:"absolute"}),t.st.enableEscapeKey&&o.on("keyup"+h,function(e){27===e.keyCode&&t.close()}),I.on("resize"+h,function(){t.updateSize()}),t.st.closeOnContentClick||(a+=" mfp-auto-cursor"),a&&t.wrap.addClass(a);var u=t.wH=I.height(),m={};if(t.fixedContentPos&&t._hasScrollBar(u)){var g=t._getScrollbarSize();g&&(m.marginRight=g)}t.fixedContentPos&&(t.isIE7?e("body, html").css("overflow","hidden"):m.overflow="hidden");var C=t.st.mainClass;return t.isIE7&&(C+=" mfp-ie7"),C&&t._addClassToMFP(C),t.updateItemHTML(),T("BuildControls"),e("html").css(m),t.bgOverlay.add(t.wrap).prependTo(t.st.prependTo||i),t._lastFocusedEl=document.activeElement,setTimeout(function(){t.content?(t._addClassToMFP(v),t._setFocus()):t.bgOverlay.addClass(v),o.on("focusin"+h,t._onFocusIn)},16),t.isOpen=!0,t.updateSize(u),T(f),n},close:function(){t.isOpen&&(T(c),t.isOpen=!1,t.st.removalDelay&&!t.isLowIE&&t.supportsTransition?(t._addClassToMFP(C),setTimeout(function(){t._close()},t.st.removalDelay)):t._close())},_close:function(){T(l);var n=C+" "+v+" ";if(t.bgOverlay.detach(),t.wrap.detach(),t.container.empty(),t.st.mainClass&&(n+=t.st.mainClass+" "),t._removeClassFromMFP(n),t.fixedContentPos){var i={marginRight:""};t.isIE7?e("body, html").css("overflow",""):i.overflow="",e("html").css(i)}o.off("keyup"+h+" focusin"+h),t.ev.off(h),t.wrap.attr("class","mfp-wrap").removeAttr("style"),t.bgOverlay.attr("class","mfp-bg"),t.container.attr("class","mfp-container"),!t.st.showCloseBtn||t.st.closeBtnInside&&t.currTemplate[t.currItem.type]!==!0||t.currTemplate.closeBtn&&t.currTemplate.closeBtn.detach(),t._lastFocusedEl&&e(t._lastFocusedEl).focus(),t.currItem=null,t.content=null,t.currTemplate=null,t.prevHeight=0,T(d)},updateSize:function(e){if(t.isIOS){var n=document.documentElement.clientWidth/window.innerWidth,i=window.innerHeight*n;t.wrap.css("height",i),t.wH=i}else t.wH=e||I.height();t.fixedContentPos||t.wrap.css("height",t.wH),T("Resize")},updateItemHTML:function(){var n=t.items[t.index];t.contentContainer.detach(),t.content&&t.content.detach(),n.parsed||(n=t.parseEl(t.index));var i=n.type;if(T("BeforeChange",[t.currItem?t.currItem.type:"",i]),t.currItem=n,!t.currTemplate[i]){var o=t.st[i]?t.st[i].markup:!1;T("FirstMarkupParse",o),t.currTemplate[i]=o?e(o):!0}r&&r!==n.type&&t.container.removeClass("mfp-"+r+"-holder");var a=t["get"+i.charAt(0).toUpperCase()+i.slice(1)](n,t.currTemplate[i]);t.appendContent(a,i),n.preloaded=!0,T(m,n),r=n.type,t.container.prepend(t.contentContainer),T("AfterChange")},appendContent:function(e,n){t.content=e,e?t.st.showCloseBtn&&t.st.closeBtnInside&&t.currTemplate[n]===!0?t.content.find(".mfp-close").length||t.content.append(E()):t.content=e:t.content="",T(u),t.container.addClass("mfp-"+n+"-holder"),t.contentContainer.append(t.content)},parseEl:function(n){var i,o=t.items[n];if(o.tagName?o={el:e(o)}:(i=o.type,o={data:o,src:o.src}),o.el){for(var r=t.types,a=0;r.length>a;a++)if(o.el.hasClass("mfp-"+r[a])){i=r[a];break}o.src=o.el.attr("data-mfp-src"),o.src||(o.src=o.el.attr("href"))}return o.type=i||t.st.type||"inline",o.index=n,o.parsed=!0,t.items[n]=o,T("ElementParse",o),t.items[n]},addGroup:function(e,n){var i=function(i){i.mfpEl=this,t._openClick(i,e,n)};n||(n={});var o="click.magnificPopup";n.mainEl=e,n.items?(n.isObj=!0,e.off(o).on(o,i)):(n.isObj=!1,n.delegate?e.off(o).on(o,n.delegate,i):(n.items=e,e.off(o).on(o,i)))},_openClick:function(n,i,o){var r=void 0!==o.midClick?o.midClick:e.magnificPopup.defaults.midClick;if(r||2!==n.which&&!n.ctrlKey&&!n.metaKey){var a=void 0!==o.disableOn?o.disableOn:e.magnificPopup.defaults.disableOn;if(a)if(e.isFunction(a)){if(!a.call(t))return!0}else if(a>I.width())return!0;n.type&&(n.preventDefault(),t.isOpen&&n.stopPropagation()),o.el=e(n.mfpEl),o.delegate&&(o.items=i.find(o.delegate)),t.open(o)}},updateStatus:function(e,i){if(t.preloader){n!==e&&t.container.removeClass("mfp-s-"+n),i||"loading"!==e||(i=t.st.tLoading);var o={status:e,text:i};T("UpdateStatus",o),e=o.status,i=o.text,t.preloader.html(i),t.preloader.find("a").on("click",function(e){e.stopImmediatePropagation()}),t.container.addClass("mfp-s-"+e),n=e}},_checkIfClose:function(n){if(!e(n).hasClass(y)){var i=t.st.closeOnContentClick,o=t.st.closeOnBgClick;if(i&&o)return!0;if(!t.content||e(n).hasClass("mfp-close")||t.preloader&&n===t.preloader[0])return!0;if(n===t.content[0]||e.contains(t.content[0],n)){if(i)return!0}else if(o&&e.contains(document,n))return!0;return!1}},_addClassToMFP:function(e){t.bgOverlay.addClass(e),t.wrap.addClass(e)},_removeClassFromMFP:function(e){this.bgOverlay.removeClass(e),t.wrap.removeClass(e)},_hasScrollBar:function(e){return(t.isIE7?o.height():document.body.scrollHeight)>(e||I.height())},_setFocus:function(){(t.st.focus?t.content.find(t.st.focus).eq(0):t.wrap).focus()},_onFocusIn:function(n){return n.target===t.wrap[0]||e.contains(t.wrap[0],n.target)?void 0:(t._setFocus(),!1)},_parseMarkup:function(t,n,i){var o;i.data&&(n=e.extend(i.data,n)),T(p,[t,n,i]),e.each(n,function(e,n){if(void 0===n||n===!1)return!0;if(o=e.split("_"),o.length>1){var i=t.find(h+"-"+o[0]);if(i.length>0){var r=o[1];"replaceWith"===r?i[0]!==n[0]&&i.replaceWith(n):"img"===r?i.is("img")?i.attr("src",n):i.replaceWith('<img src="'+n+'" class="'+i.attr("class")+'" />'):i.attr(o[1],n)}}else t.find(h+"-"+e).html(n)})},_getScrollbarSize:function(){if(void 0===t.scrollbarSize){var e=document.createElement("div");e.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(e),t.scrollbarSize=e.offsetWidth-e.clientWidth,document.body.removeChild(e)}return t.scrollbarSize}},e.magnificPopup={instance:null,proto:w.prototype,modules:[],open:function(t,n){return _(),t=t?e.extend(!0,{},t):{},t.isObj=!0,t.index=n||0,this.instance.open(t)},close:function(){return e.magnificPopup.instance&&e.magnificPopup.instance.close()},registerModule:function(t,n){n.options&&(e.magnificPopup.defaults[t]=n.options),e.extend(this.proto,n.proto),this.modules.push(t)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'<button title="%title%" type="button" class="mfp-close">×</button>',tClose:"Close (Esc)",tLoading:"Loading..."}},e.fn.magnificPopup=function(n){_();var i=e(this);if("string"==typeof n)if("open"===n){var o,r=b?i.data("magnificPopup"):i[0].magnificPopup,a=parseInt(arguments[1],10)||0;r.items?o=r.items[a]:(o=i,r.delegate&&(o=o.find(r.delegate)),o=o.eq(a)),t._openClick({mfpEl:o},i,r)}else t.isOpen&&t[n].apply(t,Array.prototype.slice.call(arguments,1));else n=e.extend(!0,{},n),b?i.data("magnificPopup",n):i[0].magnificPopup=n,t.addGroup(i,n);return i};var P,O,z,M="inline",B=function(){z&&(O.after(z.addClass(P)).detach(),z=null)};e.magnificPopup.registerModule(M,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){t.types.push(M),x(l+"."+M,function(){B()})},getInline:function(n,i){if(B(),n.src){var o=t.st.inline,r=e(n.src);if(r.length){var a=r[0].parentNode;a&&a.tagName&&(O||(P=o.hiddenClass,O=k(P),P="mfp-"+P),z=r.after(O).detach().removeClass(P)),t.updateStatus("ready")}else t.updateStatus("error",o.tNotFound),r=e("<div>");return n.inlineElement=r,r}return t.updateStatus("ready"),t._parseMarkup(i,{},n),i}}});var F,H="ajax",L=function(){F&&i.removeClass(F)},A=function(){L(),t.req&&t.req.abort()};e.magnificPopup.registerModule(H,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'<a href="%url%">The content</a> could not be loaded.'},proto:{initAjax:function(){t.types.push(H),F=t.st.ajax.cursor,x(l+"."+H,A),x("BeforeChange."+H,A)},getAjax:function(n){F&&i.addClass(F),t.updateStatus("loading");var o=e.extend({url:n.src,success:function(i,o,r){var a={data:i,xhr:r};T("ParseAjax",a),t.appendContent(e(a.data),H),n.finished=!0,L(),t._setFocus(),setTimeout(function(){t.wrap.addClass(v)},16),t.updateStatus("ready"),T("AjaxContentAdded")},error:function(){L(),n.finished=n.loadError=!0,t.updateStatus("error",t.st.ajax.tError.replace("%url%",n.src))}},t.st.ajax.settings);return t.req=e.ajax(o),""}}});var j,N=function(n){if(n.data&&void 0!==n.data.title)return n.data.title;var i=t.st.image.titleSrc;if(i){if(e.isFunction(i))return i.call(t,n);if(n.el)return n.el.attr(i)||""}return""};e.magnificPopup.registerModule("image",{options:{markup:'<div class="mfp-figure"><div class="mfp-close"></div><figure><div class="mfp-img"></div><figcaption><div class="mfp-bottom-bar"><div class="mfp-title"></div><div class="mfp-counter"></div></div></figcaption></figure></div>',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'<a href="%url%">The image</a> could not be loaded.'},proto:{initImage:function(){var e=t.st.image,n=".image";t.types.push("image"),x(f+n,function(){"image"===t.currItem.type&&e.cursor&&i.addClass(e.cursor)}),x(l+n,function(){e.cursor&&i.removeClass(e.cursor),I.off("resize"+h)}),x("Resize"+n,t.resizeImage),t.isLowIE&&x("AfterChange",t.resizeImage)},resizeImage:function(){var e=t.currItem;if(e&&e.img&&t.st.image.verticalFit){var n=0;t.isLowIE&&(n=parseInt(e.img.css("padding-top"),10)+parseInt(e.img.css("padding-bottom"),10)),e.img.css("max-height",t.wH-n)}},_onImageHasSize:function(e){e.img&&(e.hasSize=!0,j&&clearInterval(j),e.isCheckingImgSize=!1,T("ImageHasSize",e),e.imgHidden&&(t.content&&t.content.removeClass("mfp-loading"),e.imgHidden=!1))},findImageSize:function(e){var n=0,i=e.img[0],o=function(r){j&&clearInterval(j),j=setInterval(function(){return i.naturalWidth>0?(t._onImageHasSize(e),void 0):(n>200&&clearInterval(j),n++,3===n?o(10):40===n?o(50):100===n&&o(500),void 0)},r)};o(1)},getImage:function(n,i){var o=0,r=function(){n&&(n.img[0].complete?(n.img.off(".mfploader"),n===t.currItem&&(t._onImageHasSize(n),t.updateStatus("ready")),n.hasSize=!0,n.loaded=!0,T("ImageLoadComplete")):(o++,200>o?setTimeout(r,100):a()))},a=function(){n&&(n.img.off(".mfploader"),n===t.currItem&&(t._onImageHasSize(n),t.updateStatus("error",s.tError.replace("%url%",n.src))),n.hasSize=!0,n.loaded=!0,n.loadError=!0)},s=t.st.image,l=i.find(".mfp-img");if(l.length){var c=document.createElement("img");c.className="mfp-img",n.img=e(c).on("load.mfploader",r).on("error.mfploader",a),c.src=n.src,l.is("img")&&(n.img=n.img.clone()),c=n.img[0],c.naturalWidth>0?n.hasSize=!0:c.width||(n.hasSize=!1)}return t._parseMarkup(i,{title:N(n),img_replaceWith:n.img},n),t.resizeImage(),n.hasSize?(j&&clearInterval(j),n.loadError?(i.addClass("mfp-loading"),t.updateStatus("error",s.tError.replace("%url%",n.src))):(i.removeClass("mfp-loading"),t.updateStatus("ready")),i):(t.updateStatus("loading"),n.loading=!0,n.hasSize||(n.imgHidden=!0,i.addClass("mfp-loading"),t.findImageSize(n)),i)}}});var W,R=function(){return void 0===W&&(W=void 0!==document.createElement("p").style.MozTransform),W};e.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(e){return e.is("img")?e:e.find("img")}},proto:{initZoom:function(){var e,n=t.st.zoom,i=".zoom";if(n.enabled&&t.supportsTransition){var o,r,a=n.duration,s=function(e){var t=e.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),i="all "+n.duration/1e3+"s "+n.easing,o={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},r="transition";return o["-webkit-"+r]=o["-moz-"+r]=o["-o-"+r]=o[r]=i,t.css(o),t},d=function(){t.content.css("visibility","visible")};x("BuildControls"+i,function(){if(t._allowZoom()){if(clearTimeout(o),t.content.css("visibility","hidden"),e=t._getItemToZoom(),!e)return d(),void 0;r=s(e),r.css(t._getOffset()),t.wrap.append(r),o=setTimeout(function(){r.css(t._getOffset(!0)),o=setTimeout(function(){d(),setTimeout(function(){r.remove(),e=r=null,T("ZoomAnimationEnded")},16)},a)},16)}}),x(c+i,function(){if(t._allowZoom()){if(clearTimeout(o),t.st.removalDelay=a,!e){if(e=t._getItemToZoom(),!e)return;r=s(e)}r.css(t._getOffset(!0)),t.wrap.append(r),t.content.css("visibility","hidden"),setTimeout(function(){r.css(t._getOffset())},16)}}),x(l+i,function(){t._allowZoom()&&(d(),r&&r.remove(),e=null)})}},_allowZoom:function(){return"image"===t.currItem.type},_getItemToZoom:function(){return t.currItem.hasSize?t.currItem.img:!1},_getOffset:function(n){var i;i=n?t.currItem.img:t.st.zoom.opener(t.currItem.el||t.currItem);var o=i.offset(),r=parseInt(i.css("padding-top"),10),a=parseInt(i.css("padding-bottom"),10);o.top-=e(window).scrollTop()-r;var s={width:i.width(),height:(b?i.innerHeight():i[0].offsetHeight)-a-r};return R()?s["-moz-transform"]=s.transform="translate("+o.left+"px,"+o.top+"px)":(s.left=o.left,s.top=o.top),s}}});var Z="iframe",q="//about:blank",D=function(e){if(t.currTemplate[Z]){var n=t.currTemplate[Z].find("iframe");n.length&&(e||(n[0].src=q),t.isIE8&&n.css("display",e?"block":"none"))}};e.magnificPopup.registerModule(Z,{options:{markup:'<div class="mfp-iframe-scaler"><div class="mfp-close"></div><iframe class="mfp-iframe" src="//about:blank" frameborder="0" allowfullscreen></iframe></div>',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){t.types.push(Z),x("BeforeChange",function(e,t,n){t!==n&&(t===Z?D():n===Z&&D(!0))}),x(l+"."+Z,function(){D()})},getIframe:function(n,i){var o=n.src,r=t.st.iframe;e.each(r.patterns,function(){return o.indexOf(this.index)>-1?(this.id&&(o="string"==typeof this.id?o.substr(o.lastIndexOf(this.id)+this.id.length,o.length):this.id.call(this,o)),o=this.src.replace("%id%",o),!1):void 0});var a={};return r.srcAction&&(a[r.srcAction]=o),t._parseMarkup(i,a,n),t.updateStatus("ready"),i}}});var K=function(e){var n=t.items.length;return e>n-1?e-n:0>e?n+e:e},Y=function(e,t,n){return e.replace(/%curr%/gi,t+1).replace(/%total%/gi,n)};e.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'<button title="%title%" type="button" class="mfp-arrow mfp-arrow-%dir%"></button>',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var n=t.st.gallery,i=".mfp-gallery",r=Boolean(e.fn.mfpFastClick);return t.direction=!0,n&&n.enabled?(a+=" mfp-gallery",x(f+i,function(){n.navigateByImgClick&&t.wrap.on("click"+i,".mfp-img",function(){return t.items.length>1?(t.next(),!1):void 0}),o.on("keydown"+i,function(e){37===e.keyCode?t.prev():39===e.keyCode&&t.next()})}),x("UpdateStatus"+i,function(e,n){n.text&&(n.text=Y(n.text,t.currItem.index,t.items.length))}),x(p+i,function(e,i,o,r){var a=t.items.length;o.counter=a>1?Y(n.tCounter,r.index,a):""}),x("BuildControls"+i,function(){if(t.items.length>1&&n.arrows&&!t.arrowLeft){var i=n.arrowMarkup,o=t.arrowLeft=e(i.replace(/%title%/gi,n.tPrev).replace(/%dir%/gi,"left")).addClass(y),a=t.arrowRight=e(i.replace(/%title%/gi,n.tNext).replace(/%dir%/gi,"right")).addClass(y),s=r?"mfpFastClick":"click";o[s](function(){t.prev()}),a[s](function(){t.next()}),t.isIE7&&(k("b",o[0],!1,!0),k("a",o[0],!1,!0),k("b",a[0],!1,!0),k("a",a[0],!1,!0)),t.container.append(o.add(a))}}),x(m+i,function(){t._preloadTimeout&&clearTimeout(t._preloadTimeout),t._preloadTimeout=setTimeout(function(){t.preloadNearbyImages(),t._preloadTimeout=null},16)}),x(l+i,function(){o.off(i),t.wrap.off("click"+i),t.arrowLeft&&r&&t.arrowLeft.add(t.arrowRight).destroyMfpFastClick(),t.arrowRight=t.arrowLeft=null}),void 0):!1},next:function(){t.direction=!0,t.index=K(t.index+1),t.updateItemHTML()},prev:function(){t.direction=!1,t.index=K(t.index-1),t.updateItemHTML()},goTo:function(e){t.direction=e>=t.index,t.index=e,t.updateItemHTML()},preloadNearbyImages:function(){var e,n=t.st.gallery.preload,i=Math.min(n[0],t.items.length),o=Math.min(n[1],t.items.length);for(e=1;(t.direction?o:i)>=e;e++)t._preloadItem(t.index+e);for(e=1;(t.direction?i:o)>=e;e++)t._preloadItem(t.index-e)},_preloadItem:function(n){if(n=K(n),!t.items[n].preloaded){var i=t.items[n];i.parsed||(i=t.parseEl(n)),T("LazyLoad",i),"image"===i.type&&(i.img=e('<img class="mfp-img" />').on("load.mfploader",function(){i.hasSize=!0}).on("error.mfploader",function(){i.hasSize=!0,i.loadError=!0,T("LazyLoadError",i)}).attr("src",i.src)),i.preloaded=!0}}}});var U="retina";e.magnificPopup.registerModule(U,{options:{replaceSrc:function(e){return e.src.replace(/\.\w+$/,function(e){return"@2x"+e})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var e=t.st.retina,n=e.ratio;n=isNaN(n)?n():n,n>1&&(x("ImageHasSize."+U,function(e,t){t.img.css({"max-width":t.img[0].naturalWidth/n,width:"100%"})}),x("ElementParse."+U,function(t,i){i.src=e.replaceSrc(i,n)}))}}}}),function(){var t=1e3,n="ontouchstart"in window,i=function(){I.off("touchmove"+r+" touchend"+r)},o="mfpFastClick",r="."+o;e.fn.mfpFastClick=function(o){return e(this).each(function(){var a,s=e(this);if(n){var l,c,d,u,p,f;s.on("touchstart"+r,function(e){u=!1,f=1,p=e.originalEvent?e.originalEvent.touches[0]:e.touches[0],c=p.clientX,d=p.clientY,I.on("touchmove"+r,function(e){p=e.originalEvent?e.originalEvent.touches:e.touches,f=p.length,p=p[0],(Math.abs(p.clientX-c)>10||Math.abs(p.clientY-d)>10)&&(u=!0,i())}).on("touchend"+r,function(e){i(),u||f>1||(a=!0,e.preventDefault(),clearTimeout(l),l=setTimeout(function(){a=!1},t),o())})})}s.on("click"+r,function(){a||o()})})},e.fn.destroyMfpFastClick=function(){e(this).off("touchstart"+r+" click"+r),n&&I.off("touchmove"+r+" touchend"+r)}}(),_()})(window.jQuery||window.Zepto);
|
assets/js/wp-subscribe-admin.js
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Plugin Name: WP Subscribe Pro
|
3 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe-pro/
|
4 |
+
Description: WP Subscribe is a simple but powerful subscription plugin which supports MailChimp, Aweber and Feedburner.
|
5 |
+
Author: MyThemeShop
|
6 |
+
Author URI: http://mythemeshop.com/
|
7 |
+
*/
|
8 |
+
|
9 |
+
( function( $ ){
|
10 |
+
|
11 |
+
// color picker
|
12 |
+
function initColorPicker( widget ) {
|
13 |
+
|
14 |
+
var colorPickers = widget.find( '.wp-subscribe-color-select' );
|
15 |
+
|
16 |
+
if ( colorPickers.length > 0 ) {
|
17 |
+
colorPickers.wpColorPicker();
|
18 |
+
}
|
19 |
+
|
20 |
+
// and services dropdown
|
21 |
+
widget.find('.wp-subscribe-service-field select').change(function() {
|
22 |
+
|
23 |
+
var $this = $(this);
|
24 |
+
|
25 |
+
widget.find('.wp_subscribe_account_details_'+$this.val()).show().siblings('div').hide();
|
26 |
+
widget.find('.wp_subscribe_account_details').slideDown();
|
27 |
+
|
28 |
+
// Include "name" field
|
29 |
+
if ($this.val() === 'feedburner') {
|
30 |
+
widget.find('.wp_subscribe_include_name, .wp-subscribe-name_placeholder-field').hide();
|
31 |
+
} else {
|
32 |
+
widget.find('.wp_subscribe_include_name').show().find('input').trigger('change');
|
33 |
+
}
|
34 |
+
|
35 |
+
// Thanks Page option
|
36 |
+
if ($this.val() === 'mailchimp' || $this.val() === 'getresponse' || $this.val() === 'mailerlite' || $this.val() === 'benchmark' || $this.val() === 'constantcontact' || $this.val() === 'mailrelay' || $this.val() === 'activecampaign' ) {
|
37 |
+
widget.find('.wp_subscribe_thanks_page').show();
|
38 |
+
} else {
|
39 |
+
widget.find('.wp_subscribe_thanks_page').hide();
|
40 |
+
}
|
41 |
+
}).trigger('change');
|
42 |
+
widget.find('.wp_subscribe_include_name input').change(function() {
|
43 |
+
if ($(this).is(':checked')) {
|
44 |
+
$('.wp-subscribe-name_placeholder-field').show();
|
45 |
+
} else {
|
46 |
+
$('.wp-subscribe-name_placeholder-field').hide();
|
47 |
+
}
|
48 |
+
}).trigger('change');
|
49 |
+
widget.find('.thanks-page-field').change(function() {
|
50 |
+
if ($(this).is(':checked')) {
|
51 |
+
$('.wp_subscribe_thanks_page_details').show();
|
52 |
+
} else {
|
53 |
+
$('.wp_subscribe_thanks_page_details').hide();
|
54 |
+
}
|
55 |
+
}).trigger('change');
|
56 |
+
}
|
57 |
+
|
58 |
+
function onFormUpdate( event, widget ) {
|
59 |
+
initColorPicker( widget );
|
60 |
+
}
|
61 |
+
|
62 |
+
$( document ).on( 'widget-added widget-updated', onFormUpdate );
|
63 |
+
|
64 |
+
$( document ).ready( function() {
|
65 |
+
$( '#widgets-right .widget:has(.wp-subscribe-service-field select)' ).each( function () {
|
66 |
+
initColorPicker( $( this ) );
|
67 |
+
});
|
68 |
+
} );
|
69 |
+
|
70 |
+
// Get List Code
|
71 |
+
$(document).on( 'click', '.wps-get-list', function( event ) {
|
72 |
+
event.preventDefault();
|
73 |
+
|
74 |
+
var button = $(this),
|
75 |
+
select = button.prev('select'),
|
76 |
+
parent = button.closest('.wps-account-details'),
|
77 |
+
fields = parent.find('input, textarea'),
|
78 |
+
service = parent.data('service');
|
79 |
+
|
80 |
+
var args = {};
|
81 |
+
fields.each(function(){
|
82 |
+
var f = $(this),
|
83 |
+
key = f.data('id').replace(service+'_', '').replace(service, '');
|
84 |
+
|
85 |
+
args[key] = f.val();
|
86 |
+
});
|
87 |
+
|
88 |
+
$.ajax({
|
89 |
+
url: ajaxurl,
|
90 |
+
method: 'post',
|
91 |
+
data: {
|
92 |
+
action: 'wps_get_service_list',
|
93 |
+
service: service,
|
94 |
+
args: args
|
95 |
+
},
|
96 |
+
|
97 |
+
success: function( response ) {
|
98 |
+
|
99 |
+
if( response.success && response.lists ) {
|
100 |
+
var sel = select.val();
|
101 |
+
select.html( '<option value="none">Select List</option>' );
|
102 |
+
$.each( response.lists, function( key, val ){
|
103 |
+
select.append('<option value="'+ key +'">'+ val +'</option>');
|
104 |
+
});
|
105 |
+
select.val(sel);
|
106 |
+
}
|
107 |
+
else {
|
108 |
+
console.log( response.error );
|
109 |
+
}
|
110 |
+
}
|
111 |
+
});
|
112 |
+
|
113 |
+
} );
|
114 |
+
|
115 |
+
// slideToggle
|
116 |
+
$(document).on('click', function(e) {
|
117 |
+
var $this = jQuery(e.target);
|
118 |
+
var $widget = $this.closest('.wp_subscribe_options_form');
|
119 |
+
if ($widget.length) {
|
120 |
+
if ($this.is('.wp-subscribe-toggle')) {
|
121 |
+
e.preventDefault();
|
122 |
+
var $related = $widget.find('.'+$this.attr('rel'));
|
123 |
+
$related.slideToggle();
|
124 |
+
}
|
125 |
+
}
|
126 |
+
});
|
127 |
+
|
128 |
+
/*
|
129 |
+
Load Palettes
|
130 |
+
*/
|
131 |
+
$(document).on('click', '.wps-load-palette', function(e) {
|
132 |
+
var $this = $(this),
|
133 |
+
$palette = $this.closest('.single-palette');
|
134 |
+
|
135 |
+
$palette.find('input.wps-palette-color').each(function(i, el) {
|
136 |
+
$('#'+$(el).attr('name')).iris('color', $(el).val());
|
137 |
+
});
|
138 |
+
|
139 |
+
e.preventDefault();
|
140 |
+
});
|
141 |
+
$(document).on('click', '.wps-toggle-palettes', function(e) {
|
142 |
+
$(this).closest('.wps-colors-loader').find('.wps-palettes').slideToggle();
|
143 |
+
e.preventDefault();
|
144 |
+
});
|
145 |
+
|
146 |
+
}( jQuery ) );
|
assets/js/wp-subscribe-form.js
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Plugin Name: WP Subscribe Pro
|
3 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe-pro/
|
4 |
+
Description: WP Subscribe is a simple but powerful subscription plugin which supports MailChimp, Aweber and Feedburner.
|
5 |
+
Author: MyThemeShop
|
6 |
+
Author URI: http://mythemeshop.com/
|
7 |
+
*/
|
8 |
+
|
9 |
+
/* global wp_subscribe*/
|
10 |
+
jQuery(document).ready(function($) {
|
11 |
+
|
12 |
+
// AJAX subscribe form
|
13 |
+
// not working on Feedburner
|
14 |
+
$( '.wp-subscribe-form' ).submit( function( event ) {
|
15 |
+
|
16 |
+
event.preventDefault();
|
17 |
+
|
18 |
+
var form = $(this),
|
19 |
+
$widget = form.closest('.wp-subscribe').addClass('loading'),
|
20 |
+
fields = {};
|
21 |
+
|
22 |
+
if ( form.hasClass('wp-subscribe-feedburner') ) {
|
23 |
+
|
24 |
+
var original = window.open;
|
25 |
+
window.open = function( url, name, specs, replace ) {
|
26 |
+
var popup = original( url, name, specs, replace );
|
27 |
+
|
28 |
+
if( ! popup ) {
|
29 |
+
return popup;
|
30 |
+
}
|
31 |
+
|
32 |
+
if( ! url.includes( 'feedburner.google.com' ) ) {
|
33 |
+
return popup;
|
34 |
+
}
|
35 |
+
|
36 |
+
var interval = setInterval( function() {
|
37 |
+
|
38 |
+
if( popup && popup.closed ) {
|
39 |
+
clearInterval( interval );
|
40 |
+
|
41 |
+
form.hide();
|
42 |
+
$widget.find('.error').hide();
|
43 |
+
$widget.find('.thanks').show();
|
44 |
+
|
45 |
+
var thanks_page_url = $widget.data('thanks_page_url');
|
46 |
+
if ( $widget.data('thanks_page') === '1' && thanks_page_url !== '') {
|
47 |
+
window.location.href = thanks_page_url;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}, 300 );
|
51 |
+
|
52 |
+
return popup;
|
53 |
+
};
|
54 |
+
|
55 |
+
window.open( form.attr('action') + '&' + form.serialize() , 'popupwindow', 'scrollbars=yes,width=550,height=520' );
|
56 |
+
|
57 |
+
window.open = original;
|
58 |
+
|
59 |
+
return false;
|
60 |
+
}
|
61 |
+
|
62 |
+
$.map( form.serializeArray(), function( item ){
|
63 |
+
fields[ item['name'] ] = item['value'];
|
64 |
+
});
|
65 |
+
|
66 |
+
$.ajax({
|
67 |
+
|
68 |
+
url: wp_subscribe.ajaxurl,
|
69 |
+
type: 'POST',
|
70 |
+
data: {
|
71 |
+
action: 'validate_subscribe',
|
72 |
+
wps_data: fields
|
73 |
+
}
|
74 |
+
|
75 |
+
}).done( function( data ) {
|
76 |
+
|
77 |
+
$widget.removeClass('loading');
|
78 |
+
|
79 |
+
if( data.success ) {
|
80 |
+
|
81 |
+
form.hide();
|
82 |
+
$widget.find('.error').hide();
|
83 |
+
$widget.find('.thanks').show();
|
84 |
+
|
85 |
+
var thanks_page_url = $widget.data('thanks_page_url');
|
86 |
+
if ( $widget.data('thanks_page') === '1' && thanks_page_url !== '') {
|
87 |
+
window.location.href = thanks_page_url;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
else {
|
91 |
+
if ( data.error ) {
|
92 |
+
$widget.find('.error').html(data.error).show();
|
93 |
+
}
|
94 |
+
else {
|
95 |
+
$widget.find('.error').show();
|
96 |
+
}
|
97 |
+
}
|
98 |
+
});
|
99 |
+
|
100 |
+
});
|
101 |
+
});
|
assets/js/wp-subscribe-options.js
ADDED
@@ -0,0 +1,512 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Plugin Name: WP Subscribe Pro
|
3 |
+
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe-pro/
|
4 |
+
Description: WP Subscribe is a simple but powerful subscription plugin which supports MailChimp, Aweber and Feedburner.
|
5 |
+
Author: MyThemeShop
|
6 |
+
Author URI: http://mythemeshop.com/
|
7 |
+
*/
|
8 |
+
|
9 |
+
/* global wps_opts */
|
10 |
+
;( function( $ ) {
|
11 |
+
|
12 |
+
var WpSubscriber = {
|
13 |
+
|
14 |
+
init: function() {
|
15 |
+
|
16 |
+
// Cache
|
17 |
+
this.previewButtons = $('.wp-subscribe-preview-popup');
|
18 |
+
this.popupOptions = $('#wp-subscribe-popup-options');
|
19 |
+
|
20 |
+
// Init others
|
21 |
+
this.colorPicker();
|
22 |
+
this.popup();
|
23 |
+
this.subscription();
|
24 |
+
this.singlePost();
|
25 |
+
this.misc();
|
26 |
+
},
|
27 |
+
|
28 |
+
singlePost: function() {
|
29 |
+
|
30 |
+
$('#wp_subscribe_enable_single_post_form').change(function() {
|
31 |
+
|
32 |
+
if ( $(this).is(':checked') ) {
|
33 |
+
$('#wp-subscribe-single-options').slideDown();
|
34 |
+
} else {
|
35 |
+
$('#wp-subscribe-single-options').slideUp();
|
36 |
+
}
|
37 |
+
|
38 |
+
});
|
39 |
+
|
40 |
+
$('#copy_options_popup_to_single').click(function( event ) {
|
41 |
+
|
42 |
+
event.preventDefault();
|
43 |
+
|
44 |
+
$('#wp-subscribe-single-options').find('input').each(function() {
|
45 |
+
var $input = $(this);
|
46 |
+
var $mapped = $('#'+this.id.replace('single_post', 'popup'));
|
47 |
+
if ( $mapped.length && $mapped.prop('id') !== this.id ) {
|
48 |
+
$input.val($mapped.val()).trigger('change');
|
49 |
+
}
|
50 |
+
});
|
51 |
+
|
52 |
+
var service = $('#popup_form_service').val();
|
53 |
+
$('#single_post_form_service option').each(function() {
|
54 |
+
var $this = $(this);
|
55 |
+
if ( service === $this.attr('value') ) {
|
56 |
+
$this.prop('selected', true);
|
57 |
+
}
|
58 |
+
else {
|
59 |
+
$this.prop('selected', false);
|
60 |
+
}
|
61 |
+
}).trigger('change');
|
62 |
+
});
|
63 |
+
},
|
64 |
+
|
65 |
+
subscription: function() {
|
66 |
+
|
67 |
+
var formLabels = $('._popup_form_labels_name_placeholder-wrapper'),
|
68 |
+
postLabels = $('._single_post_form_labels_name_placeholder-wrapper');
|
69 |
+
|
70 |
+
$('.services_dropdown').change(function() {
|
71 |
+
|
72 |
+
var $this = $(this),
|
73 |
+
value = $this.val(),
|
74 |
+
parent = $this.parent(),
|
75 |
+
nameFields = parent.siblings( '.wp_subscribe_include_name_wrapper' ),
|
76 |
+
thankyouFields = parent.siblings( '.wp_subscribe_thanks_page' );
|
77 |
+
|
78 |
+
parent.next().find('.wp_subscribe_account_details_'+$this.val()).show().siblings().hide();
|
79 |
+
|
80 |
+
if ( 'feedburner' === value ) {
|
81 |
+
nameFields.hide();
|
82 |
+
|
83 |
+
if ( $this.closest('#wp-subscribe-single-options').length ) {
|
84 |
+
postLabels.hide();
|
85 |
+
}
|
86 |
+
else {
|
87 |
+
formLabels.hide();
|
88 |
+
}
|
89 |
+
|
90 |
+
} else {
|
91 |
+
nameFields.show().find('input').trigger('change');
|
92 |
+
}
|
93 |
+
|
94 |
+
// Thanks Page option
|
95 |
+
if ( -1 < $.inArray( value, [ 'mailchimp', 'getresponse', 'mailerlite', 'benchmark', 'constantcontact', 'mailrelay', 'activecampaign' ] ) ) {
|
96 |
+
thankyouFields.show();
|
97 |
+
} else {
|
98 |
+
thankyouFields.hide();
|
99 |
+
}
|
100 |
+
|
101 |
+
}).trigger('change');
|
102 |
+
|
103 |
+
$('.thanks-page-field').change(function() {
|
104 |
+
|
105 |
+
$(this).parent().siblings('.wp_subscribe_thanks_page_details').toggle( this.checked );
|
106 |
+
|
107 |
+
}).trigger( 'change' );
|
108 |
+
|
109 |
+
$('.wp_subscribe_include_name_wrapper input').change(function() {
|
110 |
+
|
111 |
+
var $this = $(this);
|
112 |
+
|
113 |
+
if ( $this.is(':checked') ) {
|
114 |
+
if ($this.closest('#wp-subscribe-single-options').length) {
|
115 |
+
postLabels.show();
|
116 |
+
}
|
117 |
+
else {
|
118 |
+
formLabels.show();
|
119 |
+
}
|
120 |
+
} else {
|
121 |
+
if ($this.closest('#wp-subscribe-single-options').length) {
|
122 |
+
postLabels.hide();
|
123 |
+
}
|
124 |
+
else {
|
125 |
+
formLabels.hide();
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
}).trigger('change');
|
130 |
+
|
131 |
+
// Get List Code
|
132 |
+
$('.wps-get-list').on( 'click', function( event ) {
|
133 |
+
event.preventDefault();
|
134 |
+
|
135 |
+
var button = $(this),
|
136 |
+
select = button.prev('select'),
|
137 |
+
parent = button.closest('.wps-account-details'),
|
138 |
+
fields = parent.find('input, textarea'),
|
139 |
+
service = parent.data('service');
|
140 |
+
|
141 |
+
var args = {};
|
142 |
+
fields.each(function(){
|
143 |
+
var f = $(this);
|
144 |
+
|
145 |
+
if ( f.data( 'id' ) && f.data( 'id' ).length > 0 ) {
|
146 |
+
var key = f.data( 'id' ).replace(service+'_', '').replace(service, '');
|
147 |
+
args[key] = f.val();
|
148 |
+
}
|
149 |
+
});
|
150 |
+
|
151 |
+
$.ajax({
|
152 |
+
url: ajaxurl,
|
153 |
+
method: 'post',
|
154 |
+
data: {
|
155 |
+
action: 'wps_get_service_list',
|
156 |
+
service: service,
|
157 |
+
args: args
|
158 |
+
},
|
159 |
+
|
160 |
+
success: function( response ) {
|
161 |
+
|
162 |
+
if( response.success && response.lists ) {
|
163 |
+
var sel = select.val();
|
164 |
+
select.html( '<option value="none">Select List</option>' );
|
165 |
+
$.each( response.lists, function( key, val ){
|
166 |
+
select.append('<option value="'+ key +'">'+ val +'</option>');
|
167 |
+
});
|
168 |
+
select.val(sel);
|
169 |
+
}
|
170 |
+
else {
|
171 |
+
console.log( response.error );
|
172 |
+
}
|
173 |
+
}
|
174 |
+
});
|
175 |
+
|
176 |
+
} );
|
177 |
+
},
|
178 |
+
|
179 |
+
colorPicker: function() {
|
180 |
+
|
181 |
+
$('.wp-subscribe-color-select').wpColorPicker({
|
182 |
+
change: _.throttle(function(event, ui) {
|
183 |
+
$(this).trigger( 'colorchange', [ui.color.toString()] );
|
184 |
+
}, 2000 )
|
185 |
+
});
|
186 |
+
|
187 |
+
$(document).on('click', '.wps-load-palette', function( event ) {
|
188 |
+
|
189 |
+
event.preventDefault();
|
190 |
+
|
191 |
+
var $this = $(this),
|
192 |
+
palette = $this.closest('.single-palette');
|
193 |
+
|
194 |
+
palette.find('input.wps-palette-color').each(function( i, el ) {
|
195 |
+
|
196 |
+
var elem = $(el);
|
197 |
+
|
198 |
+
$('#' + elem.attr('name') ).iris('color', elem.val() );
|
199 |
+
});
|
200 |
+
});
|
201 |
+
|
202 |
+
$(document).on('click', '.wps-toggle-palettes', function( event ) {
|
203 |
+
|
204 |
+
event.preventDefault();
|
205 |
+
|
206 |
+
$(this).closest('.wps-colors-loader').find('.wps-palettes').slideToggle();
|
207 |
+
});
|
208 |
+
},
|
209 |
+
|
210 |
+
popup: function() {
|
211 |
+
|
212 |
+
var wps = this;
|
213 |
+
|
214 |
+
wps.popupColor();
|
215 |
+
wps.popupOpacity();
|
216 |
+
wps.popupWidth();
|
217 |
+
wps.popupPreview();
|
218 |
+
|
219 |
+
$('#wp_subscribe_enable_popup').change(function() {
|
220 |
+
|
221 |
+
if ( $(this).is(':checked') ) {
|
222 |
+
|
223 |
+
wps.popupOptions.slideDown();
|
224 |
+
$('.ifpopup').show();
|
225 |
+
|
226 |
+
} else {
|
227 |
+
|
228 |
+
wps.popupOptions.slideUp();
|
229 |
+
$('.ifpopup').hide();
|
230 |
+
|
231 |
+
}
|
232 |
+
});
|
233 |
+
|
234 |
+
$('.popup_content_field').change(function() {
|
235 |
+
|
236 |
+
var value = $(this).val(),
|
237 |
+
form = $('#wp-subscribe-form-options'),
|
238 |
+
posts = $('#wp-subscribe-popup-posts-options'),
|
239 |
+
custom = $('#wp-subscribe-custom-html-field');
|
240 |
+
|
241 |
+
// Hide All
|
242 |
+
form.hide();
|
243 |
+
posts.hide();
|
244 |
+
custom.hide();
|
245 |
+
|
246 |
+
switch( value ) {
|
247 |
+
|
248 |
+
case 'subscribe_form':
|
249 |
+
form.show();
|
250 |
+
break;
|
251 |
+
|
252 |
+
case 'posts':
|
253 |
+
posts.show();
|
254 |
+
break;
|
255 |
+
|
256 |
+
case 'custom_html':
|
257 |
+
custom.show();
|
258 |
+
break;
|
259 |
+
}
|
260 |
+
|
261 |
+
var $tab = $('#popup-content-tab');
|
262 |
+
$tab.addClass('nav-tab-active');
|
263 |
+
setTimeout(function() {
|
264 |
+
$tab.removeClass('nav-tab-active');
|
265 |
+
}, 200);
|
266 |
+
});
|
267 |
+
|
268 |
+
wps.firePopup( wps_opts.popup_removal_delay );
|
269 |
+
|
270 |
+
$('#popup_animation_in').on('change', function() {
|
271 |
+
wps.previewButtons.attr( 'data-animatein', $(this).val() );
|
272 |
+
});
|
273 |
+
|
274 |
+
$('#popup_animation_out').on('change', function() {
|
275 |
+
|
276 |
+
var value = $(this).val();
|
277 |
+
wps.previewButtons.attr( 'data-animateout', value );
|
278 |
+
|
279 |
+
if (value === 'hinge') {
|
280 |
+
wps.firePopup(2000);
|
281 |
+
} else if (value === '0') {
|
282 |
+
wps.firePopup(0);
|
283 |
+
} else {
|
284 |
+
wps.firePopup(800);
|
285 |
+
}
|
286 |
+
});
|
287 |
+
},
|
288 |
+
|
289 |
+
firePopup: function(removal_delay) {
|
290 |
+
|
291 |
+
var wps = this;
|
292 |
+
|
293 |
+
wps.previewButtons.magnificPopup({
|
294 |
+
type:'inline',
|
295 |
+
midClick: true,
|
296 |
+
removalDelay: removal_delay, //delay removal by X to allow out-animation
|
297 |
+
callbacks: {
|
298 |
+
beforeOpen: function() {
|
299 |
+
this.st.mainClass = 'animated ' + this.st.el.attr( 'data-animatein' );
|
300 |
+
},
|
301 |
+
beforeClose: function() {
|
302 |
+
var $wrap = this.wrap,
|
303 |
+
$bg = $wrap.prev(),
|
304 |
+
$mfp = $wrap.add($bg);
|
305 |
+
|
306 |
+
$mfp.removeClass( this.st.el.attr( 'data-animatein' ) ).addClass( this.st.el.attr( 'data-animateout' ) );
|
307 |
+
}
|
308 |
+
}
|
309 |
+
});
|
310 |
+
},
|
311 |
+
|
312 |
+
popupPreview: function() {
|
313 |
+
|
314 |
+
var wps = this;
|
315 |
+
|
316 |
+
$('.popup_content_field, .wps-popup-content-options input, .wp-editor-area').on('change colorchange', function() {
|
317 |
+
|
318 |
+
wps.previewButtons.addClass('disabled');
|
319 |
+
|
320 |
+
var fields = $('#wp_subscribe_options_form').serialize() + '&action=preview_popup';
|
321 |
+
$.ajax({
|
322 |
+
url: ajaxurl,
|
323 |
+
type: 'POST',
|
324 |
+
dataType: 'html',
|
325 |
+
data: fields,
|
326 |
+
|
327 |
+
}).done(function(response) {
|
328 |
+
|
329 |
+
$('#wp_subscribe_popup').html(response);
|
330 |
+
|
331 |
+
}).always(function() {
|
332 |
+
|
333 |
+
wps.previewButtons.removeClass('disabled');
|
334 |
+
|
335 |
+
});
|
336 |
+
});
|
337 |
+
},
|
338 |
+
|
339 |
+
popupOpacity: function() {
|
340 |
+
|
341 |
+
var changeOpacity = function( opacity ) {
|
342 |
+
$( '#overlay-style-opacity' ).html( '.mfp-bg.mfp-ready {opacity: ' + opacity + ';}' );
|
343 |
+
};
|
344 |
+
|
345 |
+
var input = $( '#wp_subscribe_overlay_opacity' ),
|
346 |
+
slider = $( '#wp-subscribe-opacity-slider' );
|
347 |
+
|
348 |
+
input.on('change', function() {
|
349 |
+
var value = parseFloat( input.val() );
|
350 |
+
if ( value < 0 ) {
|
351 |
+
value = 0;
|
352 |
+
input.val('0');
|
353 |
+
} else if ( value > 1 ) {
|
354 |
+
value = 1;
|
355 |
+
input.val('1');
|
356 |
+
}
|
357 |
+
slider.slider( 'value', value );
|
358 |
+
changeOpacity( value );
|
359 |
+
});
|
360 |
+
|
361 |
+
slider.slider({
|
362 |
+
range: 'min',
|
363 |
+
value: input.val(),
|
364 |
+
step: 0.01,
|
365 |
+
min: 0,
|
366 |
+
max: 1,
|
367 |
+
slide: function(event, ui) {
|
368 |
+
input.val( ui.value );
|
369 |
+
changeOpacity( ui.value );
|
370 |
+
}
|
371 |
+
});
|
372 |
+
},
|
373 |
+
|
374 |
+
popupColor: function() {
|
375 |
+
|
376 |
+
$('#wp_subscribe_options_colors_popup_overlay_color').on( 'colorchange', function( event, color ) {
|
377 |
+
$('#overlay-style-color').html('.mfp-bg {background: ' + color + ';}');
|
378 |
+
});
|
379 |
+
},
|
380 |
+
|
381 |
+
popupWidth: function() {
|
382 |
+
|
383 |
+
var changeWidth = function( width ) {
|
384 |
+
$('#popup-style-width').html('#wp_subscribe_popup {width: ' + width + 'px;}');
|
385 |
+
|
386 |
+
var breakpoints = [300, 600, 900],
|
387 |
+
popup = $('#wp_subscribe_popup');
|
388 |
+
|
389 |
+
$.each(breakpoints, function(index, breakpoint) {
|
390 |
+
if (width < breakpoint) {
|
391 |
+
popup.addClass( 'lt_' + breakpoint );
|
392 |
+
} else {
|
393 |
+
popup.removeClass( 'lt_' + breakpoint );
|
394 |
+
}
|
395 |
+
});
|
396 |
+
};
|
397 |
+
|
398 |
+
var input = $( '#wp_subscribe_popup_width' ),
|
399 |
+
slider = $( '#wp-subscribe-popup-width-slider' );
|
400 |
+
|
401 |
+
input.on('change', function() {
|
402 |
+
var value = parseFloat( input.val() );
|
403 |
+
|
404 |
+
if (value < 0) {
|
405 |
+
value = 0;
|
406 |
+
input.val('0');
|
407 |
+
} else if (value > 1200) {
|
408 |
+
value = 1200;
|
409 |
+
input.val('1200');
|
410 |
+
}
|
411 |
+
|
412 |
+
slider.slider( 'value', value );
|
413 |
+
changeWidth( value );
|
414 |
+
});
|
415 |
+
|
416 |
+
slider.slider({
|
417 |
+
range: 'min',
|
418 |
+
value: input.val(),
|
419 |
+
step: 10,
|
420 |
+
min: 200,
|
421 |
+
max: 1200,
|
422 |
+
slide: function(event, ui) {
|
423 |
+
input.val( ui.value );
|
424 |
+
changeWidth( ui.value );
|
425 |
+
}
|
426 |
+
});
|
427 |
+
},
|
428 |
+
|
429 |
+
misc: function() {
|
430 |
+
|
431 |
+
$('#wp_subscribe_regenerate_cookie').click(function( event ) {
|
432 |
+
|
433 |
+
event.preventDefault();
|
434 |
+
|
435 |
+
$('#cookies-cleared').fadeIn();
|
436 |
+
$('#cookiehash').val(new Date().getTime());
|
437 |
+
|
438 |
+
});
|
439 |
+
|
440 |
+
// Tabs
|
441 |
+
var tabNav = $( '.wps-nav-tab-wrapper a' ),
|
442 |
+
tabContent = $( ' > div ', '.wps-tabs-wrapper');
|
443 |
+
|
444 |
+
tabNav.click(function( event ) {
|
445 |
+
|
446 |
+
event.preventDefault();
|
447 |
+
|
448 |
+
var $this = $(this);
|
449 |
+
|
450 |
+
tabNav.removeClass( 'nav-tab-active' );
|
451 |
+
$this.addClass( 'nav-tab-active' );
|
452 |
+
|
453 |
+
tabContent.hide();
|
454 |
+
tabContent.closest( $this.data('rel') ).show();
|
455 |
+
|
456 |
+
});
|
457 |
+
|
458 |
+
// Aweber Autorize Code
|
459 |
+
$( 'button.aweber_authorization' ).on( 'click', function() {
|
460 |
+
|
461 |
+
var $this= $( this ),
|
462 |
+
parent = $this.parent(),
|
463 |
+
code = parent.find( 'textarea' ).val().trim();
|
464 |
+
|
465 |
+
if( '' === code ) {
|
466 |
+
alert( 'No authorization code found.' );
|
467 |
+
return;
|
468 |
+
}
|
469 |
+
|
470 |
+
$.ajax({
|
471 |
+
url: ajaxurl,
|
472 |
+
type: 'POST',
|
473 |
+
data: {
|
474 |
+
action: 'connect_aweber',
|
475 |
+
aweber_code: code
|
476 |
+
}
|
477 |
+
|
478 |
+
}).done(function(response) {
|
479 |
+
|
480 |
+
if ( response && ! response.success && response.error ) {
|
481 |
+
alert( response.error );
|
482 |
+
return;
|
483 |
+
}
|
484 |
+
|
485 |
+
var details = parent.parent();
|
486 |
+
for( key in response.data ) {
|
487 |
+
details.find( '[id$="_' + key + '"]' ).val( response.data[ key ] );
|
488 |
+
}
|
489 |
+
|
490 |
+
parent.hide();
|
491 |
+
parent.next().show();
|
492 |
+
});
|
493 |
+
});
|
494 |
+
|
495 |
+
// Disconnect Aweber
|
496 |
+
$( 'a.aweber_disconnect' ).on( 'click', function() {
|
497 |
+
var $this= $( this ),
|
498 |
+
parent = $this.closest( '.alert-hint' );
|
499 |
+
|
500 |
+
parent.hide();
|
501 |
+
parent.prev().show();
|
502 |
+
|
503 |
+
parent.parent().find( 'input[type="hidden"]' ).val( '' );
|
504 |
+
});
|
505 |
+
}
|
506 |
+
};
|
507 |
+
|
508 |
+
$( document ).ready( function() {
|
509 |
+
WpSubscriber.init();
|
510 |
+
} );
|
511 |
+
|
512 |
+
}( jQuery ) );
|
css/wp-subscribe-admin.css
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Plugin Name: WP Subscribe
|
3 |
-
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe/
|
4 |
-
Author: MyThemeShop
|
5 |
-
Author URI: http://mythemeshop.com
|
6 |
-
*/
|
7 |
-
.wp_subscribe_options_form label { vertical-align: top }
|
8 |
-
.wp_subscribe_colors, .wp_subscribe_labels { }
|
9 |
-
.wp_subscribe_options_form .wp-picker-container { position: absolute; right: 0; }
|
10 |
-
.wp_subscribe_colors > div { position: relative; margin: 20px 0; }
|
11 |
-
.wp_subscribe_colors label { display: inline-block; margin-top: 2px; }
|
12 |
-
.wp_subscribe_options_form .wp-picker-container > a { margin-right: 0 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
css/wp-subscribe.css
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Plugin Name: WP Subscribe
|
3 |
-
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe/
|
4 |
-
Author: MyThemeShop
|
5 |
-
Author URI: http://mythemeshop.com
|
6 |
-
*/
|
7 |
-
#wp-subscribe { padding: 26px; background: #f47555; }
|
8 |
-
#wp-subscribe h4.title { font-size: 22px; color: #FFFFFF; line-height: 1; text-align: center; text-transform: uppercase; margin-bottom: 0; }
|
9 |
-
#wp-subscribe h4.title span { display: inline-block; font-weight: bold; font-size: 38px; margin-top: 15px; }
|
10 |
-
#wp-subscribe p { color: #FFFFFF; margin: 0; text-align: center; }
|
11 |
-
#wp-subscribe p.text { margin: 15px 0; opacity: 0.8; }
|
12 |
-
#wp-subscribe input { border: none; width: 100%; text-align: center; box-sizing: border-box; padding: 10px 0; margin: 0; box-shadow: none; border-radius: 0; height: 45px; }
|
13 |
-
#wp-subscribe .email-field { margin-top: 10px }
|
14 |
-
#wp-subscribe input.email-field, #wp-subscribe input.name-field { color: #FFFFFF; background: #d56144; }
|
15 |
-
#wp-subscribe input::-webkit-input-placeholder { color: inherit; opacity: 0.8; }
|
16 |
-
#wp-subscribe input:-moz-input-placeholder { color: inherit; opacity: 0.8; }
|
17 |
-
#wp-subscribe input::-moz-input-placeholder { color: inherit; opacity: 0.8; }
|
18 |
-
#wp-subscribe input::-ms-input-placeholder { color: inherit; opacity: 0.8; }
|
19 |
-
#wp-subscribe input:focus::-webkit-input-placeholder { color: transparent !important }
|
20 |
-
#wp-subscribe input:focus::-moz-input-placeholder { color: transparent !important }
|
21 |
-
#wp-subscribe input:focus:-moz-input-placeholder { color: transparent !important }
|
22 |
-
#wp-subscribe input:focus::input-placeholder { color: transparent !important }
|
23 |
-
#wp-subscribe input.submit { background: #FFFFFF; color: #f47555; margin-top: 20px; font-size: 18px; text-transform: uppercase; font-weight: 500; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.05); cursor: pointer; }
|
24 |
-
#wp-subscribe p.footer-text { margin-top: 10px; font-size: 12px; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/class-wps-base.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Base
|
4 |
+
* The base class for all the classes
|
5 |
+
*/
|
6 |
+
|
7 |
+
if( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
8 |
+
|
9 |
+
if( ! class_exists( 'WPS_Base' ) ):
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Base Class
|
13 |
+
*/
|
14 |
+
class WPS_Base {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Admin page ID
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
public $id;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Add action
|
24 |
+
*
|
25 |
+
* @see add_action
|
26 |
+
*/
|
27 |
+
protected function add_action( $hook, $func, $priority = 10, $args = 1 ) {
|
28 |
+
add_action( $hook, array( &$this, $func ), $priority, $args );
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Add filter
|
33 |
+
*
|
34 |
+
* @see add_filter
|
35 |
+
*/
|
36 |
+
protected function add_filter( $hook, $func, $priority = 10, $args = 1 ) {
|
37 |
+
add_filter( $hook, array( &$this, $func ), $priority, $args );
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Remove Action
|
42 |
+
*
|
43 |
+
* @see remove_action
|
44 |
+
*/
|
45 |
+
protected function remove_action( $hook, $func, $priority = 10, $args = 1 ) {
|
46 |
+
remove_action( $hook, array( &$this, $func ), $priority, $args );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Remove filter
|
51 |
+
*
|
52 |
+
* @see remove_filter
|
53 |
+
*/
|
54 |
+
protected function remove_filter( $hook, $func, $priority = 10, $args = 1 ) {
|
55 |
+
remove_filter( $hook, array( &$this, $func ), $priority, $args );
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Inject config into class
|
60 |
+
*
|
61 |
+
* @param array $config
|
62 |
+
* @return void
|
63 |
+
*/
|
64 |
+
protected function config( $config = array() ) {
|
65 |
+
|
66 |
+
// check
|
67 |
+
if( empty( $config ) ) {
|
68 |
+
return;
|
69 |
+
}
|
70 |
+
|
71 |
+
foreach( $config as $key => $value ) {
|
72 |
+
$this->$key = $value;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Is current page equals this
|
78 |
+
*
|
79 |
+
* @return boolean
|
80 |
+
*/
|
81 |
+
protected function is_current_page() {
|
82 |
+
$page = isset( $_GET['page'] ) && !empty( $_GET['page'] ) ? $_GET['page'] : false;
|
83 |
+
return $page === $this->id;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
endif;
|
includes/subscription/class-wps-aweber.php
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Aweber Subscription
|
4 |
+
*/
|
5 |
+
class WPS_Subscription_Aweber extends WPS_Subscription_Base {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Aweber Credentials
|
9 |
+
* @var mixed
|
10 |
+
*/
|
11 |
+
public $credentials;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* API Key
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
public $api_key;
|
18 |
+
|
19 |
+
public function init() {
|
20 |
+
|
21 |
+
if( !class_exists( 'AWeberAPI' ) ) {
|
22 |
+
require_once 'libs/aweber_api/aweber.php';
|
23 |
+
}
|
24 |
+
|
25 |
+
$credentials = $this->get_credentials();
|
26 |
+
|
27 |
+
if( empty( $credentials['consumer_key'] ) || empty( $credentials['consumer_secret'] ) ) {
|
28 |
+
throw new Exception ('Aweber is not connected.');
|
29 |
+
}
|
30 |
+
|
31 |
+
if( empty( $credentials['account_id'] ) ) {
|
32 |
+
throw new Exception ('The Aweber Account ID is not set.');
|
33 |
+
}
|
34 |
+
|
35 |
+
$api = new AWeberAPI( $credentials['consumer_key'], $credentials['consumer_secret'] );
|
36 |
+
|
37 |
+
return $api;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function get_credentials() {
|
41 |
+
|
42 |
+
if( !empty( $this->credentials ) ) {
|
43 |
+
return $this->credentials;
|
44 |
+
}
|
45 |
+
|
46 |
+
$credentials = array_filter( $credentials );
|
47 |
+
|
48 |
+
$this->credentials = empty( $credentials ) ? null : $credentials;
|
49 |
+
|
50 |
+
return $this->credentials;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function connect( $api_key = '' ) {
|
54 |
+
|
55 |
+
// if the auth code is empty, show the error
|
56 |
+
if ( empty( $api_key ) ) {
|
57 |
+
throw new Exception( esc_html__( 'Unable to connect to Aweber. The Authorization Code is empty.', 'wp-subscribe' ) );
|
58 |
+
}
|
59 |
+
|
60 |
+
if ( ! class_exists( 'AWeberAPI' ) ) {
|
61 |
+
require_once dirname( __FILE__ ) . '/libs/aweber_api/aweber.php';
|
62 |
+
}
|
63 |
+
|
64 |
+
list( $consumer_key, $consumer_secret, $access_key, $access_secret ) = AWeberAPI::getDataFromAweberID( $api_key );
|
65 |
+
|
66 |
+
if ( empty( $consumer_key ) || empty( $consumer_secret ) || empty( $access_key ) || empty( $access_secret ) ) {
|
67 |
+
throw new Exception( esc_html__('Unable to connect your Aweber Account. The Authorization Code is incorrect.', 'wp-subscribe' ) );
|
68 |
+
}
|
69 |
+
|
70 |
+
$aweber = new AWeberAPI( $consumer_key, $consumer_secret );
|
71 |
+
$account = $aweber->getAccount( $access_key, $access_secret );
|
72 |
+
|
73 |
+
return array(
|
74 |
+
'consumer_key' => $consumer_key,
|
75 |
+
'consumer_secret' => $consumer_secret,
|
76 |
+
'access_key' => $access_key,
|
77 |
+
'access_secret' => $access_secret,
|
78 |
+
'account_id' => $account->id
|
79 |
+
);
|
80 |
+
}
|
81 |
+
|
82 |
+
public function get_account() {
|
83 |
+
|
84 |
+
$aweber = $this->init();
|
85 |
+
$credentials = $this->get_credentials();
|
86 |
+
|
87 |
+
if( empty( $credentials['access_key'] ) || empty( $credentials['access_secret'] ) ) {
|
88 |
+
throw new Exception ('[init]: Aweber is not connected.');
|
89 |
+
}
|
90 |
+
|
91 |
+
return $aweber->getAccount( $credentials['access_key'], $credentials['access_secret'] );
|
92 |
+
}
|
93 |
+
|
94 |
+
public function get_lists() {
|
95 |
+
|
96 |
+
$this->credentials = end( func_get_args() );
|
97 |
+
$account = $this->get_account();
|
98 |
+
|
99 |
+
$lists = array();
|
100 |
+
foreach( $account->lists->data['entries'] as $list ) {
|
101 |
+
$lists[ $list['id'] ] = $list['name'];
|
102 |
+
}
|
103 |
+
|
104 |
+
return $lists;
|
105 |
+
}
|
106 |
+
|
107 |
+
public function subscribe( $identity, $options ) {
|
108 |
+
|
109 |
+
try {
|
110 |
+
$account = $this->get_account();
|
111 |
+
$credentials = $this->get_credentials();
|
112 |
+
$list_url = "/accounts/{$account->id}/lists/{$options['list']}/subscribers";
|
113 |
+
$list = $account->loadFromUrl($list_url);
|
114 |
+
|
115 |
+
$name = $this->get_fullname( $identity );
|
116 |
+
$params = array(
|
117 |
+
'name' => $name,
|
118 |
+
'email' => $identity['email'],
|
119 |
+
'ip_address' => $_SERVER['REMOTE_ADDR'],
|
120 |
+
'ad_tracking' => 'mythemeshop'
|
121 |
+
);
|
122 |
+
|
123 |
+
$list->create($params);
|
124 |
+
|
125 |
+
return array(
|
126 |
+
'status' => 'subscribed'
|
127 |
+
);
|
128 |
+
}
|
129 |
+
catch( Exception $e ) {
|
130 |
+
|
131 |
+
// already waiting confirmation:
|
132 |
+
// "Subscriber already subscribed and has not confirmed."
|
133 |
+
if ( strpos( $e->getMessage(), 'has not confirmed' ) ) {
|
134 |
+
return array( 'status' => 'pending' );
|
135 |
+
}
|
136 |
+
|
137 |
+
// already waiting confirmation:
|
138 |
+
// "Subscriber already subscribed."
|
139 |
+
if ( strpos( $e->getMessage(), 'already subscribed' ) ) {
|
140 |
+
return array( 'status' => 'pending' );
|
141 |
+
}
|
142 |
+
|
143 |
+
throw new Exception ( '[subscribe]: ' . $e->getMessage() );
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
public function get_fields() {
|
148 |
+
|
149 |
+
$instance = func_get_arg( 0 ); ?>
|
150 |
+
|
151 |
+
<div class="aweber_authorization_area mb30<?php echo ! empty( $instance['aweber_access_key'] ) ? ' hidden' : '' ?>">
|
152 |
+
<strong><?php esc_html_e( 'To connect your Aweber account:', 'content-locker' ) ?></strong>
|
153 |
+
<br />
|
154 |
+
<ul>
|
155 |
+
<li><?php printf( wp_kses_post( __( '<span>1.</span> <a href="%s" target="_blank">Click here</a> <span>to open the authorization page and log in.</span>', 'content-locker' ) ), 'https://auth.aweber.com/1.0/oauth/authorize_app/1afc783e' ) ?></li>
|
156 |
+
<li><?php echo wp_kses_post( __( '<span>2.</span> Copy and paste the authorization code in the field below.', 'content-locker' ) ) ?></li>
|
157 |
+
</ul>
|
158 |
+
|
159 |
+
<textarea rows="4" cols="80"></textarea>
|
160 |
+
<br />
|
161 |
+
<button type="button" class="button-primary aweber_authorization">Authorize</button>
|
162 |
+
</div>
|
163 |
+
<div class="alert alert-hint mb30 <?php echo empty( $instance['aweber_access_key'] ) ? ' hidden' : '' ?>">
|
164 |
+
<p>
|
165 |
+
<strong><?php _e( 'Your Aweber Account is connected.', 'content-locker' ) ?></strong>
|
166 |
+
<?php echo wp_kses_post( __( '<a href="#" class="aweber_disconnect">Click here</a> <span>to disconnect.</span>', 'content-locker' ) ) ?>
|
167 |
+
</p>
|
168 |
+
</div>
|
169 |
+
<?php
|
170 |
+
|
171 |
+
$fields = array(
|
172 |
+
'aweber_consumer_key' => array(
|
173 |
+
'id' => 'aweber_consumer_key',
|
174 |
+
'name' => 'aweber_consumer_key',
|
175 |
+
'type' => 'hidden',
|
176 |
+
),
|
177 |
+
'aweber_consumer_secret' => array(
|
178 |
+
'id' => 'aweber_consumer_secret',
|
179 |
+
'name' => 'aweber_consumer_secret',
|
180 |
+
'type' => 'hidden',
|
181 |
+
),
|
182 |
+
'aweber_access_key' => array(
|
183 |
+
'id' => 'aweber_access_key',
|
184 |
+
'name' => 'aweber_access_key',
|
185 |
+
'type' => 'hidden',
|
186 |
+
),
|
187 |
+
'aweber_access_secret' => array(
|
188 |
+
'id' => 'aweber_access_secret',
|
189 |
+
'name' => 'aweber_access_secret',
|
190 |
+
'type' => 'hidden',
|
191 |
+
),
|
192 |
+
'aweber_account_id' => array(
|
193 |
+
'id' => 'aweber_account_id',
|
194 |
+
'name' => 'aweber_account_id',
|
195 |
+
'type' => 'hidden',
|
196 |
+
),
|
197 |
+
|
198 |
+
'aweber_list_id' => array(
|
199 |
+
'id' => 'aweber_list_id',
|
200 |
+
'name' => 'aweber_list_id',
|
201 |
+
'type' => 'select',
|
202 |
+
'title' => esc_html__( 'AWeber List', 'wp-subscribe' ),
|
203 |
+
'options' => array( 'none' => esc_html__( 'Select List', 'wp-subscribe' ) ) + wps_get_service_list( 'aweber' ),
|
204 |
+
'is_list' => true
|
205 |
+
),
|
206 |
+
);
|
207 |
+
|
208 |
+
return $fields;
|
209 |
+
}
|
210 |
+
}
|
includes/subscription/class-wps-base.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* A class for subscription services
|
4 |
+
*/
|
5 |
+
abstract class WPS_Subscription_Base {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* To hold the configuration
|
9 |
+
* @var array
|
10 |
+
*/
|
11 |
+
public $config;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Hold Service Options
|
15 |
+
* @var array
|
16 |
+
*/
|
17 |
+
public $options;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* The Constructor
|
21 |
+
* @param array $config [description]
|
22 |
+
*/
|
23 |
+
public function __construct( $config = array() ) {
|
24 |
+
|
25 |
+
$this->config = $config;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Is a valid email address
|
30 |
+
* @param string $email
|
31 |
+
* @return boolean
|
32 |
+
*/
|
33 |
+
public function is_email( $email ) {
|
34 |
+
return filter_var( $email, FILTER_VALIDATE_EMAIL );
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Check for single optin method
|
39 |
+
* @return boolean
|
40 |
+
*/
|
41 |
+
public function has_single_optin() {
|
42 |
+
return in_array( 'quick', $this->config['modes'] );
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Get identity fullname
|
47 |
+
* @param array $identity
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function get_fullname( $identity ) {
|
51 |
+
|
52 |
+
if ( !empty( $identity['name'] ) && !empty( $identity['family'] ) ) {
|
53 |
+
return $identity['name'] . ' ' . $identity['family'];
|
54 |
+
}
|
55 |
+
|
56 |
+
if ( !empty( $identity['name'] ) ) {
|
57 |
+
return $identity['name'];
|
58 |
+
}
|
59 |
+
|
60 |
+
if ( !empty( $identity['family'] ) ) {
|
61 |
+
return $identity['family'];
|
62 |
+
}
|
63 |
+
|
64 |
+
if( !empty( $identity['display_name'] ) ) {
|
65 |
+
return $identity['display_name'];
|
66 |
+
}
|
67 |
+
|
68 |
+
return '';
|
69 |
+
}
|
70 |
+
|
71 |
+
public function get_fields() {
|
72 |
+
return array();
|
73 |
+
}
|
74 |
+
|
75 |
+
public function get_options( $data ) {
|
76 |
+
|
77 |
+
$options = array();
|
78 |
+
$new_options = array();
|
79 |
+
|
80 |
+
if( 'widget' === $data['form_type'] && $data['widget'] ) {
|
81 |
+
$options = wps_get_widget_settings( $data['widget'] );
|
82 |
+
}
|
83 |
+
else {
|
84 |
+
$options = wps_get_options();
|
85 |
+
$options = $options["{$data['form_type']}_form_options"];
|
86 |
+
}
|
87 |
+
|
88 |
+
foreach( $this->get_fields() as $key => $item ) {
|
89 |
+
|
90 |
+
if( isset( $options[ $key ] ) ) {
|
91 |
+
$new_key = str_replace( "{$data['service']}_", '', $key );
|
92 |
+
$new_key = str_replace( "{$data['service']}", '', $new_key );
|
93 |
+
$new_options[$new_key] = $options[ $key ];
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
return $new_options;
|
98 |
+
}
|
99 |
+
|
100 |
+
public function display_form() {
|
101 |
+
|
102 |
+
$args = func_get_args();
|
103 |
+
$instance = array_shift($args);
|
104 |
+
$widget = array_shift($args);
|
105 |
+
$fields = $this->get_fields( $instance );
|
106 |
+
|
107 |
+
foreach( $fields as $id => $field ) {
|
108 |
+
$func = is_null( $widget ) ? 'wps_field_' . $field['type'] : 'field_' . $field['type'];
|
109 |
+
$field['value'] = isset( $instance[$id] ) ? $instance[$id] : '';
|
110 |
+
//$field['service'] = $service;
|
111 |
+
|
112 |
+
if( is_null( $widget ) && function_exists( $func ) ) {
|
113 |
+
$arguments = array_merge( array( $field ), $args );
|
114 |
+
call_user_func_array( $func, $arguments );
|
115 |
+
}
|
116 |
+
|
117 |
+
if( !is_null( $widget ) && method_exists( $widget, $func ) ) {
|
118 |
+
$arguments = array_merge( array( $field ), $args );
|
119 |
+
call_user_func_array( array( $widget, $func ), $arguments );
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
public function the_name_field( $name ) {
|
125 |
+
|
126 |
+
if( !empty( $this->options['include_name_field'] ) ) {
|
127 |
+
printf( '<input class="regular-text name-field" type="text" name="%s" placeholder="%s">', esc_attr( $name ), esc_attr( $this->options['name_placeholder'] ) );
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
public function the_email_field( $name ) {
|
132 |
+
|
133 |
+
printf( '<input class="regular-text email-field" type="text" name="%s" placeholder="%s">', esc_attr( $name ), esc_attr( $this->options['email_placeholder'] ) );
|
134 |
+
}
|
135 |
+
|
136 |
+
public function the_submit_button() {
|
137 |
+
|
138 |
+
printf( '<input class="submit" type="submit" name="submit" value="%s">', esc_attr( $this->options['button_text'] ) );
|
139 |
+
}
|
140 |
+
}
|
includes/subscription/class-wps-feedburner.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* FeedBurner Subscription
|
4 |
+
*/
|
5 |
+
|
6 |
+
class WPS_Subscription_FeedBurner extends WPS_Subscription_Base {
|
7 |
+
|
8 |
+
public function the_form( $id, $options ) {
|
9 |
+
?>
|
10 |
+
|
11 |
+
<form action="https://feedburner.google.com/fb/a/mailverify?uri=<?php echo $options['feedburner_id'] ?>" method="post" class="wp-subscribe-form wp-subscribe-feedburner" id="wp-subscribe-form-<?php echo $id ?>" target="popupwindow">
|
12 |
+
|
13 |
+
<input class="regular-text email-field" type="text" name="email" placeholder="<?php echo esc_attr( $options['email_placeholder'] ) ?>">
|
14 |
+
|
15 |
+
<input type="hidden" name="uri" value="<?php echo $options['feedburner_id'] ?>">
|
16 |
+
|
17 |
+
<input type="hidden" name="loc" value="en_US">
|
18 |
+
|
19 |
+
<input type="hidden" name="form_type" value="<?php echo $options['form_type'] ?>">
|
20 |
+
|
21 |
+
<input type="hidden" name="service" value="<?php echo $options['service'] ?>">
|
22 |
+
|
23 |
+
<input type="hidden" name="widget" value="<?php echo isset( $options['widget_id'] ) ? $options['widget_id'] : '0'; ?>">
|
24 |
+
|
25 |
+
<input class="submit" type="submit" name="submit" value="<?php echo esc_attr( $options['button_text'] ) ?>">
|
26 |
+
|
27 |
+
</form>
|
28 |
+
|
29 |
+
<?php
|
30 |
+
}
|
31 |
+
|
32 |
+
public function get_fields() {
|
33 |
+
|
34 |
+
$fields = array(
|
35 |
+
'feedburner_id' => array(
|
36 |
+
'id' => 'feedburner_id',
|
37 |
+
'name' => 'feedburner_id',
|
38 |
+
'type' => 'text',
|
39 |
+
'title' => esc_html__( 'Feedburner ID', 'wp-subscribe' ),
|
40 |
+
)
|
41 |
+
);
|
42 |
+
|
43 |
+
return $fields;
|
44 |
+
}
|
45 |
+
}
|
includes/subscription/class-wps-mailchimp.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* MailChimp Subscription
|
4 |
+
*/
|
5 |
+
|
6 |
+
class WPS_Subscription_MailChimp extends WPS_Subscription_Base {
|
7 |
+
|
8 |
+
public function init( $api_key ) {
|
9 |
+
|
10 |
+
require_once 'libs/mailchimp.php';
|
11 |
+
return new MailChimp( $api_key );
|
12 |
+
}
|
13 |
+
|
14 |
+
public function get_lists( $api_key ) {
|
15 |
+
|
16 |
+
$mailchimp = $this->init( $api_key );
|
17 |
+
$result = $mailchimp->get('lists');
|
18 |
+
|
19 |
+
if( $mailchimp->getLastError() ) {
|
20 |
+
throw new Exception( $mailchimp->getLastError() );
|
21 |
+
}
|
22 |
+
|
23 |
+
$lists = array();
|
24 |
+
foreach( $result['lists'] as $list ) {
|
25 |
+
$lists[ $list['id'] ] = $list['name'];
|
26 |
+
}
|
27 |
+
|
28 |
+
return $lists;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function subscribe( $identity, $options ) {
|
32 |
+
|
33 |
+
$vars = array();
|
34 |
+
if ( empty( $vars['FNAME'] ) && !empty( $identity['name'] ) ) $vars['FNAME'] = $identity['name'];
|
35 |
+
|
36 |
+
$mailchimp = $this->init( $options['api_key'] );
|
37 |
+
$subscriber_hash = $mailchimp->subscriberHash($identity['email']);
|
38 |
+
$mailchimp->put( 'lists/'. $options['list_id'] .'/members/' . $subscriber_hash, [
|
39 |
+
'email_address' => $identity['email'],
|
40 |
+
'merge_fields' => empty( $vars ) ? new stdClass : $vars,
|
41 |
+
'status' => $options['double_optin'] ? 'pending' : 'subscribed'
|
42 |
+
]);
|
43 |
+
|
44 |
+
if( $mailchimp->getLastError() ) {
|
45 |
+
throw new Exception( $mailchimp->getLastError() );
|
46 |
+
}
|
47 |
+
|
48 |
+
return array(
|
49 |
+
'status' => 'subscribed'
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
public function get_fields() {
|
54 |
+
|
55 |
+
$fields = array(
|
56 |
+
'mailchimp_api_key' => array(
|
57 |
+
'id' => 'mailchimp_api_key',
|
58 |
+
'name' => 'mailchimp_api_key',
|
59 |
+
'type' => 'text',
|
60 |
+
'title' => esc_html__( 'MailChimp API URL', 'wp-subscribe' ),
|
61 |
+
'desc' => esc_html__( 'The API key of your MailChimp account.', 'wp-subscribe' ),
|
62 |
+
'link' => 'http://kb.mailchimp.com/integrations/api-integrations/about-api-keys#Finding-or-generating-your-API-key',
|
63 |
+
),
|
64 |
+
|
65 |
+
'mailchimp_list_id' => array(
|
66 |
+
'id' => 'mailchimp_list_id',
|
67 |
+
'name' => 'mailchimp_list_id',
|
68 |
+
'type' => 'select',
|
69 |
+
'title' => esc_html__( 'MailChimp List', 'wp-subscribe' ),
|
70 |
+
'options' => array( 'none' => esc_html__( 'Select List', 'wp-subscribe' ) ) + wps_get_service_list('mailchimp'),
|
71 |
+
'is_list' => true
|
72 |
+
),
|
73 |
+
|
74 |
+
'mailchimp_double_optin' => array(
|
75 |
+
'id' => 'mailchimp_double_optin',
|
76 |
+
'name' => 'mailchimp_double_optin',
|
77 |
+
'type' => 'checkbox',
|
78 |
+
'title' => esc_html__( 'Send double opt-in notification', 'wp-subscribe' )
|
79 |
+
)
|
80 |
+
);
|
81 |
+
|
82 |
+
return $fields;
|
83 |
+
}
|
84 |
+
}
|
includes/subscription/libs/aweber_api/aweber.php
ADDED
@@ -0,0 +1,307 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( 'exceptions.php' );
|
4 |
+
require_once( 'oauth_adapter.php' );
|
5 |
+
require_once( 'oauth_application.php' );
|
6 |
+
|
7 |
+
/**
|
8 |
+
* AWeberServiceProvider
|
9 |
+
*
|
10 |
+
* Provides specific AWeber information or implementing OAuth.
|
11 |
+
* @uses OAuthServiceProvider
|
12 |
+
* @package
|
13 |
+
* @version $id$
|
14 |
+
*/
|
15 |
+
|
16 |
+
if( ! class_exists('AWeberServiceProvider') ) :
|
17 |
+
|
18 |
+
class AWeberServiceProvider implements OAuthServiceProvider {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var String Location for API calls
|
22 |
+
*/
|
23 |
+
public $baseUri = 'https://api.aweber.com/1.0';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var String Location to request an access token
|
27 |
+
*/
|
28 |
+
public $accessTokenUrl = 'https://auth.aweber.com/1.0/oauth/access_token';
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @var String Location to authorize an Application
|
32 |
+
*/
|
33 |
+
public $authorizeUrl = 'https://auth.aweber.com/1.0/oauth/authorize';
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @var String Location to request a request token
|
37 |
+
*/
|
38 |
+
public $requestTokenUrl = 'https://auth.aweber.com/1.0/oauth/request_token';
|
39 |
+
|
40 |
+
|
41 |
+
public function getBaseUri() {
|
42 |
+
return $this->baseUri;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function removeBaseUri($url) {
|
46 |
+
return str_replace($this->getBaseUri(), '', $url);
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getAccessTokenUrl() {
|
50 |
+
return $this->accessTokenUrl;
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getAuthorizeUrl() {
|
54 |
+
return $this->authorizeUrl;
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getRequestTokenUrl() {
|
58 |
+
return $this->requestTokenUrl;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function getAuthTokenFromUrl() { return ''; }
|
62 |
+
public function getUserData() { return ''; }
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
endif; // AWeberServiceProvider
|
67 |
+
|
68 |
+
/**
|
69 |
+
* AWeberAPIBase
|
70 |
+
*
|
71 |
+
* Base object that all AWeberAPI objects inherit from. Allows specific pieces
|
72 |
+
* of functionality to be shared across any object in the API, such as the
|
73 |
+
* ability to introspect the collections map.
|
74 |
+
*
|
75 |
+
* @package
|
76 |
+
* @version $id$
|
77 |
+
*/
|
78 |
+
|
79 |
+
if ( ! class_exists('AWeberAPIBase') ) :
|
80 |
+
|
81 |
+
class AWeberAPIBase {
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Maintains data about what children collections a given object type
|
85 |
+
* contains.
|
86 |
+
*/
|
87 |
+
static protected $_collectionMap = array(
|
88 |
+
'account' => array('lists', 'integrations'),
|
89 |
+
'broadcast_campaign' => array('links', 'messages', 'stats'),
|
90 |
+
'followup_campaign' => array('links', 'messages', 'stats'),
|
91 |
+
'link' => array('clicks'),
|
92 |
+
'list' => array('campaigns', 'custom_fields', 'subscribers',
|
93 |
+
'web_forms', 'web_form_split_tests'),
|
94 |
+
'web_form' => array(),
|
95 |
+
'web_form_split_test' => array('components'),
|
96 |
+
);
|
97 |
+
|
98 |
+
/**
|
99 |
+
* loadFromUrl
|
100 |
+
*
|
101 |
+
* Creates an object, either collection or entry, based on the given
|
102 |
+
* URL.
|
103 |
+
*
|
104 |
+
* @param mixed $url URL for this request
|
105 |
+
* @access public
|
106 |
+
* @return AWeberEntry or AWeberCollection
|
107 |
+
*/
|
108 |
+
public function loadFromUrl($url) {
|
109 |
+
$data = $this->adapter->request('GET', $url);
|
110 |
+
return $this->readResponse($data, $url);
|
111 |
+
}
|
112 |
+
|
113 |
+
protected function _cleanUrl($url) {
|
114 |
+
return str_replace($this->adapter->app->getBaseUri(), '', $url);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* readResponse
|
119 |
+
*
|
120 |
+
* Interprets a response, and creates the appropriate object from it.
|
121 |
+
* @param mixed $response Data returned from a request to the AWeberAPI
|
122 |
+
* @param mixed $url URL that this data was requested from
|
123 |
+
* @access protected
|
124 |
+
* @return mixed
|
125 |
+
*/
|
126 |
+
protected function readResponse($response, $url) {
|
127 |
+
$this->adapter->parseAsError($response);
|
128 |
+
if (!empty($response['id']) || !empty($response['broadcast_id'])) {
|
129 |
+
return new AWeberEntry($response, $url, $this->adapter);
|
130 |
+
} else if (array_key_exists('entries', $response)) {
|
131 |
+
return new AWeberCollection($response, $url, $this->adapter);
|
132 |
+
}
|
133 |
+
return false;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
endif; // AWeberAPIBase
|
138 |
+
|
139 |
+
require_once( 'aweber_response.php' );
|
140 |
+
require_once( 'aweber_collection.php' );
|
141 |
+
require_once( 'aweber_entry_data_array.php' );
|
142 |
+
require_once( 'aweber_entry.php' );
|
143 |
+
|
144 |
+
/**
|
145 |
+
* AWeberAPI
|
146 |
+
*
|
147 |
+
* Creates a connection to the AWeberAPI for a given consumer application.
|
148 |
+
* This is generally the starting point for this library. Instances can be
|
149 |
+
* created directly with consumerKey and consumerSecret.
|
150 |
+
* @uses AWeberAPIBase
|
151 |
+
* @package
|
152 |
+
* @version $id$
|
153 |
+
*/
|
154 |
+
|
155 |
+
if( ! class_exists('AWeberAPI') ) :
|
156 |
+
|
157 |
+
class AWeberAPI extends AWeberAPIBase {
|
158 |
+
|
159 |
+
/**
|
160 |
+
* @var String Consumer Key
|
161 |
+
*/
|
162 |
+
public $consumerKey = false;
|
163 |
+
|
164 |
+
/**
|
165 |
+
* @var String Consumer Secret
|
166 |
+
*/
|
167 |
+
public $consumerSecret = false;
|
168 |
+
|
169 |
+
/**
|
170 |
+
* @var Object - Populated in setAdapter()
|
171 |
+
*/
|
172 |
+
public $adapter = false;
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Uses the app's authorization code to fetch an access token
|
176 |
+
*
|
177 |
+
* @param String Authorization code from authorize app page
|
178 |
+
*/
|
179 |
+
public static function getDataFromAweberID($string) {
|
180 |
+
list($consumerKey, $consumerSecret, $requestToken, $tokenSecret, $verifier) = AWeberAPI::_parseAweberID($string);
|
181 |
+
|
182 |
+
if (!$verifier) {
|
183 |
+
return null;
|
184 |
+
}
|
185 |
+
$aweber = new AweberAPI($consumerKey, $consumerSecret);
|
186 |
+
$aweber->adapter->user->requestToken = $requestToken;
|
187 |
+
$aweber->adapter->user->tokenSecret = $tokenSecret;
|
188 |
+
$aweber->adapter->user->verifier = $verifier;
|
189 |
+
list($accessToken, $accessSecret) = $aweber->getAccessToken();
|
190 |
+
return array($consumerKey, $consumerSecret, $accessToken, $accessSecret);
|
191 |
+
}
|
192 |
+
|
193 |
+
protected static function _parseAWeberID($string) {
|
194 |
+
$values = explode('|', $string);
|
195 |
+
if (count($values) < 5) {
|
196 |
+
return null;
|
197 |
+
}
|
198 |
+
return array_slice($values, 0, 5);
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Sets the consumer key and secret for the API object. The
|
203 |
+
* key and secret are listed in the My Apps page in the labs.aweber.com
|
204 |
+
* Control Panel OR, in the case of distributed apps, will be returned
|
205 |
+
* from the getDataFromAweberID() function
|
206 |
+
*
|
207 |
+
* @param String Consumer Key
|
208 |
+
* @param String Consumer Secret
|
209 |
+
* @return null
|
210 |
+
*/
|
211 |
+
public function __construct($key, $secret) {
|
212 |
+
// Load key / secret
|
213 |
+
$this->consumerKey = $key;
|
214 |
+
$this->consumerSecret = $secret;
|
215 |
+
|
216 |
+
$this->setAdapter();
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Returns the authorize URL by appending the request
|
221 |
+
* token to the end of the Authorize URI, if it exists
|
222 |
+
*
|
223 |
+
* @return string The Authorization URL
|
224 |
+
*/
|
225 |
+
public function getAuthorizeUrl() {
|
226 |
+
$requestToken = $this->user->requestToken;
|
227 |
+
return (empty($requestToken)) ?
|
228 |
+
$this->adapter->app->getAuthorizeUrl()
|
229 |
+
:
|
230 |
+
$this->adapter->app->getAuthorizeUrl() . "?oauth_token={$this->user->requestToken}";
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Sets the adapter for use with the API
|
235 |
+
*/
|
236 |
+
public function setAdapter($adapter=null) {
|
237 |
+
if (empty($adapter)) {
|
238 |
+
$serviceProvider = new AWeberServiceProvider();
|
239 |
+
$adapter = new OAuthApplication($serviceProvider);
|
240 |
+
$adapter->consumerKey = $this->consumerKey;
|
241 |
+
$adapter->consumerSecret = $this->consumerSecret;
|
242 |
+
}
|
243 |
+
$this->adapter = $adapter;
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Fetches account data for the associated account
|
248 |
+
*
|
249 |
+
* @param String Access Token (Only optional/cached if you called getAccessToken() earlier
|
250 |
+
* on the same page)
|
251 |
+
* @param String Access Token Secret (Only optional/cached if you called getAccessToken() earlier
|
252 |
+
* on the same page)
|
253 |
+
* @return Object AWeberCollection Object with the requested
|
254 |
+
* account data
|
255 |
+
*/
|
256 |
+
public function getAccount($token=false, $secret=false) {
|
257 |
+
if ($token && $secret) {
|
258 |
+
$user = new OAuthUser();
|
259 |
+
$user->accessToken = $token;
|
260 |
+
$user->tokenSecret = $secret;
|
261 |
+
$this->adapter->user = $user;
|
262 |
+
}
|
263 |
+
|
264 |
+
$body = $this->adapter->request('GET', '/accounts');
|
265 |
+
$accounts = $this->readResponse($body, '/accounts');
|
266 |
+
return $accounts[0];
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* PHP Automagic
|
271 |
+
*/
|
272 |
+
public function __get($item) {
|
273 |
+
if ($item == 'user') return $this->adapter->user;
|
274 |
+
trigger_error("Could not find \"{$item}\"");
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Request a request token from AWeber and associate the
|
279 |
+
* provided $callbackUrl with the new token
|
280 |
+
* @param String The URL where users should be redirected
|
281 |
+
* once they authorize your app
|
282 |
+
* @return Array Contains the request token as the first item
|
283 |
+
* and the request token secret as the second item of the array
|
284 |
+
*/
|
285 |
+
public function getRequestToken($callbackUrl) {
|
286 |
+
$requestToken = $this->adapter->getRequestToken($callbackUrl);
|
287 |
+
return array($requestToken, $this->user->tokenSecret);
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* Request an access token using the request tokens stored in the
|
292 |
+
* current user object. You would want to first set the request tokens
|
293 |
+
* on the user before calling this function via:
|
294 |
+
*
|
295 |
+
* $aweber->user->tokenSecret = $_COOKIE['requestTokenSecret'];
|
296 |
+
* $aweber->user->requestToken = $_GET['oauth_token'];
|
297 |
+
* $aweber->user->verifier = $_GET['oauth_verifier'];
|
298 |
+
*
|
299 |
+
* @return Array Contains the access token as the first item
|
300 |
+
* and the access token secret as the second item of the array
|
301 |
+
*/
|
302 |
+
public function getAccessToken() {
|
303 |
+
return $this->adapter->getAccessToken();
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
endif; // AWeberAPI
|
includes/subscription/libs/aweber_api/aweber_api.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (class_exists('AWeberAPI')) {
|
4 |
+
trigger_error("Duplicate: Another AWeberAPI client library is already in scope.", E_USER_WARNING);
|
5 |
+
}
|
6 |
+
else {
|
7 |
+
require_once('aweber.php');
|
8 |
+
}
|
includes/subscription/libs/aweber_api/aweber_collection.php
ADDED
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( ! class_exists('AWeberCollection') ) :
|
4 |
+
|
5 |
+
class AWeberCollection extends AWeberResponse implements ArrayAccess, Iterator, Countable {
|
6 |
+
|
7 |
+
protected $pageSize = 100;
|
8 |
+
protected $pageStart = 0;
|
9 |
+
|
10 |
+
protected function _updatePageSize() {
|
11 |
+
|
12 |
+
# grab the url, or prev and next url and pull ws.size from it
|
13 |
+
$url = $this->url;
|
14 |
+
if (array_key_exists('next_collection_link', $this->data)) {
|
15 |
+
$url = $this->data['next_collection_link'];
|
16 |
+
|
17 |
+
} elseif (array_key_exists('prev_collection_link', $this->data)) {
|
18 |
+
$url = $this->data['prev_collection_link'];
|
19 |
+
}
|
20 |
+
|
21 |
+
# scan querystring for ws_size
|
22 |
+
$url_parts = parse_url($url);
|
23 |
+
|
24 |
+
# we have a query string
|
25 |
+
if (array_key_exists('query', $url_parts)) {
|
26 |
+
parse_str($url_parts['query'], $params);
|
27 |
+
|
28 |
+
# we have a ws_size
|
29 |
+
if (array_key_exists('ws_size', $params)) {
|
30 |
+
|
31 |
+
# set pageSize
|
32 |
+
$this->pageSize = $params['ws_size'];
|
33 |
+
return;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
# we dont have one, just count the # of entries
|
38 |
+
$this->pageSize = count($this->data['entries']);
|
39 |
+
}
|
40 |
+
|
41 |
+
public function __construct($response, $url, $adapter) {
|
42 |
+
parent::__construct($response, $url, $adapter);
|
43 |
+
$this->_updatePageSize();
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @var array Holds list of keys that are not publicly accessible
|
48 |
+
*/
|
49 |
+
protected $_privateData = array(
|
50 |
+
'entries',
|
51 |
+
'start',
|
52 |
+
'next_collection_link',
|
53 |
+
);
|
54 |
+
|
55 |
+
/**
|
56 |
+
* getById
|
57 |
+
*
|
58 |
+
* Gets an entry object of this collection type with the given id
|
59 |
+
* @param mixed $id ID of the entry you are requesting
|
60 |
+
* @access public
|
61 |
+
* @return AWeberEntry
|
62 |
+
*/
|
63 |
+
public function getById($id) {
|
64 |
+
$data = $this->adapter->request('GET', "{$this->url}/{$id}");
|
65 |
+
$url = "{$this->url}/{$id}";
|
66 |
+
return new AWeberEntry($data, $url, $this->adapter);
|
67 |
+
}
|
68 |
+
|
69 |
+
/** getParentEntry
|
70 |
+
*
|
71 |
+
* Gets an entry's parent entry
|
72 |
+
* Returns NULL if no parent entry
|
73 |
+
*/
|
74 |
+
public function getParentEntry(){
|
75 |
+
$url_parts = explode('/', $this->url);
|
76 |
+
$size = count($url_parts);
|
77 |
+
|
78 |
+
# Remove collection id and slash from end of url
|
79 |
+
$url = substr($this->url, 0, -strlen($url_parts[$size-1])-1);
|
80 |
+
|
81 |
+
try {
|
82 |
+
$data = $this->adapter->request('GET', $url);
|
83 |
+
return new AWeberEntry($data, $url, $this->adapter);
|
84 |
+
} catch (Exception $e) {
|
85 |
+
return NULL;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* _type
|
91 |
+
*
|
92 |
+
* Interpret what type of resources are held in this collection by
|
93 |
+
* analyzing the URL
|
94 |
+
*
|
95 |
+
* @access protected
|
96 |
+
* @return void
|
97 |
+
*/
|
98 |
+
protected function _type() {
|
99 |
+
$urlParts = explode('/', $this->url);
|
100 |
+
$type = array_pop($urlParts);
|
101 |
+
return $type;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* create
|
106 |
+
*
|
107 |
+
* Invoke the API method to CREATE a new entry resource.
|
108 |
+
*
|
109 |
+
* Note: Not all entry resources are eligible to be created, please
|
110 |
+
* refer to the AWeber API Reference Documentation at
|
111 |
+
* https://labs.aweber.com/docs/reference/1.0 for more
|
112 |
+
* details on which entry resources may be created and what
|
113 |
+
* attributes are required for creating resources.
|
114 |
+
*
|
115 |
+
* @access public
|
116 |
+
* @param params mixed associtative array of key/value pairs.
|
117 |
+
* @return AWeberEntry(Resource) The new resource created
|
118 |
+
*/
|
119 |
+
public function create($kv_pairs) {
|
120 |
+
# Create Resource
|
121 |
+
$params = array_merge(array('ws.op' => 'create'), $kv_pairs);
|
122 |
+
$data = $this->adapter->request('POST', $this->url, $params, array('return' => 'headers'));
|
123 |
+
|
124 |
+
# Return new Resource
|
125 |
+
$url = $data['Location'];
|
126 |
+
$resource_data = $this->adapter->request('GET', $url);
|
127 |
+
return new AWeberEntry($resource_data, $url, $this->adapter);
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* find
|
132 |
+
*
|
133 |
+
* Invoke the API 'find' operation on a collection to return a subset
|
134 |
+
* of that collection. Not all collections support the 'find' operation.
|
135 |
+
* refer to https://labs.aweber.com/docs/reference/1.0 for more information.
|
136 |
+
*
|
137 |
+
* @param mixed $search_data Associative array of key/value pairs used as search filters
|
138 |
+
* * refer to https://labs.aweber.com/docs/reference/1.0 for a
|
139 |
+
* complete list of valid search filters.
|
140 |
+
* * filtering on attributes that require additional permissions to
|
141 |
+
* display requires an app authorized with those additional permissions.
|
142 |
+
* @access public
|
143 |
+
* @return AWeberCollection
|
144 |
+
*/
|
145 |
+
public function find($search_data) {
|
146 |
+
# invoke find operation
|
147 |
+
$params = array_merge($search_data, array('ws.op' => 'find'));
|
148 |
+
$data = $this->adapter->request('GET', $this->url, $params);
|
149 |
+
|
150 |
+
# get total size
|
151 |
+
$ts_params = array_merge($params, array('ws.show' => 'total_size'));
|
152 |
+
$total_size = $this->adapter->request('GET', $this->url, $ts_params, array('return' => 'integer'));
|
153 |
+
$data['total_size'] = $total_size;
|
154 |
+
|
155 |
+
# return collection
|
156 |
+
return $this->readResponse($data, $this->url);
|
157 |
+
}
|
158 |
+
|
159 |
+
/*
|
160 |
+
* ArrayAccess Functions
|
161 |
+
*
|
162 |
+
* Allows this object to be accessed via bracket notation (ie $obj[$x])
|
163 |
+
* http://php.net/manual/en/class.arrayaccess.php
|
164 |
+
*/
|
165 |
+
|
166 |
+
public function offsetSet($offset, $value) {}
|
167 |
+
public function offsetUnset($offset) {}
|
168 |
+
public function offsetExists($offset) {
|
169 |
+
|
170 |
+
if ($offset >=0 && $offset < $this->total_size) {
|
171 |
+
return true;
|
172 |
+
}
|
173 |
+
return false;
|
174 |
+
}
|
175 |
+
protected function _fetchCollectionData($offset) {
|
176 |
+
|
177 |
+
# we dont have a next page, we're done
|
178 |
+
if (!array_key_exists('next_collection_link', $this->data)) {
|
179 |
+
return null;
|
180 |
+
}
|
181 |
+
|
182 |
+
# snag query string args from collection
|
183 |
+
$parsed = parse_url($this->data['next_collection_link']);
|
184 |
+
|
185 |
+
# parse the query string to get params
|
186 |
+
$pairs = explode('&', $parsed['query']);
|
187 |
+
foreach ($pairs as $pair) {
|
188 |
+
list($key, $val) = explode('=', $pair);
|
189 |
+
$params[$key] = $val;
|
190 |
+
}
|
191 |
+
|
192 |
+
# calculate new args
|
193 |
+
$limit = $params['ws.size'];
|
194 |
+
$pagination_offset = intval($offset / $limit) * $limit;
|
195 |
+
$params['ws.start'] = $pagination_offset;
|
196 |
+
|
197 |
+
# fetch data, exclude query string
|
198 |
+
$url_parts = explode('?', $this->url);
|
199 |
+
$data = $this->adapter->request('GET', $url_parts[0], $params);
|
200 |
+
$this->pageStart = $params['ws.start'];
|
201 |
+
$this->pageSize = $params['ws.size'];
|
202 |
+
|
203 |
+
$collection_data = array('entries', 'next_collection_link', 'prev_collection_link', 'ws.start');
|
204 |
+
|
205 |
+
foreach ($collection_data as $item) {
|
206 |
+
if (!array_key_exists($item, $this->data)) {
|
207 |
+
continue;
|
208 |
+
}
|
209 |
+
if (!array_key_exists($item, $data)) {
|
210 |
+
continue;
|
211 |
+
}
|
212 |
+
$this->data[$item] = $data[$item];
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
public function offsetGet($offset) {
|
217 |
+
|
218 |
+
if (!$this->offsetExists($offset)) {
|
219 |
+
return null;
|
220 |
+
}
|
221 |
+
|
222 |
+
$limit = $this->pageSize;
|
223 |
+
$pagination_offset = intval($offset / $limit) * $limit;
|
224 |
+
|
225 |
+
# load collection page if needed
|
226 |
+
if ($pagination_offset !== $this->pageStart) {
|
227 |
+
$this->_fetchCollectionData($offset);
|
228 |
+
}
|
229 |
+
|
230 |
+
$entry = $this->data['entries'][$offset - $pagination_offset];
|
231 |
+
|
232 |
+
# we have an entry, cast it to an AWeberEntry and return it
|
233 |
+
$entry_url = $this->adapter->app->removeBaseUri($entry['self_link']);
|
234 |
+
return new AWeberEntry($entry, $entry_url, $this->adapter);
|
235 |
+
}
|
236 |
+
|
237 |
+
/*
|
238 |
+
* Iterator
|
239 |
+
*/
|
240 |
+
protected $_iterationKey = 0;
|
241 |
+
|
242 |
+
public function current() {
|
243 |
+
return $this->offsetGet($this->_iterationKey);
|
244 |
+
}
|
245 |
+
|
246 |
+
public function key() {
|
247 |
+
return $this->_iterationKey;
|
248 |
+
}
|
249 |
+
|
250 |
+
public function next() {
|
251 |
+
$this->_iterationKey++;
|
252 |
+
}
|
253 |
+
|
254 |
+
public function rewind() {
|
255 |
+
$this->_iterationKey = 0;
|
256 |
+
}
|
257 |
+
|
258 |
+
public function valid() {
|
259 |
+
return $this->offsetExists($this->key());
|
260 |
+
}
|
261 |
+
|
262 |
+
/*
|
263 |
+
* Countable interface methods
|
264 |
+
* Allows PHP's count() and sizeOf() functions to act on this object
|
265 |
+
* http://www.php.net/manual/en/class.countable.php
|
266 |
+
*/
|
267 |
+
|
268 |
+
public function count() {
|
269 |
+
return $this->total_size;
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
endif;
|
includes/subscription/libs/aweber_api/aweber_entry.php
ADDED
@@ -0,0 +1,350 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( ! class_exists('AWeberEntry') ) :
|
4 |
+
|
5 |
+
class AWeberEntry extends AWeberResponse {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @var array Holds list of data keys that are not publicly accessible
|
9 |
+
*/
|
10 |
+
protected $_privateData = array(
|
11 |
+
'resource_type_link',
|
12 |
+
'http_etag',
|
13 |
+
);
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var array Stores local modifications that have not been saved
|
17 |
+
*/
|
18 |
+
protected $_localDiff = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var array Holds AWeberCollection objects already instantiated, keyed by
|
22 |
+
* their resource name (plural)
|
23 |
+
*/
|
24 |
+
protected $_collections = array();
|
25 |
+
|
26 |
+
/**
|
27 |
+
* attrs
|
28 |
+
*
|
29 |
+
* Provides a simple array of all the available data (and collections) available
|
30 |
+
* in this entry.
|
31 |
+
*
|
32 |
+
* @access public
|
33 |
+
* @return array
|
34 |
+
*/
|
35 |
+
public function attrs() {
|
36 |
+
$attrs = array();
|
37 |
+
foreach ($this->data as $key => $value) {
|
38 |
+
if (!in_array($key, $this->_privateData) && !strpos($key, 'collection_link')) {
|
39 |
+
$attrs[$key] = $value;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
if (!empty(AWeberAPI::$_collectionMap[$this->type])) {
|
43 |
+
foreach (AWeberAPI::$_collectionMap[$this->type] as $child) {
|
44 |
+
$attrs[$child] = 'collection';
|
45 |
+
}
|
46 |
+
}
|
47 |
+
return $attrs;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* _type
|
52 |
+
*
|
53 |
+
* Used to pull the name of this resource from its resource_type_link
|
54 |
+
* @access protected
|
55 |
+
* @return String
|
56 |
+
*/
|
57 |
+
protected function _type() {
|
58 |
+
if (empty($this->type)) {
|
59 |
+
if (!empty($this->data['resource_type_link'])) {
|
60 |
+
list($url, $type) = explode('#', $this->data['resource_type_link']);
|
61 |
+
$this->type = $type;
|
62 |
+
} elseif (!empty($this->data['broadcast_id'])) {
|
63 |
+
$this->type = 'broadcast';
|
64 |
+
} else {
|
65 |
+
return null;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
return $this->type;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* delete
|
73 |
+
*
|
74 |
+
* Delete this object from the AWeber system. May not be supported
|
75 |
+
* by all entry types.
|
76 |
+
* @access public
|
77 |
+
* @return boolean Returns true if it is successfully deleted, false
|
78 |
+
* if the delete request failed.
|
79 |
+
*/
|
80 |
+
public function delete() {
|
81 |
+
$this->adapter->request('DELETE', $this->url, array(), array('return' => 'status'));
|
82 |
+
return true;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* move
|
87 |
+
*
|
88 |
+
* Invoke the API method to MOVE an entry resource to a different List.
|
89 |
+
*
|
90 |
+
* Note: Not all entry resources are eligible to be moved, please
|
91 |
+
* refer to the AWeber API Reference Documentation at
|
92 |
+
* https://labs.aweber.com/docs/reference/1.0 for more
|
93 |
+
* details on which entry resources may be moved and if there
|
94 |
+
* are any requirements for moving that resource.
|
95 |
+
*
|
96 |
+
* @access public
|
97 |
+
* @param AWeberEntry(List) List to move Resource (this) too.
|
98 |
+
* @return mixed AWeberEntry(Resource) Resource created on List ($list)
|
99 |
+
* or False if resource was not created.
|
100 |
+
*/
|
101 |
+
public function move($list, $last_followup_message_number_sent=NULL) {
|
102 |
+
# Move Resource
|
103 |
+
$params = array(
|
104 |
+
'ws.op' => 'move',
|
105 |
+
'list_link' => $list->self_link
|
106 |
+
);
|
107 |
+
if (isset($last_followup_message_number_sent)) {
|
108 |
+
$params['last_followup_message_number_sent'] = $last_followup_message_number_sent;
|
109 |
+
}
|
110 |
+
|
111 |
+
$data = $this->adapter->request('POST', $this->url, $params, array('return' => 'headers'));
|
112 |
+
|
113 |
+
# Return new Resource
|
114 |
+
$url = $data['Location'];
|
115 |
+
$resource_data = $this->adapter->request('GET', $url);
|
116 |
+
return new AWeberEntry($resource_data, $url, $this->adapter);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* save
|
121 |
+
*
|
122 |
+
* Saves the current state of this object if it has been changed.
|
123 |
+
* @access public
|
124 |
+
* @return void
|
125 |
+
*/
|
126 |
+
public function save() {
|
127 |
+
if (!empty($this->_localDiff)) {
|
128 |
+
$data = $this->adapter->request('PATCH', $this->url, $this->_localDiff, array('return' => 'status'));
|
129 |
+
}
|
130 |
+
$this->_localDiff = array();
|
131 |
+
return true;
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* __get
|
137 |
+
*
|
138 |
+
* Used to look up items in data, and special properties like type and
|
139 |
+
* child collections dynamically.
|
140 |
+
*
|
141 |
+
* @param String $value Attribute being accessed
|
142 |
+
* @access public
|
143 |
+
* @throws AWeberResourceNotImplemented
|
144 |
+
* @return mixed
|
145 |
+
*/
|
146 |
+
public function __get($value) {
|
147 |
+
if (in_array($value, $this->_privateData)) {
|
148 |
+
return null;
|
149 |
+
}
|
150 |
+
if (!empty($this->data) && array_key_exists($value, $this->data)) {
|
151 |
+
if (is_array($this->data[$value])) {
|
152 |
+
$array = new AWeberEntryDataArray($this->data[$value], $value, $this);
|
153 |
+
$this->data[$value] = $array;
|
154 |
+
}
|
155 |
+
return $this->data[$value];
|
156 |
+
}
|
157 |
+
if ($value == 'type') return $this->_type();
|
158 |
+
if ($this->_isChildCollection($value)) {
|
159 |
+
return $this->_getCollection($value);
|
160 |
+
}
|
161 |
+
throw new AWeberResourceNotImplemented($this, $value);
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* __set
|
166 |
+
*
|
167 |
+
* If the key provided is part of the data array, then update it in the
|
168 |
+
* data array. Otherwise, use the default __set() behavior.
|
169 |
+
*
|
170 |
+
* @param mixed $key Key of the attr being set
|
171 |
+
* @param mixed $value Value being set to the $key attr
|
172 |
+
* @access public
|
173 |
+
*/
|
174 |
+
public function __set($key, $value) {
|
175 |
+
if (array_key_exists($key, $this->data)) {
|
176 |
+
$this->_localDiff[$key] = $value;
|
177 |
+
return $this->data[$key] = $value;
|
178 |
+
} else {
|
179 |
+
return parent::__set($key, $value);
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* findSubscribers
|
185 |
+
*
|
186 |
+
* Looks through all lists for subscribers
|
187 |
+
* that match the given filter
|
188 |
+
* @access public
|
189 |
+
* @return AWeberCollection
|
190 |
+
*/
|
191 |
+
public function findSubscribers($search_data) {
|
192 |
+
$this->_methodFor(array('account'));
|
193 |
+
$params = array_merge($search_data, array('ws.op' => 'findSubscribers'));
|
194 |
+
$data = $this->adapter->request('GET', $this->url, $params);
|
195 |
+
|
196 |
+
$ts_params = array_merge($params, array('ws.show' => 'total_size'));
|
197 |
+
$total_size = $this->adapter->request('GET', $this->url, $ts_params, array('return' => 'integer'));
|
198 |
+
|
199 |
+
# return collection
|
200 |
+
$data['total_size'] = $total_size;
|
201 |
+
$url = $this->url . '?'. http_build_query($params);
|
202 |
+
return new AWeberCollection($data, $url, $this->adapter);
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* getActivity
|
207 |
+
*
|
208 |
+
* Returns analytics activity for a given subscriber
|
209 |
+
* @access public
|
210 |
+
* @return AWeberCollection
|
211 |
+
*/
|
212 |
+
public function getActivity() {
|
213 |
+
$this->_methodFor(array('subscriber'));
|
214 |
+
$params = array('ws.op' => 'getActivity');
|
215 |
+
$data = $this->adapter->request('GET', $this->url, $params);
|
216 |
+
|
217 |
+
$ts_params = array_merge($params, array('ws.show' => 'total_size'));
|
218 |
+
$total_size = $this->adapter->request('GET', $this->url, $ts_params, array('return' => 'integer'));
|
219 |
+
|
220 |
+
# return collection
|
221 |
+
$data['total_size'] = $total_size;
|
222 |
+
$url = $this->url . '?'. http_build_query($params);
|
223 |
+
return new AWeberCollection($data, $url, $this->adapter);
|
224 |
+
}
|
225 |
+
|
226 |
+
/** getParentEntry
|
227 |
+
*
|
228 |
+
* Gets an entry's parent entry
|
229 |
+
* Returns NULL if no parent entry
|
230 |
+
*/
|
231 |
+
public function getParentEntry(){
|
232 |
+
$url_parts = explode('/', $this->url);
|
233 |
+
$size = count($url_parts);
|
234 |
+
|
235 |
+
#Remove entry id and slash from end of url
|
236 |
+
$url = substr($this->url, 0, -strlen($url_parts[$size-1])-1);
|
237 |
+
|
238 |
+
#Remove collection name and slash from end of url
|
239 |
+
$url = substr($url, 0, -strlen($url_parts[$size-2])-1);
|
240 |
+
|
241 |
+
try {
|
242 |
+
$data = $this->adapter->request('GET', $url);
|
243 |
+
return new AWeberEntry($data, $url, $this->adapter);
|
244 |
+
} catch (Exception $e) {
|
245 |
+
return NULL;
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
/**
|
250 |
+
* getWebForms
|
251 |
+
*
|
252 |
+
* Gets all web_forms for this account
|
253 |
+
* @access public
|
254 |
+
* @return array
|
255 |
+
*/
|
256 |
+
public function getWebForms() {
|
257 |
+
$this->_methodFor(array('account'));
|
258 |
+
$data = $this->adapter->request('GET', $this->url.'?ws.op=getWebForms', array(),
|
259 |
+
array('allow_empty' => true));
|
260 |
+
return $this->_parseNamedOperation($data);
|
261 |
+
}
|
262 |
+
|
263 |
+
|
264 |
+
/**
|
265 |
+
* getWebFormSplitTests
|
266 |
+
*
|
267 |
+
* Gets all web_form split tests for this account
|
268 |
+
* @access public
|
269 |
+
* @return array
|
270 |
+
*/
|
271 |
+
public function getWebFormSplitTests() {
|
272 |
+
$this->_methodFor(array('account'));
|
273 |
+
$data = $this->adapter->request('GET', $this->url.'?ws.op=getWebFormSplitTests', array(),
|
274 |
+
array('allow_empty' => true));
|
275 |
+
return $this->_parseNamedOperation($data);
|
276 |
+
}
|
277 |
+
|
278 |
+
/**
|
279 |
+
* _parseNamedOperation
|
280 |
+
*
|
281 |
+
* Turns a dumb array of json into an array of Entries. This is NOT
|
282 |
+
* a collection, but simply an array of entries, as returned from a
|
283 |
+
* named operation.
|
284 |
+
*
|
285 |
+
* @param array $data
|
286 |
+
* @access protected
|
287 |
+
* @return array
|
288 |
+
*/
|
289 |
+
protected function _parseNamedOperation($data) {
|
290 |
+
$results = array();
|
291 |
+
foreach($data as $entryData) {
|
292 |
+
$results[] = new AWeberEntry($entryData, str_replace($this->adapter->app->getBaseUri(), '',
|
293 |
+
$entryData['self_link']), $this->adapter);
|
294 |
+
}
|
295 |
+
return $results;
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* _methodFor
|
300 |
+
*
|
301 |
+
* Raises exception if $this->type is not in array entryTypes.
|
302 |
+
* Used to restrict methods to specific entry type(s).
|
303 |
+
* @param mixed $entryTypes Array of entry types as strings, ie array('account')
|
304 |
+
* @access protected
|
305 |
+
* @return void
|
306 |
+
*/
|
307 |
+
protected function _methodFor($entryTypes) {
|
308 |
+
if (in_array($this->type, $entryTypes)) return true;
|
309 |
+
throw new AWeberMethodNotImplemented($this);
|
310 |
+
}
|
311 |
+
|
312 |
+
/**
|
313 |
+
* _getCollection
|
314 |
+
*
|
315 |
+
* Returns the AWeberCollection object representing the given
|
316 |
+
* collection name, relative to this entry.
|
317 |
+
*
|
318 |
+
* @param String $value The name of the sub-collection
|
319 |
+
* @access protected
|
320 |
+
* @return AWeberCollection
|
321 |
+
*/
|
322 |
+
protected function _getCollection($value) {
|
323 |
+
if (empty($this->_collections[$value])) {
|
324 |
+
$url = "{$this->url}/{$value}";
|
325 |
+
$data = $this->adapter->request('GET', $url);
|
326 |
+
$this->_collections[$value] = new AWeberCollection($data, $url, $this->adapter);
|
327 |
+
}
|
328 |
+
return $this->_collections[$value];
|
329 |
+
}
|
330 |
+
|
331 |
+
|
332 |
+
/**
|
333 |
+
* _isChildCollection
|
334 |
+
*
|
335 |
+
* Is the given name of a collection a child collection of this entry?
|
336 |
+
*
|
337 |
+
* @param String $value The name of the collection we are looking for
|
338 |
+
* @access protected
|
339 |
+
* @return boolean
|
340 |
+
* @throws AWeberResourceNotImplemented
|
341 |
+
*/
|
342 |
+
protected function _isChildCollection($value) {
|
343 |
+
$this->_type();
|
344 |
+
if (!empty(AWeberAPI::$_collectionMap[$this->type]) &&
|
345 |
+
in_array($value, AWeberAPI::$_collectionMap[$this->type])) return true;
|
346 |
+
return false;
|
347 |
+
}
|
348 |
+
|
349 |
+
}
|
350 |
+
endif;
|
includes/subscription/libs/aweber_api/aweber_entry_data_array.php
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( ! class_exists('AWeberEntryDataArray') ) :
|
4 |
+
|
5 |
+
class AWeberEntryDataArray implements ArrayAccess, Countable, Iterator {
|
6 |
+
private $counter = 0;
|
7 |
+
|
8 |
+
protected $data;
|
9 |
+
protected $keys;
|
10 |
+
protected $name;
|
11 |
+
protected $parent;
|
12 |
+
|
13 |
+
public function __construct($data, $name, $parent) {
|
14 |
+
$this->data = $data;
|
15 |
+
$this->keys = array_keys($data);
|
16 |
+
$this->name = $name;
|
17 |
+
$this->parent = $parent;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function count() {
|
21 |
+
return sizeOf($this->data);
|
22 |
+
}
|
23 |
+
|
24 |
+
public function offsetExists($offset) {
|
25 |
+
return (isset($this->data[$offset]));
|
26 |
+
}
|
27 |
+
|
28 |
+
public function offsetGet($offset) {
|
29 |
+
return $this->data[$offset];
|
30 |
+
}
|
31 |
+
|
32 |
+
public function offsetSet($offset, $value) {
|
33 |
+
$this->data[$offset] = $value;
|
34 |
+
$this->parent->{$this->name} = $this->data;
|
35 |
+
return $value;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function offsetUnset($offset) {
|
39 |
+
unset($this->data[$offset]);
|
40 |
+
}
|
41 |
+
|
42 |
+
public function rewind() {
|
43 |
+
$this->counter = 0;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function current() {
|
47 |
+
return $this->data[$this->key()];
|
48 |
+
}
|
49 |
+
|
50 |
+
public function key() {
|
51 |
+
return $this->keys[$this->counter];
|
52 |
+
}
|
53 |
+
|
54 |
+
public function next() {
|
55 |
+
$this->counter++;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function valid() {
|
59 |
+
if ($this->counter >= sizeOf($this->data)) {
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
endif;
|
includes/subscription/libs/aweber_api/aweber_response.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* AWeberResponse
|
5 |
+
*
|
6 |
+
* Base class for objects that represent a response from the AWeberAPI.
|
7 |
+
* Responses will exist as one of the two AWeberResponse subclasses:
|
8 |
+
* - AWeberEntry - a single instance of an AWeber resource
|
9 |
+
* - AWeberCollection - a collection of AWeber resources
|
10 |
+
* @uses AWeberAPIBase
|
11 |
+
* @package
|
12 |
+
* @version $id$
|
13 |
+
*/
|
14 |
+
|
15 |
+
if( ! class_exists('AWeberResponse') ) :
|
16 |
+
|
17 |
+
class AWeberResponse extends AWeberAPIBase {
|
18 |
+
|
19 |
+
public $adapter = false;
|
20 |
+
public $data = array();
|
21 |
+
public $_dynamicData = array();
|
22 |
+
|
23 |
+
/**
|
24 |
+
* __construct
|
25 |
+
*
|
26 |
+
* Creates a new AWeberRespones
|
27 |
+
*
|
28 |
+
* @param mixed $response Data returned by the API servers
|
29 |
+
* @param mixed $url URL we hit to get the data
|
30 |
+
* @param mixed $adapter OAuth adapter used for future interactions
|
31 |
+
* @access public
|
32 |
+
* @return void
|
33 |
+
*/
|
34 |
+
public function __construct($response, $url, $adapter) {
|
35 |
+
$this->adapter = $adapter;
|
36 |
+
$this->url = $url;
|
37 |
+
$this->data = $response;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* __set
|
42 |
+
*
|
43 |
+
* Manual re-implementation of __set, allows sub classes to access
|
44 |
+
* the default behavior by using the parent:: format.
|
45 |
+
*
|
46 |
+
* @param mixed $key Key of the attr being set
|
47 |
+
* @param mixed $value Value being set to the attr
|
48 |
+
* @access public
|
49 |
+
*/
|
50 |
+
public function __set($key, $value) {
|
51 |
+
$this->{$key} = $value;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* __get
|
56 |
+
*
|
57 |
+
* PHP "MagicMethod" to allow for dynamic objects. Defers first to the
|
58 |
+
* data in $this->data.
|
59 |
+
*
|
60 |
+
* @param String $value Name of the attribute requested
|
61 |
+
* @access public
|
62 |
+
* @return mixed
|
63 |
+
*/
|
64 |
+
public function __get($value) {
|
65 |
+
if (in_array($value, $this->_privateData)) {
|
66 |
+
return null;
|
67 |
+
}
|
68 |
+
if (array_key_exists($value, $this->data)) {
|
69 |
+
return $this->data[$value];
|
70 |
+
}
|
71 |
+
if ($value == 'type') return $this->_type();
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
75 |
+
endif;
|
includes/subscription/libs/aweber_api/curl_object.php
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* CurlInterface
|
5 |
+
*
|
6 |
+
* An object-oriented shim that wraps the standard PHP cURL library.
|
7 |
+
*
|
8 |
+
* This interface has been created so that cURL functionality can be stubbed
|
9 |
+
* out for unit testing, or swapped for an alternative library.
|
10 |
+
*
|
11 |
+
* @see curl
|
12 |
+
* @package
|
13 |
+
* @version $id$
|
14 |
+
*/
|
15 |
+
interface CurlInterface {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* errNo
|
19 |
+
*
|
20 |
+
* Encapsulates curl_errno - Returns the last error number
|
21 |
+
* @param resource $ch - A cURL handle returned by init.
|
22 |
+
* @access public
|
23 |
+
* @return the error number or 0 if no error occured.
|
24 |
+
*/
|
25 |
+
public function errno($ch);
|
26 |
+
|
27 |
+
/**
|
28 |
+
* error
|
29 |
+
*
|
30 |
+
* Encapsulates curl_error - Return last error string
|
31 |
+
* @param resource $ch - A cURL handle returned by init.
|
32 |
+
* @access public
|
33 |
+
* @return the error messge or '' if no error occured.
|
34 |
+
*/
|
35 |
+
public function error($ch);
|
36 |
+
|
37 |
+
/**
|
38 |
+
* execute
|
39 |
+
*
|
40 |
+
* Encapsulates curl_exec - Perform a cURL session.
|
41 |
+
* @param resource $ch - A cURL handle returned by init.
|
42 |
+
* @access public
|
43 |
+
* @return TRUE on success, FALSE on failure.
|
44 |
+
*/
|
45 |
+
public function execute($ch);
|
46 |
+
|
47 |
+
/**
|
48 |
+
* init
|
49 |
+
*
|
50 |
+
* Encapsulates curl_init - Initialize a cURL session.
|
51 |
+
* @param string $url - url to use.
|
52 |
+
* @access public
|
53 |
+
* @return cURL handle on success, FALSE on failure.
|
54 |
+
*/
|
55 |
+
public function init($url);
|
56 |
+
|
57 |
+
/**
|
58 |
+
* setopt
|
59 |
+
*
|
60 |
+
* Encapsulates curl_setopt - Set an option for cURL transfer.
|
61 |
+
* @param resource $ch - A cURL handle returned by init.
|
62 |
+
* @param int $opt - The CURLOPT to set.
|
63 |
+
* @param mixed $value - The value to set.
|
64 |
+
* @access public
|
65 |
+
* @return True on success, FALSE on failure.
|
66 |
+
*/
|
67 |
+
public function setopt ($ch , $option , $value);
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
* CurlObject
|
73 |
+
*
|
74 |
+
* A concrete implementation of CurlInterface using the PHP cURL library.
|
75 |
+
*
|
76 |
+
* @package
|
77 |
+
* @version $id$
|
78 |
+
*/
|
79 |
+
class CurlObject implements CurlInterface {
|
80 |
+
|
81 |
+
public function errno($ch) {
|
82 |
+
return curl_errno($ch);
|
83 |
+
}
|
84 |
+
|
85 |
+
public function error($ch) {
|
86 |
+
return curl_error($ch);
|
87 |
+
}
|
88 |
+
|
89 |
+
public function execute($ch) {
|
90 |
+
return curl_exec($ch);
|
91 |
+
}
|
92 |
+
|
93 |
+
public function init($url) {
|
94 |
+
return curl_init($url);
|
95 |
+
}
|
96 |
+
|
97 |
+
public function setopt ($ch , $option , $value) {
|
98 |
+
return curl_setopt($ch, $option, $value);
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
?>
|
includes/subscription/libs/aweber_api/curl_response.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
# CurlResponse
|
4 |
+
#
|
5 |
+
# Author Sean Huber - shuber@huberry.com
|
6 |
+
# Date May 2008
|
7 |
+
#
|
8 |
+
# A basic CURL wrapper for PHP
|
9 |
+
#
|
10 |
+
# See the README for documentation/examples or http://php.net/curl for more information
|
11 |
+
# about the libcurl extension for PHP -- http://github.com/shuber/curl/tree/master
|
12 |
+
#
|
13 |
+
|
14 |
+
class CurlResponse
|
15 |
+
{
|
16 |
+
public $body = '';
|
17 |
+
public $headers = array();
|
18 |
+
|
19 |
+
public function __construct($response)
|
20 |
+
{
|
21 |
+
# Extract headers from response
|
22 |
+
$pattern = '#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims';
|
23 |
+
preg_match_all($pattern, $response, $matches);
|
24 |
+
$headers = explode("\r\n", str_replace("\r\n\r\n", '', array_pop($matches[0])));
|
25 |
+
|
26 |
+
# Extract the version and status from the first header
|
27 |
+
$version_and_status = array_shift($headers);
|
28 |
+
preg_match('#HTTP/(\d\.\d)\s(\d\d\d)\s(.*)#', $version_and_status, $matches);
|
29 |
+
$this->headers['Http-Version'] = $matches[1];
|
30 |
+
$this->headers['Status-Code'] = $matches[2];
|
31 |
+
$this->headers['Status'] = $matches[2].' '.$matches[3];
|
32 |
+
|
33 |
+
# Convert headers into an associative array
|
34 |
+
foreach ($headers as $header) {
|
35 |
+
preg_match('#(.*?)\:\s(.*)#', $header, $matches);
|
36 |
+
$this->headers[$matches[1]] = $matches[2];
|
37 |
+
}
|
38 |
+
|
39 |
+
# Remove the headers from the response body
|
40 |
+
$this->body = preg_replace($pattern, '', $response);
|
41 |
+
}
|
42 |
+
|
43 |
+
public function __toString()
|
44 |
+
{
|
45 |
+
return $this->body;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function headers(){
|
49 |
+
return $this->headers;
|
50 |
+
}
|
51 |
+
}
|
includes/subscription/libs/aweber_api/exceptions.php
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( ! class_exists('AWeberException') ) :
|
4 |
+
class AWeberException extends Exception {
|
5 |
+
|
6 |
+
}
|
7 |
+
endif;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Thrown when the API returns an error. (HTTP status >= 400)
|
11 |
+
*
|
12 |
+
*
|
13 |
+
* @uses AWeberException
|
14 |
+
* @package
|
15 |
+
* @version $id$
|
16 |
+
*/
|
17 |
+
|
18 |
+
if( ! class_exists('AWeberAPIException') ) :
|
19 |
+
class AWeberAPIException extends AWeberException {
|
20 |
+
|
21 |
+
public $type;
|
22 |
+
public $status;
|
23 |
+
public $message;
|
24 |
+
public $documentation_url;
|
25 |
+
public $url;
|
26 |
+
|
27 |
+
public function __construct($error, $url) {
|
28 |
+
// record specific details of the API exception for processing
|
29 |
+
$this->url = $url;
|
30 |
+
$this->type = $error['type'];
|
31 |
+
$this->status = array_key_exists('status', $error) ? $error['status'] : '';
|
32 |
+
$this->message = $error['message'];
|
33 |
+
$this->documentation_url = $error['documentation_url'];
|
34 |
+
|
35 |
+
parent::__construct($this->message);
|
36 |
+
}
|
37 |
+
}
|
38 |
+
endif;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Thrown when attempting to use a resource that is not implemented.
|
42 |
+
*
|
43 |
+
* @uses AWeberException
|
44 |
+
* @package
|
45 |
+
* @version $id$
|
46 |
+
*/
|
47 |
+
|
48 |
+
if( ! class_exists('AWeberResourceNotImplemented') ) :
|
49 |
+
class AWeberResourceNotImplemented extends AWeberException {
|
50 |
+
|
51 |
+
public function __construct($object, $value) {
|
52 |
+
$this->object = $object;
|
53 |
+
$this->value = $value;
|
54 |
+
parent::__construct("Resource \"{$value}\" is not implemented on this resource.");
|
55 |
+
}
|
56 |
+
}
|
57 |
+
endif;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* AWeberMethodNotImplemented
|
61 |
+
*
|
62 |
+
* Thrown when attempting to call a method that is not implemented for a resource
|
63 |
+
* / collection. Differs from standard method not defined errors, as this will
|
64 |
+
* be thrown when the method is infact implemented on the base class, but the
|
65 |
+
* current resource type does not provide access to that method (ie calling
|
66 |
+
* getByMessageNumber on a web_forms collection).
|
67 |
+
*
|
68 |
+
* @uses AWeberException
|
69 |
+
* @package
|
70 |
+
* @version $id$
|
71 |
+
*/
|
72 |
+
|
73 |
+
if( ! class_exists('AWeberMethodNotImplemented') ) :
|
74 |
+
class AWeberMethodNotImplemented extends AWeberException {
|
75 |
+
|
76 |
+
public function __construct($object) {
|
77 |
+
$this->object = $object;
|
78 |
+
parent::__construct("This method is not implemented by the current resource.");
|
79 |
+
|
80 |
+
}
|
81 |
+
}
|
82 |
+
endif;
|
83 |
+
|
84 |
+
/**
|
85 |
+
* AWeberOAuthException
|
86 |
+
*
|
87 |
+
* OAuth exception, as generated by an API JSON error response
|
88 |
+
* @uses AWeberException
|
89 |
+
* @package
|
90 |
+
* @version $id$
|
91 |
+
*/
|
92 |
+
|
93 |
+
if( ! class_exists('AWeberOAuthException') ) :
|
94 |
+
class AWeberOAuthException extends AWeberException {
|
95 |
+
|
96 |
+
public function __construct($type, $message) {
|
97 |
+
$this->type = $type;
|
98 |
+
$this->message = $message;
|
99 |
+
parent::__construct("{$type}: {$message}");
|
100 |
+
}
|
101 |
+
}
|
102 |
+
endif;
|
103 |
+
|
104 |
+
/**
|
105 |
+
* AWeberOAuthDataMissing
|
106 |
+
*
|
107 |
+
* Used when a specific piece or pieces of data was not found in the
|
108 |
+
* response. This differs from the exception that might be thrown as
|
109 |
+
* an AWeberOAuthException when parameters are not provided because
|
110 |
+
* it is not the servers' expectations that were not met, but rather
|
111 |
+
* the expecations of the client were not met by the server.
|
112 |
+
*
|
113 |
+
* @uses AWeberException
|
114 |
+
* @package
|
115 |
+
* @version $id$
|
116 |
+
*/
|
117 |
+
|
118 |
+
if( ! class_exists('AWeberOAuthDataMissing') ) :
|
119 |
+
class AWeberOAuthDataMissing extends AWeberException {
|
120 |
+
|
121 |
+
public function __construct($missing) {
|
122 |
+
if (!is_array($missing)) $missing = array($missing);
|
123 |
+
$this->missing = $missing;
|
124 |
+
$required = join(', ', $this->missing);
|
125 |
+
parent::__construct("OAuthDataMissing: Response was expected to contain: {$required}");
|
126 |
+
|
127 |
+
}
|
128 |
+
}
|
129 |
+
endif;
|
130 |
+
|
131 |
+
/**
|
132 |
+
* AWeberResponseError
|
133 |
+
*
|
134 |
+
* This is raised when the server returns a non-JSON response. This
|
135 |
+
* should only occur when there is a server or some type of connectivity
|
136 |
+
* issue.
|
137 |
+
*
|
138 |
+
* @uses AWeberException
|
139 |
+
* @package
|
140 |
+
* @version $id$
|
141 |
+
*/
|
142 |
+
|
143 |
+
if( ! class_exists('AWeberResponseError') ) :
|
144 |
+
class AWeberResponseError extends AWeberException {
|
145 |
+
|
146 |
+
public function __construct($uri) {
|
147 |
+
$this->uri = $uri;
|
148 |
+
parent::__construct("Request for {$uri} did not respond properly.");
|
149 |
+
}
|
150 |
+
|
151 |
+
}
|
152 |
+
endif;
|
includes/subscription/libs/aweber_api/oauth_adapter.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( ! interface_exists('AWeberOAuthAdapter') ) :
|
4 |
+
interface AWeberOAuthAdapter {
|
5 |
+
|
6 |
+
public function request($method, $uri, $data = array());
|
7 |
+
public function getRequestToken($callbackUrl=false);
|
8 |
+
|
9 |
+
}
|
10 |
+
endif;
|
includes/subscription/libs/aweber_api/oauth_application.php
ADDED
@@ -0,0 +1,689 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! class_exists('CurlObject') ) require_once( 'curl_object.php' );
|
3 |
+
if ( ! class_exists('CurlResponse') ) require_once( 'curl_response.php' );
|
4 |
+
|
5 |
+
/**
|
6 |
+
* OAuthServiceProvider
|
7 |
+
*
|
8 |
+
* Represents the service provider in the OAuth authentication model.
|
9 |
+
* The class that implements the service provider will contain the
|
10 |
+
* specific knowledge about the API we are interfacing with, and
|
11 |
+
* provide useful methods for interfacing with its API.
|
12 |
+
*
|
13 |
+
* For example, an OAuthServiceProvider would know the URLs necessary
|
14 |
+
* to perform specific actions, the type of data that the API calls
|
15 |
+
* would return, and would be responsible for manipulating the results
|
16 |
+
* into a useful manner.
|
17 |
+
*
|
18 |
+
* It should be noted that the methods enforced by the OAuthServiceProvider
|
19 |
+
* interface are made so that it can interact with our OAuthApplication
|
20 |
+
* cleanly, rather than from a general use perspective, though some
|
21 |
+
* methods for those purposes do exists (such as getUserData).
|
22 |
+
*
|
23 |
+
* @package
|
24 |
+
* @version $id$
|
25 |
+
*/
|
26 |
+
|
27 |
+
if( ! interface_exists('OAuthServiceProvider') ) :
|
28 |
+
interface OAuthServiceProvider {
|
29 |
+
|
30 |
+
public function getAccessTokenUrl();
|
31 |
+
public function getAuthorizeUrl();
|
32 |
+
public function getRequestTokenUrl();
|
33 |
+
public function getAuthTokenFromUrl();
|
34 |
+
public function getBaseUri();
|
35 |
+
public function getUserData();
|
36 |
+
|
37 |
+
}
|
38 |
+
endif;
|
39 |
+
|
40 |
+
/**
|
41 |
+
* OAuthApplication
|
42 |
+
*
|
43 |
+
* Base class to represent an OAuthConsumer application. This class is
|
44 |
+
* intended to be extended and modified for each ServiceProvider. Each
|
45 |
+
* OAuthServiceProvider should have a complementary OAuthApplication
|
46 |
+
*
|
47 |
+
* The OAuthApplication class should contain any details on preparing
|
48 |
+
* requires that is unique or specific to that specific service provider's
|
49 |
+
* implementation of the OAuth model.
|
50 |
+
*
|
51 |
+
* This base class is based on OAuth 1.0, designed with AWeber's implementation
|
52 |
+
* as a model. An OAuthApplication built to work with a different service
|
53 |
+
* provider (especially an OAuth2.0 Application) may alter or bypass portions
|
54 |
+
* of the logic in this class to meet the needs of the service provider it
|
55 |
+
* is designed to interface with.
|
56 |
+
*
|
57 |
+
* @package
|
58 |
+
* @version $id$
|
59 |
+
*/
|
60 |
+
|
61 |
+
if( ! class_exists('OAuthApplication') ) :
|
62 |
+
class OAuthApplication implements AWeberOAuthAdapter {
|
63 |
+
public $debug = false;
|
64 |
+
|
65 |
+
public $userAgent = 'AWeber OAuth Consumer Application 1.0 - https://labs.aweber.com/';
|
66 |
+
|
67 |
+
public $format = false;
|
68 |
+
|
69 |
+
public $requiresTokenSecret = true;
|
70 |
+
|
71 |
+
public $signatureMethod = 'HMAC-SHA1';
|
72 |
+
public $version = '1.0';
|
73 |
+
|
74 |
+
public $curl = false;
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @var OAuthUser User currently interacting with the service provider
|
78 |
+
*/
|
79 |
+
public $user = false;
|
80 |
+
|
81 |
+
// Data binding this OAuthApplication to the consumer application it is acting
|
82 |
+
// as a proxy for
|
83 |
+
public $consumerKey = false;
|
84 |
+
public $consumerSecret = false;
|
85 |
+
|
86 |
+
/**
|
87 |
+
* __construct
|
88 |
+
*
|
89 |
+
* Create a new OAuthApplication, based on an OAuthServiceProvider
|
90 |
+
* @access public
|
91 |
+
* @return void
|
92 |
+
*/
|
93 |
+
public function __construct($parentApp = false) {
|
94 |
+
if ($parentApp) {
|
95 |
+
if (!is_a($parentApp, 'OAuthServiceProvider')) {
|
96 |
+
throw new Exception('Parent App must be a valid OAuthServiceProvider!');
|
97 |
+
}
|
98 |
+
$this->app = $parentApp;
|
99 |
+
}
|
100 |
+
$this->user = new OAuthUser();
|
101 |
+
$this->curl = new CurlObject();
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* request
|
106 |
+
*
|
107 |
+
* Implemented for a standard OAuth adapter interface
|
108 |
+
* @param mixed $method
|
109 |
+
* @param mixed $uri
|
110 |
+
* @param array $data
|
111 |
+
* @param array $options
|
112 |
+
* @access public
|
113 |
+
* @return void
|
114 |
+
*/
|
115 |
+
public function request($method, $uri, $data = array(), $options = array()) {
|
116 |
+
$uri = $this->app->removeBaseUri($uri);
|
117 |
+
$url = $this->app->getBaseUri() . $uri;
|
118 |
+
|
119 |
+
# WARNING: non-primative items in data must be json serialized in GET and POST.
|
120 |
+
if ($method == 'POST' or $method == 'GET') {
|
121 |
+
foreach ($data as $key => $value) {
|
122 |
+
if (is_array($value)) {
|
123 |
+
$data[$key] = json_encode($value);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
$response = $this->makeRequest($method, $url, $data);
|
129 |
+
if (!empty($options['return'])) {
|
130 |
+
if ($options['return'] == 'status') {
|
131 |
+
return $response->headers['Status-Code'];
|
132 |
+
}
|
133 |
+
if ($options['return'] == 'headers') {
|
134 |
+
return $response->headers;
|
135 |
+
}
|
136 |
+
if ($options['return'] == 'integer') {
|
137 |
+
return intval($response->body);
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
$data = json_decode($response->body, true);
|
142 |
+
|
143 |
+
if (empty($options['allow_empty']) && !isset($data)) {
|
144 |
+
throw new AWeberResponseError($uri);
|
145 |
+
}
|
146 |
+
return $data;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* getRequestToken
|
151 |
+
*
|
152 |
+
* Gets a new request token / secret for this user.
|
153 |
+
* @access public
|
154 |
+
* @return void
|
155 |
+
*/
|
156 |
+
public function getRequestToken($callbackUrl=false) {
|
157 |
+
$data = ($callbackUrl)? array('oauth_callback' => $callbackUrl) : array();
|
158 |
+
$resp = $this->makeRequest('POST', $this->app->getRequestTokenUrl(), $data);
|
159 |
+
$data = $this->parseResponse($resp);
|
160 |
+
$this->requiredFromResponse($data, array('oauth_token', 'oauth_token_secret'));
|
161 |
+
$this->user->requestToken = $data['oauth_token'];
|
162 |
+
$this->user->tokenSecret = $data['oauth_token_secret'];
|
163 |
+
return $data['oauth_token'];
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* getAccessToken
|
168 |
+
*
|
169 |
+
* Makes a request for access tokens. Requires that the current user has an authorized
|
170 |
+
* token and token secret.
|
171 |
+
*
|
172 |
+
* @access public
|
173 |
+
* @return void
|
174 |
+
*/
|
175 |
+
public function getAccessToken() {
|
176 |
+
$resp = $this->makeRequest('POST', $this->app->getAccessTokenUrl(),
|
177 |
+
array('oauth_verifier' => $this->user->verifier)
|
178 |
+
);
|
179 |
+
$data = $this->parseResponse($resp);
|
180 |
+
$this->requiredFromResponse($data, array('oauth_token', 'oauth_token_secret'));
|
181 |
+
|
182 |
+
if (empty($data['oauth_token'])) {
|
183 |
+
throw new AWeberOAuthDataMissing('oauth_token');
|
184 |
+
}
|
185 |
+
|
186 |
+
$this->user->accessToken = $data['oauth_token'];
|
187 |
+
$this->user->tokenSecret = $data['oauth_token_secret'];
|
188 |
+
return array($data['oauth_token'], $data['oauth_token_secret']);
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* parseAsError
|
193 |
+
*
|
194 |
+
* Checks if response is an error. If it is, raise an appropriately
|
195 |
+
* configured exception.
|
196 |
+
*
|
197 |
+
* @param mixed $response Data returned from the server, in array form
|
198 |
+
* @access public
|
199 |
+
* @throws AWeberOAuthException
|
200 |
+
* @return void
|
201 |
+
*/
|
202 |
+
public function parseAsError($response) {
|
203 |
+
if (!empty($response['error'])) {
|
204 |
+
throw new AWeberOAuthException($response['error']['type'],
|
205 |
+
$response['error']['message']);
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* requiredFromResponse
|
211 |
+
*
|
212 |
+
* Enforce that all the fields in requiredFields are present and not
|
213 |
+
* empty in data. If a required field is empty, throw an exception.
|
214 |
+
*
|
215 |
+
* @param mixed $data Array of data
|
216 |
+
* @param mixed $requiredFields Array of required field names.
|
217 |
+
* @access protected
|
218 |
+
* @return void
|
219 |
+
*/
|
220 |
+
protected function requiredFromResponse($data, $requiredFields) {
|
221 |
+
foreach ($requiredFields as $field) {
|
222 |
+
if (empty($data[$field])) {
|
223 |
+
throw new AWeberOAuthDataMissing($field);
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* get
|
230 |
+
*
|
231 |
+
* Make a get request. Used to exchange user tokens with serice provider.
|
232 |
+
* @param mixed $url URL to make a get request from.
|
233 |
+
* @param array $data Data for the request.
|
234 |
+
* @access protected
|
235 |
+
* @return void
|
236 |
+
*/
|
237 |
+
protected function get($url, $data) {
|
238 |
+
$url = $this->_addParametersToUrl($url, $data);
|
239 |
+
$handle = $this->curl->init($url);
|
240 |
+
$resp = $this->_sendRequest($handle);
|
241 |
+
return $resp;
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* _addParametersToUrl
|
246 |
+
*
|
247 |
+
* Adds the parameters in associative array $data to the
|
248 |
+
* given URL
|
249 |
+
* @param String $url URL
|
250 |
+
* @param array $data Parameters to be added as a query string to
|
251 |
+
* the URL provided
|
252 |
+
* @access protected
|
253 |
+
* @return void
|
254 |
+
*/
|
255 |
+
protected function _addParametersToUrl($url, $data) {
|
256 |
+
if (!empty($data)) {
|
257 |
+
if (strpos($url, '?') === false) {
|
258 |
+
$url .= '?'.$this->buildData($data);
|
259 |
+
} else {
|
260 |
+
$url .= '&'.$this->buildData($data);
|
261 |
+
}
|
262 |
+
}
|
263 |
+
return $url;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* generateNonce
|
268 |
+
*
|
269 |
+
* Generates a 'nonce', which is a unique request id based on the
|
270 |
+
* timestamp. If no timestamp is provided, generate one.
|
271 |
+
* @param mixed $timestamp Either a timestamp (epoch seconds) or false,
|
272 |
+
* in which case it will generate a timestamp.
|
273 |
+
* @access public
|
274 |
+
* @return string Returns a unique nonce
|
275 |
+
*/
|
276 |
+
public function generateNonce($timestamp = false) {
|
277 |
+
if (!$timestamp) $timestamp = $this->generateTimestamp();
|
278 |
+
return md5($timestamp.'-'.rand(10000,99999).'-'.uniqid());
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* generateTimestamp
|
283 |
+
*
|
284 |
+
* Generates a timestamp, in seconds
|
285 |
+
* @access public
|
286 |
+
* @return int Timestamp, in epoch seconds
|
287 |
+
*/
|
288 |
+
public function generateTimestamp() {
|
289 |
+
return time();
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* createSignature
|
294 |
+
*
|
295 |
+
* Creates a signature on the signature base and the signature key
|
296 |
+
* @param mixed $sigBase Base string of data to sign
|
297 |
+
* @param mixed $sigKey Key to sign the data with
|
298 |
+
* @access public
|
299 |
+
* @return string The signature
|
300 |
+
*/
|
301 |
+
public function createSignature($sigBase, $sigKey) {
|
302 |
+
switch ($this->signatureMethod) {
|
303 |
+
case 'HMAC-SHA1':
|
304 |
+
default:
|
305 |
+
return base64_encode(hash_hmac('sha1', $sigBase, $sigKey, true));
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* encode
|
311 |
+
*
|
312 |
+
* Short-cut for utf8_encode / rawurlencode
|
313 |
+
* @param mixed $data Data to encode
|
314 |
+
* @access protected
|
315 |
+
* @return void Encoded data
|
316 |
+
*/
|
317 |
+
protected function encode($data) {
|
318 |
+
return rawurlencode($data);
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* createSignatureKey
|
323 |
+
*
|
324 |
+
* Creates a key that will be used to sign our signature. Signatures
|
325 |
+
* are signed with the consumerSecret for this consumer application and
|
326 |
+
* the token secret of the user that the application is acting on behalf
|
327 |
+
* of.
|
328 |
+
* @access public
|
329 |
+
* @return void
|
330 |
+
*/
|
331 |
+
public function createSignatureKey() {
|
332 |
+
return $this->consumerSecret.'&'.$this->user->tokenSecret;
|
333 |
+
}
|
334 |
+
|
335 |
+
/**
|
336 |
+
* getOAuthRequestData
|
337 |
+
*
|
338 |
+
* Get all the pre-signature, OAuth specific parameters for a request.
|
339 |
+
* @access public
|
340 |
+
* @return void
|
341 |
+
*/
|
342 |
+
public function getOAuthRequestData() {
|
343 |
+
$token = $this->user->getHighestPriorityToken();
|
344 |
+
$ts = $this->generateTimestamp();
|
345 |
+
$nonce = $this->generateNonce($ts);
|
346 |
+
return array(
|
347 |
+
'oauth_token' => $token,
|
348 |
+
'oauth_consumer_key' => $this->consumerKey,
|
349 |
+
'oauth_version' => $this->version,
|
350 |
+
'oauth_timestamp' => $ts,
|
351 |
+
'oauth_signature_method' => $this->signatureMethod,
|
352 |
+
'oauth_nonce' => $nonce);
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
/**
|
357 |
+
* mergeOAuthData
|
358 |
+
*
|
359 |
+
* @param mixed $requestData
|
360 |
+
* @access public
|
361 |
+
* @return void
|
362 |
+
*/
|
363 |
+
public function mergeOAuthData($requestData) {
|
364 |
+
$oauthData = $this->getOAuthRequestData();
|
365 |
+
return array_merge($requestData, $oauthData);
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* createSignatureBase
|
370 |
+
*
|
371 |
+
* @param mixed $method String name of HTTP method, such as "GET"
|
372 |
+
* @param mixed $url URL where this request will go
|
373 |
+
* @param mixed $data Array of params for this request. This should
|
374 |
+
* include ALL oauth properties except for the signature.
|
375 |
+
* @access public
|
376 |
+
* @return void
|
377 |
+
*/
|
378 |
+
public function createSignatureBase($method, $url, $data) {
|
379 |
+
$method = $this->encode(strtoupper($method));
|
380 |
+
$query = parse_url($url, PHP_URL_QUERY);
|
381 |
+
if ($query) {
|
382 |
+
$parts = explode('?', $url, 2);
|
383 |
+
$url = array_shift($parts);
|
384 |
+
$items = explode('&', $query);
|
385 |
+
foreach ($items as $item) {
|
386 |
+
list($key, $value) = explode('=', $item);
|
387 |
+
$data[rawurldecode($key)] = rawurldecode($value);
|
388 |
+
}
|
389 |
+
}
|
390 |
+
$url = $this->encode($url);
|
391 |
+
$data = $this->encode($this->collapseDataForSignature($data));
|
392 |
+
|
393 |
+
return $method.'&'.$url.'&'.$data;
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* collapseDataForSignature
|
398 |
+
*
|
399 |
+
* Turns an array of request data into a string, as used by the oauth
|
400 |
+
* signature
|
401 |
+
* @param mixed $data
|
402 |
+
* @access public
|
403 |
+
* @return void
|
404 |
+
*/
|
405 |
+
public function collapseDataForSignature($data) {
|
406 |
+
ksort($data);
|
407 |
+
$collapse = '';
|
408 |
+
foreach ($data as $key => $val) {
|
409 |
+
if (!empty($collapse)) $collapse .= '&';
|
410 |
+
$collapse .= $key.'='.$this->encode($val);
|
411 |
+
}
|
412 |
+
return $collapse;
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* signRequest
|
417 |
+
*
|
418 |
+
* Signs the request.
|
419 |
+
*
|
420 |
+
* @param mixed $method HTTP method
|
421 |
+
* @param mixed $url URL for the request
|
422 |
+
* @param mixed $data The data to be signed
|
423 |
+
* @access public
|
424 |
+
* @return array The data, with the signature.
|
425 |
+
*/
|
426 |
+
public function signRequest($method, $url, $data) {
|
427 |
+
$base = $this->createSignatureBase($method, $url, $data);
|
428 |
+
$key = $this->createSignatureKey();
|
429 |
+
$data['oauth_signature'] = $this->createSignature($base, $key);
|
430 |
+
ksort($data);
|
431 |
+
return $data;
|
432 |
+
}
|
433 |
+
|
434 |
+
|
435 |
+
/**
|
436 |
+
* makeRequest
|
437 |
+
*
|
438 |
+
* Public facing function to make a request
|
439 |
+
*
|
440 |
+
* @param mixed $method
|
441 |
+
* @param mixed $url - Reserved characters in query params MUST be escaped
|
442 |
+
* @param mixed $data - Reserved characters in values MUST NOT be escaped
|
443 |
+
* @access public
|
444 |
+
* @return void
|
445 |
+
*/
|
446 |
+
public function makeRequest($method, $url, $data=array()) {
|
447 |
+
|
448 |
+
if ($this->debug) echo "\n** {$method}: $url\n";
|
449 |
+
|
450 |
+
switch (strtoupper($method)) {
|
451 |
+
case 'POST':
|
452 |
+
$oauth = $this->prepareRequest($method, $url, $data);
|
453 |
+
$resp = $this->post($url, $oauth);
|
454 |
+
break;
|
455 |
+
|
456 |
+
case 'GET':
|
457 |
+
$oauth = $this->prepareRequest($method, $url, $data);
|
458 |
+
$resp = $this->get($url, $oauth, $data);
|
459 |
+
break;
|
460 |
+
|
461 |
+
case 'DELETE':
|
462 |
+
$oauth = $this->prepareRequest($method, $url, $data);
|
463 |
+
$resp = $this->delete($url, $oauth);
|
464 |
+
break;
|
465 |
+
|
466 |
+
case 'PATCH':
|
467 |
+
$oauth = $this->prepareRequest($method, $url, array());
|
468 |
+
$resp = $this->patch($url, $oauth, $data);
|
469 |
+
break;
|
470 |
+
}
|
471 |
+
|
472 |
+
// enable debug output
|
473 |
+
if ($this->debug) {
|
474 |
+
echo "<pre>";
|
475 |
+
print_r($oauth);
|
476 |
+
echo " --> Status: {$resp->headers['Status-Code']}\n";
|
477 |
+
echo " --> Body: {$resp->body}";
|
478 |
+
echo "</pre>";
|
479 |
+
}
|
480 |
+
|
481 |
+
if (!$resp) {
|
482 |
+
$msg = 'Unable to connect to the AWeber API. (' . $this->error . ')';
|
483 |
+
$error = array('message' => $msg, 'type' => 'APIUnreachableError',
|
484 |
+
'documentation_url' => 'https://labs.aweber.com/docs/troubleshooting');
|
485 |
+
throw new AWeberAPIException($error, $url);
|
486 |
+
}
|
487 |
+
|
488 |
+
if($resp->headers['Status-Code'] >= 400) {
|
489 |
+
$data = json_decode($resp->body, true);
|
490 |
+
throw new AWeberAPIException($data['error'], $url);
|
491 |
+
}
|
492 |
+
|
493 |
+
return $resp;
|
494 |
+
}
|
495 |
+
|
496 |
+
/**
|
497 |
+
* put
|
498 |
+
*
|
499 |
+
* Prepare an OAuth put method.
|
500 |
+
*
|
501 |
+
* @param mixed $url URL where we are making the request to
|
502 |
+
* @param mixed $data Data that is used to make the request
|
503 |
+
* @access protected
|
504 |
+
* @return void
|
505 |
+
*/
|
506 |
+
protected function patch($url, $oauth, $data) {
|
507 |
+
$url = $this->_addParametersToUrl($url, $oauth);
|
508 |
+
$handle = $this->curl->init($url);
|
509 |
+
$this->curl->setopt($handle, CURLOPT_CUSTOMREQUEST, 'PATCH');
|
510 |
+
$this->curl->setopt($handle, CURLOPT_POSTFIELDS, json_encode($data));
|
511 |
+
$resp = $this->_sendRequest($handle, array('Expect:', 'Content-Type: application/json'));
|
512 |
+
return $resp;
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* post
|
517 |
+
*
|
518 |
+
* Prepare an OAuth post method.
|
519 |
+
*
|
520 |
+
* @param mixed $url URL where we are making the request to
|
521 |
+
* @param mixed $data Data that is used to make the request
|
522 |
+
* @access protected
|
523 |
+
* @return void
|
524 |
+
*/
|
525 |
+
protected function post($url, $oauth) {
|
526 |
+
$handle = $this->curl->init($url);
|
527 |
+
$postData = $this->buildData($oauth);
|
528 |
+
$this->curl->setopt($handle, CURLOPT_POST, true);
|
529 |
+
$this->curl->setopt($handle, CURLOPT_POSTFIELDS, $postData);
|
530 |
+
$resp = $this->_sendRequest($handle);
|
531 |
+
return $resp;
|
532 |
+
}
|
533 |
+
|
534 |
+
/**
|
535 |
+
* delete
|
536 |
+
*
|
537 |
+
* Makes a DELETE request
|
538 |
+
* @param mixed $url URL where we are making the request to
|
539 |
+
* @param mixed $data Data that is used in the request
|
540 |
+
* @access protected
|
541 |
+
* @return void
|
542 |
+
*/
|
543 |
+
protected function delete($url, $data) {
|
544 |
+
$url = $this->_addParametersToUrl($url, $data);
|
545 |
+
$handle = $this->curl->init($url);
|
546 |
+
$this->curl->setopt($handle, CURLOPT_CUSTOMREQUEST, 'DELETE');
|
547 |
+
$resp = $this->_sendRequest($handle);
|
548 |
+
return $resp;
|
549 |
+
}
|
550 |
+
|
551 |
+
/**
|
552 |
+
* buildData
|
553 |
+
*
|
554 |
+
* Creates a string of data for either post or get requests.
|
555 |
+
* @param mixed $data Array of key value pairs
|
556 |
+
* @access public
|
557 |
+
* @return void
|
558 |
+
*/
|
559 |
+
public function buildData($data) {
|
560 |
+
ksort($data);
|
561 |
+
$params = array();
|
562 |
+
foreach ($data as $key => $value) {
|
563 |
+
$params[] = $key.'='.$this->encode($value);
|
564 |
+
}
|
565 |
+
return implode('&', $params);
|
566 |
+
}
|
567 |
+
|
568 |
+
/**
|
569 |
+
* _sendRequest
|
570 |
+
*
|
571 |
+
* Actually makes a request.
|
572 |
+
* @param mixed $handle Curl handle
|
573 |
+
* @param array $headers Additional headers needed for request
|
574 |
+
* @access private
|
575 |
+
* @return void
|
576 |
+
*/
|
577 |
+
private function _sendRequest($handle, $headers = array('Expect:')) {
|
578 |
+
$this->curl->setopt($handle, CURLOPT_RETURNTRANSFER, true);
|
579 |
+
$this->curl->setopt($handle, CURLOPT_HEADER, true);
|
580 |
+
$this->curl->setopt($handle, CURLOPT_HTTPHEADER, $headers);
|
581 |
+
$this->curl->setopt($handle, CURLOPT_USERAGENT, $this->userAgent);
|
582 |
+
$this->curl->setopt($handle, CURLOPT_SSL_VERIFYPEER, FALSE);
|
583 |
+
$this->curl->setopt($handle, CURLOPT_VERBOSE, FALSE);
|
584 |
+
$this->curl->setopt($handle, CURLOPT_CONNECTTIMEOUT, 10);
|
585 |
+
$this->curl->setopt($handle, CURLOPT_TIMEOUT, 90);
|
586 |
+
$resp = $this->curl->execute($handle);
|
587 |
+
if ($resp) {
|
588 |
+
return new CurlResponse($resp);
|
589 |
+
}
|
590 |
+
$this->error = $this->curl->errno($handle) . ' - ' .
|
591 |
+
$this->curl->error($handle);
|
592 |
+
return false;
|
593 |
+
}
|
594 |
+
|
595 |
+
/**
|
596 |
+
* prepareRequest
|
597 |
+
*
|
598 |
+
* @param mixed $method HTTP method
|
599 |
+
* @param mixed $url URL for the request
|
600 |
+
* @param mixed $data The data to generate oauth data and be signed
|
601 |
+
* @access public
|
602 |
+
* @return void The data, with all its OAuth variables and signature
|
603 |
+
*/
|
604 |
+
public function prepareRequest($method, $url, $data) {
|
605 |
+
$data = $this->mergeOAuthData($data);
|
606 |
+
$data = $this->signRequest($method, $url, $data);
|
607 |
+
return $data;
|
608 |
+
}
|
609 |
+
|
610 |
+
/**
|
611 |
+
* parseResponse
|
612 |
+
*
|
613 |
+
* Parses the body of the response into an array
|
614 |
+
* @param mixed $string The body of a response
|
615 |
+
* @access public
|
616 |
+
* @return void
|
617 |
+
*/
|
618 |
+
public function parseResponse($resp) {
|
619 |
+
$data = array();
|
620 |
+
|
621 |
+
if (!$resp) { return $data; }
|
622 |
+
if (empty($resp)) { return $data; }
|
623 |
+
if (empty($resp->body)) { return $data; }
|
624 |
+
|
625 |
+
switch ($this->format) {
|
626 |
+
case 'json':
|
627 |
+
$data = json_decode($resp->body);
|
628 |
+
break;
|
629 |
+
default:
|
630 |
+
parse_str($resp->body, $data);
|
631 |
+
}
|
632 |
+
$this->parseAsError($data);
|
633 |
+
return $data;
|
634 |
+
}
|
635 |
+
|
636 |
+
}
|
637 |
+
endif;
|
638 |
+
|
639 |
+
/**
|
640 |
+
* OAuthUser
|
641 |
+
*
|
642 |
+
* Simple data class representing the user in an OAuth application.
|
643 |
+
* @package
|
644 |
+
* @version $id$
|
645 |
+
*/
|
646 |
+
|
647 |
+
if( ! class_exists('OAuthUser') ) :
|
648 |
+
class OAuthUser {
|
649 |
+
|
650 |
+
public $authorizedToken = false;
|
651 |
+
public $requestToken = false;
|
652 |
+
public $verifier = false;
|
653 |
+
public $tokenSecret = false;
|
654 |
+
public $accessToken = false;
|
655 |
+
|
656 |
+
/**
|
657 |
+
* isAuthorized
|
658 |
+
*
|
659 |
+
* Checks if this user is authorized.
|
660 |
+
* @access public
|
661 |
+
* @return void
|
662 |
+
*/
|
663 |
+
public function isAuthorized() {
|
664 |
+
if (empty($this->authorizedToken) && empty($this->accessToken)) {
|
665 |
+
return false;
|
666 |
+
}
|
667 |
+
return true;
|
668 |
+
}
|
669 |
+
|
670 |
+
|
671 |
+
/**
|
672 |
+
* getHighestPriorityToken
|
673 |
+
*
|
674 |
+
* Returns highest priority token - used to define authorization
|
675 |
+
* state for a given OAuthUser
|
676 |
+
* @access public
|
677 |
+
* @return void
|
678 |
+
*/
|
679 |
+
public function getHighestPriorityToken() {
|
680 |
+
if (!empty($this->accessToken)) return $this->accessToken;
|
681 |
+
if (!empty($this->authorizedToken)) return $this->authorizedToken;
|
682 |
+
if (!empty($this->requestToken)) return $this->requestToken;
|
683 |
+
|
684 |
+
// Return no token, new user
|
685 |
+
return '';
|
686 |
+
}
|
687 |
+
|
688 |
+
}
|
689 |
+
endif;
|
includes/subscription/libs/mailchimp.php
ADDED
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Super-simple, minimum abstraction MailChimp API v3 wrapper
|
4 |
+
* MailChimp API v3: http://developer.mailchimp.com
|
5 |
+
* This wrapper: https://github.com/drewm/mailchimp-api
|
6 |
+
*
|
7 |
+
* @author Drew McLellan <drew.mclellan@gmail.com>
|
8 |
+
* @version 2.2
|
9 |
+
*/
|
10 |
+
|
11 |
+
if( ! class_exists('MailChimp') ):
|
12 |
+
|
13 |
+
class MailChimp {
|
14 |
+
|
15 |
+
private $api_key;
|
16 |
+
private $api_endpoint = 'https://<dc>.api.mailchimp.com/3.0';
|
17 |
+
|
18 |
+
/* SSL Verification
|
19 |
+
Read before disabling:
|
20 |
+
http://snippets.webaware.com.au/howto/stop-turning-off-curlopt_ssl_verifypeer-and-fix-your-php-config/
|
21 |
+
*/
|
22 |
+
public $verify_ssl = false;
|
23 |
+
|
24 |
+
private $request_successful = false;
|
25 |
+
private $last_error = '';
|
26 |
+
private $last_response = array();
|
27 |
+
private $last_request = array();
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Create a new instance
|
31 |
+
* @param string $api_key Your MailChimp API key
|
32 |
+
* @throws \Exception
|
33 |
+
*/
|
34 |
+
public function __construct( $api_key ) {
|
35 |
+
|
36 |
+
$this->api_key = $api_key;
|
37 |
+
|
38 |
+
list(, $data_center) = explode( '-', $this->api_key );
|
39 |
+
$this->api_endpoint = str_replace('<dc>', $data_center, $this->api_endpoint);
|
40 |
+
|
41 |
+
$this->last_response = array('headers' => null, 'body' => null);
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Convert an email address into a 'subscriber hash' for identifying the subscriber in a method URL
|
46 |
+
* @param string $email The subscriber's email address
|
47 |
+
* @return string Hashed version of the input
|
48 |
+
*/
|
49 |
+
public function subscriberHash($email) {
|
50 |
+
return md5(strtolower($email));
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Was the last request successful?
|
55 |
+
* @return bool True for success, false for failure
|
56 |
+
*/
|
57 |
+
public function success() {
|
58 |
+
return $this->request_successful;
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Get the last error returned by either the network transport, or by the API.
|
63 |
+
* If something didn't work, this should contain the string describing the problem.
|
64 |
+
* @return array|false describing the error
|
65 |
+
*/
|
66 |
+
public function getLastError() {
|
67 |
+
return $this->last_error ?: false;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Get an array containing the HTTP headers and the body of the API response.
|
72 |
+
* @return array Assoc array with keys 'headers' and 'body'
|
73 |
+
*/
|
74 |
+
public function getLastResponse() {
|
75 |
+
return $this->last_response;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Get an array containing the HTTP headers and the body of the API request.
|
80 |
+
* @return array Assoc array
|
81 |
+
*/
|
82 |
+
public function getLastRequest() {
|
83 |
+
return $this->last_request;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Make an HTTP DELETE request - for deleting data
|
88 |
+
* @param string $method URL of the API request method
|
89 |
+
* @param array $args Assoc array of arguments (if any)
|
90 |
+
* @param int $timeout Timeout limit for request in seconds
|
91 |
+
* @return array|false Assoc array of API response, decoded from JSON
|
92 |
+
*/
|
93 |
+
public function delete( $method, $args = array(), $timeout = 10 ) {
|
94 |
+
return $this->makeRequest('delete', $method, $args, $timeout);
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Make an HTTP GET request - for retrieving data
|
99 |
+
* @param string $method URL of the API request method
|
100 |
+
* @param array $args Assoc array of arguments (usually your data)
|
101 |
+
* @param int $timeout Timeout limit for request in seconds
|
102 |
+
* @return array|false Assoc array of API response, decoded from JSON
|
103 |
+
*/
|
104 |
+
public function get( $method, $args = array(), $timeout = 10 ) {
|
105 |
+
return $this->makeRequest('get', $method, $args, $timeout);
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Make an HTTP PATCH request - for performing partial updates
|
110 |
+
* @param string $method URL of the API request method
|
111 |
+
* @param array $args Assoc array of arguments (usually your data)
|
112 |
+
* @param int $timeout Timeout limit for request in seconds
|
113 |
+
* @return array|false Assoc array of API response, decoded from JSON
|
114 |
+
*/
|
115 |
+
public function patch( $method, $args = array(), $timeout = 10 ) {
|
116 |
+
return $this->makeRequest('patch', $method, $args, $timeout);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Make an HTTP POST request - for creating and updating items
|
121 |
+
* @param string $method URL of the API request method
|
122 |
+
* @param array $args Assoc array of arguments (usually your data)
|
123 |
+
* @param int $timeout Timeout limit for request in seconds
|
124 |
+
* @return array|false Assoc array of API response, decoded from JSON
|
125 |
+
*/
|
126 |
+
public function post( $method, $args = array(), $timeout = 10 ) {
|
127 |
+
return $this->makeRequest('post', $method, $args, $timeout);
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Make an HTTP PUT request - for creating new items
|
132 |
+
* @param string $method URL of the API request method
|
133 |
+
* @param array $args Assoc array of arguments (usually your data)
|
134 |
+
* @param int $timeout Timeout limit for request in seconds
|
135 |
+
* @return array|false Assoc array of API response, decoded from JSON
|
136 |
+
*/
|
137 |
+
public function put( $method, $args = array(), $timeout = 10 ) {
|
138 |
+
return $this->makeRequest('put', $method, $args, $timeout);
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Performs the underlying HTTP request. Not very exciting.
|
143 |
+
* @param string $http_verb The HTTP verb to use: get, post, put, patch, delete
|
144 |
+
* @param string $method The API method to be called
|
145 |
+
* @param array $args Assoc array of parameters to be passed
|
146 |
+
* @param int $timeout
|
147 |
+
* @return array|false Assoc array of decoded result
|
148 |
+
* @throws \Exception
|
149 |
+
*/
|
150 |
+
private function makeRequest( $http_verb, $method, $args = array(), $timeout = 10 ) {
|
151 |
+
|
152 |
+
if (!function_exists('curl_init') || !function_exists('curl_setopt')) {
|
153 |
+
throw new \Exception("cURL support is required, but can't be found.");
|
154 |
+
}
|
155 |
+
|
156 |
+
$url = $this->api_endpoint . '/' . $method;
|
157 |
+
|
158 |
+
$this->last_error = '';
|
159 |
+
$this->request_successful = false;
|
160 |
+
$response = array('headers' => null, 'body' => null);
|
161 |
+
$this->last_response = $response;
|
162 |
+
|
163 |
+
$this->last_request = array(
|
164 |
+
'method' => $http_verb,
|
165 |
+
'path' => $method,
|
166 |
+
'url' => $url,
|
167 |
+
'body' => '',
|
168 |
+
'timeout' => $timeout,
|
169 |
+
);
|
170 |
+
|
171 |
+
$ch = curl_init();
|
172 |
+
curl_setopt($ch, CURLOPT_URL, $url);
|
173 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
174 |
+
'Accept: application/vnd.api+json',
|
175 |
+
'Content-Type: application/vnd.api+json',
|
176 |
+
'Authorization: apikey ' . $this->api_key
|
177 |
+
));
|
178 |
+
curl_setopt($ch, CURLOPT_USERAGENT, 'DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)');
|
179 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
180 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
181 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);
|
182 |
+
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
|
183 |
+
curl_setopt($ch, CURLOPT_ENCODING, '');
|
184 |
+
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
|
185 |
+
|
186 |
+
switch ($http_verb) {
|
187 |
+
case 'post':
|
188 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
189 |
+
$this->attachRequestPayload($ch, $args);
|
190 |
+
break;
|
191 |
+
|
192 |
+
case 'get':
|
193 |
+
$query = http_build_query($args, '', '&');
|
194 |
+
curl_setopt($ch, CURLOPT_URL, $url . '?' . $query);
|
195 |
+
break;
|
196 |
+
|
197 |
+
case 'delete':
|
198 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
|
199 |
+
break;
|
200 |
+
|
201 |
+
case 'patch':
|
202 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
|
203 |
+
$this->attachRequestPayload($ch, $args);
|
204 |
+
break;
|
205 |
+
|
206 |
+
case 'put':
|
207 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
|
208 |
+
$this->attachRequestPayload($ch, $args);
|
209 |
+
break;
|
210 |
+
}
|
211 |
+
|
212 |
+
$response['body'] = curl_exec($ch);
|
213 |
+
$response['headers'] = curl_getinfo($ch);
|
214 |
+
|
215 |
+
if (isset($response['headers']['request_header'])) {
|
216 |
+
$this->last_request['headers'] = $response['headers']['request_header'];
|
217 |
+
}
|
218 |
+
|
219 |
+
if ($response['body'] === false) {
|
220 |
+
$this->last_error = curl_error($ch);
|
221 |
+
}
|
222 |
+
|
223 |
+
curl_close($ch);
|
224 |
+
|
225 |
+
$formattedResponse = $this->formatResponse($response);
|
226 |
+
|
227 |
+
$this->determineSuccess($response, $formattedResponse);
|
228 |
+
|
229 |
+
return $formattedResponse;
|
230 |
+
}
|
231 |
+
|
232 |
+
/**
|
233 |
+
* @return string The url to the API endpoint
|
234 |
+
*/
|
235 |
+
public function getApiEndpoint() {
|
236 |
+
return $this->api_endpoint;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Encode the data and attach it to the request
|
241 |
+
* @param resource $ch cURL session handle, used by reference
|
242 |
+
* @param array $data Assoc array of data to attach
|
243 |
+
*/
|
244 |
+
private function attachRequestPayload(&$ch, $data) {
|
245 |
+
$encoded = json_encode($data);
|
246 |
+
$this->last_request['body'] = $encoded;
|
247 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded);
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Decode the response and format any error messages for debugging
|
252 |
+
* @param array $response The response from the curl request
|
253 |
+
* @return array|false The JSON decoded into an array
|
254 |
+
*/
|
255 |
+
private function formatResponse($response) {
|
256 |
+
$this->last_response = $response;
|
257 |
+
|
258 |
+
if (!empty($response['body'])) {
|
259 |
+
return json_decode($response['body'], true);
|
260 |
+
}
|
261 |
+
|
262 |
+
return false;
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Check if the response was successful or a failure. If it failed, store the error.
|
267 |
+
* @param array $response The response from the curl request
|
268 |
+
* @param array|false $formattedResponse The response body payload from the curl request
|
269 |
+
* @return bool If the request was successful
|
270 |
+
*/
|
271 |
+
private function determineSuccess($response, $formattedResponse) {
|
272 |
+
$status = $this->findHTTPStatus($response, $formattedResponse);
|
273 |
+
|
274 |
+
if ($status >= 200 && $status <= 299) {
|
275 |
+
$this->request_successful = true;
|
276 |
+
return true;
|
277 |
+
}
|
278 |
+
|
279 |
+
if (isset($formattedResponse['detail'])) {
|
280 |
+
$this->last_error = sprintf('%d: %s', $formattedResponse['status'], $formattedResponse['detail']);
|
281 |
+
return false;
|
282 |
+
}
|
283 |
+
|
284 |
+
$this->last_error = 'Unknown error, call getLastResponse() to find out what happened.';
|
285 |
+
return false;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Find the HTTP status code from the headers or API response body
|
290 |
+
* @param array $response The response from the curl request
|
291 |
+
* @param array|false $formattedResponse The response body payload from the curl request
|
292 |
+
* @return int HTTP status code
|
293 |
+
*/
|
294 |
+
private function findHTTPStatus($response, $formattedResponse) {
|
295 |
+
if (!empty($response['headers']) && isset($response['headers']['http_code'])) {
|
296 |
+
return (int) $response['headers']['http_code'];
|
297 |
+
}
|
298 |
+
|
299 |
+
if (!empty($response['body']) && isset($formattedResponse['status'])) {
|
300 |
+
return (int) $formattedResponse['status'];
|
301 |
+
}
|
302 |
+
|
303 |
+
return 418;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
endif;
|
includes/wps-functions-options.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin options functions.
|
4 |
+
*/
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Get mailing services
|
8 |
+
*
|
9 |
+
* @use filter wp_subscribe_mailing_services
|
10 |
+
* @return array
|
11 |
+
*/
|
12 |
+
function wps_get_mailing_services( $type = 'raw' ) {
|
13 |
+
|
14 |
+
$services = array(
|
15 |
+
|
16 |
+
'aweber' => array(
|
17 |
+
'title' => esc_html__( 'Aweber', 'wp-subscribe' ),
|
18 |
+
'description' => esc_html__( 'Adds subscribers to your Aweber account.', 'wp-subscribe' ),
|
19 |
+
'class' => 'WPS_Subscription_Aweber'
|
20 |
+
),
|
21 |
+
|
22 |
+
'feedburner' => array(
|
23 |
+
'title' => esc_html__( 'FeedBurner', 'wp-subscribe' ),
|
24 |
+
'description' => esc_html__( 'Adds subscribers to your FeedBurner account.', 'wp-subscribe' ),
|
25 |
+
'class' => 'WPS_Subscription_FeedBurner'
|
26 |
+
),
|
27 |
+
|
28 |
+
'mailchimp' => array(
|
29 |
+
'title' => esc_html__( 'MailChimp', 'wp-subscribe' ),
|
30 |
+
'description' => esc_html__( 'Adds subscribers to your MailChimp account.', 'wp-subscribe' ),
|
31 |
+
'class' => 'WPS_Subscription_MailChimp'
|
32 |
+
)
|
33 |
+
);
|
34 |
+
|
35 |
+
$services = apply_filters( 'wp_subscribe_mailing_services', $services );
|
36 |
+
|
37 |
+
if( 'options' === $type ) {
|
38 |
+
return wp_list_pluck( $services, 'title' );
|
39 |
+
}
|
40 |
+
|
41 |
+
return $services;
|
42 |
+
}
|
includes/wps-helpers.php
ADDED
@@ -0,0 +1,365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Helper Functions
|
4 |
+
*/
|
5 |
+
|
6 |
+
// Exit if accessed directly
|
7 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
8 |
+
|
9 |
+
// ---------------- PLUGIN HELPERS -----------------------------------
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Generate the subscription form
|
13 |
+
* @return void
|
14 |
+
*/
|
15 |
+
function wps_the_form( $options = null ) {
|
16 |
+
|
17 |
+
global $wp, $wp_subscribe_forms;
|
18 |
+
|
19 |
+
// Options
|
20 |
+
if ( null == $options ) {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
// Enqueue script and styles
|
25 |
+
wp_enqueue_style( 'wp-subscribe' );
|
26 |
+
wp_enqueue_script( 'wp-subscribe' );
|
27 |
+
|
28 |
+
$wp_subscribe_forms++;
|
29 |
+
$service = wps_get_subscription_service( $options['service'] );
|
30 |
+
$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );
|
31 |
+
?>
|
32 |
+
<?php if( isset( $options['before_widget'] ) ) : ?>
|
33 |
+
<?php echo $options['before_widget'] ?>
|
34 |
+
<?php else: ?>
|
35 |
+
<div class="wp-subscribe-popup-form-wrapper">
|
36 |
+
<?php endif; ?>
|
37 |
+
|
38 |
+
<?php wps_the_form_css( $wp_subscribe_forms, $options ) ?>
|
39 |
+
|
40 |
+
<div id="wp-subscribe" class="wp-subscribe-wrap wp-subscribe wp-subscribe-<?php echo $wp_subscribe_forms ?>" data-thanks_page="<?php echo absint( $options['thanks_page'] ) ?>" data-thanks_page_url="<?php echo esc_url( $options['thanks_page_url'] ) ?>" data-thanks_page_new_window="0">
|
41 |
+
|
42 |
+
<h4 class="title"><?php echo wp_kses_post( $options['title'] )?></h4>
|
43 |
+
|
44 |
+
<p class="text"><?php echo wp_kses_post( $options['text'] ) ?></p>
|
45 |
+
|
46 |
+
<?php if( method_exists( $service, 'the_form' ) ) :
|
47 |
+
$service->the_form( $wp_subscribe_forms, $options );
|
48 |
+
else: ?>
|
49 |
+
|
50 |
+
<form action="<?php echo $current_url ?>" method="post" class="wp-subscribe-form wp-subscribe-<?php echo $options['service'] ?>" id="wp-subscribe-form-<?php echo $wp_subscribe_forms ?>">
|
51 |
+
|
52 |
+
<?php if( !empty( $options['include_name_field'] ) ) : ?>
|
53 |
+
<input class="regular-text name-field" type="text" name="name" placeholder="<?php echo esc_attr( $options['name_placeholder'] ) ?>">
|
54 |
+
<?php endif; ?>
|
55 |
+
|
56 |
+
<input class="regular-text email-field" type="text" name="email" placeholder="<?php echo esc_attr( $options['email_placeholder'] ) ?>">
|
57 |
+
|
58 |
+
<input type="hidden" name="form_type" value="<?php echo $options['form_type'] ?>">
|
59 |
+
|
60 |
+
<input type="hidden" name="service" value="<?php echo $options['service'] ?>">
|
61 |
+
|
62 |
+
<input type="hidden" name="widget" value="<?php echo isset( $options['widget_id'] ) ? $options['widget_id'] : '0'; ?>">
|
63 |
+
|
64 |
+
<input class="submit" type="submit" name="submit" value="<?php echo esc_attr( $options['button_text'] ) ?>">
|
65 |
+
|
66 |
+
</form>
|
67 |
+
|
68 |
+
<?php endif; ?>
|
69 |
+
|
70 |
+
<?php if( !empty( $options['success_message'] ) ) {
|
71 |
+
printf( '<p class="thanks">%s</p>', wp_kses_post( $options['success_message'] ) );
|
72 |
+
} ?>
|
73 |
+
|
74 |
+
<?php if( !empty( $options['error_message'] ) ) {
|
75 |
+
printf( '<p class="error">%s</p>', wp_kses_post( $options['error_message'] ) );
|
76 |
+
} ?>
|
77 |
+
|
78 |
+
<div class="clear"></div>
|
79 |
+
|
80 |
+
<p class="footer-text"><?php echo $options['footer_text'];?></p>
|
81 |
+
|
82 |
+
</div>
|
83 |
+
|
84 |
+
<?php if( isset( $options['after_widget'] ) ) : ?>
|
85 |
+
<?php echo $options['after_widget'] ?>
|
86 |
+
<?php else: ?>
|
87 |
+
</div><!-- /form-wrapper -->
|
88 |
+
<?php endif; ?>
|
89 |
+
|
90 |
+
<?php
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* [wps_the_form_css description]
|
95 |
+
* @param [type] $id [description]
|
96 |
+
* @param [type] $options [description]
|
97 |
+
* @return [type] [description]
|
98 |
+
*/
|
99 |
+
function wps_the_form_css( $id, $options, $type = 'subscribe_form' ) {
|
100 |
+
|
101 |
+
$css = array();
|
102 |
+
$id = "\n.wp-subscribe-{$id} ";
|
103 |
+
|
104 |
+
if ( 'subscribe_form' == $type ) {
|
105 |
+
$css[] = sprintf( '{background: %s}', $options['background_color'] );
|
106 |
+
$css[] = sprintf( 'h4 {color: %s}', $options['title_color'] );
|
107 |
+
$css[] = sprintf( 'p {color: %s}', $options['text_color'] );
|
108 |
+
$css[] = sprintf( '.regular-text {background: %s; color: %s }', $options['field_background_color'], $options['field_text_color'] );
|
109 |
+
$css[] = sprintf( '.submit {background: %s; color: %s }', $options['button_background_color'], $options['button_text_color'] );
|
110 |
+
$css[] = sprintf( '.thanks {color: %s; display: none}', $options['text_color'] );
|
111 |
+
$css[] = sprintf( '.error {color: %s; display: none}', $options['text_color'] );
|
112 |
+
$css[] = sprintf( '.footer-text {color: %s }', $options['footer_text_color'] );
|
113 |
+
}
|
114 |
+
?>
|
115 |
+
<style>
|
116 |
+
<?php echo $id . join( $id, $css ) ?>
|
117 |
+
</style>
|
118 |
+
<?php
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Get widget setting by id
|
123 |
+
* @param int $widget_id
|
124 |
+
* @return mixed
|
125 |
+
*/
|
126 |
+
function wps_get_widget_settings( $widget_id ) {
|
127 |
+
|
128 |
+
$options = array();
|
129 |
+
global $wp_registered_widgets;
|
130 |
+
|
131 |
+
if ( isset( $wp_registered_widgets ) && isset( $wp_registered_widgets[$widget_id] ) ) {
|
132 |
+
|
133 |
+
$widget = $wp_registered_widgets[$widget_id];
|
134 |
+
$settings = $widget['callback'][0]->get_settings();
|
135 |
+
|
136 |
+
if ( isset( $settings[$widget['params'][0]['number']] ) ) {
|
137 |
+
$options = $settings[$widget['params'][0]['number']];
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
return $options;
|
142 |
+
}
|
143 |
+
|
144 |
+
|
145 |
+
// ---------------- STRING HELPERS ---------------------------------
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Check if the string begins with the given value
|
149 |
+
*
|
150 |
+
* @param string $needle The sub-string to search for
|
151 |
+
* @param string $haystack The string to search
|
152 |
+
*
|
153 |
+
* @return bool
|
154 |
+
*/
|
155 |
+
function wps_str_start_with( $needle, $haystack ) {
|
156 |
+
return substr_compare( $haystack, $needle, 0, strlen( $needle ) ) === 0;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Check if the string contains the given value
|
161 |
+
*
|
162 |
+
* @param string $needle The sub-string to search for
|
163 |
+
* @param string $haystack The string to search
|
164 |
+
*
|
165 |
+
* @return bool
|
166 |
+
*/
|
167 |
+
function wps_str_contains( $needle, $haystack ) {
|
168 |
+
return strpos( $haystack, $needle ) !== false;
|
169 |
+
}
|
170 |
+
|
171 |
+
|
172 |
+
// ---------------- HTML HELPERS ---------------------------------
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Output select field html
|
176 |
+
*
|
177 |
+
* @param array $args
|
178 |
+
*
|
179 |
+
* @return void
|
180 |
+
*/
|
181 |
+
function wps_field_select( $args = array() ) {
|
182 |
+
|
183 |
+
extract( wp_parse_args( $args, array(
|
184 |
+
'class' => 'widefat'
|
185 |
+
) ) );
|
186 |
+
?>
|
187 |
+
<select class="<?php echo esc_attr( $class ) ?>" id="<?php echo esc_attr( $id ) ?>" name="<?php echo esc_attr( $name ) ?>">
|
188 |
+
|
189 |
+
<?php foreach ( $options as $key => $text ) : ?>
|
190 |
+
<option value="<?php echo esc_attr( $key ) ?>"<?php selected( $key, $value ) ?>>
|
191 |
+
<?php echo esc_html( $text ) ?>
|
192 |
+
</option>
|
193 |
+
<?php endforeach ?>
|
194 |
+
</select>
|
195 |
+
<?php
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Output text field html
|
200 |
+
*
|
201 |
+
* @param array $args
|
202 |
+
*
|
203 |
+
* @return void
|
204 |
+
*/
|
205 |
+
function wps_field_text( $args = array() ) {
|
206 |
+
|
207 |
+
extract( wp_parse_args( $args, array(
|
208 |
+
'class' => 'widefat'
|
209 |
+
) ) );
|
210 |
+
?>
|
211 |
+
<input class="<?php echo esc_attr( $class ) ?>" id="<?php echo esc_attr( $id ) ?>" name="<?php echo esc_attr( $name ) ?>" type="text" value="<?php echo esc_attr( $value ) ?>"<?php if( isset( $data_id ) ) { printf( 'data-id="%s"', $data_id ); } ?>>
|
212 |
+
<?php
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Output hidden field html
|
217 |
+
*
|
218 |
+
* @param array $args
|
219 |
+
*
|
220 |
+
* @return void
|
221 |
+
*/
|
222 |
+
function wps_field_hidden( $args = array() ) {
|
223 |
+
|
224 |
+
extract( $args );
|
225 |
+
?>
|
226 |
+
<input id="<?php echo esc_attr( $id ) ?>" name="<?php echo esc_attr( $name ) ?>" type="hidden" value="<?php echo esc_attr( $value ) ?>"<?php if( isset( $data_id ) ) { printf( 'data-id="%s"', $data_id ); } ?>>
|
227 |
+
<?php
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Get animation select
|
232 |
+
* @param string $id
|
233 |
+
* @param string $name
|
234 |
+
* @return void
|
235 |
+
*/
|
236 |
+
function wps_get_animations( $id = '', $name = '', $value = '' ) {
|
237 |
+
|
238 |
+
$animations = array(
|
239 |
+
'0' => esc_html__( 'No Animation', 'wp-subscribe' ),
|
240 |
+
esc_html__( 'Attention Seekers', 'wp-subscribe' ) => array(
|
241 |
+
'bounce' => esc_html__( 'bounce', 'wp-subscribe' ),
|
242 |
+
'flash' => esc_html__( 'flash', 'wp-subscribe' ),
|
243 |
+
'pulse' => esc_html__( 'pulse', 'wp-subscribe' ),
|
244 |
+
'rubberBand' => esc_html__( 'rubberBand', 'wp-subscribe' ),
|
245 |
+
'shake' => esc_html__( 'shake', 'wp-subscribe' ),
|
246 |
+
'swing' => esc_html__( 'swing', 'wp-subscribe' ),
|
247 |
+
'tada' => esc_html__( 'tada', 'wp-subscribe' ),
|
248 |
+
'wobble' => esc_html__( 'wobble', 'wp-subscribe' ),
|
249 |
+
),
|
250 |
+
esc_html__( 'Bouncing Entrances', 'wp-subscribe' ) => array(
|
251 |
+
'bounceIn' => esc_html__( 'bounceIn', 'wp-subscribe' ),
|
252 |
+
'bounceInDown' => esc_html__( 'bounceInDown', 'wp-subscribe' ),
|
253 |
+
'bounceInLeft' => esc_html__( 'bounceInLeft', 'wp-subscribe' ),
|
254 |
+
'bounceInRight' => esc_html__( 'bounceInRight', 'wp-subscribe' ),
|
255 |
+
'bounceInUp' => esc_html__( 'bounceInUp', 'wp-subscribe' ),
|
256 |
+
),
|
257 |
+
esc_html__( 'Fading Entrances', 'wp-subscribe' ) => array(
|
258 |
+
'fadeIn' => esc_html__( 'fadeIn', 'wp-subscribe' ),
|
259 |
+
'fadeInDown' => esc_html__( 'fadeInDown', 'wp-subscribe' ),
|
260 |
+
'fadeInDownBig' => esc_html__( 'fadeInDownBig', 'wp-subscribe' ),
|
261 |
+
'fadeInLeft' => esc_html__( 'fadeInLeft', 'wp-subscribe' ),
|
262 |
+
'fadeInLeftBig' => esc_html__( 'fadeInLeftBig', 'wp-subscribe' ),
|
263 |
+
'fadeInRight' => esc_html__( 'fadeInRight', 'wp-subscribe' ),
|
264 |
+
'fadeInRightBig' => esc_html__( 'fadeInRightBig', 'wp-subscribe' ),
|
265 |
+
'fadeInUp' => esc_html__( 'fadeInUp', 'wp-subscribe' ),
|
266 |
+
'fadeInUpBig' => esc_html__( 'fadeInUpBig', 'wp-subscribe' ),
|
267 |
+
),
|
268 |
+
esc_html__( 'Flippers', 'wp-subscribe' ) => array(
|
269 |
+
'flipInX' => esc_html__( 'flipInX', 'wp-subscribe' ),
|
270 |
+
'flipInY' => esc_html__( 'flipInY', 'wp-subscribe' ),
|
271 |
+
),
|
272 |
+
esc_html__( 'Lightspeed', 'wp-subscribe' ) => array(
|
273 |
+
'lightSpeedIn' => esc_html__( 'lightSpeedIn', 'wp-subscribe' ),
|
274 |
+
),
|
275 |
+
esc_html__( 'Rotating Entrances', 'wp-subscribe' ) => array(
|
276 |
+
'rotateIn' => esc_html__( 'rotateIn', 'wp-subscribe' ),
|
277 |
+
'rotateInDownLeft' => esc_html__( 'rotateInDownLeft', 'wp-subscribe' ),
|
278 |
+
'rotateInDownRight' => esc_html__( 'rotateInDownRight', 'wp-subscribe' ),
|
279 |
+
'rotateInUpLeft' => esc_html__( 'rotateInUpLeft', 'wp-subscribe' ),
|
280 |
+
'rotateInUpRight' => esc_html__( 'rotateInUpRight', 'wp-subscribe' ),
|
281 |
+
),
|
282 |
+
esc_html__( 'Specials', 'wp-subscribe' ) => array(
|
283 |
+
'rollIn' => esc_html__( 'rollIn', 'wp-subscribe' ),
|
284 |
+
),
|
285 |
+
esc_html__( 'Zoom Entrances', 'wp-subscribe' ) => array(
|
286 |
+
'zoomIn' => esc_html__( 'zoomIn', 'wp-subscribe' ),
|
287 |
+
'zoomInDown' => esc_html__( 'zoomInDown', 'wp-subscribe' ),
|
288 |
+
'zoomInLeft' => esc_html__( 'zoomInLeft', 'wp-subscribe' ),
|
289 |
+
'zoomInRight' => esc_html__( 'zoomInRight', 'wp-subscribe' ),
|
290 |
+
'zoomInUp' => esc_html__( 'zoomInUp', 'wp-subscribe' ),
|
291 |
+
)
|
292 |
+
);
|
293 |
+
|
294 |
+
printf( '<select id="%1$s" name="%2$s">', $id, $name );
|
295 |
+
wps_print_select_options( $animations, $value );
|
296 |
+
echo '</select>';
|
297 |
+
}
|
298 |
+
|
299 |
+
function wps_print_select_options( $options, $value ) {
|
300 |
+
|
301 |
+
foreach( $options as $key => $text ) {
|
302 |
+
|
303 |
+
if( is_array( $text ) ) {
|
304 |
+
printf( '<optgroup label="%s">', $key );
|
305 |
+
wps_print_select_options( $text, $value );
|
306 |
+
echo '</optgroup>';
|
307 |
+
}
|
308 |
+
else {
|
309 |
+
printf(
|
310 |
+
'<option value="%1$s"%3$s>%2$s</option>',
|
311 |
+
$key, $text,
|
312 |
+
selected( $value, $key, false )
|
313 |
+
);
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
// ---------------- SERVICE HELPERS ---------------------------------
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Get subscription service info
|
322 |
+
*
|
323 |
+
* @param string $id
|
324 |
+
* @return string
|
325 |
+
*/
|
326 |
+
function wps_get_subscription_info( $id ) {
|
327 |
+
|
328 |
+
$services = wps_get_mailing_services();
|
329 |
+
|
330 |
+
return isset( $services[$id] ) ? $services[$id] : null;
|
331 |
+
}
|
332 |
+
|
333 |
+
/**
|
334 |
+
* Get subscription service class instance
|
335 |
+
*
|
336 |
+
* @param string $id
|
337 |
+
* @return object
|
338 |
+
*/
|
339 |
+
function wps_get_subscription_service( $id ) {
|
340 |
+
|
341 |
+
$info = wps_get_subscription_info( $id );
|
342 |
+
|
343 |
+
if( is_null( $info ) ) {
|
344 |
+
return;
|
345 |
+
}
|
346 |
+
|
347 |
+
return new $info['class']( $info );
|
348 |
+
}
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Get service list stored in db as trasient
|
352 |
+
*
|
353 |
+
* @param string $name
|
354 |
+
* @return array
|
355 |
+
*/
|
356 |
+
function wps_get_service_list( $name = '' ) {
|
357 |
+
|
358 |
+
if( !$name ) {
|
359 |
+
return;
|
360 |
+
}
|
361 |
+
|
362 |
+
$list = get_transient( 'mts_wps_'. $name . '_lists' );
|
363 |
+
|
364 |
+
return empty( $list ) ? array() : $list;
|
365 |
+
}
|
includes/wps-widget.php
ADDED
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The WP Subscribe widget class
|
5 |
+
*/
|
6 |
+
|
7 |
+
if( ! class_exists('wp_subscribe') ) :
|
8 |
+
|
9 |
+
class wp_subscribe extends WP_Widget {
|
10 |
+
|
11 |
+
/**
|
12 |
+
* The Constructor
|
13 |
+
*/
|
14 |
+
public function __construct() {
|
15 |
+
|
16 |
+
add_action( 'wp_enqueue_scripts', array( &$this, 'register_scripts' ) );
|
17 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
|
18 |
+
add_action( 'customize_controls_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
|
19 |
+
|
20 |
+
// Widget settings
|
21 |
+
$widget_ops = array(
|
22 |
+
'classname' => 'wp_subscribe',
|
23 |
+
'description' => esc_html__( 'Displays subscription form, supports FeedBurner, MailChimp & AWeber.', 'wp-subscribe' )
|
24 |
+
);
|
25 |
+
|
26 |
+
// Widget control settings
|
27 |
+
$control_ops = array(
|
28 |
+
'id_base' => 'wp_subscribe'
|
29 |
+
);
|
30 |
+
|
31 |
+
// Create the widget.
|
32 |
+
parent::__construct(
|
33 |
+
'wp_subscribe',
|
34 |
+
esc_html__( 'WP Subscribe Widget', 'wp-subscribe' ),
|
35 |
+
$widget_ops,
|
36 |
+
$control_ops
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get default values for widget
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
public function get_defaults() {
|
45 |
+
|
46 |
+
return apply_filters( 'wp_subscribe_form_defaults', array(
|
47 |
+
'service' => 'feedburner',
|
48 |
+
'include_name_field' => false,
|
49 |
+
|
50 |
+
'title' => esc_html__( 'Get more stuff', 'wp-subscribe' ),
|
51 |
+
'text' => esc_html__( 'Subscribe to our mailing list and get interesting stuff and updates to your email inbox.', 'wp-subscribe' ),
|
52 |
+
'email_placeholder' => esc_html__( 'Enter your email here', 'wp-subscribe' ),
|
53 |
+
'name_placeholder' => esc_html__( 'Enter your name here', 'wp-subscribe' ),
|
54 |
+
'button_text' => esc_html__( 'Sign Up Now', 'wp-subscribe' ),
|
55 |
+
'success_message' => esc_html__( 'Thank you for subscribing.', 'wp-subscribe' ),
|
56 |
+
'error_message' => esc_html__( 'Something went wrong.', 'wp-subscribe' ),
|
57 |
+
'footer_text' => esc_html__( 'we respect your privacy and take protecting it seriously', 'wp-subscribe' )
|
58 |
+
));
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Register scripts and json to be used in plugin
|
63 |
+
* @return void
|
64 |
+
*/
|
65 |
+
function register_scripts() {
|
66 |
+
|
67 |
+
wp_register_style( 'wp-subscribe', wps()->plugin_url() . '/assets/css/wp-subscribe-form.css' );
|
68 |
+
wp_register_script( 'wp-subscribe', wps()->plugin_url() . '/assets/js/wp-subscribe-form.js', array( 'jquery' ) );
|
69 |
+
|
70 |
+
wp_localize_script( 'wp-subscribe', 'wp_subscribe', array(
|
71 |
+
'ajaxurl' => admin_url( 'admin-ajax.php' )
|
72 |
+
) );
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Enqueue script for specific screens only
|
77 |
+
* @return void
|
78 |
+
*/
|
79 |
+
function enqueue_scripts() {
|
80 |
+
|
81 |
+
$screen = get_current_screen();
|
82 |
+
$current_filter = current_filter();
|
83 |
+
|
84 |
+
if ( 'widgets' === $screen->id || 'customize_controls_enqueue_scripts' === $current_filter ) {
|
85 |
+
|
86 |
+
wp_enqueue_style( 'wp-subscribe-options', wps()->plugin_url() . '/assets/css/wp-subscribe-options.css' );
|
87 |
+
wp_enqueue_script( 'wp-subscribe-admin', wps()->plugin_url() . '/assets/js/wp-subscribe-admin.js', array( 'jquery' ) );
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Display widget
|
93 |
+
* @param array $args
|
94 |
+
* @param array $instance
|
95 |
+
* @return void
|
96 |
+
*/
|
97 |
+
function widget( $args, $instance ) {
|
98 |
+
|
99 |
+
extract( $args );
|
100 |
+
$instance = wp_parse_args( (array) $instance, $this->get_defaults() );
|
101 |
+
|
102 |
+
$instance['before_widget'] = $before_widget;
|
103 |
+
$instance['after_widget'] = $after_widget;
|
104 |
+
$instance['widget_id'] = $this->id;
|
105 |
+
$instance['form_type'] = 'widget';
|
106 |
+
|
107 |
+
wps_the_form( $instance );
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Update widget
|
112 |
+
*
|
113 |
+
* @param array $new_instance
|
114 |
+
* @param array $old_instance
|
115 |
+
*
|
116 |
+
* @return array
|
117 |
+
*/
|
118 |
+
function update( $new_instance, $old_instance ) {
|
119 |
+
|
120 |
+
$instance = $old_instance;
|
121 |
+
$instance = array_merge( $instance, $new_instance );
|
122 |
+
|
123 |
+
// Feedburner ID -- make sure the user didn't insert full url
|
124 |
+
if( isset( $instance['feedburner_id'] ) && 0 === strpos( $instance['feedburner_id'], 'http' ) ) {
|
125 |
+
$instance['feedburner_id'] = substr( $instance['feedburner_id'], strrpos( $instance['feedburner_id'], '/' ) + 1 );
|
126 |
+
}
|
127 |
+
|
128 |
+
return $instance;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Display widget form
|
133 |
+
*
|
134 |
+
* @param array $instance
|
135 |
+
* @return void
|
136 |
+
*/
|
137 |
+
function form( $instance ) {
|
138 |
+
|
139 |
+
$instance = wp_parse_args( (array) $instance, $this->get_defaults() );
|
140 |
+
$services = wps_get_mailing_services('options');
|
141 |
+
?>
|
142 |
+
<div class="wp_subscribe_options_form">
|
143 |
+
|
144 |
+
<!-- Hidden title field to prevent WP picking up Title Color field as widget title -->
|
145 |
+
<input type="hidden" value="" id="<?php echo $this->get_field_id('title') ?>" name="<?php echo $this->get_field_name('title') ?>">
|
146 |
+
|
147 |
+
<?php $this->field_select(array(
|
148 |
+
'id' => 'service',
|
149 |
+
'name' => 'service',
|
150 |
+
'title' => esc_html( 'Service:', 'wp-subscribe' ),
|
151 |
+
'value' => $instance['service'],
|
152 |
+
'options' => $services,
|
153 |
+
'class' => 'services_dropdown'
|
154 |
+
)); ?>
|
155 |
+
|
156 |
+
<div class="wp_subscribe_account_details">
|
157 |
+
|
158 |
+
<?php foreach( $services as $service_id => $service_name ): ?>
|
159 |
+
<div class="wps-account-details wp_subscribe_account_details_<?php echo esc_attr( $service_id ) ?>" data-service="<?php echo esc_attr( $service_id ) ?>" style="display: none;">
|
160 |
+
<?php
|
161 |
+
$service = wps_get_subscription_service( $service_id );
|
162 |
+
$service->display_form( $instance, $this );
|
163 |
+
?>
|
164 |
+
</div><!-- /wp_subscribe_account_details_<?php echo esc_attr( $service_id ) ?> -->
|
165 |
+
<?php endforeach; ?>
|
166 |
+
|
167 |
+
</div><!-- .wp_subscribe_account_details -->
|
168 |
+
|
169 |
+
<p class="wp_subscribe_include_name">
|
170 |
+
|
171 |
+
<label for="<?php echo $this->get_field_id('include_name_field') ?>">
|
172 |
+
<input type="hidden" name="<?php echo $this->get_field_name('include_name_field'); ?>" value="0">
|
173 |
+
<input id="<?php echo $this->get_field_id('include_name_field'); ?>" type="checkbox" class="include-name-field" name="<?php echo $this->get_field_name('include_name_field'); ?>" value="1" <?php checked($instance['include_name_field']); ?>>
|
174 |
+
<?php echo wp_kses_post( __( 'Include <strong>Name</strong> field', 'wp-subscribe' ) ) ?>
|
175 |
+
</label>
|
176 |
+
|
177 |
+
</p>
|
178 |
+
|
179 |
+
<h4 class="wp_subscribe_labels_header">
|
180 |
+
<a class="wp-subscribe-toggle" href="#" rel="wp_subscribe_labels"><?php _e('Labels', 'wp-subscribe'); ?></a>
|
181 |
+
</h4>
|
182 |
+
|
183 |
+
<div class="wp_subscribe_labels" style="display: none;">
|
184 |
+
|
185 |
+
<?php
|
186 |
+
|
187 |
+
$this->field_textarea(array(
|
188 |
+
'id' => 'title',
|
189 |
+
'name' => 'title',
|
190 |
+
'title' => esc_html( 'Title', 'wp-subscribe' ),
|
191 |
+
'value' => $instance['title']
|
192 |
+
));
|
193 |
+
|
194 |
+
$this->field_text(array(
|
195 |
+
'id' => 'text',
|
196 |
+
'name' => 'text',
|
197 |
+
'title' => esc_html( 'Text', 'wp-subscribe' ),
|
198 |
+
'value' => $instance['text']
|
199 |
+
));
|
200 |
+
|
201 |
+
$this->field_text(array(
|
202 |
+
'id' => 'name_placeholder',
|
203 |
+
'name' => 'name_placeholder',
|
204 |
+
'title' => esc_html( 'Name Placeholder', 'wp-subscribe' ),
|
205 |
+
'value' => $instance['name_placeholder']
|
206 |
+
));
|
207 |
+
|
208 |
+
$this->field_text(array(
|
209 |
+
'id' => 'email_placeholder',
|
210 |
+
'name' => 'email_placeholder',
|
211 |
+
'title' => esc_html( 'Email Placeholder', 'wp-subscribe' ),
|
212 |
+
'value' => $instance['email_placeholder']
|
213 |
+
));
|
214 |
+
|
215 |
+
$this->field_text(array(
|
216 |
+
'id' => 'button_text',
|
217 |
+
'name' => 'button_text',
|
218 |
+
'title' => esc_html( 'Button Text', 'wp-subscribe' ),
|
219 |
+
'value' => $instance['button_text']
|
220 |
+
));
|
221 |
+
|
222 |
+
$this->field_text(array(
|
223 |
+
'id' => 'success_message',
|
224 |
+
'name' => 'success_message',
|
225 |
+
'title' => esc_html( 'Success Message', 'wp-subscribe' ),
|
226 |
+
'value' => $instance['success_message']
|
227 |
+
));
|
228 |
+
|
229 |
+
$this->field_text(array(
|
230 |
+
'id' => 'error_message',
|
231 |
+
'name' => 'error_message',
|
232 |
+
'title' => esc_html( 'Error Message', 'wp-subscribe' ),
|
233 |
+
'value' => $instance['error_message']
|
234 |
+
));
|
235 |
+
|
236 |
+
$this->field_text(array(
|
237 |
+
'id' => 'footer_text',
|
238 |
+
'name' => 'footer_text',
|
239 |
+
'title' => esc_html( 'Footer Text', 'wp-subscribe' ),
|
240 |
+
'value' => $instance['footer_text']
|
241 |
+
));
|
242 |
+
?>
|
243 |
+
|
244 |
+
</div><!-- .wp_subscribe_labels -->
|
245 |
+
|
246 |
+
</div><!-- .wp_subscribe_options_form -->
|
247 |
+
<?php
|
248 |
+
}
|
249 |
+
|
250 |
+
// -------------------------- FIELD HELPRES ----------------------
|
251 |
+
|
252 |
+
public function field_textarea( $args = array() ) {
|
253 |
+
|
254 |
+
extract( $args );
|
255 |
+
?>
|
256 |
+
<p class="wp-subscribe-label-field wp-subscribe-<?php echo $id; ?>-field">
|
257 |
+
<label for="<?php echo $this->get_field_id($id) ?>">
|
258 |
+
<?php echo $title ?>
|
259 |
+
</label>
|
260 |
+
|
261 |
+
<textarea class="widefat" id="<?php echo $this->get_field_id($id) ?>" name="<?php echo $this->get_field_name($id) ?>"><?php echo esc_textarea( $value ) ?></textarea>
|
262 |
+
</p>
|
263 |
+
|
264 |
+
<?php
|
265 |
+
}
|
266 |
+
|
267 |
+
public function field_text( $args = array() ) {
|
268 |
+
|
269 |
+
extract( $args );
|
270 |
+
?>
|
271 |
+
<div class="wp-subscribe-label-field wp-subscribe-<?php echo $id; ?>-field">
|
272 |
+
<label for="<?php echo $this->get_field_id( $id ) ?>">
|
273 |
+
<?php echo esc_html( $title ) ?>
|
274 |
+
</label>
|
275 |
+
|
276 |
+
<div class="wps-input-wrapper">
|
277 |
+
|
278 |
+
<?php wps_field_text(array(
|
279 |
+
'id' => $this->get_field_id( $id ),
|
280 |
+
'name' => $this->get_field_name( $id ),
|
281 |
+
'value' => $value,
|
282 |
+
'data_id' => $id
|
283 |
+
)) ?>
|
284 |
+
|
285 |
+
<?php if( isset( $link ) ) {
|
286 |
+
printf( ' <a target="_blank" href="%s" class="button">%s</a>', esc_url( $link ), esc_html__( 'Click here', 'wp-subscribe' ) );
|
287 |
+
} ?>
|
288 |
+
|
289 |
+
<?php if( isset( $desc ) ) {
|
290 |
+
printf( '<span class="wps-desc">%s</span>', wp_kses_post( $desc ) );
|
291 |
+
} ?>
|
292 |
+
|
293 |
+
</div>
|
294 |
+
|
295 |
+
</div>
|
296 |
+
<?php
|
297 |
+
}
|
298 |
+
|
299 |
+
public function field_hidden( $args = array() ) {
|
300 |
+
|
301 |
+
extract( $args );
|
302 |
+
|
303 |
+
wps_field_hidden(array(
|
304 |
+
'id' => $this->get_field_id( $id ),
|
305 |
+
'name' => $this->get_field_name( $id ),
|
306 |
+
'value' => $value,
|
307 |
+
'data_id' => $id
|
308 |
+
));
|
309 |
+
}
|
310 |
+
|
311 |
+
function field_checkbox( $args = array() ) {
|
312 |
+
|
313 |
+
extract( $args );
|
314 |
+
?>
|
315 |
+
<div class="wp-subscribe-<?php echo $id; ?>-field">
|
316 |
+
|
317 |
+
<label for="<?php echo $this->get_field_id( $id ) ?>">
|
318 |
+
|
319 |
+
<input type="hidden" name="<?php echo $this->get_field_name( $id ) ?>" value="0" data-id="<?php echo $this->get_field_id( $id ) ?>">
|
320 |
+
|
321 |
+
<input type="checkbox" id="<?php echo $this->get_field_id( $id ) ?>" name="<?php echo $this->get_field_name( $id ) ?>" value="1"<?php checked( $value ) ?> data-id="<?php echo $id ?>">
|
322 |
+
|
323 |
+
<?php echo esc_html($title) ?>
|
324 |
+
|
325 |
+
</label>
|
326 |
+
|
327 |
+
</div>
|
328 |
+
<?php
|
329 |
+
}
|
330 |
+
|
331 |
+
public function field_select( $args = array() ) {
|
332 |
+
|
333 |
+
$options = array();
|
334 |
+
extract( $args );
|
335 |
+
?>
|
336 |
+
|
337 |
+
<div class="wp-subscribe-label-field wp-subscribe-<?php echo $id ?>-field">
|
338 |
+
<label for="<?php echo $this->get_field_id( $id ) ?>">
|
339 |
+
<?php echo esc_html( $title ) ?>
|
340 |
+
</label>
|
341 |
+
|
342 |
+
<div class="wps-input-wrapper">
|
343 |
+
<?php wps_field_select(array(
|
344 |
+
'id' => $this->get_field_id( $id ),
|
345 |
+
'name' => $this->get_field_name( $id ),
|
346 |
+
'value' => $value,
|
347 |
+
'options' => $options,
|
348 |
+
'class' => 'widefat list-selectbox'
|
349 |
+
)) ?>
|
350 |
+
|
351 |
+
<?php if( isset( $is_list ) && $is_list ) {
|
352 |
+
printf( ' <button class="button wps-get-list">%s</button>', esc_html__( 'Get list', 'wp-subscribe' ) );
|
353 |
+
} ?>
|
354 |
+
|
355 |
+
<?php if( isset( $link ) ) {
|
356 |
+
printf( ' <a target="_blank" href="%s" class="button">%s</a>', esc_url( $link ), esc_html__( 'Click here', 'wp-subscribe' ) );
|
357 |
+
} ?>
|
358 |
+
|
359 |
+
<?php if( isset( $desc ) ) {
|
360 |
+
printf( '<span class="wps-desc">%s</span>', wp_kses_post( $desc ) );
|
361 |
+
} ?>
|
362 |
+
|
363 |
+
</div>
|
364 |
+
|
365 |
+
</div>
|
366 |
+
|
367 |
+
<?php
|
368 |
+
}
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Register widget
|
373 |
+
* @return void
|
374 |
+
*/
|
375 |
+
add_action( 'widgets_init', 'wps_register_widget' );
|
376 |
+
function wps_register_widget() {
|
377 |
+
register_widget( 'wp_subscribe' );
|
378 |
+
}
|
379 |
+
|
380 |
+
endif;
|
js/wp-subscribe-admin.js
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Plugin Name: WP Subscribe
|
3 |
-
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe/
|
4 |
-
Author: MyThemeShop
|
5 |
-
Author URI: http://mythemeshop.com
|
6 |
-
*/
|
7 |
-
( function( $ ){
|
8 |
-
|
9 |
-
// color picker
|
10 |
-
function initColorPicker( widget ) {
|
11 |
-
// and services dropdown
|
12 |
-
widget.find('.wp-subscribe-service-field select').change(function(event) {
|
13 |
-
var $this = $(this);
|
14 |
-
widget.find('.wp_subscribe_account_details_'+$this.val()).show().siblings('div').hide();
|
15 |
-
widget.find('.wp_subscribe_account_details').slideDown();
|
16 |
-
}).trigger('change');
|
17 |
-
}
|
18 |
-
|
19 |
-
function onFormUpdate( event, widget ) {
|
20 |
-
initColorPicker( widget );
|
21 |
-
}
|
22 |
-
|
23 |
-
$( document ).on( 'widget-added widget-updated', onFormUpdate );
|
24 |
-
|
25 |
-
$( document ).ready( function() {
|
26 |
-
$( '#widgets-right .widget:has(.wp-subscribe-service-field select)' ).each( function () {
|
27 |
-
initColorPicker( $( this ) );
|
28 |
-
});
|
29 |
-
} );
|
30 |
-
|
31 |
-
// slideToggle
|
32 |
-
$(document).on('click', function(e) {
|
33 |
-
var $this = jQuery(e.target);
|
34 |
-
var $widget = $this.closest('.wp_subscribe_options_form');
|
35 |
-
if ($widget.length) {
|
36 |
-
if ($this.is('.wp-subscribe-toggle')) {
|
37 |
-
e.preventDefault();
|
38 |
-
var $related = $widget.find('.'+$this.attr('rel'));
|
39 |
-
$related.slideToggle();
|
40 |
-
}
|
41 |
-
}
|
42 |
-
});
|
43 |
-
}( jQuery ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/default.po
DELETED
@@ -1,138 +0,0 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: WP Subscribe by MyThemeShop\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: 2015-09-26 04:49+0530\n"
|
6 |
-
"PO-Revision-Date: 2015-09-26 04:49+0530\n"
|
7 |
-
"Last-Translator: MyThemeShop <support-team@mythemeshop.com>\n"
|
8 |
-
"Language-Team: MyThemeShop <support-team@mythemeshop.com>\n"
|
9 |
-
"Language: en_US\n"
|
10 |
-
"MIME-Version: 1.0\n"
|
11 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
-
"Content-Transfer-Encoding: 8bit\n"
|
13 |
-
"X-Poedit-KeywordsList: __;_e\n"
|
14 |
-
"X-Poedit-Basepath: .\n"
|
15 |
-
"X-Generator: Poedit 1.6.2\n"
|
16 |
-
"X-Poedit-SearchPath-0: ..\n"
|
17 |
-
|
18 |
-
#: ../wp-subscribe.php:41
|
19 |
-
msgid "Displays Subscription Form, Supports - FeedBurner, MailChimp & AWeber."
|
20 |
-
msgstr ""
|
21 |
-
|
22 |
-
#: ../wp-subscribe.php:47
|
23 |
-
msgid "WP Subscribe Widget"
|
24 |
-
msgstr ""
|
25 |
-
|
26 |
-
#: ../wp-subscribe.php:176
|
27 |
-
msgid "Service:"
|
28 |
-
msgstr ""
|
29 |
-
|
30 |
-
#: ../wp-subscribe.php:182
|
31 |
-
msgid "Feedburner ID"
|
32 |
-
msgstr ""
|
33 |
-
|
34 |
-
#: ../wp-subscribe.php:186
|
35 |
-
msgid "Mailchimp API key"
|
36 |
-
msgstr ""
|
37 |
-
|
38 |
-
#: ../wp-subscribe.php:187
|
39 |
-
msgid "Find your API key"
|
40 |
-
msgstr ""
|
41 |
-
|
42 |
-
#: ../wp-subscribe.php:188
|
43 |
-
msgid "Mailchimp List ID"
|
44 |
-
msgstr ""
|
45 |
-
|
46 |
-
#: ../wp-subscribe.php:189 ../wp-subscribe.php:199
|
47 |
-
msgid "Find your list ID"
|
48 |
-
msgstr ""
|
49 |
-
|
50 |
-
#: ../wp-subscribe.php:193
|
51 |
-
msgid "Send double opt-in notification"
|
52 |
-
msgstr ""
|
53 |
-
|
54 |
-
#: ../wp-subscribe.php:198
|
55 |
-
msgid "AWeber List ID"
|
56 |
-
msgstr ""
|
57 |
-
|
58 |
-
#: ../wp-subscribe.php:203
|
59 |
-
msgid "Labels"
|
60 |
-
msgstr ""
|
61 |
-
|
62 |
-
#: ../wp-subscribe.php:206
|
63 |
-
msgid "Title"
|
64 |
-
msgstr ""
|
65 |
-
|
66 |
-
#: ../wp-subscribe.php:207
|
67 |
-
msgid "Text"
|
68 |
-
msgstr ""
|
69 |
-
|
70 |
-
#: ../wp-subscribe.php:208
|
71 |
-
msgid "Email Placeholder"
|
72 |
-
msgstr ""
|
73 |
-
|
74 |
-
#: ../wp-subscribe.php:209
|
75 |
-
msgid "Button Text"
|
76 |
-
msgstr ""
|
77 |
-
|
78 |
-
#: ../wp-subscribe.php:210
|
79 |
-
msgid "Success Message"
|
80 |
-
msgstr ""
|
81 |
-
|
82 |
-
#: ../wp-subscribe.php:211
|
83 |
-
msgid "Error Message"
|
84 |
-
msgstr ""
|
85 |
-
|
86 |
-
#: ../wp-subscribe.php:212
|
87 |
-
msgid "Error: Already Subscribed"
|
88 |
-
msgstr ""
|
89 |
-
|
90 |
-
#: ../wp-subscribe.php:213
|
91 |
-
msgid "Footer Text"
|
92 |
-
msgstr ""
|
93 |
-
|
94 |
-
#: ../wp-subscribe.php:289
|
95 |
-
msgid "Get more stuff like this<br/> <span>in your inbox</span>"
|
96 |
-
msgstr ""
|
97 |
-
|
98 |
-
#: ../wp-subscribe.php:290
|
99 |
-
msgid ""
|
100 |
-
"Subscribe to our mailing list and get interesting stuff and updates to your "
|
101 |
-
"email inbox."
|
102 |
-
msgstr ""
|
103 |
-
|
104 |
-
#: ../wp-subscribe.php:291
|
105 |
-
msgid "Enter your email here"
|
106 |
-
msgstr ""
|
107 |
-
|
108 |
-
#: ../wp-subscribe.php:292
|
109 |
-
msgid "Sign Up Now"
|
110 |
-
msgstr ""
|
111 |
-
|
112 |
-
#: ../wp-subscribe.php:293
|
113 |
-
msgid "Thank you for subscribing."
|
114 |
-
msgstr ""
|
115 |
-
|
116 |
-
#: ../wp-subscribe.php:294
|
117 |
-
msgid "Something went wrong."
|
118 |
-
msgstr ""
|
119 |
-
|
120 |
-
#: ../wp-subscribe.php:295
|
121 |
-
msgid "This email is already subscribed"
|
122 |
-
msgstr ""
|
123 |
-
|
124 |
-
#: ../wp-subscribe.php:296
|
125 |
-
msgid "we respect your privacy and take protecting it seriously"
|
126 |
-
msgstr ""
|
127 |
-
|
128 |
-
#: ../wp-subscribe.php:377
|
129 |
-
#, php-format
|
130 |
-
msgid ""
|
131 |
-
"<h4 style=\"font-size: 20px; color: #5FA52A; font-weight: normal; margin-"
|
132 |
-
"bottom: 10px; margin-top: 5px;\">Get WP Suscbribe Pro Today!</"
|
133 |
-
"h4><p><strong>Turn visitors into paying customers with pro version of WP "
|
134 |
-
"Subscribe</strong>. WP Subscribe Pro + WordPress is the ultimate lead "
|
135 |
-
"generation machine. Grow your email list like crazy and generate more "
|
136 |
-
"residual traffic and earnings.</p><a class=\"notice-dismiss\" href=\"%1$s\" "
|
137 |
-
"style=\"z-index: 1;\"></a>"
|
138 |
-
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/{default.mo → wp-subscribe.mo}
RENAMED
Binary file
|
languages/wp-subscribe.po
ADDED
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: WP Subscribe by MyThemeShop\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2017-04-12 16:50+0530\n"
|
6 |
+
"PO-Revision-Date: 2017-04-12 16:50+0530\n"
|
7 |
+
"Last-Translator: MyThemeShop <support-team@mythemeshop.com>\n"
|
8 |
+
"Language-Team: MyThemeShop <support-team@mythemeshop.com>\n"
|
9 |
+
"Language: en_US\n"
|
10 |
+
"MIME-Version: 1.0\n"
|
11 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
12 |
+
"Content-Transfer-Encoding: 8bit\n"
|
13 |
+
"X-Poedit-KeywordsList: __;_e;esc_html__\n"
|
14 |
+
"X-Poedit-Basepath: .\n"
|
15 |
+
"X-Generator: Poedit 1.6.2\n"
|
16 |
+
"X-Poedit-SearchPath-0: ..\n"
|
17 |
+
|
18 |
+
#: ../wp-subscribe.php:61 ../wp-subscribe.php:68
|
19 |
+
msgid "Cheatin’ huh?"
|
20 |
+
msgstr ""
|
21 |
+
|
22 |
+
#: ../wp-subscribe.php:163
|
23 |
+
msgid "No data found."
|
24 |
+
msgstr ""
|
25 |
+
|
26 |
+
#: ../wp-subscribe.php:171
|
27 |
+
msgid "No email address found."
|
28 |
+
msgstr ""
|
29 |
+
|
30 |
+
#: ../wp-subscribe.php:178
|
31 |
+
msgid "Not a valid email address."
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#: ../wp-subscribe.php:187
|
35 |
+
msgid "Unknown mailing service called."
|
36 |
+
msgstr ""
|
37 |
+
|
38 |
+
#: ../wp-subscribe.php:222
|
39 |
+
msgid "Not permitted."
|
40 |
+
msgstr ""
|
41 |
+
|
42 |
+
#: ../wp-subscribe.php:231
|
43 |
+
msgid "Service not defined."
|
44 |
+
msgstr ""
|
45 |
+
|
46 |
+
#: ../wp-subscribe.php:248
|
47 |
+
msgid "No lists found."
|
48 |
+
msgstr ""
|
49 |
+
|
50 |
+
#: ../includes/wps-functions-options.php:17
|
51 |
+
msgid "Aweber"
|
52 |
+
msgstr ""
|
53 |
+
|
54 |
+
#: ../includes/wps-functions-options.php:18
|
55 |
+
msgid "Adds subscribers to your Aweber account."
|
56 |
+
msgstr ""
|
57 |
+
|
58 |
+
#: ../includes/wps-functions-options.php:23
|
59 |
+
msgid "FeedBurner"
|
60 |
+
msgstr ""
|
61 |
+
|
62 |
+
#: ../includes/wps-functions-options.php:24
|
63 |
+
msgid "Adds subscribers to your FeedBurner account."
|
64 |
+
msgstr ""
|
65 |
+
|
66 |
+
#: ../includes/wps-functions-options.php:29
|
67 |
+
msgid "MailChimp"
|
68 |
+
msgstr ""
|
69 |
+
|
70 |
+
#: ../includes/wps-functions-options.php:30
|
71 |
+
msgid "Adds subscribers to your MailChimp account."
|
72 |
+
msgstr ""
|
73 |
+
|
74 |
+
#: ../includes/wps-helpers.php:239
|
75 |
+
msgid "No Animation"
|
76 |
+
msgstr ""
|
77 |
+
|
78 |
+
#: ../includes/wps-helpers.php:240
|
79 |
+
msgid "Attention Seekers"
|
80 |
+
msgstr ""
|
81 |
+
|
82 |
+
#: ../includes/wps-helpers.php:241
|
83 |
+
msgid "bounce"
|
84 |
+
msgstr ""
|
85 |
+
|
86 |
+
#: ../includes/wps-helpers.php:242
|
87 |
+
msgid "flash"
|
88 |
+
msgstr ""
|
89 |
+
|
90 |
+
#: ../includes/wps-helpers.php:243
|
91 |
+
msgid "pulse"
|
92 |
+
msgstr ""
|
93 |
+
|
94 |
+
#: ../includes/wps-helpers.php:244
|
95 |
+
msgid "rubberBand"
|
96 |
+
msgstr ""
|
97 |
+
|
98 |
+
#: ../includes/wps-helpers.php:245
|
99 |
+
msgid "shake"
|
100 |
+
msgstr ""
|
101 |
+
|
102 |
+
#: ../includes/wps-helpers.php:246
|
103 |
+
msgid "swing"
|
104 |
+
msgstr ""
|
105 |
+
|
106 |
+
#: ../includes/wps-helpers.php:247
|
107 |
+
msgid "tada"
|
108 |
+
msgstr ""
|
109 |
+
|
110 |
+
#: ../includes/wps-helpers.php:248
|
111 |
+
msgid "wobble"
|
112 |
+
msgstr ""
|
113 |
+
|
114 |
+
#: ../includes/wps-helpers.php:250
|
115 |
+
msgid "Bouncing Entrances"
|
116 |
+
msgstr ""
|
117 |
+
|
118 |
+
#: ../includes/wps-helpers.php:251
|
119 |
+
msgid "bounceIn"
|
120 |
+
msgstr ""
|
121 |
+
|
122 |
+
#: ../includes/wps-helpers.php:252
|
123 |
+
msgid "bounceInDown"
|
124 |
+
msgstr ""
|
125 |
+
|
126 |
+
#: ../includes/wps-helpers.php:253
|
127 |
+
msgid "bounceInLeft"
|
128 |
+
msgstr ""
|
129 |
+
|
130 |
+
#: ../includes/wps-helpers.php:254
|
131 |
+
msgid "bounceInRight"
|
132 |
+
msgstr ""
|
133 |
+
|
134 |
+
#: ../includes/wps-helpers.php:255
|
135 |
+
msgid "bounceInUp"
|
136 |
+
msgstr ""
|
137 |
+
|
138 |
+
#: ../includes/wps-helpers.php:257
|
139 |
+
msgid "Fading Entrances"
|
140 |
+
msgstr ""
|
141 |
+
|
142 |
+
#: ../includes/wps-helpers.php:258
|
143 |
+
msgid "fadeIn"
|
144 |
+
msgstr ""
|
145 |
+
|
146 |
+
#: ../includes/wps-helpers.php:259
|
147 |
+
msgid "fadeInDown"
|
148 |
+
msgstr ""
|
149 |
+
|
150 |
+
#: ../includes/wps-helpers.php:260
|
151 |
+
msgid "fadeInDownBig"
|
152 |
+
msgstr ""
|
153 |
+
|
154 |
+
#: ../includes/wps-helpers.php:261
|
155 |
+
msgid "fadeInLeft"
|
156 |
+
msgstr ""
|
157 |
+
|
158 |
+
#: ../includes/wps-helpers.php:262
|
159 |
+
msgid "fadeInLeftBig"
|
160 |
+
msgstr ""
|
161 |
+
|
162 |
+
#: ../includes/wps-helpers.php:263
|
163 |
+
msgid "fadeInRight"
|
164 |
+
msgstr ""
|
165 |
+
|
166 |
+
#: ../includes/wps-helpers.php:264
|
167 |
+
msgid "fadeInRightBig"
|
168 |
+
msgstr ""
|
169 |
+
|
170 |
+
#: ../includes/wps-helpers.php:265
|
171 |
+
msgid "fadeInUp"
|
172 |
+
msgstr ""
|
173 |
+
|
174 |
+
#: ../includes/wps-helpers.php:266
|
175 |
+
msgid "fadeInUpBig"
|
176 |
+
msgstr ""
|
177 |
+
|
178 |
+
#: ../includes/wps-helpers.php:268
|
179 |
+
msgid "Flippers"
|
180 |
+
msgstr ""
|
181 |
+
|
182 |
+
#: ../includes/wps-helpers.php:269
|
183 |
+
msgid "flipInX"
|
184 |
+
msgstr ""
|
185 |
+
|
186 |
+
#: ../includes/wps-helpers.php:270
|
187 |
+
msgid "flipInY"
|
188 |
+
msgstr ""
|
189 |
+
|
190 |
+
#: ../includes/wps-helpers.php:272
|
191 |
+
msgid "Lightspeed"
|
192 |
+
msgstr ""
|
193 |
+
|
194 |
+
#: ../includes/wps-helpers.php:273
|
195 |
+
msgid "lightSpeedIn"
|
196 |
+
msgstr ""
|
197 |
+
|
198 |
+
#: ../includes/wps-helpers.php:275
|
199 |
+
msgid "Rotating Entrances"
|
200 |
+
msgstr ""
|
201 |
+
|
202 |
+
#: ../includes/wps-helpers.php:276
|
203 |
+
msgid "rotateIn"
|
204 |
+
msgstr ""
|
205 |
+
|
206 |
+
#: ../includes/wps-helpers.php:277
|
207 |
+
msgid "rotateInDownLeft"
|
208 |
+
msgstr ""
|
209 |
+
|
210 |
+
#: ../includes/wps-helpers.php:278
|
211 |
+
msgid "rotateInDownRight"
|
212 |
+
msgstr ""
|
213 |
+
|
214 |
+
#: ../includes/wps-helpers.php:279
|
215 |
+
msgid "rotateInUpLeft"
|
216 |
+
msgstr ""
|
217 |
+
|
218 |
+
#: ../includes/wps-helpers.php:280
|
219 |
+
msgid "rotateInUpRight"
|
220 |
+
msgstr ""
|
221 |
+
|
222 |
+
#: ../includes/wps-helpers.php:282
|
223 |
+
msgid "Specials"
|
224 |
+
msgstr ""
|
225 |
+
|
226 |
+
#: ../includes/wps-helpers.php:283
|
227 |
+
msgid "rollIn"
|
228 |
+
msgstr ""
|
229 |
+
|
230 |
+
#: ../includes/wps-helpers.php:285
|
231 |
+
msgid "Zoom Entrances"
|
232 |
+
msgstr ""
|
233 |
+
|
234 |
+
#: ../includes/wps-helpers.php:286
|
235 |
+
msgid "zoomIn"
|
236 |
+
msgstr ""
|
237 |
+
|
238 |
+
#: ../includes/wps-helpers.php:287
|
239 |
+
msgid "zoomInDown"
|
240 |
+
msgstr ""
|
241 |
+
|
242 |
+
#: ../includes/wps-helpers.php:288
|
243 |
+
msgid "zoomInLeft"
|
244 |
+
msgstr ""
|
245 |
+
|
246 |
+
#: ../includes/wps-helpers.php:289
|
247 |
+
msgid "zoomInRight"
|
248 |
+
msgstr ""
|
249 |
+
|
250 |
+
#: ../includes/wps-helpers.php:290
|
251 |
+
msgid "zoomInUp"
|
252 |
+
msgstr ""
|
253 |
+
|
254 |
+
#: ../includes/wps-widget.php:23
|
255 |
+
msgid "Displays subscription form, supports FeedBurner, MailChimp & AWeber."
|
256 |
+
msgstr ""
|
257 |
+
|
258 |
+
#: ../includes/wps-widget.php:34
|
259 |
+
msgid "WP Subscribe Widget"
|
260 |
+
msgstr ""
|
261 |
+
|
262 |
+
#: ../includes/wps-widget.php:50
|
263 |
+
msgid "Get more stuff"
|
264 |
+
msgstr ""
|
265 |
+
|
266 |
+
#: ../includes/wps-widget.php:51
|
267 |
+
msgid ""
|
268 |
+
"Subscribe to our mailing list and get interesting stuff and updates to your "
|
269 |
+
"email inbox."
|
270 |
+
msgstr ""
|
271 |
+
|
272 |
+
#: ../includes/wps-widget.php:52
|
273 |
+
msgid "Enter your email here"
|
274 |
+
msgstr ""
|
275 |
+
|
276 |
+
#: ../includes/wps-widget.php:53
|
277 |
+
msgid "Enter your name here"
|
278 |
+
msgstr ""
|
279 |
+
|
280 |
+
#: ../includes/wps-widget.php:54
|
281 |
+
msgid "Sign Up Now"
|
282 |
+
msgstr ""
|
283 |
+
|
284 |
+
#: ../includes/wps-widget.php:55
|
285 |
+
msgid "Thank you for subscribing."
|
286 |
+
msgstr ""
|
287 |
+
|
288 |
+
#: ../includes/wps-widget.php:56
|
289 |
+
msgid "Something went wrong."
|
290 |
+
msgstr ""
|
291 |
+
|
292 |
+
#: ../includes/wps-widget.php:57
|
293 |
+
msgid "we respect your privacy and take protecting it seriously"
|
294 |
+
msgstr ""
|
295 |
+
|
296 |
+
#: ../includes/wps-widget.php:174
|
297 |
+
msgid "Include <strong>Name</strong> field"
|
298 |
+
msgstr ""
|
299 |
+
|
300 |
+
#: ../includes/wps-widget.php:180
|
301 |
+
msgid "Labels"
|
302 |
+
msgstr ""
|
303 |
+
|
304 |
+
#: ../includes/wps-widget.php:286 ../includes/wps-widget.php:356
|
305 |
+
msgid "Click here"
|
306 |
+
msgstr ""
|
307 |
+
|
308 |
+
#: ../includes/wps-widget.php:352
|
309 |
+
msgid "Get list"
|
310 |
+
msgstr ""
|
311 |
+
|
312 |
+
#: ../includes/subscription/class-wps-aweber.php:57
|
313 |
+
msgid "Unable to connect to Aweber. The Authorization Code is empty."
|
314 |
+
msgstr ""
|
315 |
+
|
316 |
+
#: ../includes/subscription/class-wps-aweber.php:67
|
317 |
+
msgid ""
|
318 |
+
"Unable to connect your Aweber Account. The Authorization Code is incorrect."
|
319 |
+
msgstr ""
|
320 |
+
|
321 |
+
#: ../includes/subscription/class-wps-aweber.php:155
|
322 |
+
#, php-format
|
323 |
+
msgid ""
|
324 |
+
"<span>1.</span> <a href=\"%s\" target=\"_blank\">Click here</a> <span>to "
|
325 |
+
"open the authorization page and log in.</span>"
|
326 |
+
msgstr ""
|
327 |
+
|
328 |
+
#: ../includes/subscription/class-wps-aweber.php:156
|
329 |
+
msgid ""
|
330 |
+
"<span>2.</span> Copy and paste the authorization code in the field below."
|
331 |
+
msgstr ""
|
332 |
+
|
333 |
+
#: ../includes/subscription/class-wps-aweber.php:165
|
334 |
+
msgid "Your Aweber Account is connected."
|
335 |
+
msgstr ""
|
336 |
+
|
337 |
+
#: ../includes/subscription/class-wps-aweber.php:166
|
338 |
+
msgid ""
|
339 |
+
"<a href=\"#\" class=\"aweber_disconnect\">Click here</a> <span>to disconnect."
|
340 |
+
"</span>"
|
341 |
+
msgstr ""
|
342 |
+
|
343 |
+
#: ../includes/subscription/class-wps-aweber.php:202
|
344 |
+
msgid "AWeber List"
|
345 |
+
msgstr ""
|
346 |
+
|
347 |
+
#: ../includes/subscription/class-wps-aweber.php:203
|
348 |
+
#: ../includes/subscription/class-wps-mailchimp.php:70
|
349 |
+
msgid "Select List"
|
350 |
+
msgstr ""
|
351 |
+
|
352 |
+
#: ../includes/subscription/class-wps-feedburner.php:39
|
353 |
+
msgid "Feedburner ID"
|
354 |
+
msgstr ""
|
355 |
+
|
356 |
+
#: ../includes/subscription/class-wps-mailchimp.php:60
|
357 |
+
msgid "MailChimp API URL"
|
358 |
+
msgstr ""
|
359 |
+
|
360 |
+
#: ../includes/subscription/class-wps-mailchimp.php:61
|
361 |
+
msgid "The API key of your MailChimp account."
|
362 |
+
msgstr ""
|
363 |
+
|
364 |
+
#: ../includes/subscription/class-wps-mailchimp.php:69
|
365 |
+
msgid "MailChimp List"
|
366 |
+
msgstr ""
|
367 |
+
|
368 |
+
#: ../includes/subscription/class-wps-mailchimp.php:78
|
369 |
+
msgid "Send double opt-in notification"
|
370 |
+
msgstr ""
|
package.json
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "WP-Subscribe-Pro",
|
3 |
+
"version": "0.0.1",
|
4 |
+
"description": "The subscriber plugin",
|
5 |
+
"main": "index.js",
|
6 |
+
"scripts": {
|
7 |
+
"test": "echo \"Error: no test specified\" && exit 1"
|
8 |
+
},
|
9 |
+
"keywords": [
|
10 |
+
"mythemeshop"
|
11 |
+
],
|
12 |
+
"author": "MyThemeShop",
|
13 |
+
"license": "ISC",
|
14 |
+
"devDependencies": {
|
15 |
+
"grunt": "^1.0.1",
|
16 |
+
"grunt-checktextdomain": "^1.0.1",
|
17 |
+
"grunt-wp-i18n": "^0.5.4"
|
18 |
+
}
|
19 |
+
}
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== WP Subscribe ===
|
2 |
Contributors: mythemeshop
|
3 |
Creator's website link: http://mythemeshop.com/plugins/wp-subscribe/
|
4 |
-
Tags: subscribe, subscription, subscription box, newsletter, subscribe widget, mailchimp, aweber, feedburner,
|
5 |
-
Requires at least:
|
6 |
Tested up to: 4.7.3
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -57,7 +57,7 @@ GitHub link: <a href="https://github.com/MyThemeShop/WP-Subscribe/">https://gith
|
|
57 |
|
58 |
= Feedback =
|
59 |
If you like this plugin, then please leave us a good rating and review.<br/>
|
60 |
-
Consider following us on <a rel="author" href="https://plus.google.com/+Mythemeshop/">Google+</a>, <a href="https://twitter.com/MyThemeShopTeam">Twitter</a>, and <a href="https://www.facebook.com/MyThemeShop">Facebook</a>
|
61 |
|
62 |
== Installation ==
|
63 |
|
@@ -82,6 +82,13 @@ Please disable all plugins and check if plugin is working properly. Then you can
|
|
82 |
|
83 |
== Changelog ==
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
= 1.1.4 =
|
86 |
* Changed AWeber form URL to HTTPS
|
87 |
|
1 |
=== WP Subscribe ===
|
2 |
Contributors: mythemeshop
|
3 |
Creator's website link: http://mythemeshop.com/plugins/wp-subscribe/
|
4 |
+
Tags: subscribe, subscription, subscription box, newsletter, subscribe widget, mailchimp, aweber, feedburner,
|
5 |
+
Requires at least: 4.0
|
6 |
Tested up to: 4.7.3
|
7 |
+
Stable tag: 1.2.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
57 |
|
58 |
= Feedback =
|
59 |
If you like this plugin, then please leave us a good rating and review.<br/>
|
60 |
+
Consider following us on <a rel="author" href="https://plus.google.com/+Mythemeshop/">Google+</a>, <a href="https://twitter.com/MyThemeShopTeam">Twitter</a>, and <a href="https://www.facebook.com/MyThemeShop">Facebook</a>
|
61 |
|
62 |
== Installation ==
|
63 |
|
82 |
|
83 |
== Changelog ==
|
84 |
|
85 |
+
= 1.2.0 =
|
86 |
+
* Whole plugin is re-written in OOP
|
87 |
+
* Huge performance Improvements
|
88 |
+
* Moved JS and CSS folders inside assets folder
|
89 |
+
* Enhanced: Functions are more organized in wps-helpers and wps-functions-options file.
|
90 |
+
* Fixed: Missing and in-correct textdomain
|
91 |
+
|
92 |
= 1.1.4 =
|
93 |
* Changed AWeber form URL to HTTPS
|
94 |
|
wp-subscribe.php
CHANGED
@@ -1,453 +1,303 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
Plugin Name: WP Subscribe
|
4 |
-
Plugin URI: http://mythemeshop.com/plugins/wp-subscribe/
|
5 |
-
Description: WP Subscribe is a simple but powerful subscription plugin which supports MailChimp, Aweber and Feedburner.
|
6 |
-
|
7 |
-
|
8 |
-
Author URI: http://mythemeshop.com/
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
//
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
'aweber_list_id' => '',
|
305 |
-
'include_name_field' => false,
|
306 |
-
'title' => __('Get more stuff like this<br/> <span>in your inbox</span>', 'wp-subscribe'),
|
307 |
-
'text' => __('Subscribe to our mailing list and get interesting stuff and updates to your email inbox.', 'wp-subscribe'),
|
308 |
-
'email_placeholder' => __('Enter your email here', 'wp-subscribe'),
|
309 |
-
'name_placeholder' => __('Enter your name here', 'wp-subscribe'),
|
310 |
-
'button_text' => __('Sign Up Now', 'wp-subscribe'),
|
311 |
-
'success_message' => __('Thank you for subscribing.', 'wp-subscribe'),
|
312 |
-
'error_message' => __('Something went wrong.', 'wp-subscribe'),
|
313 |
-
'already_subscribed_message' => __('This email is already subscribed', 'wp-subscribe'),
|
314 |
-
'footer_text' => __('we respect your privacy and take protecting it seriously', 'wp-subscribe'),
|
315 |
-
);
|
316 |
-
}
|
317 |
-
|
318 |
-
// For MailChimp subscribe
|
319 |
-
function get_widget_settings($widget_id) {
|
320 |
-
global $wp_registered_widgets;
|
321 |
-
$ret = array();
|
322 |
-
|
323 |
-
if (isset($wp_registered_widgets)) {
|
324 |
-
$widget = $wp_registered_widgets[$widget_id];
|
325 |
-
$option_data = get_option($widget['callback'][0]->option_name);
|
326 |
-
|
327 |
-
if (isset($option_data[$widget['params'][0]['number']])) {
|
328 |
-
$ret = $option_data[$widget['params'][0]['number']];
|
329 |
-
}
|
330 |
-
}
|
331 |
-
|
332 |
-
return $ret;
|
333 |
-
}
|
334 |
-
|
335 |
-
function mailchimp_subscribe() {
|
336 |
-
$ret = array(
|
337 |
-
'success' => false,
|
338 |
-
'message' => '',
|
339 |
-
);
|
340 |
-
|
341 |
-
$email = isset($_POST['mailchimp_email']) ? trim($_POST['mailchimp_email']) : '';
|
342 |
-
$name = isset($_POST['mailchimp_name']) ? trim($_POST['mailchimp_name']) : '';
|
343 |
-
|
344 |
-
$mc_api_key = null;
|
345 |
-
$mc_list_id = null;
|
346 |
-
$error_message = '';
|
347 |
-
$widget_id = isset($_POST['widget_id']) ? trim($_POST['widget_id']) : '';
|
348 |
-
|
349 |
-
if (($widget_settings = $this->get_widget_settings($widget_id))) {
|
350 |
-
$mc_api_key = isset($widget_settings['mailchimp_api_key']) ? $widget_settings['mailchimp_api_key'] : null;
|
351 |
-
$mc_list_id = isset($widget_settings['mailchimp_list_id']) ? $widget_settings['mailchimp_list_id'] : null;
|
352 |
-
$error_message = isset($widget_settings['error_message']) ? $widget_settings['error_message'] : '';
|
353 |
-
$double_optin = !empty($widget_settings['mailchimp_double_optin']) ? true : false;
|
354 |
-
}
|
355 |
-
|
356 |
-
if ($email &&
|
357 |
-
$widget_settings &&
|
358 |
-
$mc_api_key != null &&
|
359 |
-
$mc_list_id != null ) {
|
360 |
-
|
361 |
-
try {
|
362 |
-
$list = new Mailchimp_Lists(new Mailchimp($mc_api_key));
|
363 |
-
$merge_vars = null;
|
364 |
-
if ($name) {
|
365 |
-
$fname = $name;
|
366 |
-
$lname = '';
|
367 |
-
if ($space_pos = strpos($name, ' ')) {
|
368 |
-
$fname = substr($name, 0, $space_pos);
|
369 |
-
$lname = substr($name, $space_pos);
|
370 |
-
}
|
371 |
-
$merge_vars = array('FNAME' => $fname, 'LNAME' => $lname);
|
372 |
-
}
|
373 |
-
$resp = $list->subscribe($mc_list_id, array('email' => $email), $merge_vars, 'html', (bool) $double_optin, true);
|
374 |
-
|
375 |
-
if ($resp) {
|
376 |
-
$ret['success'] = true;
|
377 |
-
$ret['message'] = $widget_settings['success_message'];
|
378 |
-
} else {
|
379 |
-
$ret['message'] = $widget_settings['error_message'];
|
380 |
-
}
|
381 |
-
} catch (Exception $ex) {
|
382 |
-
$ret['message'] = is_user_logged_in() ? $ex->getMessage() : $widget_settings['error_message'];
|
383 |
-
}
|
384 |
-
} else {
|
385 |
-
$ret['message'] = $error_message;
|
386 |
-
}
|
387 |
-
return $ret;
|
388 |
-
}
|
389 |
-
|
390 |
-
}
|
391 |
-
|
392 |
-
/* Display a notice*/
|
393 |
-
|
394 |
-
add_action('admin_notices', 'subscribe_admin_notice');
|
395 |
-
|
396 |
-
function subscribe_admin_notice() {
|
397 |
-
global $current_user ;
|
398 |
-
$user_id = $current_user->ID;
|
399 |
-
/* Check that the user hasn't already clicked to ignore the message */
|
400 |
-
if ( ! get_user_meta($user_id, 'subscribe_ignore_notice') ) {
|
401 |
-
echo '<style type="text/css">.wp-subscribe-notice:after { content:""; position: absolute; right: 0; bottom: 0; background: url('.plugins_url('/mail-icon.svg', __FILE__).') right bottom no-repeat; width: 120px; height: 120px; opacity: 0.1;} .wp-core-ui .wps_notice_button { line-height: 44px; height: 44px; padding: 0 30px; font-size: 17px; margin: 0 auto; top: 30px; float: right; right: 50px; position: relative; z-index: 1; }</style>';
|
402 |
-
echo '<div class="updated notice-info wp-subscribe-notice" id="wpsubscribe-notice" style="position:relative;overflow: hidden; padding: 17px 44px 17px 20px;">
|
403 |
-
<div class="wps-left-block" style="float: left; width: 60%;">';
|
404 |
-
printf(__('<h4 style="font-size: 20px; color: #5FA52A; font-weight: normal; margin-bottom: 10px; margin-top: 5px;">Get WP Subscribe Pro Today!</h4><p><strong>Turn visitors into paying customers with pro version of WP Subscribe</strong>. WP Subscribe Pro + WordPress is the ultimate lead generation machine. Grow your email list like crazy and generate more residual traffic and earnings.</p><a class="notice-dismiss" href="%1$s" style="z-index: 1;"></a>'), '?subscribe_admin_notice_ignore=0');
|
405 |
-
echo '</div>
|
406 |
-
<div class="wps-right-block" style="width: 40%; float: right;">
|
407 |
-
<a href="https://mythemeshop.com/plugins/wp-subscribe-pro/?utm_source=WP+Subscribe&utm_medium=Notification+Link&utm_content=WP+Subscribe+Pro+LP&utm_campaign=WordPressOrg" target="_blank" class="button button-primary wps_notice_button">Get WP Subscribe Pro Now</a>
|
408 |
-
</div>
|
409 |
-
</div>';
|
410 |
-
}
|
411 |
-
}
|
412 |
-
|
413 |
-
add_action('admin_init', 'subscribe_admin_notice_ignore');
|
414 |
-
|
415 |
-
function subscribe_admin_notice_ignore() {
|
416 |
-
global $current_user;
|
417 |
-
$user_id = $current_user->ID;
|
418 |
-
/* If user clicks to ignore the notice, add that to their user meta */
|
419 |
-
if ( isset($_GET['subscribe_admin_notice_ignore']) && '0' == $_GET['subscribe_admin_notice_ignore'] ) {
|
420 |
-
add_user_meta($user_id, 'subscribe_ignore_notice', 'true', true);
|
421 |
-
}
|
422 |
-
}
|
423 |
-
|
424 |
-
// Add MyThemeShop tab to "Add Plugins" Page
|
425 |
-
add_action( 'after_setup_theme', 'subscribe_install_plugins_mts_tab', 20 );
|
426 |
-
function subscribe_install_plugins_mts_tab() {
|
427 |
-
if ( !has_filter( 'install_plugins_tabs', 'mts_install_plugins_tab' ) ) {
|
428 |
-
// Add MyThemeShop tab to "Add Plugins" Page
|
429 |
-
add_filter( 'install_plugins_tabs', 'subscribe_mts_install_plugins_tab' );
|
430 |
-
// Set args for MyThemeShop tab in "Add Plugins" Page
|
431 |
-
add_filter( 'install_plugins_table_api_args_mts_addons', 'subscribe_mts_addons_args' );
|
432 |
-
// List plugins in "Add Plugins" Page under "MyThemeShop" tab
|
433 |
-
add_action( 'install_plugins_mts_addons', 'display_plugins_table' );
|
434 |
-
}
|
435 |
-
}
|
436 |
-
function subscribe_mts_install_plugins_tab( $tabs ) {
|
437 |
-
$tabs['mts_addons'] = 'MyThemeShop';
|
438 |
-
return $tabs;
|
439 |
-
}
|
440 |
-
function subscribe_mts_addons_args( $args ) {
|
441 |
-
$args = array(
|
442 |
-
'page' => 1,
|
443 |
-
'per_page' => 30,
|
444 |
-
'fields' => array(
|
445 |
-
'last_updated' => true,
|
446 |
-
'icons' => true,
|
447 |
-
'active_installs' => true
|
448 |
-
),
|
449 |
-
'author' => 'MyThemeShop'
|
450 |
-
);
|
451 |
-
|
452 |
-
return $args;
|
453 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Name: WP Subscribe
|
4 |
+
* Plugin URI: http://mythemeshop.com/plugins/wp-subscribe/
|
5 |
+
* Description: WP Subscribe is a simple but powerful subscription plugin which supports MailChimp, Aweber and Feedburner.
|
6 |
+
* Version: 1.2.0
|
7 |
+
* Author: MyThemeShop
|
8 |
+
* Author URI: http://mythemeshop.com/
|
9 |
+
* Text Domain: wp-subscribe
|
10 |
+
*/
|
11 |
+
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
+
exit;
|
14 |
+
} // Exit if accessed directly.
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Include Base Class
|
18 |
+
* From which all other classes are derived
|
19 |
+
*/
|
20 |
+
include_once 'includes/class-wps-base.php';
|
21 |
+
|
22 |
+
if( ! class_exists('MTS_WP_Subscribe') ) :
|
23 |
+
|
24 |
+
final class MTS_WP_Subscribe extends WPS_Base {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Plugin Version
|
28 |
+
* @var string
|
29 |
+
*/
|
30 |
+
private $version = '1.2.0';
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Hold an instance of MTS_WP_Subscribe class
|
34 |
+
* @var MTS_WP_Subscribe
|
35 |
+
*/
|
36 |
+
protected static $instance = null;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Hold WPS_Settings instance.
|
40 |
+
* @var WPS_Settings
|
41 |
+
*/
|
42 |
+
public $settings;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Hold an instance of MTS_ContentLocker class.
|
46 |
+
* @return MTS_WP_Subscribe
|
47 |
+
*/
|
48 |
+
public static function get_instance() {
|
49 |
+
|
50 |
+
if( is_null( self::$instance ) ) {
|
51 |
+
self::$instance = new MTS_WP_Subscribe;
|
52 |
+
}
|
53 |
+
|
54 |
+
return self::$instance;
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* You cannot clone this class
|
59 |
+
*/
|
60 |
+
public function __clone() {
|
61 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'wp-subscribe' ), $this->version );
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* You cannot unserialize instances of this class
|
66 |
+
*/
|
67 |
+
public function __wakeup() {
|
68 |
+
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'wp-subscribe' ), $this->version );
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* The Constructor
|
73 |
+
*/
|
74 |
+
private function __construct() {
|
75 |
+
|
76 |
+
// Include files
|
77 |
+
include_once 'includes/wps-helpers.php';
|
78 |
+
include_once 'includes/wps-functions-options.php';
|
79 |
+
include_once 'includes/wps-widget.php';
|
80 |
+
|
81 |
+
$this->autoloader();
|
82 |
+
$this->hooks();
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Register file autoloading mechanism
|
87 |
+
* @return void
|
88 |
+
*/
|
89 |
+
private function autoloader() {
|
90 |
+
|
91 |
+
if ( function_exists( '__autoload' ) ) {
|
92 |
+
spl_autoload_register( '__autoload' );
|
93 |
+
}
|
94 |
+
|
95 |
+
spl_autoload_register( array( $this, 'autoload' ) );
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Add hooks
|
100 |
+
* @return void
|
101 |
+
*/
|
102 |
+
private function hooks() {
|
103 |
+
|
104 |
+
$this->add_action( 'init', 'load_textdomain' );
|
105 |
+
|
106 |
+
// AJAX
|
107 |
+
$this->add_action( 'wp_ajax_wps_get_service_list', 'get_service_list' );
|
108 |
+
$this->add_action( 'wp_ajax_validate_subscribe', 'validate_subscribe' );
|
109 |
+
$this->add_action( 'wp_ajax_nopriv_validate_subscribe', 'validate_subscribe' );
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Autoload strategy
|
114 |
+
*
|
115 |
+
* @param string $class
|
116 |
+
* @return void
|
117 |
+
*/
|
118 |
+
public function autoload( $class ) {
|
119 |
+
|
120 |
+
if( ! wps_str_start_with( 'WPS_', $class ) ) {
|
121 |
+
return;
|
122 |
+
}
|
123 |
+
|
124 |
+
$path = '';
|
125 |
+
$class = strtolower( $class );
|
126 |
+
$file = 'class-' . str_replace( '_', '-', strtolower( $class ) ) . '.php';
|
127 |
+
$path = $this->plugin_dir() . '/includes/';
|
128 |
+
|
129 |
+
if( wps_str_start_with('wps_subscription', $class ) ) {
|
130 |
+
$path .= 'subscription/';
|
131 |
+
$file = str_replace( 'subscription-', '', $file );
|
132 |
+
}
|
133 |
+
|
134 |
+
// Load File
|
135 |
+
$load = $path . $file;
|
136 |
+
if ( $load && is_readable( $load ) ) {
|
137 |
+
include_once $load;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Load localization files
|
143 |
+
* @return void
|
144 |
+
*/
|
145 |
+
public function load_textdomain() {
|
146 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), 'wp-subscribe' );
|
147 |
+
|
148 |
+
load_textdomain( 'wp-subscribe', WP_LANG_DIR . '/wp-subscribe/wp-subscribe-' . $locale . '.mo' );
|
149 |
+
load_plugin_textdomain( 'wp-subscribe', false, $this->plugin_dir() . '/languages' );
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Validate subscription
|
154 |
+
* @return void
|
155 |
+
*/
|
156 |
+
public function validate_subscribe() {
|
157 |
+
|
158 |
+
// check for data
|
159 |
+
$data = isset( $_POST['wps_data'] ) ? $_POST['wps_data'] : array();
|
160 |
+
if( empty( $data ) ) {
|
161 |
+
wp_send_json( array(
|
162 |
+
'success' => false,
|
163 |
+
'error' => esc_html__( 'No data found.', 'wp-subscribe' )
|
164 |
+
) );
|
165 |
+
}
|
166 |
+
|
167 |
+
// check for valid data
|
168 |
+
if( empty( $data['email'] ) ) {
|
169 |
+
wp_send_json( array(
|
170 |
+
'success' => false,
|
171 |
+
'error' => esc_html__( 'No email address found.', 'wp-subscribe' )
|
172 |
+
) );
|
173 |
+
}
|
174 |
+
|
175 |
+
if( !filter_var( $data['email'], FILTER_VALIDATE_EMAIL ) ) {
|
176 |
+
wp_send_json( array(
|
177 |
+
'success' => false,
|
178 |
+
'error' => esc_html__( 'Not a valid email address.', 'wp-subscribe' )
|
179 |
+
) );
|
180 |
+
}
|
181 |
+
|
182 |
+
// check for valid service
|
183 |
+
$services = wps_get_mailing_services('options');
|
184 |
+
if( !array_key_exists( $data['service'], $services ) ) {
|
185 |
+
wp_send_json( array(
|
186 |
+
'success' => false,
|
187 |
+
'error' => esc_html__( 'Unknown mailing service called.', 'wp-subscribe' )
|
188 |
+
) );
|
189 |
+
}
|
190 |
+
|
191 |
+
// Call service subscription method
|
192 |
+
try {
|
193 |
+
$service = wps_get_subscription_service( $data['service'] );
|
194 |
+
$status = $service->subscribe( $data, $service->get_options( $data ) );
|
195 |
+
|
196 |
+
wp_send_json(array(
|
197 |
+
'success' => true,
|
198 |
+
'status' => $status['status']
|
199 |
+
));
|
200 |
+
}
|
201 |
+
catch( Exception $e ) {
|
202 |
+
wp_send_json(array(
|
203 |
+
'success' => false,
|
204 |
+
'error' => $e->getMessage()
|
205 |
+
));
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* Get mailing lists according to service
|
211 |
+
*
|
212 |
+
* @return array
|
213 |
+
*/
|
214 |
+
public function get_service_list() {
|
215 |
+
|
216 |
+
$name = $_REQUEST['service'];
|
217 |
+
$args = $_REQUEST['args'];
|
218 |
+
|
219 |
+
if( empty( $name ) || empty( $args ) ) {
|
220 |
+
wp_send_json(array(
|
221 |
+
'success' => false,
|
222 |
+
'error' => esc_html__( 'Not permitted.', 'wp-subscribe' )
|
223 |
+
));
|
224 |
+
}
|
225 |
+
|
226 |
+
$service = wps_get_subscription_service( $name );
|
227 |
+
|
228 |
+
if( is_null( $service ) ) {
|
229 |
+
wp_send_json(array(
|
230 |
+
'success' => false,
|
231 |
+
'error' => esc_html__( 'Service not defined.', 'wp-subscribe' )
|
232 |
+
));
|
233 |
+
}
|
234 |
+
|
235 |
+
try {
|
236 |
+
$lists = call_user_func_array( array( $service, 'get_lists' ), $args );
|
237 |
+
}
|
238 |
+
catch( Exception $e ) {
|
239 |
+
wp_send_json(array(
|
240 |
+
'success' => false,
|
241 |
+
'error' => $e->getMessage()
|
242 |
+
));
|
243 |
+
}
|
244 |
+
|
245 |
+
if( empty( $lists ) ) {
|
246 |
+
wp_send_json(array(
|
247 |
+
'success' => false,
|
248 |
+
'error' => esc_html__( 'No lists found.', 'wp-subscribe' )
|
249 |
+
));
|
250 |
+
}
|
251 |
+
|
252 |
+
// Save for letter use
|
253 |
+
set_transient( 'mts_wps_'. $name . '_lists', $lists );
|
254 |
+
|
255 |
+
wp_send_json(array(
|
256 |
+
'success' => true,
|
257 |
+
'lists' => $lists
|
258 |
+
));
|
259 |
+
}
|
260 |
+
|
261 |
+
// Helper ------------------------------------------------------
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Get plugin directory
|
265 |
+
*
|
266 |
+
* @return string
|
267 |
+
*/
|
268 |
+
public function plugin_dir() {
|
269 |
+
return untrailingslashit( plugin_dir_path( __FILE__ ) );
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Get plugin uri
|
274 |
+
*
|
275 |
+
* @return string
|
276 |
+
*/
|
277 |
+
public function plugin_url() {
|
278 |
+
return untrailingslashit( plugin_dir_url( __FILE__ ) );
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Get plugin version
|
283 |
+
*
|
284 |
+
* @return string
|
285 |
+
*/
|
286 |
+
public function get_version() {
|
287 |
+
return $this->version;
|
288 |
+
}
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Main instance of MTS_WP_Subscribe
|
293 |
+
*
|
294 |
+
* Return the main instance of MTS_WP_Subscribe to prevent the need to use globals.
|
295 |
+
*
|
296 |
+
* @return MTS_WP_Subscribe
|
297 |
+
*/
|
298 |
+
function wps() {
|
299 |
+
return MTS_WP_Subscribe::get_instance();
|
300 |
+
}
|
301 |
+
wps(); // Init it
|
302 |
+
|
303 |
+
endif;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|