Skip to content

Commit 07a2fb5

Browse files
authored
Merge pull request #77 from ConvertKit/remove-rocket-loader
Remove `rocket-loader.min.js` from Landing Pages
2 parents 7278076 + a3187c1 commit 07a2fb5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/class-convertkit-api-traits.php

+6
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,12 @@ public function convert_relative_to_absolute_urls(\DOMNodeList $elements, string
16621662
continue;
16631663
}
16641664

1665+
// Remove element if it's rocket-loader.min.js. Including it prevents landing page redirects from working.
1666+
if (strpos($element->getAttribute($attribute), 'rocket-loader.min.js') !== false) {
1667+
$element->parentNode->removeChild($element);
1668+
continue;
1669+
}
1670+
16651671
// If here, the attribute's value is a relative URL, missing the http(s) and domain.
16661672
// Prepend the URL to the attribute's value.
16671673
$element->setAttribute($attribute, $url . $element->getAttribute($attribute));

tests/wpunit/APITest.php

+9
Original file line numberDiff line numberDiff line change
@@ -6155,6 +6155,9 @@ public function testGetLandingPageHTML()
61556155
$result = $this->api->get_landing_page_html($_ENV['CONVERTKIT_API_LANDING_PAGE_URL']);
61566156
$this->assertNotInstanceOf(WP_Error::class, $result);
61576157
$this->assertStringContainsString('<form method="POST" action="https://app.convertkit.com/forms/' . $_ENV['CONVERTKIT_API_LANDING_PAGE_ID'] . '/subscriptions" data-sv-form="' . $_ENV['CONVERTKIT_API_LANDING_PAGE_ID'] . '" data-uid="99f1db6843" class="formkit-form"', $result);
6158+
6159+
// Check that rocket-loader.min.js has been removed, as including it breaks landing page redirects.
6160+
$this->assertStringNotContainsString('rocket-loader.min.js', $result);
61586161
}
61596162

61606163
/**
@@ -6171,6 +6174,9 @@ public function testGetLandingPageWithCharacterEncodingHTML()
61716174

61726175
// Assert that character encoding works, and that special characters are not malformed.
61736176
$this->assertStringContainsString('Vantar þinn ungling sjálfstraust í stærðfræði?', $result);
6177+
6178+
// Check that rocket-loader.min.js has been removed, as including it breaks landing page redirects.
6179+
$this->assertStringNotContainsString('rocket-loader.min.js', $result);
61746180
}
61756181

61766182
/**
@@ -6184,6 +6190,9 @@ public function testGetLegacyLandingPageHTML()
61846190
$result = $this->api->get_landing_page_html($_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_URL']);
61856191
$this->assertNotInstanceOf(WP_Error::class, $result);
61866192
$this->assertStringContainsString('<form id="ck_subscribe_form" class="ck_subscribe_form" action="https://app.convertkit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] . '/subscribe" data-remote="true">', $result);
6193+
6194+
// Check that rocket-loader.min.js has been removed, as including it breaks landing page redirects.
6195+
$this->assertStringNotContainsString('rocket-loader.min.js', $result);
61876196
}
61886197

61896198
/**

0 commit comments

Comments
 (0)