Instapage WordPress Plugin - Version 3.2.14

Version Description

(2020-04-30) = - Bugfix: Problems with OG and meta tags when using alternative loading system (visible when sharing in social media) - Bugfix: Rare error when using a specific set of plugins on Installed Plugins listing in WordPress admin - Increased Tested up to: 5.4.0

Download this release

Release Info

Developer marek@instapage.com
Plugin Icon 128x128 Instapage WordPress Plugin
Version 3.2.14
Comparing to
See all releases

Code changes from version 3.2.13 to 3.2.14

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: marek@instapage
3
  Tags: landing page, lead generation, a/b testing, Instapage, squeeze page, conversion rate optimization, splash page, WordPress landing page, landing page optimization, lead capture page, mobile app landing page, Facebook landing page, sales page
4
  Requires at least: 3.4
5
  Requires PHP: 5.2.4
6
- Tested up to: 5.3.1
7
  Stable tag: 3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -55,6 +55,11 @@ Join 250,000+ businesses who rely on Instapage.
55
  4. Instapage app's dashboard.
56
 
57
  == Changelog ==
 
 
 
 
 
58
  = 3.2.13 (2020-01-28) =
59
  - Added Custom experiences/dynamic text replacement alternative loading system
60
 
3
  Tags: landing page, lead generation, a/b testing, Instapage, squeeze page, conversion rate optimization, splash page, WordPress landing page, landing page optimization, lead capture page, mobile app landing page, Facebook landing page, sales page
4
  Requires at least: 3.4
5
  Requires PHP: 5.2.4
6
+ Tested up to: 5.4.0
7
  Stable tag: 3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
55
  4. Instapage app's dashboard.
56
 
57
  == Changelog ==
58
+ = 3.2.14 (2020-04-30) =
59
+ - Bugfix: Problems with OG and meta tags when using alternative loading system (visible when sharing in social media)
60
+ - Bugfix: Rare error when using a specific set of plugins on Installed Plugins listing in WordPress admin
61
+ - Increased Tested up to: 5.4.0
62
+
63
  = 3.2.13 (2020-01-28) =
64
  - Added Custom experiences/dynamic text replacement alternative loading system
65
 
connectors/InstapageCmsPluginWPConnector.php CHANGED
@@ -411,13 +411,20 @@ class InstapageCmsPluginWPConnector {
411
  );
412
  }
413
 
414
- /**
415
- * WP filter. Adds a link to Instapage plugin's dashboard in WP plugin list.
416
- *
417
- * @param array $links List of links admin dashboard.
418
- */
419
  public function addActionLink($links) {
420
- $links[] = '<a href="' . admin_url('admin.php?page=instapage_dashboard') . '">' . InstapageCmsPluginConnector::lang('Instapage dashboard') . '</a>';
 
 
 
 
 
 
 
421
 
422
  return $links;
423
  }
411
  );
412
  }
413
 
414
+ /**
415
+ * WP filter. Adds a link to Instapage plugin's dashboard in WP plugin list.
416
+ *
417
+ * @param array $links List of links admin dashboard.
418
+ */
419
  public function addActionLink($links) {
420
+ // in some cases this function is called with $links containing different values than array
421
+ if (!is_array($links)) {
422
+ $links = (array) $links;
423
+ }
424
+
425
+ $links[] = '<a href="' . admin_url('admin.php?page=instapage_dashboard') . '">'
426
+ . InstapageCmsPluginConnector::lang('Instapage dashboard')
427
+ . '</a>';
428
 
429
  return $links;
430
  }
instapage.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Instapage Plugin
5
  Description: The best way for WordPress to seamlessly publish landing pages as a natural extension of your website.
6
- Version: 3.2.13
7
  Requires PHP: 5.2.4
8
  Plugin URI: https://instapage.com/
9
  Author: Instapage
