Version Description
Download this release
Release Info
Developer | activecampaign |
Plugin | ActiveCampaign |
Version | 2012-04-10 |
Comparing to | |
See all releases |
Version 2012-04-10
- activecampaign_subscribe.php +295 -0
- readme.txt +73 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
activecampaign_subscribe.php
ADDED
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: ActiveCampaign Email Marketing
|
4 |
+
Plugin URI: http://www.activecampaign.com/email-marketing/extend-wordpress.php
|
5 |
+
Description: The ActiveCampaign email marketing plugin connects Wordpress with your email marketing software and allows you to choose a subscription form to embed (as a widget) anywhere on your site. After enabling go to Appearance > Widgets to activate this plugin.
|
6 |
+
Author: ActiveCampaign
|
7 |
+
Version: 2.1
|
8 |
+
Author URI: http://www.activecampaign.com/
|
9 |
+
*/
|
10 |
+
|
11 |
+
# Changelog
|
12 |
+
## version 1: - initial release
|
13 |
+
## version 1.1: Verified this works with latest versions of WordPress and ActiveCampaign; Updated installation instructions
|
14 |
+
## version 2.0: Re-configured to work with ActiveCampaign version 5.4. Also improved some areas.
|
15 |
+
## version 2.1: Changed internal API requests to use only API URL and Key instead of Username and Password. Also provided option to remove style blocks, and converting <input type="button" into <input type="submit"
|
16 |
+
|
17 |
+
function widget_ac_subscribe_public($args = false) {
|
18 |
+
|
19 |
+
$options_site = ac_subscribe_options_site_get();
|
20 |
+
$options_form = ac_subscribe_options_form_get();
|
21 |
+
|
22 |
+
if ($args) extract($args);
|
23 |
+
|
24 |
+
echo $before_widget;
|
25 |
+
echo $before_title;
|
26 |
+
|
27 |
+
if ( !function_exists(curl_init) ) {
|
28 |
+
ac_subscribe_curl_fail();
|
29 |
+
}
|
30 |
+
else {
|
31 |
+
if (!(int)$options_form["form_fetch"]) {
|
32 |
+
// if it's set to display the static HTML saved in the Wordpress database
|
33 |
+
if ($options_form["form_html"]) {
|
34 |
+
$form_html = $options_form["form_html"];
|
35 |
+
|
36 |
+
if ( (int)$options_form["remove_css"] ) {
|
37 |
+
// remove <style> block
|
38 |
+
preg_match_all("|<style[^>]*>(.*)</style>|iUs", $form_html, $matches);
|
39 |
+
if ( isset($matches[0]) and count($matches[0]) > 0 ) {
|
40 |
+
$form_html = str_replace($matches[0], "", $form_html);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
// replace <input type="button" with <input type="submit" (otherwise the form won't submit)
|
45 |
+
//print_r($matches);exit();
|
46 |
+
$form_html = preg_replace("/<input type=[\"']?button[\"']? value=[\"']?Subscribe[\"']?>/i", "<input type=\"submit\" value=\"Subscribe\">", $form_html);
|
47 |
+
echo $form_html;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
else {
|
51 |
+
// If it's set to fetch the form each time (using the API)
|
52 |
+
if ($options_site["api_url"] && $options_site["api_key"] && $options_form["form_id"]) {
|
53 |
+
|
54 |
+
$api_url = $options_site["api_url"] . "admin/api.php?api_key=" . $options_site["api_key"] . "&api_action=form_view&api_output=serialize&id=" . $options_form["form_id"];
|
55 |
+
$api_result = ac_subscribe_curl_get($api_url);
|
56 |
+
|
57 |
+
// for some reason the very first character of the string is "s" instead of "<". Example: sstyle>
|
58 |
+
$api_result = preg_replace("/^s?/i", "<", $api_result);
|
59 |
+
|
60 |
+
if ( (int)$options_form["remove_css"] ) {
|
61 |
+
// remove <style> block
|
62 |
+
preg_match_all("|<style[^>]*>(.*)</style>|iUs", $api_result, $matches);
|
63 |
+
if ( isset($matches[0]) and count($matches[0]) > 0 ) {
|
64 |
+
$api_result = str_replace($matches[0], "", $api_result);
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
// replace <input type="button" with <input type="submit" (otherwise the form won't submit)
|
69 |
+
$api_result = preg_replace("/<input type=[\"']?button[\"']? value=[\"']?Subscribe[\"']?>/i", "<input type=\"submit\" value=\"Subscribe\">", $api_result);
|
70 |
+
echo $api_result;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
//echo print_r($options_site);
|
76 |
+
//echo print_r($options_form);
|
77 |
+
|
78 |
+
echo $after_title;
|
79 |
+
echo $after_widget;
|
80 |
+
}
|
81 |
+
|
82 |
+
function widget_ac_subscribe_admin() {
|
83 |
+
|
84 |
+
$options_site = ac_subscribe_options_site_get();
|
85 |
+
$options_form = ac_subscribe_options_form_get();
|
86 |
+
|
87 |
+
if ( !function_exists(curl_init) ) {
|
88 |
+
|
89 |
+
ac_subscribe_curl_fail();
|
90 |
+
}
|
91 |
+
else {
|
92 |
+
|
93 |
+
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
94 |
+
|
95 |
+
// The second part of the form, where we ask which form they want to use.
|
96 |
+
// Have to run this section of code first, since we exit right away once this is run.
|
97 |
+
// Hidden form element which is set to true when that part of the form is submitted
|
98 |
+
if ($_POST["ac_subscribe_form_submit"] == true) {
|
99 |
+
|
100 |
+
// SECOND submit
|
101 |
+
|
102 |
+
$api_url = $options_site["api_url"] . "admin/api.php?api_key=" . $options_site["api_key"] . "&api_action=form_view&api_output=serialize&id=" . $_POST["ac_subscribe_form_id"];
|
103 |
+
|
104 |
+
$api_result = ac_subscribe_curl_get($api_url);
|
105 |
+
//print_r($api_result);exit();
|
106 |
+
|
107 |
+
if (is_array($api_result) && isset($api_result["result_code"]) && !(int)$api_result["result_code"]) {
|
108 |
+
echo "
|
109 |
+
<p><span style=\"color: red; font-weight: bold;\">Connection failed.</span> Here is the message returned:</p>
|
110 |
+
<p><span style=\"font-weight: bold;\">" . $api_result["result_message"] . "</span></p>
|
111 |
+
<p>API URL:<br /><a href=\"" . $api_url . "\">" . $api_url . "</a></p>
|
112 |
+
";
|
113 |
+
exit();
|
114 |
+
}
|
115 |
+
|
116 |
+
$options_form_update["form_id"] = $_POST["ac_subscribe_form_id"];
|
117 |
+
// for some reason the very first character of the string is "s" instead of "<". Example: sstyle>
|
118 |
+
$api_result = preg_replace("/^s?/i", "<", $api_result);
|
119 |
+
$options_form_update["form_html"] = $api_result;
|
120 |
+
$options_form_update["form_fetch"] = ( isset($_POST["ac_subscribe_form_fetch"]) ) ? 1 : 0;
|
121 |
+
$options_form_update["remove_css"] = ( isset($_POST["ac_subscribe_remove_css"]) ) ? 1 : 0;
|
122 |
+
|
123 |
+
ac_subscribe_options_form_update($options_form_update);
|
124 |
+
|
125 |
+
echo "Settings saved! Visit the public side to see the form in the sidebar. Refresh this page to go back and choose a different form.";
|
126 |
+
|
127 |
+
exit();
|
128 |
+
}
|
129 |
+
|
130 |
+
if ($_POST["api_url"] != "" && $_POST["api_url"] != "/" && $_POST["api_key"] != "") {
|
131 |
+
|
132 |
+
// FIRST submit
|
133 |
+
|
134 |
+
// Update options_site values from form to database.
|
135 |
+
// Also set friendly-named variables for use further down.
|
136 |
+
// We use the form element values to conduct the API call - not the saved database values.
|
137 |
+
// In other words, we don't save, then pull the same values. We just use the values they provided in the form.
|
138 |
+
// For p_link, check for trailing slash - if there is not one, add it before saving.
|
139 |
+
$options_site_update["api_url"] = $api_url = ( substr($_POST["api_url"], -1, 1) != "/" ) ? $_POST["api_url"] . "/" : $_POST["api_url"];
|
140 |
+
$options_site_update["api_key"] = $api_key = $_POST["api_key"];
|
141 |
+
|
142 |
+
ac_subscribe_options_site_update($options_site_update);
|
143 |
+
|
144 |
+
if ($api_url && $api_key) {
|
145 |
+
|
146 |
+
$api_url = $api_url . "admin/api.php?api_key=" . $api_key . "&api_action=form_list&api_output=serialize";
|
147 |
+
//print_r($api_url);
|
148 |
+
|
149 |
+
$api_result = ac_subscribe_curl_get($api_url);
|
150 |
+
//print_r($api_result["result_code"]);exit();
|
151 |
+
// If the result code is 0, meaning the URL, username, or password could be incorrect,
|
152 |
+
// or they don't have the form_list API call (using an older version)
|
153 |
+
if (!(int)$api_result["result_code"]) {
|
154 |
+
|
155 |
+
echo "
|
156 |
+
|
157 |
+
<p><span style=\"color: red; font-weight: bold;\">" . $api_result["result_message"] . "</span></p>
|
158 |
+
|
159 |
+
<p style=\"font-size: 0.9em;\">Please make sure that your login information is correct, and that you have at least one integration form set up already.</p>
|
160 |
+
|
161 |
+
";
|
162 |
+
|
163 |
+
// Show login form again
|
164 |
+
ac_subscribe_admin_login();
|
165 |
+
|
166 |
+
exit();
|
167 |
+
}
|
168 |
+
|
169 |
+
// Start second page of the form
|
170 |
+
|
171 |
+
echo "
|
172 |
+
|
173 |
+
<p>Please select the form to display:</p>
|
174 |
+
|
175 |
+
";
|
176 |
+
|
177 |
+
// Loop through each array item in the result
|
178 |
+
// Remember, the result contains other items like "result_code"
|
179 |
+
foreach ($api_result as $k => $v) {
|
180 |
+
|
181 |
+
// Only look at array items that are not result_code, result_message, or result_output (included at the end of the result array)
|
182 |
+
if ( $k === 0 || intval($k) ) {
|
183 |
+
|
184 |
+
echo "
|
185 |
+
|
186 |
+
<p>
|
187 |
+
|
188 |
+
<input type=\"radio\" name=\"ac_subscribe_form_id\" id=\"form_id_" . $v["id"] . "\" value=\"" . $v["id"] . "\" />
|
189 |
+
|
190 |
+
";
|
191 |
+
|
192 |
+
echo "<label for=\"form_id_" . $v["id"] . "\">" . $v["name"] . "</label>";
|
193 |
+
|
194 |
+
echo "
|
195 |
+
|
196 |
+
</p>
|
197 |
+
|
198 |
+
";
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
else {
|
203 |
+
|
204 |
+
ac_subscribe_admin_login();
|
205 |
+
}
|
206 |
+
|
207 |
+
?>
|
208 |
+
|
209 |
+
<input type="checkbox" name="ac_subscribe_form_fetch" id="ac_subscribe_form_fetch" />
|
210 |
+
<label for="ac_subscribe_form_fetch">Fetch form with each page load?</label>
|
211 |
+
|
212 |
+
<br />
|
213 |
+
|
214 |
+
<input type="checkbox" name="ac_subscribe_remove_css" id="ac_subscribe_remove_css" />
|
215 |
+
<label for="ac_subscribe_remove_css">Remove embedded CSS? (Can often conflict with WordPress styles.)</label>
|
216 |
+
|
217 |
+
<input type="hidden" name="ac_subscribe_form_submit" value="true" />
|
218 |
+
|
219 |
+
<?php
|
220 |
+
}
|
221 |
+
}
|
222 |
+
else {
|
223 |
+
|
224 |
+
ac_subscribe_admin_login();
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
function ac_subscribe_options_site_get() {
|
230 |
+
|
231 |
+
$options_site = get_option("widget_ac_subscribe_site");
|
232 |
+
|
233 |
+
return $options_site;
|
234 |
+
}
|
235 |
+
|
236 |
+
function ac_subscribe_options_site_update($options_site) {
|
237 |
+
|
238 |
+
update_option("widget_ac_subscribe_site", $options_site);
|
239 |
+
}
|
240 |
+
|
241 |
+
function ac_subscribe_options_form_get() {
|
242 |
+
|
243 |
+
$options_form = get_option("widget_ac_subscribe_form");
|
244 |
+
|
245 |
+
return $options_form;
|
246 |
+
}
|
247 |
+
|
248 |
+
function ac_subscribe_options_form_update($options_form) {
|
249 |
+
|
250 |
+
update_option("widget_ac_subscribe_form", $options_form);
|
251 |
+
}
|
252 |
+
|
253 |
+
function ac_subscribe_curl_get($api_url) {
|
254 |
+
$api_request = curl_init($api_url);
|
255 |
+
curl_setopt($api_request, CURLOPT_HEADER, 0);
|
256 |
+
curl_setopt($api_request, CURLOPT_RETURNTRANSFER, 1);
|
257 |
+
curl_setopt($api_request, CURLOPT_FOLLOWLOCATION, true);
|
258 |
+
$api_response = curl_exec($api_request);
|
259 |
+
curl_close($api_request);
|
260 |
+
//print_r($api_response);exit();
|
261 |
+
$api_result = unserialize($api_response);
|
262 |
+
return $api_result;
|
263 |
+
}
|
264 |
+
|
265 |
+
function ac_subscribe_curl_fail() {
|
266 |
+
echo "<b>CURL is not supported on your server (introduced in PHP 4.0.2).</b> Please enable it to use this widget.";
|
267 |
+
}
|
268 |
+
|
269 |
+
function ac_subscribe_admin_login() {
|
270 |
+
|
271 |
+
$options_site = ac_subscribe_options_site_get();
|
272 |
+
|
273 |
+
?>
|
274 |
+
|
275 |
+
<p>
|
276 |
+
Your ActiveCampaign API URL:
|
277 |
+
<input type="text" name="api_url" id="api_url" value="<?php echo $options_site["api_url"]; ?>" style="width: 99%;" />
|
278 |
+
</p>
|
279 |
+
|
280 |
+
<p>
|
281 |
+
Your ActiveCampaign API Key:
|
282 |
+
<input type="text" name="api_key" id="api_key" value="<?php echo $options_site["api_key"]; ?>" style="width: 99%;" />
|
283 |
+
</p>
|
284 |
+
|
285 |
+
<?php
|
286 |
+
}
|
287 |
+
|
288 |
+
function ac_subscribe_init() {
|
289 |
+
register_sidebar_widget("ActiveCampaign Subscription Form", "widget_ac_subscribe_public");
|
290 |
+
register_widget_control("ActiveCampaign Subscription Form", 'widget_ac_subscribe_admin');
|
291 |
+
}
|
292 |
+
|
293 |
+
add_action("plugins_loaded", "ac_subscribe_init");
|
294 |
+
|
295 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== ActiveCampaign Subscription Form ===
|
2 |
+
Contributors: activecampaign
|
3 |
+
Tags: activecampaign, subscribe, email, newsletter, signup, marketing, plugin, widget, sidebar
|
4 |
+
Requires at least: 2
|
5 |
+
Tested up to: 3.2.1
|
6 |
+
Stable tag: trunk
|
7 |
+
|
8 |
+
The ActiveCampaign email marketing plugin connects WordPress with your email marketing software and allows you to choose a subscription form to embed (as a widget) anywhere on your site.
|
9 |
+
|
10 |
+
== Description ==
|
11 |
+
|
12 |
+
The ActiveCampaign plugin connects WordPress with your [email marketing software](http://www.activecampaign.com/) and allows you to choose a subscription form to embed (as a widget) anywhere on your site. After enabling go to Appearance > Widgets to activate this plugin.
|
13 |
+
|
14 |
+
For more information & to download a free trial visit the [ActiveCampaign](http://www.activecampaign.com/) web site.
|
15 |
+
|
16 |
+
== Installation ==
|
17 |
+
|
18 |
+
This section describes how to install the plugin and get it working.
|
19 |
+
|
20 |
+
1. Upload the entire "activecampaign_subscribe" Zip file to the Plugins section of WordPress.
|
21 |
+
2. Activate the plugin through the Plugins section in WordPress.
|
22 |
+
3. Visit Appearance > Widgets and drag the "ActiveCampaign Subscription Form" widget to a sidebar.
|
23 |
+
4. Fill in your ActiveCampaign connection details, then hit Save.
|
24 |
+
5. Choose a subscription form to display, then hit Save again.
|
25 |
+
|
26 |
+
== Frequently Asked Questions ==
|
27 |
+
|
28 |
+
= How do I create ActiveCampaign subscription forms to use in WordPress? =
|
29 |
+
|
30 |
+
You need to be using [ActiveCampaign email marketing software](http://www.activecampaign.com/) to use this widget. Create new subscriptions forms in the software by going to the "Integration" section, then they will be available through this widget.
|
31 |
+
|
32 |
+
= I get a "Connection failed" message. What does this mean? =
|
33 |
+
|
34 |
+
Please make sure that your login information is correct, and that you have at least one Integration form already created in the ActiveCampaign system.
|
35 |
+
|
36 |
+
= What does "Fetch form with each page load" mean? =
|
37 |
+
|
38 |
+
If you check this box, WordPress will re-request the details of your form each time the page is loaded. For performance reasons, it's best to leave this box unchecked.
|
39 |
+
|
40 |
+
== Screenshots ==
|
41 |
+
|
42 |
+
1. Entering your ActiveCampaign API information
|
43 |
+
2. Selecting the subscription form to display
|
44 |
+
3. Confirmation that your settings have been saved
|
45 |
+
4. Viewing the subscription form on the public side when using the plugin
|
46 |
+
|
47 |
+
== Changelog ==
|
48 |
+
|
49 |
+
= 1.0 =
|
50 |
+
* Initial release.
|
51 |
+
|
52 |
+
= 1.1 =
|
53 |
+
* Verified this works with latest versions of WordPress and ActiveCampaign.
|
54 |
+
* Updated installation instructions.
|
55 |
+
|
56 |
+
= 2.0 =
|
57 |
+
* Re-configured to work with ActiveCampaign version 5.4.
|
58 |
+
* Improved some areas.
|
59 |
+
|
60 |
+
= 2.1 =
|
61 |
+
* Changed internal API requests to use only API URL and Key instead of Username and Password.
|
62 |
+
* Provided option to remove style blocks from embedded form code, and converting <input type="button" into <input type="submit".
|
63 |
+
|
64 |
+
== Upgrade Notice ==
|
65 |
+
|
66 |
+
= 1.1 =
|
67 |
+
* Installation instructions updated if you are having trouble installing it.
|
68 |
+
|
69 |
+
= 2.0 =
|
70 |
+
* Version 2.0 will NOT work with ActiveCampaign versions < 5.4.
|
71 |
+
|
72 |
+
= 2.1 =
|
73 |
+
* This version requires the use of API URL and Key instead of Username and Password.
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
screenshot-3.png
ADDED
Binary file
|
screenshot-4.png
ADDED
Binary file
|
screenshot-5.png
ADDED
Binary file
|