Version Description
- Better documentation and troubleshooting
- Tested with WP 5.0
Download this release
Release Info
Developer | unbouncewordpress |
Plugin | Unbounce Landing Pages |
Version | 1.0.37 |
Comparing to | |
See all releases |
Code changes from version 1.0.36 to 1.0.37
- UBConfig.php +2 -2
- UBDiagnostics.php +2 -2
- UBHTTP.php +1 -1
- Unbounce-Page.php +1 -1
- css/unbounce-pages.css +14 -1
- readme.txt +6 -2
- templates/diagnostics.php +83 -28
- templates/main_authorized_footer.php +2 -2
- templates/main_unauthorized_footer.php +2 -2
- trunk/UBCompatibility.php +0 -152
- trunk/UBConfig.php +0 -416
- trunk/UBDiagnostics.php +0 -221
- trunk/UBEvents.php +0 -95
- trunk/UBHTTP.php +0 -372
- trunk/UBIcon.php +0 -10
- trunk/UBLogger.php +0 -95
- trunk/UBPageTable.php +0 -49
- trunk/UBTemplate.php +0 -46
- trunk/UBUtil.php +0 -105
- trunk/UBWPListTable.php +0 -1246
- trunk/Unbounce-Page.php +0 -340
- trunk/css/unbounce-pages.css +0 -89
- trunk/img/unbounce-logo-blue.png +0 -0
- trunk/js/clipboard.min.js +0 -7
- trunk/js/rx.lite.compat.min.js +0 -5
- trunk/js/set-unbounce-domains.js +0 -146
- trunk/js/unbounce-diagnostics.js +0 -22
- trunk/js/unbounce-page.js +0 -7
- trunk/readme.txt +0 -222
- trunk/templates/authorize_button.php +0 -26
- trunk/templates/diagnostics.php +0 -82
- trunk/templates/main.php +0 -46
- trunk/templates/main_authorized.php +0 -32
- trunk/templates/main_authorized_footer.php +0 -24
- trunk/templates/main_failed_authorization.php +0 -33
- trunk/templates/main_header.php +0 -21
- trunk/templates/main_unauthorized.php +0 -25
- trunk/templates/main_unauthorized_footer.php +0 -7
UBConfig.php
CHANGED
@@ -5,8 +5,8 @@ class UBConfig
|
|
5 |
|
6 |
const UB_PLUGIN_NAME = 'ub-wordpress';
|
7 |
const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
|
8 |
-
const UB_USER_AGENT = 'Unbounce WP Plugin 1.0.
|
9 |
-
const UB_VERSION = '1.0.
|
10 |
|
11 |
// Option keys
|
12 |
const UB_ROUTES_CACHE_KEY = 'ub-route-cache';
|
5 |
|
6 |
const UB_PLUGIN_NAME = 'ub-wordpress';
|
7 |
const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
|
8 |
+
const UB_USER_AGENT = 'Unbounce WP Plugin 1.0.37';
|
9 |
+
const UB_VERSION = '1.0.37';
|
10 |
|
11 |
// Option keys
|
12 |
const UB_ROUTES_CACHE_KEY = 'ub-route-cache';
|
UBDiagnostics.php
CHANGED
@@ -100,7 +100,7 @@ class UBDiagnostics
|
|
100 |
return array(
|
101 |
'PHP Version' => phpversion(),
|
102 |
'WordPress Version' => UBDiagnostics::wordpress_version(),
|
103 |
-
'Unbounce Plugin Version' => '1.0.
|
104 |
'Checks' => self::pp(UBDiagnostics::checks($domain, $domain_info)),
|
105 |
'Options' => self::pp(UBDiagnostics::ub_options()),
|
106 |
'Permalink Structure' => get_option('permalink_structure', ''),
|
@@ -181,7 +181,7 @@ class UBDiagnostics
|
|
181 |
return array(
|
182 |
'php' => phpversion(),
|
183 |
'wordpress' => UBDiagnostics::wordpress_version(),
|
184 |
-
'plugin_version' => '1.0.
|
185 |
'curl_installed' => self::is_curl_installed(),
|
186 |
'xml_installed' => self::is_xml_installed(),
|
187 |
'sni_support' => self::hasSNI(),
|
100 |
return array(
|
101 |
'PHP Version' => phpversion(),
|
102 |
'WordPress Version' => UBDiagnostics::wordpress_version(),
|
103 |
+
'Unbounce Plugin Version' => '1.0.37',
|
104 |
'Checks' => self::pp(UBDiagnostics::checks($domain, $domain_info)),
|
105 |
'Options' => self::pp(UBDiagnostics::ub_options()),
|
106 |
'Permalink Structure' => get_option('permalink_structure', ''),
|
181 |
return array(
|
182 |
'php' => phpversion(),
|
183 |
'wordpress' => UBDiagnostics::wordpress_version(),
|
184 |
+
'plugin_version' => '1.0.37',
|
185 |
'curl_installed' => self::is_curl_installed(),
|
186 |
'xml_installed' => self::is_xml_installed(),
|
187 |
'sni_support' => self::hasSNI(),
|
UBHTTP.php
CHANGED
@@ -221,7 +221,7 @@ class UBHTTP
|
|
221 |
curl_setopt_array($curl, $curl_options);
|
222 |
$resp = curl_exec($curl);
|
223 |
if (!$resp) {
|
224 |
-
$message = "Error proxying to '
|
225 |
UBLogger::warning($message);
|
226 |
http_response_code(500);
|
227 |
$result = array(false, $message);
|
221 |
curl_setopt_array($curl, $curl_options);
|
222 |
$resp = curl_exec($curl);
|
223 |
if (!$resp) {
|
224 |
+
$message = "Error proxying to '" . $target_url . "': " . curl_error($curl) . " - Code: " . curl_errno($curl);
|
225 |
UBLogger::warning($message);
|
226 |
http_response_code(500);
|
227 |
$result = array(false, $message);
|
Unbounce-Page.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Unbounce Landing Pages
|
4 |
Plugin URI: http://unbounce.com
|
5 |
Description: Unbounce is the most powerful standalone landing page builder available.
|
6 |
-
Version: 1.0.
|
7 |
Author: Unbounce
|
8 |
Author URI: http://unbounce.com
|
9 |
License: GPLv2
|
3 |
Plugin Name: Unbounce Landing Pages
|
4 |
Plugin URI: http://unbounce.com
|
5 |
Description: Unbounce is the most powerful standalone landing page builder available.
|
6 |
+
Version: 1.0.37
|
7 |
Author: Unbounce
|
8 |
Author URI: http://unbounce.com
|
9 |
License: GPLv2
|
css/unbounce-pages.css
CHANGED
@@ -84,6 +84,19 @@
|
|
84 |
margin-left: 24px;
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
#ub-diagnostics-copy-result div {
|
88 |
margin: 10px 0 10px 0 !important;
|
89 |
-
}
|
84 |
margin-left: 24px;
|
85 |
}
|
86 |
|
87 |
+
.causes {
|
88 |
+
list-style: disc;
|
89 |
+
padding: 0 20px;
|
90 |
+
}
|
91 |
+
|
92 |
+
.info {
|
93 |
+
background: #fff;
|
94 |
+
padding: 10px 20px;
|
95 |
+
margin-bottom: 20px;
|
96 |
+
border: 1px solid #0098db;
|
97 |
+
border-radius: 3px;
|
98 |
+
}
|
99 |
+
|
100 |
#ub-diagnostics-copy-result div {
|
101 |
margin: 10px 0 10px 0 !important;
|
102 |
+
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
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:
|
6 |
-
Stable tag: 1.0.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -100,6 +100,10 @@ You should add a rule to your cache to avoid caching Unbounce Pages which have t
|
|
100 |
|
101 |
== Changelog ==
|
102 |
|
|
|
|
|
|
|
|
|
103 |
= 1.0.36 =
|
104 |
* Improved testing instrumentation
|
105 |
|
2 |
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: 5.0
|
6 |
+
Stable tag: 1.0.37
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
100 |
|
101 |
== Changelog ==
|
102 |
|
103 |
+
= 1.0.37 =
|
104 |
+
* Better documentation and troubleshooting
|
105 |
+
* Tested with WP 5.0
|
106 |
+
|
107 |
= 1.0.36 =
|
108 |
* Improved testing instrumentation
|
109 |
|
templates/diagnostics.php
CHANGED
@@ -1,31 +1,54 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
$diagnostic_descriptions = array(
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
'Domain is Authorized' => "Your Domain ({$domain}) needs to be added to your
|
13 |
-
Unbounce account, please return to the main plugin page, select
|
14 |
-
\"Add My Domain In Unbounce\". After adding your domain in
|
15 |
-
Unbounce, return to the main plugin page and select the \"Update
|
16 |
-
WordPress Enabled Domains\".",
|
17 |
-
'Can Fetch Page Listing' => 'We are unable to fetch the page listing from Unbounce, please
|
18 |
-
contact your hosting provider or IT professional to ensure Curl
|
19 |
-
Supported is installed and enabled.',
|
20 |
-
'Supported PHP Version' => 'The Unbounce Pages plugin is supported when using PHP version
|
21 |
-
5.3 or higher, please contact your hosting provider or IT
|
22 |
-
professional and update to a supported version.',
|
23 |
-
'Supported Wordpress Version' => 'The Unbounce Pages plugin is supported on WordPress versions 4.0
|
24 |
-
and higher, please contact your hosting provider or IT
|
25 |
-
professional and update to a supported version.',
|
26 |
);
|
27 |
|
28 |
?>
|
|
|
29 |
<div class="ub-plugin-wrapper">
|
30 |
<img class="ub-logo" src="<?php echo $img_url; ?>" />
|
31 |
<h1 class="ub-unbounce-pages-heading">Unbounce Pages Diagnostics</h1>
|
@@ -51,13 +74,45 @@ $diagnostic_descriptions = array(
|
|
51 |
<?php endforeach; ?>
|
52 |
</ul>
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
<h2>Details</h2>
|
55 |
-
<p>
|
56 |
-
If you are experiencing problems with the Unbounce Pages plugin, or if the problem
|
57 |
-
continues to persist after all checks have passed, please email the following details
|
58 |
-
to <a href="mailto:support@unbounce.com">support@unbounce.com</a>. If possible,
|
59 |
-
please also provide details on your hosting provider.
|
60 |
-
</p>
|
61 |
<textarea id="ub-diagnostics-text" rows="10" cols="100">
|
62 |
<?php
|
63 |
|
1 |
<?php
|
2 |
|
3 |
+
$domain_is_authorized = "<p>The plugin is not able to verify that your domain ({$domain}) is added to your account in Unbounce.</p>
|
4 |
+
<p>Possible causes:</p>
|
5 |
+
<ul class=\"causes\">
|
6 |
+
<li>Log in & out of Unbounce. It s possible that your session has expired</li>
|
7 |
+
<li>Domain is not added in Unbounce account you are using to authorize. Make sure that the domain is present in a client you are the owner or administrator for.</li>
|
8 |
+
<li>Domain in Unbounce does not match WP configured domain (i.e. has, or does not have www.). The domain listed in Unbounce must match the WP domain exactly, so if it is configured to be www.domain.com, then that should be what is listed in the domain portion of your Unbounce account.</li>
|
9 |
+
<li>In order to connect with Unbounce, we need to validate the cert for wp.unbounce.com. Please make sure that your CA Cert file is up to date, as an out of date CA Cert file can cause the connection to fail</li>
|
10 |
+
</ul>
|
11 |
+
For more troubleshooting information please read our <a href=\"https://documentation.unbounce.com/hc/en-us/articles/360000393623-Troubleshooting-WordPress-Plugin-Technical-Issues\" target=\"_blank\">Support Article</a>";
|
12 |
+
|
13 |
+
$can_fetch_page_listing = "<p>We are unable to fetch the page listing from Unbounce, there are a few possible reasons for this issue.</p>
|
14 |
+
<ul class=\"causes\">
|
15 |
+
<li>Occasionally the domain in Unbounce can be added improperly, and sitemap file does not exist on our servers. To fix this issue simply remove & re-add the domain in Unbounce.</li>
|
16 |
+
<li>Your plugin may need to re-authorize with Unbounce, try clicking the \"Update Published Page List\". This will trigger an attempt to re-authorize with Unbounce.</li>
|
17 |
+
<li>If your WP install is behind a proxy or a firewall, then the Unbounce WP Plugin might have difficulty connecting with the Unbounce servers. Please see our troubleshooting documentation linked below for additional information</li>
|
18 |
+
<li>The plugin uses cURL in order to fetch the published page list. Ensure that your server has php-curl installed. You may need to ask your hosting provider for support.</li>
|
19 |
+
</ul>
|
20 |
+
|
21 |
+
<p>For more troubleshooting information please read our <a href=\"https://documentation.unbounce.com/hc/en-us/articles/360000393623-Troubleshooting-WordPress-Plugin-Technical-Issues\" target=\"_blank\">Support Article</a></p>";
|
22 |
+
|
23 |
+
$curl_support = '<p>The Unbounce Plugin uses cURL to fetch page listing information. Either the version of cURL installed is not supported, or the php-curl extension is not installed.</p>
|
24 |
+
<p>Please ensure that cURL has been properly configured on your server.</p>';
|
25 |
+
|
26 |
+
$xml_support = '<p>The Unbounce Plugin requires that the php-xml extension be installed. We parse xml in order to determine what pages should be served by Unbounce</p>
|
27 |
+
<p>Please ensure that your server has php-xml installed.</p>';
|
28 |
+
|
29 |
+
$permalink_structure = "<p>By default WordPress uses web URLs which have question marks and lots of numbers in them; however, this default structure will not work with the Unbounce Plugin. </p>
|
30 |
+
|
31 |
+
<p>Please update your <a href=\"{$permalink_url}\" target=\"_blank\">WordPress Permalink Structure</a> (link to: yourdomain.com/wp-admin/options-permalink) and change to anything other than the default WordPress setting.</p>";
|
32 |
+
|
33 |
+
$supported_php_version = 'The Unbounce Pages plugin is supported when using PHP version 5.3 or higher, please contact your hosting provider or IT professional and update to a supported version.';
|
34 |
+
|
35 |
+
$supported_wordpress_version = 'The Unbounce Pages plugin is supported on WordPress versions 4.0 and higher, please contact your hosting provider or IT professional and update to a supported version.';
|
36 |
+
|
37 |
+
$sni_support = 'The Unbounce Plugin communicates with the Unbounce servers using a TLS 1.2 connection, this requires SNI support in order to function. Our diagnostics indicate that your server does not currently have SNI support.';
|
38 |
+
|
39 |
$diagnostic_descriptions = array(
|
40 |
+
'Curl Support' => $curl_support,
|
41 |
+
'XML Support' => $xml_support,
|
42 |
+
'Permalink Structure' => $permalink_structure,
|
43 |
+
'Domain is Authorized' => $domain_is_authorized,
|
44 |
+
'Can Fetch Page Listing' => $can_fetch_page_listing,
|
45 |
+
'Supported PHP Version' => $supported_php_version,
|
46 |
+
'Supported Wordpress Version' => $supported_wordpress_version,
|
47 |
+
'SNI Support' => $sni_support
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
);
|
49 |
|
50 |
?>
|
51 |
+
|
52 |
<div class="ub-plugin-wrapper">
|
53 |
<img class="ub-logo" src="<?php echo $img_url; ?>" />
|
54 |
<h1 class="ub-unbounce-pages-heading">Unbounce Pages Diagnostics</h1>
|
74 |
<?php endforeach; ?>
|
75 |
</ul>
|
76 |
|
77 |
+
<h2>Troubleshooting Information</h2>
|
78 |
+
<p>There are a number of known issues with the Unbounce WP Plugin, with different possible causes.</p>
|
79 |
+
|
80 |
+
<div class="info">
|
81 |
+
<h2>Known issues:</h2>
|
82 |
+
<ul class="causes">
|
83 |
+
<li>Unbounce Pages 404ing</li>
|
84 |
+
<li> Unbounce Pages are not tracking stats</li>
|
85 |
+
<li>Form Confirmation Dialog isn't loading</li>
|
86 |
+
<li>Lightboxes aren't loading</li>
|
87 |
+
<li>Buttons (clkn/clkg) links do not redirect properly</li>
|
88 |
+
<li>Domain Directory in Unbounce says "Plugin Setup Required"</li>
|
89 |
+
<li>Seeing Protected Assets after form submission</li>
|
90 |
+
</ul>
|
91 |
+
|
92 |
+
|
93 |
+
<p>Each of the above issues are usually a configuration issue. Please read through our <a href="https://documentation.unbounce.com/hc/en-us/articles/360000393623-Troubleshooting-WordPress-Plugin-Technical-Issues" target="_blank">Troubleshooting Documentation</a> to address each symptom.</p>
|
94 |
+
</div>
|
95 |
+
|
96 |
+
<div class="info">
|
97 |
+
<h2>Known Incompatible Plugins:</h2>
|
98 |
+
|
99 |
+
<p>Check that you don’t have any caching plugins installed, or any plugins that affect the order in which Javascript is loaded. These types of plugins will affect how Unbounce pages behave on WordPress.</p>
|
100 |
+
<ul class="causes">
|
101 |
+
<li>wp-rocket - This plugin re-orders script tags in the <head> which break how Javascript Loads.</li>
|
102 |
+
<li>wp-super-cache - caching plugins often cause Unbounce pages to 404</li>
|
103 |
+
<li>wp-total-cache - caching plugins often cause Unbounce pages to 404</li>
|
104 |
+
<li>Cloudflare - caching plugins often cause Unbounce pages to 404</li>
|
105 |
+
</ul>
|
106 |
+
<p>Please see our <a href="https://documentation.unbounce.com/hc/en-us/articles/360000393623-Troubleshooting-WordPress-Plugin-Technical-Issues" target="_blank">Support Documentation</a> for troubleshooting.</p>
|
107 |
+
</div>
|
108 |
+
|
109 |
+
<div class="info">
|
110 |
+
<h2>Still having issues? Contact our support team</h2>
|
111 |
+
<p>If you are experiencing problems with the Unbounce Pages plugin after attempting to troubleshoot the issue, please reach out to our support team at <em>support@unbounce.com</em>.</p>
|
112 |
+
<p>Please make sure to include the details below, and if possible, please also provide details on your hosting provider.</p>
|
113 |
+
</div>
|
114 |
+
|
115 |
<h2>Details</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
<textarea id="ub-diagnostics-text" rows="10" cols="100">
|
117 |
<?php
|
118 |
|
templates/main_authorized_footer.php
CHANGED
@@ -14,11 +14,11 @@ $refresh_button = get_submit_button('refreshing the Published Pages list', 'seco
|
|
14 |
If they are still not appearing, double check that your Unbounce pages are using a Wordpress domain.
|
15 |
</p>
|
16 |
</form>
|
17 |
-
<a href="
|
18 |
Check out our knowledge base.
|
19 |
</a>
|
20 |
<br/>
|
21 |
<a class="ub-diagnostics-link" href="<?php echo $diagnostics_url ?>">
|
22 |
Click here for troubleshooting and plugin diagnostics
|
23 |
</a>
|
24 |
-
<p class="ub-version">Unbounce Version 1.0.
|
14 |
If they are still not appearing, double check that your Unbounce pages are using a Wordpress domain.
|
15 |
</p>
|
16 |
</form>
|
17 |
+
<a href="https://documentation.unbounce.com/hc/en-us/articles/360000393623-Troubleshooting-WordPress-Plugin-Technical-Issues" target="_blank">
|
18 |
Check out our knowledge base.
|
19 |
</a>
|
20 |
<br/>
|
21 |
<a class="ub-diagnostics-link" href="<?php echo $diagnostics_url ?>">
|
22 |
Click here for troubleshooting and plugin diagnostics
|
23 |
</a>
|
24 |
+
<p class="ub-version">Unbounce Version 1.0.37</p>
|
templates/main_unauthorized_footer.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
<a href="
|
2 |
target="_blank">Check out our knowledge base.</a>
|
3 |
<br/>
|
4 |
<a class="ub-diagnostics-link" href="<?php echo admin_url('admin.php?page=unbounce-pages-diagnostics'); ?>">
|
5 |
Click here for troubleshooting and plugin diagnostics
|
6 |
</a>
|
7 |
-
<p class="ub-version">Unbounce Version 1.0.
|
1 |
+
<a href="https://documentation.unbounce.com/hc/en-us/articles/360000393623-Troubleshooting-WordPress-Plugin-Technical-Issues"
|
2 |
target="_blank">Check out our knowledge base.</a>
|
3 |
<br/>
|
4 |
<a class="ub-diagnostics-link" href="<?php echo admin_url('admin.php?page=unbounce-pages-diagnostics'); ?>">
|
5 |
Click here for troubleshooting and plugin diagnostics
|
6 |
</a>
|
7 |
+
<p class="ub-version">Unbounce Version 1.0.37</p>
|
trunk/UBCompatibility.php
DELETED
@@ -1,152 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// taken from: http://php.net/manual/en/function.http-response-code.php
|
4 |
-
// For 4.3.0 <= PHP <= 5.4.0
|
5 |
-
if (!function_exists('http_response_code')) {
|
6 |
-
function http_response_code($code = null)
|
7 |
-
{
|
8 |
-
|
9 |
-
if ($code !== null) {
|
10 |
-
switch ($code) {
|
11 |
-
case 100:
|
12 |
-
$text = 'Continue';
|
13 |
-
break;
|
14 |
-
case 101:
|
15 |
-
$text = 'Switching Protocols';
|
16 |
-
break;
|
17 |
-
case 200:
|
18 |
-
$text = 'OK';
|
19 |
-
break;
|
20 |
-
case 201:
|
21 |
-
$text = 'Created';
|
22 |
-
break;
|
23 |
-
case 202:
|
24 |
-
$text = 'Accepted';
|
25 |
-
break;
|
26 |
-
case 203:
|
27 |
-
$text = 'Non-Authoritative Information';
|
28 |
-
break;
|
29 |
-
case 204:
|
30 |
-
$text = 'No Content';
|
31 |
-
break;
|
32 |
-
case 205:
|
33 |
-
$text = 'Reset Content';
|
34 |
-
break;
|
35 |
-
case 206:
|
36 |
-
$text = 'Partial Content';
|
37 |
-
break;
|
38 |
-
case 300:
|
39 |
-
$text = 'Multiple Choices';
|
40 |
-
break;
|
41 |
-
case 301:
|
42 |
-
$text = 'Moved Permanently';
|
43 |
-
break;
|
44 |
-
case 302:
|
45 |
-
$text = 'Moved Temporarily';
|
46 |
-
break;
|
47 |
-
case 303:
|
48 |
-
$text = 'See Other';
|
49 |
-
break;
|
50 |
-
case 304:
|
51 |
-
$text = 'Not Modified';
|
52 |
-
break;
|
53 |
-
case 305:
|
54 |
-
$text = 'Use Proxy';
|
55 |
-
break;
|
56 |
-
case 400:
|
57 |
-
$text = 'Bad Request';
|
58 |
-
break;
|
59 |
-
case 401:
|
60 |
-
$text = 'Unauthorized';
|
61 |
-
break;
|
62 |
-
case 402:
|
63 |
-
$text = 'Payment Required';
|
64 |
-
break;
|
65 |
-
case 403:
|
66 |
-
$text = 'Forbidden';
|
67 |
-
break;
|
68 |
-
case 404:
|
69 |
-
$text = 'Not Found';
|
70 |
-
break;
|
71 |
-
case 405:
|
72 |
-
$text = 'Method Not Allowed';
|
73 |
-
break;
|
74 |
-
case 406:
|
75 |
-
$text = 'Not Acceptable';
|
76 |
-
break;
|
77 |
-
case 407:
|
78 |
-
$text = 'Proxy Authentication Required';
|
79 |
-
break;
|
80 |
-
case 408:
|
81 |
-
$text = 'Request Time-out';
|
82 |
-
break;
|
83 |
-
case 409:
|
84 |
-
$text = 'Conflict';
|
85 |
-
break;
|
86 |
-
case 410:
|
87 |
-
$text = 'Gone';
|
88 |
-
break;
|
89 |
-
case 411:
|
90 |
-
$text = 'Length Required';
|
91 |
-
break;
|
92 |
-
case 412:
|
93 |
-
$text = 'Precondition Failed';
|
94 |
-
break;
|
95 |
-
case 413:
|
96 |
-
$text = 'Request Entity Too Large';
|
97 |
-
break;
|
98 |
-
case 414:
|
99 |
-
$text = 'Request-URI Too Large';
|
100 |
-
break;
|
101 |
-
case 415:
|
102 |
-
$text = 'Unsupported Media Type';
|
103 |
-
break;
|
104 |
-
case 500:
|
105 |
-
$text = 'Internal Server Error';
|
106 |
-
break;
|
107 |
-
case 501:
|
108 |
-
$text = 'Not Implemented';
|
109 |
-
break;
|
110 |
-
case 502:
|
111 |
-
$text = 'Bad Gateway';
|
112 |
-
break;
|
113 |
-
case 503:
|
114 |
-
$text = 'Service Unavailable';
|
115 |
-
break;
|
116 |
-
case 504:
|
117 |
-
$text = 'Gateway Time-out';
|
118 |
-
break;
|
119 |
-
case 505:
|
120 |
-
$text = 'HTTP Version not supported';
|
121 |
-
break;
|
122 |
-
default:
|
123 |
-
exit('Unknown http status code "' . htmlentities($code) . '"');
|
124 |
-
break;
|
125 |
-
}
|
126 |
-
|
127 |
-
$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1');
|
128 |
-
|
129 |
-
header($protocol . ' ' . $code . ' ' . $text);
|
130 |
-
|
131 |
-
$GLOBALS['http_response_code'] = $code;
|
132 |
-
} else {
|
133 |
-
$code = (isset($GLOBALS['http_response_code']) ? $GLOBALS['http_response_code'] : 200);
|
134 |
-
}
|
135 |
-
|
136 |
-
return $code;
|
137 |
-
}
|
138 |
-
}
|
139 |
-
|
140 |
-
// taken from: http://php.net/manual/en/function.getallheaders.php
|
141 |
-
if (!function_exists('getallheaders')) {
|
142 |
-
function getallheaders()
|
143 |
-
{
|
144 |
-
$headers = array();
|
145 |
-
foreach ($_SERVER as $name => $value) {
|
146 |
-
if (substr($name, 0, 5) == 'HTTP_') {
|
147 |
-
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
|
148 |
-
}
|
149 |
-
}
|
150 |
-
return $headers;
|
151 |
-
}
|
152 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBConfig.php
DELETED
@@ -1,416 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class UBConfig
|
4 |
-
{
|
5 |
-
|
6 |
-
const UB_PLUGIN_NAME = 'ub-wordpress';
|
7 |
-
const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
|
8 |
-
const UB_USER_AGENT = 'Unbounce WP Plugin 1.0.36';
|
9 |
-
const UB_VERSION = '1.0.36';
|
10 |
-
|
11 |
-
// Option keys
|
12 |
-
const UB_ROUTES_CACHE_KEY = 'ub-route-cache';
|
13 |
-
const UB_REMOTE_DEBUG_KEY = 'ub-remote-debug';
|
14 |
-
const UB_PAGE_SERVER_DOMAIN_KEY = 'ub-page-server-domain';
|
15 |
-
const UB_REMOTE_LOG_URL_KEY = 'ub-remote-log-url';
|
16 |
-
const UB_REMOTE_EVENTS_URL_KEY = 'ub-remote-events-url';
|
17 |
-
const UB_API_URL_KEY = 'ub-api-url';
|
18 |
-
const UB_API_CLIENT_ID_KEY = 'ub-api-client-id';
|
19 |
-
const UB_AUTHORIZED_DOMAINS_KEY = 'ub-authorized-domains';
|
20 |
-
const UB_HAS_AUTHORIZED_KEY = 'ub-has-authorized';
|
21 |
-
const UB_USER_ID_KEY = 'ub-user-id';
|
22 |
-
const UB_DOMAIN_ID_KEY = 'ub-domain-id';
|
23 |
-
const UB_CLIENT_ID_KEY = 'ub-client-id';
|
24 |
-
const UB_PROXY_ERROR_MESSAGE_KEY = 'ub-proxy-error-message';
|
25 |
-
const UB_ALLOW_PUBLIC_ADDRESS_X_FORWARDED_FOR = 'ub-allow-public-address-x-forwarded-for';
|
26 |
-
const UB_PLUGIN_VERSION_KEY = 'ub-plugin-version';
|
27 |
-
|
28 |
-
const UB_LOCK_NAME = 'ub-sql-lock';
|
29 |
-
|
30 |
-
public static function ub_option_keys()
|
31 |
-
{
|
32 |
-
// All options, used by UBDiagnostics and deactivation hook
|
33 |
-
// Arrays are not allowed in class constants, so use a function
|
34 |
-
return array(
|
35 |
-
UBConfig::UB_ROUTES_CACHE_KEY,
|
36 |
-
UBConfig::UB_REMOTE_DEBUG_KEY,
|
37 |
-
UBConfig::UB_PAGE_SERVER_DOMAIN_KEY,
|
38 |
-
UBConfig::UB_REMOTE_LOG_URL_KEY,
|
39 |
-
UBConfig::UB_REMOTE_EVENTS_URL_KEY,
|
40 |
-
UBConfig::UB_API_URL_KEY,
|
41 |
-
UBConfig::UB_API_CLIENT_ID_KEY,
|
42 |
-
UBConfig::UB_AUTHORIZED_DOMAINS_KEY,
|
43 |
-
UBConfig::UB_HAS_AUTHORIZED_KEY,
|
44 |
-
UBConfig::UB_USER_ID_KEY,
|
45 |
-
UBConfig::UB_DOMAIN_ID_KEY,
|
46 |
-
UBConfig::UB_CLIENT_ID_KEY,
|
47 |
-
UBConfig::UB_PROXY_ERROR_MESSAGE_KEY,
|
48 |
-
UBConfig::UB_ALLOW_PUBLIC_ADDRESS_X_FORWARDED_FOR
|
49 |
-
);
|
50 |
-
}
|
51 |
-
|
52 |
-
public static function default_page_server_domain()
|
53 |
-
{
|
54 |
-
$domain = getenv('UB_PAGE_SERVER_DOMAIN');
|
55 |
-
return $domain ? $domain : 'wp.unbounce.com';
|
56 |
-
}
|
57 |
-
|
58 |
-
public static function default_remote_log_url()
|
59 |
-
{
|
60 |
-
$url = getenv('UB_REMOTE_LOG_URL');
|
61 |
-
if ($url == null) {
|
62 |
-
return 'https://events-gateway.unbounce.com/events/wordpress_logs';
|
63 |
-
}
|
64 |
-
return $url;
|
65 |
-
}
|
66 |
-
|
67 |
-
public static function default_remote_events_url()
|
68 |
-
{
|
69 |
-
$url = getenv('UB_REMOTE_EVENTS_URL');
|
70 |
-
if ($url == null) {
|
71 |
-
return 'https://events-gateway.unbounce.com/events/domains';
|
72 |
-
}
|
73 |
-
return $url;
|
74 |
-
}
|
75 |
-
|
76 |
-
public static function default_api_url()
|
77 |
-
{
|
78 |
-
$url = getenv('UB_API_URL');
|
79 |
-
return $url ? $url : 'https://api.unbounce.com';
|
80 |
-
}
|
81 |
-
|
82 |
-
public static function default_api_client_id()
|
83 |
-
{
|
84 |
-
$client_id = getenv('UB_API_CLIENT_ID');
|
85 |
-
return $client_id ? $client_id : '660a311881321b9d4e777993e50875dec5da9cc4ef44369d121544b21da52b92';
|
86 |
-
}
|
87 |
-
|
88 |
-
public static function default_authorized_domains()
|
89 |
-
{
|
90 |
-
$domains = getenv('UB_AUTHORIZED_DOMAINS');
|
91 |
-
return $domains ? explode(',', $domains) : array();
|
92 |
-
}
|
93 |
-
|
94 |
-
public static function page_server_domain()
|
95 |
-
{
|
96 |
-
return get_option(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY, UBConfig::default_page_server_domain());
|
97 |
-
}
|
98 |
-
|
99 |
-
public static function remote_log_url()
|
100 |
-
{
|
101 |
-
return get_option(UBConfig::UB_REMOTE_LOG_URL_KEY, UBConfig::default_remote_log_url());
|
102 |
-
}
|
103 |
-
|
104 |
-
public static function remote_events_url()
|
105 |
-
{
|
106 |
-
return get_option(UBConfig::UB_REMOTE_EVENTS_URL_KEY, UBConfig::default_remote_events_url());
|
107 |
-
}
|
108 |
-
|
109 |
-
public static function api_url()
|
110 |
-
{
|
111 |
-
return get_option(UBConfig::UB_API_URL_KEY, UBConfig::default_api_url());
|
112 |
-
}
|
113 |
-
|
114 |
-
public static function api_client_id()
|
115 |
-
{
|
116 |
-
return get_option(UBConfig::UB_API_CLIENT_ID_KEY, UBConfig::default_api_client_id());
|
117 |
-
}
|
118 |
-
|
119 |
-
public static function authorized_domains()
|
120 |
-
{
|
121 |
-
return get_option(UBConfig::UB_AUTHORIZED_DOMAINS_KEY, UBConfig::default_authorized_domains());
|
122 |
-
}
|
123 |
-
|
124 |
-
public static function has_authorized()
|
125 |
-
{
|
126 |
-
return (bool) get_option(UBConfig::UB_HAS_AUTHORIZED_KEY);
|
127 |
-
}
|
128 |
-
|
129 |
-
public static function debug_loggging_enabled()
|
130 |
-
{
|
131 |
-
return (defined('UB_ENABLE_LOCAL_LOGGING') && UB_ENABLE_LOCAL_LOGGING) || self::remote_debug_logging_enabled();
|
132 |
-
}
|
133 |
-
|
134 |
-
public static function remote_debug_logging_enabled()
|
135 |
-
{
|
136 |
-
return get_option(UBConfig::UB_REMOTE_DEBUG_KEY, 0) == 1;
|
137 |
-
}
|
138 |
-
|
139 |
-
public static function allow_public_address_x_forwarded_for()
|
140 |
-
{
|
141 |
-
return get_option(UBConfig::UB_ALLOW_PUBLIC_ADDRESS_X_FORWARDED_FOR, 0) == 1;
|
142 |
-
}
|
143 |
-
|
144 |
-
public static function create_none_response()
|
145 |
-
{
|
146 |
-
return array(array('status' => 'NONE'), null, null, null);
|
147 |
-
}
|
148 |
-
|
149 |
-
public static function create_same_response($etag, $max_age)
|
150 |
-
{
|
151 |
-
return array(array('status' => 'SAME'), $etag, $max_age, null);
|
152 |
-
}
|
153 |
-
|
154 |
-
public static function create_new_response($etag, $max_age, $proxyable_url_set)
|
155 |
-
{
|
156 |
-
return array(array('status' => 'NEW'), $etag, $max_age, $proxyable_url_set);
|
157 |
-
}
|
158 |
-
|
159 |
-
public static function create_failure_response($failure_message)
|
160 |
-
{
|
161 |
-
return array(array('status' => 'FAILURE',
|
162 |
-
'failure_message' => $failure_message),
|
163 |
-
null, null, null);
|
164 |
-
}
|
165 |
-
|
166 |
-
public static function domain()
|
167 |
-
{
|
168 |
-
return parse_url(get_home_url(), PHP_URL_HOST);
|
169 |
-
}
|
170 |
-
|
171 |
-
public static function domain_with_port()
|
172 |
-
{
|
173 |
-
$port = parse_url(get_home_url(), PHP_URL_PORT);
|
174 |
-
$host = parse_url(get_home_url(), PHP_URL_HOST);
|
175 |
-
if ($port) {
|
176 |
-
return $host . ':' . $port;
|
177 |
-
} else {
|
178 |
-
return $host;
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
public static function fetch_proxyable_url_set($domain, $etag, $ps_domain)
|
183 |
-
{
|
184 |
-
if (!$domain) {
|
185 |
-
$failure_message = 'Domain not provided, not fetching sitemap.xml';
|
186 |
-
UBLogger::warning($failure_message);
|
187 |
-
return UBConfig::create_failure_response($failure_message);
|
188 |
-
}
|
189 |
-
|
190 |
-
try {
|
191 |
-
$url = 'https://' . $ps_domain . '/sitemap.xml';
|
192 |
-
$curl = curl_init();
|
193 |
-
$curl_options = array(
|
194 |
-
CURLOPT_URL => $url,
|
195 |
-
CURLOPT_CUSTOMREQUEST => "GET",
|
196 |
-
CURLOPT_HEADER => true,
|
197 |
-
CURLOPT_USERAGENT => UBConfig::UB_USER_AGENT,
|
198 |
-
CURLOPT_HTTPHEADER => array('Host: ' . $domain, 'If-None-Match: ' . $etag),
|
199 |
-
CURLOPT_RETURNTRANSFER => true,
|
200 |
-
CURLOPT_FOLLOWLOCATION => false,
|
201 |
-
CURLOPT_TIMEOUT => 5
|
202 |
-
);
|
203 |
-
|
204 |
-
UBLogger::debug("Retrieving routes from '$url', etag: '$etag', host: '$domain'");
|
205 |
-
|
206 |
-
curl_setopt_array($curl, $curl_options);
|
207 |
-
$data = curl_exec($curl);
|
208 |
-
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
209 |
-
$header_size = strlen($data) - curl_getinfo($curl, CURLINFO_SIZE_DOWNLOAD);
|
210 |
-
$curl_error = null;
|
211 |
-
$etag = null;
|
212 |
-
$max_age = null;
|
213 |
-
|
214 |
-
// when having an CURL error, http_code is 0
|
215 |
-
if ($http_code == 0) {
|
216 |
-
$curl_error = curl_error($curl);
|
217 |
-
}
|
218 |
-
|
219 |
-
curl_close($curl);
|
220 |
-
|
221 |
-
$headers = substr($data, 0, $header_size);
|
222 |
-
|
223 |
-
$matches = array();
|
224 |
-
$does_match = preg_match('/ETag: (\S+)/is', $headers, $matches);
|
225 |
-
if ($does_match) {
|
226 |
-
$etag = $matches[1];
|
227 |
-
}
|
228 |
-
|
229 |
-
$matches = array();
|
230 |
-
$does_match = preg_match('/Cache-Control: max-age=(\S+)/is', $headers, $matches);
|
231 |
-
if ($does_match) {
|
232 |
-
$max_age = $matches[1];
|
233 |
-
}
|
234 |
-
|
235 |
-
if ($http_code == 200) {
|
236 |
-
$body = substr($data, $header_size);
|
237 |
-
list($success, $result) = UBConfig::url_list_from_sitemap($body);
|
238 |
-
|
239 |
-
if ($success) {
|
240 |
-
UBLogger::debug("Retrieved new routes, HTTP code: '$http_code'");
|
241 |
-
return UBConfig::create_new_response($etag, $max_age, $result);
|
242 |
-
} else {
|
243 |
-
$errors = join(', ', $result);
|
244 |
-
$failure_message = "An error occurred while processing pages, XML errors: '$errors'";
|
245 |
-
UBLogger::warning($failure_message);
|
246 |
-
return UBConfig::create_failure_response($failure_message);
|
247 |
-
}
|
248 |
-
}
|
249 |
-
if ($http_code == 304) {
|
250 |
-
UBLogger::debug("Routes have not changed, HTTP code: '$http_code'");
|
251 |
-
return UBConfig::create_same_response($etag, $max_age);
|
252 |
-
}
|
253 |
-
if ($http_code == 404) {
|
254 |
-
UBLogger::debug("No routes to retrieve, HTTP code: '$http_code'");
|
255 |
-
return UBConfig::create_none_response();
|
256 |
-
} else {
|
257 |
-
$failure_message = "An error occurred while retrieving routes;
|
258 |
-
HTTP code: '$http_code';
|
259 |
-
Error: " . $curl_error;
|
260 |
-
UBLogger::warning($failure_message);
|
261 |
-
return UBConfig::create_failure_response($failure_message);
|
262 |
-
}
|
263 |
-
} catch (Exception $e) {
|
264 |
-
$failure_message = "An error occurred while retrieving routes; Error: " . $e;
|
265 |
-
UBLogger::warning($failure_message);
|
266 |
-
return UBConfig::create_failure_response($failure_message);
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
public static function url_list_from_sitemap($string)
|
271 |
-
{
|
272 |
-
if (is_null($string)) {
|
273 |
-
return array(false, array('input is null'));
|
274 |
-
}
|
275 |
-
|
276 |
-
if (!UBDiagnostics::is_xml_installed()) {
|
277 |
-
return array(false, array('xml extension is not installed'));
|
278 |
-
}
|
279 |
-
|
280 |
-
$use_internal_errors = libxml_use_internal_errors(true);
|
281 |
-
$sitemap = simplexml_load_string($string);
|
282 |
-
|
283 |
-
if ($sitemap !== false) {
|
284 |
-
libxml_use_internal_errors($use_internal_errors);
|
285 |
-
$urls = array();
|
286 |
-
|
287 |
-
// Valid XML that is not a valid sitemap.xml will be considered an empty sitemap.xml.
|
288 |
-
// We have no easy way to tell the difference between the two.
|
289 |
-
if (isset($sitemap->url)) {
|
290 |
-
foreach ($sitemap->url as $sitemap_url) {
|
291 |
-
if (isset($sitemap_url->loc)) {
|
292 |
-
$url = (string) $sitemap_url->loc;
|
293 |
-
// URLs come in with protocol and trailing slash, we need just host and path with no
|
294 |
-
// trailing slash internally.
|
295 |
-
$urls[] = parse_url($url, PHP_URL_HOST) . rtrim(parse_url($url, PHP_URL_PATH), '/');
|
296 |
-
}
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
return array(true, $urls);
|
301 |
-
} else {
|
302 |
-
// libXMLError has no default tostring, use print_r to get a string representation of it
|
303 |
-
$errors = array_map(function ($error) {
|
304 |
-
return print_r($error, true);
|
305 |
-
}, libxml_get_errors());
|
306 |
-
// Return what we tried to parse for debugging
|
307 |
-
$errors[] = "XML content: ${string}";
|
308 |
-
libxml_use_internal_errors($use_internal_errors);
|
309 |
-
return array(false, $errors);
|
310 |
-
}
|
311 |
-
}
|
312 |
-
|
313 |
-
public static function read_unbounce_domain_info($domain, $expire_now = false)
|
314 |
-
{
|
315 |
-
// Bail out if curl is not installed to prevent fatal error
|
316 |
-
if (!UBDiagnostics::is_curl_installed()) {
|
317 |
-
return array();
|
318 |
-
}
|
319 |
-
|
320 |
-
$proxyable_url_set = null;
|
321 |
-
$cache_max_time_default = 10;
|
322 |
-
|
323 |
-
$ps_domain = get_option(UBConfig::UB_PAGE_SERVER_DOMAIN_KEY, UBConfig::default_page_server_domain());
|
324 |
-
$domains_info = get_option(UBConfig::UB_ROUTES_CACHE_KEY, array());
|
325 |
-
|
326 |
-
if (!is_array($domains_info)) {
|
327 |
-
// This is a regression from BEE-878. We aren't sure why the data could be corrupted.
|
328 |
-
$domains_info = array();
|
329 |
-
}
|
330 |
-
|
331 |
-
$domain_info = UBUtil::array_fetch($domains_info, $domain, array());
|
332 |
-
|
333 |
-
$proxyable_url_set = UBUtil::array_fetch($domain_info, 'proxyable_url_set');
|
334 |
-
$proxyable_url_set_fetched_at = UBUtil::array_fetch($domain_info, 'proxyable_url_set_fetched_at');
|
335 |
-
$proxyable_url_set_cache_timeout = UBUtil::array_fetch($domain_info, 'proxyable_url_set_cache_timeout');
|
336 |
-
$proxyable_url_set_etag = UBUtil::array_fetch($domain_info, 'proxyable_url_set_etag');
|
337 |
-
|
338 |
-
$cache_max_time = is_null($proxyable_url_set_cache_timeout) ?
|
339 |
-
$cache_max_time_default :
|
340 |
-
$proxyable_url_set_cache_timeout;
|
341 |
-
|
342 |
-
$current_time = time();
|
343 |
-
|
344 |
-
if ($expire_now ||
|
345 |
-
is_null($proxyable_url_set) ||
|
346 |
-
($current_time - $proxyable_url_set_fetched_at > $cache_max_time)) {
|
347 |
-
try {
|
348 |
-
$can_fetch = UBUtil::get_lock();
|
349 |
-
UBLogger::debug('Locking: ' . $can_fetch);
|
350 |
-
|
351 |
-
if ($can_fetch) {
|
352 |
-
$result_array = UBConfig::fetch_proxyable_url_set($domain, $proxyable_url_set_etag, $ps_domain);
|
353 |
-
|
354 |
-
list($routes_status, $etag, $max_age, $proxyable_url_set_new) = $result_array;
|
355 |
-
|
356 |
-
if ($routes_status['status'] == 'NEW') {
|
357 |
-
$domain_info['proxyable_url_set'] = $proxyable_url_set_new;
|
358 |
-
$domain_info['proxyable_url_set_etag'] = $etag;
|
359 |
-
$domain_info['proxyable_url_set_cache_timeout'] = $max_age;
|
360 |
-
} elseif ($routes_status['status'] == 'SAME') {
|
361 |
-
// Just extend the cache
|
362 |
-
$domain_info['proxyable_url_set_cache_timeout'] = $max_age;
|
363 |
-
} elseif ($routes_status['status'] == 'NONE') {
|
364 |
-
$domain_info['proxyable_url_set'] = array();
|
365 |
-
$domain_info['proxyable_url_set_etag'] = null;
|
366 |
-
} elseif ($routes_status['status'] == 'FAILURE') {
|
367 |
-
UBLogger::warning('Route fetching failed');
|
368 |
-
} else {
|
369 |
-
UBLogger::warning("Unknown response from route fetcher: '$routes_status'");
|
370 |
-
}
|
371 |
-
|
372 |
-
// Creation of domain_info entry
|
373 |
-
$domain_info['proxyable_url_set_fetched_at'] = $current_time;
|
374 |
-
$domain_info['last_status'] = $routes_status['status'];
|
375 |
-
if ($routes_status['status'] == 'FAILURE') {
|
376 |
-
$domain_info['failure_message'] = $routes_status['failure_message'];
|
377 |
-
}
|
378 |
-
$domains_info[$domain] = $domain_info;
|
379 |
-
// set autoload to false so that options are always loaded from DB
|
380 |
-
update_option(UBConfig::UB_ROUTES_CACHE_KEY, $domains_info, false);
|
381 |
-
}
|
382 |
-
} catch (Exception $e) {
|
383 |
-
UBLogger::warning('Could not update sitemap: ' . $e);
|
384 |
-
}
|
385 |
-
|
386 |
-
$release_result = UBUtil::release_lock();
|
387 |
-
UBLogger::debug('Unlocking: ' . $release_result);
|
388 |
-
}
|
389 |
-
|
390 |
-
return UBUtil::array_select_by_key(
|
391 |
-
$domain_info,
|
392 |
-
array('proxyable_url_set', 'proxyable_url_set_fetched_at', 'failure_message', 'last_status')
|
393 |
-
);
|
394 |
-
}
|
395 |
-
|
396 |
-
public static function is_authorized_domain($domain0)
|
397 |
-
{
|
398 |
-
$pieces = explode(':', $domain0);
|
399 |
-
$domain = $pieces[0];
|
400 |
-
return in_array($domain, UBConfig::authorized_domains());
|
401 |
-
}
|
402 |
-
|
403 |
-
public static function update_authorization_options($domains, $data)
|
404 |
-
{
|
405 |
-
update_option(UBConfig::UB_USER_ID_KEY, $data['user_id']);
|
406 |
-
update_option(UBConfig::UB_DOMAIN_ID_KEY, $data['domain_id']);
|
407 |
-
update_option(UBConfig::UB_CLIENT_ID_KEY, $data['client_id']);
|
408 |
-
update_option(UBConfig::UB_AUTHORIZED_DOMAINS_KEY, $domains);
|
409 |
-
update_option(UBConfig::UB_HAS_AUTHORIZED_KEY, true);
|
410 |
-
}
|
411 |
-
|
412 |
-
public static function int_min()
|
413 |
-
{
|
414 |
-
return (PHP_INT_MAX * -1) - 1;
|
415 |
-
}
|
416 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBDiagnostics.php
DELETED
@@ -1,221 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class UBDiagnostics
|
4 |
-
{
|
5 |
-
const SUPPORTED_PHP_VERSION = '5.3';
|
6 |
-
const SUPPORTED_WP_VERSION = '4.0';
|
7 |
-
|
8 |
-
public static function checks($domain, $domain_info)
|
9 |
-
{
|
10 |
-
return array_merge(self::domain_checks($domain, $domain_info), self::system_checks());
|
11 |
-
}
|
12 |
-
|
13 |
-
public static function domain_checks($domain, $domain_info)
|
14 |
-
{
|
15 |
-
return array(
|
16 |
-
'Domain is Authorized' => UBConfig::is_authorized_domain($domain),
|
17 |
-
'Can Fetch Page Listing' => UBDiagnostics::last_status_success($domain_info),
|
18 |
-
);
|
19 |
-
}
|
20 |
-
|
21 |
-
public static function system_checks()
|
22 |
-
{
|
23 |
-
return array(
|
24 |
-
'Curl Support' => self::is_curl_installed(),
|
25 |
-
'XML Support' => self::is_xml_installed(),
|
26 |
-
'Permalink Structure' => get_option('permalink_structure', '') !== '',
|
27 |
-
'Supported PHP Version' => version_compare(
|
28 |
-
phpversion(),
|
29 |
-
UBDiagnostics::SUPPORTED_PHP_VERSION,
|
30 |
-
'>='
|
31 |
-
),
|
32 |
-
'Supported Wordpress Version' => version_compare(
|
33 |
-
UBDiagnostics::wordpress_version(),
|
34 |
-
UBDiagnostics::SUPPORTED_WP_VERSION,
|
35 |
-
'>='
|
36 |
-
),
|
37 |
-
'SNI Support' => self::hasSNI(),
|
38 |
-
);
|
39 |
-
}
|
40 |
-
|
41 |
-
public static function hasSNI()
|
42 |
-
{
|
43 |
-
return defined('OPENSSL_TLSEXT_SERVER_NAME') && OPENSSL_TLSEXT_SERVER_NAME;
|
44 |
-
}
|
45 |
-
|
46 |
-
public static function is_curl_installed()
|
47 |
-
{
|
48 |
-
return function_exists('curl_init');
|
49 |
-
}
|
50 |
-
|
51 |
-
public static function is_xml_installed()
|
52 |
-
{
|
53 |
-
return function_exists('simplexml_load_string');
|
54 |
-
}
|
55 |
-
|
56 |
-
public static function should_show_warning($domain, $domain_info)
|
57 |
-
{
|
58 |
-
$domain_issue = in_array(false, self::domain_checks($domain, $domain_info));
|
59 |
-
$system_issue = in_array(false, self::system_checks());
|
60 |
-
if (UBConfig::has_authorized()) {
|
61 |
-
return $domain_issue || $system_issue;
|
62 |
-
} else {
|
63 |
-
return $system_issue;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Format a variable as condensed human-readable output
|
69 |
-
* Example: non-assoc arrays are output as [foo, bar] and assoc looks like
|
70 |
-
* [
|
71 |
-
* foo: 'bar'
|
72 |
-
* baz: NULL
|
73 |
-
* ]
|
74 |
-
* @param mixed $var
|
75 |
-
* @param int $level
|
76 |
-
* @return string
|
77 |
-
*/
|
78 |
-
private static function pp($var, $level = 1)
|
79 |
-
{
|
80 |
-
$str = '';
|
81 |
-
if (is_array($var)) {
|
82 |
-
$simple = empty($var) ? true : array_keys($var) === range(0, count($var) -1);
|
83 |
-
$str .= '[';
|
84 |
-
if ($simple) {
|
85 |
-
$str .= implode(', ', $var);
|
86 |
-
} else {
|
87 |
-
foreach ($var as $key => $value) {
|
88 |
-
$str .= "\n" . str_repeat(' ', $level) . "$key: " . self::pp($value, $level + 1);
|
89 |
-
}
|
90 |
-
}
|
91 |
-
$str .= ']';
|
92 |
-
} else {
|
93 |
-
$str = var_export($var, true);
|
94 |
-
}
|
95 |
-
return $str;
|
96 |
-
}
|
97 |
-
|
98 |
-
public static function details($domain, $domain_info)
|
99 |
-
{
|
100 |
-
return array(
|
101 |
-
'PHP Version' => phpversion(),
|
102 |
-
'WordPress Version' => UBDiagnostics::wordpress_version(),
|
103 |
-
'Unbounce Plugin Version' => '1.0.36',
|
104 |
-
'Checks' => self::pp(UBDiagnostics::checks($domain, $domain_info)),
|
105 |
-
'Options' => self::pp(UBDiagnostics::ub_options()),
|
106 |
-
'Permalink Structure' => get_option('permalink_structure', ''),
|
107 |
-
'Domain' => $domain,
|
108 |
-
'Domain Authorized' => self::pp(UBConfig::is_authorized_domain($domain)),
|
109 |
-
'Has Authorized' => self::pp(UBConfig::has_authorized()),
|
110 |
-
'Active Plugins' => self::pp(get_option('active_plugins')),
|
111 |
-
'Plugin Details' => self::pp(get_plugins()),
|
112 |
-
'Curl Version' => self::pp(UBDiagnostics::curl_version()),
|
113 |
-
'SNI Support' => self::hasSNI(),
|
114 |
-
'Configuration Options' => self::pp(self::phpConfig()),
|
115 |
-
'Extensions' => self::pp(get_loaded_extensions()),
|
116 |
-
'Operating System' => php_uname(),
|
117 |
-
);
|
118 |
-
}
|
119 |
-
|
120 |
-
private static function phpConfig()
|
121 |
-
{
|
122 |
-
return ini_get_all(null, false);
|
123 |
-
}
|
124 |
-
|
125 |
-
private static function ub_options()
|
126 |
-
{
|
127 |
-
$option_values = array_map(function ($key) {
|
128 |
-
return get_option($key);
|
129 |
-
}, UBConfig::ub_option_keys());
|
130 |
-
|
131 |
-
// Return an array where the key is the option key and the value
|
132 |
-
// the option value:
|
133 |
-
// array('ub-option-key' => 'option value')
|
134 |
-
return array_combine(UBConfig::ub_option_keys(), $option_values);
|
135 |
-
}
|
136 |
-
|
137 |
-
private static function curl_version()
|
138 |
-
{
|
139 |
-
if (function_exists('curl_version')) {
|
140 |
-
return curl_version();
|
141 |
-
} else {
|
142 |
-
return 'N/A';
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
private static function wordpress_version()
|
147 |
-
{
|
148 |
-
global $wp_version;
|
149 |
-
include(ABSPATH . WPINC . '/version.php');
|
150 |
-
return $wp_version;
|
151 |
-
}
|
152 |
-
|
153 |
-
private static function last_status_success($domain_info)
|
154 |
-
{
|
155 |
-
$last_status = UBUtil::array_fetch($domain_info, 'last_status');
|
156 |
-
return $last_status !== null && $last_status !== 'FAILURE';
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Perform a sitemap request with default parameters to test communication with unbounce
|
161 |
-
* @return array
|
162 |
-
*/
|
163 |
-
public static function testSiteMapRequest()
|
164 |
-
{
|
165 |
-
$res = UBConfig::fetch_proxyable_url_set(UBConfig::domain(), null, UBConfig::page_server_domain());
|
166 |
-
if (!is_array($res) || !isset($res[0])) {
|
167 |
-
return array(
|
168 |
-
'status' => 'ERROR',
|
169 |
-
'result' => var_export($res, true),
|
170 |
-
);
|
171 |
-
}
|
172 |
-
return $res[0];
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Retrieve environment details relevant at plugin activation time
|
177 |
-
* @return array
|
178 |
-
*/
|
179 |
-
public static function installationDetails()
|
180 |
-
{
|
181 |
-
return array(
|
182 |
-
'php' => phpversion(),
|
183 |
-
'wordpress' => UBDiagnostics::wordpress_version(),
|
184 |
-
'plugin_version' => '1.0.36',
|
185 |
-
'curl_installed' => self::is_curl_installed(),
|
186 |
-
'xml_installed' => self::is_xml_installed(),
|
187 |
-
'sni_support' => self::hasSNI(),
|
188 |
-
'permalink_structure' => get_option('permalink_structure'),
|
189 |
-
'domain' => UBConfig::domain(),
|
190 |
-
'active_plugins' => get_option('active_plugins'),
|
191 |
-
'curl_version' => UBDiagnostics::curl_version(),
|
192 |
-
'php_config' => UBUtil::array_select_by_key(
|
193 |
-
self::phpConfig(),
|
194 |
-
array(
|
195 |
-
'allow_url_fopen', 'cgi.discard_path', 'cgi.fix_pathinfo', 'curl.cainfo', 'default_charset',
|
196 |
-
'default_socket_timeout', 'disable_functions', 'display_errors', 'error_reporting',
|
197 |
-
'enable_post_data_reading', 'file_uploads', 'implicit_flush', 'memory_limit', 'max_execution_time',
|
198 |
-
'max_input_time', 'opcache.enable', 'openssl.cafile', 'openssl.capath', 'output_buffering',
|
199 |
-
'output_encoding', 'output_handler', 'post_max_size', 'short_open_tag', 'upload_max_filesize',
|
200 |
-
)
|
201 |
-
),
|
202 |
-
'php_extensions' => get_loaded_extensions(),
|
203 |
-
'os' => php_uname(),
|
204 |
-
);
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* @param string|null $previousVersion
|
209 |
-
*/
|
210 |
-
public static function sendActivationEvent($previousVersion = null)
|
211 |
-
{
|
212 |
-
if (!self::is_curl_installed()) {
|
213 |
-
return;
|
214 |
-
}
|
215 |
-
|
216 |
-
$env = self::installationDetails();
|
217 |
-
$sitemapRequest = self::testSiteMapRequest();
|
218 |
-
$event = UBEvents::activationEvent($env, $sitemapRequest, $previousVersion);
|
219 |
-
UBHTTP::send_event_to_events_gateway(UBConfig::remote_log_url(), $event);
|
220 |
-
}
|
221 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBEvents.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class UBEvents
|
4 |
-
{
|
5 |
-
|
6 |
-
public static function successful_authorization_event($data)
|
7 |
-
{
|
8 |
-
return UBEvents::event(
|
9 |
-
'WordPressSuccessfulAuthorizationEventV1.0',
|
10 |
-
UBEvents::authorization_event($data)
|
11 |
-
);
|
12 |
-
}
|
13 |
-
|
14 |
-
public static function failed_authorization_event($data)
|
15 |
-
{
|
16 |
-
return UBEvents::event(
|
17 |
-
'WordPressFailedAuthorizationEventV1.0',
|
18 |
-
UBEvents::authorization_event($data)
|
19 |
-
);
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @param array $environment
|
24 |
-
* @param array|null $sitemapRequest
|
25 |
-
* @param string|null $previousVersion
|
26 |
-
*
|
27 |
-
* @return array
|
28 |
-
*/
|
29 |
-
public static function activationEvent($environment, $sitemapRequest, $previousVersion = null)
|
30 |
-
{
|
31 |
-
$data = array('environment' => $environment, 'sitemap_request' => $sitemapRequest);
|
32 |
-
|
33 |
-
if ($previousVersion) {
|
34 |
-
$data['previous_version'] = $previousVersion;
|
35 |
-
}
|
36 |
-
|
37 |
-
return UBEvents::event('WordpressActivationEventV1.0', $data);
|
38 |
-
}
|
39 |
-
|
40 |
-
public static function log_event($data)
|
41 |
-
{
|
42 |
-
return UBEvents::event('WordpressLogV1.0', $data);
|
43 |
-
}
|
44 |
-
|
45 |
-
private static function authorization_event($data)
|
46 |
-
{
|
47 |
-
$event = array(
|
48 |
-
'domain_name' => $data['domain_name'],
|
49 |
-
'first_authorization' => (boolean) $data['first_authorization'],
|
50 |
-
'metadata' => array()
|
51 |
-
);
|
52 |
-
|
53 |
-
if ($data['domain_id']) {
|
54 |
-
$event['domain_id'] = UBEvents::maybe_convert_to_int($data['domain_id']);
|
55 |
-
}
|
56 |
-
|
57 |
-
if ($data['user_id']) {
|
58 |
-
$event['metadata']['user_id'] = UBEvents::maybe_convert_to_int($data['user_id']);
|
59 |
-
}
|
60 |
-
|
61 |
-
if ($data['client_id']) {
|
62 |
-
$event['metadata']['client_id'] = UBEvents::maybe_convert_to_int($data['client_id']);
|
63 |
-
}
|
64 |
-
|
65 |
-
return $event;
|
66 |
-
}
|
67 |
-
|
68 |
-
private static function maybe_convert_to_int($str)
|
69 |
-
{
|
70 |
-
if (is_numeric($str)) {
|
71 |
-
return intval($str);
|
72 |
-
} else {
|
73 |
-
return $str;
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
private static function event($type, $data)
|
78 |
-
{
|
79 |
-
$event = array_merge(
|
80 |
-
array('type' => $type),
|
81 |
-
UBEvents::default_attributes(),
|
82 |
-
$data
|
83 |
-
);
|
84 |
-
$json_unescaped = json_encode($event);
|
85 |
-
return str_replace('\\/', '/', $json_unescaped);
|
86 |
-
}
|
87 |
-
|
88 |
-
private static function default_attributes()
|
89 |
-
{
|
90 |
-
$datetime = new DateTime('NOW', new DateTimeZone('UTC'));
|
91 |
-
return array('id' => uniqid(),
|
92 |
-
'time_sent' => $datetime->format('Y-m-d\TH:i:s\Z'),
|
93 |
-
'source' => UBConfig::UB_USER_AGENT . ' ' . gethostname());
|
94 |
-
}
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBHTTP.php
DELETED
@@ -1,372 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class UBHTTP
|
4 |
-
{
|
5 |
-
public static $powered_by_header_regex = '/^X-Powered-By: (.+)$/i';
|
6 |
-
public static $form_confirmation_url_regex = '/(.+)\/[a-z]+-form_confirmation\.html/i';
|
7 |
-
public static $lightbox_url_regex = '/(.+)\/[a-z]+-[0-9]+-lightbox\.html/i';
|
8 |
-
public static $variant_url_regex = '/(.+)\/[a-z]+\.html/i';
|
9 |
-
public static $pie_htc_url = '/PIE.htc';
|
10 |
-
// Suppress Etag and Last-Modified so that browser doesn't send
|
11 |
-
// If-None-Match and If-Modified-Since header (to bypass front-end caches)
|
12 |
-
// @codingStandardsIgnoreLine
|
13 |
-
public static $response_header_whitelist = '/^(Content-Type:|Location:|Link:|Content-Location:|Set-Cookie:|X-Server-Instance:|X-Unbounce-PageId:|X-Unbounce-Variant:|X-Unbounce-VisitorID:)/i';
|
14 |
-
public static $request_header_blacklist = '/^(Accept-Encoding:)/i';
|
15 |
-
|
16 |
-
public static function is_private_ip_address($ip_address)
|
17 |
-
{
|
18 |
-
return !filter_var(
|
19 |
-
$ip_address,
|
20 |
-
FILTER_VALIDATE_IP,
|
21 |
-
FILTER_FLAG_NO_PRIV_RANGE + FILTER_FLAG_NO_RES_RANGE
|
22 |
-
);
|
23 |
-
}
|
24 |
-
|
25 |
-
public static function cookie_string_from_array($cookies)
|
26 |
-
{
|
27 |
-
$join_cookie_values = function ($k, $v) {
|
28 |
-
return $k . '=' . $v;
|
29 |
-
};
|
30 |
-
$cookie_strings = array_map(
|
31 |
-
$join_cookie_values,
|
32 |
-
array_keys($cookies),
|
33 |
-
$cookies
|
34 |
-
);
|
35 |
-
return join('; ', $cookie_strings);
|
36 |
-
}
|
37 |
-
|
38 |
-
private static function fetch_header_value_function($regex)
|
39 |
-
{
|
40 |
-
return function ($header_string) use ($regex) {
|
41 |
-
$matches = array();
|
42 |
-
preg_match(
|
43 |
-
$regex,
|
44 |
-
$header_string,
|
45 |
-
$matches
|
46 |
-
);
|
47 |
-
return $matches[1];
|
48 |
-
};
|
49 |
-
}
|
50 |
-
|
51 |
-
public static function rewrite_x_powered_by_header($header_string, $existing_headers)
|
52 |
-
{
|
53 |
-
$fetch_powered_by_value = UBHTTP::fetch_header_value_function(UBHTTP::$powered_by_header_regex);
|
54 |
-
|
55 |
-
$existing_powered_by = preg_grep(
|
56 |
-
UBHTTP::$powered_by_header_regex,
|
57 |
-
$existing_headers
|
58 |
-
);
|
59 |
-
|
60 |
-
$existing_powered_by = array_map(
|
61 |
-
$fetch_powered_by_value,
|
62 |
-
$existing_powered_by
|
63 |
-
);
|
64 |
-
|
65 |
-
return 'X-Powered-By: ' .
|
66 |
-
join($existing_powered_by, ', ') . ', ' .
|
67 |
-
$fetch_powered_by_value($header_string);
|
68 |
-
}
|
69 |
-
|
70 |
-
public static function get_proxied_for_header(
|
71 |
-
$out_headers,
|
72 |
-
$forwarded_for,
|
73 |
-
$current_ip
|
74 |
-
) {
|
75 |
-
if ($forwarded_for !== null &&
|
76 |
-
(UBConfig::allow_public_address_x_forwarded_for() ||
|
77 |
-
UBHTTP::is_private_ip_address($current_ip))) {
|
78 |
-
$proxied_for = $forwarded_for;
|
79 |
-
} else {
|
80 |
-
$proxied_for = $current_ip;
|
81 |
-
}
|
82 |
-
|
83 |
-
$out_headers[] = 'X-Proxied-For: ' . $proxied_for;
|
84 |
-
return $out_headers;
|
85 |
-
}
|
86 |
-
|
87 |
-
public static function stream_headers_function($existing_headers)
|
88 |
-
{
|
89 |
-
return function ($curl, $header_string) use ($existing_headers) {
|
90 |
-
$http_status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
91 |
-
|
92 |
-
http_response_code($http_status_code);
|
93 |
-
|
94 |
-
if (preg_match(UBHTTP::$powered_by_header_regex, $header_string) == 1) {
|
95 |
-
$result = UBHTTP::rewrite_x_powered_by_header($header_string, $existing_headers);
|
96 |
-
header($result);
|
97 |
-
} elseif (preg_match(UBHTTP::$response_header_whitelist, $header_string)) {
|
98 |
-
// false means don't replace the exsisting header
|
99 |
-
header($header_string, false);
|
100 |
-
}
|
101 |
-
|
102 |
-
// We must show curl that we've processed every byte of the input header
|
103 |
-
return strlen($header_string);
|
104 |
-
};
|
105 |
-
}
|
106 |
-
|
107 |
-
public static function stream_response_function()
|
108 |
-
{
|
109 |
-
return function ($curl, $string) {
|
110 |
-
// Stream the body to the client
|
111 |
-
echo $string;
|
112 |
-
|
113 |
-
// We must show curl that we've processed every byte of the input string
|
114 |
-
return strlen($string);
|
115 |
-
};
|
116 |
-
}
|
117 |
-
|
118 |
-
public static function determine_protocol($server_global, $wp_is_ssl)
|
119 |
-
{
|
120 |
-
$forwarded_proto = UBUtil::array_fetch($server_global, 'HTTP_X_FORWARDED_PROTO');
|
121 |
-
$request_scheme = UBUtil::array_fetch($server_global, 'REQUEST_SCHEME');
|
122 |
-
$script_uri = UBUtil::array_fetch($server_global, 'SCRIPT_URI');
|
123 |
-
$script_uri_scheme = parse_url($script_uri, PHP_URL_SCHEME);
|
124 |
-
$https = UBUtil::array_fetch($server_global, 'HTTPS', 'off');
|
125 |
-
|
126 |
-
UBLogger::debug_var('UBHTTP::forwarded_proto', $forwarded_proto);
|
127 |
-
UBLogger::debug_var('UBHTTP::request_scheme', $request_scheme);
|
128 |
-
UBLogger::debug_var('UBHTTP::script_uri', $script_uri);
|
129 |
-
UBLogger::debug_var('UBHTTP::script_uri_scheme', $script_uri_scheme);
|
130 |
-
UBLogger::debug_var('UBHTTP::https', $https);
|
131 |
-
|
132 |
-
// X-Forwarded-Proto should be respected first, as it is what the end
|
133 |
-
// user will see (if Wordpress is behind a load balancer).
|
134 |
-
if (UBHTTP::is_valid_protocol($forwarded_proto)) {
|
135 |
-
return $forwarded_proto . '://';
|
136 |
-
} // Wordpress' is_ssl() may return the correct boolean for http/https if
|
137 |
-
// the site was setup properly.
|
138 |
-
elseif ($wp_is_ssl || !is_null($https) && $https !== 'off') {
|
139 |
-
return 'https://';
|
140 |
-
} // Next use REQUEST_SCHEME, if it is available. This is the recommended way
|
141 |
-
// to get the protocol, but it is not available on all hosts.
|
142 |
-
elseif (UBHTTP::is_valid_protocol($request_scheme)) {
|
143 |
-
return $request_scheme . '://';
|
144 |
-
} // Next try to pull it out of the SCRIPT_URI. This is also not always available.
|
145 |
-
elseif (UBHTTP::is_valid_protocol($script_uri_scheme)) {
|
146 |
-
return $script_uri_scheme . '://';
|
147 |
-
} // We default to http as most HTTPS sites will also have HTTP available.
|
148 |
-
else {
|
149 |
-
return 'http://';
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
private static function is_valid_protocol($protocol)
|
154 |
-
{
|
155 |
-
return $protocol === 'http' || $protocol === 'https';
|
156 |
-
}
|
157 |
-
|
158 |
-
// taken from: http://stackoverflow.com/a/13036310/322727
|
159 |
-
private static function convert_headers_to_curl($headers)
|
160 |
-
{
|
161 |
-
// map to curl-friendly format
|
162 |
-
$req_headers = array();
|
163 |
-
array_walk($headers, function (&$v, $k) use (&$req_headers) {
|
164 |
-
array_push($req_headers, $k . ": " . $v);
|
165 |
-
});
|
166 |
-
|
167 |
-
return $req_headers;
|
168 |
-
}
|
169 |
-
|
170 |
-
public static function stream_request(
|
171 |
-
$method,
|
172 |
-
$target_url,
|
173 |
-
$cookie_string,
|
174 |
-
$headers0,
|
175 |
-
$user_agent
|
176 |
-
) {
|
177 |
-
|
178 |
-
// Always add this header to responses to show it comes from our plugin.
|
179 |
-
header("X-Unbounce-Plugin: 1", false);
|
180 |
-
|
181 |
-
$existing_headers = headers_list();
|
182 |
-
$forwarded_for = UBUtil::array_fetch($_SERVER, 'HTTP_X_FORWARDED_FOR');
|
183 |
-
$remote_ip = UBUtil::array_fetch($_SERVER, 'REMOTE_ADDR');
|
184 |
-
|
185 |
-
$headers1 = UBHTTP::convert_headers_to_curl($headers0);
|
186 |
-
$curl_headers = array_filter($headers1, function ($key) {
|
187 |
-
return !preg_match(UBHTTP::$request_header_blacklist, $key);
|
188 |
-
});
|
189 |
-
|
190 |
-
$headers = UBHTTP::get_proxied_for_header(
|
191 |
-
$curl_headers,
|
192 |
-
$forwarded_for,
|
193 |
-
$remote_ip
|
194 |
-
);
|
195 |
-
UBLogger::debug_var('target_url', $target_url);
|
196 |
-
UBLogger::debug_var('original_headers', print_r($headers0, true));
|
197 |
-
UBLogger::debug_var('sent_headers', print_r($headers, true));
|
198 |
-
|
199 |
-
$stream_headers = UBHTTP::stream_headers_function($existing_headers);
|
200 |
-
$stream_body = UBHTTP::stream_response_function();
|
201 |
-
$curl = curl_init();
|
202 |
-
// http://php.net/manual/en/function.curl-setopt.php
|
203 |
-
$curl_options = array(
|
204 |
-
CURLOPT_URL => $target_url,
|
205 |
-
CURLOPT_POST => $method == "POST",
|
206 |
-
CURLOPT_CUSTOMREQUEST => $method,
|
207 |
-
CURLOPT_USERAGENT => $user_agent,
|
208 |
-
CURLOPT_COOKIE => $cookie_string,
|
209 |
-
CURLOPT_HTTPHEADER => $headers,
|
210 |
-
CURLOPT_HEADERFUNCTION => $stream_headers,
|
211 |
-
CURLOPT_WRITEFUNCTION => $stream_body,
|
212 |
-
CURLOPT_FOLLOWLOCATION => false,
|
213 |
-
CURLOPT_TIMEOUT => 30
|
214 |
-
);
|
215 |
-
|
216 |
-
if ($method == "POST") {
|
217 |
-
// Use raw post body to allow the same post key to occur more than once
|
218 |
-
$curl_options[CURLOPT_POSTFIELDS] = file_get_contents('php://input');
|
219 |
-
}
|
220 |
-
|
221 |
-
curl_setopt_array($curl, $curl_options);
|
222 |
-
$resp = curl_exec($curl);
|
223 |
-
if (!$resp) {
|
224 |
-
$message = "Error proxying to '{$target_url}': '{curl_error($curl)}' - Code: {curl_errno($curl)}";
|
225 |
-
UBLogger::warning($message);
|
226 |
-
http_response_code(500);
|
227 |
-
$result = array(false, $message);
|
228 |
-
} else {
|
229 |
-
$result = array(true, null);
|
230 |
-
}
|
231 |
-
|
232 |
-
curl_close($curl);
|
233 |
-
|
234 |
-
return $result;
|
235 |
-
}
|
236 |
-
|
237 |
-
public static function is_extract_url_proxyable(
|
238 |
-
$proxyable_url_set,
|
239 |
-
$extract_regex,
|
240 |
-
$match_position,
|
241 |
-
$url
|
242 |
-
) {
|
243 |
-
$matches = array();
|
244 |
-
$does_match = preg_match(
|
245 |
-
$extract_regex,
|
246 |
-
$url,
|
247 |
-
$matches
|
248 |
-
);
|
249 |
-
|
250 |
-
return $does_match && in_array($matches[1], $proxyable_url_set);
|
251 |
-
}
|
252 |
-
|
253 |
-
public static function is_confirmation_dialog($proxyable_url_set, $url_without_protocol)
|
254 |
-
{
|
255 |
-
return UBHTTP::is_extract_url_proxyable(
|
256 |
-
$proxyable_url_set,
|
257 |
-
UBHTTP::$form_confirmation_url_regex,
|
258 |
-
1,
|
259 |
-
$url_without_protocol
|
260 |
-
);
|
261 |
-
}
|
262 |
-
|
263 |
-
public static function is_lightbox($proxyable_url_set, $url_without_protocol)
|
264 |
-
{
|
265 |
-
return UBHTTP::is_extract_url_proxyable(
|
266 |
-
$proxyable_url_set,
|
267 |
-
UBHTTP::$lightbox_url_regex,
|
268 |
-
1,
|
269 |
-
$url_without_protocol
|
270 |
-
);
|
271 |
-
}
|
272 |
-
|
273 |
-
public static function is_variant($proxyable_url_set, $url_without_protocol)
|
274 |
-
{
|
275 |
-
return UBHTTP::is_extract_url_proxyable(
|
276 |
-
$proxyable_url_set,
|
277 |
-
UBHTTP::$variant_url_regex,
|
278 |
-
1,
|
279 |
-
$url_without_protocol
|
280 |
-
);
|
281 |
-
}
|
282 |
-
|
283 |
-
public static function is_tracking_link($proxyable_url_set, $url_without_protocol)
|
284 |
-
{
|
285 |
-
return UBHTTP::is_extract_url_proxyable(
|
286 |
-
$proxyable_url_set,
|
287 |
-
"/^(.+)?\/(clkn|clkg)\/?/",
|
288 |
-
1,
|
289 |
-
$url_without_protocol
|
290 |
-
);
|
291 |
-
}
|
292 |
-
|
293 |
-
public static function get_url_purpose($proxyable_url_set, $http_method, $url)
|
294 |
-
{
|
295 |
-
$host = parse_url($url, PHP_URL_HOST);
|
296 |
-
$path = rtrim(parse_url($url, PHP_URL_PATH), '/');
|
297 |
-
$url_without_protocol = $host . $path;
|
298 |
-
|
299 |
-
UBLogger::debug_var('get_url_purpose $host', $host);
|
300 |
-
UBLogger::debug_var('get_url_purpose $path', $path);
|
301 |
-
UBLogger::debug_var('get_url_purpose $url_without_protocol', $url_without_protocol);
|
302 |
-
|
303 |
-
if ($http_method == 'GET' && $path == '/_ubhc') {
|
304 |
-
return 'HealthCheck';
|
305 |
-
} elseif ($http_method == "POST" &&
|
306 |
-
preg_match("/^\/(fsn|fsg|fs)\/?$/", $path)) {
|
307 |
-
return "SubmitLead";
|
308 |
-
} elseif ($http_method == "GET" &&
|
309 |
-
UBHTTP::is_tracking_link($proxyable_url_set, $url_without_protocol)) {
|
310 |
-
return "TrackClick";
|
311 |
-
} elseif (($http_method == "GET" || $http_method == "POST") &&
|
312 |
-
(in_array($url_without_protocol, $proxyable_url_set) ||
|
313 |
-
UBHTTP::is_confirmation_dialog($proxyable_url_set, $url_without_protocol) ||
|
314 |
-
UBHTTP::is_lightbox($proxyable_url_set, $url_without_protocol) ||
|
315 |
-
UBHTTP::is_variant($proxyable_url_set, $url_without_protocol))) {
|
316 |
-
return "ViewLandingPage";
|
317 |
-
} elseif ($http_method == "GET" && $path == UBHTTP::$pie_htc_url) {
|
318 |
-
// proxy PIE.htc
|
319 |
-
return "ViewLandingPage";
|
320 |
-
} else {
|
321 |
-
return null;
|
322 |
-
}
|
323 |
-
}
|
324 |
-
|
325 |
-
public static function send_event_to_events_gateway($url, $data_string)
|
326 |
-
{
|
327 |
-
try {
|
328 |
-
$stream_function = function ($curl, $str) {
|
329 |
-
return strlen($str);
|
330 |
-
};
|
331 |
-
|
332 |
-
$curl = curl_init();
|
333 |
-
$curl_options = array(
|
334 |
-
CURLOPT_URL => $url,
|
335 |
-
CURLOPT_CUSTOMREQUEST => 'POST',
|
336 |
-
CURLOPT_USERAGENT => UBConfig::UB_USER_AGENT,
|
337 |
-
CURLOPT_FOLLOWLOCATION => false,
|
338 |
-
CURLOPT_HTTPHEADER => array(
|
339 |
-
'Content-Type: application/json',
|
340 |
-
'Content-Length: ' . strlen($data_string)
|
341 |
-
),
|
342 |
-
CURLOPT_HEADERFUNCTION => $stream_function,
|
343 |
-
CURLOPT_WRITEFUNCTION => $stream_function,
|
344 |
-
CURLOPT_POSTFIELDS => $data_string,
|
345 |
-
CURLOPT_TIMEOUT => 2
|
346 |
-
);
|
347 |
-
curl_setopt_array($curl, $curl_options);
|
348 |
-
$success = curl_exec($curl);
|
349 |
-
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
350 |
-
|
351 |
-
if (!$success) {
|
352 |
-
$message = 'Unable to send log messages to ' . $url . ': "'
|
353 |
-
. curl_error($curl) . '" - HTTP status: ' . curl_errno($curl);
|
354 |
-
UBLogger::warning($message);
|
355 |
-
} elseif ($http_code >= 200 && $http_code < 300) {
|
356 |
-
$message = 'Successfully sent log messsages to ' . $url
|
357 |
-
. ' - HTTP status: ' . $http_code;
|
358 |
-
UBLogger::debug($message);
|
359 |
-
} else {
|
360 |
-
$message = 'Unable to send log messages to ' . $url
|
361 |
-
. ' - HTTP status: ' . $http_code;
|
362 |
-
UBLogger::warning($message);
|
363 |
-
}
|
364 |
-
|
365 |
-
curl_close($curl);
|
366 |
-
} catch (Exception $e) {
|
367 |
-
$message = 'Unable to send log messages to ' . $url
|
368 |
-
. ' - Error: ' . $e;
|
369 |
-
UBLogger::warning($message);
|
370 |
-
}
|
371 |
-
}
|
372 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBIcon.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class UBIcon
|
4 |
-
{
|
5 |
-
public static function base64_encoded_svg()
|
6 |
-
{
|
7 |
-
// @codingStandardsIgnoreLine
|
8 |
-
return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgdmlld0JveD0iMCAwIDI1Mi43ODY2NyAyNTIuNzg2NjciCiAgIGhlaWdodD0iMjUyLjc4NjY3IgogICB3aWR0aD0iMjUyLjc4NjY3IgogICB4bWw6c3BhY2U9InByZXNlcnZlIgogICB2ZXJzaW9uPSIxLjEiCiAgIGlkPSJzdmcyIj48bWV0YWRhdGEKICAgICBpZD0ibWV0YWRhdGE4Ij48cmRmOlJERj48Y2M6V29yawogICAgICAgICByZGY6YWJvdXQ9IiI+PGRjOmZvcm1hdD5pbWFnZS9zdmcreG1sPC9kYzpmb3JtYXQ+PGRjOnR5cGUKICAgICAgICAgICByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIiAvPjwvY2M6V29yaz48L3JkZjpSREY+PC9tZXRhZGF0YT48ZGVmcwogICAgIGlkPSJkZWZzNiIgLz48ZwogICAgIHRyYW5zZm9ybT0ibWF0cml4KDEuMzMzMzMzMywwLDAsLTEuMzMzMzMzMywwLDI1Mi43ODY2NykiCiAgICAgaWQ9ImcxMCI+PGcKICAgICAgIHRyYW5zZm9ybT0ic2NhbGUoMC4xKSIKICAgICAgIGlkPSJnMTIiPjxwYXRoCiAgICAgICAgIGlkPSJwYXRoMTQiCiAgICAgICAgIHN0eWxlPSJmaWxsOiNmZmZmZmY7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiCiAgICAgICAgIGQ9Ik0gOTQ3Ljk1MywxODk1LjkgQyA0MjQuMzkxLDE4OTUuOSAwLDE0NzEuNDkgMCw5NDcuOTUzIDAsNDI0LjQxNCA0MjQuMzkxLDAgOTQ3Ljk1MywwIGMgNTIzLjU2NywwIDk0Ny45NTcsNDI0LjQxNCA5NDcuOTU3LDk0Ny45NTMgMCw1MjMuNTM3IC00MjQuMzksOTQ3Ljk0NyAtOTQ3Ljk1Nyw5NDcuOTQ3IHogTSA2ODUuODU1LDI4MS4yMjcgYyAxMC40ODUsNjcuNDg4IDIwLjQ4MSwxMjkuNTA3IDI5LjgyNSwxODYuNzQyIC0yMDguNzc0LDEwNC42NDQgLTM0MS4wODIsMzE1LjMxNiAtMzA3LjM0LDU1OC43OTEgNDYuMDU4LDMzMC42NyAzMDAuNjY0LDUwMC4yNSA2MjAuODYsNDcxLjQgMjQuMjgsMzQuMzcgNTAuOTMsNjcuMzUgODEuMjYsOTkuMjYgNTQuMDIsNjAuMzkgMTM0LjM1LDYyLjI5IDk4LjIyLC05LjI4IC03Mi44MiwtMTM3LjggLTEwMS42LC0yNDEuODQgLTE2NC4xNSwtNDA4LjkyIC02Mi4zNDIsLTE3Ny43IC0xNTguNzA2LC00MzguNTEzIC0yODYuOTg3LC04OTYuNDYyIC05LjI3NywtNDEuOTM0IC03NS4wMDQsLTM1LjI1IC03MS42ODgsLTEuNTMxIHogTSAxNDg4LjA1LDg4OC40ODQgQyAxNDQ2LjQyLDU3Mi43NSAxMTUxLjMsMzkzLjU3IDg1Ny45NDUsNDI0LjUwOCBjIDIxLjI5Myw3MS45ODggMzEuMzc5LDEwMi42OTEgNTYuMDU5LDE2MC43MTkgMTguNjIxLDMzLjQ4OCA4OC4zMzYsNDcuMTc1IDE0Mi40NjYsNzAuMTgzIDEwOS45NSwzOS41MTYgMTk0LjM5LDEzNy42NiAyMTAuMzUsMjYxLjUxMiAxMS4yMyw4Ny44MDggLTE0LjQyLDE3MS45NDggLTY0LjcsMjM2Ljk3OCAtMzUuMTYsNDQuNjIgLTY4LjMsNzEuNjYgLTU2Ljk4LDExMy41NSAxNi42NSw1Ni41NCAyOS40Miw5OC41MSA2MC40OCwxNjkuNTggMTkyLjc1LC0xMDMuNTMgMzEyLjkxLC0zMTguNTcgMjgyLjQzLC01NDguNTQ2IiAvPjxwYXRoCiAgICAgICAgIGlkPSJwYXRoMTYiCiAgICAgICAgIHN0eWxlPSJmaWxsOiNmZmZmZmY7ZmlsbC1vcGFjaXR5OjE7ZmlsbC1ydWxlOm5vbnplcm87c3Ryb2tlOm5vbmUiCiAgICAgICAgIGQ9Im0gNjI5LjgwMSw5OTguNDY1IGMgLTEwLjg3NSwtODQuNDY5IDEyLjEyOSwtMTY1LjA4MiA1OC4yMzQsLTIyOC42NzYgMzAuNzMxLC00MS4wNDcgNTQuMjcsLTY0Ljk4IDY1Ljc5NywtODMuODEyIDM3Ljk4OCwyMDUuNzA3IDY1LjQwMiwzMTIuMTE3IDEwMS45MzgsNDMxLjUwMyAxNi4zNzUsNDkuODcgNDMuNTA3LDExOS44MiA2My4xNDgsMTY3LjQ1IC0yMy40MjYsLTcuODQgLTU2LjY1NiwtMTYuNTYgLTgzLjc5NywtMjcuMTggLTEwNy40OTIsLTQwLjMxIC0xODkuNjY4LC0xMzcuNDQgLTIwNS4zMiwtMjU5LjI4NSIgLz48L2c+PC9nPjwvc3ZnPg==';
|
9 |
-
}
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBLogger.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class UBLogger
|
4 |
-
{
|
5 |
-
|
6 |
-
// should be called when the plugin is loaded
|
7 |
-
public static function setup_logger()
|
8 |
-
{
|
9 |
-
if (!isset($GLOBALS['wp_log_plugins'])) {
|
10 |
-
$GLOBALS['wp_log_plugins'] = array();
|
11 |
-
}
|
12 |
-
$GLOBALS['wp_log_plugins'][UBConfig::UB_PLUGIN_NAME] = array();
|
13 |
-
$GLOBALS['wp_log_plugins'][UBConfig::UB_PLUGIN_NAME . '-vars'] = array();
|
14 |
-
}
|
15 |
-
|
16 |
-
public static function upload_logs_to_unbounce($url)
|
17 |
-
{
|
18 |
-
// The assumption is that if curl is not installed will likely have
|
19 |
-
// reached support and would have been diagnosed through diagnostics
|
20 |
-
if (!UBDiagnostics::is_curl_installed()) {
|
21 |
-
return;
|
22 |
-
}
|
23 |
-
|
24 |
-
if (UBConfig::remote_debug_logging_enabled()) {
|
25 |
-
$data = array(
|
26 |
-
'messages' => $GLOBALS['wp_log'][UBConfig::UB_PLUGIN_NAME],
|
27 |
-
'vars' => $GLOBALS['wp_log'][UBConfig::UB_PLUGIN_NAME . '-vars'],
|
28 |
-
);
|
29 |
-
UBHTTP::send_event_to_events_gateway($url, UBEvents::log_event($data));
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
public static function format_log_entry($level, $msg)
|
34 |
-
{
|
35 |
-
$msg = is_string($msg) ? $msg : print_r($msg, true);
|
36 |
-
return '[' . UBConfig::UB_PLUGIN_NAME . '] [' . $level . '] ' . $msg;
|
37 |
-
}
|
38 |
-
|
39 |
-
private static function log_wp_log($log_entry)
|
40 |
-
{
|
41 |
-
$GLOBALS['wp_log'][UBConfig::UB_PLUGIN_NAME][] = $log_entry;
|
42 |
-
}
|
43 |
-
|
44 |
-
private static function log_wp_log_var($var, $val)
|
45 |
-
{
|
46 |
-
$GLOBALS['wp_log'][UBConfig::UB_PLUGIN_NAME . '-vars'][$var] = $val;
|
47 |
-
}
|
48 |
-
|
49 |
-
private static function log_error_log($log_entry)
|
50 |
-
{
|
51 |
-
error_log($log_entry);
|
52 |
-
}
|
53 |
-
|
54 |
-
public static function log($level, $msg)
|
55 |
-
{
|
56 |
-
if (UBConfig::debug_loggging_enabled()) {
|
57 |
-
$log_entry = UBLogger::format_log_entry($level, $msg);
|
58 |
-
UBLogger::log_wp_log($log_entry);
|
59 |
-
UBLogger::log_error_log($log_entry);
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
-
public static function log_var($level, $var, $val)
|
64 |
-
{
|
65 |
-
if (UBConfig::debug_loggging_enabled()) {
|
66 |
-
UBLogger::log($level, '$' . $var . ': ' . $val);
|
67 |
-
UBLogger::log_wp_log_var($var, $val);
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
public static function info($msg)
|
72 |
-
{
|
73 |
-
UBLogger::log('INFO', $msg);
|
74 |
-
}
|
75 |
-
|
76 |
-
public static function warning($msg)
|
77 |
-
{
|
78 |
-
UBLogger::log('WARNING', $msg);
|
79 |
-
}
|
80 |
-
|
81 |
-
public static function debug($msg)
|
82 |
-
{
|
83 |
-
UBLogger::log('DEBUG', $msg);
|
84 |
-
}
|
85 |
-
|
86 |
-
public static function debug_var($var, $val)
|
87 |
-
{
|
88 |
-
UBLogger::log_var('DEBUG', $var, $val);
|
89 |
-
}
|
90 |
-
|
91 |
-
public static function config($msg)
|
92 |
-
{
|
93 |
-
UBLogger::log('CONFIG', $msg);
|
94 |
-
}
|
95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBPageTable.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class UBPageTable extends UBWPListTable
|
4 |
-
{
|
5 |
-
|
6 |
-
private $item_scroll_threshold = 10;
|
7 |
-
|
8 |
-
public function __construct($page_urls)
|
9 |
-
{
|
10 |
-
parent::__construct();
|
11 |
-
|
12 |
-
$this->items = array_map(function ($url) {
|
13 |
-
return array('url' => $url);
|
14 |
-
}, $page_urls);
|
15 |
-
|
16 |
-
$this->_column_headers = array(array('url' => 'Url'), array(), array());
|
17 |
-
}
|
18 |
-
|
19 |
-
protected function column_default($item, $column_name)
|
20 |
-
{
|
21 |
-
switch ($column_name) {
|
22 |
-
case 'url':
|
23 |
-
return "<a href=\"//${item[$column_name]}\" target=\"_blank\">${item[$column_name]}</a>";
|
24 |
-
break;
|
25 |
-
default:
|
26 |
-
return $item[$column_name];
|
27 |
-
}
|
28 |
-
}
|
29 |
-
|
30 |
-
protected function display_tablenav($which)
|
31 |
-
{
|
32 |
-
}
|
33 |
-
|
34 |
-
protected function get_table_classes()
|
35 |
-
{
|
36 |
-
$super = parent::get_table_classes();
|
37 |
-
|
38 |
-
if (count($this->items) > $this->item_scroll_threshold) {
|
39 |
-
$super[] = 'ub-table-scroll';
|
40 |
-
}
|
41 |
-
|
42 |
-
return $super;
|
43 |
-
}
|
44 |
-
|
45 |
-
public function no_items()
|
46 |
-
{
|
47 |
-
_e('None of your Unbounce pages have been published to WordPress.');
|
48 |
-
}
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBTemplate.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class UBTemplate
|
4 |
-
{
|
5 |
-
|
6 |
-
/*
|
7 |
-
* Renders a PHP template with local variables.
|
8 |
-
*
|
9 |
-
* `$template` Path to a PHP template
|
10 |
-
* `$vars` An array of local variables to render in the template
|
11 |
-
*
|
12 |
-
* For example:
|
13 |
-
*
|
14 |
-
* templates/hello.php:
|
15 |
-
* <h1>Hello, <?php $name; ?>!</h1>
|
16 |
-
*
|
17 |
-
* echo UBTemplate::render('hello', array('name' => 'World'));
|
18 |
-
*
|
19 |
-
* will output:
|
20 |
-
*
|
21 |
-
* <h1>Hello, World!</h1>
|
22 |
-
*
|
23 |
-
*/
|
24 |
-
|
25 |
-
public static function render($template, $vars = array())
|
26 |
-
{
|
27 |
-
ob_start();
|
28 |
-
try {
|
29 |
-
extract($vars);
|
30 |
-
include(UBTemplate::template_path($template));
|
31 |
-
} catch (Exception $e) {
|
32 |
-
echo $e;
|
33 |
-
}
|
34 |
-
return ob_get_clean();
|
35 |
-
}
|
36 |
-
|
37 |
-
public static function template_path($template)
|
38 |
-
{
|
39 |
-
return UBTemplate::join_paths(dirname(__FILE__), 'templates', $template . '.php');
|
40 |
-
}
|
41 |
-
|
42 |
-
private static function join_paths()
|
43 |
-
{
|
44 |
-
return preg_replace('~[/\\\]+~', DIRECTORY_SEPARATOR, implode(DIRECTORY_SEPARATOR, func_get_args()));
|
45 |
-
}
|
46 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBUtil.php
DELETED
@@ -1,105 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class UBUtil
|
4 |
-
{
|
5 |
-
|
6 |
-
public static function array_select_by_key($input, $keep)
|
7 |
-
{
|
8 |
-
return array_intersect_key($input, array_flip($keep));
|
9 |
-
}
|
10 |
-
|
11 |
-
public static function array_fetch($array, $index, $default = null)
|
12 |
-
{
|
13 |
-
return isset($array[$index]) ? $array[$index] : $default;
|
14 |
-
}
|
15 |
-
|
16 |
-
public static function time_ago($timestamp)
|
17 |
-
{
|
18 |
-
$now = new DateTime('now');
|
19 |
-
$from = new DateTime();
|
20 |
-
$from->setTimestamp($timestamp);
|
21 |
-
$diff = date_diff($now, $from);
|
22 |
-
|
23 |
-
if ($diff->y > 0) {
|
24 |
-
$message = $diff->y . ' year'. ($diff->y > 1 ? 's' : '');
|
25 |
-
} elseif ($diff->m > 0) {
|
26 |
-
$message = $diff->m . ' month'. ($diff->m > 1 ? 's' : '');
|
27 |
-
} elseif ($diff->d > 0) {
|
28 |
-
$message = $diff->d . ' day' . ($diff->d > 1 ? 's' : '');
|
29 |
-
} elseif ($diff->h > 0) {
|
30 |
-
$message = $diff->h . ' hour' . ($diff->h > 1 ? 's' : '');
|
31 |
-
} elseif ($diff->i > 0) {
|
32 |
-
$message = $diff->i . ' minute' . ($diff->i > 1 ? 's' : '');
|
33 |
-
} elseif ($diff->s > 0) {
|
34 |
-
$message = $diff->s . ' second' . ($diff->s > 1? 's' : '');
|
35 |
-
} else {
|
36 |
-
$message = 'a moment';
|
37 |
-
}
|
38 |
-
|
39 |
-
return $message . ' ago';
|
40 |
-
}
|
41 |
-
|
42 |
-
public static function clear_flash()
|
43 |
-
{
|
44 |
-
foreach ($_COOKIE as $cookie_name => $value) {
|
45 |
-
if (strpos($cookie_name, 'ub-flash-') === 0) {
|
46 |
-
setcookie($cookie_name, '', time() - 60);
|
47 |
-
}
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
public static function get_flash($cookie_name, $default = null)
|
52 |
-
{
|
53 |
-
return UBUtil::array_fetch($_COOKIE, "ub-flash-${cookie_name}", $default);
|
54 |
-
}
|
55 |
-
|
56 |
-
public static function set_flash($cookie_name, $value)
|
57 |
-
{
|
58 |
-
setcookie("ub-flash-${cookie_name}", $value, time() + 60);
|
59 |
-
}
|
60 |
-
|
61 |
-
public static function get_lock()
|
62 |
-
{
|
63 |
-
global $wpdb;
|
64 |
-
|
65 |
-
try {
|
66 |
-
$lock = $wpdb->get_var('select coalesce(get_lock("' . UBConfig::UB_LOCK_NAME . '",0), 0);');
|
67 |
-
|
68 |
-
return (bool) $lock;
|
69 |
-
} catch (Exception $e) {
|
70 |
-
// ensure backward compatibility on failure
|
71 |
-
return true;
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
public static function release_lock()
|
76 |
-
{
|
77 |
-
global $wpdb;
|
78 |
-
|
79 |
-
try {
|
80 |
-
$release = $wpdb->get_var('select coalesce(release_lock("' . UBConfig::UB_LOCK_NAME . '"), 0);');
|
81 |
-
|
82 |
-
return (bool) $release;
|
83 |
-
} catch (Exception $e) {
|
84 |
-
// ensure backward compatibility on failure
|
85 |
-
return true;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Checks if the current page is a preview page (from on GET parameters).
|
91 |
-
*
|
92 |
-
* This is needed because Wordpress's is_preview() is only true for pages that
|
93 |
-
* are already published.
|
94 |
-
*
|
95 |
-
* This should return true when:
|
96 |
-
* - previewing posts
|
97 |
-
* - previewing pages
|
98 |
-
* - previewing drafts (of posts & pages)
|
99 |
-
*/
|
100 |
-
public static function is_wordpress_preview($get_params)
|
101 |
-
{
|
102 |
-
return isset($get_params['preview'])
|
103 |
-
&& (isset($get_params['p']) || isset($get_params['page_id']) || isset($get_params['preview_id']));
|
104 |
-
}
|
105 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/UBWPListTable.php
DELETED
@@ -1,1246 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Base class for displaying a list of items in an ajaxified HTML table.
|
4 |
-
*
|
5 |
-
* @since 3.1.0
|
6 |
-
* @access private
|
7 |
-
*
|
8 |
-
* @package WordPress
|
9 |
-
* @subpackage List_Table
|
10 |
-
*/
|
11 |
-
class UBWPListTable
|
12 |
-
{
|
13 |
-
|
14 |
-
/**
|
15 |
-
* The current list of items
|
16 |
-
*
|
17 |
-
* @since 3.1.0
|
18 |
-
* @var array
|
19 |
-
* @access public
|
20 |
-
*/
|
21 |
-
public $items;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Various information about the current table
|
25 |
-
*
|
26 |
-
* @since 3.1.0
|
27 |
-
* @var array
|
28 |
-
* @access protected
|
29 |
-
*/
|
30 |
-
protected $_args;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Various information needed for displaying the pagination
|
34 |
-
*
|
35 |
-
* @since 3.1.0
|
36 |
-
* @var array
|
37 |
-
*/
|
38 |
-
protected $_pagination_args = array();
|
39 |
-
|
40 |
-
/**
|
41 |
-
* The current screen
|
42 |
-
*
|
43 |
-
* @since 3.1.0
|
44 |
-
* @var object
|
45 |
-
* @access protected
|
46 |
-
*/
|
47 |
-
protected $screen;
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Cached bulk actions
|
51 |
-
*
|
52 |
-
* @since 3.1.0
|
53 |
-
* @var array
|
54 |
-
* @access private
|
55 |
-
*/
|
56 |
-
private $_actions;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Cached pagination output
|
60 |
-
*
|
61 |
-
* @since 3.1.0
|
62 |
-
* @var string
|
63 |
-
* @access private
|
64 |
-
*/
|
65 |
-
private $_pagination;
|
66 |
-
|
67 |
-
/**
|
68 |
-
* The view switcher modes.
|
69 |
-
*
|
70 |
-
* @since 4.1.0
|
71 |
-
* @var array
|
72 |
-
* @access protected
|
73 |
-
*/
|
74 |
-
protected $modes = array();
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Stores the value returned by ->get_column_info()
|
78 |
-
*
|
79 |
-
* @var array
|
80 |
-
*/
|
81 |
-
protected $_column_headers;
|
82 |
-
|
83 |
-
protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
|
84 |
-
|
85 |
-
protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions',
|
86 |
-
'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination',
|
87 |
-
'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav',
|
88 |
-
'single_row_columns' );
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Constructor.
|
92 |
-
*
|
93 |
-
* The child class should call this constructor from its own constructor to override
|
94 |
-
* the default $args.
|
95 |
-
*
|
96 |
-
* @since 3.1.0
|
97 |
-
* @access public
|
98 |
-
*
|
99 |
-
* @param array|string $args {
|
100 |
-
* Array or string of arguments.
|
101 |
-
*
|
102 |
-
* @type string $plural Plural value used for labels and the objects being listed.
|
103 |
-
* This affects things such as CSS class-names and nonces used
|
104 |
-
* in the list table, e.g. 'posts'. Default empty.
|
105 |
-
* @type string $singular Singular label for an object being listed, e.g. 'post'.
|
106 |
-
* Default empty
|
107 |
-
* @type bool $ajax Whether the list table supports AJAX. This includes loading
|
108 |
-
* and sorting data, for example. If true, the class will call
|
109 |
-
* the {@see _js_vars()} method in the footer to provide variables
|
110 |
-
* to any scripts handling AJAX events. Default false.
|
111 |
-
* @type string $screen String containing the hook name used to determine the current
|
112 |
-
* screen. If left null, the current screen will be automatically set.
|
113 |
-
* Default null.
|
114 |
-
* }
|
115 |
-
*/
|
116 |
-
public function __construct($args = array())
|
117 |
-
{
|
118 |
-
$args = wp_parse_args($args, array(
|
119 |
-
'plural' => '',
|
120 |
-
'singular' => '',
|
121 |
-
'ajax' => false,
|
122 |
-
'screen' => null,
|
123 |
-
));
|
124 |
-
|
125 |
-
$this->screen = convert_to_screen($args['screen']);
|
126 |
-
|
127 |
-
add_filter("manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0);
|
128 |
-
|
129 |
-
if (!$args['plural']) {
|
130 |
-
$args['plural'] = $this->screen->base;
|
131 |
-
}
|
132 |
-
|
133 |
-
$args['plural'] = sanitize_key($args['plural']);
|
134 |
-
$args['singular'] = sanitize_key($args['singular']);
|
135 |
-
|
136 |
-
$this->_args = $args;
|
137 |
-
|
138 |
-
if ($args['ajax']) {
|
139 |
-
// wp_enqueue_script( 'list-table' );
|
140 |
-
add_action('admin_footer', array( $this, '_js_vars' ));
|
141 |
-
}
|
142 |
-
|
143 |
-
if (empty($this->modes)) {
|
144 |
-
$this->modes = array(
|
145 |
-
'list' => __('List View'),
|
146 |
-
'excerpt' => __('Excerpt View')
|
147 |
-
);
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
-
/**
|
152 |
-
* Make private properties readable for backwards compatibility.
|
153 |
-
*
|
154 |
-
* @since 4.0.0
|
155 |
-
* @access public
|
156 |
-
*
|
157 |
-
* @param string $name Property to get.
|
158 |
-
* @return mixed Property.
|
159 |
-
*/
|
160 |
-
public function __get($name)
|
161 |
-
{
|
162 |
-
if (in_array($name, $this->compat_fields)) {
|
163 |
-
return $this->$name;
|
164 |
-
}
|
165 |
-
}
|
166 |
-
|
167 |
-
/**
|
168 |
-
* Make private properties settable for backwards compatibility.
|
169 |
-
*
|
170 |
-
* @since 4.0.0
|
171 |
-
* @access public
|
172 |
-
*
|
173 |
-
* @param string $name Property to check if set.
|
174 |
-
* @param mixed $value Property value.
|
175 |
-
* @return mixed Newly-set property.
|
176 |
-
*/
|
177 |
-
public function __set($name, $value)
|
178 |
-
{
|
179 |
-
if (in_array($name, $this->compat_fields)) {
|
180 |
-
return $this->$name = $value;
|
181 |
-
}
|
182 |
-
}
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Make private properties checkable for backwards compatibility.
|
186 |
-
*
|
187 |
-
* @since 4.0.0
|
188 |
-
* @access public
|
189 |
-
*
|
190 |
-
* @param string $name Property to check if set.
|
191 |
-
* @return bool Whether the property is set.
|
192 |
-
*/
|
193 |
-
public function __isset($name)
|
194 |
-
{
|
195 |
-
if (in_array($name, $this->compat_fields)) {
|
196 |
-
return isset($this->$name);
|
197 |
-
}
|
198 |
-
}
|
199 |
-
|
200 |
-
/**
|
201 |
-
* Make private properties un-settable for backwards compatibility.
|
202 |
-
*
|
203 |
-
* @since 4.0.0
|
204 |
-
* @access public
|
205 |
-
*
|
206 |
-
* @param string $name Property to unset.
|
207 |
-
*/
|
208 |
-
public function __unset($name)
|
209 |
-
{
|
210 |
-
if (in_array($name, $this->compat_fields)) {
|
211 |
-
unset($this->$name);
|
212 |
-
}
|
213 |
-
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
* Make private/protected methods readable for backwards compatibility.
|
217 |
-
*
|
218 |
-
* @since 4.0.0
|
219 |
-
* @access public
|
220 |
-
*
|
221 |
-
* @param callable $name Method to call.
|
222 |
-
* @param array $arguments Arguments to pass when calling.
|
223 |
-
* @return mixed|bool Return value of the callback, false otherwise.
|
224 |
-
*/
|
225 |
-
public function __call($name, $arguments)
|
226 |
-
{
|
227 |
-
if (in_array($name, $this->compat_methods)) {
|
228 |
-
return call_user_func_array(array( $this, $name ), $arguments);
|
229 |
-
}
|
230 |
-
return false;
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Checks the current user's permissions
|
235 |
-
*
|
236 |
-
* @since 3.1.0
|
237 |
-
* @access public
|
238 |
-
* @abstract
|
239 |
-
*/
|
240 |
-
public function ajax_user_can()
|
241 |
-
{
|
242 |
-
die('function WP_List_Table::ajax_user_can() must be over-ridden in a sub-class.');
|
243 |
-
}
|
244 |
-
|
245 |
-
/**
|
246 |
-
* Prepares the list of items for displaying.
|
247 |
-
* @uses WP_List_Table::set_pagination_args()
|
248 |
-
*
|
249 |
-
* @since 3.1.0
|
250 |
-
* @access public
|
251 |
-
* @abstract
|
252 |
-
*/
|
253 |
-
public function prepare_items()
|
254 |
-
{
|
255 |
-
die('function WP_List_Table::prepare_items() must be over-ridden in a sub-class.');
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* An internal method that sets all the necessary pagination arguments
|
260 |
-
*
|
261 |
-
* @param array $args An associative array with information about the pagination
|
262 |
-
* @access protected
|
263 |
-
*/
|
264 |
-
protected function set_pagination_args($args)
|
265 |
-
{
|
266 |
-
$args = wp_parse_args($args, array(
|
267 |
-
'total_items' => 0,
|
268 |
-
'total_pages' => 0,
|
269 |
-
'per_page' => 0,
|
270 |
-
));
|
271 |
-
|
272 |
-
if (!$args['total_pages'] && $args['per_page'] > 0) {
|
273 |
-
$args['total_pages'] = ceil($args['total_items'] / $args['per_page']);
|
274 |
-
}
|
275 |
-
|
276 |
-
$doingAjax = defined('DOING_AJAX') && DOING_AJAX;
|
277 |
-
|
278 |
-
// Redirect if page number is invalid and headers are not already sent.
|
279 |
-
if (!headers_sent() && !$doingAjax && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages']) {
|
280 |
-
wp_redirect(add_query_arg('paged', $args['total_pages']));
|
281 |
-
exit;
|
282 |
-
}
|
283 |
-
|
284 |
-
$this->_pagination_args = $args;
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Access the pagination args.
|
289 |
-
*
|
290 |
-
* @since 3.1.0
|
291 |
-
* @access public
|
292 |
-
*
|
293 |
-
* @param string $key Pagination argument to retrieve. Common values include 'total_items',
|
294 |
-
* 'total_pages', 'per_page', or 'infinite_scroll'.
|
295 |
-
* @return int Number of items that correspond to the given pagination argument.
|
296 |
-
*/
|
297 |
-
public function get_pagination_arg($key)
|
298 |
-
{
|
299 |
-
if ('page' == $key) {
|
300 |
-
return $this->get_pagenum();
|
301 |
-
}
|
302 |
-
|
303 |
-
if (isset($this->_pagination_args[$key])) {
|
304 |
-
return $this->_pagination_args[$key];
|
305 |
-
}
|
306 |
-
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* Whether the table has items to display or not
|
310 |
-
*
|
311 |
-
* @since 3.1.0
|
312 |
-
* @access public
|
313 |
-
*
|
314 |
-
* @return bool
|
315 |
-
*/
|
316 |
-
public function has_items()
|
317 |
-
{
|
318 |
-
return !empty($this->items);
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Message to be displayed when there are no items
|
323 |
-
*
|
324 |
-
* @since 3.1.0
|
325 |
-
* @access public
|
326 |
-
*/
|
327 |
-
public function no_items()
|
328 |
-
{
|
329 |
-
_e('No items found.');
|
330 |
-
}
|
331 |
-
|
332 |
-
/**
|
333 |
-
* Display the search box.
|
334 |
-
*
|
335 |
-
* @since 3.1.0
|
336 |
-
* @access public
|
337 |
-
*
|
338 |
-
* @param string $text The search button text
|
339 |
-
* @param string $input_id The search input id
|
340 |
-
*/
|
341 |
-
public function search_box($text, $input_id)
|
342 |
-
{
|
343 |
-
if (empty($_REQUEST['s']) && !$this->has_items()) {
|
344 |
-
return;
|
345 |
-
}
|
346 |
-
|
347 |
-
$input_id = $input_id . '-search-input';
|
348 |
-
|
349 |
-
if (! empty($_REQUEST['orderby'])) {
|
350 |
-
echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />';
|
351 |
-
}
|
352 |
-
if (! empty($_REQUEST['order'])) {
|
353 |
-
echo '<input type="hidden" name="order" value="' . esc_attr($_REQUEST['order']) . '" />';
|
354 |
-
}
|
355 |
-
if (! empty($_REQUEST['post_mime_type'])) {
|
356 |
-
echo '<input type="hidden" name="post_mime_type" value="' . esc_attr($_REQUEST['post_mime_type']) . '" />';
|
357 |
-
}
|
358 |
-
if (! empty($_REQUEST['detached'])) {
|
359 |
-
echo '<input type="hidden" name="detached" value="' . esc_attr($_REQUEST['detached']) . '" />';
|
360 |
-
}
|
361 |
-
?>
|
362 |
-
<p class="search-box">
|
363 |
-
<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
|
364 |
-
<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
|
365 |
-
<?php submit_button($text, 'button', '', false, array('id' => 'search-submit')); ?>
|
366 |
-
</p>
|
367 |
-
<?php
|
368 |
-
}
|
369 |
-
|
370 |
-
/**
|
371 |
-
* Get an associative array ( id => link ) with the list
|
372 |
-
* of views available on this table.
|
373 |
-
*
|
374 |
-
* @since 3.1.0
|
375 |
-
* @access protected
|
376 |
-
*
|
377 |
-
* @return array
|
378 |
-
*/
|
379 |
-
protected function get_views()
|
380 |
-
{
|
381 |
-
return array();
|
382 |
-
}
|
383 |
-
|
384 |
-
/**
|
385 |
-
* Display the list of views available on this table.
|
386 |
-
*
|
387 |
-
* @since 3.1.0
|
388 |
-
* @access public
|
389 |
-
*/
|
390 |
-
public function views()
|
391 |
-
{
|
392 |
-
$views = $this->get_views();
|
393 |
-
/**
|
394 |
-
* Filter the list of available list table views.
|
395 |
-
*
|
396 |
-
* The dynamic portion of the hook name, `$this->screen->id`, refers
|
397 |
-
* to the ID of the current screen, usually a string.
|
398 |
-
*
|
399 |
-
* @since 3.5.0
|
400 |
-
*
|
401 |
-
* @param array $views An array of available list table views.
|
402 |
-
*/
|
403 |
-
$views = apply_filters("views_{$this->screen->id}", $views);
|
404 |
-
|
405 |
-
if (empty($views)) {
|
406 |
-
return;
|
407 |
-
}
|
408 |
-
|
409 |
-
echo "<ul class='subsubsub'>\n";
|
410 |
-
foreach ($views as $class => $view) {
|
411 |
-
$views[ $class ] = "\t<li class='$class'>$view";
|
412 |
-
}
|
413 |
-
echo implode(" |</li>\n", $views) . "</li>\n";
|
414 |
-
echo "</ul>";
|
415 |
-
}
|
416 |
-
|
417 |
-
/**
|
418 |
-
* Get an associative array ( option_name => option_title ) with the list
|
419 |
-
* of bulk actions available on this table.
|
420 |
-
*
|
421 |
-
* @since 3.1.0
|
422 |
-
* @access protected
|
423 |
-
*
|
424 |
-
* @return array
|
425 |
-
*/
|
426 |
-
protected function get_bulk_actions()
|
427 |
-
{
|
428 |
-
return array();
|
429 |
-
}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* Display the bulk actions dropdown.
|
433 |
-
*
|
434 |
-
* @since 3.1.0
|
435 |
-
* @access protected
|
436 |
-
*
|
437 |
-
* @param string $which The location of the bulk actions: 'top' or 'bottom'.
|
438 |
-
* This is designated as optional for backwards-compatibility.
|
439 |
-
*/
|
440 |
-
protected function bulk_actions($which = '')
|
441 |
-
{
|
442 |
-
if (is_null($this->_actions)) {
|
443 |
-
$no_new_actions = $this->_actions = $this->get_bulk_actions();
|
444 |
-
/**
|
445 |
-
* Filter the list table Bulk Actions drop-down.
|
446 |
-
*
|
447 |
-
* The dynamic portion of the hook name, `$this->screen->id`, refers
|
448 |
-
* to the ID of the current screen, usually a string.
|
449 |
-
*
|
450 |
-
* This filter can currently only be used to remove bulk actions.
|
451 |
-
*
|
452 |
-
* @since 3.5.0
|
453 |
-
*
|
454 |
-
* @param array $actions An array of the available bulk actions.
|
455 |
-
*/
|
456 |
-
$this->_actions = apply_filters("bulk_actions-{$this->screen->id}", $this->_actions);
|
457 |
-
$this->_actions = array_intersect_assoc($this->_actions, $no_new_actions);
|
458 |
-
$two = '';
|
459 |
-
} else {
|
460 |
-
$two = '2';
|
461 |
-
}
|
462 |
-
|
463 |
-
if (empty($this->_actions)) {
|
464 |
-
return;
|
465 |
-
}
|
466 |
-
|
467 |
-
echo "<label for='bulk-action-selector-" . esc_attr($which) . "' class='screen-reader-text'>" .
|
468 |
-
__('Select bulk action') . "</label>";
|
469 |
-
echo "<select name='action$two' id='bulk-action-selector-" . esc_attr($which) . "'>\n";
|
470 |
-
echo "<option value='-1' selected='selected'>" . __('Bulk Actions') . "</option>\n";
|
471 |
-
|
472 |
-
foreach ($this->_actions as $name => $title) {
|
473 |
-
$class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
|
474 |
-
|
475 |
-
echo "\t<option value='$name'$class>$title</option>\n";
|
476 |
-
}
|
477 |
-
|
478 |
-
echo "</select>\n";
|
479 |
-
|
480 |
-
submit_button(__('Apply'), 'action', '', false, array( 'id' => "doaction$two" ));
|
481 |
-
echo "\n";
|
482 |
-
}
|
483 |
-
|
484 |
-
/**
|
485 |
-
* Get the current action selected from the bulk actions dropdown.
|
486 |
-
*
|
487 |
-
* @since 3.1.0
|
488 |
-
* @access public
|
489 |
-
*
|
490 |
-
* @return string|bool The action name or False if no action was selected
|
491 |
-
*/
|
492 |
-
public function current_action()
|
493 |
-
{
|
494 |
-
if (isset($_REQUEST['filter_action']) && ! empty($_REQUEST['filter_action'])) {
|
495 |
-
return false;
|
496 |
-
}
|
497 |
-
|
498 |
-
if (isset($_REQUEST['action']) && -1 != $_REQUEST['action']) {
|
499 |
-
return $_REQUEST['action'];
|
500 |
-
}
|
501 |
-
|
502 |
-
if (isset($_REQUEST['action2']) && -1 != $_REQUEST['action2']) {
|
503 |
-
return $_REQUEST['action2'];
|
504 |
-
}
|
505 |
-
|
506 |
-
return false;
|
507 |
-
}
|
508 |
-
|
509 |
-
/**
|
510 |
-
* Generate row actions div
|
511 |
-
*
|
512 |
-
* @since 3.1.0
|
513 |
-
* @access protected
|
514 |
-
*
|
515 |
-
* @param array $actions The list of actions
|
516 |
-
* @param bool $always_visible Whether the actions should be always visible
|
517 |
-
* @return string
|
518 |
-
*/
|
519 |
-
protected function row_actions($actions, $always_visible = false)
|
520 |
-
{
|
521 |
-
$action_count = count($actions);
|
522 |
-
$i = 0;
|
523 |
-
|
524 |
-
if (!$action_count) {
|
525 |
-
return '';
|
526 |
-
}
|
527 |
-
|
528 |
-
$out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
|
529 |
-
foreach ($actions as $action => $link) {
|
530 |
-
++$i;
|
531 |
-
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
532 |
-
$out .= "<span class='$action'>$link$sep</span>";
|
533 |
-
}
|
534 |
-
$out .= '</div>';
|
535 |
-
|
536 |
-
return $out;
|
537 |
-
}
|
538 |
-
|
539 |
-
/**
|
540 |
-
* Display a monthly dropdown for filtering items
|
541 |
-
*
|
542 |
-
* @since 3.1.0
|
543 |
-
* @access protected
|
544 |
-
*
|
545 |
-
* @param string $post_type
|
546 |
-
*/
|
547 |
-
protected function months_dropdown($post_type)
|
548 |
-
{
|
549 |
-
global $wpdb, $wp_locale;
|
550 |
-
|
551 |
-
/**
|
552 |
-
* Filter whether to remove the 'Months' drop-down from the post list table.
|
553 |
-
*
|
554 |
-
* @since 4.2.0
|
555 |
-
*
|
556 |
-
* @param bool $disable Whether to disable the drop-down. Default false.
|
557 |
-
* @param string $post_type The post type.
|
558 |
-
*/
|
559 |
-
if (apply_filters('disable_months_dropdown', false, $post_type)) {
|
560 |
-
return;
|
561 |
-
}
|
562 |
-
|
563 |
-
$months = $wpdb->get_results($wpdb->prepare("
|
564 |
-
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
565 |
-
FROM $wpdb->posts
|
566 |
-
WHERE post_type = %s
|
567 |
-
ORDER BY post_date DESC
|
568 |
-
", $post_type));
|
569 |
-
|
570 |
-
/**
|
571 |
-
* Filter the 'Months' drop-down results.
|
572 |
-
*
|
573 |
-
* @since 3.7.0
|
574 |
-
*
|
575 |
-
* @param object $months The months drop-down query results.
|
576 |
-
* @param string $post_type The post type.
|
577 |
-
*/
|
578 |
-
$months = apply_filters('months_dropdown_results', $months, $post_type);
|
579 |
-
|
580 |
-
$month_count = count($months);
|
581 |
-
|
582 |
-
if (!$month_count || ( 1 == $month_count && 0 == $months[0]->month )) {
|
583 |
-
return;
|
584 |
-
}
|
585 |
-
|
586 |
-
$m = isset($_GET['m']) ? (int) $_GET['m'] : 0;
|
587 |
-
?>
|
588 |
-
<label for="filter-by-date" class="screen-reader-text"><?php _e('Filter by date'); ?></label>
|
589 |
-
<select name="m" id="filter-by-date">
|
590 |
-
<option<?php selected($m, 0); ?> value="0"><?php _e('All dates'); ?></option>
|
591 |
-
<?php
|
592 |
-
foreach ($months as $arc_row) {
|
593 |
-
if (0 == $arc_row->year) {
|
594 |
-
continue;
|
595 |
-
}
|
596 |
-
|
597 |
-
$month = zeroise($arc_row->month, 2);
|
598 |
-
$year = $arc_row->year;
|
599 |
-
|
600 |
-
printf(
|
601 |
-
"<option %s value='%s'>%s</option>\n",
|
602 |
-
selected($m, $year . $month, false),
|
603 |
-
esc_attr($arc_row->year . $month),
|
604 |
-
/* translators: 1: month name, 2: 4-digit year */
|
605 |
-
sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year)
|
606 |
-
);
|
607 |
-
}
|
608 |
-
?>
|
609 |
-
</select>
|
610 |
-
<?php
|
611 |
-
}
|
612 |
-
|
613 |
-
/**
|
614 |
-
* Display a view switcher
|
615 |
-
*
|
616 |
-
* @since 3.1.0
|
617 |
-
* @access protected
|
618 |
-
*
|
619 |
-
* @param string $current_mode
|
620 |
-
*/
|
621 |
-
protected function view_switcher($current_mode)
|
622 |
-
{
|
623 |
-
?>
|
624 |
-
<input type="hidden" name="mode" value="<?php echo esc_attr($current_mode); ?>" />
|
625 |
-
<div class="view-switch">
|
626 |
-
<?php
|
627 |
-
foreach ($this->modes as $mode => $title) {
|
628 |
-
$classes = array( 'view-' . $mode );
|
629 |
-
if ($current_mode == $mode) {
|
630 |
-
$classes[] = 'current';
|
631 |
-
}
|
632 |
-
printf(
|
633 |
-
"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
|
634 |
-
esc_url(add_query_arg('mode', $mode)),
|
635 |
-
implode(' ', $classes),
|
636 |
-
$title
|
637 |
-
);
|
638 |
-
}
|
639 |
-
?>
|
640 |
-
</div>
|
641 |
-
<?php
|
642 |
-
}
|
643 |
-
|
644 |
-
/**
|
645 |
-
* Display a comment count bubble
|
646 |
-
*
|
647 |
-
* @since 3.1.0
|
648 |
-
* @access protected
|
649 |
-
*
|
650 |
-
* @param int $post_id The post ID.
|
651 |
-
* @param int $pending_comments Number of pending comments.
|
652 |
-
*/
|
653 |
-
protected function comments_bubble($post_id, $pending_comments)
|
654 |
-
{
|
655 |
-
$pending_phrase = sprintf(__('%s pending'), number_format($pending_comments));
|
656 |
-
|
657 |
-
if ($pending_comments) {
|
658 |
-
echo '<strong>';
|
659 |
-
}
|
660 |
-
|
661 |
-
printf(
|
662 |
-
'<a href="%s" title="%s" class="post-com-count"><span class="comment-count">%s</span></a>',
|
663 |
-
esc_url(add_query_arg('p', $post_id, admin_url('edit-comments.php'))),
|
664 |
-
esc_attr($pending_phrase),
|
665 |
-
number_format_i18n(get_comments_number())
|
666 |
-
);
|
667 |
-
|
668 |
-
if ($pending_comments) {
|
669 |
-
echo '</strong>';
|
670 |
-
}
|
671 |
-
}
|
672 |
-
|
673 |
-
/**
|
674 |
-
* Get the current page number
|
675 |
-
*
|
676 |
-
* @since 3.1.0
|
677 |
-
* @access public
|
678 |
-
*
|
679 |
-
* @return int
|
680 |
-
*/
|
681 |
-
public function get_pagenum()
|
682 |
-
{
|
683 |
-
$pagenum = isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 0;
|
684 |
-
|
685 |
-
if (isset($this->_pagination_args['total_pages']) && $pagenum > $this->_pagination_args['total_pages']) {
|
686 |
-
$pagenum = $this->_pagination_args['total_pages'];
|
687 |
-
}
|
688 |
-
|
689 |
-
return max(1, $pagenum);
|
690 |
-
}
|
691 |
-
|
692 |
-
/**
|
693 |
-
* Get number of items to display on a single page
|
694 |
-
*
|
695 |
-
* @since 3.1.0
|
696 |
-
* @access protected
|
697 |
-
*
|
698 |
-
* @param string $option
|
699 |
-
* @param int $default
|
700 |
-
* @return int
|
701 |
-
*/
|
702 |
-
protected function get_items_per_page($option, $default = 20)
|
703 |
-
{
|
704 |
-
$per_page = (int) get_user_option($option);
|
705 |
-
if (empty($per_page) || $per_page < 1) {
|
706 |
-
$per_page = $default;
|
707 |
-
}
|
708 |
-
|
709 |
-
/**
|
710 |
-
* Filter the number of items to be displayed on each page of the list table.
|
711 |
-
*
|
712 |
-
* The dynamic hook name, $option, refers to the `per_page` option depending
|
713 |
-
* on the type of list table in use. Possible values include: 'edit_comments_per_page',
|
714 |
-
* 'sites_network_per_page', 'site_themes_network_per_page', 'themes_network_per_page',
|
715 |
-
* 'users_network_per_page', 'edit_post_per_page', 'edit_page_per_page',
|
716 |
-
* 'edit_{$post_type}_per_page', etc.
|
717 |
-
*
|
718 |
-
* @since 2.9.0
|
719 |
-
*
|
720 |
-
* @param int $per_page Number of items to be displayed. Default 20.
|
721 |
-
*/
|
722 |
-
return (int) apply_filters($option, $per_page);
|
723 |
-
}
|
724 |
-
|
725 |
-
/**
|
726 |
-
* Display the pagination.
|
727 |
-
*
|
728 |
-
* @since 3.1.0
|
729 |
-
* @access protected
|
730 |
-
*
|
731 |
-
* @param string $which
|
732 |
-
*/
|
733 |
-
protected function pagination($which)
|
734 |
-
{
|
735 |
-
if (empty($this->_pagination_args)) {
|
736 |
-
return;
|
737 |
-
}
|
738 |
-
|
739 |
-
$total_items = $this->_pagination_args['total_items'];
|
740 |
-
$total_pages = $this->_pagination_args['total_pages'];
|
741 |
-
$infinite_scroll = false;
|
742 |
-
if (isset($this->_pagination_args['infinite_scroll'])) {
|
743 |
-
$infinite_scroll = $this->_pagination_args['infinite_scroll'];
|
744 |
-
}
|
745 |
-
|
746 |
-
$output = '<span class="displaying-num">'
|
747 |
-
. sprintf(_n('1 item', '%s items', $total_items), number_format_i18n($total_items))
|
748 |
-
. '</span>';
|
749 |
-
|
750 |
-
$current = $this->get_pagenum();
|
751 |
-
|
752 |
-
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
753 |
-
|
754 |
-
$current_url = remove_query_arg(array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url);
|
755 |
-
|
756 |
-
$page_links = array();
|
757 |
-
|
758 |
-
$disable_first = $disable_last = '';
|
759 |
-
if ($current == 1) {
|
760 |
-
$disable_first = ' disabled';
|
761 |
-
}
|
762 |
-
if ($current == $total_pages) {
|
763 |
-
$disable_last = ' disabled';
|
764 |
-
}
|
765 |
-
$page_links[] = sprintf(
|
766 |
-
"<a class='%s' title='%s' href='%s'>%s</a>",
|
767 |
-
'first-page' . $disable_first,
|
768 |
-
esc_attr__('Go to the first page'),
|
769 |
-
esc_url(remove_query_arg('paged', $current_url)),
|
770 |
-
'«'
|
771 |
-
);
|
772 |
-
|
773 |
-
$page_links[] = sprintf(
|
774 |
-
"<a class='%s' title='%s' href='%s'>%s</a>",
|
775 |
-
'prev-page' . $disable_first,
|
776 |
-
esc_attr__('Go to the previous page'),
|
777 |
-
esc_url(add_query_arg('paged', max(1, $current-1), $current_url)),
|
778 |
-
'‹'
|
779 |
-
);
|
780 |
-
|
781 |
-
if ('bottom' == $which) {
|
782 |
-
$html_current_page = $current;
|
783 |
-
} else {
|
784 |
-
$html_current_page = sprintf(
|
785 |
-
"%s<input class='current-page' id='current-page-selector' title='%s'
|
786 |
-
type='text'name='paged' value='%s' size='%d' />",
|
787 |
-
'<label for="current-page-selector" class="screen-reader-text">' . __('Select Page') . '</label>',
|
788 |
-
esc_attr__('Current page'),
|
789 |
-
$current,
|
790 |
-
strlen($total_pages)
|
791 |
-
);
|
792 |
-
}
|
793 |
-
$html_total_pages = sprintf("<span class='total-pages'>%s</span>", number_format_i18n($total_pages));
|
794 |
-
$page_links[] = '<span class="paging-input">'
|
795 |
-
. sprintf(_x('%1$s of %2$s', 'paging'), $html_current_page, $html_total_pages)
|
796 |
-
. '</span>';
|
797 |
-
|
798 |
-
$page_links[] = sprintf(
|
799 |
-
"<a class='%s' title='%s' href='%s'>%s</a>",
|
800 |
-
'next-page' . $disable_last,
|
801 |
-
esc_attr__('Go to the next page'),
|
802 |
-
esc_url(add_query_arg('paged', min($total_pages, $current+1), $current_url)),
|
803 |
-
'›'
|
804 |
-
);
|
805 |
-
|
806 |
-
$page_links[] = sprintf(
|
807 |
-
"<a class='%s' title='%s' href='%s'>%s</a>",
|
808 |
-
'last-page' . $disable_last,
|
809 |
-
esc_attr__('Go to the last page'),
|
810 |
-
esc_url(add_query_arg('paged', $total_pages, $current_url)),
|
811 |
-
'»'
|
812 |
-
);
|
813 |
-
|
814 |
-
$pagination_links_class = 'pagination-links';
|
815 |
-
if (! empty($infinite_scroll)) {
|
816 |
-
$pagination_links_class = ' hide-if-js';
|
817 |
-
}
|
818 |
-
$output .= "\n<span class='$pagination_links_class'>" . join("\n", $page_links) . '</span>';
|
819 |
-
|
820 |
-
if ($total_pages) {
|
821 |
-
$page_class = $total_pages < 2 ? ' one-page' : '';
|
822 |
-
} else {
|
823 |
-
$page_class = ' no-pages';
|
824 |
-
}
|
825 |
-
$this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>";
|
826 |
-
|
827 |
-
echo $this->_pagination;
|
828 |
-
}
|
829 |
-
|
830 |
-
/**
|
831 |
-
* Get a list of columns. The format is:
|
832 |
-
* 'internal-name' => 'Title'
|
833 |
-
*
|
834 |
-
* @since 3.1.0
|
835 |
-
* @access public
|
836 |
-
* @abstract
|
837 |
-
*
|
838 |
-
* @return array
|
839 |
-
*/
|
840 |
-
public function get_columns()
|
841 |
-
{
|
842 |
-
die('function WP_List_Table::get_columns() must be over-ridden in a sub-class.');
|
843 |
-
}
|
844 |
-
|
845 |
-
/**
|
846 |
-
* Get a list of sortable columns. The format is:
|
847 |
-
* 'internal-name' => 'orderby'
|
848 |
-
* or
|
849 |
-
* 'internal-name' => array( 'orderby', true )
|
850 |
-
*
|
851 |
-
* The second format will make the initial sorting order be descending
|
852 |
-
*
|
853 |
-
* @since 3.1.0
|
854 |
-
* @access protected
|
855 |
-
*
|
856 |
-
* @return array
|
857 |
-
*/
|
858 |
-
protected function get_sortable_columns()
|
859 |
-
{
|
860 |
-
return array();
|
861 |
-
}
|
862 |
-
|
863 |
-
/**
|
864 |
-
* Get a list of all, hidden and sortable columns, with filter applied
|
865 |
-
*
|
866 |
-
* @since 3.1.0
|
867 |
-
* @access protected
|
868 |
-
*
|
869 |
-
* @return array
|
870 |
-
*/
|
871 |
-
protected function get_column_info()
|
872 |
-
{
|
873 |
-
if (isset($this->_column_headers)) {
|
874 |
-
return $this->_column_headers;
|
875 |
-
}
|
876 |
-
|
877 |
-
$columns = get_column_headers($this->screen);
|
878 |
-
$hidden = get_hidden_columns($this->screen);
|
879 |
-
|
880 |
-
$sortable_columns = $this->get_sortable_columns();
|
881 |
-
/**
|
882 |
-
* Filter the list table sortable columns for a specific screen.
|
883 |
-
*
|
884 |
-
* The dynamic portion of the hook name, `$this->screen->id`, refers
|
885 |
-
* to the ID of the current screen, usually a string.
|
886 |
-
*
|
887 |
-
* @since 3.5.0
|
888 |
-
*
|
889 |
-
* @param array $sortable_columns An array of sortable columns.
|
890 |
-
*/
|
891 |
-
$_sortable = apply_filters("manage_{$this->screen->id}_sortable_columns", $sortable_columns);
|
892 |
-
|
893 |
-
$sortable = array();
|
894 |
-
foreach ($_sortable as $id => $data) {
|
895 |
-
if (empty($data)) {
|
896 |
-
continue;
|
897 |
-
}
|
898 |
-
|
899 |
-
$data = (array) $data;
|
900 |
-
if (!isset($data[1])) {
|
901 |
-
$data[1] = false;
|
902 |
-
}
|
903 |
-
|
904 |
-
$sortable[$id] = $data;
|
905 |
-
}
|
906 |
-
|
907 |
-
$this->_column_headers = array( $columns, $hidden, $sortable );
|
908 |
-
|
909 |
-
return $this->_column_headers;
|
910 |
-
}
|
911 |
-
|
912 |
-
/**
|
913 |
-
* Return number of visible columns
|
914 |
-
*
|
915 |
-
* @since 3.1.0
|
916 |
-
* @access public
|
917 |
-
*
|
918 |
-
* @return int
|
919 |
-
*/
|
920 |
-
public function get_column_count()
|
921 |
-
{
|
922 |
-
list ( $columns, $hidden ) = $this->get_column_info();
|
923 |
-
$hidden = array_intersect(array_keys($columns), array_filter($hidden));
|
924 |
-
return count($columns) - count($hidden);
|
925 |
-
}
|
926 |
-
|
927 |
-
/**
|
928 |
-
* Print column headers, accounting for hidden and sortable columns.
|
929 |
-
*
|
930 |
-
* @since 3.1.0
|
931 |
-
* @access public
|
932 |
-
*
|
933 |
-
* @param bool $with_id Whether to set the id attribute or not
|
934 |
-
*/
|
935 |
-
public function print_column_headers($with_id = true)
|
936 |
-
{
|
937 |
-
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
938 |
-
|
939 |
-
$current_url = set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
940 |
-
$current_url = remove_query_arg('paged', $current_url);
|
941 |
-
|
942 |
-
if (isset($_GET['orderby'])) {
|
943 |
-
$current_orderby = $_GET['orderby'];
|
944 |
-
} else {
|
945 |
-
$current_orderby = '';
|
946 |
-
}
|
947 |
-
|
948 |
-
if (isset($_GET['order']) && 'desc' == $_GET['order']) {
|
949 |
-
$current_order = 'desc';
|
950 |
-
} else {
|
951 |
-
$current_order = 'asc';
|
952 |
-
}
|
953 |
-
|
954 |
-
if (! empty($columns['cb'])) {
|
955 |
-
static $cb_counter = 1;
|
956 |
-
$columns['cb'] = sprintf(
|
957 |
-
'<label class="screen-reader-text" for="cb-select-all-%s">%s</label>
|
958 |
-
<input id="cb-select-all-%s" type="checkbox" />',
|
959 |
-
$cb_counter,
|
960 |
-
__('Select All'),
|
961 |
-
$cb_counter
|
962 |
-
);
|
963 |
-
$cb_counter++;
|
964 |
-
}
|
965 |
-
|
966 |
-
foreach ($columns as $column_key => $column_display_name) {
|
967 |
-
$class = array( 'manage-column', "column-$column_key" );
|
968 |
-
|
969 |
-
$style = '';
|
970 |
-
if (in_array($column_key, $hidden)) {
|
971 |
-
$style = 'display:none;';
|
972 |
-
}
|
973 |
-
|
974 |
-
$style = ' style="' . $style . '"';
|
975 |
-
|
976 |
-
if ('cb' == $column_key) {
|
977 |
-
$class[] = 'check-column';
|
978 |
-
} elseif (in_array($column_key, array( 'posts', 'comments', 'links' ))) {
|
979 |
-
$class[] = 'num';
|
980 |
-
}
|
981 |
-
|
982 |
-
if (isset($sortable[$column_key])) {
|
983 |
-
list( $orderby, $desc_first ) = $sortable[$column_key];
|
984 |
-
|
985 |
-
if ($current_orderby == $orderby) {
|
986 |
-
$order = 'asc' == $current_order ? 'desc' : 'asc';
|
987 |
-
$class[] = 'sorted';
|
988 |
-
$class[] = $current_order;
|
989 |
-
} else {
|
990 |
-
$order = $desc_first ? 'desc' : 'asc';
|
991 |
-
$class[] = 'sortable';
|
992 |
-
$class[] = $desc_first ? 'asc' : 'desc';
|
993 |
-
}
|
994 |
-
|
995 |
-
$column_display_name = sprintf(
|
996 |
-
'<a href="%s"><span>%s</span><span class="sorting-indicator"></span></a>',
|
997 |
-
esc_url(add_query_arg(compact('orderby', 'order'), $current_url)),
|
998 |
-
$column_display_name
|
999 |
-
);
|
1000 |
-
}
|
1001 |
-
|
1002 |
-
$id = $with_id ? "id='$column_key'" : '';
|
1003 |
-
|
1004 |
-
if (!empty($class)) {
|
1005 |
-
$class = "class='" . join(' ', $class) . "'";
|
1006 |
-
}
|
1007 |
-
|
1008 |
-
echo "<th scope='col' $id $class $style>$column_display_name</th>";
|
1009 |
-
}
|
1010 |
-
}
|
1011 |
-
|
1012 |
-
/**
|
1013 |
-
* Display the table
|
1014 |
-
*
|
1015 |
-
* @since 3.1.0
|
1016 |
-
* @access public
|
1017 |
-
*/
|
1018 |
-
public function display()
|
1019 |
-
{
|
1020 |
-
$singular = $this->_args['singular'];
|
1021 |
-
|
1022 |
-
$this->display_tablenav('top');
|
1023 |
-
|
1024 |
-
?>
|
1025 |
-
<table class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>">
|
1026 |
-
<thead>
|
1027 |
-
<tr>
|
1028 |
-
<?php $this->print_column_headers(); ?>
|
1029 |
-
</tr>
|
1030 |
-
</thead>
|
1031 |
-
|
1032 |
-
<tbody id="the-list"<?php
|
1033 |
-
if ($singular) {
|
1034 |
-
echo " data-wp-lists='list:$singular'";
|
1035 |
-
} ?>>
|
1036 |
-
<?php $this->display_rows_or_placeholder(); ?>
|
1037 |
-
</tbody>
|
1038 |
-
|
1039 |
-
<tfoot>
|
1040 |
-
<tr>
|
1041 |
-
<?php $this->print_column_headers(false); ?>
|
1042 |
-
</tr>
|
1043 |
-
</tfoot>
|
1044 |
-
|
1045 |
-
</table>
|
1046 |
-
<?php
|
1047 |
-
$this->display_tablenav('bottom');
|
1048 |
-
}
|
1049 |
-
|
1050 |
-
/**
|
1051 |
-
* Get a list of CSS classes for the list table table tag.
|
1052 |
-
*
|
1053 |
-
* @since 3.1.0
|
1054 |
-
* @access protected
|
1055 |
-
*
|
1056 |
-
* @return array List of CSS classes for the table tag.
|
1057 |
-
*/
|
1058 |
-
protected function get_table_classes()
|
1059 |
-
{
|
1060 |
-
return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] );
|
1061 |
-
}
|
1062 |
-
|
1063 |
-
/**
|
1064 |
-
* Generate the table navigation above or below the table
|
1065 |
-
*
|
1066 |
-
* @since 3.1.0
|
1067 |
-
* @access protected
|
1068 |
-
* @param string $which
|
1069 |
-
*/
|
1070 |
-
protected function display_tablenav($which)
|
1071 |
-
{
|
1072 |
-
if ('top' == $which) {
|
1073 |
-
wp_nonce_field('bulk-' . $this->_args['plural']);
|
1074 |
-
}
|
1075 |
-
?>
|
1076 |
-
<div class="tablenav <?php echo esc_attr($which); ?>">
|
1077 |
-
|
1078 |
-
<div class="alignleft actions bulkactions">
|
1079 |
-
<?php $this->bulk_actions($which); ?>
|
1080 |
-
</div>
|
1081 |
-
<?php
|
1082 |
-
$this->extra_tablenav($which);
|
1083 |
-
$this->pagination($which);
|
1084 |
-
?>
|
1085 |
-
|
1086 |
-
<br class="clear" />
|
1087 |
-
</div>
|
1088 |
-
<?php
|
1089 |
-
}
|
1090 |
-
|
1091 |
-
/**
|
1092 |
-
* Extra controls to be displayed between bulk actions and pagination
|
1093 |
-
*
|
1094 |
-
* @since 3.1.0
|
1095 |
-
* @access protected
|
1096 |
-
*
|
1097 |
-
* @param string $which
|
1098 |
-
*/
|
1099 |
-
protected function extra_tablenav($which)
|
1100 |
-
{
|
1101 |
-
}
|
1102 |
-
|
1103 |
-
/**
|
1104 |
-
* Generate the tbody element for the list table.
|
1105 |
-
*
|
1106 |
-
* @since 3.1.0
|
1107 |
-
* @access public
|
1108 |
-
*/
|
1109 |
-
public function display_rows_or_placeholder()
|
1110 |
-
{
|
1111 |
-
if ($this->has_items()) {
|
1112 |
-
$this->display_rows();
|
1113 |
-
} else {
|
1114 |
-
echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
|
1115 |
-
$this->no_items();
|
1116 |
-
echo '</td></tr>';
|
1117 |
-
}
|
1118 |
-
}
|
1119 |
-
|
1120 |
-
/**
|
1121 |
-
* Generate the table rows
|
1122 |
-
*
|
1123 |
-
* @since 3.1.0
|
1124 |
-
* @access public
|
1125 |
-
*/
|
1126 |
-
public function display_rows()
|
1127 |
-
{
|
1128 |
-
foreach ($this->items as $item) {
|
1129 |
-
$this->single_row($item);
|
1130 |
-
}
|
1131 |
-
}
|
1132 |
-
|
1133 |
-
/**
|
1134 |
-
* Generates content for a single row of the table
|
1135 |
-
*
|
1136 |
-
* @since 3.1.0
|
1137 |
-
* @access public
|
1138 |
-
*
|
1139 |
-
* @param object $item The current item
|
1140 |
-
*/
|
1141 |
-
public function single_row($item)
|
1142 |
-
{
|
1143 |
-
echo '<tr>';
|
1144 |
-
$this->single_row_columns($item);
|
1145 |
-
echo '</tr>';
|
1146 |
-
}
|
1147 |
-
|
1148 |
-
protected function column_default($item, $column_name)
|
1149 |
-
{
|
1150 |
-
}
|
1151 |
-
|
1152 |
-
protected function column_cb($item)
|
1153 |
-
{
|
1154 |
-
}
|
1155 |
-
|
1156 |
-
/**
|
1157 |
-
* Generates the columns for a single row of the table
|
1158 |
-
*
|
1159 |
-
* @since 3.1.0
|
1160 |
-
* @access protected
|
1161 |
-
*
|
1162 |
-
* @param object $item The current item
|
1163 |
-
*/
|
1164 |
-
protected function single_row_columns($item)
|
1165 |
-
{
|
1166 |
-
list( $columns, $hidden ) = $this->get_column_info();
|
1167 |
-
|
1168 |
-
foreach ($columns as $column_name => $column_display_name) {
|
1169 |
-
$class = "class='$column_name column-$column_name'";
|
1170 |
-
|
1171 |
-
$style = '';
|
1172 |
-
if (in_array($column_name, $hidden)) {
|
1173 |
-
$style = ' style="display:none;"';
|
1174 |
-
}
|
1175 |
-
|
1176 |
-
$attributes = "$class$style";
|
1177 |
-
|
1178 |
-
if ('cb' == $column_name) {
|
1179 |
-
echo '<th scope="row" class="check-column">';
|
1180 |
-
echo $this->column_cb($item);
|
1181 |
-
echo '</th>';
|
1182 |
-
} elseif (method_exists($this, 'column_' . $column_name)) {
|
1183 |
-
echo "<td $attributes>";
|
1184 |
-
echo call_user_func(array( $this, 'column_' . $column_name ), $item);
|
1185 |
-
echo "</td>";
|
1186 |
-
} else {
|
1187 |
-
echo "<td $attributes>";
|
1188 |
-
echo $this->column_default($item, $column_name);
|
1189 |
-
echo "</td>";
|
1190 |
-
}
|
1191 |
-
}
|
1192 |
-
}
|
1193 |
-
|
1194 |
-
/**
|
1195 |
-
* Handle an incoming ajax request (called from admin-ajax.php)
|
1196 |
-
*
|
1197 |
-
* @since 3.1.0
|
1198 |
-
* @access public
|
1199 |
-
*/
|
1200 |
-
public function ajax_response()
|
1201 |
-
{
|
1202 |
-
$this->prepare_items();
|
1203 |
-
|
1204 |
-
ob_start();
|
1205 |
-
if (! empty($_REQUEST['no_placeholder'])) {
|
1206 |
-
$this->display_rows();
|
1207 |
-
} else {
|
1208 |
-
$this->display_rows_or_placeholder();
|
1209 |
-
}
|
1210 |
-
|
1211 |
-
$rows = ob_get_clean();
|
1212 |
-
|
1213 |
-
$response = array( 'rows' => $rows );
|
1214 |
-
|
1215 |
-
if (isset($this->_pagination_args['total_items'])) {
|
1216 |
-
$response['total_items_i18n'] = sprintf(
|
1217 |
-
_n('1 item', '%s items', $this->_pagination_args['total_items']),
|
1218 |
-
number_format_i18n($this->_pagination_args['total_items'])
|
1219 |
-
);
|
1220 |
-
}
|
1221 |
-
if (isset($this->_pagination_args['total_pages'])) {
|
1222 |
-
$response['total_pages'] = $this->_pagination_args['total_pages'];
|
1223 |
-
$response['total_pages_i18n'] = number_format_i18n($this->_pagination_args['total_pages']);
|
1224 |
-
}
|
1225 |
-
|
1226 |
-
die(wp_json_encode($response));
|
1227 |
-
}
|
1228 |
-
|
1229 |
-
/**
|
1230 |
-
* Send required variables to JavaScript land
|
1231 |
-
*
|
1232 |
-
* @access public
|
1233 |
-
*/
|
1234 |
-
public function _js_vars()
|
1235 |
-
{
|
1236 |
-
$args = array(
|
1237 |
-
'class' => get_class($this),
|
1238 |
-
'screen' => array(
|
1239 |
-
'id' => $this->screen->id,
|
1240 |
-
'base' => $this->screen->base,
|
1241 |
-
)
|
1242 |
-
);
|
1243 |
-
|
1244 |
-
printf("<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode($args));
|
1245 |
-
}
|
1246 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/Unbounce-Page.php
DELETED
@@ -1,340 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
Plugin Name: Unbounce Landing Pages
|
4 |
-
Plugin URI: http://unbounce.com
|
5 |
-
Description: Unbounce is the most powerful standalone landing page builder available.
|
6 |
-
Version: 1.0.36
|
7 |
-
Author: Unbounce
|
8 |
-
Author URI: http://unbounce.com
|
9 |
-
License: GPLv2
|
10 |
-
*/
|
11 |
-
|
12 |
-
require_once dirname(__FILE__) . '/UBCompatibility.php';
|
13 |
-
require_once dirname(__FILE__) . '/UBDiagnostics.php';
|
14 |
-
require_once dirname(__FILE__) . '/UBUtil.php';
|
15 |
-
require_once dirname(__FILE__) . '/UBConfig.php';
|
16 |
-
require_once dirname(__FILE__) . '/UBLogger.php';
|
17 |
-
require_once dirname(__FILE__) . '/UBHTTP.php';
|
18 |
-
require_once dirname(__FILE__) . '/UBIcon.php';
|
19 |
-
require_once dirname(__FILE__) . '/UBWPListTable.php';
|
20 |
-
require_once dirname(__FILE__) . '/UBPageTable.php';
|
21 |
-
require_once dirname(__FILE__) . '/UBEvents.php';
|
22 |
-
require_once dirname(__FILE__) . '/UBTemplate.php';
|
23 |
-
|
24 |
-
register_activation_hook(__FILE__, function () {
|
25 |
-
add_option(UBConfig::UB_ROUTES_CACHE_KEY, array());
|
26 |
-
add_option(UBConfig::UB_REMOTE_DEBUG_KEY, 0);
|
27 |
-
add_option(
|
28 |
-
UBConfig::UB_PAGE_SERVER_DOMAIN_KEY,
|
29 |
-
UBConfig::default_page_server_domain()
|
30 |
-
);
|
31 |
-
add_option(
|
32 |
-
UBConfig::UB_REMOTE_LOG_URL_KEY,
|
33 |
-
UBConfig::default_remote_log_url()
|
34 |
-
);
|
35 |
-
add_option(
|
36 |
-
UBConfig::UB_API_URL_KEY,
|
37 |
-
UBConfig::default_api_url()
|
38 |
-
);
|
39 |
-
add_option(
|
40 |
-
UBConfig::UB_API_CLIENT_ID_KEY,
|
41 |
-
UBConfig::default_api_client_id()
|
42 |
-
);
|
43 |
-
add_option(
|
44 |
-
UBConfig::UB_AUTHORIZED_DOMAINS_KEY,
|
45 |
-
UBConfig::default_authorized_domains()
|
46 |
-
);
|
47 |
-
add_option(UBConfig::UB_HAS_AUTHORIZED_KEY, '');
|
48 |
-
add_option(
|
49 |
-
UBConfig::UB_REMOTE_EVENTS_URL_KEY,
|
50 |
-
UBConfig::default_remote_events_url()
|
51 |
-
);
|
52 |
-
add_option(UBConfig::UB_USER_ID_KEY, '');
|
53 |
-
add_option(UBConfig::UB_DOMAIN_ID_KEY, '');
|
54 |
-
add_option(UBConfig::UB_CLIENT_ID_KEY, '');
|
55 |
-
add_option(UBConfig::UB_PROXY_ERROR_MESSAGE_KEY, '');
|
56 |
-
add_option(UBConfig::UB_ALLOW_PUBLIC_ADDRESS_X_FORWARDED_FOR, 0);
|
57 |
-
add_option(UBConfig::UB_PLUGIN_VERSION_KEY, UBConfig::UB_VERSION);
|
58 |
-
|
59 |
-
// NOTE: This should be brought back when working on BEE-1136
|
60 |
-
// @UBDiagnostics::sendActivationEvent();
|
61 |
-
});
|
62 |
-
|
63 |
-
register_deactivation_hook(__FILE__, function () {
|
64 |
-
foreach (UBConfig::ub_option_keys() as $key) {
|
65 |
-
delete_option($key);
|
66 |
-
}
|
67 |
-
});
|
68 |
-
|
69 |
-
add_action('init', function () {
|
70 |
-
UBLogger::setup_logger();
|
71 |
-
|
72 |
-
$domain = UBConfig::domain();
|
73 |
-
|
74 |
-
if (!UBConfig::is_authorized_domain($domain)) {
|
75 |
-
UBLogger::info("Domain: $domain has not been authorized");
|
76 |
-
return;
|
77 |
-
}
|
78 |
-
|
79 |
-
$start = microtime(true);
|
80 |
-
|
81 |
-
$ps_domain = UBConfig::page_server_domain();
|
82 |
-
$http_method = UBUtil::array_fetch($_SERVER, 'REQUEST_METHOD');
|
83 |
-
$referer = UBUtil::array_fetch($_SERVER, 'HTTP_REFERER');
|
84 |
-
$user_agent = UBUtil::array_fetch($_SERVER, 'HTTP_USER_AGENT');
|
85 |
-
$protocol = UBHTTP::determine_protocol($_SERVER, is_ssl());
|
86 |
-
$current_path = UBUtil::array_fetch($_SERVER, 'REQUEST_URI');
|
87 |
-
|
88 |
-
$raw_url = $protocol . $ps_domain . $current_path;
|
89 |
-
$current_url = $protocol . $domain . $current_path;
|
90 |
-
|
91 |
-
$domain_info = UBConfig::read_unbounce_domain_info($domain, false);
|
92 |
-
$proxyable_url_set = UBUtil::array_fetch($domain_info, 'proxyable_url_set', array());
|
93 |
-
|
94 |
-
UBLogger::debug_var('ps_domain', $ps_domain);
|
95 |
-
UBLogger::debug_var('http_method', $http_method);
|
96 |
-
UBLogger::debug_var('referer', $referer);
|
97 |
-
UBLogger::debug_var('user_agent', $user_agent);
|
98 |
-
UBLogger::debug_var('protocol', $protocol);
|
99 |
-
UBLogger::debug_var('domain', $domain);
|
100 |
-
UBLogger::debug_var('current_path', $current_path);
|
101 |
-
UBLogger::debug_var('raw_url', $raw_url);
|
102 |
-
UBLogger::debug_var('current_url', $current_url);
|
103 |
-
|
104 |
-
////////////////////
|
105 |
-
|
106 |
-
$url_purpose = UBHTTP::get_url_purpose(
|
107 |
-
$proxyable_url_set,
|
108 |
-
$http_method,
|
109 |
-
$current_url
|
110 |
-
);
|
111 |
-
if ($url_purpose == null) {
|
112 |
-
UBLogger::debug("ignoring request to URL " . $current_url);
|
113 |
-
} elseif (is_user_logged_in() && UBUtil::is_wordpress_preview($_GET)) {
|
114 |
-
UBLogger::debug("Serving Wordpress Preview instead of landing page on root");
|
115 |
-
} elseif ($url_purpose == 'HealthCheck') {
|
116 |
-
if (UBConfig::domain_with_port() !== UBUtil::array_fetch($_SERVER, 'HTTP_HOST')) {
|
117 |
-
http_response_code(412);
|
118 |
-
}
|
119 |
-
|
120 |
-
header('Content-Type: application/json');
|
121 |
-
$version = UBConfig::UB_VERSION;
|
122 |
-
echo "{\"ub_wordpress\":{\"version\":\"$version\"}}";
|
123 |
-
exit(0);
|
124 |
-
} else {
|
125 |
-
// Disable caching plugins. This should take care of:
|
126 |
-
// - W3 Total Cache
|
127 |
-
// - WP Super Cache
|
128 |
-
// - ZenCache (Previously QuickCache)
|
129 |
-
if (!defined('DONOTCACHEPAGE')) {
|
130 |
-
define('DONOTCACHEPAGE', true);
|
131 |
-
}
|
132 |
-
|
133 |
-
if (!defined('DONOTCDN')) {
|
134 |
-
define('DONOTCDN', true);
|
135 |
-
}
|
136 |
-
|
137 |
-
if (!defined('DONOTCACHEDB')) {
|
138 |
-
define('DONOTCACHEDB', true);
|
139 |
-
}
|
140 |
-
|
141 |
-
if (!defined('DONOTMINIFY')) {
|
142 |
-
define('DONOTMINIFY', true);
|
143 |
-
}
|
144 |
-
|
145 |
-
if (!defined('DONOTCACHEOBJECT')) {
|
146 |
-
define('DONOTCACHEOBJECT', true);
|
147 |
-
}
|
148 |
-
|
149 |
-
UBLogger::debug("perform ''" . $url_purpose . "'' on received URL " . $current_url);
|
150 |
-
|
151 |
-
$cookies_to_forward = UBUtil::array_select_by_key(
|
152 |
-
$_COOKIE,
|
153 |
-
array('ubvs', 'ubpv', 'ubvt', 'hubspotutk')
|
154 |
-
);
|
155 |
-
|
156 |
-
$cookie_string = UBHTTP::cookie_string_from_array($cookies_to_forward);
|
157 |
-
|
158 |
-
$all_headers = getallheaders();
|
159 |
-
$all_headers['Host'] = $domain;
|
160 |
-
|
161 |
-
// Make sure we don't get cached by Wordpress hosts like WPEngine
|
162 |
-
header('Cache-Control: max-age=0; private');
|
163 |
-
|
164 |
-
list($success, $message) = UBHTTP::stream_request(
|
165 |
-
$http_method,
|
166 |
-
$raw_url,
|
167 |
-
$cookie_string,
|
168 |
-
$all_headers,
|
169 |
-
$user_agent
|
170 |
-
);
|
171 |
-
|
172 |
-
if ($success === false) {
|
173 |
-
update_option(UBConfig::UB_PROXY_ERROR_MESSAGE_KEY, $message);
|
174 |
-
}
|
175 |
-
|
176 |
-
$end = microtime(true);
|
177 |
-
$time_taken = ($end - $start) * 1000;
|
178 |
-
|
179 |
-
UBLogger::debug_var('time_taken', $time_taken);
|
180 |
-
UBLogger::debug("proxying for $current_url done successfuly -- took $time_taken ms");
|
181 |
-
|
182 |
-
exit(0);
|
183 |
-
}
|
184 |
-
}, UBConfig::int_min());
|
185 |
-
|
186 |
-
add_action('admin_init', function () {
|
187 |
-
|
188 |
-
// If plugin was updated, send event to unbounce
|
189 |
-
$pluginVersion = get_option(UBConfig::UB_PLUGIN_VERSION_KEY);
|
190 |
-
if (UBConfig::UB_VERSION != $pluginVersion) {
|
191 |
-
@UBDiagnostics::sendActivationEvent($pluginVersion);
|
192 |
-
update_option(UBConfig::UB_PLUGIN_VERSION_KEY, UBConfig::UB_VERSION);
|
193 |
-
}
|
194 |
-
|
195 |
-
UBUtil::clear_flash();
|
196 |
-
|
197 |
-
// Disable incompatible scripts
|
198 |
-
|
199 |
-
// WPML
|
200 |
-
wp_dequeue_script('installer-admin');
|
201 |
-
|
202 |
-
// Enqueue our own scripts
|
203 |
-
|
204 |
-
// Main page
|
205 |
-
wp_enqueue_script(
|
206 |
-
'ub-rx',
|
207 |
-
plugins_url('js/rx.lite.compat.min.js', __FILE__)
|
208 |
-
);
|
209 |
-
wp_enqueue_script(
|
210 |
-
'set-unbounce-domains-js',
|
211 |
-
plugins_url('js/set-unbounce-domains.js', __FILE__),
|
212 |
-
array('jquery', 'ub-rx')
|
213 |
-
);
|
214 |
-
wp_enqueue_script(
|
215 |
-
'unbounce-page-js',
|
216 |
-
plugins_url('js/unbounce-page.js', __FILE__),
|
217 |
-
array('jquery')
|
218 |
-
);
|
219 |
-
|
220 |
-
// Diagnostics page
|
221 |
-
wp_enqueue_script(
|
222 |
-
'ub-clipboard-js',
|
223 |
-
plugins_url('js/clipboard.min.js', __FILE__)
|
224 |
-
);
|
225 |
-
wp_enqueue_script(
|
226 |
-
'unbounce-diagnostics-js',
|
227 |
-
plugins_url('js/unbounce-diagnostics.js', __FILE__),
|
228 |
-
array('jquery', 'ub-clipboard-js')
|
229 |
-
);
|
230 |
-
// Re-enable incompatible scripts
|
231 |
-
|
232 |
-
// WPML
|
233 |
-
wp_enqueue_script('installer-admin');
|
234 |
-
|
235 |
-
wp_enqueue_style(
|
236 |
-
'unbounce-pages-css',
|
237 |
-
plugins_url('css/unbounce-pages.css', __FILE__)
|
238 |
-
);
|
239 |
-
}, 0);
|
240 |
-
|
241 |
-
add_action('admin_menu', function () {
|
242 |
-
// Main admin page
|
243 |
-
$print_admin_panel = function () {
|
244 |
-
$domain = UBConfig::domain();
|
245 |
-
$domain_info = UBConfig::read_unbounce_domain_info($domain, false);
|
246 |
-
|
247 |
-
echo UBTemplate::render(
|
248 |
-
'main',
|
249 |
-
array('domain_info' => $domain_info,
|
250 |
-
'domain' => $domain)
|
251 |
-
);
|
252 |
-
};
|
253 |
-
|
254 |
-
add_menu_page(
|
255 |
-
'Unbounce Pages',
|
256 |
-
'Unbounce Pages',
|
257 |
-
'manage_options',
|
258 |
-
'unbounce-pages',
|
259 |
-
$print_admin_panel,
|
260 |
-
UBIcon::base64_encoded_svg()
|
261 |
-
);
|
262 |
-
|
263 |
-
// Diagnostics page
|
264 |
-
$print_diagnostics_panel = function () {
|
265 |
-
$domain = UBConfig::domain();
|
266 |
-
$domain_info = UBConfig::read_unbounce_domain_info($domain, false);
|
267 |
-
|
268 |
-
echo UBTemplate::render(
|
269 |
-
'diagnostics',
|
270 |
-
array('img_url' => plugins_url('img/unbounce-logo-blue.png', __FILE__),
|
271 |
-
'checks' => UBDiagnostics::checks($domain, $domain_info),
|
272 |
-
'details' => UBDiagnostics::details($domain, $domain_info),
|
273 |
-
'domain' => $domain,
|
274 |
-
'permalink_url' => admin_url('options-permalink.php'),
|
275 |
-
'curl_error_message' => UBUtil::array_fetch(
|
276 |
-
$domain_info,
|
277 |
-
'failure_message'
|
278 |
-
))
|
279 |
-
);
|
280 |
-
};
|
281 |
-
|
282 |
-
add_submenu_page(
|
283 |
-
'unbounce-pages',
|
284 |
-
'Unbounce Pages Diagnostics',
|
285 |
-
'Unbounce Pages Diagnostics',
|
286 |
-
'manage_options',
|
287 |
-
'unbounce-pages-diagnostics',
|
288 |
-
$print_diagnostics_panel
|
289 |
-
);
|
290 |
-
});
|
291 |
-
|
292 |
-
add_action('admin_post_set_unbounce_domains', function () {
|
293 |
-
$domains_list = UBUtil::array_fetch($_POST, 'domains', '');
|
294 |
-
$domains = array_filter(explode(',', $domains_list), function ($domain) {
|
295 |
-
return $domain == UBConfig::domain();
|
296 |
-
});
|
297 |
-
|
298 |
-
if ($domains && is_array($domains)) {
|
299 |
-
$authorization = 'success';
|
300 |
-
$has_authorized = get_option(UBConfig::UB_HAS_AUTHORIZED_KEY, false);
|
301 |
-
|
302 |
-
$data = array(
|
303 |
-
'domain_name' => UBConfig::domain(),
|
304 |
-
'first_authorization' => !$has_authorized,
|
305 |
-
'user_id' => UBUtil::array_fetch($_POST, 'user_id', ''),
|
306 |
-
'client_id' => UBUtil::array_fetch($_POST, 'client_id', ''),
|
307 |
-
'domain_id' => UBUtil::array_fetch($_POST, 'domain_id', ''),
|
308 |
-
);
|
309 |
-
|
310 |
-
UBConfig::update_authorization_options($domains, $data);
|
311 |
-
|
312 |
-
if (UBConfig::is_authorized_domain(UBConfig::domain())) {
|
313 |
-
$event = UBEvents::successful_authorization_event($data);
|
314 |
-
} else {
|
315 |
-
$event = UBEvents::failed_authorization_event($data);
|
316 |
-
}
|
317 |
-
UBHTTP::send_event_to_events_gateway(UBConfig::remote_events_url(), $event);
|
318 |
-
} else {
|
319 |
-
$authorization = 'failure';
|
320 |
-
}
|
321 |
-
|
322 |
-
UBUtil::set_flash('authorization', $authorization);
|
323 |
-
|
324 |
-
status_header(301);
|
325 |
-
$location = admin_url('admin.php?page=unbounce-pages');
|
326 |
-
header("Location: $location");
|
327 |
-
});
|
328 |
-
|
329 |
-
add_action('admin_post_flush_unbounce_pages', function () {
|
330 |
-
$domain = UBConfig::domain();
|
331 |
-
// Expire cache and redirect
|
332 |
-
$_domain_info = UBConfig::read_unbounce_domain_info($domain, true);
|
333 |
-
status_header(301);
|
334 |
-
$location = admin_url('admin.php?page=unbounce-pages');
|
335 |
-
header("Location: $location");
|
336 |
-
});
|
337 |
-
|
338 |
-
add_action('shutdown', function () {
|
339 |
-
UBLogger::upload_logs_to_unbounce(UBConfig::remote_log_url());
|
340 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/css/unbounce-pages.css
DELETED
@@ -1,89 +0,0 @@
|
|
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 {
|
13 |
-
margin-top: 30px;
|
14 |
-
}
|
15 |
-
|
16 |
-
.ub-authorize-message {
|
17 |
-
margin-top: 30px;
|
18 |
-
}
|
19 |
-
|
20 |
-
.ub-published-pages-heading {
|
21 |
-
float: left;
|
22 |
-
margin-right: 10px;
|
23 |
-
}
|
24 |
-
|
25 |
-
.ub-need-help-header {
|
26 |
-
margin-bottom: 7px;
|
27 |
-
}
|
28 |
-
|
29 |
-
.ub-version {
|
30 |
-
text-align: right;
|
31 |
-
}
|
32 |
-
|
33 |
-
.ub-page-list {
|
34 |
-
margin: 0;
|
35 |
-
padding: 0 20px 0 0;
|
36 |
-
}
|
37 |
-
|
38 |
-
.ub-table-scroll table {
|
39 |
-
width: 100%;
|
40 |
-
border-collapse: collapse;
|
41 |
-
border-spacing: 0;
|
42 |
-
}
|
43 |
-
|
44 |
-
.ub-table-scroll thead,
|
45 |
-
.ub-table-scroll tbody,
|
46 |
-
.ub-table-scroll tr,
|
47 |
-
.ub-table-scroll td,
|
48 |
-
.ub-table-scroll th {
|
49 |
-
box-sizing: border-box;
|
50 |
-
display: block;
|
51 |
-
}
|
52 |
-
|
53 |
-
.ub-table-scroll tr:after {
|
54 |
-
content: ' ';
|
55 |
-
display: block;
|
56 |
-
visibility: hidden;
|
57 |
-
clear: both;
|
58 |
-
}
|
59 |
-
|
60 |
-
.ub-table-scroll tbody {
|
61 |
-
height: 350px;
|
62 |
-
overflow-y: auto;
|
63 |
-
width: 100%;
|
64 |
-
}
|
65 |
-
|
66 |
-
.ub-table-scroll tbody td, .ub-table-scroll thead th {
|
67 |
-
width: 100%;
|
68 |
-
float: left;
|
69 |
-
}
|
70 |
-
|
71 |
-
.ub-diagnostics-link {
|
72 |
-
float: left;
|
73 |
-
}
|
74 |
-
|
75 |
-
.ub-diagnostics-checks .dashicons-yes {
|
76 |
-
color: #7ad03a;
|
77 |
-
}
|
78 |
-
|
79 |
-
.ub-diagnostics-checks .dashicons-no-alt {
|
80 |
-
color: #dd3d36;
|
81 |
-
}
|
82 |
-
|
83 |
-
.ub-diagnostics-check-description {
|
84 |
-
margin-left: 24px;
|
85 |
-
}
|
86 |
-
|
87 |
-
#ub-diagnostics-copy-result div {
|
88 |
-
margin: 10px 0 10px 0 !important;
|
89 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/img/unbounce-logo-blue.png
DELETED
Binary file
|
trunk/js/clipboard.min.js
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
/*!
|
2 |
-
* clipboard.js v1.4.2
|
3 |
-
* https://zenorocha.github.io/clipboard.js
|
4 |
-
*
|
5 |
-
* Licensed MIT © Zeno Rocha
|
6 |
-
*/
|
7 |
-
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,i){function o(a,c){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return o(n?n:t)},u,u.exports,t,e,n,i)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<i.length;a++)o(i[a]);return o}({1:[function(t,e,n){var i=t("closest"),o=t("component-event"),r=["focus","blur"];n.bind=function(t,e,n,a,c){return-1!==r.indexOf(n)&&(c=!0),o.bind(t,n,function(n){var o=n.target||n.srcElement;n.delegateTarget=i(o,e,!0,t),n.delegateTarget&&a.call(t,n)},c)},n.unbind=function(t,e,n,i){-1!==r.indexOf(e)&&(i=!0),o.unbind(t,e,n,i)}},{closest:2,"component-event":4}],2:[function(t,e,n){var i=t("matches-selector");e.exports=function(t,e,n){for(var o=n?t:t.parentNode;o&&o!==document;){if(i(o,e))return o;o=o.parentNode}}},{"matches-selector":3}],3:[function(t,e,n){function i(t,e){if(r)return r.call(t,e);for(var n=t.parentNode.querySelectorAll(e),i=0;i<n.length;++i)if(n[i]==t)return!0;return!1}var o=Element.prototype,r=o.matchesSelector||o.webkitMatchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector;e.exports=i},{}],4:[function(t,e,n){var i=window.addEventListener?"addEventListener":"attachEvent",o=window.removeEventListener?"removeEventListener":"detachEvent",r="addEventListener"!==i?"on":"";n.bind=function(t,e,n,o){return t[i](r+e,n,o||!1),n},n.unbind=function(t,e,n,i){return t[o](r+e,n,i||!1),n}},{}],5:[function(t,e,n){function i(){}i.prototype={on:function(t,e,n){var i=this.e||(this.e={});return(i[t]||(i[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var i=this,o=function(){i.off(t,o),e.apply(n,arguments)};return this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),i=0,o=n.length;for(i;o>i;i++)n[i].fn.apply(n[i].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),i=n[t],o=[];if(i&&e)for(var r=0,a=i.length;a>r;r++)i[r].fn!==e&&o.push(i[r]);return o.length?n[t]=o:delete n[t],this}},e.exports=i},{}],6:[function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}n.__esModule=!0;var o=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),r=function(){function t(e){i(this,t),this.resolveOptions(e),this.initSelection()}return t.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action=e.action,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""},t.prototype.initSelection=function t(){if(this.text&&this.target)throw new Error('Multiple attributes declared, use either "target" or "text"');if(this.text)this.selectFake();else{if(!this.target)throw new Error('Missing required attributes, use either "target" or "text"');this.selectTarget()}},t.prototype.selectFake=function t(){var e=this;this.removeFake(),this.fakeHandler=document.body.addEventListener("click",function(){return e.removeFake()}),this.fakeElem=document.createElement("textarea"),this.fakeElem.style.position="absolute",this.fakeElem.style.left="-9999px",this.fakeElem.style.top=(window.pageYOffset||document.documentElement.scrollTop)+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.selectedText=this.text,document.body.appendChild(this.fakeElem),this.fakeElem.select(),this.copyText()},t.prototype.removeFake=function t(){this.fakeHandler&&(document.body.removeEventListener("click"),this.fakeHandler=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)},t.prototype.selectTarget=function t(){if("INPUT"===this.target.nodeName||"TEXTAREA"===this.target.nodeName)this.target.select(),this.selectedText=this.target.value;else{var e=document.createRange(),n=window.getSelection();n.removeAllRanges(),e.selectNodeContents(this.target),n.addRange(e),this.selectedText=n.toString()}this.copyText()},t.prototype.copyText=function t(){var e=void 0;try{e=document.execCommand(this.action)}catch(n){e=!1}this.handleResult(e)},t.prototype.handleResult=function t(e){e?this.emitter.emit("success",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)}):this.emitter.emit("error",{action:this.action,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})},t.prototype.clearSelection=function t(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()},t.prototype.destroy=function t(){this.removeFake()},o(t,[{key:"action",set:function t(){var e=arguments.length<=0||void 0===arguments[0]?"copy":arguments[0];if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function t(e){if(void 0!==e){if(!e||"object"!=typeof e||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');this._target=e}},get:function t(){return this._target}}]),t}();n.default=r,e.exports=n.default},{}],7:[function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function a(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}n.__esModule=!0;var c=t("./clipboard-action"),s=i(c),l=t("delegate-events"),u=i(l),f=t("tiny-emitter"),d=i(f),h=function(t){function e(n,i){o(this,e),t.call(this),this.resolveOptions(i),this.delegateClick(n)}return r(e,t),e.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText},e.prototype.delegateClick=function t(e){var n=this;this.binding=u.default.bind(document.body,e,"click",function(t){return n.onClick(t)})},e.prototype.undelegateClick=function t(){u.default.unbind(document.body,"click",this.binding)},e.prototype.onClick=function t(e){this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new s.default({action:this.action(e.delegateTarget),target:this.target(e.delegateTarget),text:this.text(e.delegateTarget),trigger:e.delegateTarget,emitter:this})},e.prototype.defaultAction=function t(e){return a("action",e)},e.prototype.defaultTarget=function t(e){var n=a("target",e);return n?document.querySelector(n):void 0},e.prototype.defaultText=function t(e){return a("text",e)},e.prototype.destroy=function t(){this.undelegateClick(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)},e}(d.default);n.default=h,e.exports=n.default},{"./clipboard-action":6,"delegate-events":1,"tiny-emitter":5}]},{},[7])(7)});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/js/rx.lite.compat.min.js
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
|
2 |
-
(function(a){function b(a){for(var b=a.length,c=new Array(b),d=0;b>d;d++)c[d]=a[d];return c}function c(a,b){if(ma&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&-1===a.stack.indexOf(qa)){for(var c=[],e=b;e;e=e.source)e.stack&&c.unshift(e.stack);c.unshift(a.stack);var f=c.join("\n"+qa+"\n");a.stack=d(f)}}function d(a){for(var b=a.split("\n"),c=[],d=0,g=b.length;g>d;d++){var h=b[d];e(h)||f(h)||!h||c.push(h)}return c.join("\n")}function e(a){var b=h(a);if(!b)return!1;var c=b[0],d=b[1];return c===oa&&d>=pa&&Vc>=d}function f(a){return-1!==a.indexOf("(module.js:")||-1!==a.indexOf("(node.js:")}function g(){if(ma)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=h(c);if(!d)return;return oa=d[0],d[1]}}function h(a){var b=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);if(b)return[b[1],Number(b[2])];var c=/at ([^ ]+):(\d+):(?:\d+)$/.exec(a);if(c)return[c[1],Number(c[2])];var d=/.*@(.+):(\d+)$/.exec(a);return d?[d[1],Number(d[2])]:void 0}function i(a){var b=[];if(!Za(a))return b;Ya.nonEnumArgs&&a.length&&$a(a)&&(a=cb.call(a));var c=Ya.enumPrototypes&&"function"==typeof a,d=Ya.enumErrorProps&&(a===Ta||a instanceof Error);for(var e in a)c&&"prototype"==e||d&&("message"==e||"name"==e)||b.push(e);if(Ya.nonEnumShadows&&a!==Ua){var f=a.constructor,g=-1,h=Fa;if(a===(f&&f.prototype))var i=a===Va?Pa:a===Ta?Ka:Qa.call(a),j=Xa[i];for(;++g<h;)e=Ea[g],j&&j[e]||!Ra.call(a,e)||b.push(e)}return b}function j(a,b,c){for(var d=-1,e=c(a),f=e.length;++d<f;){var g=e[d];if(b(a[g],g,a)===!1)break}return a}function k(a,b){return j(a,b,i)}function l(a){return"function"!=typeof a.toString&&"string"==typeof(a+"")}function m(a,b,c,d){if(a===b)return 0!==a||1/a==1/b;var e=typeof a,f=typeof b;if(a===a&&(null==a||null==b||"function"!=e&&"object"!=e&&"function"!=f&&"object"!=f))return!1;var g=Qa.call(a),h=Qa.call(b);if(g==Ga&&(g=Na),h==Ga&&(h=Na),g!=h)return!1;switch(g){case Ia:case Ja:return+a==+b;case Ma:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case Oa:case Pa:return a==String(b)}var i=g==Ha;if(!i){if(g!=Na||!Ya.nodeClass&&(l(a)||l(b)))return!1;var j=!Ya.argsObject&&$a(a)?Object:a.constructor,n=!Ya.argsObject&&$a(b)?Object:b.constructor;if(!(j==n||Ra.call(a,"constructor")&&Ra.call(b,"constructor")||la(j)&&j instanceof j&&la(n)&&n instanceof n||!("constructor"in a&&"constructor"in b)))return!1}c||(c=[]),d||(d=[]);for(var o=c.length;o--;)if(c[o]==a)return d[o]==b;var p=0,q=!0;if(c.push(a),d.push(b),i){if(o=a.length,p=b.length,q=p==o)for(;p--;){var r=b[p];if(!(q=m(a[p],r,c,d)))break}}else k(b,function(b,e,f){return Ra.call(f,e)?(p++,q=Ra.call(a,e)&&m(a[e],b,c,d)):void 0}),q&&k(a,function(a,b,c){return Ra.call(c,b)?q=--p>-1:void 0});return c.pop(),d.pop(),q}function n(){try{return _a.apply(this,arguments)}catch(a){return bb.e=a,bb}}function o(a){if(!la(a))throw new TypeError("fn must be a function");return _a=a,n}function p(a){throw a}function q(a,b){for(var c=new Array(a),d=0;a>d;d++)c[d]=b();return c}function r(a,b){this.id=a,this.value=b}function t(a){this._s=s}function u(a){this._s=s,this._l=s.length,this._i=0}function v(a){this._a=a}function w(a){this._a=a,this._l=A(a),this._i=0}function x(a){return"number"==typeof a&&$.isFinite(a)}function y(b){var c,d=b[ya];if(!d&&"string"==typeof b)return c=new t(b),c[ya]();if(!d&&b.length!==a)return c=new v(b),c[ya]();if(!d)throw new TypeError("Object is not iterable");return b[ya]()}function z(a){var b=+a;return 0===b?b:isNaN(b)?b:0>b?-1:1}function A(a){var b=+a.length;return isNaN(b)?0:0!==b&&x(b)?(b=z(b)*Math.floor(Math.abs(b)),0>=b?0:b>bc?bc:b):b}function B(a,b){this.observer=a,this.parent=b}function C(a,b){return vb(a)||(a=zb),new dc(b,a)}function D(a,b){this.observer=a,this.parent=b}function E(a,b){this.observer=a,this.parent=b}function F(a,b){return new Nc(function(c){var d=new qb,e=new rb;return e.setDisposable(d),d.setDisposable(a.subscribe(function(a){c.onNext(a)},function(a){try{var d=b(a)}catch(f){return c.onError(f)}ka(d)&&(d=Gc(d));var g=new qb;e.setDisposable(g),g.setDisposable(d.subscribe(c))},function(a){c.onCompleted(a)})),e},a)}function G(){return!1}function H(a,b){var c=this;return new Nc(function(d){var e=0,f=a.length;return c.subscribe(function(c){if(f>e){var g=a[e++],h=o(b)(c,g);if(h===bb)return d.onError(h.e);d.onNext(h)}else d.onCompleted()},function(a){d.onError(a)},function(){d.onCompleted()})},c)}function G(){return!1}function I(){return[]}function G(){return!1}function J(){return[]}function K(a,b){this.observer=a,this.accumulator=b.accumulator,this.hasSeed=b.hasSeed,this.seed=b.seed,this.hasAccumulation=!1,this.accumulation=null,this.hasValue=!1,this.isStopped=!1}function L(a,b,c){var d=Da(b,c,3);return a.map(function(b,c){var e=d(b,c,a);return ka(e)&&(e=Gc(e)),(Ba(e)||Aa(e))&&(e=cc(e)),e}).concatAll()}function M(a,b,c){var d=Da(b,c,3);return a.map(function(b,c){var e=d(b,c,a);return ka(e)&&(e=Gc(e)),(Ba(e)||Aa(e))&&(e=cc(e)),e}).mergeAll()}function N(a){return window.StaticNodeList?a instanceof window.StaticNodeList||a instanceof window.NodeList:"[object NodeList]"==Object.prototype.toString.call(a)}function O(a){var b=function(){this.cancelBubble=!0},c=function(){if(this.bubbledKeyCode=this.keyCode,this.ctrlKey)try{this.keyCode=0}catch(a){}this.defaultPrevented=!0,this.returnValue=!1,this.modified=!0};if(a||(a=$.event),!a.target)switch(a.target=a.target||a.srcElement,"mouseover"==a.type&&(a.relatedTarget=a.fromElement),"mouseout"==a.type&&(a.relatedTarget=a.toElement),a.stopPropagation||(a.stopPropagation=b,a.preventDefault=c),a.type){case"keypress":var d="charCode"in a?a.charCode:a.keyCode;10==d?(d=0,a.keyCode=13):13==d||27==d?d=0:3==d&&(d=99),a.charCode=d,a.keyChar=a.charCode?String.fromCharCode(a.charCode):""}return a}function P(a,b,c){if(a.addEventListener)return a.addEventListener(b,c,!1),mb(function(){a.removeEventListener(b,c,!1)});if(a.attachEvent){var d=function(a){c(O(a))};return a.attachEvent("on"+b,d),mb(function(){a.detachEvent("on"+b,d)})}return a["on"+b]=c,mb(function(){a["on"+b]=null})}function Q(a,b,c){var d=new jb;if(N(a)||"[object HTMLCollection]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;f>e;e++)d.add(Q(a.item(e),b,c));else a&&d.add(P(a,b,c));return d}function R(a,b){return new Nc(function(c){return b.scheduleWithAbsolute(a,function(){c.onNext(0),c.onCompleted()})})}function S(a,b,c){return new Nc(function(d){var e=a,f=ub(b);return c.scheduleRecursiveWithAbsoluteAndState(0,e,function(a,b){if(f>0){var g=c.now();e+=f,g>=e&&(e=g+f)}d.onNext(a),b(a+1,e)})})}function T(a,b){return new Nc(function(c){return b.scheduleWithRelative(ub(a),function(){c.onNext(0),c.onCompleted()})})}function U(a,b,c){return a===b?new Nc(function(a){return c.schedulePeriodicWithState(0,b,function(b){return a.onNext(b),b+1})}):Yb(function(){return S(c.now()+a,b,c)})}function V(a,b,c){return new Nc(function(d){var e,f=!1,g=new rb,h=null,i=[],j=!1;return e=a.materialize().timestamp(c).subscribe(function(a){var e,k;"E"===a.value.kind?(i=[],i.push(a),h=a.value.exception,k=!j):(i.push({value:a.value,timestamp:a.timestamp+b}),k=!f,f=!0),k&&(null!==h?d.onError(h):(e=new qb,g.setDisposable(e),e.setDisposable(c.scheduleRecursiveWithRelative(b,function(a){var b,e,g,k;if(null===h){j=!0;do g=null,i.length>0&&i[0].timestamp-c.now()<=0&&(g=i.shift().value),null!==g&&g.accept(d);while(null!==g);k=!1,e=0,i.length>0?(k=!0,e=Math.max(0,i[0].timestamp-c.now())):f=!1,b=h,j=!1,null!==b?d.onError(b):k&&a(e)}}))))}),new jb(e,g)},a)}function W(a,b,c){return Yb(function(){return V(a,b-c.now(),c)})}function X(a,b){return new Nc(function(c){function d(){g&&(g=!1,c.onNext(e)),f&&c.onCompleted()}var e,f=!1,g=!1,h=new qb;return h.setDisposable(a.subscribe(function(a){g=!0,e=a},function(a){c.onError(a)},function(){f=!0,h.dispose()})),new jb(h,b.subscribe(d,function(a){c.onError(a)},d))},a)}function Y(a,b,c){return new Nc(function(d){function e(a,b){if(j[b]=a,g[b]=!0,h||(h=g.every(fa))){if(f)return d.onError(f);var e=o(c).apply(null,j);if(e===bb)return d.onError(e.e);d.onNext(e)}i&&j[1]&&d.onCompleted()}var f,g=[!1,!1],h=!1,i=!1,j=new Array(2);return new jb(a.subscribe(function(a){e(a,0)},function(a){j[1]?d.onError(a):f=a},function(){i=!0,j[1]&&d.onCompleted()}),b.subscribe(function(a){e(a,1)},function(a){d.onError(a)},function(){i=!0,e(!0,1)}))},a)}var Z={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},$=Z[typeof window]&&window||this,_=Z[typeof exports]&&exports&&!exports.nodeType&&exports,aa=Z[typeof module]&&module&&!module.nodeType&&module,ba=aa&&aa.exports===_&&_,ca=Z[typeof global]&&global;!ca||ca.global!==ca&&ca.window!==ca||($=ca);var da={internals:{},config:{Promise:$.Promise},helpers:{}},ea=da.helpers.noop=function(){},fa=(da.helpers.notDefined=function(a){return"undefined"==typeof a},da.helpers.identity=function(a){return a}),ga=(da.helpers.pluck=function(a){return function(b){return b[a]}},da.helpers.just=function(a){return function(){return a}},da.helpers.defaultNow=function(){return Date.now?Date.now:function(){return+new Date}}()),ha=da.helpers.defaultComparer=function(a,b){return ab(a,b)},ia=da.helpers.defaultSubComparer=function(a,b){return a>b?1:b>a?-1:0},ja=(da.helpers.defaultKeySerializer=function(a){return a.toString()},da.helpers.defaultError=function(a){throw a}),ka=da.helpers.isPromise=function(a){return!!a&&"function"!=typeof a.subscribe&&"function"==typeof a.then},la=(da.helpers.asArray=function(){return Array.prototype.slice.call(arguments)},da.helpers.not=function(a){return!a},da.helpers.isFunction=function(){var a=function(a){return"function"==typeof a||!1};return a(/x/)&&(a=function(a){return"function"==typeof a&&"[object Function]"==Qa.call(a)}),a}());da.config.longStackSupport=!1;var ma=!1;try{throw new Error}catch(na){ma=!!na.stack}var oa,pa=g(),qa="From previous event:",ra=da.EmptyError=function(){this.message="Sequence contains no elements.",Error.call(this)};ra.prototype=Error.prototype;var sa=da.ObjectDisposedError=function(){this.message="Object has been disposed",Error.call(this)};sa.prototype=Error.prototype;var ta=da.ArgumentOutOfRangeError=function(){this.message="Argument out of range",Error.call(this)};ta.prototype=Error.prototype;var ua=da.NotSupportedError=function(a){this.message=a||"This operation is not supported",Error.call(this)};ua.prototype=Error.prototype;var va=da.NotImplementedError=function(a){this.message=a||"This operation is not implemented",Error.call(this)};va.prototype=Error.prototype;var wa=da.helpers.notImplemented=function(){throw new va},xa=da.helpers.notSupported=function(){throw new ua},ya="function"==typeof Symbol&&Symbol.iterator||"_es6shim_iterator_";$.Set&&"function"==typeof(new $.Set)["@@iterator"]&&(ya="@@iterator");var za=da.doneEnumerator={done:!0,value:a},Aa=da.helpers.isIterable=function(b){return b[ya]!==a},Ba=da.helpers.isArrayLike=function(b){return b&&b.length!==a};da.helpers.iterator=ya;var Ca,Da=da.internals.bindCallback=function(a,b,c){if("undefined"==typeof b)return a;switch(c){case 0:return function(){return a.call(b)};case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)}}return function(){return a.apply(b,arguments)}},Ea=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],Fa=Ea.length,Ga="[object Arguments]",Ha="[object Array]",Ia="[object Boolean]",Ja="[object Date]",Ka="[object Error]",La="[object Function]",Ma="[object Number]",Na="[object Object]",Oa="[object RegExp]",Pa="[object String]",Qa=Object.prototype.toString,Ra=Object.prototype.hasOwnProperty,Sa=Qa.call(arguments)==Ga,Ta=Error.prototype,Ua=Object.prototype,Va=String.prototype,Wa=Ua.propertyIsEnumerable;try{Ca=!(Qa.call(document)==Na&&!({toString:0}+""))}catch(na){Ca=!0}var Xa={};Xa[Ha]=Xa[Ja]=Xa[Ma]={constructor:!0,toLocaleString:!0,toString:!0,valueOf:!0},Xa[Ia]=Xa[Pa]={constructor:!0,toString:!0,valueOf:!0},Xa[Ka]=Xa[La]=Xa[Oa]={constructor:!0,toString:!0},Xa[Na]={constructor:!0};var Ya={};!function(){var a=function(){this.x=1},b=[];a.prototype={valueOf:1,y:1};for(var c in new a)b.push(c);for(c in arguments);Ya.enumErrorProps=Wa.call(Ta,"message")||Wa.call(Ta,"name"),Ya.enumPrototypes=Wa.call(a,"prototype"),Ya.nonEnumArgs=0!=c,Ya.nonEnumShadows=!/valueOf/.test(b)}(1);var Za=da.internals.isObject=function(a){var b=typeof a;return a&&("function"==b||"object"==b)||!1},$a=function(a){return a&&"object"==typeof a?Qa.call(a)==Ga:!1};Sa||($a=function(a){return a&&"object"==typeof a?Ra.call(a,"callee"):!1});{var _a,ab=da.internals.isEqual=function(a,b){return m(a,b,[],[])},bb={e:{}},cb=({}.hasOwnProperty,Array.prototype.slice),db=this.inherits=da.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c},eb=da.internals.addProperties=function(a){for(var b=[],c=1,d=arguments.length;d>c;c++)b.push(arguments[c]);for(var e=0,f=b.length;f>e;e++){var g=b[e];for(var h in g)a[h]=g[h]}};da.internals.addRef=function(a,b){return new Nc(function(c){return new jb(b.getDisposable(),a.subscribe(c))})}}Function.prototype.bind||(Function.prototype.bind=function(a){var b=this,c=cb.call(arguments,1),d=function(){function e(){}if(this instanceof d){e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(cb.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(cb.call(arguments)))};return d}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(arguments.length>1&&(c=b),d=0;f>d;){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++}});var fb=Object("a"),gb="a"!=fb[0]||!(0 in fb);Array.prototype.every||(Array.prototype.every=function(a){var b=Object(this),c=gb&&{}.toString.call(this)==Pa?this.split(""):b,d=c.length>>>0,e=arguments[1];if({}.toString.call(a)!=La)throw new TypeError(a+" is not a function");for(var f=0;d>f;f++)if(f in c&&!a.call(e,c[f],f,b))return!1;return!0}),Array.prototype.map||(Array.prototype.map=function(a){var b=Object(this),c=gb&&{}.toString.call(this)==Pa?this.split(""):b,d=c.length>>>0,e=Array(d),f=arguments[1];if({}.toString.call(a)!=La)throw new TypeError(a+" is not a function");for(var g=0;d>g;g++)g in c&&(e[g]=a.call(f,c[g],g,b));return e}),Array.prototype.filter||(Array.prototype.filter=function(a){for(var b,c=[],d=new Object(this),e=0,f=d.length>>>0;f>e;e++)b=d[e],e in d&&a.call(arguments[1],b,e,d)&&c.push(b);return c}),Array.isArray||(Array.isArray=function(a){return{}.toString.call(a)==Ha}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=Object(this),c=b.length>>>0;if(0===c)return-1;var d=0;if(arguments.length>1&&(d=Number(arguments[1]),d!==d?d=0:0!==d&&d!=1/0&&d!==-(1/0)&&(d=(d>0||-1)*Math.floor(Math.abs(d)))),d>=c)return-1;for(var e=d>=0?d:Math.max(c-Math.abs(d),0);c>e;e++)if(e in b&&b[e]===a)return e;return-1}),Object.prototype.propertyIsEnumerable||(Object.prototype.propertyIsEnumerable=function(a){for(var b in this)if(b===a)return!0;return!1}),Object.keys||(Object.keys=function(){"use strict";var a=Object.prototype.hasOwnProperty,b=!{toString:null}.propertyIsEnumerable("toString");return function(c){if("object"!=typeof c&&("function"!=typeof c||null===c))throw new TypeError("Object.keys called on non-object");var d,e,f=[];for(d in c)a.call(c,d)&&f.push(d);if(b)for(e=0;Fa>e;e++)a.call(c,Ea[e])&&f.push(Ea[e]);return f}}()),r.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var hb=da.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},ib=hb.prototype;ib.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},ib.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},ib.heapify=function(a){if(+a||(a=0),!(a>=this.length||0>a)){var b=2*a+1,c=2*a+2,d=a;if(b<this.length&&this.isHigherPriority(b,d)&&(d=b),c<this.length&&this.isHigherPriority(c,d)&&(d=c),d!==a){var e=this.items[a];this.items[a]=this.items[d],this.items[d]=e,this.heapify(d)}}},ib.peek=function(){return this.items[0].value},ib.removeAt=function(b){this.items[b]=this.items[--this.length],this.items[this.length]=a,this.heapify()},ib.dequeue=function(){var a=this.peek();return this.removeAt(0),a},ib.enqueue=function(a){var b=this.length++;this.items[b]=new r(hb.count++,a),this.percolate(b)},ib.remove=function(a){for(var b=0;b<this.length;b++)if(this.items[b].value===a)return this.removeAt(b),!0;return!1},hb.count=0;var jb=da.CompositeDisposable=function(){var a,b,c=[];if(Array.isArray(arguments[0]))c=arguments[0],b=c.length;else for(b=arguments.length,c=new Array(b),a=0;b>a;a++)c[a]=arguments[a];for(a=0;b>a;a++)if(!ob(c[a]))throw new TypeError("Not a disposable");this.disposables=c,this.isDisposed=!1,this.length=c.length},kb=jb.prototype;kb.add=function(a){this.isDisposed?a.dispose():(this.disposables.push(a),this.length++)},kb.remove=function(a){var b=!1;if(!this.isDisposed){var c=this.disposables.indexOf(a);-1!==c&&(b=!0,this.disposables.splice(c,1),this.length--,a.dispose())}return b},kb.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;for(var a=this.disposables.length,b=new Array(a),c=0;a>c;c++)b[c]=this.disposables[c];for(this.disposables=[],this.length=0,c=0;a>c;c++)b[c].dispose()}};var lb=da.Disposable=function(a){this.isDisposed=!1,this.action=a||ea};lb.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var mb=lb.create=function(a){return new lb(a)},nb=lb.empty={dispose:ea},ob=lb.isDisposable=function(a){return a&&la(a.dispose)},pb=lb.checkDisposed=function(a){if(a.isDisposed)throw new sa},qb=da.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null};qb.prototype.getDisposable=function(){return this.current},qb.prototype.setDisposable=function(a){if(this.current)throw new Error("Disposable has already been assigned");var b=this.isDisposed;!b&&(this.current=a),b&&a&&a.dispose()},qb.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.current;this.current=null}a&&a.dispose()};var rb=da.SerialDisposable=function(){this.isDisposed=!1,this.current=null};rb.prototype.getDisposable=function(){return this.current},rb.prototype.setDisposable=function(a){var b=this.isDisposed;if(!b){var c=this.current;this.current=a}c&&c.dispose(),b&&a&&a.dispose()},rb.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.current;this.current=null}a&&a.dispose()};var sb=(da.RefCountDisposable=function(){function a(a){this.disposable=a,this.disposable.count++,this.isInnerDisposed=!1}function b(a){this.underlyingDisposable=a,this.isDisposed=!1,this.isPrimaryDisposed=!1,this.count=0}return a.prototype.dispose=function(){this.disposable.isDisposed||this.isInnerDisposed||(this.isInnerDisposed=!0,this.disposable.count--,0===this.disposable.count&&this.disposable.isPrimaryDisposed&&(this.disposable.isDisposed=!0,this.disposable.underlyingDisposable.dispose()))},b.prototype.dispose=function(){this.isDisposed||this.isPrimaryDisposed||(this.isPrimaryDisposed=!0,0===this.count&&(this.isDisposed=!0,this.underlyingDisposable.dispose()))},b.prototype.getDisposable=function(){return this.isDisposed?nb:new a(this)},b}(),da.internals.ScheduledItem=function(a,b,c,d,e){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=e||ia,this.disposable=new qb});sb.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},sb.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},sb.prototype.isCancelled=function(){return this.disposable.isDisposed},sb.prototype.invokeCore=function(){return this.action(this.scheduler,this.state)};var tb=da.Scheduler=function(){function a(a,b,c,d){this.now=a,this._schedule=b,this._scheduleRelative=c,this._scheduleAbsolute=d}function b(a,b){return b(),nb}a.isScheduler=function(b){return b instanceof a};var c=a.prototype;return c.schedule=function(a){return this._schedule(a,b)},c.scheduleWithState=function(a,b){return this._schedule(a,b)},c.scheduleWithRelative=function(a,c){return this._scheduleRelative(c,a,b)},c.scheduleWithRelativeAndState=function(a,b,c){return this._scheduleRelative(a,b,c)},c.scheduleWithAbsolute=function(a,c){return this._scheduleAbsolute(c,a,b)},c.scheduleWithAbsoluteAndState=function(a,b,c){return this._scheduleAbsolute(a,b,c)},a.now=ga,a.normalize=function(a){return 0>a&&(a=0),a},a}(),ub=tb.normalize,vb=tb.isScheduler;!function(a){function b(a,b){function c(b){e(b,function(b){var d=!1,e=!1,g=a.scheduleWithState(b,function(a,b){return d?f.remove(g):e=!0,c(b),nb});e||(f.add(g),d=!0)})}var d=b[0],e=b[1],f=new jb;return c(d),f}function c(a,b,c){function d(b){f(b,function(b,e){var f=!1,h=!1,i=a[c](b,e,function(a,b){return f?g.remove(i):h=!0,d(b),nb});h||(g.add(i),f=!0)})}var e=b[0],f=b[1],g=new jb;return d(e),g}function d(a,b){a(function(c){b(a,c)})}a.scheduleRecursive=function(a){return this.scheduleRecursiveWithState(a,d)},a.scheduleRecursiveWithState=function(a,c){return this.scheduleWithState([a,c],b)},a.scheduleRecursiveWithRelative=function(a,b){return this.scheduleRecursiveWithRelativeAndState(b,a,d)},a.scheduleRecursiveWithRelativeAndState=function(a,b,d){return this._scheduleRelative([a,d],b,function(a,b){return c(a,b,"scheduleWithRelativeAndState")})},a.scheduleRecursiveWithAbsolute=function(a,b){return this.scheduleRecursiveWithAbsoluteAndState(b,a,d)},a.scheduleRecursiveWithAbsoluteAndState=function(a,b,d){return this._scheduleAbsolute([a,d],b,function(a,b){return c(a,b,"scheduleWithAbsoluteAndState")})}}(tb.prototype),function(a){tb.prototype.schedulePeriodic=function(a,b){return this.schedulePeriodicWithState(null,a,b)},tb.prototype.schedulePeriodicWithState=function(a,b,c){if("undefined"==typeof $.setInterval)throw new ua;b=ub(b);var d=a,e=$.setInterval(function(){d=c(d)},b);return mb(function(){$.clearInterval(e)})}}(tb.prototype);var wb,xb,yb=tb.immediate=function(){function a(a,b){return b(this,a)}return new tb(ga,a,xa,xa)}(),zb=tb.currentThread=function(){function a(){for(;c.length>0;){var a=c.dequeue();!a.isCancelled()&&a.invoke()}}function b(b,d){var e=new sb(this,b,d,this.now());if(c)c.enqueue(e);else{c=new hb(4),c.enqueue(e);var f=o(a)();if(c=null,f===bb)return p(f.e)}return e.disposable}var c,d=new tb(ga,b,xa,xa);return d.scheduleRequired=function(){return!c},d}(),Ab=(da.internals.SchedulePeriodicRecursive=function(){function a(a,b){b(0,this._period);try{this._state=this._action(this._state)}catch(c){throw this._cancel.dispose(),c}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new qb;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveWithRelativeAndState(0,this._period,a.bind(this))),b},b}(),function(){var a,b=ea;if($.setTimeout)a=$.setTimeout,b=$.clearTimeout;else{if(!$.WScript)throw new ua;a=function(a,b){$.WScript.Sleep(b),a()}}return{setTimeout:a,clearTimeout:b}}()),Bb=Ab.setTimeout,Cb=Ab.clearTimeout;!function(){function a(b){if(f)Bb(function(){a(b)},0);else{var c=e[b];if(c){f=!0;var d=o(c)();if(xb(b),f=!1,d===bb)return p(d.e)}}}function b(){if(!$.postMessage||$.importScripts)return!1;var a=!1,b=$.onmessage;return $.onmessage=function(){a=!0},$.postMessage("","*"),$.onmessage=b,a}function c(b){"string"==typeof b.data&&b.data.substring(0,i.length)===i&&a(b.data.substring(i.length))}var d=1,e={},f=!1;xb=function(a){delete e[a]};var g=RegExp("^"+String(Qa).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),h="function"==typeof(h=ca&&ba&&ca.setImmediate)&&!g.test(h)&&h;if(la(h))wb=function(b){var c=d++;return e[c]=b,h(function(){a(c)}),c};else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))wb=function(b){var c=d++;return e[c]=b,process.nextTick(function(){a(c)}),c};else if(b()){var i="ms.rx.schedule"+Math.random();$.addEventListener?$.addEventListener("message",c,!1):$.attachEvent?$.attachEvent("onmessage",c):$.onmessage=c,wb=function(a){var b=d++;return e[b]=a,$.postMessage(i+currentId,"*"),b}}else if($.MessageChannel){var j=new $.MessageChannel;j.port1.onmessage=function(b){a(b.data)},wb=function(a){var b=d++;return e[b]=a,j.port2.postMessage(b),b}}else wb="document"in $&&"onreadystatechange"in $.document.createElement("script")?function(b){var c=$.document.createElement("script"),f=d++;return e[f]=b,c.onreadystatechange=function(){a(f),c.onreadystatechange=null,c.parentNode.removeChild(c),c=null},$.document.documentElement.appendChild(c),f}:function(b){var c=d++;return e[c]=b,Bb(function(){a(c)},0),c}}();var Db,Eb=tb.timeout=tb["default"]=function(){function a(a,b){var c=this,d=new qb,e=wb(function(){!d.isDisposed&&d.setDisposable(b(c,a))});return new jb(d,mb(function(){xb(e)}))}function b(a,b,c){var d=this,e=tb.normalize(b),f=new qb;if(0===e)return d.scheduleWithState(a,c);var g=Bb(function(){!f.isDisposed&&f.setDisposable(c(d,a))},e);return new jb(f,mb(function(){Cb(g)}))}function c(a,b,c){return this.scheduleWithRelativeAndState(a,b-this.now(),c)}return new tb(ga,a,b,c)}(),Fb=da.Notification=function(){function a(a,b,c,d,e,f){this.kind=a,this.value=b,this.exception=c,this._accept=d,this._acceptObservable=e,this.toString=f}return a.prototype.accept=function(a,b,c){return a&&"object"==typeof a?this._acceptObservable(a):this._accept(a,b,c)},a.prototype.toObservable=function(a){var b=this;return vb(a)||(a=yb),new Nc(function(c){return a.scheduleWithState(b,function(a,b){b._acceptObservable(c),"N"===b.kind&&c.onCompleted()})})},a}(),Gb=Fb.createOnNext=function(){function a(a){return a(this.value)}function b(a){return a.onNext(this.value)}function c(){return"OnNext("+this.value+")"}return function(d){return new Fb("N",d,null,a,b,c)}}(),Hb=Fb.createOnError=function(){function a(a,b){return b(this.exception)}function b(a){return a.onError(this.exception)}function c(){return"OnError("+this.exception+")"}return function(d){return new Fb("E",null,d,a,b,c)}}(),Ib=Fb.createOnCompleted=function(){function a(a,b,c){return c()}function b(a){return a.onCompleted()}function c(){return"OnCompleted()"}return function(){return new Fb("C",null,null,a,b,c)}}(),Jb=da.Observer=function(){},Kb=Jb.create=function(a,b,c){return a||(a=ea),b||(b=ja),c||(c=ea),new Mb(a,b,c)},Lb=da.internals.AbstractObserver=function(a){function b(){this.isStopped=!1,a.call(this)}return db(b,a),b.prototype.next=wa,b.prototype.error=wa,b.prototype.completed=wa,b.prototype.onNext=function(a){this.isStopped||this.next(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.error(a))},b.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.error(a),!0)},b}(Jb),Mb=da.AnonymousObserver=function(a){function b(b,c,d){a.call(this),this._onNext=b,this._onError=c,this._onCompleted=d}return db(b,a),b.prototype.next=function(a){this._onNext(a)},b.prototype.error=function(a){this._onError(a)},b.prototype.completed=function(){this._onCompleted()},b}(Lb),Nb=da.Observable=function(){function a(a){if(da.config.longStackSupport&&ma){try{throw new Error}catch(b){this.stack=b.stack.substring(b.stack.indexOf("\n")+1)}var d=this;this._subscribe=function(b){var e=b.onError.bind(b);return b.onError=function(a){c(a,d),e(a)},a.call(d,b)}}else this._subscribe=a}return Db=a.prototype,Db.subscribe=Db.forEach=function(a,b,c){return this._subscribe("object"==typeof a?a:Kb(a,b,c))},Db.subscribeOnNext=function(a,b){return this._subscribe(Kb("undefined"!=typeof b?function(c){a.call(b,c)}:a))},Db.subscribeOnError=function(a,b){return this._subscribe(Kb(null,"undefined"!=typeof b?function(c){a.call(b,c)}:a))},Db.subscribeOnCompleted=function(a,b){return this._subscribe(Kb(null,null,"undefined"!=typeof b?function(){a.call(b)}:a))},a}(),Ob=da.ObservableBase=function(a){function b(a){return a&&la(a.dispose)?a:la(a)?mb(a):nb}function c(a,c){var d=c[0],e=c[1],f=o(e.subscribeCore).call(e,d);return f!==bb||d.fail(bb.e)?void d.setDisposable(b(f)):p(bb.e)}function d(a){var b=new Oc(a),d=[b,this];return zb.scheduleRequired()?zb.scheduleWithState(d,c):c(null,d),b}function e(){a.call(this,d)}return db(e,a),e.prototype.subscribeCore=wa,e}(Nb),Pb=da.internals.Enumerable=function(){},Qb=function(a){function b(b){this.sources=b,a.call(this)}function c(a,b,c){this.o=a,this.s=b,this.e=c,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){var b,d=new rb,e=yb.scheduleRecursiveWithState(this.sources[ya](),function(e,f){if(!b){var g=o(e.next).call(e);if(g===bb)return a.onError(g.e);if(g.done)return a.onCompleted();var h=g.value;ka(h)&&(h=Gc(h));var i=new qb;d.setDisposable(i),i.setDisposable(h.subscribe(new c(a,f,e)))}});return new jb(d,e,mb(function(){b=!0}))},c.prototype.onNext=function(a){this.isStopped||this.o.onNext(a)},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.s(this.e))},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Pb.prototype.concat=function(){return new Qb(this)};var Rb=function(a){function b(b){this.sources=b,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b,c=this.sources[ya](),d=new rb,e=yb.scheduleRecursiveWithState(null,function(e,f){if(!b){var g=o(c.next).call(c);if(g===bb)return a.onError(g.e);if(g.done)return null!==e?a.onError(e):a.onCompleted();var h=g.value;ka(h)&&(h=Gc(h));var i=new qb;d.setDisposable(i),i.setDisposable(h.subscribe(function(b){a.onNext(b)},f,function(){a.onCompleted()}))}});return new jb(d,e,mb(function(){b=!0}))},b}(Ob);Pb.prototype.catchError=function(){return new Rb(this)},Pb.prototype.catchErrorWhen=function(a){var b=this;return new Nc(function(c){var d,e,f=new Qc,g=new Qc,h=a(f),i=h.subscribe(g),j=b[ya](),k=new rb,l=yb.scheduleRecursive(function(a){if(!d){var b=o(j.next).call(j);if(b===bb)return c.onError(b.e);if(b.done)return void(e?c.onError(e):c.onCompleted());var h=b.value;ka(h)&&(h=Gc(h));var i=new qb,l=new qb;k.setDisposable(new jb(l,i)),i.setDisposable(h.subscribe(function(a){c.onNext(a)},function(b){l.setDisposable(g.subscribe(a,function(a){c.onError(a)},function(){c.onCompleted()})),f.onNext(b)},function(){c.onCompleted()}))}});return new jb(i,k,l,mb(function(){d=!0}))})};var Sb=function(a){function b(a,b){this.v=a,this.c=null==b?-1:b}function c(a){this.v=a.v,this.l=a.c}return db(b,a),b.prototype[ya]=function(){return new c(this)},c.prototype.next=function(){return 0===this.l?za:(this.l>0&&this.l--,{done:!1,value:this.v})},b}(Pb),Tb=Pb.repeat=function(a,b){return new Sb(a,b)},Ub=function(a){function b(a,b,c){this.s=a,this.fn=b?Da(b,c,3):null}function c(a){this.i=-1,this.s=a.s,this.l=this.s.length,this.fn=a.fn}return db(b,a),b.prototype[ya]=function(){return new c(this)},c.prototype.next=function(){return++this.i<this.l?{done:!1,value:this.fn?this.fn(this.s[this.i],this.i,this.s):this.s[this.i]}:za},b}(Pb),Vb=Pb.of=function(a,b,c){return new Ub(a,b,c)},Wb=da.internals.ScheduledObserver=function(a){function b(b,c){a.call(this),this.scheduler=b,this.observer=c,this.isAcquired=!1,this.hasFaulted=!1,this.queue=[],this.disposable=new rb}return db(b,a),b.prototype.next=function(a){var b=this;this.queue.push(function(){b.observer.onNext(a)})},b.prototype.error=function(a){var b=this;this.queue.push(function(){b.observer.onError(a)})},b.prototype.completed=function(){var a=this;this.queue.push(function(){a.observer.onCompleted()})},b.prototype.ensureActive=function(){var a=!1,b=this;!this.hasFaulted&&this.queue.length>0&&(a=!this.isAcquired,this.isAcquired=!0),a&&this.disposable.setDisposable(this.scheduler.scheduleRecursive(function(a){
|
3 |
-
var c;if(!(b.queue.length>0))return void(b.isAcquired=!1);c=b.queue.shift();try{c()}catch(d){throw b.queue=[],b.hasFaulted=!0,d}a()}))},b.prototype.dispose=function(){a.prototype.dispose.call(this),this.disposable.dispose()},b}(Lb),Xb=function(a){function b(b){this.source=b,a.call(this)}function c(a){this.o=a,this.a=[],this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a))},c.prototype.onNext=function(a){this.isStopped||this.a.push(a)},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onNext(this.a),this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.toArray=function(){return new Xb(this)},Nb.create=Nb.createWithDisposable=function(a,b){return new Nc(a,b)};var Yb=Nb.defer=function(a){return new Nc(function(b){var c;try{c=a()}catch(d){return mc(d).subscribe(b)}return ka(c)&&(c=Gc(c)),c.subscribe(b)})},Zb=function(a){function b(b){this.scheduler=b,a.call(this)}function c(a,b){this.observer=a,this.parent=b}function d(a,b){b.onCompleted()}return db(b,a),b.prototype.subscribeCore=function(a){var b=new c(a,this);return b.run()},c.prototype.run=function(){return this.parent.scheduler.scheduleWithState(this.observer,d)},b}(Ob),$b=Nb.empty=function(a){return vb(a)||(a=yb),new Zb(a)},_b=function(a){function b(b,c,d){this.iterable=b,this.mapper=c,this.scheduler=d,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new ac(a,this);return b.run()},b}(Ob),ac=function(){function a(a,b){this.observer=a,this.parent=b}return a.prototype.run=function(){function a(a,b){try{var f=c.next()}catch(g){return d.onError(g)}if(f.done)return d.onCompleted();var h=f.value;if(e)try{h=e(h,a)}catch(g){return d.onError(g)}d.onNext(h),b(a+1)}var b=Object(this.parent.iterable),c=y(b),d=this.observer,e=this.parent.mapper;return this.parent.scheduler.scheduleRecursiveWithState(0,a)},a}(),bc=Math.pow(2,53)-1;t.prototype[ya]=function(){return new u(this._s)},u.prototype[ya]=function(){return this},u.prototype.next=function(){return this._i<this._l?{done:!1,value:this._s.charAt(this._i++)}:za},v.prototype[ya]=function(){return new w(this._a)},w.prototype[ya]=function(){return this},w.prototype.next=function(){return this._i<this._l?{done:!1,value:this._a[this._i++]}:za};var cc=Nb.from=function(a,b,c,d){if(null==a)throw new Error("iterable cannot be null.");if(b&&!la(b))throw new Error("mapFn when provided must be a function");if(b)var e=Da(b,c,2);return vb(d)||(d=zb),new _b(a,e,d)},dc=function(a){function b(b,c){this.args=b,this.scheduler=c,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new B(a,this);return b.run()},b}(Ob);B.prototype.run=function(){function a(a,e){d>a?(b.onNext(c[a]),e(a+1)):b.onCompleted()}var b=this.observer,c=this.parent.args,d=c.length;return this.parent.scheduler.scheduleRecursiveWithState(0,a)};{var ec=Nb.fromArray=function(a,b){return vb(b)||(b=zb),new dc(a,b)},fc=function(a){function b(){a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){return nb},b}(Ob);Nb.never=function(){return new fc}}Nb.of=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return new dc(b,zb)},Nb.ofWithScheduler=function(a){for(var b=arguments.length,c=new Array(b-1),d=1;b>d;d++)c[d-1]=arguments[d];return new dc(c,a)};var gc=function(a){function b(b,c){this.obj=b,this.keys=Object.keys(b),this.scheduler=c,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new D(a,this);return b.run()},b}(Ob);D.prototype.run=function(){function a(a,f){if(e>a){var g=d[a];b.onNext([g,c[g]]),f(a+1)}else b.onCompleted()}var b=this.observer,c=this.parent.obj,d=this.parent.keys,e=d.length;return this.parent.scheduler.scheduleRecursiveWithState(0,a)},Nb.pairs=function(a,b){return b||(b=zb),new gc(a,b)};var hc=function(a){function b(b,c,d){this.start=b,this.rangeCount=c,this.scheduler=d,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new ic(a,this);return b.run()},b}(Ob),ic=function(){function a(a,b){this.observer=a,this.parent=b}return a.prototype.run=function(){function a(a,e){c>a?(d.onNext(b+a),e(a+1)):d.onCompleted()}var b=this.parent.start,c=this.parent.rangeCount,d=this.observer;return this.parent.scheduler.scheduleRecursiveWithState(0,a)},a}();Nb.range=function(a,b,c){return vb(c)||(c=zb),new hc(a,b,c)};var jc=function(a){function b(b,c,d){this.value=b,this.repeatCount=null==c?-1:c,this.scheduler=d,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new E(a,this);return b.run()},b}(Ob);E.prototype.run=function(){function a(a,d){return(-1===a||a>0)&&(b.onNext(c),a>0&&a--),0===a?b.onCompleted():void d(a)}var b=this.observer,c=this.parent.value;return this.parent.scheduler.scheduleRecursiveWithState(this.parent.repeatCount,a)},Nb.repeat=function(a,b,c){return vb(c)||(c=zb),new jc(a,b,c)};var kc=function(a){function b(b,c){this.value=b,this.scheduler=c,a.call(this)}function c(a,b){this.observer=a,this.parent=b}function d(a,b){var c=b[0],d=b[1];d.onNext(c),d.onCompleted()}return db(b,a),b.prototype.subscribeCore=function(a){var b=new c(a,this);return b.run()},c.prototype.run=function(){return this.parent.scheduler.scheduleWithState([this.parent.value,this.observer],d)},b}(Ob),lc=(Nb["return"]=Nb.just=Nb.returnValue=function(a,b){return vb(b)||(b=yb),new kc(a,b)},function(a){function b(b,c){this.error=b,this.scheduler=c,a.call(this)}function c(a,b){this.o=a,this.p=b}function d(a,b){var c=b[0],d=b[1];d.onError(c)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new c(a,this);return b.run()},c.prototype.run=function(){return this.p.scheduler.scheduleWithState([this.p.error,this.o],d)},b}(Ob)),mc=Nb["throw"]=Nb.throwError=Nb.throwException=function(a,b){return vb(b)||(b=yb),new lc(a,b)};Db["catch"]=Db.catchError=Db.catchException=function(a){return"function"==typeof a?F(this,a):nc([this,a])};var nc=Nb.catchError=Nb["catch"]=Nb.catchException=function(){var a=[];if(Array.isArray(arguments[0]))a=arguments[0];else for(var b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);return Vb(a).catchError()};Db.combineLatest=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];return Array.isArray(b[0])?b[0].unshift(this):b.unshift(this),oc.apply(this,b)};var oc=Nb.combineLatest=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=b.pop();return Array.isArray(b[0])&&(b=b[0]),new Nc(function(a){function c(b){if(h[b]=!0,i||(i=h.every(fa))){try{var c=d.apply(null,k)}catch(e){return a.onError(e)}a.onNext(c)}else j.filter(function(a,c){return c!==b}).every(fa)&&a.onCompleted()}function e(b){j[b]=!0,j.every(fa)&&a.onCompleted()}for(var f=b.length,g=function(){return!1},h=q(f,g),i=!1,j=q(f,g),k=new Array(f),l=new Array(f),m=0;f>m;m++)!function(d){var f=b[d],g=new qb;ka(f)&&(f=Gc(f)),g.setDisposable(f.subscribe(function(a){k[d]=a,c(d)},function(b){a.onError(b)},function(){e(d)})),l[d]=g}(m);return new jb(l)},this)};Db.concat=function(){for(var a=[],b=0,c=arguments.length;c>b;b++)a.push(arguments[b]);return a.unshift(this),qc.apply(null,a)};var pc=function(a){function b(b){this.sources=b,a.call(this)}function c(a,b){this.sources=a,this.o=b}return db(b,a),b.prototype.subscribeCore=function(a){var b=new c(this.sources,a);return b.run()},c.prototype.run=function(){var a,b=new rb,c=this.sources,d=c.length,e=this.o,f=yb.scheduleRecursiveWithState(0,function(f,g){if(!a){if(f===d)return e.onCompleted();var h=c[f];ka(h)&&(h=Gc(h));var i=new qb;b.setDisposable(i),i.setDisposable(h.subscribe(function(a){e.onNext(a)},function(a){e.onError(a)},function(){g(f+1)}))}});return new jb(b,f,mb(function(){a=!0}))},b}(Ob),qc=Nb.concat=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{a=new Array(arguments.length);for(var b=0,c=arguments.length;c>b;b++)a[b]=arguments[b]}return new pc(a)};Db.concatAll=Db.concatObservable=function(){return this.merge(1)};var rc=function(a){function b(b,c){this.source=b,this.maxConcurrent=c,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){var b=new jb;return b.add(this.source.subscribe(new sc(a,this.maxConcurrent,b))),b},b}(Ob),sc=function(){function a(a,b,c){this.o=a,this.max=b,this.g=c,this.done=!1,this.q=[],this.activeCount=0,this.isStopped=!1}function b(a,b){this.parent=a,this.sad=b,this.isStopped=!1}return a.prototype.handleSubscribe=function(a){var c=new qb;this.g.add(c),ka(a)&&(a=Gc(a)),c.setDisposable(a.subscribe(new b(this,c)))},a.prototype.onNext=function(a){this.isStopped||(this.activeCount<this.max?(this.activeCount++,this.handleSubscribe(a)):this.q.push(a))},a.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},a.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.done=!0,0===this.activeCount&&this.o.onCompleted())},a.prototype.dispose=function(){this.isStopped=!0},a.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b.prototype.onNext=function(a){this.isStopped||this.parent.o.onNext(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.parent.o.onError(a))},b.prototype.onCompleted=function(){if(!this.isStopped){this.isStopped=!0;var a=this.parent;a.g.remove(this.sad),a.q.length>0?a.handleSubscribe(a.q.shift()):(a.activeCount--,a.done&&0===a.activeCount&&a.o.onCompleted())}},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(a),!0)},a}();Db.merge=function(a){return"number"!=typeof a?tc(this,a):new rc(this,a)};var tc=Nb.merge=function(){var a,b,c=[],d=arguments.length;if(arguments[0])if(vb(arguments[0]))for(a=arguments[0],b=1;d>b;b++)c.push(arguments[b]);else for(a=yb,b=0;d>b;b++)c.push(arguments[b]);else for(a=yb,b=1;d>b;b++)c.push(arguments[b]);return Array.isArray(c[0])&&(c=c[0]),C(a,c).mergeAll()},uc=function(a){function b(b){this.source=b,a.call(this)}function c(a,b){this.o=a,this.g=b,this.isStopped=!1,this.done=!1}function d(a,b,c){this.parent=a,this.g=b,this.sad=c,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){var b=new jb,d=new qb;return b.add(d),d.setDisposable(this.source.subscribe(new c(a,b))),b},c.prototype.onNext=function(a){if(!this.isStopped){var b=new qb;this.g.add(b),ka(a)&&(a=Gc(a)),b.setDisposable(a.subscribe(new d(this,this.g,b)))}},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.done=!0,1===this.g.length&&this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},d.prototype.onNext=function(a){this.isStopped||this.parent.o.onNext(a)},d.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.parent.o.onError(a))},d.prototype.onCompleted=function(){if(!this.isStopped){var a=this.parent;this.isStopped=!0,a.g.remove(this.sad),a.done&&1===a.g.length&&a.o.onCompleted()}},d.prototype.dispose=function(){this.isStopped=!0},d.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(a),!0)},b}(Ob);Db.mergeAll=Db.mergeObservable=function(){return new uc(this)};var vc=da.CompositeError=function(a){this.name="NotImplementedError",this.innerErrors=a,this.message="This contains multiple errors. Check the innerErrors",Error.call(this)};vc.prototype=Error.prototype,Nb.mergeDelayError=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{var b=arguments.length;a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}var d=C(null,a);return new Nc(function(a){function b(){0===g.length?a.onCompleted():a.onError(1===g.length?g[0]:new vc(g))}var c=new jb,e=new qb,f=!1,g=[];return c.add(e),e.setDisposable(d.subscribe(function(d){var e=new qb;c.add(e),ka(d)&&(d=Gc(d)),e.setDisposable(d.subscribe(function(b){a.onNext(b)},function(a){g.push(a),c.remove(e),f&&1===c.length&&b()},function(){c.remove(e),f&&1===c.length&&b()}))},function(a){g.push(a),f=!0,1===c.length&&b()},function(){f=!0,1===c.length&&b()})),c})},Db.skipUntil=function(a){var b=this;return new Nc(function(c){var d=!1,e=new jb(b.subscribe(function(a){d&&c.onNext(a)},function(a){c.onError(a)},function(){d&&c.onCompleted()}));ka(a)&&(a=Gc(a));var f=new qb;return e.add(f),f.setDisposable(a.subscribe(function(){d=!0,f.dispose()},function(a){c.onError(a)},function(){f.dispose()})),e},b)};var wc=function(a){function b(b){this.source=b,a.call(this)}function c(a,b){this.o=a,this.inner=b,this.stopped=!1,this.latest=0,this.hasLatest=!1,this.isStopped=!1}function d(a,b){this.parent=a,this.id=b,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){var b=new rb,d=this.source.subscribe(new c(a,b));return new jb(d,b)},c.prototype.onNext=function(a){if(!this.isStopped){var b=new qb,c=++this.latest;this.hasLatest=!0,this.inner.setDisposable(b),ka(a)&&(a=Gc(a)),b.setDisposable(a.subscribe(new d(this,c)))}},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.stopped=!0,!this.hasLatest&&this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},d.prototype.onNext=function(a){this.isStopped||this.parent.latest===this.id&&this.parent.o.onNext(a)},d.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.parent.latest===this.id&&this.parent.o.onError(a))},d.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.parent.latest===this.id&&(this.parent.hasLatest=!1,this.parent.isStopped&&this.parent.o.onCompleted()))},d.prototype.dispose=function(){this.isStopped=!0},d.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.parent.o.onError(a),!0)},b}(Ob);Db["switch"]=Db.switchLatest=function(){return new wc(this)};var xc=function(a){function b(b,c){this.source=b,this.other=ka(c)?Gc(c):c,a.call(this)}function c(a){this.o=a,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return new jb(this.source.subscribe(a),this.other.subscribe(new c(a)))},c.prototype.onNext=function(a){this.isStopped||this.o.onCompleted()},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){!this.isStopped&&(this.isStopped=!0)},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.takeUntil=function(a){return new xc(this,a)},Db.withLatestFrom=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=b.pop(),e=this;return Array.isArray(b[0])&&(b=b[0]),new Nc(function(a){for(var c=b.length,f=q(c,G),g=!1,h=new Array(c),i=new Array(c+1),j=0;c>j;j++)!function(c){var d=b[c],e=new qb;ka(d)&&(d=Gc(d)),e.setDisposable(d.subscribe(function(a){h[c]=a,f[c]=!0,g=f.every(fa)},function(b){a.onError(b)},ea)),i[c]=e}(j);var k=new qb;return k.setDisposable(e.subscribe(function(b){var c=[b].concat(h);if(g){var e=o(d).apply(null,c);return e===bb?a.onError(e.e):void a.onNext(e)}},function(b){a.onError(b)},function(){a.onCompleted()})),i[c]=k,new jb(i)},this)},Db.zip=function(){if(Array.isArray(arguments[0]))return H.apply(this,arguments);for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=this,e=b.pop();return b.unshift(d),new Nc(function(a){for(var c=b.length,f=q(c,I),g=q(c,G),h=new Array(c),i=0;c>i;i++)!function(c){var i=b[c],j=new qb;ka(i)&&(i=Gc(i)),j.setDisposable(i.subscribe(function(b){if(f[c].push(b),f.every(function(a){return a.length>0})){var h=f.map(function(a){return a.shift()}),i=o(e).apply(d,h);if(i===bb)return a.onError(i.e);a.onNext(i)}else g.filter(function(a,b){return b!==c}).every(fa)&&a.onCompleted()},function(b){a.onError(b)},function(){g[c]=!0,g.every(fa)&&a.onCompleted()})),h[c]=j}(i);return new jb(h)},d)},Nb.zip=function(){for(var a=arguments.length,b=new Array(a),c=0;a>c;c++)b[c]=arguments[c];var d=b.shift();return d.zip.apply(d,b)},Nb.zipArray=function(){var a;if(Array.isArray(arguments[0]))a=arguments[0];else{var b=arguments.length;a=new Array(b);for(var c=0;b>c;c++)a[c]=arguments[c]}return new Nc(function(b){for(var c=a.length,d=q(c,J),e=q(c,G),f=new Array(c),g=0;c>g;g++)!function(c){f[c]=new qb,f[c].setDisposable(a[c].subscribe(function(a){if(d[c].push(a),d.every(function(a){return a.length>0})){var f=d.map(function(a){return a.shift()});b.onNext(f)}else if(e.filter(function(a,b){return b!==c}).every(fa))return b.onCompleted()},function(a){b.onError(a)},function(){e[c]=!0,e.every(fa)&&b.onCompleted()}))}(g);return new jb(f)})},Db.asObservable=function(){var a=this;return new Nc(function(b){return a.subscribe(b)},a)},Db.dematerialize=function(){var a=this;return new Nc(function(b){return a.subscribe(function(a){return a.accept(b)},function(a){b.onError(a)},function(){b.onCompleted()})},this)},Db.distinctUntilChanged=function(a,b){var c=this;return b||(b=ha),new Nc(function(d){var e,f=!1;return c.subscribe(function(c){var g=c;if(a&&(g=o(a)(c),g===bb))return d.onError(g.e);if(f){var h=o(b)(e,g);if(h===bb)return d.onError(h.e)}f&&h||(f=!0,e=g,d.onNext(c))},function(a){d.onError(a)},function(){d.onCompleted()})},this)};var yc=function(a){function b(b,c,d,e){this.source=b,this.t=!c||la(c)?Kb(c||ea,d||ea,e||ea):c,a.call(this)}function c(a,b){this.o=a,this.t=b,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a,this.t))},c.prototype.onNext=function(a){if(!this.isStopped){var b=o(this.t.onNext).call(this.t,a);b===bb&&this.o.onError(b.e),this.o.onNext(a)}},c.prototype.onError=function(a){if(!this.isStopped){this.isStopped=!0;var b=o(this.t.onError).call(this.t,a);if(b===bb)return this.o.onError(b.e);this.o.onError(a)}},c.prototype.onCompleted=function(){if(!this.isStopped){this.isStopped=!0;var a=o(this.t.onCompleted).call(this.t);if(a===bb)return this.o.onError(a.e);this.o.onCompleted()}},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db["do"]=Db.tap=Db.doAction=function(a,b,c){return new yc(this,a,b,c)},Db.doOnNext=Db.tapOnNext=function(a,b){return this.tap("undefined"!=typeof b?function(c){a.call(b,c)}:a)},Db.doOnError=Db.tapOnError=function(a,b){return this.tap(ea,"undefined"!=typeof b?function(c){a.call(b,c)}:a)},Db.doOnCompleted=Db.tapOnCompleted=function(a,b){return this.tap(ea,null,"undefined"!=typeof b?function(){a.call(b)}:a)},Db["finally"]=Db.ensure=function(a){var b=this;return new Nc(function(c){var d;try{d=b.subscribe(c)}catch(e){throw a(),e}return mb(function(){try{d.dispose()}catch(b){throw b}finally{a()}})},this)},Db.finallyAction=function(a){return this.ensure(a)};var zc=function(a){function b(b){this.source=b,a.call(this)}function c(a){this.o=a,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a))},c.prototype.onNext=ea,c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(a),!0)},b}(Ob);Db.ignoreElements=function(){return new zc(this)},Db.materialize=function(){var a=this;return new Nc(function(b){return a.subscribe(function(a){b.onNext(Gb(a))},function(a){b.onNext(Hb(a)),b.onCompleted()},function(){b.onNext(Ib()),b.onCompleted()})},a)},Db.repeat=function(a){return Tb(this,a).concat()},Db.retry=function(a){return Tb(this,a).catchError()},Db.retryWhen=function(a){return Tb(this).catchErrorWhen(a)};var Ac=function(a){function b(b,c,d,e){this.source=b,this.accumulator=c,this.hasSeed=d,this.seed=e,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new K(a,this))},b}(Ob);K.prototype.onNext=function(a){if(!this.isStopped){!this.hasValue&&(this.hasValue=!0);try{this.hasAccumulation?this.accumulation=this.accumulator(this.accumulation,a):(this.accumulation=this.hasSeed?this.accumulator(this.seed,a):a,this.hasAccumulation=!0)}catch(b){return this.observer.onError(b)}this.observer.onNext(this.accumulation)}},K.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.observer.onError(a))},K.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,!this.hasValue&&this.hasSeed&&this.observer.onNext(this.seed),this.observer.onCompleted())},K.prototype.dispose=function(){this.isStopped=!0},K.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.observer.onError(a),!0)},Db.scan=function(){var a,b,c=!1;return 2===arguments.length?(c=!0,a=arguments[0],b=arguments[1]):b=arguments[0],new Ac(this,b,c,a)},Db.skipLast=function(a){if(0>a)throw new ta;var b=this;return new Nc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&c.onNext(d.shift())},function(a){c.onError(a)},function(){c.onCompleted()})},b)},Db.startWith=function(){var a,b=0;arguments.length&&vb(arguments[0])?(a=arguments[0],b=1):a=yb;for(var c=[],d=b,e=arguments.length;e>d;d++)c.push(arguments[d]);return Vb([ec(c,a),this]).concat()},Db.takeLast=function(a){if(0>a)throw new ta;var b=this;return new Nc(function(c){var d=[];return b.subscribe(function(b){d.push(b),d.length>a&&d.shift()},function(a){c.onError(a)},function(){for(;d.length>0;)c.onNext(d.shift());c.onCompleted()})},b)},Db.selectConcat=Db.concatMap=function(a,b,c){return la(a)&&la(b)?this.concatMap(function(c,d){var e=a(c,d);return ka(e)&&(e=Gc(e)),(Ba(e)||Aa(e))&&(e=cc(e)),e.map(function(a,e){return b(c,a,d,e)})}):la(a)?L(this,a,c):L(this,function(){return a})};var Bc=function(a){function b(b,c,d){this.source=b,this.selector=Da(c,d,3),a.call(this)}function c(a,b){return function(c,d,e){return a.call(this,b.selector(c,d,e),d,e)}}function d(a,b,c){this.o=a,this.selector=b,this.source=c,this.i=0,this.isStopped=!1}return db(b,a),b.prototype.internalMap=function(a,d){return new b(this.source,c(a,this),d)},b.prototype.subscribeCore=function(a){return this.source.subscribe(new d(a,this.selector,this))},d.prototype.onNext=function(a){if(!this.isStopped){var b=o(this.selector)(a,this.i++,this.source);return b===bb?this.o.onError(b.e):void this.o.onNext(b)}},d.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},d.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},d.prototype.dispose=function(){this.isStopped=!0},d.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.map=Db.select=function(a,b){var c="function"==typeof a?a:function(){return a};return this instanceof Bc?this.internalMap(c,b):new Bc(this,c,b)},Db.pluck=function(){var b=arguments,c=arguments.length;if(0===c)throw new Error("List of properties cannot be empty.");return this.map(function(d){for(var e=d,f=0;c>f;f++){var g=e[b[f]];if("undefined"==typeof g)return a;e=g}return e})},Db.selectMany=Db.flatMap=function(a,b,c){return la(a)&&la(b)?this.flatMap(function(c,d){var e=a(c,d);return ka(e)&&(e=Gc(e)),(Ba(e)||Aa(e))&&(e=cc(e)),e.map(function(a,e){return b(c,a,d,e)})},c):la(a)?M(this,a,c):M(this,function(){return a})},Db.selectSwitch=Db.flatMapLatest=Db.switchMap=function(a,b){return this.select(a,b).switchLatest()};var Cc=function(a){function b(b,c){this.source=b,this.skipCount=c,a.call(this)}function c(a,b){this.c=b,this.r=b,this.o=a,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new c(a,this.skipCount))},c.prototype.onNext=function(a){this.isStopped||(this.r<=0?this.o.onNext(a):this.r--)},c.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},c.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},c.prototype.dispose=function(){this.isStopped=!0},c.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.skip=function(a){if(0>a)throw new ta;return new Cc(this,a)},Db.skipWhile=function(a,b){var c=this,d=Da(a,b,3);return new Nc(function(a){var b=0,e=!1;return c.subscribe(function(f){if(!e)try{e=!d(f,b++,c)}catch(g){return void a.onError(g)}e&&a.onNext(f)},function(b){a.onError(b)},function(){a.onCompleted()})},c)},Db.take=function(a,b){if(0>a)throw new ta;if(0===a)return $b(b);var c=this;return new Nc(function(b){var d=a;return c.subscribe(function(a){d-->0&&(b.onNext(a),0>=d&&b.onCompleted())},function(a){b.onError(a)},function(){b.onCompleted()})},c)},Db.takeWhile=function(a,b){var c=this,d=Da(a,b,3);return new Nc(function(a){var b=0,e=!0;return c.subscribe(function(f){if(e){try{e=d(f,b++,c)}catch(g){return void a.onError(g)}e?a.onNext(f):a.onCompleted()}},function(b){a.onError(b)},function(){a.onCompleted()})},c)};var Dc=function(a){function b(b,c,d){this.source=b,this.predicate=Da(c,d,3),a.call(this)}function c(a,b){return function(c,d,e){return b.predicate(c,d,e)&&a.call(this,c,d,e)}}function d(a,b,c){this.o=a,this.predicate=b,this.source=c,this.i=0,this.isStopped=!1}return db(b,a),b.prototype.subscribeCore=function(a){return this.source.subscribe(new d(a,this.predicate,this))},b.prototype.internalFilter=function(a,d){return new b(this.source,c(a,this),d)},d.prototype.onNext=function(a){if(!this.isStopped){var b=o(this.predicate)(a,this.i++,this.source);return b===bb?this.o.onError(b.e):void(b&&this.o.onNext(a))}},d.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.o.onError(a))},d.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.o.onCompleted())},d.prototype.dispose=function(){this.isStopped=!0},d.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.o.onError(a),!0)},b}(Ob);Db.filter=Db.where=function(a,b){return this instanceof Dc?this.internalFilter(a,b):new Dc(this,a,b)},Nb.fromCallback=function(a,b,c){return function(){for(var d=arguments.length,e=new Array(d),f=0;d>f;f++)e[f]=arguments[f];return new Nc(function(d){function f(){for(var a=arguments.length,e=new Array(a),f=0;a>f;f++)e[f]=arguments[f];if(c){try{e=c.apply(b,e)}catch(g){return d.onError(g)}d.onNext(e)}else e.length<=1?d.onNext.apply(d,e):d.onNext(e);d.onCompleted()}e.push(f),a.apply(b,e)}).publishLast().refCount()}},Nb.fromNodeCallback=function(a,b,c){return function(){for(var d=arguments.length,e=new Array(d),f=0;d>f;f++)e[f]=arguments[f];return new Nc(function(d){function f(a){if(a)return void d.onError(a);for(var e=arguments.length,f=[],g=1;e>g;g++)f[g-1]=arguments[g];if(c){try{f=c.apply(b,f)}catch(h){return d.onError(h)}d.onNext(f)}else f.length<=1?d.onNext.apply(d,f):d.onNext(f);d.onCompleted()}e.push(f),a.apply(b,e)}).publishLast().refCount()}},da.config.useNativeEvents=!1,Nb.fromEvent=function(a,b,c){return a.addListener?Ec(function(c){a.addListener(b,c)},function(c){a.removeListener(b,c)},c):da.config.useNativeEvents||"function"!=typeof a.on||"function"!=typeof a.off?new Nc(function(d){return Q(a,b,function(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e)}d.onNext(b)})}).publish().refCount():Ec(function(c){a.on(b,c)},function(c){a.off(b,c)},c)};var Ec=Nb.fromEventPattern=function(a,b,c){return new Nc(function(d){function e(a){var b=a;if(c)try{b=c(arguments)}catch(e){return d.onError(e)}d.onNext(b)}var f=a(e);return mb(function(){b&&b(e,f)})}).publish().refCount()},Fc=function(a){function b(b){this.p=b,a.call(this)}return db(b,a),b.prototype.subscribeCore=function(a){return this.p.then(function(b){a.onNext(b),a.onCompleted()},function(b){a.onError(b)}),nb},b}(Ob),Gc=Nb.fromPromise=function(a){return new Fc(a)};Db.toPromise=function(a){if(a||(a=da.config.Promise),!a)throw new ua("Promise type not provided nor in Rx.config.Promise");var b=this;return new a(function(a,c){var d,e=!1;b.subscribe(function(a){d=a,e=!0},c,function(){e&&a(d)})})},Nb.startAsync=function(a){var b;try{b=a()}catch(c){return mc(c)}return Gc(b)},Db.multicast=function(a,b){var c=this;return"function"==typeof a?new Nc(function(d){var e=c.multicast(a());return new jb(b(e).subscribe(d),e.connect())},c):new Hc(c,a)},Db.publish=function(a){return a&&la(a)?this.multicast(function(){return new Qc},a):this.multicast(new Qc)},Db.share=function(){return this.publish().refCount()},Db.publishLast=function(a){return a&&la(a)?this.multicast(function(){return new Rc},a):this.multicast(new Rc)},Db.publishValue=function(a,b){return 2===arguments.length?this.multicast(function(){return new Tc(b)},a):this.multicast(new Tc(a))},Db.shareValue=function(a){return this.publishValue(a).refCount()},Db.replay=function(a,b,c,d){return a&&la(a)?this.multicast(function(){return new Uc(b,c,d)},a):this.multicast(new Uc(b,c,d))},Db.shareReplay=function(a,b,c){return this.replay(null,a,b,c).refCount()};{var Hc=da.ConnectableObservable=function(a){function b(b,c){var d,e=!1,f=b.asObservable();this.connect=function(){return e||(e=!0,d=new jb(f.subscribe(c),mb(function(){e=!1}))),d},a.call(this,function(a){return c.subscribe(a)})}return db(b,a),b.prototype.refCount=function(){var a,b=0,c=this;return new Nc(function(d){var e=1===++b,f=c.subscribe(d);return e&&(a=c.connect()),function(){f.dispose(),0===--b&&a.dispose()}})},b}(Nb),Ic=Nb.interval=function(a,b){return U(a,a,vb(b)?b:Eb)};Nb.timer=function(b,c,d){var e;return vb(d)||(d=Eb),c!==a&&"number"==typeof c?e=c:vb(c)&&(d=c),b instanceof Date&&e===a?R(b.getTime(),d):b instanceof Date&&e!==a?(e=c,S(b.getTime(),e,d)):e===a?T(b,d):U(b,e,d)}}Db.delay=function(a,b){return vb(b)||(b=Eb),a instanceof Date?W(this,a.getTime(),b):V(this,a,b)},Db.debounce=Db.throttleWithTimeout=function(a,b){vb(b)||(b=Eb);var c=this;return new Nc(function(d){var e,f=new rb,g=!1,h=0,i=c.subscribe(function(c){g=!0,e=c,h++;var i=h,j=new qb;f.setDisposable(j),j.setDisposable(b.scheduleWithRelative(a,function(){g&&h===i&&d.onNext(e),g=!1}))},function(a){f.dispose(),d.onError(a),g=!1,h++},function(){f.dispose(),g&&d.onNext(e),d.onCompleted(),g=!1,h++});return new jb(i,f)},this)},Db.throttle=function(a,b){return this.debounce(a,b)},Db.timestamp=function(a){return vb(a)||(a=Eb),this.map(function(b){return{value:b,timestamp:a.now()}})},Db.sample=Db.throttleLatest=function(a,b){return vb(b)||(b=Eb),"number"==typeof a?X(this,Ic(a,b)):X(this,a)},Db.timeout=function(a,b,c){(null==b||"string"==typeof b)&&(b=mc(new Error(b||"Timeout"))),vb(c)||(c=Eb);var d=this,e=a instanceof Date?"scheduleWithAbsolute":"scheduleWithRelative";return new Nc(function(f){function g(){var d=h;l.setDisposable(c[e](a,function(){h===d&&(ka(b)&&(b=Gc(b)),j.setDisposable(b.subscribe(f)))}))}var h=0,i=new qb,j=new rb,k=!1,l=new rb;return j.setDisposable(i),g(),i.setDisposable(d.subscribe(function(a){k||(h++,f.onNext(a),g())},function(a){k||(h++,f.onError(a))},function(){k||(h++,f.onCompleted())})),new jb(j,l)},d)},Db.throttleFirst=function(a,b){vb(b)||(b=Eb);var c=+a||0;if(0>=c)throw new RangeError("windowDuration cannot be less or equal zero.");var d=this;return new Nc(function(a){var e=0;return d.subscribe(function(d){var f=b.now();(0===e||f-e>=c)&&(e=f,a.onNext(d))},function(b){a.onError(b)},function(){a.onCompleted()})},d)};var Jc=function(a){function b(a){var b=this.source.publish(),c=b.subscribe(a),d=nb,e=this.pauser.distinctUntilChanged().subscribe(function(a){a?d=b.connect():(d.dispose(),d=nb)});return new jb(c,d,e)}function c(c,d){this.source=c,this.controller=new Qc,d&&d.subscribe?this.pauser=this.controller.merge(d):this.pauser=this.controller,a.call(this,b,c)}return db(c,a),c.prototype.pause=function(){this.controller.onNext(!1)},
|
4 |
-
c.prototype.resume=function(){this.controller.onNext(!0)},c}(Nb);Db.pausable=function(a){return new Jc(this,a)};var Kc=function(b){function c(b){function c(){for(;e.length>0;)b.onNext(e.shift())}var d,e=[],f=Y(this.source,this.pauser.distinctUntilChanged().startWith(!1),function(a,b){return{data:a,shouldFire:b}}).subscribe(function(f){d!==a&&f.shouldFire!=d?(d=f.shouldFire,f.shouldFire&&c()):(d=f.shouldFire,f.shouldFire?b.onNext(f.data):e.push(f.data))},function(a){c(),b.onError(a)},function(){c(),b.onCompleted()});return f}function d(a,d){this.source=a,this.controller=new Qc,d&&d.subscribe?this.pauser=this.controller.merge(d):this.pauser=this.controller,b.call(this,c,a)}return db(d,b),d.prototype.pause=function(){this.controller.onNext(!1)},d.prototype.resume=function(){this.controller.onNext(!0)},d}(Nb);Db.pausableBuffered=function(a){return new Kc(this,a)};var Lc=function(a){function b(a){return this.source.subscribe(a)}function c(c,d,e){a.call(this,b,c),this.subject=new Mc(d,e),this.source=c.multicast(this.subject).refCount()}return db(c,a),c.prototype.request=function(a){return this.subject.request(null==a?-1:a)},c}(Nb),Mc=function(a){function b(a){return this.subject.subscribe(a)}function c(c,d){null==c&&(c=!0),a.call(this,b),this.subject=new Qc,this.enableQueue=c,this.queue=c?[]:null,this.requestedCount=0,this.requestedDisposable=nb,this.error=null,this.hasFailed=!1,this.hasCompleted=!1,this.scheduler=d||zb}return db(c,a),eb(c.prototype,Jb,{onCompleted:function(){this.hasCompleted=!0,this.enableQueue&&0!==this.queue.length?this.queue.push(Fb.createOnCompleted()):this.subject.onCompleted()},onError:function(a){this.hasFailed=!0,this.error=a,this.enableQueue&&0!==this.queue.length?this.queue.push(Fb.createOnError(a)):this.subject.onError(a)},onNext:function(a){var b=!1;0===this.requestedCount?this.enableQueue&&this.queue.push(Fb.createOnNext(a)):(-1!==this.requestedCount&&0===this.requestedCount--&&this.disposeCurrentRequest(),b=!0),b&&this.subject.onNext(a)},_processRequest:function(a){if(this.enableQueue){for(;this.queue.length>=a&&a>0||this.queue.length>0&&"N"!==this.queue[0].kind;){var b=this.queue.shift();b.accept(this.subject),"N"===b.kind?a--:(this.disposeCurrentRequest(),this.queue=[])}return{numberOfItems:a,returnValue:0!==this.queue.length}}return{numberOfItems:a,returnValue:!1}},request:function(a){this.disposeCurrentRequest();var b=this;return this.requestedDisposable=this.scheduler.scheduleWithState(a,function(a,c){var d=b._processRequest(c),e=d.numberOfItems;d.returnValue||(b.requestedCount=e,b.requestedDisposable=mb(function(){b.requestedCount=0}))}),this.requestedDisposable},disposeCurrentRequest:function(){this.requestedDisposable.dispose(),this.requestedDisposable=nb}}),c}(Nb);Db.controlled=function(a,b){return a&&vb(a)&&(b=a,a=!0),null==a&&(a=!0),new Lc(this,a,b)},Db.pipe=function(a){function b(){c.resume()}var c=this.pausableBuffered();return a.addListener("drain",b),c.subscribe(function(b){!a.write(String(b))&&c.pause()},function(b){a.emit("error",b)},function(){!a._isStdio&&a.end(),a.removeListener("drain",b)}),c.resume(),a},Db.transduce=function(a){function b(a){return{"@@transducer/init":function(){return a},"@@transducer/step":function(a,b){return a.onNext(b)},"@@transducer/result":function(a){return a.onCompleted()}}}var c=this;return new Nc(function(d){var e=a(b(d));return c.subscribe(function(a){try{e["@@transducer/step"](d,a)}catch(b){d.onError(b)}},function(a){d.onError(a)},function(){e["@@transducer/result"](d)})},c)};var Nc=da.AnonymousObservable=function(a){function b(a){return a&&la(a.dispose)?a:la(a)?mb(a):nb}function c(a,c){var d=c[0],e=c[1],f=o(e)(d);return f!==bb||d.fail(bb.e)?void d.setDisposable(b(f)):p(bb.e)}function d(b,d){function e(a){var d=new Oc(a),e=[d,b];return zb.scheduleRequired()?zb.scheduleWithState(e,c):c(null,e),d}this.source=d,a.call(this,e)}return db(d,a),d}(Nb),Oc=function(a){function b(b){a.call(this),this.observer=b,this.m=new qb}db(b,a);var c=b.prototype;return c.next=function(a){var b=o(this.observer.onNext).call(this.observer,a);b===bb&&(this.dispose(),p(b.e))},c.error=function(a){var b=o(this.observer.onError).call(this.observer,a);this.dispose(),b===bb&&p(b.e)},c.completed=function(){var a=o(this.observer.onCompleted).call(this.observer);this.dispose(),a===bb&&p(a.e)},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(Lb),Pc=function(a,b){this.subject=a,this.observer=b};Pc.prototype.dispose=function(){if(!this.subject.isDisposed&&null!==this.observer){var a=this.subject.observers.indexOf(this.observer);this.subject.observers.splice(a,1),this.observer=null}};var Qc=da.Subject=function(a){function c(a){return pb(this),this.isStopped?this.hasError?(a.onError(this.error),nb):(a.onCompleted(),nb):(this.observers.push(a),new Pc(this,a))}function d(){a.call(this,c),this.isDisposed=!1,this.isStopped=!1,this.observers=[],this.hasError=!1}return db(d,a),eb(d.prototype,Jb.prototype,{hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(pb(this),!this.isStopped){this.isStopped=!0;for(var a=0,c=b(this.observers),d=c.length;d>a;a++)c[a].onCompleted();this.observers.length=0}},onError:function(a){if(pb(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onError(a);this.observers.length=0}},onNext:function(a){if(pb(this),!this.isStopped)for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onNext(a)},dispose:function(){this.isDisposed=!0,this.observers=null}}),d.create=function(a,b){return new Sc(a,b)},d}(Nb),Rc=da.AsyncSubject=function(a){function c(a){return pb(this),this.isStopped?(this.hasError?a.onError(this.error):this.hasValue?(a.onNext(this.value),a.onCompleted()):a.onCompleted(),nb):(this.observers.push(a),new Pc(this,a))}function d(){a.call(this,c),this.isDisposed=!1,this.isStopped=!1,this.hasValue=!1,this.observers=[],this.hasError=!1}return db(d,a),eb(d.prototype,Jb,{hasObservers:function(){return pb(this),this.observers.length>0},onCompleted:function(){var a,c;if(pb(this),!this.isStopped){this.isStopped=!0;var d=b(this.observers),c=d.length;if(this.hasValue)for(a=0;c>a;a++){var e=d[a];e.onNext(this.value),e.onCompleted()}else for(a=0;c>a;a++)d[a].onCompleted();this.observers.length=0}},onError:function(a){if(pb(this),!this.isStopped){this.isStopped=!0,this.hasError=!0,this.error=a;for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onError(a);this.observers.length=0}},onNext:function(a){pb(this),this.isStopped||(this.value=a,this.hasValue=!0)},dispose:function(){this.isDisposed=!0,this.observers=null,this.exception=null,this.value=null}}),d}(Nb),Sc=da.AnonymousSubject=function(a){function b(a){return this.observable.subscribe(a)}function c(c,d){this.observer=c,this.observable=d,a.call(this,b)}return db(c,a),eb(c.prototype,Jb.prototype,{onCompleted:function(){this.observer.onCompleted()},onError:function(a){this.observer.onError(a)},onNext:function(a){this.observer.onNext(a)}}),c}(Nb),Tc=da.BehaviorSubject=function(a){function c(a){return pb(this),this.isStopped?(this.hasError?a.onError(this.error):a.onCompleted(),nb):(this.observers.push(a),a.onNext(this.value),new Pc(this,a))}function d(b){a.call(this,c),this.value=b,this.observers=[],this.isDisposed=!1,this.isStopped=!1,this.hasError=!1}return db(d,a),eb(d.prototype,Jb,{getValue:function(){if(pb(this),this.hasError)throw this.error;return this.value},hasObservers:function(){return this.observers.length>0},onCompleted:function(){if(pb(this),!this.isStopped){this.isStopped=!0;for(var a=0,c=b(this.observers),d=c.length;d>a;a++)c[a].onCompleted();this.observers.length=0}},onError:function(a){if(pb(this),!this.isStopped){this.isStopped=!0,this.hasError=!0,this.error=a;for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onError(a);this.observers.length=0}},onNext:function(a){if(pb(this),!this.isStopped){this.value=a;for(var c=0,d=b(this.observers),e=d.length;e>c;c++)d[c].onNext(a)}},dispose:function(){this.isDisposed=!0,this.observers=null,this.value=null,this.exception=null}}),d}(Nb),Uc=da.ReplaySubject=function(a){function c(a,b){return mb(function(){b.dispose(),!a.isDisposed&&a.observers.splice(a.observers.indexOf(b),1)})}function d(a){var b=new Wb(this.scheduler,a),d=c(this,b);pb(this),this._trim(this.scheduler.now()),this.observers.push(b);for(var e=0,f=this.q.length;f>e;e++)b.onNext(this.q[e].value);return this.hasError?b.onError(this.error):this.isStopped&&b.onCompleted(),b.ensureActive(),d}function e(b,c,e){this.bufferSize=null==b?f:b,this.windowSize=null==c?f:c,this.scheduler=e||zb,this.q=[],this.observers=[],this.isStopped=!1,this.isDisposed=!1,this.hasError=!1,this.error=null,a.call(this,d)}var f=Math.pow(2,53)-1;return db(e,a),eb(e.prototype,Jb.prototype,{hasObservers:function(){return this.observers.length>0},_trim:function(a){for(;this.q.length>this.bufferSize;)this.q.shift();for(;this.q.length>0&&a-this.q[0].interval>this.windowSize;)this.q.shift()},onNext:function(a){if(pb(this),!this.isStopped){var c=this.scheduler.now();this.q.push({interval:c,value:a}),this._trim(c);for(var d=0,e=b(this.observers),f=e.length;f>d;d++){var g=e[d];g.onNext(a),g.ensureActive()}}},onError:function(a){if(pb(this),!this.isStopped){this.isStopped=!0,this.error=a,this.hasError=!0;var c=this.scheduler.now();this._trim(c);for(var d=0,e=b(this.observers),f=e.length;f>d;d++){var g=e[d];g.onError(a),g.ensureActive()}this.observers.length=0}},onCompleted:function(){if(pb(this),!this.isStopped){this.isStopped=!0;var a=this.scheduler.now();this._trim(a);for(var c=0,d=b(this.observers),e=d.length;e>c;c++){var f=d[c];f.onCompleted(),f.ensureActive()}this.observers.length=0}},dispose:function(){this.isDisposed=!0,this.observers=null}}),e}(Nb);da.Pauser=function(a){function b(){a.call(this)}return db(b,a),b.prototype.pause=function(){this.onNext(!1)},b.prototype.resume=function(){this.onNext(!0)},b}(Qc),"function"==typeof define&&"object"==typeof define.amd&&define.amd?($.Rx=da,define(function(){return da})):_&&aa?ba?(aa.exports=da).Rx=da:_.Rx=da:$.Rx=da;var Vc=g()}).call(this);
|
5 |
-
//# sourceMappingURL=rx.lite.compat.map
|
|
|
|
|
|
|
|
|
|
trunk/js/set-unbounce-domains.js
DELETED
@@ -1,146 +0,0 @@
|
|
1 |
-
(function($) {
|
2 |
-
|
3 |
-
function apiGetPromise(url, token) {
|
4 |
-
return $.ajax({
|
5 |
-
url: url,
|
6 |
-
method: 'get',
|
7 |
-
headers: { 'Authorization': 'Bearer ' + token,
|
8 |
-
'Accept': 'application/vnd.unbounce.api.v0.4+json' },
|
9 |
-
dataType: 'json'
|
10 |
-
}).promise();
|
11 |
-
}
|
12 |
-
|
13 |
-
function apiGet(url, token) {
|
14 |
-
return Rx.Observable.fromPromise(apiGetPromise(url, token));
|
15 |
-
}
|
16 |
-
|
17 |
-
function getDomainData(subAccount, domains) {
|
18 |
-
if($.isArray(domains)) {
|
19 |
-
return Rx.Observable.fromArray(
|
20 |
-
$.map(domains, function(domain) {
|
21 |
-
if(domain && domain.name) {
|
22 |
-
return {
|
23 |
-
clientId: subAccount.id,
|
24 |
-
domainId: domain.id,
|
25 |
-
name: domain.name
|
26 |
-
};
|
27 |
-
} else {
|
28 |
-
throw 'Unable to fetch domain name';
|
29 |
-
}
|
30 |
-
}));
|
31 |
-
} else {
|
32 |
-
throw 'Unable to fetch domains';
|
33 |
-
}
|
34 |
-
}
|
35 |
-
|
36 |
-
function getUserSubAccounts(user, token) {
|
37 |
-
if(user.metadata && user.metadata.related && $.isArray(user.metadata.related.sub_accounts)) {
|
38 |
-
var promises = $.map(user.metadata.related.sub_accounts, function(subAccountUrl) {
|
39 |
-
return apiGetPromise(subAccountUrl, token);
|
40 |
-
});
|
41 |
-
return Rx.Observable.fromArray(promises).flatMap(Rx.Observable.fromPromise);
|
42 |
-
} else {
|
43 |
-
throw 'Unable to fetch user';
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
function postDomainsToWordpress($form, data, wordpressDomainName) {
|
48 |
-
if($.isArray(data.domains)) {
|
49 |
-
var wordpressDomains = data.domains.filter(function(domain) {
|
50 |
-
return domain.name === wordpressDomainName;
|
51 |
-
});
|
52 |
-
|
53 |
-
if(wordpressDomains[0]) {
|
54 |
-
var wordpressDomain = wordpressDomains[0];
|
55 |
-
$form.find('[name="domain_id"]').val(wordpressDomain.domainId);
|
56 |
-
$form.find('[name="client_id"]').val(wordpressDomain.clientId);
|
57 |
-
}
|
58 |
-
|
59 |
-
var domainNames = $.map(data.domains, function(domain) {
|
60 |
-
return domain.name;
|
61 |
-
});
|
62 |
-
|
63 |
-
$form.find('[name="user_id"]').val(data.userId);
|
64 |
-
$form.find('[name="domains"]').val(domainNames.join(','));
|
65 |
-
}
|
66 |
-
|
67 |
-
$form.submit();
|
68 |
-
}
|
69 |
-
|
70 |
-
function failureUI($form, $submitButton, originalText) {
|
71 |
-
var message = $('<div class="error">').text('Sorry, something went wrong when Authenticating with Unbounce. Please try again.');
|
72 |
-
$form.append(message);
|
73 |
-
$submitButton.attr('disabled', false).val(originalText);
|
74 |
-
}
|
75 |
-
|
76 |
-
function loadingUI($submitButton, text) {
|
77 |
-
$submitButton.attr('disabled', true).val(text);
|
78 |
-
}
|
79 |
-
|
80 |
-
$(document).ready(function(){
|
81 |
-
var $submitButton = $('#set-unbounce-domains');
|
82 |
-
|
83 |
-
if($submitButton[0]) {
|
84 |
-
var $form = $($submitButton[0].form),
|
85 |
-
originalText = $submitButton.val(),
|
86 |
-
loadingText = 'Authorizing...',
|
87 |
-
apiUrl = $submitButton.attr('data-api-url'),
|
88 |
-
redirectUri = $submitButton.attr('data-redirect-uri'),
|
89 |
-
apiClientId = $submitButton.attr('data-api-client-id'),
|
90 |
-
wordpressDomainName = $submitButton.attr('data-wordpress-domain-name'),
|
91 |
-
getTokenUrl = apiUrl + '/oauth/authorize?response_type=token&client_id=' + apiClientId + '&redirect_uri=' + redirectUri,
|
92 |
-
getUserUrl = apiUrl + '/users/self?limit=1000',
|
93 |
-
getSubAccountsUrl = apiUrl + '/accounts/{accountId}/sub_accounts',
|
94 |
-
getSubAccountUrl = apiUrl + '/sub_accounts/{subAccountId}',
|
95 |
-
getDomainsUrl = apiUrl + '/sub_accounts/{subAccountId}/domains?limit=1000',
|
96 |
-
setDomainsUrl = $form.attr('action'),
|
97 |
-
matches = location.hash.match(/access_token=([a-z0-9]+)/),
|
98 |
-
accessToken = matches && matches[1];
|
99 |
-
|
100 |
-
$submitButton.click(function(e) {
|
101 |
-
e.preventDefault();
|
102 |
-
|
103 |
-
document.location = getTokenUrl;
|
104 |
-
|
105 |
-
return false;
|
106 |
-
});
|
107 |
-
|
108 |
-
if(accessToken) {
|
109 |
-
loadingUI($submitButton, loadingText);
|
110 |
-
|
111 |
-
var userObservable = apiGet(getUserUrl, accessToken).publish(),
|
112 |
-
domainsObservable = userObservable
|
113 |
-
.flatMap(function(user) {
|
114 |
-
return getUserSubAccounts(user, accessToken);
|
115 |
-
}).flatMap(function (subAccount) {
|
116 |
-
return apiGet(getDomainsUrl.replace('{subAccountId}', subAccount.id), accessToken)
|
117 |
-
.flatMap(function(response) {
|
118 |
-
return getDomainData(subAccount, response.domains);
|
119 |
-
});
|
120 |
-
}).toArray().publish(),
|
121 |
-
userDomainsObservable = Rx.Observable.zip(
|
122 |
-
userObservable,
|
123 |
-
domainsObservable,
|
124 |
-
function(user, domains) {
|
125 |
-
return {userId: user.id, domains: domains};
|
126 |
-
}).publish(),
|
127 |
-
subscription = userDomainsObservable.subscribe(
|
128 |
-
function (domains) {
|
129 |
-
postDomainsToWordpress($form, domains, wordpressDomainName);
|
130 |
-
},
|
131 |
-
function (error) {
|
132 |
-
failureUI($form, $submitButton, originalText);
|
133 |
-
console.log('[ub-wordpress]', error);
|
134 |
-
},
|
135 |
-
function () {
|
136 |
-
// toArray will ensure that onNext is called only once. We'll consider that 'completed'
|
137 |
-
// as we'll also have access to the list of domains
|
138 |
-
});
|
139 |
-
|
140 |
-
userDomainsObservable.connect();
|
141 |
-
domainsObservable.connect();
|
142 |
-
userObservable.connect();
|
143 |
-
}
|
144 |
-
}
|
145 |
-
});
|
146 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/js/unbounce-diagnostics.js
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
(function($) {
|
2 |
-
$(document).ready(function(){
|
3 |
-
function updateResultMessage(messageText, type) {
|
4 |
-
var message = $('<p>')
|
5 |
-
.text(messageText),
|
6 |
-
wrapper = $('<div>')
|
7 |
-
.addClass(type)
|
8 |
-
.html(message);
|
9 |
-
$("#ub-diagnostics-copy-result").html(wrapper);
|
10 |
-
}
|
11 |
-
|
12 |
-
var clipboard = new Clipboard('#ub-diagnostics-copy');
|
13 |
-
|
14 |
-
clipboard.on('success', function(e) {
|
15 |
-
updateResultMessage('Copied to clipboard.', 'updated');
|
16 |
-
});
|
17 |
-
|
18 |
-
clipboard.on('error', function(e) {
|
19 |
-
updateResultMessage('Press Ctrl-C/Cmd-C to copy to your clipboard.', 'update-nag');
|
20 |
-
});
|
21 |
-
});
|
22 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/js/unbounce-page.js
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
// Unbounce-Page.php JS Functions
|
2 |
-
|
3 |
-
function swap_primary_buttons(current_primary, current_secondary) {
|
4 |
-
var $ = jQuery;
|
5 |
-
$('#' + current_primary).removeClass('button-primary');
|
6 |
-
$('#' + current_secondary).addClass('button-primary');
|
7 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/readme.txt
DELETED
@@ -1,222 +0,0 @@
|
|
1 |
-
=== Plugin Name ===
|
2 |
-
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: 5.0
|
6 |
-
Stable tag: 1.0.36
|
7 |
-
License: GPLv2 or later
|
8 |
-
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
-
|
10 |
-
Unbounce is the most powerful standalone landing page builder available.
|
11 |
-
|
12 |
-
== Description ==
|
13 |
-
|
14 |
-
With Unbounce’s landing page plugin for WordPress, marketers can create fully customized landing pages for
|
15 |
-
their campaigns and publish them to their existing WordPress sites.
|
16 |
-
|
17 |
-
To publish landing pages on your WordPress website:
|
18 |
-
|
19 |
-
1. Build your landing page in Unbounce, the world’s most powerful landing page builder
|
20 |
-
1. Publish your page to WordPress using this very plugin
|
21 |
-
1. Manage all your WordPress landing pages through the plugin’s interface
|
22 |
-
1. Edit and update all your landing pages from Unbounce’s page builder. They’ll automatically get updated on your WordPress site
|
23 |
-
|
24 |
-
Unbounce allows you to customize your landing pages to match your brand perfectly. The WYSIWYG builder allows
|
25 |
-
for quick and easy page editing. With the Unbounce WordPress Landing Page Plugin, you can launch your landing
|
26 |
-
page on your own domain without ever talking to I.T. Try it for a month for free!
|
27 |
-
|
28 |
-
More than 10,000 digital marketers use Unbounce. Some of the features they love the most include:
|
29 |
-
|
30 |
-
- Publish pages to your WordPress domain
|
31 |
-
- A team of Customer Success coaches that are easy to reach when you need help
|
32 |
-
- 80+ free templates (plus more on ThemeForest)
|
33 |
-
- Complete customizability of the desktop and mobile layouts
|
34 |
-
- Built in A/B testing features
|
35 |
-
- Integrations with the tools marketers use - MailChimp, SalesForce, Hubspot & more
|
36 |
-
- Easy Google Analytics tagging & event tracking
|
37 |
-
- Plus much more
|
38 |
-
|
39 |
-
== Installation ==
|
40 |
-
|
41 |
-
Our plugin requires the following setup for the WordPress Server:
|
42 |
-
- cURL 7.34.0+
|
43 |
-
- OpenSSL 1.0.1+
|
44 |
-
|
45 |
-
We recommend at least PHP 5.6.
|
46 |
-
|
47 |
-
1. Create a Wordpress domain in [Unbounce](http://unbounce.com/ "The Mobile Responsive Landing Page Builder for Marketers")
|
48 |
-
1. Install this plugin through the WordPress store
|
49 |
-
1. Activate this plugin after installation completes
|
50 |
-
|
51 |
-
OR
|
52 |
-
|
53 |
-
1. Create a Wordpress domain in [Unbounce](http://unbounce.com/ "The Mobile Responsive Landing Page Builder for Marketers")
|
54 |
-
1. Upload the zip file via the 'Plugins' menu in WordPress
|
55 |
-
1. Activate this plugin after installation completes
|
56 |
-
|
57 |
-
== Frequently Asked Questions ==
|
58 |
-
|
59 |
-
= Do I need an Unbounce account? =
|
60 |
-
|
61 |
-
Yes. You need to sign up for Unbounce in order to publish pages. To publish Unbounce pages to your
|
62 |
-
Unbounce site, you will need to add a Wordpress domain in Unbounce. For example, if you Wordpress
|
63 |
-
site is available at www.example.com, you will need to add www.example.com and publish pages in
|
64 |
-
Unbounce to that domain for them to be visible on your Wordpress site.
|
65 |
-
|
66 |
-
= Do I need to log in to Unbounce? =
|
67 |
-
|
68 |
-
Yes, after installing and activating this plugin, you will need to go "Unbounce Pages" in the admin
|
69 |
-
section and click "Authorize With Unbounce." You will then be sent to Unbounce where you need to
|
70 |
-
log in. You must log in as an Unbounce user that has access to the Client that has the current
|
71 |
-
domain in Unbounce, or you will need to authorize again as an authorized user before the plugin
|
72 |
-
will function.
|
73 |
-
|
74 |
-
= Does this plugin fetch any data from Unbounce? =
|
75 |
-
|
76 |
-
Yes, this plugin will pull information from Unbounce's servers regarding which pages you have
|
77 |
-
published from Unbounce to your Wordpress site. Any pages that you have published to your Wordpress
|
78 |
-
site in Unbounce will be fetched from Unbounce's servers and displayed on your Wordpress site.
|
79 |
-
If you have a page published in Unbounce and are using the same URL for a Wordpress Page, the
|
80 |
-
Unbounce page will be displayed, not the Wordpress page.
|
81 |
-
|
82 |
-
= Does this plugin send any data to Unbounce? =
|
83 |
-
|
84 |
-
No, not by default. This plugin as an optional "debug" mode which will send diagnostic information to
|
85 |
-
Unbounce when switched on. This feature is disabled when you install the plugin. An Unbounce Customer
|
86 |
-
Success Coach may request that you turn the debug feature on if you are experiencing issues with the plugin
|
87 |
-
to help track down the issue.
|
88 |
-
|
89 |
-
= Unbounce Pages are loading, but my conversions are not being tracked =
|
90 |
-
|
91 |
-
This is typically caused by caching responses which affects how users are assigned unique identifiers.
|
92 |
-
You should add a rule to your cache to avoid caching Unbounce Pages which have the HTTP header "X-Unbounce-Plugin".
|
93 |
-
|
94 |
-
== Screenshots ==
|
95 |
-
|
96 |
-
1. Build your landing page in Unbounce, the world’s most powerful landing page builder.
|
97 |
-
2. Publish your page to WordPress using this very plugin.
|
98 |
-
3. View all of your WordPress landing pages in the plugin’s interface and easily manage them in Unbounce.
|
99 |
-
4. Edit and update all your landing pages from Unbounce’s page builder. They’ll automatically get updated on your WordPress site.
|
100 |
-
|
101 |
-
== Changelog ==
|
102 |
-
|
103 |
-
= 1.0.36 =
|
104 |
-
* Improved testing instrumentation
|
105 |
-
|
106 |
-
= 1.0.35 =
|
107 |
-
* Update plugin requirements
|
108 |
-
|
109 |
-
= 1.0.34 =
|
110 |
-
* New diagnostics entry for SSL's SNI Support on WordPress installations
|
111 |
-
* Better
|
112 |
-
|
113 |
-
= 1.0.33 =
|
114 |
-
* Improved support for PHP 7.1
|
115 |
-
|
116 |
-
= 1.0.32 =
|
117 |
-
* Fix support for PHP 5.3
|
118 |
-
|
119 |
-
= 1.0.31 =
|
120 |
-
* Un-released 1.0.30 (same as 1.0.29)
|
121 |
-
|
122 |
-
= 1.0.30 =
|
123 |
-
* Minor bug fix
|
124 |
-
|
125 |
-
= 1.0.29 =
|
126 |
-
* Minor bug fix
|
127 |
-
|
128 |
-
= 1.0.28 =
|
129 |
-
* Disables the unbounce plugin when editing drafts as a logged in user.
|
130 |
-
|
131 |
-
= 1.0.27 =
|
132 |
-
* Add a custom header "X-Unbounce-Plugin: 1" to identify all pages served by the plugin to support cache invalidation.
|
133 |
-
|
134 |
-
= 1.0.26 =
|
135 |
-
* Minor fix
|
136 |
-
|
137 |
-
= 1.0.25 =
|
138 |
-
* Minor bug fix
|
139 |
-
|
140 |
-
= 1.0.24 =
|
141 |
-
* Improves support for installations using SSL
|
142 |
-
* is_ssl() has higher precedence for determing protocol of content to serve
|
143 |
-
|
144 |
-
= 1.0.23 =
|
145 |
-
* Add optional support for web servers with a load balancer or proxy that is on a different network
|
146 |
-
* This feature can be enabled with the ub-allow-public-address-x-forwarded-for option
|
147 |
-
* This feature may decrease the effectiveness of spam detection in some cases, and should only be enabled if absolutely necessary
|
148 |
-
|
149 |
-
= 1.0.22 =
|
150 |
-
* Add global UB_ENABLE_LOCAL_LOGGING to enable/disable debug logging of Unbounce Plugin
|
151 |
-
|
152 |
-
= 1.0.21 =
|
153 |
-
* Fixes some multi-site compatibility issues
|
154 |
-
|
155 |
-
= 1.0.20 =
|
156 |
-
* Revert changes in 1.0.19
|
157 |
-
|
158 |
-
= 1.0.19 =
|
159 |
-
* Minor bug fix
|
160 |
-
|
161 |
-
= 1.0.18 =
|
162 |
-
* Minor bug fix
|
163 |
-
|
164 |
-
= 1.0.17 =
|
165 |
-
* Fixes some multi-site compatibility issues
|
166 |
-
|
167 |
-
= 1.0.16 =
|
168 |
-
* Update compatibility information and changelog
|
169 |
-
|
170 |
-
= 1.0.15 =
|
171 |
-
* Added support for rounded corners, gradients, and transparency on IE 8
|
172 |
-
|
173 |
-
= 1.0.14 =
|
174 |
-
* Minor improvements
|
175 |
-
* Added support for viewing page variants directly (i.e. a.html, b.html, etc)
|
176 |
-
|
177 |
-
= 1.0.13 =
|
178 |
-
* Minor bug fix
|
179 |
-
|
180 |
-
= 1.0.11 =
|
181 |
-
* Add support for earlier versions of curl on WP installs (<7.30)
|
182 |
-
* Increased timeout for proxying pages
|
183 |
-
* Updated plugin description and diagnostics page
|
184 |
-
|
185 |
-
= 1.0.10 =
|
186 |
-
* Minor bug fix
|
187 |
-
|
188 |
-
= 1.0.9 =
|
189 |
-
* Minor bug fixes
|
190 |
-
|
191 |
-
= 1.0.6 =
|
192 |
-
* Fixed a bug with how checkbox values were being sent
|
193 |
-
|
194 |
-
= 1.0.4 =
|
195 |
-
* Add support for POSTS to landing page URLS
|
196 |
-
* Minor bug fixes
|
197 |
-
|
198 |
-
= 1.0.3 =
|
199 |
-
* Added a diagnostics page
|
200 |
-
|
201 |
-
= 1.0.2 =
|
202 |
-
* Fix bug with Unbounce accounts that have more than 50 domains
|
203 |
-
|
204 |
-
= 1.0.1 =
|
205 |
-
* Updated plugin description readme
|
206 |
-
|
207 |
-
= 1.0.0 =
|
208 |
-
* Bug fixes for authorization and caching issues.
|
209 |
-
* No longer in beta!
|
210 |
-
|
211 |
-
= 0.1.19 =
|
212 |
-
* This release introduces the requirement to authorize your installation with Unbounce. After installing
|
213 |
-
you will need to go "Unbounce Pages" in the admin section and click "Authorize With Unbounce." You
|
214 |
-
will then be sent to Unbounce where you need to log in. You must log in as an Unbounce user that
|
215 |
-
has access to the Client that has the current domain in Unbounce, or you will need to authorize
|
216 |
-
again as an authorized user before the plugin will function.
|
217 |
-
* Fixes compatibility issues with caching plugins such as ZenCache, W3 Total Cache, and WP Super Cache
|
218 |
-
|
219 |
-
= 0.1.1 =
|
220 |
-
* Initial release
|
221 |
-
|
222 |
-
== Upgrade Notice ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/templates/authorize_button.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<form method="post" action="<?php echo admin_url('admin-post.php?action=set_unbounce_domains') ?>">
|
2 |
-
<input type="hidden" name="domains" />
|
3 |
-
<input type="hidden" name="user_id" />
|
4 |
-
<input type="hidden" name="domain_id" />
|
5 |
-
<input type="hidden" name="client_id" />
|
6 |
-
<?php if (isset($outer_text)) { ?>
|
7 |
-
<?php echo $outer_text; ?>
|
8 |
-
<?php } ?>
|
9 |
-
<?php $style = isset($outer_text) ? 'vertical-align: baseline' : ''; ?>
|
10 |
-
<?php
|
11 |
-
|
12 |
-
echo get_submit_button(
|
13 |
-
$text,
|
14 |
-
$is_primary ? 'primary' : 'secondary',
|
15 |
-
'set-unbounce-domains',
|
16 |
-
$wrap_in_p,
|
17 |
-
array(
|
18 |
-
'data-set-domains-url' => admin_url('admin-post.php?action=set_unbounce_domains'),
|
19 |
-
'data-redirect-uri' => admin_url('admin.php?page=unbounce-pages'),
|
20 |
-
'data-api-url' => UBConfig::api_url(),
|
21 |
-
'data-api-client-id' => UBConfig::api_client_id(),
|
22 |
-
'data-wordpress-domain-name' => $domain,
|
23 |
-
'style' => $style,
|
24 |
-
)
|
25 |
-
); ?>
|
26 |
-
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/templates/diagnostics.php
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$diagnostic_descriptions = array(
|
4 |
-
'Curl Support' => 'Curl is not currently enabled, please contact your hosting provider
|
5 |
-
or IT professional to enable Curl support.',
|
6 |
-
'Permalink Structure' => "By default WordPress uses web URLs which have question marks
|
7 |
-
and lots of numbers in them; however, this default structure
|
8 |
-
will not work with the Unbounce Plugin. Please update your
|
9 |
-
<a href=\"{$permalink_url}\">WordPress Permalink
|
10 |
-
Structure</a> and change to anything other than the default
|
11 |
-
WordPress setting.",
|
12 |
-
'Domain is Authorized' => "Your Domain ({$domain}) needs to be added to your
|
13 |
-
Unbounce account, please return to the main plugin page, select
|
14 |
-
\"Add My Domain In Unbounce\". After adding your domain in
|
15 |
-
Unbounce, return to the main plugin page and select the \"Update
|
16 |
-
WordPress Enabled Domains\".",
|
17 |
-
'Can Fetch Page Listing' => 'We are unable to fetch the page listing from Unbounce, please
|
18 |
-
contact your hosting provider or IT professional to ensure Curl
|
19 |
-
Supported is installed and enabled.',
|
20 |
-
'Supported PHP Version' => 'The Unbounce Pages plugin is supported when using PHP version
|
21 |
-
5.3 or higher, please contact your hosting provider or IT
|
22 |
-
professional and update to a supported version.',
|
23 |
-
'Supported Wordpress Version' => 'The Unbounce Pages plugin is supported on WordPress versions 4.0
|
24 |
-
and higher, please contact your hosting provider or IT
|
25 |
-
professional and update to a supported version.',
|
26 |
-
);
|
27 |
-
|
28 |
-
?>
|
29 |
-
<div class="ub-plugin-wrapper">
|
30 |
-
<img class="ub-logo" src="<?php echo $img_url; ?>" />
|
31 |
-
<h1 class="ub-unbounce-pages-heading">Unbounce Pages Diagnostics</h1>
|
32 |
-
<a href="<?php echo admin_url('admin.php?page=unbounce-pages'); ?>">Main Plugin Page</a>
|
33 |
-
<br/>
|
34 |
-
<ul class="ub-diagnostics-checks">
|
35 |
-
<?php foreach ($checks as $check => $success) : ?>
|
36 |
-
<?php $css_class = ($success ? 'dashicons-yes' : 'dashicons-no-alt'); ?>
|
37 |
-
<li>
|
38 |
-
<span class='dashicons <?php echo $css_class; ?>'></span>
|
39 |
-
<?php
|
40 |
-
echo $check;
|
41 |
-
|
42 |
-
if (!$success) {
|
43 |
-
foreach ($diagnostic_descriptions as $title => $description) {
|
44 |
-
if ($title == $check) {
|
45 |
-
echo '<p class="ub-diagnostics-check-description">' . $description . '</p>';
|
46 |
-
}
|
47 |
-
}
|
48 |
-
}
|
49 |
-
?>
|
50 |
-
</li>
|
51 |
-
<?php endforeach; ?>
|
52 |
-
</ul>
|
53 |
-
|
54 |
-
<h2>Details</h2>
|
55 |
-
<p>
|
56 |
-
If you are experiencing problems with the Unbounce Pages plugin, or if the problem
|
57 |
-
continues to persist after all checks have passed, please email the following details
|
58 |
-
to <a href="mailto:support@unbounce.com">support@unbounce.com</a>. If possible,
|
59 |
-
please also provide details on your hosting provider.
|
60 |
-
</p>
|
61 |
-
<textarea id="ub-diagnostics-text" rows="10" cols="100">
|
62 |
-
<?php
|
63 |
-
|
64 |
-
foreach ($details as $detail_name => $detail) {
|
65 |
-
echo "[${detail_name}] ${detail}\n";
|
66 |
-
}
|
67 |
-
|
68 |
-
?>
|
69 |
-
</textarea>
|
70 |
-
<div id="ub-diagnostics-copy-result"></div>
|
71 |
-
<?php
|
72 |
-
|
73 |
-
echo get_submit_button(
|
74 |
-
'Copy to Clipboard',
|
75 |
-
'primary',
|
76 |
-
'ub-diagnostics-copy',
|
77 |
-
false,
|
78 |
-
array('data-clipboard-target' => '#ub-diagnostics-text')
|
79 |
-
);
|
80 |
-
|
81 |
-
?>
|
82 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/templates/main.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
echo '<div class="ub-plugin-wrapper>';
|
4 |
-
|
5 |
-
$is_authorized = UBConfig::is_authorized_domain($domain);
|
6 |
-
|
7 |
-
echo UBTemplate::render(
|
8 |
-
'main_header',
|
9 |
-
array(
|
10 |
-
'img_url' => plugins_url('img/unbounce-logo-blue.png', __FILE__),
|
11 |
-
'is_authorized' => $is_authorized,
|
12 |
-
'authorization' => UBUtil::get_flash('authorization'),
|
13 |
-
'show_warning' => UBDiagnostics::should_show_warning($domain, $domain_info)
|
14 |
-
)
|
15 |
-
);
|
16 |
-
|
17 |
-
if ($is_authorized) {
|
18 |
-
$proxyable_url_set = UBUtil::array_fetch($domain_info, 'proxyable_url_set', array());
|
19 |
-
$proxyable_url_set_fetched_at = UBUtil::array_fetch($domain_info, 'proxyable_url_set_fetched_at');
|
20 |
-
$last_refreshed = UBUtil::time_ago($proxyable_url_set_fetched_at);
|
21 |
-
echo UBTemplate::render(
|
22 |
-
'main_authorized',
|
23 |
-
array(
|
24 |
-
'domain' => $domain,
|
25 |
-
'proxyable_url_set' => $proxyable_url_set,
|
26 |
-
'last_refreshed' => $last_refreshed,
|
27 |
-
)
|
28 |
-
);
|
29 |
-
|
30 |
-
add_action('in_admin_footer', function () {
|
31 |
-
echo UBTemplate::render('main_authorized_footer');
|
32 |
-
});
|
33 |
-
} else {
|
34 |
-
if (UBConfig::has_authorized()) {
|
35 |
-
// They've attempted to authorize, but this domain isn't in the list
|
36 |
-
echo UBTemplate::render('main_failed_authorization', array('domain' => $domain));
|
37 |
-
} else {
|
38 |
-
echo UBTemplate::render('main_unauthorized', array('domain' => $domain));
|
39 |
-
}
|
40 |
-
|
41 |
-
add_action('in_admin_footer', function () {
|
42 |
-
echo UBTemplate::render('main_unauthorized_footer');
|
43 |
-
});
|
44 |
-
}
|
45 |
-
|
46 |
-
echo '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/templates/main_authorized.php
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<h2 class="ub-published-pages-heading">Published Pages</h2>
|
2 |
-
|
3 |
-
<form method="get" action="https://app.unbounce.com" target="_blank">
|
4 |
-
<?php
|
5 |
-
|
6 |
-
echo get_submit_button(
|
7 |
-
'Manage Pages In Unbounce',
|
8 |
-
'primary',
|
9 |
-
'flush-unbounce-pages',
|
10 |
-
false,
|
11 |
-
array('style' => 'margin-top: 10px')
|
12 |
-
); ?>
|
13 |
-
</form>
|
14 |
-
|
15 |
-
<div class="ub-page-list">
|
16 |
-
<?php $table = new UBPageTable($proxyable_url_set); ?>
|
17 |
-
<?php echo $table->display(); ?>
|
18 |
-
|
19 |
-
<p>Last refreshed <?php echo $last_refreshed; ?>.</p>
|
20 |
-
|
21 |
-
<?php
|
22 |
-
|
23 |
-
echo UBTemplate::render(
|
24 |
-
'authorize_button',
|
25 |
-
array(
|
26 |
-
'text' => 'Update WordPress Enabled Domains',
|
27 |
-
'domain' => $domain,
|
28 |
-
'wrap_in_p' => false,
|
29 |
-
'is_primary' => false,
|
30 |
-
)
|
31 |
-
); ?>
|
32 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/templates/main_authorized_footer.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$flush_pages_url = admin_url('admin-post.php');
|
4 |
-
$diagnostics_url = admin_url('admin.php?page=unbounce-pages-diagnostics');
|
5 |
-
$refresh_button = get_submit_button('refreshing the Published Pages list', 'secondary', 'flush-unbounce-pages', false);
|
6 |
-
?>
|
7 |
-
|
8 |
-
<h2 class="ub-need-help-header">Need Help?</h2>
|
9 |
-
|
10 |
-
<form method="post" action="<?php $flush_pages_url ?>">
|
11 |
-
<input type="hidden" name="action" value="flush_unbounce_pages" />
|
12 |
-
<p>
|
13 |
-
If your pages are not showing up, first try <?php echo $refresh_button; ?>.
|
14 |
-
If they are still not appearing, double check that your Unbounce pages are using a Wordpress domain.
|
15 |
-
</p>
|
16 |
-
</form>
|
17 |
-
<a href="http://documentation.unbounce.com/hc/en-us/articles/205069824-Integrating-with-WordPress" target="_blank">
|
18 |
-
Check out our knowledge base.
|
19 |
-
</a>
|
20 |
-
<br/>
|
21 |
-
<a class="ub-diagnostics-link" href="<?php echo $diagnostics_url ?>">
|
22 |
-
Click here for troubleshooting and plugin diagnostics
|
23 |
-
</a>
|
24 |
-
<p class="ub-version">Unbounce Version 1.0.36</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/templates/main_failed_authorization.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<div class="error">
|
2 |
-
<p>It looks like <strong><?php echo $domain; ?></strong> has not been added as a WordPress domain
|
3 |
-
in your Unbounce account.</p>
|
4 |
-
</div>
|
5 |
-
|
6 |
-
<form method="get" action="https://app.unbounce.com/add_wordpress_domain" target="_blank">
|
7 |
-
<input type="hidden" name="domain_name" value="<?php echo $domain; ?>" />
|
8 |
-
<?php
|
9 |
-
|
10 |
-
get_submit_Button(
|
11 |
-
'Add My Domain in Unbounce',
|
12 |
-
'primary',
|
13 |
-
null,
|
14 |
-
true,
|
15 |
-
array(
|
16 |
-
'id' => 'add-domain',
|
17 |
-
'onclick' => 'swap_primary_buttons("add-domain", "set-unbounce-domains");',
|
18 |
-
)
|
19 |
-
); ?>
|
20 |
-
</form>
|
21 |
-
|
22 |
-
<?php
|
23 |
-
|
24 |
-
echo UBTemplate::render(
|
25 |
-
'authorize_button',
|
26 |
-
array(
|
27 |
-
'text' => 'Update WordPress Enabled Domains',
|
28 |
-
'domain' => $domain,
|
29 |
-
'wrap_in_p' => false,
|
30 |
-
'is_primary' => false,
|
31 |
-
'outer_text' => 'After adding your domain in Unbounce, come back here and ',
|
32 |
-
)
|
33 |
-
); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/templates/main_header.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<img class="ub-logo src=<?php echo $img_url; ?>" />
|
2 |
-
<h1 class="ub-unbounce-pages-heading">Unbounce Pages</h1>
|
3 |
-
|
4 |
-
<?php if ($authorization === 'success' && $is_authorized) : ?>
|
5 |
-
<div class="updated"><p>Authorized with Unbounce and WordPress domain successfully enabled.</p></div>
|
6 |
-
<?php elseif ($authorization === 'success') : ?>
|
7 |
-
<div class="updated"><p>Successfully authorized with Unbounce.</p></div>
|
8 |
-
<?php elseif ($authorization === 'failure') : ?>
|
9 |
-
<div class="error"><p>Sorry, there was an error authorizing with Unbounce. Please try again.</p></div>
|
10 |
-
<?php endif; ?>
|
11 |
-
|
12 |
-
<?php // Only show error if they've never authorized, otherwise it will be shown right away ?>
|
13 |
-
<?php if ($show_warning) : ?>
|
14 |
-
<div class="error">
|
15 |
-
<p>
|
16 |
-
We have identified a configuration issue with this Unbounce Pages Plugin and your WordPress
|
17 |
-
configuration, please <a href="<?php echo admin_url('admin.php?page=unbounce-pages-diagnostics'); ?>">click here
|
18 |
-
</a> for more details.
|
19 |
-
</p>
|
20 |
-
</div>
|
21 |
-
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/templates/main_unauthorized.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<div class="ub-authorize-message">
|
2 |
-
Before you can publish your pages to WordPress you will have to authorize your Unbounce account.
|
3 |
-
</div>
|
4 |
-
|
5 |
-
<?php
|
6 |
-
|
7 |
-
echo UBTemplate::render(
|
8 |
-
'authorize_button',
|
9 |
-
array(
|
10 |
-
'text' => 'Authorize With Unbounce',
|
11 |
-
'domain' => $domain,
|
12 |
-
'wrap_in_p' => true,
|
13 |
-
'is_primary' => true,
|
14 |
-
)
|
15 |
-
) ?>
|
16 |
-
|
17 |
-
<form method="get" action="http://unbounce.com/landing-pages-for-wordpress/" target='_blank'>
|
18 |
-
<input type="hidden" name="utm_medium" value="product" />
|
19 |
-
<input type="hidden" name="utm_source" value="wordpress-plugin" />
|
20 |
-
<input type="hidden" name="utm_campaign" value="product-launch-wordpress" />
|
21 |
-
<p>
|
22 |
-
Not an Unbounce customer?
|
23 |
-
<?php echo get_submit_Button('Try Unbounce For Free', 'secondary', null, false); ?>
|
24 |
-
</p>
|
25 |
-
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trunk/templates/main_unauthorized_footer.php
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
<a href="http://documentation.unbounce.com/hc/en-us/articles/205069824-Integrating-with-WordPress"
|
2 |
-
target="_blank">Check out our knowledge base.</a>
|
3 |
-
<br/>
|
4 |
-
<a class="ub-diagnostics-link" href="<?php echo admin_url('admin.php?page=unbounce-pages-diagnostics'); ?>">
|
5 |
-
Click here for troubleshooting and plugin diagnostics
|
6 |
-
</a>
|
7 |
-
<p class="ub-version">Unbounce Version 1.0.36</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|