3
  /*
4
  Plugin Name: Instapage Plugin
5
  Description: The best way for WordPress to seamlessly publish landing pages as a natural extension of your website.
6
+ Version: 3.2.14
7
  Requires PHP: 5.2.4
8
  Plugin URI: https://instapage.com/
9
  Author: Instapage
models/InstapageCmsPluginPageModel.php CHANGED
@@ -451,36 +451,19 @@ class InstapageCmsPluginPageModel {
451
  $url = preg_replace('/https?:\/\/' . $host . '/', INSTAPAGE_ENTERPRISE_ENDPOINT, $page->enterprise_url);
452
  $url .= $querySufix;
453
 
454
- if ($lpAjaxLoaderController->shouldBeUsed($url)) {
455
- $html = $lpAjaxLoaderController->getView();
456
- $result['code'] = 200;
457
- } else {
458
- $result = $api->enterpriseCall($url, $host, $cookies);
459
- $pageserverCookie = isset($result['headers']['set-cookie']) ? $result['headers']['set-cookie'] : '';
460
-
461
- if (is_array($pageserverCookie)) {
462
- $pageserverCookie = array_pop($pageserverCookie);
463
- }
464
-
465
- $instapageVariant = InstapageCmsPluginHelper::getVariant((string)$pageserverCookie);
466
-
467
- if (!empty($instapageVariant)) {
468
- setcookie(
469
- "instapage-variant-{$instapageId}",
470
- $instapageVariant,
471
- strtotime('+12 month')
472
- );
473
- }
474
 
475
- $html = InstapageCmsPluginHelper::getVar($result['body']);
476
- $html = $this->disableCloudFlareScriptReplace($html);
477
- $html = $this->fixHtmlHead($html);
478
  }
479
 
480
  if ($forcedStatus) {
481
  $status = $forcedStatus;
482
  } else {
483
- $status = InstapageCmsPluginHelper::getVar($result['code'], 200);
484
  }
485
 
486
  if ($html) {
@@ -495,6 +478,46 @@ class InstapageCmsPluginPageModel {
495
  }
496
  }
497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  /**
499
  * Deletes a page from local DB.
500
  *
451
  $url = preg_replace('/https?:\/\/' . $host . '/', INSTAPAGE_ENTERPRISE_ENDPOINT, $page->enterprise_url);
452
  $url .= $querySufix;
453
 
454
+ $enterpriseCallResult = $api->enterpriseCall($url, $host, $cookies);
455
+ $html = $this->getLandingPageHTMLFromTheApp($enterpriseCallResult);
456
+ $this->setVariantCookie($enterpriseCallResult, $instapageId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
 
458
+ if ($lpAjaxLoaderController->shouldBeUsed($url)) {
459
+ $html = $lpAjaxLoaderController->injectScript($html);
460
+ $html = $lpAjaxLoaderController->addDisplayNoneOnBody($html);
461
  }
462
 
463
  if ($forcedStatus) {
464
  $status = $forcedStatus;
465
  } else {
466
+ $status = InstapageCmsPluginHelper::getVar($enterpriseCallResult['code'], 200);
467
  }
468
 
469
  if ($html) {
478
  }
479
  }
480
 
481
+ /**
482
+ * Gets and prepares Landing Page HTML from app (from request to so called enterprise)
483
+ *
484
+ * @param array $enterpriseCallResult Result from enterpriseCall() method
485
+ * @return string
486
+ */
487
+ public function getLandingPageHTMLFromTheApp($enterpriseCallResult)
488
+ {
489
+ $html = InstapageCmsPluginHelper::getVar($enterpriseCallResult['body']);
490
+ $html = $this->disableCloudFlareScriptReplace($html);
491
+ $html = $this->fixHtmlHead($html);
492
+
493
+ return $html;
494
+ }
495
+
496
+ /**
497
+ * Set cookie with variant value
498
+ *
499
+ * @param array $enterpriseCallResult Result from enterpriseCall() method
500
+ * @param int $instapageId
501
+ */
502
+ public function setVariantCookie($enterpriseCallResult, $instapageId)
503
+ {
504
+ $pageserverCookie = isset($enterpriseCallResult['headers']['set-cookie']) ? $enterpriseCallResult['headers']['set-cookie'] : '';
505
+
506
+ if (is_array($pageserverCookie)) {
507
+ $pageserverCookie = array_pop($pageserverCookie);
508
+ }
509
+
510
+ $instapageVariant = InstapageCmsPluginHelper::getVariant((string) $pageserverCookie);
511
+
512
+ if (!empty($instapageVariant)) {
513
+ setcookie(
514
+ "instapage-variant-{$instapageId}",
515
+ $instapageVariant,
516
+ strtotime('+12 month')
517
+ );
518
+ }
519
+ }
520
+
521
  /**
522
  * Deletes a page from local DB.
523
  *
modules/lpAjaxLoader/InstapageCmsPluginLPAjaxLoaderController.php CHANGED
@@ -55,4 +55,40 @@ class InstapageCmsPluginLPAjaxLoaderController
55
  include(__DIR__ . '/view.php');
56
  return ob_get_clean();
57
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
55
  include(__DIR__ . '/view.php');
56
  return ob_get_clean();
57
  }
58
+
59
+ /**
60
+ * Inject loading script. This script is responsible for base64 encoding query to it is not altered/stripped
61
+ * by custom caching layers (as Pantheon for example does)
62
+ *
63
+ * @param $html string Whole landing page html
64
+ * @return string
65
+ */
66
+ public function injectScript($html)
67
+ {
68
+ $headTag = '<head>';
69
+ $scriptTag = $this->getView();
70
+
71
+ return str_replace(
72
+ $headTag,
73
+ $headTag . $scriptTag,
74
+ $html
75
+ );
76
+ }
77
+
78
+ /**
79
+ * Set display on body in passed $html
80
+ *
81
+ * @param $html string Whole landing page html
82
+ * @return string
83
+ */
84
+ public function addDisplayNoneOnBody($html)
85
+ {
86
+ $bodyTag = '<body';
87
+
88
+ return str_replace(
89
+ $bodyTag,
90
+ $bodyTag . ' style="display: none"',
91
+ $html
92
+ );
93
+ }
94
  }
