Version Description
Download this release
Release Info
Developer | unbouncewordpress |
Plugin | Unbounce Landing Pages |
Version | 0.1.24 |
Comparing to | |
See all releases |
Code changes from version 0.1.23 to 0.1.24
- UBConfig.php +2 -2
- UBHTTP.php +3 -4
- Unbounce-Page.php +47 -49
- css/unbounce-pages.css +5 -1
- js/set-unbounce-domains.js +24 -18
- readme.txt +1 -1
UBConfig.php
CHANGED
@@ -12,8 +12,8 @@ class UBConfig {
|
|
12 |
const UB_AUTHORIZED_DOMAINS_KEY = 'ub-authorized-domains';
|
13 |
const UB_HAS_AUTHORIZED_KEY = 'ub-has-authorized';
|
14 |
const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
|
15 |
-
const UB_USER_AGENT = 'Unbounce WP Plugin 0.1.
|
16 |
-
const UB_VERSION = '0.1.
|
17 |
|
18 |
public static function default_page_server_domain() {
|
19 |
$domain = getenv('UB_PAGE_SERVER_DOMAIN');
|
12 |
const UB_AUTHORIZED_DOMAINS_KEY = 'ub-authorized-domains';
|
13 |
const UB_HAS_AUTHORIZED_KEY = 'ub-has-authorized';
|
14 |
const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
|
15 |
+
const UB_USER_AGENT = 'Unbounce WP Plugin 0.1.24';
|
16 |
+
const UB_VERSION = '0.1.24';
|
17 |
|
18 |
public static function default_page_server_domain() {
|
19 |
$domain = getenv('UB_PAGE_SERVER_DOMAIN');
|
UBHTTP.php
CHANGED
@@ -3,7 +3,8 @@
|
|
3 |
class UBHTTP {
|
4 |
public static $powered_by_header_regex = '/^X-Powered-By: (.+)$/i';
|
5 |
public static $form_confirmation_url_regex = '/(.+)\/[a-z]+-form_confirmation\.html/';
|
6 |
-
|
|
|
7 |
|
8 |
public static function is_private_ip_address($ip_address) {
|
9 |
return !filter_var($ip_address,
|
@@ -207,20 +208,18 @@ class UBHTTP {
|
|
207 |
|
208 |
if ($http_method == 'GET' && $path == '/_ubhc') {
|
209 |
return 'HealthCheck';
|
|
|
210 |
} elseif ($http_method == "POST" &&
|
211 |
preg_match("/^\/(fsn|fsg|fs)\/?$/", $path)) {
|
212 |
-
|
213 |
return "SubmitLead";
|
214 |
|
215 |
} elseif ($http_method == "GET" &&
|
216 |
UBHTTP::is_tracking_link($proxyable_url_set, $url_without_protocol)) {
|
217 |
-
|
218 |
return "TrackClick";
|
219 |
|
220 |
} elseif ($http_method == "GET" &&
|
221 |
(in_array($url_without_protocol, $proxyable_url_set) ||
|
222 |
UBHTTP::is_confirmation_dialog($proxyable_url_set, $url_without_protocol))) {
|
223 |
-
|
224 |
return "ViewLandingPage";
|
225 |
|
226 |
} else {
|
3 |
class UBHTTP {
|
4 |
public static $powered_by_header_regex = '/^X-Powered-By: (.+)$/i';
|
5 |
public static $form_confirmation_url_regex = '/(.+)\/[a-z]+-form_confirmation\.html/';
|
6 |
+
// Suppress Etag and Last-Modified so that browser doesn't send If-None-Match and If-Modified-Since header (to bypass front-end caches)
|
7 |
+
public static $forward_headers = '/^(Content-Type:|Location:|Link:|Content-Location:|Set-Cookie:|X-Server-Instance:|X-Unbounce-PageId:|X-Unbounce-Variant:|X-Unbounce-VisitorID:)/i';
|
8 |
|
9 |
public static function is_private_ip_address($ip_address) {
|
10 |
return !filter_var($ip_address,
|
208 |
|
209 |
if ($http_method == 'GET' && $path == '/_ubhc') {
|
210 |
return 'HealthCheck';
|
211 |
+
|
212 |
} elseif ($http_method == "POST" &&
|
213 |
preg_match("/^\/(fsn|fsg|fs)\/?$/", $path)) {
|
|
|
214 |
return "SubmitLead";
|
215 |
|
216 |
} elseif ($http_method == "GET" &&
|
217 |
UBHTTP::is_tracking_link($proxyable_url_set, $url_without_protocol)) {
|
|
|
218 |
return "TrackClick";
|
219 |
|
220 |
} elseif ($http_method == "GET" &&
|
221 |
(in_array($url_without_protocol, $proxyable_url_set) ||
|
222 |
UBHTTP::is_confirmation_dialog($proxyable_url_set, $url_without_protocol))) {
|
|
|
223 |
return "ViewLandingPage";
|
224 |
|
225 |
} else {
|
Unbounce-Page.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Unbounce
|
4 |
Plugin URI: http://unbounce.com
|
5 |
Description: Publish Unbounce Landing Pages to your Wordpress Domain.
|
6 |
-
Version: 0.1.
|
7 |
Author: Unbounce
|
8 |
Author URI: http://unbounce.com
|
9 |
License: GPLv2
|
@@ -47,7 +47,7 @@ register_deactivation_hook(__FILE__, function() {
|
|
47 |
add_action('init', function() {
|
48 |
UBLogger::setup_logger();
|
49 |
|
50 |
-
$domain = parse_url(
|
51 |
|
52 |
if(!UBConfig::is_authorized_domain($domain)) {
|
53 |
UBLogger::info("Domain: $domain has not been authorized");
|
@@ -81,63 +81,59 @@ add_action('init', function() {
|
|
81 |
|
82 |
////////////////////
|
83 |
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|
87 |
else {
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
header('Content-Type: application/json');
|
96 |
-
$version = UBConfig::UB_VERSION;
|
97 |
-
echo "{\"ub_wordpress\":{\"version\":\"$version\"}}";
|
98 |
-
exit(0);
|
99 |
}
|
100 |
-
else {
|
101 |
-
// Disable caching plugins. This should take care of:
|
102 |
-
// - W3 Total Cache
|
103 |
-
// - WP Super Cache
|
104 |
-
// - ZenCache (Previously QuickCache)
|
105 |
-
if(!defined('DONOTCACHEPAGE')) {
|
106 |
-
define('DONOTCACHEPAGE', true);
|
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 |
|
@@ -179,6 +175,7 @@ function authorization_button($text, $wrap_in_p = false) {
|
|
179 |
echo '</form>';
|
180 |
}
|
181 |
function render_unbounce_pages($domain_info, $domain) {
|
|
|
182 |
$img_url = plugins_url('img/unbounce-logo-blue.png', __FILE__);
|
183 |
echo "<img class=\"ub-logo\" src=\"${img_url}\" />";
|
184 |
echo "<h1 class=\"ub-unbounce-pages-heading\">Unbounce Pages</h1>";
|
@@ -218,7 +215,7 @@ function render_unbounce_pages($domain_info, $domain) {
|
|
218 |
echo '. If they are still not appearing, double check that your Unbounce pages are using a Wordpress domain.</p>';
|
219 |
echo '</form>';
|
220 |
echo '<a href="http://documentation.unbounce.com/hc/en-us/articles/205069824-Integrating-with-WordPress" target="_blank">Check out our knowledge base.</a>';
|
221 |
-
echo '<p class="ub-version">Unbounce Version 0.1.
|
222 |
});
|
223 |
} else {
|
224 |
if (UBConfig::has_authorized()) {
|
@@ -240,11 +237,12 @@ function render_unbounce_pages($domain_info, $domain) {
|
|
240 |
} elseif($authorization === 'failure') {
|
241 |
echo '<div class="error"><p>Sorry, there was an error authorizing with Unbounce. Please try again.</p></div>';
|
242 |
}
|
|
|
243 |
}
|
244 |
|
245 |
add_action('admin_menu', function() {
|
246 |
$print_admin_panel = function() {
|
247 |
-
$domain = parse_url(
|
248 |
$domain_info = UBConfig::read_unbounce_domain_info($domain, false);
|
249 |
|
250 |
render_unbounce_pages($domain_info, $domain);
|
@@ -278,7 +276,7 @@ add_action('admin_post_set_unbounce_domains', function() {
|
|
278 |
});
|
279 |
|
280 |
add_action('admin_post_flush_unbounce_pages', function() {
|
281 |
-
$domain = parse_url(
|
282 |
// Expire cache and redirect
|
283 |
$_domain_info = UBConfig::read_unbounce_domain_info($domain, true);
|
284 |
status_header(301);
|
3 |
Plugin Name: Unbounce
|
4 |
Plugin URI: http://unbounce.com
|
5 |
Description: Publish Unbounce Landing Pages to your Wordpress Domain.
|
6 |
+
Version: 0.1.24
|
7 |
Author: Unbounce
|
8 |
Author URI: http://unbounce.com
|
9 |
License: GPLv2
|
47 |
add_action('init', function() {
|
48 |
UBLogger::setup_logger();
|
49 |
|
50 |
+
$domain = parse_url(get_home_url(), PHP_URL_HOST);
|
51 |
|
52 |
if(!UBConfig::is_authorized_domain($domain)) {
|
53 |
UBLogger::info("Domain: $domain has not been authorized");
|
81 |
|
82 |
////////////////////
|
83 |
|
84 |
+
$url_purpose = UBHTTP::get_url_purpose($proxyable_url_set,
|
85 |
+
$http_method,
|
86 |
+
$current_url);
|
87 |
+
if ($url_purpose == null) {
|
88 |
+
UBLogger::debug("ignoring request to URL " . $current_url);
|
89 |
+
}
|
90 |
+
elseif ($url_purpose == 'HealthCheck') {
|
91 |
+
header('Content-Type: application/json');
|
92 |
+
$version = UBConfig::UB_VERSION;
|
93 |
+
echo "{\"ub_wordpress\":{\"version\":\"$version\"}}";
|
94 |
+
exit(0);
|
95 |
}
|
96 |
else {
|
97 |
+
|
98 |
+
// Disable caching plugins. This should take care of:
|
99 |
+
// - W3 Total Cache
|
100 |
+
// - WP Super Cache
|
101 |
+
// - ZenCache (Previously QuickCache)
|
102 |
+
if(!defined('DONOTCACHEPAGE')) {
|
103 |
+
define('DONOTCACHEPAGE', true);
|
|
|
|
|
|
|
|
|
104 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
+
// Disable CDN for W3 Total Cache
|
107 |
+
if(!defined('DONOTCDN')) {
|
108 |
+
define('DONOTCDN', true);
|
109 |
+
}
|
110 |
|
111 |
+
UBLogger::debug("perform ''" . $url_purpose . "'' on received URL " . $current_url);
|
112 |
|
113 |
+
$cookies_to_forward = UBUtil::array_select_by_key($_COOKIE,
|
114 |
+
array('ubvs', 'ubpv', 'ubvt'));
|
115 |
|
116 |
+
$cookie_string = UBHTTP::cookie_string_from_array($cookies_to_forward);
|
117 |
|
118 |
+
$req_headers = $referer == null ? array('Host: ' . $domain) : array('Referer: ' . $referer, 'Host: ' . $domain);
|
119 |
|
120 |
+
// Make sure we don't get cached by Wordpress hosts like WPEngine
|
121 |
+
header('Cache-Control: max-age=0; private');
|
122 |
|
123 |
+
UBHTTP::stream_request($http_method,
|
124 |
+
$raw_url,
|
125 |
+
$cookie_string,
|
126 |
+
$req_headers,
|
127 |
+
$_POST,
|
128 |
+
$user_agent);
|
129 |
|
130 |
+
$end = microtime(true);
|
131 |
+
$time_taken = ($end - $start) * 1000;
|
132 |
|
133 |
+
UBLogger::debug_var('time_taken', $time_taken);
|
134 |
+
UBLogger::debug("proxying for $current_url done successfuly -- took $time_taken ms");
|
135 |
|
136 |
+
exit(0);
|
|
|
137 |
}
|
138 |
});
|
139 |
|
175 |
echo '</form>';
|
176 |
}
|
177 |
function render_unbounce_pages($domain_info, $domain) {
|
178 |
+
echo "<div class=\"ub-plugin-wrapper\">";
|
179 |
$img_url = plugins_url('img/unbounce-logo-blue.png', __FILE__);
|
180 |
echo "<img class=\"ub-logo\" src=\"${img_url}\" />";
|
181 |
echo "<h1 class=\"ub-unbounce-pages-heading\">Unbounce Pages</h1>";
|
215 |
echo '. If they are still not appearing, double check that your Unbounce pages are using a Wordpress domain.</p>';
|
216 |
echo '</form>';
|
217 |
echo '<a href="http://documentation.unbounce.com/hc/en-us/articles/205069824-Integrating-with-WordPress" target="_blank">Check out our knowledge base.</a>';
|
218 |
+
echo '<p class="ub-version">Unbounce Version 0.1.24</p>';
|
219 |
});
|
220 |
} else {
|
221 |
if (UBConfig::has_authorized()) {
|
237 |
} elseif($authorization === 'failure') {
|
238 |
echo '<div class="error"><p>Sorry, there was an error authorizing with Unbounce. Please try again.</p></div>';
|
239 |
}
|
240 |
+
echo "</div>"; //close ub-plugin-wrapper
|
241 |
}
|
242 |
|
243 |
add_action('admin_menu', function() {
|
244 |
$print_admin_panel = function() {
|
245 |
+
$domain = parse_url(get_home_url(), PHP_URL_HOST);
|
246 |
$domain_info = UBConfig::read_unbounce_domain_info($domain, false);
|
247 |
|
248 |
render_unbounce_pages($domain_info, $domain);
|
276 |
});
|
277 |
|
278 |
add_action('admin_post_flush_unbounce_pages', function() {
|
279 |
+
$domain = parse_url(get_home_url(), PHP_URL_HOST);
|
280 |
// Expire cache and redirect
|
281 |
$_domain_info = UBConfig::read_unbounce_domain_info($domain, true);
|
282 |
status_header(301);
|
css/unbounce-pages.css
CHANGED
@@ -1,8 +1,12 @@
|
|
|
|
|
|
|
|
|
|
1 |
.ub-logo {
|
2 |
width: 40px;
|
3 |
height: 40px;
|
4 |
float: left;
|
5 |
-
margin:
|
6 |
}
|
7 |
|
8 |
.ub-unbounce-pages-heading {
|
1 |
+
.ub-plugin-wrapper {
|
2 |
+
padding-bottom: 100px;
|
3 |
+
}
|
4 |
+
|
5 |
.ub-logo {
|
6 |
width: 40px;
|
7 |
height: 40px;
|
8 |
float: left;
|
9 |
+
margin: -10px 10px 0 0;
|
10 |
}
|
11 |
|
12 |
.ub-unbounce-pages-heading {
|
js/set-unbounce-domains.js
CHANGED
@@ -11,18 +11,30 @@
|
|
11 |
return Rx.Observable.fromPromise(request.promise());
|
12 |
}
|
13 |
|
14 |
-
function
|
15 |
-
if($.isArray(result
|
16 |
return Rx.Observable.fromArray(
|
17 |
-
$.map(result
|
18 |
-
if(
|
19 |
-
return
|
20 |
} else {
|
21 |
-
throw 'Unable to fetch '
|
22 |
}
|
23 |
}));
|
24 |
} else {
|
25 |
-
throw 'Unable to fetch '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
}
|
28 |
|
@@ -52,7 +64,7 @@
|
|
52 |
redirectUri = $submitButton.attr('data-redirect-uri'),
|
53 |
apiClientId = $submitButton.attr('data-api-client-id'),
|
54 |
getTokenUrl = apiUrl + '/oauth/authorize?response_type=token&client_id=' + apiClientId + '&redirect_uri=' + redirectUri,
|
55 |
-
|
56 |
getSubAccountsUrl = apiUrl + '/accounts/{accountId}/sub_accounts',
|
57 |
getSubAccountUrl = apiUrl + '/sub_accounts/{subAccountId}',
|
58 |
getDomainsUrl = apiUrl + '/sub_accounts/{subAccountId}/domains',
|
@@ -71,21 +83,15 @@
|
|
71 |
if(accessToken) {
|
72 |
loadingUI($submitButton, loadingText);
|
73 |
|
74 |
-
var source = apiGet(
|
75 |
-
.flatMap(function(
|
76 |
-
return
|
77 |
-
})
|
78 |
-
.flatMap(function(accountId) {
|
79 |
-
return apiGet(getSubAccountsUrl.replace('{accountId}', accountId), accessToken);
|
80 |
-
})
|
81 |
-
.flatMap(function(subAccount) {
|
82 |
-
return getApiResult('sub_accounts', 'id', subAccount);
|
83 |
})
|
84 |
.flatMap(function (subAccountId) {
|
85 |
return apiGet(getDomainsUrl.replace('{subAccountId}', subAccountId), accessToken);
|
86 |
})
|
87 |
.flatMap(function(domains) {
|
88 |
-
return
|
89 |
}).toArray().publish(),
|
90 |
subscription = source.subscribe(
|
91 |
function (domains) {
|
11 |
return Rx.Observable.fromPromise(request.promise());
|
12 |
}
|
13 |
|
14 |
+
function getDomainNames(result) {
|
15 |
+
if($.isArray(result.domains)) {
|
16 |
return Rx.Observable.fromArray(
|
17 |
+
$.map(result.domains, function(domain) {
|
18 |
+
if(domain && domain.name) {
|
19 |
+
return domain.name;
|
20 |
} else {
|
21 |
+
throw 'Unable to fetch domain name';
|
22 |
}
|
23 |
}));
|
24 |
} else {
|
25 |
+
throw 'Unable to fetch domains';
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
function getUserSubAccountIds(user) {
|
30 |
+
if(user.metadata && user.metadata.related && $.isArray(user.metadata.related.sub_accounts)) {
|
31 |
+
return Rx.Observable.fromArray(
|
32 |
+
$.map(user.metadata.related.sub_accounts, function(sub_account_url) {
|
33 |
+
var pieces = sub_account_url.split('/');
|
34 |
+
return pieces[pieces.length - 1];
|
35 |
+
}));
|
36 |
+
} else {
|
37 |
+
throw 'Unable to fetch user';
|
38 |
}
|
39 |
}
|
40 |
|
64 |
redirectUri = $submitButton.attr('data-redirect-uri'),
|
65 |
apiClientId = $submitButton.attr('data-api-client-id'),
|
66 |
getTokenUrl = apiUrl + '/oauth/authorize?response_type=token&client_id=' + apiClientId + '&redirect_uri=' + redirectUri,
|
67 |
+
getUserUrl = apiUrl + '/users/self',
|
68 |
getSubAccountsUrl = apiUrl + '/accounts/{accountId}/sub_accounts',
|
69 |
getSubAccountUrl = apiUrl + '/sub_accounts/{subAccountId}',
|
70 |
getDomainsUrl = apiUrl + '/sub_accounts/{subAccountId}/domains',
|
83 |
if(accessToken) {
|
84 |
loadingUI($submitButton, loadingText);
|
85 |
|
86 |
+
var source = apiGet(getUserUrl, accessToken)
|
87 |
+
.flatMap(function(user) {
|
88 |
+
return getUserSubAccountIds(user);
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
})
|
90 |
.flatMap(function (subAccountId) {
|
91 |
return apiGet(getDomainsUrl.replace('{subAccountId}', subAccountId), accessToken);
|
92 |
})
|
93 |
.flatMap(function(domains) {
|
94 |
+
return getDomainNames(domains);
|
95 |
}).toArray().publish(),
|
96 |
subscription = source.subscribe(
|
97 |
function (domains) {
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: unbouncewordpress
|
|
3 |
Tags: Unbounce, AB testing, A/B testing, split testing, CRO, conversion optimization, wordpress landing page, wp landing pages, splash pages, landing pages, squeeze pages, lead gen, lead generation, email list, responsive landing pages, templates, inbound marketing, ppc, analytics
|
4 |
Requires at least: 4.1.5
|
5 |
Tested up to: 4.2.2
|
6 |
-
Stable tag: 0.1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
3 |
Tags: Unbounce, AB testing, A/B testing, split testing, CRO, conversion optimization, wordpress landing page, wp landing pages, splash pages, landing pages, squeeze pages, lead gen, lead generation, email list, responsive landing pages, templates, inbound marketing, ppc, analytics
|
4 |
Requires at least: 4.1.5
|
5 |
Tested up to: 4.2.2
|
6 |
+
Stable tag: 0.1.24
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|