Version Description
- New Feature: Completely compatible with LiteSpeed servers
- Improvement: The help button is now an interactive widget
- Improvement: Full compatibility with WPX Cloud
- Improvement: Resolve an occasional issue with the cache layer on Pressable
- Improvement: Overall stability improvements
- Bug fix: Correctly purge cache when a post transitions to a draft state
Download this release
Release Info
Developer | nitropack |
Plugin | NitroPack |
Version | 1.5.13 |
Comparing to | |
See all releases |
Code changes from version 1.5.12 to 1.5.13
- advanced-cache.php +17 -0
- classes/Integration.php +1 -0
- classes/Integration/Hosting/Pressable.php +4 -4
- classes/Integration/Hosting/WPX.php +59 -1
- classes/Integration/Server/LiteSpeed.php +98 -30
- classes/WordPress/NitroPack.php +9 -0
- constants.php +1 -1
- functions.php +148 -5
- main.php +1 -1
- nitropack-sdk/NitroPack/SDK/NitroPack.php +6 -1
- nitropack-sdk/NitroPack/SDK/Pagecache.php +10 -2
- nitropack-sdk/vendor/autoload.php +6 -1
- nitropack-sdk/vendor/composer/InstalledVersions.php +9 -7
- nitropack-sdk/vendor/composer/autoload_classmap.php +1 -1
- nitropack-sdk/vendor/composer/autoload_namespaces.php +1 -1
- nitropack-sdk/vendor/composer/autoload_psr4.php +1 -1
- nitropack-sdk/vendor/composer/autoload_real.php +7 -26
- nitropack-sdk/vendor/composer/autoload_static.php +4 -4
- nitropack-sdk/vendor/composer/installed.json +5 -5
- nitropack-sdk/vendor/composer/installed.php +6 -6
- nitropack-sdk/vendor/nitropack/httpclient/src/HttpClient.php +15 -14
- nitropack-sdk/vendor/nitropack/url/src/Url.php +7 -0
- readme.txt +11 -3
- view/admin.php +21 -3
advanced-cache.php
CHANGED
@@ -2,6 +2,13 @@
|
|
2 |
|
3 |
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
$nitropack_functions_file = '/*NITROPACK_FUNCTIONS_FILE*/';
|
6 |
$nitropack_abspath = '/*NITROPACK_ABSPATH*/';
|
7 |
|
@@ -21,12 +28,22 @@ if (defined("NITROPACK_VERSION") && defined("NITROPACK_ADVANCED_CACHE_VERSION")
|
|
21 |
if (null !== $nitro) {
|
22 |
$np_siteConfig = nitropack_get_site_config();
|
23 |
if ( !empty($np_siteConfig["alwaysBuffer"]) || ($nitro->isAJAXRequest() && $nitro->isAllowedAJAX()) ) {
|
|
|
24 |
ob_start(function($buffer) use (&$nitro) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
if ($nitro->isAJAXRequest() && $nitro->isAllowedAJAX()) {
|
26 |
$nitro->pageCache->setContent($buffer, []);
|
27 |
}
|
28 |
return $buffer;
|
29 |
}, 0, PHP_OUTPUT_HANDLER_FLUSHABLE | PHP_OUTPUT_HANDLER_REMOVABLE);
|
|
|
|
|
30 |
}
|
31 |
}
|
32 |
}
|
2 |
|
3 |
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
4 |
|
5 |
+
if (strpos($_SERVER["REQUEST_URI"], "nitroHealthcheck") !== false) {
|
6 |
+
// This healthcheck is used to quickly check test whether the PHP application is able to handle the requests
|
7 |
+
// Mainly used to check for errors after .htaccess has been modified
|
8 |
+
echo "Healthy";
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
$nitropack_functions_file = '/*NITROPACK_FUNCTIONS_FILE*/';
|
13 |
$nitropack_abspath = '/*NITROPACK_ABSPATH*/';
|
14 |
|
28 |
if (null !== $nitro) {
|
29 |
$np_siteConfig = nitropack_get_site_config();
|
30 |
if ( !empty($np_siteConfig["alwaysBuffer"]) || ($nitro->isAJAXRequest() && $nitro->isAllowedAJAX()) ) {
|
31 |
+
define( 'NITROPACK_IS_BUFFERING', true );
|
32 |
ob_start(function($buffer) use (&$nitro) {
|
33 |
+
if (!defined("NITROPACK_BEACON_PRINTED")) {
|
34 |
+
if (strpos($buffer, "</body") !== false) {
|
35 |
+
define("NITROPACK_BEACON_PRINTED", true);
|
36 |
+
$buffer = str_replace("</body", nitropack_get_beacon_script() . "</body", $buffer);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
if ($nitro->isAJAXRequest() && $nitro->isAllowedAJAX()) {
|
41 |
$nitro->pageCache->setContent($buffer, []);
|
42 |
}
|
43 |
return $buffer;
|
44 |
}, 0, PHP_OUTPUT_HANDLER_FLUSHABLE | PHP_OUTPUT_HANDLER_REMOVABLE);
|
45 |
+
} else {
|
46 |
+
define( 'NITROPACK_IS_BUFFERING', false );
|
47 |
}
|
48 |
}
|
49 |
}
|
classes/Integration.php
CHANGED
@@ -25,6 +25,7 @@ class Integration {
|
|
25 |
"NitroPack/Integration/Hosting/RocketNet",
|
26 |
"NitroPack/Integration/Hosting/Savvii",
|
27 |
"NitroPack/Integration/Hosting/DreamHost",
|
|
|
28 |
"NitroPack/Integration/Server/LiteSpeed",
|
29 |
"NitroPack/Integration/Server/Fastly",
|
30 |
"NitroPack/Integration/Server/Cloudflare",
|
25 |
"NitroPack/Integration/Hosting/RocketNet",
|
26 |
"NitroPack/Integration/Hosting/Savvii",
|
27 |
"NitroPack/Integration/Hosting/DreamHost",
|
28 |
+
"NitroPack/Integration/Hosting/WPX",
|
29 |
"NitroPack/Integration/Server/LiteSpeed",
|
30 |
"NitroPack/Integration/Server/Fastly",
|
31 |
"NitroPack/Integration/Server/Cloudflare",
|
classes/Integration/Hosting/Pressable.php
CHANGED
@@ -34,7 +34,7 @@ class Pressable extends Hosting {
|
|
34 |
public function noCache() {
|
35 |
global $batcache;
|
36 |
|
37 |
-
if (!empty($batcache)) {
|
38 |
$batcache->max_age = 0;
|
39 |
}
|
40 |
}
|
@@ -42,7 +42,7 @@ class Pressable extends Hosting {
|
|
42 |
public function cacheShort() {
|
43 |
global $batcache;
|
44 |
|
45 |
-
if (!empty($batcache)) {
|
46 |
$batcache->max_age = 30;
|
47 |
}
|
48 |
}
|
@@ -50,7 +50,7 @@ class Pressable extends Hosting {
|
|
50 |
public function cacheLong() {
|
51 |
global $batcache;
|
52 |
|
53 |
-
if (!empty($batcache)) {
|
54 |
$batcache->max_age = 300;
|
55 |
}
|
56 |
}
|
@@ -58,7 +58,7 @@ class Pressable extends Hosting {
|
|
58 |
public function purgeUrl($url) {
|
59 |
global $batcache;
|
60 |
|
61 |
-
if (!$batcache) return;
|
62 |
|
63 |
$urlObj = new \NitroPack\Url($url);
|
64 |
if ($urlObj->getHost()) {
|
34 |
public function noCache() {
|
35 |
global $batcache;
|
36 |
|
37 |
+
if (!empty($batcache) && is_object($batcache)) {
|
38 |
$batcache->max_age = 0;
|
39 |
}
|
40 |
}
|
42 |
public function cacheShort() {
|
43 |
global $batcache;
|
44 |
|
45 |
+
if (!empty($batcache) && is_object($batcache)) {
|
46 |
$batcache->max_age = 30;
|
47 |
}
|
48 |
}
|
50 |
public function cacheLong() {
|
51 |
global $batcache;
|
52 |
|
53 |
+
if (!empty($batcache) && is_object($batcache)) {
|
54 |
$batcache->max_age = 300;
|
55 |
}
|
56 |
}
|
58 |
public function purgeUrl($url) {
|
59 |
global $batcache;
|
60 |
|
61 |
+
if (!$batcache || !is_object($batcache)) return;
|
62 |
|
63 |
$urlObj = new \NitroPack\Url($url);
|
64 |
if ($urlObj->getHost()) {
|
classes/Integration/Hosting/WPX.php
CHANGED
@@ -3,11 +3,69 @@
|
|
3 |
namespace NitroPack\Integration\Hosting;
|
4 |
|
5 |
class WPX extends Hosting {
|
6 |
-
const STAGE =
|
7 |
|
8 |
public static function detect() {
|
9 |
$hostname = gethostname();
|
10 |
return $hostname && (preg_match("/wpx\.net$/", $hostname) || preg_match("/wpxhosting\.com$/", $hostname));
|
11 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
}
|
13 |
|
3 |
namespace NitroPack\Integration\Hosting;
|
4 |
|
5 |
class WPX extends Hosting {
|
6 |
+
const STAGE = "very_early";
|
7 |
|
8 |
public static function detect() {
|
9 |
$hostname = gethostname();
|
10 |
return $hostname && (preg_match("/wpx\.net$/", $hostname) || preg_match("/wpxhosting\.com$/", $hostname));
|
11 |
}
|
12 |
+
|
13 |
+
public static function isCDNEnabled() {
|
14 |
+
$siteConfig = get_nitropack()->getSiteConfig();
|
15 |
+
if ($siteConfig) {
|
16 |
+
$urlObj = new \NitroPack\Url($siteConfig["home_url"]);
|
17 |
+
$ip = gethostbyname($urlObj->getHost());
|
18 |
+
|
19 |
+
$wpxMin = ip2long("194.1.147.1");
|
20 |
+
$wpxMax = ip2long("194.1.147.254");
|
21 |
+
$clientIp = ip2long($ip);
|
22 |
+
|
23 |
+
return $clientIp >= $wpxMin && $clientIp <= $wpxMax;
|
24 |
+
}
|
25 |
+
|
26 |
+
return false;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function init($stage) {
|
30 |
+
if ($this->getHosting() == "wpx" && self::isCDNEnabled()) {
|
31 |
+
add_action('nitropack_execute_purge_url', [$this, 'purgeUrl']);
|
32 |
+
add_action('nitropack_execute_purge_all', [$this, 'purgeAll']);
|
33 |
+
add_action('nitropack_cacheable_cache_headers', [$this, 'setCacheControl']);
|
34 |
+
add_action('nitropack_cachehit_cache_headers', [$this, 'setCacheControl']);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
public function purgeUrl($url) {
|
39 |
+
try {
|
40 |
+
$siteConfig = get_nitropack()->getSiteConfig();
|
41 |
+
if ($siteConfig) {
|
42 |
+
$urlObj = new \NitroPack\Url($siteConfig["home_url"]);
|
43 |
+
$purgeUrl = "http://" . $urlObj->getHost() . ":6081" . $urlObj->getPath() . ".*";
|
44 |
+
$purger = new \NitroPack\SDK\Integrations\ReverseProxy(array("127.0.0.1"), "PURGE");
|
45 |
+
$purger->purge($purgeUrl);
|
46 |
+
}
|
47 |
+
} catch (\Exception $e) {
|
48 |
+
// Exception
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
public function purgeAll() {
|
53 |
+
try {
|
54 |
+
$siteConfig = get_nitropack()->getSiteConfig();
|
55 |
+
if ($siteConfig) {
|
56 |
+
$urlObj = new \NitroPack\Url($siteConfig["home_url"]);
|
57 |
+
$purgeUrl = "http://" . $urlObj->getHost() . ":6081/.*";
|
58 |
+
$purger = new \NitroPack\SDK\Integrations\ReverseProxy(array("127.0.0.1"), "PURGE");
|
59 |
+
$purger->purge($purgeUrl);
|
60 |
+
}
|
61 |
+
} catch (\Exception $e) {
|
62 |
+
// Exception
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
public function setCacheControl() {
|
67 |
+
nitropack_header("Cache-Control: public, max-age=0, s-maxage=3600");
|
68 |
+
nitropack_header("CDN-Cache-Control: public, max-age=3600");
|
69 |
+
}
|
70 |
}
|
71 |
|
classes/Integration/Server/LiteSpeed.php
CHANGED
@@ -1,22 +1,24 @@
|
|
1 |
<?php
|
2 |
|
3 |
namespace NitroPack\Integration\Server;
|
|
|
|
|
|
|
|
|
4 |
|
5 |
class LiteSpeed {
|
6 |
const STAGE = "very_early";
|
7 |
-
const DEVICE_COOKIE = "ls_nitro_device";
|
8 |
|
9 |
public static function detect() {
|
10 |
return !empty($_SERVER["X-LSCACHE"]) || ( !empty($_SERVER["SERVER_SOFTWARE"]) && strtolower($_SERVER["SERVER_SOFTWARE"]) == "litespeed" );
|
11 |
}
|
12 |
|
13 |
public static function isCacheEnabled() {
|
14 |
-
return
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
return isset($_COOKIE[self::DEVICE_COOKIE]);
|
20 |
}
|
21 |
|
22 |
public static function sendCacheHeader($maxAge = NULL) {
|
@@ -32,16 +34,16 @@ class LiteSpeed {
|
|
32 |
$headerValues = [];
|
33 |
|
34 |
if ($url) {
|
35 |
-
$urlObj = new
|
36 |
if (!$urlObj->getQuery()) {
|
37 |
-
$headerValues[] = $urlObj->getPath();
|
38 |
} else {
|
39 |
-
$headerValues[] = $urlObj->getPath() . "?" . $urlObj->getQuery();
|
40 |
}
|
41 |
}
|
42 |
|
43 |
if ($tag) {
|
44 |
-
$headerValues[] =
|
45 |
}
|
46 |
|
47 |
nitropack_header("X-LiteSpeed-Purge: " . implode(", ", $headerValues), false);
|
@@ -51,12 +53,23 @@ class LiteSpeed {
|
|
51 |
}
|
52 |
|
53 |
public function init($stage) {
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
}
|
62 |
|
@@ -69,22 +82,77 @@ class LiteSpeed {
|
|
69 |
}
|
70 |
|
71 |
public function setupVary() {
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
|
75 |
public function allowProxyCache() {
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
$
|
80 |
-
|
81 |
-
|
82 |
-
} else if ($device->isTablet()) {
|
83 |
-
nitropack_setcookie(self::DEVICE_COOKIE, "tablet", time() + 86400);
|
84 |
-
} else {
|
85 |
-
nitropack_setcookie(self::DEVICE_COOKIE, "desktop", time() + 86400);
|
86 |
-
}
|
87 |
}
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
-
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
namespace NitroPack\Integration\Server;
|
4 |
+
use NitroPack\WordPress\NitroPack;
|
5 |
+
use NitroPack\Url;
|
6 |
+
use NitroPack\SDK\Device;
|
7 |
+
use NitroPack\Integration\Hosting\WPX;
|
8 |
|
9 |
class LiteSpeed {
|
10 |
const STAGE = "very_early";
|
|
|
11 |
|
12 |
public static function detect() {
|
13 |
return !empty($_SERVER["X-LSCACHE"]) || ( !empty($_SERVER["SERVER_SOFTWARE"]) && strtolower($_SERVER["SERVER_SOFTWARE"]) == "litespeed" );
|
14 |
}
|
15 |
|
16 |
public static function isCacheEnabled() {
|
17 |
+
return
|
18 |
+
!empty($_SERVER["X-LSCACHE"]) &&
|
19 |
+
in_array("on", array_map("trim", explode(",", $_SERVER["X-LSCACHE"]))) &&
|
20 |
+
!empty($_SERVER['LSCACHE_VARY_VALUE']) &&
|
21 |
+
in_array($_SERVER['LSCACHE_VARY_VALUE'], array("nitrodesktop", "nitrotablet", "nitromobile"));
|
|
|
22 |
}
|
23 |
|
24 |
public static function sendCacheHeader($maxAge = NULL) {
|
34 |
$headerValues = [];
|
35 |
|
36 |
if ($url) {
|
37 |
+
$urlObj = new Url((new Url($url))->getNormalized());
|
38 |
if (!$urlObj->getQuery()) {
|
39 |
+
$headerValues[] = "uri=" . md5($urlObj->getPath());
|
40 |
} else {
|
41 |
+
$headerValues[] = "uri=" . md5($urlObj->getPath() . "?" . $urlObj->getQuery());
|
42 |
}
|
43 |
}
|
44 |
|
45 |
if ($tag) {
|
46 |
+
$headerValues[] = $tag;
|
47 |
}
|
48 |
|
49 |
nitropack_header("X-LiteSpeed-Purge: " . implode(", ", $headerValues), false);
|
53 |
}
|
54 |
|
55 |
public function init($stage) {
|
56 |
+
if (self::detect()) {
|
57 |
+
add_filter('nitropack_should_modify_htaccess', function() { return true; });
|
58 |
+
add_filter('nitropack_htaccess_rules', [$this, 'getHtaccessRules'], 10);
|
59 |
+
|
60 |
+
if (self::isCacheEnabled()) {
|
61 |
+
add_action('nitropack_integration_purge_url', [$this, 'purgeUrl']);
|
62 |
+
add_action('nitropack_integration_purge_all', [$this, 'purgeAll']);
|
63 |
+
add_action('nitropack_early_cache_headers', [$this, 'setupVary']);
|
64 |
+
add_action('nitropack_early_cache_headers', [$this, 'preventProxyCache']);
|
65 |
+
add_action('nitropack_cacheable_cache_headers', [$this, 'allowProxyCache']);
|
66 |
+
add_filter('nocache_headers', function($headers) {
|
67 |
+
$headers["X-LiteSpeed-Cache-Control"] = "no-cache";
|
68 |
+
return $headers;
|
69 |
+
});
|
70 |
+
} else {
|
71 |
+
add_filter('nitropack_needs_htaccess_changes', function() { return true; });
|
72 |
+
}
|
73 |
}
|
74 |
}
|
75 |
|
82 |
}
|
83 |
|
84 |
public function setupVary() {
|
85 |
+
$cookies = []; // Configure vary based on NitroPack's variation cookies.
|
86 |
+
|
87 |
+
$nitro = get_nitropack()->getSdk();
|
88 |
+
if ($nitro && !empty($nitro->getConfig()->PageCache->SupportedCookies)) {
|
89 |
+
$cookies = $nitro->getConfig()->PageCache->SupportedCookies;
|
90 |
+
}
|
91 |
+
|
92 |
+
$device = new Device($_SERVER["HTTP_USER_AGENT"]);
|
93 |
+
$deviceStr = "nitrodesktop";
|
94 |
+
|
95 |
+
if ($device->isMobile()) {
|
96 |
+
$deviceStr = "nitromobile";
|
97 |
+
} else if ($device->isTablet()) {
|
98 |
+
$deviceStr = "nitrotablet";
|
99 |
+
}
|
100 |
+
|
101 |
+
$varyStr = "";
|
102 |
+
|
103 |
+
if ($cookies) {
|
104 |
+
$varyStr = implode(",", array_map(function($name) { return "cookie=$name"; }, $cookies)); // Vary on multiple cookies should look like this: cookie=name1,cookie=name2
|
105 |
+
}
|
106 |
+
|
107 |
+
$varyStr .= ($varyStr ? ", " : "") . "value=$deviceStr";
|
108 |
+
|
109 |
+
nitropack_header("X-LiteSpeed-Vary: $varyStr");
|
110 |
+
}
|
111 |
+
|
112 |
+
public function preventProxyCache() {
|
113 |
+
nitropack_header("X-LiteSpeed-Cache-Control: no-cache");
|
114 |
}
|
115 |
|
116 |
public function allowProxyCache() {
|
117 |
+
self::sendCacheHeader(3600);
|
118 |
+
$urlObj = new Url(NitroPack::getInstance()->getSdk()->getUrl());
|
119 |
+
if (!$urlObj->getQuery()) {
|
120 |
+
$uri = md5($urlObj->getPath());
|
121 |
+
} else {
|
122 |
+
$uri = md5($urlObj->getPath() . "?" . $urlObj->getQuery());
|
|
|
|
|
|
|
|
|
|
|
123 |
}
|
124 |
+
|
125 |
+
nitropack_header("X-LiteSpeed-Tag: uri=$uri");
|
126 |
+
|
127 |
+
// TODO: Add LSC-Cookie headers for variation cookies - https://docs.litespeedtech.com/lscache/devguide/controls/#lsc-cookie
|
128 |
}
|
|
|
129 |
|
130 |
+
public function getHtaccessRules($ruleLines) {
|
131 |
+
$rules = "
|
132 |
+
<IfModule LiteSpeed>
|
133 |
+
RewriteEngine on
|
134 |
+
CacheLookup on
|
135 |
+
|
136 |
+
RewriteRule .* - [E=Cache-Control:vary=nitrodesktop]
|
137 |
+
|
138 |
+
RewriteCond %{HTTP_USER_AGENT} Android|iPad|RIM\ Tablet|hp-tablet|Kindle\ Fire [NC]
|
139 |
+
RewriteRule .* - [E=Cache-Control:vary=nitrotablet]
|
140 |
+
|
141 |
+
RewriteCond %{HTTP_USER_AGENT} iPod|iPhone|MobileSafari|webOS|BlackBerry|windows\ phone|symbian|vodafone|opera\ mini|windows\ ce|smartphone|palm|midp [NC,OR]
|
142 |
+
RewriteCond %{HTTP_USER_AGENT} Android.*Mobile [NC,OR]
|
143 |
+
RewriteCond %{HTTP_USER_AGENT} Mobile.*Android [NC]
|
144 |
+
RewriteRule .* - [E=Cache-Control:vary=nitromobile]
|
145 |
+
|
146 |
+
# QSDROP
|
147 |
+
|
148 |
+
</IfModule>
|
149 |
+
";
|
150 |
+
|
151 |
+
$nitro = get_nitropack()->getSdk();
|
152 |
+
if ($nitro && !empty($nitro->getConfig()->IgnoredParams)) {
|
153 |
+
$rules = str_replace("# QSDROP", implode("\n", array_map(function($param) { return "CacheKeyModify -qs:$param"; }, array_filter($nitro->getConfig()->IgnoredParams, function($param) { return $param != "ignorenitro"; }))), $rules);
|
154 |
+
}
|
155 |
+
|
156 |
+
return array_merge($ruleLines, explode("\n", $rules));
|
157 |
+
}
|
158 |
+
}
|
classes/WordPress/NitroPack.php
CHANGED
@@ -154,6 +154,10 @@ class NitroPack {
|
|
154 |
return true;
|
155 |
}
|
156 |
|
|
|
|
|
|
|
|
|
157 |
public function getSdk($siteId = null, $siteSecret = null, $urlOverride = NULL, $forwardExceptions = false) {
|
158 |
$siteConfig = $this->getSiteConfig();
|
159 |
|
@@ -194,6 +198,11 @@ class NitroPack {
|
|
194 |
define('NP_GEOLOCATION_PREFIX_DEFINED', true);
|
195 |
}
|
196 |
|
|
|
|
|
|
|
|
|
|
|
197 |
$nitro = new \NitroPack\SDK\NitroPack($siteId, $siteSecret, $userAgent, $urlOverride, $dataDir);
|
198 |
$this->sdkObjects[$cacheKey] = $nitro;
|
199 |
}
|
154 |
return true;
|
155 |
}
|
156 |
|
157 |
+
public function resetSdkInstances() {
|
158 |
+
$this->sdkObjects = [];
|
159 |
+
}
|
160 |
+
|
161 |
public function getSdk($siteId = null, $siteSecret = null, $urlOverride = NULL, $forwardExceptions = false) {
|
162 |
$siteConfig = $this->getSiteConfig();
|
163 |
|
198 |
define('NP_GEOLOCATION_PREFIX_DEFINED', true);
|
199 |
}
|
200 |
|
201 |
+
if (defined("NITROPACK_CUSTOM_CACHE_PREFIX") && !defined('NP_CUSTOM_CACHE_PREFIX_SET')) {
|
202 |
+
\NitroPack\SDK\NitroPack::addCustomCachePrefix(NITROPACK_CUSTOM_CACHE_PREFIX);
|
203 |
+
define('NP_CUSTOM_CACHE_PREFIX_SET', true);
|
204 |
+
}
|
205 |
+
|
206 |
$nitro = new \NitroPack\SDK\NitroPack($siteId, $siteSecret, $userAgent, $urlOverride, $dataDir);
|
207 |
$this->sdkObjects[$cacheKey] = $nitro;
|
208 |
}
|
constants.php
CHANGED
@@ -6,7 +6,7 @@ function nitropack_trailingslashit($string) {
|
|
6 |
return rtrim( $string, '/\\' ) . '/';
|
7 |
}
|
8 |
|
9 |
-
define( 'NITROPACK_VERSION', '1.5.
|
10 |
define( 'NITROPACK_OPTION_GROUP', 'nitropack' );
|
11 |
define( 'NITROPACK_DATA_DIR', nitropack_trailingslashit(WP_CONTENT_DIR) . 'nitropack' );
|
12 |
define( 'NITROPACK_CONFIG_FILE', nitropack_trailingslashit(NITROPACK_DATA_DIR) . 'config.json' );
|
6 |
return rtrim( $string, '/\\' ) . '/';
|
7 |
}
|
8 |
|
9 |
+
define( 'NITROPACK_VERSION', '1.5.13' );
|
10 |
define( 'NITROPACK_OPTION_GROUP', 'nitropack' );
|
11 |
define( 'NITROPACK_DATA_DIR', nitropack_trailingslashit(WP_CONTENT_DIR) . 'nitropack' );
|
12 |
define( 'NITROPACK_CONFIG_FILE', nitropack_trailingslashit(NITROPACK_DATA_DIR) . 'config.json' );
|
functions.php
CHANGED
@@ -21,8 +21,8 @@ function nitropack_is_logged_in() {
|
|
21 |
return true;
|
22 |
}
|
23 |
}
|
24 |
-
|
25 |
-
return false;
|
26 |
}
|
27 |
|
28 |
function nitropack_passes_cookie_requirements() {
|
@@ -38,6 +38,7 @@ function nitropack_passes_cookie_requirements() {
|
|
38 |
}
|
39 |
|
40 |
function nitropack_activate() {
|
|
|
41 |
nitropack_set_wp_cache_const(true);
|
42 |
$htaccessFile = nitropack_trailingslashit(NITROPACK_DATA_DIR) . ".htaccess";
|
43 |
if (!file_exists($htaccessFile) && get_nitropack()->initDataDir()) {
|
@@ -56,9 +57,11 @@ function nitropack_activate() {
|
|
56 |
} else {
|
57 |
setcookie("nitropack_after_activate_notice", 1, time() + 3600);
|
58 |
}
|
|
|
59 |
}
|
60 |
|
61 |
function nitropack_deactivate() {
|
|
|
62 |
nitropack_set_wp_cache_const(false);
|
63 |
nitropack_uninstall_advanced_cache();
|
64 |
|
@@ -71,6 +74,7 @@ function nitropack_deactivate() {
|
|
71 |
if (get_nitropack()->isConnected()) {
|
72 |
nitropack_event("disable_extension");
|
73 |
}
|
|
|
74 |
}
|
75 |
|
76 |
function nitropack_install_advanced_cache() {
|
@@ -154,6 +158,93 @@ function nitropack_set_wp_cache_const($status) {
|
|
154 |
return WP_DEBUG ? file_put_contents($configFilePath, implode("", $lines)) : @file_put_contents($configFilePath, implode("", $lines));
|
155 |
}
|
156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
function nitropack_set_batcache_compat($status) {
|
158 |
$currentCompatStatus = defined("NITROPACK_BATCACHE_COMPAT") && NITROPACK_BATCACHE_COMPAT;
|
159 |
if ($currentCompatStatus === $status) return true;
|
@@ -288,6 +379,8 @@ function nitropack_handle_webhook() {
|
|
288 |
switch($_GET["nitroWebhook"]) {
|
289 |
case "config":
|
290 |
nitropack_fetch_config();
|
|
|
|
|
291 |
break;
|
292 |
case "cache_ready":
|
293 |
if (!empty($_POST["url"])) {
|
@@ -556,6 +649,24 @@ function nitropack_init() {
|
|
556 |
}
|
557 |
}
|
558 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
559 |
add_action('the_post', 'nitropack_handle_the_post');
|
560 |
add_action('wp_footer', 'nitropack_log_tags');
|
561 |
}
|
@@ -619,7 +730,7 @@ function nitropack_set_custom_expiration() {
|
|
619 |
{$wpdb->prefix}posts.post_date > '" . date("Y-m-d H:i:s") . "'
|
620 |
AND {$wpdb->prefix}posts.post_type = 'post' AND (({$wpdb->prefix}posts.post_status = 'future')) ORDER BY {$wpdb->prefix}posts.post_date ASC LIMIT 0, 1" );
|
621 |
|
622 |
-
if (!empty($unmodifiedPosts)) {
|
623 |
$np_customExpirationTimes[] = strtotime($unmodifiedPosts[0]->post_date);
|
624 |
}
|
625 |
|
@@ -630,7 +741,7 @@ function nitropack_set_custom_expiration() {
|
|
630 |
"start_date" => time()
|
631 |
));
|
632 |
|
633 |
-
if (count($events)) {
|
634 |
$np_customExpirationTimes[] = strtotime($events[0]->event_date);
|
635 |
}
|
636 |
}
|
@@ -1678,6 +1789,9 @@ function nitropack_clean_post_cache($post, $taxonomies = NULL, $hasImportantChan
|
|
1678 |
} else {
|
1679 |
nitropack_invalidate(NULL, "single:$postID", $reason);
|
1680 |
}
|
|
|
|
|
|
|
1681 |
if ($hasImportantChangeInPost === NULL) {
|
1682 |
$hasImportantChangeInPost = nitropack_has_post_important_change($post);
|
1683 |
}
|
@@ -1763,7 +1877,7 @@ function nitropack_handle_post_transition($new, $old, $post) {
|
|
1763 |
if (!get_option("nitropack-autoCachePurge", 1)) return;
|
1764 |
|
1765 |
try {
|
1766 |
-
if ($new === "auto-draft" || $new === "draft" || $new === "inherit") { // Creating a new post or draft, don't do anything for now.
|
1767 |
return;
|
1768 |
}
|
1769 |
|
@@ -1804,6 +1918,8 @@ function nitropack_handle_post_transition($new, $old, $post) {
|
|
1804 |
nitropack_clean_post_cache($post, array('deleted' => nitropack_get_taxonomies($post)), true, sprintf("Invalidate related pages due to deleting %s '%s'", $nicePostTypeLabel, $post->post_title), true);
|
1805 |
} else if ($new == "private" && $old == "publish") {
|
1806 |
nitropack_clean_post_cache($post, array('deleted' => nitropack_get_taxonomies($post)), true, sprintf("Invalidate related pages due to making %s '%s' private", $nicePostTypeLabel, $post->post_title), true);
|
|
|
|
|
1807 |
} else if ($new != "trash") {
|
1808 |
nitropack_clean_post_cache($post);
|
1809 |
$np_loggedWarmups[] = get_permalink($post);
|
@@ -1828,6 +1944,14 @@ function nitropack_handle_product_updates($product, $updated) {
|
|
1828 |
}
|
1829 |
}
|
1830 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1831 |
function nitropack_handle_the_post($post) {
|
1832 |
global $np_customExpirationTimes, $np_queriedObj;
|
1833 |
if (defined('POSTEXPIRATOR_VERSION')) {
|
@@ -2458,6 +2582,19 @@ function nitropack_get_wpconfig_path() {
|
|
2458 |
return $configFilePath;
|
2459 |
}
|
2460 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2461 |
function nitropack_detect_hosting() {
|
2462 |
if (\NitroPack\Integration\Hosting\Flywheel::detect()) {
|
2463 |
return "flywheel";
|
@@ -2837,6 +2974,12 @@ function nitropack_plugin_notices() {
|
|
2837 |
}
|
2838 |
}
|
2839 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2840 |
if ( !get_nitropack()->dataDirExists() && !get_nitropack()->initDataDir()) {
|
2841 |
$errors[] = "The NitroPack data directory cannot be created. Please make sure that the /wp-content/ directory is writable and refresh this page.";
|
2842 |
return [
|
21 |
return true;
|
22 |
}
|
23 |
}
|
24 |
+
$cookieStr = implode("|", array_keys($_COOKIE));
|
25 |
+
return strpos($cookieStr, "wordpress_logged_in_") !== false;
|
26 |
}
|
27 |
|
28 |
function nitropack_passes_cookie_requirements() {
|
38 |
}
|
39 |
|
40 |
function nitropack_activate() {
|
41 |
+
nitropack_set_htaccess_rules(true);
|
42 |
nitropack_set_wp_cache_const(true);
|
43 |
$htaccessFile = nitropack_trailingslashit(NITROPACK_DATA_DIR) . ".htaccess";
|
44 |
if (!file_exists($htaccessFile) && get_nitropack()->initDataDir()) {
|
57 |
} else {
|
58 |
setcookie("nitropack_after_activate_notice", 1, time() + 3600);
|
59 |
}
|
60 |
+
opcache_reset();
|
61 |
}
|
62 |
|
63 |
function nitropack_deactivate() {
|
64 |
+
nitropack_set_htaccess_rules(false);
|
65 |
nitropack_set_wp_cache_const(false);
|
66 |
nitropack_uninstall_advanced_cache();
|
67 |
|
74 |
if (get_nitropack()->isConnected()) {
|
75 |
nitropack_event("disable_extension");
|
76 |
}
|
77 |
+
opcache_reset();
|
78 |
}
|
79 |
|
80 |
function nitropack_install_advanced_cache() {
|
158 |
return WP_DEBUG ? file_put_contents($configFilePath, implode("", $lines)) : @file_put_contents($configFilePath, implode("", $lines));
|
159 |
}
|
160 |
|
161 |
+
function nitropack_set_htaccess_rules($status) {
|
162 |
+
if (!apply_filters('nitropack_should_modify_htaccess', false)) return true;
|
163 |
+
|
164 |
+
$htaccessFilePath = nitropack_get_htaccess_path();
|
165 |
+
if (!$htaccessFilePath) return false;
|
166 |
+
|
167 |
+
$htaccessBackupFilePath = $htaccessFilePath . ".nitrobackup";
|
168 |
+
$backupExists = WP_DEBUG ? file_exists($htaccessBackupFilePath) : @file_exists($htaccessBackupFilePath);
|
169 |
+
if (!$backupExists) {
|
170 |
+
$isBackupSuccess = WP_DEBUG ? copy($htaccessFilePath, $htaccessBackupFilePath) : @copy($htaccessFilePath, $htaccessBackupFilePath);
|
171 |
+
if (!$isBackupSuccess) return false;
|
172 |
+
}
|
173 |
+
|
174 |
+
$lines = file($htaccessFilePath);
|
175 |
+
$linesBackup = $lines;
|
176 |
+
|
177 |
+
if (empty($lines)) return false; // We might want to remove this check
|
178 |
+
|
179 |
+
$nitroOpenLine = false;
|
180 |
+
$nitroCloseLine = false;
|
181 |
+
|
182 |
+
foreach ($lines as $lineIndex => &$line) {
|
183 |
+
if (trim($line) == "# BEGIN NITROPACK") {
|
184 |
+
$nitroOpenLine = $lineIndex;
|
185 |
+
}
|
186 |
+
|
187 |
+
if (trim($line) == "# END NITROPACK") {
|
188 |
+
$nitroCloseLine = $lineIndex;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
$nitroLines = [];
|
193 |
+
|
194 |
+
if ( // We either didn't find the NitroPack markers or we found both in the correct order
|
195 |
+
($nitroOpenLine === false && $nitroCloseLine === false) ||
|
196 |
+
($nitroOpenLine !== false && $nitroCloseLine !== false && $nitroCloseLine > $nitroOpenLine)
|
197 |
+
) {
|
198 |
+
$nitroLines[] = "# BEGIN NITROPACK";
|
199 |
+
if ($status) {
|
200 |
+
$rules = apply_filters("nitropack_htaccess_rules", []);
|
201 |
+
|
202 |
+
if (is_string($rules)) {
|
203 |
+
$rules = explode("\n", $rules);
|
204 |
+
}
|
205 |
+
|
206 |
+
if (is_array($rules)) {
|
207 |
+
$nitroLines = array_merge($nitroLines, $rules);
|
208 |
+
}
|
209 |
+
}
|
210 |
+
$nitroLines[] = "# END NITROPACK";
|
211 |
+
$nitroLines = array_map(function($line) { return trim($line) . "\n"; }, $nitroLines);
|
212 |
+
|
213 |
+
// Begin .htaccess modification
|
214 |
+
$offset = $nitroOpenLine !== false ? $nitroOpenLine : 0;
|
215 |
+
$length = $nitroOpenLine !== false ? $nitroCloseLine - $nitroOpenLine + 1 : 0;
|
216 |
+
array_splice($lines, $offset, $length, $nitroLines);
|
217 |
+
$writeResult = WP_DEBUG ? file_put_contents($htaccessFilePath, implode("", $lines)) : @file_put_contents($htaccessFilePath, implode("", $lines));
|
218 |
+
if ($writeResult) {
|
219 |
+
$homeUrl = NULL;
|
220 |
+
$siteConfig = get_nitropack()->getSiteConfig();
|
221 |
+
|
222 |
+
if ($siteConfig && !empty($siteConfig["home_url"])) {
|
223 |
+
$homeUrl = $siteConfig["home_url"];
|
224 |
+
} else if (function_exists(get_home_url())) {
|
225 |
+
$homeUrl = get_home_url();
|
226 |
+
}
|
227 |
+
|
228 |
+
if ($homeUrl) {
|
229 |
+
$homeUrl .= (strpos($homeUrl, "?") === false ? "?" : "&") . "nitroHealthcheck=1";
|
230 |
+
$client = new \NitroPack\HttpClient($homeUrl);
|
231 |
+
$client->setHeader("Accept", "text/html");
|
232 |
+
$client->fetch();
|
233 |
+
if ($client->getStatusCode() != 200) {
|
234 |
+
// Restore the initial version of the file
|
235 |
+
WP_DEBUG ? file_put_contents($htaccessFilePath, implode("", $linesBackup)) : @file_put_contents($htaccessFilePath, implode("", $linesBackup));
|
236 |
+
return false;
|
237 |
+
}
|
238 |
+
} else {
|
239 |
+
return false;
|
240 |
+
}
|
241 |
+
}
|
242 |
+
return $writeResult;
|
243 |
+
}
|
244 |
+
|
245 |
+
return true;
|
246 |
+
}
|
247 |
+
|
248 |
function nitropack_set_batcache_compat($status) {
|
249 |
$currentCompatStatus = defined("NITROPACK_BATCACHE_COMPAT") && NITROPACK_BATCACHE_COMPAT;
|
250 |
if ($currentCompatStatus === $status) return true;
|
379 |
switch($_GET["nitroWebhook"]) {
|
380 |
case "config":
|
381 |
nitropack_fetch_config();
|
382 |
+
get_nitropack()->resetSdkInstances(); // This is needed in order to obtain a new SDK instance with the fresh config
|
383 |
+
nitropack_set_htaccess_rules(true);
|
384 |
break;
|
385 |
case "cache_ready":
|
386 |
if (!empty($_POST["url"])) {
|
649 |
}
|
650 |
}
|
651 |
|
652 |
+
// Uncomment the code below in case object cache interferes with correct URL taggig
|
653 |
+
// The code below will attempt to temporarily disable using the object cache only for the requests coming from NitroPack
|
654 |
+
//wp_using_ext_object_cache(false);
|
655 |
+
//add_action("pre_get_posts", function($query) {
|
656 |
+
// $query->query_vars["cache_results"] = false;
|
657 |
+
//});
|
658 |
+
//
|
659 |
+
//add_filter("all", function() {
|
660 |
+
// $args = func_get_args();
|
661 |
+
// if (count($args) > 1) {
|
662 |
+
// list($filterName, $value) = func_get_args();
|
663 |
+
// if (preg_match("/^transient_(.*)/", $filterName, $matches) && $value) {
|
664 |
+
// return false;
|
665 |
+
// }
|
666 |
+
// }
|
667 |
+
//}, 10, 2);
|
668 |
+
|
669 |
+
add_filter('post_link', 'nitropack_post_link_listener', 10, 3);
|
670 |
add_action('the_post', 'nitropack_handle_the_post');
|
671 |
add_action('wp_footer', 'nitropack_log_tags');
|
672 |
}
|
730 |
{$wpdb->prefix}posts.post_date > '" . date("Y-m-d H:i:s") . "'
|
731 |
AND {$wpdb->prefix}posts.post_type = 'post' AND (({$wpdb->prefix}posts.post_status = 'future')) ORDER BY {$wpdb->prefix}posts.post_date ASC LIMIT 0, 1" );
|
732 |
|
733 |
+
if (!empty($unmodifiedPosts) && strtotime($unmodifiedPosts[0]->post_date) > time()) {
|
734 |
$np_customExpirationTimes[] = strtotime($unmodifiedPosts[0]->post_date);
|
735 |
}
|
736 |
|
741 |
"start_date" => time()
|
742 |
));
|
743 |
|
744 |
+
if (count($events) && strtotime($events[0]->event_date) > time()) {
|
745 |
$np_customExpirationTimes[] = strtotime($events[0]->event_date);
|
746 |
}
|
747 |
}
|
1789 |
} else {
|
1790 |
nitropack_invalidate(NULL, "single:$postID", $reason);
|
1791 |
}
|
1792 |
+
|
1793 |
+
nitropack_invalidate(NULL, "post:$postID", $reason);
|
1794 |
+
|
1795 |
if ($hasImportantChangeInPost === NULL) {
|
1796 |
$hasImportantChangeInPost = nitropack_has_post_important_change($post);
|
1797 |
}
|
1877 |
if (!get_option("nitropack-autoCachePurge", 1)) return;
|
1878 |
|
1879 |
try {
|
1880 |
+
if ($new === "auto-draft" || ($new === "draft" && $old != "publish") || $new === "inherit") { // Creating a new post or draft, don't do anything for now.
|
1881 |
return;
|
1882 |
}
|
1883 |
|
1918 |
nitropack_clean_post_cache($post, array('deleted' => nitropack_get_taxonomies($post)), true, sprintf("Invalidate related pages due to deleting %s '%s'", $nicePostTypeLabel, $post->post_title), true);
|
1919 |
} else if ($new == "private" && $old == "publish") {
|
1920 |
nitropack_clean_post_cache($post, array('deleted' => nitropack_get_taxonomies($post)), true, sprintf("Invalidate related pages due to making %s '%s' private", $nicePostTypeLabel, $post->post_title), true);
|
1921 |
+
} else if ($new == "draft" && $old == "publish") {
|
1922 |
+
nitropack_clean_post_cache($post, array('deleted' => nitropack_get_taxonomies($post)), true, sprintf("Invalidate related pages due to making %s '%s' a draft", $nicePostTypeLabel, $post->post_title), true);
|
1923 |
} else if ($new != "trash") {
|
1924 |
nitropack_clean_post_cache($post);
|
1925 |
$np_loggedWarmups[] = get_permalink($post);
|
1944 |
}
|
1945 |
}
|
1946 |
|
1947 |
+
function nitropack_post_link_listener($permalink, $post, $leavename) {
|
1948 |
+
if (is_object($post)) {
|
1949 |
+
nitropack_handle_the_post($post);
|
1950 |
+
}
|
1951 |
+
|
1952 |
+
return $permalink;
|
1953 |
+
}
|
1954 |
+
|
1955 |
function nitropack_handle_the_post($post) {
|
1956 |
global $np_customExpirationTimes, $np_queriedObj;
|
1957 |
if (defined('POSTEXPIRATOR_VERSION')) {
|
2582 |
return $configFilePath;
|
2583 |
}
|
2584 |
|
2585 |
+
function nitropack_get_htaccess_path() {
|
2586 |
+
$configFilePath = nitropack_trailingslashit(ABSPATH) . ".htaccess";
|
2587 |
+
if (!file_exists($configFilePath)) {
|
2588 |
+
return false;
|
2589 |
+
}
|
2590 |
+
|
2591 |
+
if (!is_writable($configFilePath)) {
|
2592 |
+
return false;
|
2593 |
+
}
|
2594 |
+
|
2595 |
+
return $configFilePath;
|
2596 |
+
}
|
2597 |
+
|
2598 |
function nitropack_detect_hosting() {
|
2599 |
if (\NitroPack\Integration\Hosting\Flywheel::detect()) {
|
2600 |
return "flywheel";
|
2974 |
}
|
2975 |
}
|
2976 |
|
2977 |
+
if ( apply_filters('nitropack_needs_htaccess_changes', false) ) {
|
2978 |
+
if (!nitropack_set_htaccess_rules(true)) {
|
2979 |
+
$warnings[] = "Unable to configure LiteSpeed specific rules for maximum performance. Please make sure your .htaccess file is writable or contact support.";
|
2980 |
+
}
|
2981 |
+
}
|
2982 |
+
|
2983 |
if ( !get_nitropack()->dataDirExists() && !get_nitropack()->initDataDir()) {
|
2984 |
$errors[] = "The NitroPack data directory cannot be created. Please make sure that the /wp-content/ directory is writable and refresh this page.";
|
2985 |
return [
|
main.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: NitroPack
|
4 |
Plugin URI: https://nitropack.io/platform/wordpress
|
5 |
Description: Everything you need for a fast website. Simple set up, easy to use, awesome support. Caching, Lazy Loading, Minification, Defer CSS/JS, CDN and more!
|
6 |
-
Version: 1.5.
|
7 |
Author: NitroPack LLC
|
8 |
Author URI: https://nitropack.io/
|
9 |
License: GPL2
|
3 |
Plugin Name: NitroPack
|
4 |
Plugin URI: https://nitropack.io/platform/wordpress
|
5 |
Description: Everything you need for a fast website. Simple set up, easy to use, awesome support. Caching, Lazy Loading, Minification, Defer CSS/JS, CDN and more!
|
6 |
+
Version: 1.5.13
|
7 |
Author: NitroPack LLC
|
8 |
Author URI: https://nitropack.io/
|
9 |
License: GPL2
|
nitropack-sdk/NitroPack/SDK/NitroPack.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
namespace NitroPack\SDK;
|
3 |
|
4 |
class NitroPack {
|
5 |
-
const VERSION = '0.
|
6 |
const PAGECACHE_LOCK_EXPIRATION_TIME = 300; // in seconds
|
7 |
private $dataDir;
|
8 |
private $cachePath = array('data', 'pagecache');
|
@@ -146,6 +146,7 @@ class NitroPack {
|
|
146 |
$this->url = $urlInfo->getNormalized();
|
147 |
|
148 |
$this->pageCache = new Pagecache($this->url, $this->userAgent, $this->supportedCookiesFilter(self::getCookies()), $this->config->PageCache->SupportedCookies, $this->isAJAXRequest());
|
|
|
149 |
if ($this->isAJAXRequest() && $this->isAllowedAJAXUrl($this->url) && !empty($_SERVER["HTTP_REFERER"])) {
|
150 |
$refererInfo = new \NitroPack\Url($_SERVER["HTTP_REFERER"]);
|
151 |
$this->pageCache->setReferer($refererInfo->getNormalized());
|
@@ -164,6 +165,10 @@ class NitroPack {
|
|
164 |
$this->useCompression = false;
|
165 |
}
|
166 |
|
|
|
|
|
|
|
|
|
167 |
public function supportedCookiesFilter($cookies) {
|
168 |
$supportedCookies = array();
|
169 |
foreach ($cookies as $cookieName=>$cookieValue) {
|
2 |
namespace NitroPack\SDK;
|
3 |
|
4 |
class NitroPack {
|
5 |
+
const VERSION = '0.50.0';
|
6 |
const PAGECACHE_LOCK_EXPIRATION_TIME = 300; // in seconds
|
7 |
private $dataDir;
|
8 |
private $cachePath = array('data', 'pagecache');
|
146 |
$this->url = $urlInfo->getNormalized();
|
147 |
|
148 |
$this->pageCache = new Pagecache($this->url, $this->userAgent, $this->supportedCookiesFilter(self::getCookies()), $this->config->PageCache->SupportedCookies, $this->isAJAXRequest());
|
149 |
+
$this->pageCache->setCookiesProvider([$this, "getPagecacheCookies"]);
|
150 |
if ($this->isAJAXRequest() && $this->isAllowedAJAXUrl($this->url) && !empty($_SERVER["HTTP_REFERER"])) {
|
151 |
$refererInfo = new \NitroPack\Url($_SERVER["HTTP_REFERER"]);
|
152 |
$this->pageCache->setReferer($refererInfo->getNormalized());
|
165 |
$this->useCompression = false;
|
166 |
}
|
167 |
|
168 |
+
public function getPagecacheCookies() {
|
169 |
+
return $this->supportedCookiesFilter(self::getCookies());
|
170 |
+
}
|
171 |
+
|
172 |
public function supportedCookiesFilter($cookies) {
|
173 |
$supportedCookies = array();
|
174 |
foreach ($cookies as $cookieName=>$cookieValue) {
|
nitropack-sdk/NitroPack/SDK/Pagecache.php
CHANGED
@@ -13,6 +13,7 @@ class Pagecache {
|
|
13 |
protected $useCompression;
|
14 |
protected $useInvalidated;
|
15 |
private $urlPathVersion;
|
|
|
16 |
|
17 |
public static function getUrlDir($dataDir, $url, $useInvalidated = false, $pathVersion = 1) {
|
18 |
$safeUrl = str_replace(array('/','?',':',';','=','&','.','--','%','~'),'-', $url);
|
@@ -45,6 +46,7 @@ class Pagecache {
|
|
45 |
$this->Device = new Device($userAgent);
|
46 |
$this->useCompression = false;
|
47 |
$this->useInvalidated = false;
|
|
|
48 |
$this->setUrlPathVersion(1);
|
49 |
$this->setReferer($referer);
|
50 |
}
|
@@ -111,6 +113,10 @@ class Pagecache {
|
|
111 |
}
|
112 |
}
|
113 |
|
|
|
|
|
|
|
|
|
114 |
public function hasCache() {
|
115 |
// If there is no cache for the parent we do not need to check cache existance for the current object, because we only serve AJAX cache for pages already cached by NitroPack
|
116 |
if ($this->parent && !$this->parent->hasCache()) return false;
|
@@ -288,9 +294,11 @@ class Pagecache {
|
|
288 |
private function cookiePrefix() {
|
289 |
$prefix = '';
|
290 |
|
291 |
-
|
|
|
|
|
292 |
|
293 |
-
foreach ($
|
294 |
foreach ($this->supportedCookies as $cookie) {
|
295 |
if (preg_match('/' . NitroPack::wildcardToRegex($cookie) . '/', $cookieName)) {
|
296 |
$prefix .= $cookieName.'='.$cookieValue.';';
|
13 |
protected $useCompression;
|
14 |
protected $useInvalidated;
|
15 |
private $urlPathVersion;
|
16 |
+
private $cookiesProvider;
|
17 |
|
18 |
public static function getUrlDir($dataDir, $url, $useInvalidated = false, $pathVersion = 1) {
|
19 |
$safeUrl = str_replace(array('/','?',':',';','=','&','.','--','%','~'),'-', $url);
|
46 |
$this->Device = new Device($userAgent);
|
47 |
$this->useCompression = false;
|
48 |
$this->useInvalidated = false;
|
49 |
+
$this->cookiesProvider = NULL;
|
50 |
$this->setUrlPathVersion(1);
|
51 |
$this->setReferer($referer);
|
52 |
}
|
113 |
}
|
114 |
}
|
115 |
|
116 |
+
public function setCookiesProvider($provider) {
|
117 |
+
$this->cookiesProvider = $provider;
|
118 |
+
}
|
119 |
+
|
120 |
public function hasCache() {
|
121 |
// If there is no cache for the parent we do not need to check cache existance for the current object, because we only serve AJAX cache for pages already cached by NitroPack
|
122 |
if ($this->parent && !$this->parent->hasCache()) return false;
|
294 |
private function cookiePrefix() {
|
295 |
$prefix = '';
|
296 |
|
297 |
+
$cookies = $this->cookiesProvider ? call_user_func($this->cookiesProvider) : $this->cookies;
|
298 |
+
|
299 |
+
ksort($cookies);
|
300 |
|
301 |
+
foreach ($cookies as $cookieName=>$cookieValue) {
|
302 |
foreach ($this->supportedCookies as $cookie) {
|
303 |
if (preg_match('/' . NitroPack::wildcardToRegex($cookie) . '/', $cookieName)) {
|
304 |
$prefix .= $cookieName.'='.$cookieValue.';';
|
nitropack-sdk/vendor/autoload.php
CHANGED
@@ -2,6 +2,11 @@
|
|
2 |
|
3 |
// autoload.php @generated by Composer
|
4 |
|
|
|
|
|
|
|
|
|
|
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
2 |
|
3 |
// autoload.php @generated by Composer
|
4 |
|
5 |
+
if (PHP_VERSION_ID < 50600) {
|
6 |
+
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
7 |
+
exit(1);
|
8 |
+
}
|
9 |
+
|
10 |
require_once __DIR__ . '/composer/autoload_real.php';
|
11 |
|
12 |
+
return ComposerAutoloaderInit8fcbb1a5ffa2542d92b974779798cb81::getLoader();
|
nitropack-sdk/vendor/composer/InstalledVersions.php
CHANGED
@@ -21,12 +21,14 @@ use Composer\Semver\VersionParser;
|
|
21 |
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
22 |
*
|
23 |
* To require its presence, you can require `composer-runtime-api ^2.0`
|
|
|
|
|
24 |
*/
|
25 |
class InstalledVersions
|
26 |
{
|
27 |
/**
|
28 |
* @var mixed[]|null
|
29 |
-
* @psalm-var array{root: array{name: string,
|
30 |
*/
|
31 |
private static $installed;
|
32 |
|
@@ -37,7 +39,7 @@ class InstalledVersions
|
|
37 |
|
38 |
/**
|
39 |
* @var array[]
|
40 |
-
* @psalm-var array<string, array{root: array{name: string,
|
41 |
*/
|
42 |
private static $installedByVendor = array();
|
43 |
|
@@ -241,7 +243,7 @@ class InstalledVersions
|
|
241 |
|
242 |
/**
|
243 |
* @return array
|
244 |
-
* @psalm-return array{name: string,
|
245 |
*/
|
246 |
public static function getRootPackage()
|
247 |
{
|
@@ -255,7 +257,7 @@ class InstalledVersions
|
|
255 |
*
|
256 |
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
257 |
* @return array[]
|
258 |
-
* @psalm-return array{root: array{name: string,
|
259 |
*/
|
260 |
public static function getRawData()
|
261 |
{
|
@@ -278,7 +280,7 @@ class InstalledVersions
|
|
278 |
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
279 |
*
|
280 |
* @return array[]
|
281 |
-
* @psalm-return list<array{root: array{name: string,
|
282 |
*/
|
283 |
public static function getAllRawData()
|
284 |
{
|
@@ -301,7 +303,7 @@ class InstalledVersions
|
|
301 |
* @param array[] $data A vendor/composer/installed.php data set
|
302 |
* @return void
|
303 |
*
|
304 |
-
* @psalm-param array{root: array{name: string,
|
305 |
*/
|
306 |
public static function reload($data)
|
307 |
{
|
@@ -311,7 +313,7 @@ class InstalledVersions
|
|
311 |
|
312 |
/**
|
313 |
* @return array[]
|
314 |
-
* @psalm-return list<array{root: array{name: string,
|
315 |
*/
|
316 |
private static function getInstalled()
|
317 |
{
|
21 |
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
22 |
*
|
23 |
* To require its presence, you can require `composer-runtime-api ^2.0`
|
24 |
+
*
|
25 |
+
* @final
|
26 |
*/
|
27 |
class InstalledVersions
|
28 |
{
|
29 |
/**
|
30 |
* @var mixed[]|null
|
31 |
+
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
32 |
*/
|
33 |
private static $installed;
|
34 |
|
39 |
|
40 |
/**
|
41 |
* @var array[]
|
42 |
+
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
43 |
*/
|
44 |
private static $installedByVendor = array();
|
45 |
|
243 |
|
244 |
/**
|
245 |
* @return array
|
246 |
+
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
247 |
*/
|
248 |
public static function getRootPackage()
|
249 |
{
|
257 |
*
|
258 |
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
259 |
* @return array[]
|
260 |
+
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
261 |
*/
|
262 |
public static function getRawData()
|
263 |
{
|
280 |
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
281 |
*
|
282 |
* @return array[]
|
283 |
+
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
284 |
*/
|
285 |
public static function getAllRawData()
|
286 |
{
|
303 |
* @param array[] $data A vendor/composer/installed.php data set
|
304 |
* @return void
|
305 |
*
|
306 |
+
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
307 |
*/
|
308 |
public static function reload($data)
|
309 |
{
|
313 |
|
314 |
/**
|
315 |
* @return array[]
|
316 |
+
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
317 |
*/
|
318 |
private static function getInstalled()
|
319 |
{
|
nitropack-sdk/vendor/composer/autoload_classmap.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_classmap.php @generated by Composer
|
4 |
|
5 |
-
$vendorDir = dirname(
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
2 |
|
3 |
// autoload_classmap.php @generated by Composer
|
4 |
|
5 |
+
$vendorDir = dirname(__DIR__);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
nitropack-sdk/vendor/composer/autoload_namespaces.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_namespaces.php @generated by Composer
|
4 |
|
5 |
-
$vendorDir = dirname(
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
2 |
|
3 |
// autoload_namespaces.php @generated by Composer
|
4 |
|
5 |
+
$vendorDir = dirname(__DIR__);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
nitropack-sdk/vendor/composer/autoload_psr4.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_psr4.php @generated by Composer
|
4 |
|
5 |
-
$vendorDir = dirname(
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
2 |
|
3 |
// autoload_psr4.php @generated by Composer
|
4 |
|
5 |
+
$vendorDir = dirname(__DIR__);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
nitropack-sdk/vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -22,31 +22,12 @@ class ComposerAutoloaderInit3dcb0cd3b9802939155e959c3c6cfd5d
|
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
-
spl_autoload_register(array('
|
26 |
-
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(
|
27 |
-
spl_autoload_unregister(array('
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
require __DIR__ . '/autoload_static.php';
|
32 |
-
|
33 |
-
call_user_func(\Composer\Autoload\ComposerStaticInit3dcb0cd3b9802939155e959c3c6cfd5d::getInitializer($loader));
|
34 |
-
} else {
|
35 |
-
$map = require __DIR__ . '/autoload_namespaces.php';
|
36 |
-
foreach ($map as $namespace => $path) {
|
37 |
-
$loader->set($namespace, $path);
|
38 |
-
}
|
39 |
-
|
40 |
-
$map = require __DIR__ . '/autoload_psr4.php';
|
41 |
-
foreach ($map as $namespace => $path) {
|
42 |
-
$loader->setPsr4($namespace, $path);
|
43 |
-
}
|
44 |
-
|
45 |
-
$classMap = require __DIR__ . '/autoload_classmap.php';
|
46 |
-
if ($classMap) {
|
47 |
-
$loader->addClassMap($classMap);
|
48 |
-
}
|
49 |
-
}
|
50 |
|
51 |
$loader->register(true);
|
52 |
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit8fcbb1a5ffa2542d92b974779798cb81
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
22 |
return self::$loader;
|
23 |
}
|
24 |
|
25 |
+
spl_autoload_register(array('ComposerAutoloaderInit8fcbb1a5ffa2542d92b974779798cb81', 'loadClassLoader'), true, true);
|
26 |
+
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
27 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit8fcbb1a5ffa2542d92b974779798cb81', 'loadClassLoader'));
|
28 |
+
|
29 |
+
require __DIR__ . '/autoload_static.php';
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit8fcbb1a5ffa2542d92b974779798cb81::getInitializer($loader));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
$loader->register(true);
|
33 |
|
nitropack-sdk/vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'N' =>
|
@@ -33,9 +33,9 @@ class ComposerStaticInit3dcb0cd3b9802939155e959c3c6cfd5d
|
|
33 |
public static function getInitializer(ClassLoader $loader)
|
34 |
{
|
35 |
return \Closure::bind(function () use ($loader) {
|
36 |
-
$loader->prefixLengthsPsr4 =
|
37 |
-
$loader->prefixDirsPsr4 =
|
38 |
-
$loader->classMap =
|
39 |
|
40 |
}, null, ClassLoader::class);
|
41 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit8fcbb1a5ffa2542d92b974779798cb81
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'N' =>
|
33 |
public static function getInitializer(ClassLoader $loader)
|
34 |
{
|
35 |
return \Closure::bind(function () use ($loader) {
|
36 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit8fcbb1a5ffa2542d92b974779798cb81::$prefixLengthsPsr4;
|
37 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit8fcbb1a5ffa2542d92b974779798cb81::$prefixDirsPsr4;
|
38 |
+
$loader->classMap = ComposerStaticInit8fcbb1a5ffa2542d92b974779798cb81::$classMap;
|
39 |
|
40 |
}, null, ClassLoader::class);
|
41 |
}
|
nitropack-sdk/vendor/composer/installed.json
CHANGED
@@ -7,12 +7,12 @@
|
|
7 |
"source": {
|
8 |
"type": "git",
|
9 |
"url": "git@bitbucket.org:nitropack/httpclient.git",
|
10 |
-
"reference": "
|
11 |
},
|
12 |
"require": {
|
13 |
"nitropack/url": "dev-master"
|
14 |
},
|
15 |
-
"time": "
|
16 |
"default-branch": true,
|
17 |
"type": "library",
|
18 |
"installation-source": "source",
|
@@ -42,12 +42,12 @@
|
|
42 |
"source": {
|
43 |
"type": "git",
|
44 |
"url": "git@bitbucket.org:nitropack/url.git",
|
45 |
-
"reference": "
|
46 |
},
|
47 |
"require-dev": {
|
48 |
"phpunit/phpunit": "^9"
|
49 |
},
|
50 |
-
"time": "2022-
|
51 |
"default-branch": true,
|
52 |
"type": "library",
|
53 |
"installation-source": "source",
|
@@ -71,6 +71,6 @@
|
|
71 |
"install-path": "../nitropack/url"
|
72 |
}
|
73 |
],
|
74 |
-
"dev":
|
75 |
"dev-package-names": []
|
76 |
}
|
7 |
"source": {
|
8 |
"type": "git",
|
9 |
"url": "git@bitbucket.org:nitropack/httpclient.git",
|
10 |
+
"reference": "143a55343664f01873f2ddc79e88c9ee65cbd2dd"
|
11 |
},
|
12 |
"require": {
|
13 |
"nitropack/url": "dev-master"
|
14 |
},
|
15 |
+
"time": "2022-06-22T09:15:34+00:00",
|
16 |
"default-branch": true,
|
17 |
"type": "library",
|
18 |
"installation-source": "source",
|
42 |
"source": {
|
43 |
"type": "git",
|
44 |
"url": "git@bitbucket.org:nitropack/url.git",
|
45 |
+
"reference": "c6662db42d29e5746e4f0dad88a2bd45232bab49"
|
46 |
},
|
47 |
"require-dev": {
|
48 |
"phpunit/phpunit": "^9"
|
49 |
},
|
50 |
+
"time": "2022-07-28T16:06:45+00:00",
|
51 |
"default-branch": true,
|
52 |
"type": "library",
|
53 |
"installation-source": "source",
|
71 |
"install-path": "../nitropack/url"
|
72 |
}
|
73 |
],
|
74 |
+
"dev": true,
|
75 |
"dev-package-names": []
|
76 |
}
|
nitropack-sdk/vendor/composer/installed.php
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
<?php return array(
|
2 |
'root' => array(
|
|
|
3 |
'pretty_version' => 'dev-master',
|
4 |
'version' => 'dev-master',
|
|
|
5 |
'type' => 'package',
|
6 |
'install_path' => __DIR__ . '/../../',
|
7 |
'aliases' => array(),
|
8 |
-
'
|
9 |
-
'name' => 'nitropack/nitropackcloud-sdk',
|
10 |
-
'dev' => false,
|
11 |
),
|
12 |
'versions' => array(
|
13 |
'nitropack/httpclient' => array(
|
14 |
'pretty_version' => 'dev-master',
|
15 |
'version' => 'dev-master',
|
|
|
16 |
'type' => 'library',
|
17 |
'install_path' => __DIR__ . '/../nitropack/httpclient',
|
18 |
'aliases' => array(
|
19 |
0 => '9999999-dev',
|
20 |
),
|
21 |
-
'reference' => 'ae92c176c1800a7ebf817f39d76324664290c958',
|
22 |
'dev_requirement' => false,
|
23 |
),
|
24 |
'nitropack/nitropackcloud-sdk' => array(
|
25 |
'pretty_version' => 'dev-master',
|
26 |
'version' => 'dev-master',
|
|
|
27 |
'type' => 'package',
|
28 |
'install_path' => __DIR__ . '/../../',
|
29 |
'aliases' => array(),
|
30 |
-
'reference' => 'd078ce9ee21e856b364bd578db356773df01584b',
|
31 |
'dev_requirement' => false,
|
32 |
),
|
33 |
'nitropack/url' => array(
|
34 |
'pretty_version' => 'dev-master',
|
35 |
'version' => 'dev-master',
|
|
|
36 |
'type' => 'library',
|
37 |
'install_path' => __DIR__ . '/../nitropack/url',
|
38 |
'aliases' => array(
|
39 |
0 => '9999999-dev',
|
40 |
),
|
41 |
-
'reference' => 'faf6a956debd6e4f9ae9d45c8d3e0e763ca79d06',
|
42 |
'dev_requirement' => false,
|
43 |
),
|
44 |
),
|
1 |
<?php return array(
|
2 |
'root' => array(
|
3 |
+
'name' => 'nitropack/nitropackcloud-sdk',
|
4 |
'pretty_version' => 'dev-master',
|
5 |
'version' => 'dev-master',
|
6 |
+
'reference' => '68159c0e85c7117da2511caece6494e8c2ecff5e',
|
7 |
'type' => 'package',
|
8 |
'install_path' => __DIR__ . '/../../',
|
9 |
'aliases' => array(),
|
10 |
+
'dev' => true,
|
|
|
|
|
11 |
),
|
12 |
'versions' => array(
|
13 |
'nitropack/httpclient' => array(
|
14 |
'pretty_version' => 'dev-master',
|
15 |
'version' => 'dev-master',
|
16 |
+
'reference' => '143a55343664f01873f2ddc79e88c9ee65cbd2dd',
|
17 |
'type' => 'library',
|
18 |
'install_path' => __DIR__ . '/../nitropack/httpclient',
|
19 |
'aliases' => array(
|
20 |
0 => '9999999-dev',
|
21 |
),
|
|
|
22 |
'dev_requirement' => false,
|
23 |
),
|
24 |
'nitropack/nitropackcloud-sdk' => array(
|
25 |
'pretty_version' => 'dev-master',
|
26 |
'version' => 'dev-master',
|
27 |
+
'reference' => '68159c0e85c7117da2511caece6494e8c2ecff5e',
|
28 |
'type' => 'package',
|
29 |
'install_path' => __DIR__ . '/../../',
|
30 |
'aliases' => array(),
|
|
|
31 |
'dev_requirement' => false,
|
32 |
),
|
33 |
'nitropack/url' => array(
|
34 |
'pretty_version' => 'dev-master',
|
35 |
'version' => 'dev-master',
|
36 |
+
'reference' => 'c6662db42d29e5746e4f0dad88a2bd45232bab49',
|
37 |
'type' => 'library',
|
38 |
'install_path' => __DIR__ . '/../nitropack/url',
|
39 |
'aliases' => array(
|
40 |
0 => '9999999-dev',
|
41 |
),
|
|
|
42 |
'dev_requirement' => false,
|
43 |
),
|
44 |
),
|
nitropack-sdk/vendor/nitropack/httpclient/src/HttpClient.php
CHANGED
@@ -767,7 +767,7 @@ class HttpClient {
|
|
767 |
}
|
768 |
|
769 |
$host = $this->host;
|
770 |
-
$reuseKey = implode(':', array($host, $port));
|
771 |
if (isset(self::$connections[$reuseKey])) {
|
772 |
foreach (self::$connections[$reuseKey] as $sock) {
|
773 |
if (!in_array($sock, HttpClient::$free_connections)) continue;
|
@@ -1339,7 +1339,7 @@ class HttpClient {
|
|
1339 |
$cookies_combined = array();
|
1340 |
if (is_array($this->cookies)) {
|
1341 |
foreach ($this->cookies as $domain=>$cookies) {
|
1342 |
-
if (preg_match("/".preg_quote(ltrim($domain, "."))."$/", $this->host)) {
|
1343 |
foreach ($cookies as $name=>$value) {
|
1344 |
if (is_array($value)) {
|
1345 |
foreach ($value as $k=>$v) {
|
@@ -1436,17 +1436,18 @@ class HttpClient {
|
|
1436 |
|
1437 |
register_shutdown_function(array("\NitroPack\HttpClient", "drainConnections"));
|
1438 |
|
1439 |
-
class
|
1440 |
-
class
|
1441 |
-
class
|
1442 |
-
class
|
1443 |
-
class
|
1444 |
-
class
|
1445 |
-
class
|
1446 |
-
class
|
|
|
1447 |
class SocketTlsTimedOutException extends SocketConTimedOutException {}
|
1448 |
class SocketReadTimedOutException extends SocketConTimedOutException {}
|
1449 |
-
class SocketClosedUnexpectedlyException extends
|
1450 |
-
class ResponseTooLargeException extends
|
1451 |
-
class ChunkSizeException extends
|
1452 |
-
class RedirectException extends
|
767 |
}
|
768 |
|
769 |
$host = $this->host;
|
770 |
+
$reuseKey = implode(':', array($this->host, $this->port));
|
771 |
if (isset(self::$connections[$reuseKey])) {
|
772 |
foreach (self::$connections[$reuseKey] as $sock) {
|
773 |
if (!in_array($sock, HttpClient::$free_connections)) continue;
|
1339 |
$cookies_combined = array();
|
1340 |
if (is_array($this->cookies)) {
|
1341 |
foreach ($this->cookies as $domain=>$cookies) {
|
1342 |
+
if (preg_match("/".preg_quote(ltrim($domain, "."), "/")."$/", $this->host)) {
|
1343 |
foreach ($cookies as $name=>$value) {
|
1344 |
if (is_array($value)) {
|
1345 |
foreach ($value as $k=>$v) {
|
1436 |
|
1437 |
register_shutdown_function(array("\NitroPack\HttpClient", "drainConnections"));
|
1438 |
|
1439 |
+
class HttpClientException extends Exception {}
|
1440 |
+
class URLException extends HttpClientException {}
|
1441 |
+
class URLEmptyException extends HttpClientException {}
|
1442 |
+
class URLInvalidException extends HttpClientException {}
|
1443 |
+
class URLUnsupportedProtocolException extends HttpClientException {}
|
1444 |
+
class SocketOpenException extends HttpClientException {}
|
1445 |
+
class SocketWriteException extends HttpClientException {}
|
1446 |
+
class SocketReadException extends HttpClientException {}
|
1447 |
+
class SocketConTimedOutException extends HttpClientException {}
|
1448 |
class SocketTlsTimedOutException extends SocketConTimedOutException {}
|
1449 |
class SocketReadTimedOutException extends SocketConTimedOutException {}
|
1450 |
+
class SocketClosedUnexpectedlyException extends HttpClientException {}
|
1451 |
+
class ResponseTooLargeException extends HttpClientException {}
|
1452 |
+
class ChunkSizeException extends HttpClientException {}
|
1453 |
+
class RedirectException extends HttpClientException {}
|
nitropack-sdk/vendor/nitropack/url/src/Url.php
CHANGED
@@ -103,6 +103,13 @@ class Url {
|
|
103 |
public function getRootUrl() { return $this->rootUrl; }
|
104 |
public function getRelativePath() { return $this->relativePath; }
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
public function setBaseUrl($url) {
|
107 |
if ($url instanceof Url) {
|
108 |
$this->base = $url;
|
103 |
public function getRootUrl() { return $this->rootUrl; }
|
104 |
public function getRelativePath() { return $this->relativePath; }
|
105 |
|
106 |
+
public function setScheme($scheme) { $this->scheme = $scheme; }
|
107 |
+
public function setPort($port) { $this->port = $port; }
|
108 |
+
public function setHost($host) { $this->host = $host; }
|
109 |
+
public function setPath($path) { $this->path = $path; }
|
110 |
+
public function setQuery($query) { $this->query = $query; }
|
111 |
+
public function setHash($hash) { $this->hash = $hash; }
|
112 |
+
|
113 |
public function setBaseUrl($url) {
|
114 |
if ($url instanceof Url) {
|
115 |
$this->base = $url;
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: nitropack
|
3 |
Tags: cache,perfomance,optimize,pagespeed,lazy load,cdn,critical css,compression,defer css javascript,minify css,minify,webp
|
4 |
Requires at least: 4.7
|
5 |
-
Tested up to:
|
6 |
-
Requires PHP: 5.
|
7 |
-
Stable tag: 1.5.
|
8 |
License: GNU General Public License, version 2
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -169,6 +169,14 @@ No. We’ve designed NitroPack to be a very lightweight solution that adds no CP
|
|
169 |
|
170 |
== Changelog ==
|
171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
= 1.5.12 =
|
173 |
* Improvement: Add exclude for a healtcheck endpoint in Pagely
|
174 |
* Bug fix: Resolve compatibility issues related to Aelia Currency Switcher
|
2 |
Contributors: nitropack
|
3 |
Tags: cache,perfomance,optimize,pagespeed,lazy load,cdn,critical css,compression,defer css javascript,minify css,minify,webp
|
4 |
Requires at least: 4.7
|
5 |
+
Tested up to: 6.0.1
|
6 |
+
Requires PHP: 5.6
|
7 |
+
Stable tag: 1.5.13
|
8 |
License: GNU General Public License, version 2
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
169 |
|
170 |
== Changelog ==
|
171 |
|
172 |
+
= 1.5.13 =
|
173 |
+
* New Feature: Completely compatible with LiteSpeed servers
|
174 |
+
* Improvement: The help button is now an interactive widget
|
175 |
+
* Improvement: Full compatibility with WPX Cloud
|
176 |
+
* Improvement: Resolve an occasional issue with the cache layer on Pressable
|
177 |
+
* Improvement: Overall stability improvements
|
178 |
+
* Bug fix: Correctly purge cache when a post transitions to a draft state
|
179 |
+
|
180 |
= 1.5.12 =
|
181 |
* Improvement: Add exclude for a healtcheck endpoint in Pagely
|
182 |
* Bug fix: Resolve compatibility issues related to Aelia Currency Switcher
|
view/admin.php
CHANGED
@@ -26,9 +26,27 @@
|
|
26 |
</form>
|
27 |
</div>
|
28 |
<?php if (NITROPACK_SUPPORT_BUBBLE_VISIBLE) { ?>
|
29 |
-
<div class="
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
<?php } ?>
|
33 |
<script>
|
34 |
(function($) {
|
26 |
</form>
|
27 |
</div>
|
28 |
<?php if (NITROPACK_SUPPORT_BUBBLE_VISIBLE) { ?>
|
29 |
+
<div class="support-widget">
|
30 |
+
<!-- zendesk widget -->
|
31 |
+
<script type="text/javascript">
|
32 |
+
jQuery(document).ready(function(){
|
33 |
+
window.zESettings = {
|
34 |
+
webWidget: {
|
35 |
+
offset: {
|
36 |
+
vertical: '24px',
|
37 |
+
mobile: {
|
38 |
+
vertical: '24px'
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
};
|
43 |
+
|
44 |
+
zE('webWidget', 'setLocale', 'en-US');
|
45 |
+
zE('webWidget', 'helpCenter:setSuggestions', { labels: ['wordpress_plugin_help'] });
|
46 |
+
});
|
47 |
+
</script>
|
48 |
+
<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=6ba5e4cd-1924-45ee-b2fa-39317be2c2aa"></script>
|
49 |
+
<!-- end zendesk widget -->
|
50 |
<?php } ?>
|
51 |
<script>
|
52 |
(function($) {
|