modules/lpAjaxLoader/view.php CHANGED
@@ -6,40 +6,74 @@
6
  */
7
  ?>
8
 
9
- <html>
10
- <script id='b64-replace' type="text/javascript">
11
- (function () {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  var query = [];
13
  var searchArray = document.location.search.replace('?', '').split('&');
14
- var url = document.location.origin + document.location.pathname + '?b64=';
15
- var i;
16
 
17
- for (i = 0; i < searchArray.length; i++) {
18
  if (searchArray[i].indexOf("PANTHEON_STRIPPED") === -1) {
19
  query.push(searchArray[i]);
20
  }
21
  }
22
 
23
  query.push(
24
- '<?php echo InstapageCmsPluginLPAjaxLoaderController::AJAX_REQUEST_FLAG_NAME ?>=true'
25
  );
26
 
 
 
 
 
 
 
 
 
 
27
  if (window.XMLHttpRequest) {
28
  var xhReq = new XMLHttpRequest();
29
  } else {
30
  var xhReq = new ActiveXObject("Microsoft.XMLHTTP");
31
  }
32
 
33
- xhReq.open('GET', url + window.btoa(query.join('&')), false);
34
  xhReq.setRequestHeader("X-Requested-With", "XMLHttpRequest");
35
  xhReq.send();
36
 
37
- document.open();
38
- document.write(xhReq.responseText);
39
- document.close();
40
- document.getElementById("b64-replace").remove();
41
- })();
42
- </script>
43
- <body>
44
- </body>
45
- </html>
 
 
 
 
 
 
 
 
 
6
  */
7
  ?>
8
 
9
+ <script id="b64-replace" type="text/javascript">
10
+ (function () {
11
+ function hasGetParameters() {
12
+ return document.location.search !== '';
13
+ }
14
+
15
+ /**
16
+ * Execute fn not earlier than DOM is ready
17
+ */
18
+ function onDOMReady(fn) {
19
+ if (document.readyState != 'loading') {
20
+ fn();
21
+ } else {
22
+ document.addEventListener('DOMContentLoaded', fn);
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Encode query string to pass it to backend of our plugin (we omit by this stripping utm tags)
28
+ */
29
+ function buildBase64EncodedQueryString() {
30
  var query = [];
31
  var searchArray = document.location.search.replace('?', '').split('&');
 
 
32
 
33
+ for (var i = 0; i < searchArray.length; i++) {
34
  if (searchArray[i].indexOf("PANTHEON_STRIPPED") === -1) {
35
  query.push(searchArray[i]);
36
  }
37
  }
38
 
39
  query.push(
40
+ '<?php echo InstapageCmsPluginLPAjaxLoaderController::AJAX_REQUEST_FLAG_NAME ?>=true'
41
  );
42
 
43
+ return window.btoa(query.join('&'));
44
+ }
45
+
46
+ /**
47
+ * Fetch landing page with base64 encoding query strings to ommit caching/altering layers of query params
48
+ */
49
+ function fetchLandingPage() {
50
+ var url = document.location.origin + document.location.pathname;
51
+
52
  if (window.XMLHttpRequest) {
53
  var xhReq = new XMLHttpRequest();
54
  } else {
55
  var xhReq = new ActiveXObject("Microsoft.XMLHTTP");
56
  }
57
 
58
+ xhReq.open('GET', url + '?b64=' + buildBase64EncodedQueryString(), false);
59
  xhReq.setRequestHeader("X-Requested-With", "XMLHttpRequest");
60
  xhReq.send();
61
 
62
+ onDOMReady(function () {
63
+ document.getElementsByTagName('html')[0].innerHTML = xhReq.responseText;
64
+ })
65
+ }
66
+
67
+ function showBody() {
68
+ onDOMReady(function () {
69
+ document.getElementsByTagName('body')[0].style.display = 'block';
70
+ })
71
+ }
72
+
73
+ if (hasGetParameters()) {
74
+ fetchLandingPage();
75
+ } else {
76
+ showBody();
77
+ }
78
+ })();
79
+ </script>