Unbounce Landing Pages - Version 1.0.9

Version Description

Download this release

Release Info

Developer unbouncewordpress
Plugin Icon Unbounce Landing Pages
Version 1.0.9
Comparing to
See all releases

Code changes from version 1.0.8 to 1.0.9

UBConfig.php CHANGED
@@ -4,8 +4,8 @@ class UBConfig {
4
 
5
  const UB_PLUGIN_NAME = 'ub-wordpress';
6
  const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
7
- const UB_USER_AGENT = 'Unbounce WP Plugin 1.0.8';
8
- const UB_VERSION = '1.0.8';
9
 
10
  # Option keys
11
  const UB_ROUTES_CACHE_KEY = 'ub-route-cache';
@@ -257,7 +257,12 @@ class UBConfig {
257
  return array(true, $urls);
258
  }
259
  else {
260
- $errors = libxml_get_errors();
 
 
 
 
 
261
  libxml_use_internal_errors($use_internal_errors);
262
  return array(false, $errors);
263
  }
4
 
5
  const UB_PLUGIN_NAME = 'ub-wordpress';
6
  const UB_CACHE_TIMEOUT_ENV_KEY = 'UB_WP_ROUTES_CACHE_EXP';
7
+ const UB_USER_AGENT = 'Unbounce WP Plugin 1.0.9';
8
+ const UB_VERSION = '1.0.9';
9
 
10
  # Option keys
11
  const UB_ROUTES_CACHE_KEY = 'ub-route-cache';
257
  return array(true, $urls);
258
  }
259
  else {
260
+ # libXMLError has no default tostring, use print_r to get a string representation of it
261
+ $errors = array_map(function($error) {
262
+ return print_r($error, true);
263
+ }, libxml_get_errors());
264
+ # Return what we tried to parse for debugging
265
+ $errors[] = "XML content: ${string}";
266
  libxml_use_internal_errors($use_internal_errors);
267
  return array(false, $errors);
268
  }
UBDiagnostics.php CHANGED
@@ -28,7 +28,7 @@ class UBDiagnostics {
28
  return array(
29
  'PHP Version' => phpversion(),
30
  'WordPress Version' => UBDiagnostics::wordpress_version(),
31
- 'Unbounce Plugin Version' => "1.0.8",
32
  'Permalink Structure' => get_option('permalink_structure', ''),
33
  'Domain' => $domain,
34
  'Domain Authorized' => print_r(UBConfig::is_authorized_domain($domain), true),
28
  return array(
29
  'PHP Version' => phpversion(),
30
  'WordPress Version' => UBDiagnostics::wordpress_version(),
31
+ 'Unbounce Plugin Version' => "1.0.9",
32
  'Permalink Structure' => get_option('permalink_structure', ''),
33
  'Domain' => $domain,
34
  'Domain Authorized' => print_r(UBConfig::is_authorized_domain($domain), true),
UBTemplate.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class UBTemplate {
4
+
5
+ /*
6
+ * Renders a PHP template with local variables.
7
+ *
8
+ * `$template` Path to a PHP template
9
+ * `$vars` An array of local variables to render in the template
10
+ *
11
+ * For example:
12
+ *
13
+ * templates/hello.php:
14
+ * <h1>Hello, <?php $name; ?>!</h1>
15
+ *
16
+ * echo UBTemplate::render('hello', array('name' => 'World'));
17
+ *
18
+ * will output:
19
+ *
20
+ * <h1>Hello, World!</h1>
21
+ *
22
+ */
23
+
24
+ public static function render($template, $vars = array()) {
25
+ ob_start();
26
+ try {
27
+ extract($vars);
28
+ include(UBTemplate::template_path($template));
29
+ } catch(Exception $e) {
30
+ echo $e;
31
+ }
32
+ return ob_get_clean();
33
+ }
34
+
35
+ public static function template_path($template) {
36
+ return UBTemplate::join_paths(dirname(__FILE__), 'templates', $template . '.php');
37
+ }
38
+
39
+ private static function join_paths() {
40
+ return preg_replace('~[/\\\]+~', DIRECTORY_SEPARATOR, implode(DIRECTORY_SEPARATOR, func_get_args()));
41
+ }
42
+
43
+ }
44
+
45
+ ?>
Unbounce-Page.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Unbounce
4
  Plugin URI: http://unbounce.com
5
  Description: Publish Unbounce Landing Pages to your Wordpress Domain.
6
- Version: 1.0.8
7
  Author: Unbounce
8
  Author URI: http://unbounce.com
9
  License: GPLv2
@@ -18,6 +18,7 @@ require_once dirname(__FILE__) . '/UBHTTP.php';
18
  require_once dirname(__FILE__) . '/UBIcon.php';
19
  require_once dirname(__FILE__) . '/UBPageTable.php';
20
  require_once dirname(__FILE__) . '/UBEvents.php';
 
21
 
22
  register_activation_hook(__FILE__, function() {
23
  add_option(UBConfig::UB_ROUTES_CACHE_KEY, array());
@@ -165,12 +166,14 @@ add_action('init', function() {
165
  add_action('admin_init', function() {
166
  UBUtil::clear_flash();
167
 
168
- # disable incompatible scripts
169
 
170
  # WPML
171
  wp_dequeue_script('installer-admin');
172
 
173
- # enqueue our own scripts
 
 
174
  wp_enqueue_script('ub-rx',
175
  plugins_url('js/rx.lite.compat.min.js', __FILE__));
176
  wp_enqueue_script('set-unbounce-domains-js',
@@ -179,7 +182,14 @@ add_action('admin_init', function() {
179
  wp_enqueue_script('unbounce-page-js',
180
  plugins_url('js/unbounce-page.js', __FILE__),
181
  array('jquery'));
182
- # re-enable incompatible scripts
 
 
 
 
 
 
 
183
 
184
  # WPML
185
  wp_enqueue_script('installer-admin');
@@ -188,156 +198,15 @@ add_action('admin_init', function() {
188
  plugins_url('css/unbounce-pages.css', __FILE__));
189
  }, 0);
190
 
191
- function authorization_button($text, $domain, $wrap_in_p = false, $is_primary = true, $outer_text = '') {
192
- $set_domains_url = admin_url('admin-post.php?action=set_unbounce_domains');
193
- echo "<form method='post' action='$set_domains_url'>";
194
- echo "<input type='hidden' name='domains' />";
195
- echo "<input type='hidden' name='user_id' />";
196
- echo "<input type='hidden' name='domain_id' />";
197
- echo "<input type='hidden' name='client_id' />";
198
- echo $outer_text;
199
- $style = $outer_text ? 'vertical-align: baseline' : '';
200
- echo get_submit_button($text,
201
- $is_primary ? 'primary' : 'secondary',
202
- 'set-unbounce-domains',
203
- $wrap_in_p,
204
- array('data-set-domains-url' => $set_domains_url,
205
- 'data-redirect-uri' => admin_url('admin.php?page=unbounce-pages'),
206
- 'data-api-url' => UBConfig::api_url(),
207
- 'data-api-client-id' => UBConfig::api_client_id(),
208
- 'data-wordpress-domain-name' => $domain,
209
- 'style' => $style));
210
- echo '</form>';
211
- }
212
- function render_unbounce_pages($domain_info, $domain) {
213
- echo "<div class=\"ub-plugin-wrapper\">";
214
- $img_url = plugins_url('img/unbounce-logo-blue.png', __FILE__);
215
- echo "<img class=\"ub-logo\" src=\"${img_url}\" />";
216
- echo "<h1 class=\"ub-unbounce-pages-heading\">Unbounce Pages</h1>";
217
-
218
- $authorization = UBUtil::get_flash('authorization');
219
- if($authorization === 'success' && UBConfig::is_authorized_domain($domain)) {
220
- echo '<div class="updated"><p>Authorized with Unbounce and WordPress domain successfully enabled.</p></div>';
221
- } elseif($authorization === 'success') {
222
- echo '<div class="updated"><p>Successfully authorized with Unbounce.</p></div>';
223
- } elseif($authorization === 'failure') {
224
- echo '<div class="error"><p>Sorry, there was an error authorizing with Unbounce. Please try again.</p></div>';
225
- }
226
-
227
- if(UBConfig::is_authorized_domain($domain)) {
228
- $proxyable_url_set = UBUtil::array_fetch($domain_info, 'proxyable_url_set', array());
229
-
230
- echo '<h2 class="ub-published-pages-heading">Published Pages</h2>';
231
-
232
- echo '<form method="get" action="https://app.unbounce.com" target="_blank">';
233
- echo '<input type="hidden" name="action" value="flush_unbounce_pages" />';
234
- echo get_submit_button('Manage Pages In Unbounce',
235
- 'primary',
236
- 'flush-unbounce-pages',
237
- false,
238
- array('style' => 'margin-top: 10px'));
239
- echo '</form>';
240
-
241
- echo '<div class="ub-page-list">';
242
- $table = new UBPageTable($proxyable_url_set);
243
- echo $table->display();
244
-
245
- $proxyable_url_set_fetched_at = UBUtil::array_fetch($domain_info, 'proxyable_url_set_fetched_at');
246
- echo '<p>Last refreshed ' . UBUtil::time_ago($proxyable_url_set_fetched_at) . '.</p>';
247
- authorization_button('Update WordPress Enabled Domains', $domain, false, false);
248
- echo '</p>';
249
- echo '</div>';
250
-
251
- add_action('in_admin_footer', function() {
252
- echo '<h2 class="ub-need-help-header">Need Help?</h2>';
253
-
254
- $flush_pages_url = admin_url('admin-post.php');
255
- echo "<form method='get' action='$flush_pages_url'>";
256
- echo '<input type="hidden" name="action" value="flush_unbounce_pages" />';
257
- echo '<p>If your pages are not showing up, first try ';
258
- echo get_submit_button('refreshing the Published Pages list', 'secondary', 'flush-unbounce-pages', false);
259
- echo '. If they are still not appearing, double check that your Unbounce pages are using a Wordpress domain.</p>';
260
- echo '</form>';
261
- echo '<a href="http://documentation.unbounce.com/hc/en-us/articles/205069824-Integrating-with-WordPress" target="_blank">Check out our knowledge base.</a>';
262
- $diagnostics_url = admin_url('admin.php?page=unbounce-pages-diagnostics');
263
- echo "<br/><a class='ub-diagnostics-link' href='${diagnostics_url}'>Diagnostics</a>";
264
- echo '<p class="ub-version">Unbounce Version 1.0.8</p>';
265
- });
266
- } else {
267
- if (UBConfig::has_authorized()) {
268
- // They've attempted to authorize, but this domain isn't in the list
269
- echo '<div class="error"><p>It looks like <strong>'.$domain.'</strong> has not been added as a WordPress domain in your Unbounce account.</p></div>';
270
-
271
- $add_domain_url = "https://app.unbounce.com/add_wordpress_domain";
272
- echo "<form method='get' action='$add_domain_url' target='_blank'>";
273
- echo '<input type="hidden" name="domain_name" value="'.$domain.'" />';
274
- echo get_submit_Button('Add My Domain in Unbounce', 'primary', null, true,
275
- array('id' => 'add-domain',
276
- 'onclick' => 'swap_primary_buttons("add-domain", "set-unbounce-domains");'));
277
- echo '</form>';
278
-
279
- authorization_button('Update WordPress Enabled Domains', $domain, false, false, 'After adding your domain in Unbounce, come back here and ');
280
- } else {
281
- echo '<div class="ub-authorize-message">Before you can publish your pages to WordPress you will have to authorize your Unbounce account.</div>';
282
-
283
- authorization_button('Authorize With Unbounce', $domain, true);
284
-
285
- $try_unbounce_url = "http://unbounce.com/landing-pages-for-wordpress/";
286
- echo "<form method='get' action='$try_unbounce_url' target='_blank'>";
287
- echo '<input type="hidden" name="utm_medium" value="product" />';
288
- echo '<input type="hidden" name="utm_source" value="wordpress-plugin" />';
289
- echo '<input type="hidden" name="utm_campaign" value="product-launch-wordpress" />';
290
- echo '<p>Not an Unbounce customer? ';
291
- echo get_submit_Button('Try Unbounce For Free', 'secondary', null, false);
292
- echo '</p>';
293
- echo '</form>';
294
- }
295
-
296
- add_action('in_admin_footer', function() {
297
- echo '<a href="http://documentation.unbounce.com/hc/en-us/articles/205069824-Integrating-with-WordPress"';
298
- echo ' target="_blank">Check out our knowledge base.</a>';
299
- $diagnostics_url = admin_url('admin.php?page=unbounce-pages-diagnostics');
300
- echo "<br/><a class='ub-diagnostics-link' href='${diagnostics_url}'>Diagnostics</a>";
301
- echo '<p class="ub-version">Unbounce Version 1.0.8</p>';
302
- });
303
- }
304
-
305
- echo "</div>"; //close ub-plugin-wrapper
306
- }
307
-
308
- function render_unbounce_pages_diagnostics($domain, $domain_info) {
309
- echo "<div class=\"ub-plugin-wrapper\">";
310
- $img_url = plugins_url('img/unbounce-logo-blue.png', __FILE__);
311
- echo "<img class=\"ub-logo\" src=\"${img_url}\" />";
312
- echo "<h1 class=\"ub-unbounce-pages-heading\">Unbounce Pages Diagnostics</h1>";
313
-
314
- $checks = UBDiagnostics::checks($domain, $domain_info);
315
- echo '<br/>';
316
- echo '<ul class="ub-diagnostics-checks">';
317
- foreach($checks as $check => $success) {
318
- $css_class = ($success ? 'dashicons-yes' : 'dashicons-no-alt');
319
- echo "<li><span class='dashicons ${css_class}'></span>${check}</li>";
320
- }
321
- echo '</ul>';
322
-
323
- echo '<h2>Details</h2>';
324
- echo '<p>If you are experiencing problems with the Unbounce Pages plugin, please email the following details to <a href="mailto:support@unbounce.com">support@unbounce.com</a>.</p>';
325
- $details = UBDiagnostics::details($domain, $domain_info);
326
- echo '<textarea rows="10" cols="100">';
327
- foreach($details as $detail_name => $detail) {
328
- echo "[${detail_name}] ${detail}\n";
329
- }
330
- echo '</textarea>';
331
- echo "</div>"; //close ub-plugin-wrapper
332
- }
333
-
334
  add_action('admin_menu', function() {
335
  // Main admin page
336
  $print_admin_panel = function() {
337
  $domain = UBConfig::domain();
338
  $domain_info = UBConfig::read_unbounce_domain_info($domain, false);
339
 
340
- render_unbounce_pages($domain_info, $domain);
 
 
341
  };
342
 
343
  add_menu_page('Unbounce Pages',
@@ -352,7 +221,13 @@ add_action('admin_menu', function() {
352
  $domain = UBConfig::domain();
353
  $domain_info = UBConfig::read_unbounce_domain_info($domain, false);
354
 
355
- render_unbounce_pages_diagnostics($domain, $domain_info);
 
 
 
 
 
 
356
  };
357
 
358
  add_submenu_page(NULL,
3
  Plugin Name: Unbounce
4
  Plugin URI: http://unbounce.com
5
  Description: Publish Unbounce Landing Pages to your Wordpress Domain.
6
+ Version: 1.0.9
7
  Author: Unbounce
8
  Author URI: http://unbounce.com
9
  License: GPLv2
18
  require_once dirname(__FILE__) . '/UBIcon.php';
19
  require_once dirname(__FILE__) . '/UBPageTable.php';
20
  require_once dirname(__FILE__) . '/UBEvents.php';
21
+ require_once dirname(__FILE__) . '/UBTemplate.php';
22
 
23
  register_activation_hook(__FILE__, function() {
24
  add_option(UBConfig::UB_ROUTES_CACHE_KEY, array());
166
  add_action('admin_init', function() {
167
  UBUtil::clear_flash();
168
 
169
+ # Disable incompatible scripts
170
 
171
  # WPML
172
  wp_dequeue_script('installer-admin');
173
 
174
+ # Enqueue our own scripts
175
+
176
+ # Main page
177
  wp_enqueue_script('ub-rx',
178
  plugins_url('js/rx.lite.compat.min.js', __FILE__));
179
  wp_enqueue_script('set-unbounce-domains-js',
182
  wp_enqueue_script('unbounce-page-js',
183
  plugins_url('js/unbounce-page.js', __FILE__),
184
  array('jquery'));
185
+
186
+ # Diagnostics page
187
+ wp_enqueue_script('ub-clipboard-js',
188
+ plugins_url('js/clipboard.min.js', __FILE__));
189
+ wp_enqueue_script('unbounce-diagnostics-js',
190
+ plugins_url('js/unbounce-diagnostics.js', __FILE__),
191
+ array('jquery', 'ub-clipboard-js'));
192
+ # Re-enable incompatible scripts
193
 
194
  # WPML
195
  wp_enqueue_script('installer-admin');
198
  plugins_url('css/unbounce-pages.css', __FILE__));
199
  }, 0);
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  add_action('admin_menu', function() {
202
  // Main admin page
203
  $print_admin_panel = function() {
204
  $domain = UBConfig::domain();
205
  $domain_info = UBConfig::read_unbounce_domain_info($domain, false);
206
 
207
+ echo UBTemplate::render('main',
208
+ array('domain_info' => $domain_info,
209
+ 'domain' => $domain));
210
  };
211
 
212
  add_menu_page('Unbounce Pages',
221
  $domain = UBConfig::domain();
222
  $domain_info = UBConfig::read_unbounce_domain_info($domain, false);
223
 
224
+ echo UBTemplate::render('diagnostics',
225
+ array('img_url' => plugins_url('img/unbounce-logo-blue.png', __FILE__),
226
+ 'checks' => UBDiagnostics::checks($domain, $domain_info),
227
+ 'details' => UBDiagnostics::details($domain, $domain_info),
228
+ 'domain' => $domain,
229
+ 'permalink_url' => admin_url('options-permalink.php'),
230
+ 'curl_error_message' => UBUtil::array_fetch($domain_info, 'failure_message')));
231
  };
232
 
233
  add_submenu_page(NULL,
css/unbounce-pages.css CHANGED
@@ -79,3 +79,11 @@
79
  .ub-diagnostics-checks .dashicons-no-alt {
80
  color: #dd3d36;
81
  }
 
 
 
 
 
 
 
 
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
+ }
js/clipboard.min.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
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)});
js/unbounce-diagnostics.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: unbouncewordpress
3
  Tags: Unbounce, AB testing, A/B testing, split testing, CRO, conversion optimization, wordpress landing page, wp landing pages, splash pages, landing pages, squeeze pages, lead gen, lead generation, email list, responsive landing pages, templates, inbound marketing, ppc, analytics
4
  Requires at least: 4.1.5
5
  Tested up to: 4.3
6
- Stable tag: 1.0.8
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
3
  Tags: Unbounce, AB testing, A/B testing, split testing, CRO, conversion optimization, wordpress landing page, wp landing pages, splash pages, landing pages, squeeze pages, lead gen, lead generation, email list, responsive landing pages, templates, inbound marketing, ppc, analytics
4
  Requires at least: 4.1.5
5
  Tested up to: 4.3
6
+ Stable tag: 1.0.9
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
templates/authorize_button.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 echo get_submit_button($text,
11
+ $is_primary ? 'primary' : 'secondary',
12
+ 'set-unbounce-domains',
13
+ $wrap_in_p,
14
+ array('data-set-domains-url' => admin_url('admin-post.php?action=set_unbounce_domains'),
15
+ 'data-redirect-uri' => admin_url('admin.php?page=unbounce-pages'),
16
+ 'data-api-url' => UBConfig::api_url(),
17
+ 'data-api-client-id' => UBConfig::api_client_id(),
18
+ 'data-wordpress-domain-name' => $domain,
19
+ 'style' => $style)); ?>
20
+ </form>
templates/diagnostics.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="ub-plugin-wrapper">
2
+ <img class="ub-logo" src="<?php echo $img_url; ?>" />
3
+ <h1 class="ub-unbounce-pages-heading">Unbounce Pages Diagnostics</h1>
4
+ <a href="<?php echo admin_url('admin.php?page=unbounce-pages'); ?>">Main Plugin Page</a>
5
+ <br/>
6
+ <ul class="ub-diagnostics-checks">
7
+ <?php foreach($checks as $check => $success) { ?>
8
+ <?php $css_class = ($success ? 'dashicons-yes' : 'dashicons-no-alt'); ?>
9
+ <li>
10
+ <span class='dashicons <?php echo $css_class; ?>'></span>
11
+ <?php echo $check; ?>
12
+ <?php if(!$success) { ?>
13
+ <?php switch($check) {
14
+ case 'Curl Support': ?>
15
+ <p class="ub-diagnostics-check-description">
16
+ Curl is not currently enabled, please contact your hosting provider or IT professional to enable Curl support.
17
+ </p>
18
+ <?php break; ?>
19
+ <?php case 'Permalink Structure': ?>
20
+ <p class="ub-diagnostics-check-description">
21
+ By default WordPress uses web URLs which have question marks
22
+ and lots of numbers in them; however, this default structure
23
+ will not work with the Unbounce Plugin. Please update your
24
+ <a href="<?php echo $permalink_url; ?>">WordPress Permalink
25
+ Structure</a> and change to anything other than the default
26
+ WordPress setting.
27
+ </p>
28
+ <?php break; ?>
29
+ <?php case 'Domain is Authorized': ?>
30
+ <p class="ub-diagnostics-check-description">
31
+ Your Domain (<?php echo $domain ?>) needs to be added to your
32
+ Unbounce account, please return to the main plugin page, select
33
+ "Add My Domain In Unbounce". After adding your domain in
34
+ Unbounce, return to the main plugin page and select the "Update
35
+ WordPress Enabled Domains".
36
+ </p>
37
+ <?php break; ?>
38
+ <?php case 'Can Fetch Page Listing': ?>
39
+ <p class="ub-diagnostics-check-description">
40
+ We are unable to fetch the page listing from Unbounce, please
41
+ contact your hosting provider or IT professional to ensure Curl
42
+ Supported is installed and enabled.
43
+ </p>
44
+ <?php if($curl_error_message) { ?>
45
+ <p class="ub-diagnostics-check-description"><?php echo $curl_error_message; ?></p>
46
+ <?php } ?>
47
+ <?php break; ?>
48
+ <?php case 'Supported PHP Version': ?>
49
+ <p class="ub-diagnostics-check-description">
50
+ The Unbounce Pages plugin is supported when using PHP version
51
+ 5.3 or higher, please contact your hosting provider or IT
52
+ professional and update to a supported version.
53
+ </p>
54
+ <?php break; ?>
55
+ <?php case 'Supported Wordpress Version': ?>
56
+ <p class="ub-diagnostics-check-description">
57
+ The Unbounce Pages plugin is supported on WordPress versions 4.0
58
+ and higher, please contact your hosting provider or IT
59
+ professional and update to a supported version.
60
+ </p>
61
+ <?php break; ?>
62
+ <?php } ?>
63
+ <?php } ?>
64
+ </li>
65
+ <?php } ?>
66
+ </ul>
67
+
68
+ <h2>Details</h2>
69
+ <p>
70
+ If you are experiencing problems with the Unbounce Pages plugin, or if the problem
71
+ continues to persist after all checks have passed, please email the following details
72
+ to <a href="mailto:support@unbounce.com">support@unbounce.com</a>. If possible,
73
+ please also provide details on your hosting provider.
74
+ </p>
75
+ <textarea id="ub-diagnostics-text" rows="10" cols="100">
76
+ <?php foreach($details as $detail_name => $detail) { ?>
77
+ <?php echo "[${detail_name}] ${detail}\n"; ?>
78
+ <?php } ?>
79
+ </textarea>
80
+ <div id="ub-diagnostics-copy-result"></div>
81
+ <?php echo get_submit_button('Copy to Clipboard',
82
+ 'primary',
83
+ 'ub-diagnostics-copy',
84
+ false,
85
+ array('data-clipboard-target' => '#ub-diagnostics-text')); ?>
86
+ </div>
templates/main.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ echo '<div class="ub-plugin-wrapper>';
3
+
4
+ $is_authorized = UBConfig::is_authorized_domain($domain);
5
+ $diagnostics_failed = in_array(false, UBDiagnostics::checks($domain, $domain_info));
6
+
7
+ echo UBTemplate::render('main_header',
8
+ array('img_url' => plugins_url('img/unbounce-logo-blue.png', __FILE__),
9
+ 'is_authorized' => $is_authorized,
10
+ 'authorization' => UBUtil::get_flash('authorization'),
11
+ 'diagnostics_failed' => $diagnostics_failed));
12
+
13
+ if($is_authorized) {
14
+ $proxyable_url_set = UBUtil::array_fetch($domain_info, 'proxyable_url_set', array());
15
+ $proxyable_url_set_fetched_at = UBUtil::array_fetch($domain_info, 'proxyable_url_set_fetched_at');
16
+ $last_refreshed = UBUtil::time_ago($proxyable_url_set_fetched_at);
17
+ echo UBTemplate::render('main_authorized',
18
+ array('domain' => $domain,
19
+ 'proxyable_url_set' => $proxyable_url_set,
20
+ 'last_refreshed' => $last_refreshed));
21
+
22
+ add_action('in_admin_footer', function() {
23
+ echo UBTemplate::render('main_authorized_footer');
24
+ });
25
+ } else {
26
+ if (UBConfig::has_authorized()) {
27
+ // They've attempted to authorize, but this domain isn't in the list
28
+ echo UBTemplate::render('main_failed_authorization', array('domain' => $domain));
29
+ } else {
30
+ echo UBTemplate::render('main_unauthorized', array('domain' => $domain));
31
+ }
32
+
33
+ add_action('in_admin_footer', function() {
34
+ echo UBTemplate::render('main_unauthorized_footer');
35
+ });
36
+ }
37
+
38
+ echo '</div>';
39
+ ?>
templates/main_authorized.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h2 class="ub-published-pages-heading">Published Pages</h2>
2
+
3
+ <form method="get" action="https://app.unbounce.com" target="_blank">
4
+ <?php echo get_submit_button('Manage Pages In Unbounce',
5
+ 'primary',
6
+ 'flush-unbounce-pages',
7
+ false,
8
+ array('style' => 'margin-top: 10px')); ?>
9
+ </form>
10
+
11
+ <div class="ub-page-list">
12
+ <?php $table = new UBPageTable($proxyable_url_set); ?>
13
+ <?php echo $table->display(); ?>
14
+
15
+ <p>Last refreshed <?php echo $last_refreshed; ?>.</p>
16
+
17
+ <?php echo UBTemplate::render('authorize_button',
18
+ array('text' => 'Update WordPress Enabled Domains',
19
+ 'domain' => $domain,
20
+ 'wrap_in_p' => false,
21
+ 'is_primary' => false)); ?>
22
+ </div>
templates/main_authorized_footer.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $flush_pages_url = admin_url('admin-post.php');
3
+ $diagnostics_url = admin_url('admin.php?page=unbounce-pages-diagnostics');
4
+ $refresh_button = get_submit_button('refreshing the Published Pages list', 'secondary', 'flush-unbounce-pages', false);
5
+ ?>
6
+
7
+ <h2 class="ub-need-help-header">Need Help?</h2>
8
+
9
+ <form method="post" action="<?php $flush_pages_url ?>">
10
+ <input type="hidden" name="action" value="flush_unbounce_pages" />
11
+ <p>
12
+ If your pages are not showing up, first try <?php echo $refresh_button; ?>.
13
+ If they are still not appearing, double check that your Unbounce pages are using a Wordpress domain.
14
+ </p>
15
+ </form>
16
+ <a href="http://documentation.unbounce.com/hc/en-us/articles/205069824-Integrating-with-WordPress" target="_blank">
17
+ Check out our knowledge base.
18
+ </a>
19
+ <br/><a class="ub-diagnostics-link" href="<?php echo $diagnostics_url ?>">Click here for troubleshooting and plugin diagnostics</a>
20
+ <p class="ub-version">Unbounce Version 1.0.9</p>
templates/main_failed_authorization.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="error">
2
+ <p>It looks like <strong><?php echo $domain; ?></strong> has not been added as a WordPress domain in your Unbounce account.</p>
3
+ </div>
4
+
5
+ <form method="get" action="https://app.unbounce.com/add_wordpress_domain" target="_blank">
6
+ <input type="hidden" name="domain_name" value="<?php echo $domain; ?>" />
7
+ <?php get_submit_Button('Add My Domain in Unbounce', 'primary', null, true,
8
+ array('id' => 'add-domain',
9
+ 'onclick' => 'swap_primary_buttons("add-domain", "set-unbounce-domains");')); ?>
10
+ </form>
11
+
12
+ <?php echo UBTemplate::render('authorize_button',
13
+ array('text' => 'Update WordPress Enabled Domains',
14
+ 'domain' => $domain,
15
+ 'wrap_in_p' => false,
16
+ 'is_primary' => false,
17
+ 'outer_text' => 'After adding your domain in Unbounce, come back here and ')); ?>
templates/main_header.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 } ?>
11
+
12
+ <?php // Only show error if they've never authorized, otherwise it will be shown right away ?>
13
+ <?php if(UBConfig::has_authorized() && $diagnostics_failed) { ?>
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</a>
18
+ for more details.
19
+ </p>
20
+ </div>
21
+ <?php } ?>
templates/main_unauthorized.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="ub-authorize-message">Before you can publish your pages to WordPress you will have to authorize your Unbounce account.</div>
2
+
3
+ <?php echo UBTemplate::render('authorize_button',
4
+ array('text' => 'Authorize With Unbounce',
5
+ 'domain' => $domain,
6
+ 'wrap_in_p' => true,
7
+ 'is_primary' => true)) ?>
8
+
9
+ <form method="get" action="http://unbounce.com/landing-pages-for-wordpress/" target='_blank'>
10
+ <input type="hidden" name="utm_medium" value="product" />
11
+ <input type="hidden" name="utm_source" value="wordpress-plugin" />
12
+ <input type="hidden" name="utm_campaign" value="product-launch-wordpress" />
13
+ <p>
14
+ Not an Unbounce customer?
15
+ <?php echo get_submit_Button('Try Unbounce For Free', 'secondary', null, false); ?>
16
+ </p>
17
+ </form>
templates/main_unauthorized_footer.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
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.9</p>