NitroPack - Version 1.5.9

Version Description

  • New Feature: Compatibility with DreamPress hosting
  • Improvement: Full compatibility with Pressable's caching layer
  • Improvement: Full compatibility with Rocket.net's caching layer
  • Improvement: Overall stability improvements
  • Bug fix: Resolve an issue where separate URLs were incorrectly using the same cache files
  • Bug fix: Switching between prod and staging environments no-longer causes issues with cache sync
Download this release

Release Info

Developer nitropack
Plugin Icon 128x128 NitroPack
Version 1.5.9
Comparing to
See all releases

Code changes from version 1.5.8 to 1.5.9

classes/Integration.php CHANGED
@@ -24,6 +24,7 @@ class Integration {
24
  "NitroPack/Integration/Hosting/Pressable",
25
  "NitroPack/Integration/Hosting/RocketNet",
26
  "NitroPack/Integration/Hosting/Savvii",
 
27
  "NitroPack/Integration/Server/LiteSpeed",
28
  "NitroPack/Integration/Server/Fastly",
29
  "NitroPack/Integration/Server/Cloudflare",
24
  "NitroPack/Integration/Hosting/Pressable",
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",
classes/Integration/Hosting/Cloudways.php CHANGED
@@ -24,7 +24,7 @@ class Cloudways extends Hosting {
24
  $purger = new \NitroPack\SDK\Integrations\Varnish(array("127.0.0.1"), "URLPURGE");
25
  $purger->purge($url);
26
  } catch (\Exception $e) {
27
- // Breeze exception
28
  }
29
  }
30
 
24
  $purger = new \NitroPack\SDK\Integrations\Varnish(array("127.0.0.1"), "URLPURGE");
25
  $purger->purge($url);
26
  } catch (\Exception $e) {
27
+ // Exception
28
  }
29
  }
30
 
classes/Integration/Hosting/DreamHost.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace NitroPack\Integration\Hosting;
4
+
5
+ class DreamHost extends Hosting {
6
+ const STAGE = "very_early";
7
+
8
+ public static function detect() {
9
+ // Detect DreamPress
10
+ return preg_match("/^dp-.+/", gethostname());
11
+ }
12
+
13
+ public function init($stage) {
14
+ if ($this->getHosting() == "dreamhost") {
15
+ add_action('nitropack_execute_purge_url', [$this, 'purgeUrl']);
16
+ add_action('nitropack_execute_purge_all', [$this, 'purgeAll']);
17
+ add_action('nitropack_early_cache_headers', [$this, 'setCacheControl']);
18
+ add_action('nitropack_cacheable_cache_headers', [$this, 'setCacheControl']);
19
+ add_action('nitropack_cachehit_cache_headers', [$this, 'setCacheControl']);
20
+ }
21
+ }
22
+
23
+ public function purgeUrl($url) {
24
+ try {
25
+ $urlObj = new \NitroPack\Url($url);
26
+ $purgeUrl = "https://" . $urlObj->getHost() . $urlObj->getPath();
27
+ if ($urlObj->getQuery()) {
28
+ $purger = new \NitroPack\SDK\Integrations\Varnish(array($_SERVER["SERVER_ADDR"]), "PURGE", ["x-purge-method" => "regex"]);
29
+ $purgeUrl .= ".*";
30
+ } else {
31
+ $purger = new \NitroPack\SDK\Integrations\Varnish(array($_SERVER["SERVER_ADDR"]), "PURGE", ["x-purge-method" => "default"]);
32
+ }
33
+ $purger->purge($purgeUrl);
34
+ } catch (\Exception $e) {
35
+ // Exception
36
+ }
37
+ }
38
+
39
+ public function purgeAll() {
40
+ try {
41
+ $siteConfig = nitropack_get_site_config();
42
+ if(!empty($siteConfig['home_url'])) {
43
+ $homepage = nitropack_trailingslashit($siteConfig['home_url']) . '.*';
44
+ $purger = new \NitroPack\SDK\Integrations\Varnish(array($_SERVER["SERVER_ADDR"]), "PURGE", ["x-purge-method" => "regex"]);
45
+ $purger->purge($homepage);
46
+ }
47
+ } catch (\Exception $e) {
48
+ // Exception
49
+ }
50
+ }
51
+
52
+ public function setCacheControl() {
53
+ header("Vary: sec-ch-ua-mobile");
54
+ if (isset($_SERVER["HTTP_SEC_CH_UA_MOBILE"])) {
55
+ header("Cache-Control: public, max-age=0, s-maxage=3600"); // needs to be like that instead of Cache-Control: no-cache in order to allow caching in the provided reverse proxy, but prevent the browsers from doing so
56
+ } else {
57
+ header("Cache-Control: no-cache");
58
+ return;
59
+ }
60
+ }
61
+ }
classes/Integration/Hosting/Pressable.php CHANGED
@@ -48,30 +48,18 @@ class Pressable extends Hosting {
48
  }
49
 
50
  public function cacheLong() {
51
- $this->cacheShort();
52
- // Purging single cache files doesn't work yet, so we still cannot afford long cache times
53
- //global $batcache;
54
 
55
- //if (!empty($batcache)) {
56
- // $batcache->max_age = 300;
57
- //}
58
  }
59
 
60
  public function purgeUrl($url) {
61
- global $batcache, $wp_object_cache;
62
 
63
  if (!$batcache) return;
64
 
65
- if (!$wp_object_cache) {
66
- wp_cache_init();
67
- }
68
-
69
- /* This doesn't look to be needed based on dumps of the wp_object_cache object
70
- if (!$this->configuredCacheGroups) {
71
- $batcache->configure_groups();
72
- $this->configuredCacheGroups = true;
73
- }*/
74
-
75
  $urlObj = new \NitroPack\Url($url);
76
  if ($urlObj->getHost()) {
77
  parse_str($urlObj->getQuery(), $query);
@@ -96,11 +84,13 @@ class Pressable extends Hosting {
96
  if ( $urlObj->getScheme() == "https" )
97
  $keys['ssl'] = true;
98
 
 
 
 
99
  foreach ($this->deviceTypes as $deviceType) {
100
  $keys["extra"] = [$deviceType];
101
  $url_key = md5(serialize($keys));
102
 
103
- // The $url_key matches the key which batcache used to cache the page, but for some reason this doesn't delete the cache here
104
  wp_cache_delete( $url_key, $batcache->group );
105
  }
106
  }
48
  }
49
 
50
  public function cacheLong() {
51
+ global $batcache;
 
 
52
 
53
+ if (!empty($batcache)) {
54
+ $batcache->max_age = 300;
55
+ }
56
  }
57
 
58
  public function purgeUrl($url) {
59
+ global $batcache;
60
 
61
  if (!$batcache) return;
62
 
 
 
 
 
 
 
 
 
 
 
63
  $urlObj = new \NitroPack\Url($url);
64
  if ($urlObj->getHost()) {
65
  parse_str($urlObj->getQuery(), $query);
84
  if ( $urlObj->getScheme() == "https" )
85
  $keys['ssl'] = true;
86
 
87
+ wp_cache_init();
88
+ $batcache->configure_groups();
89
+
90
  foreach ($this->deviceTypes as $deviceType) {
91
  $keys["extra"] = [$deviceType];
92
  $url_key = md5(serialize($keys));
93
 
 
94
  wp_cache_delete( $url_key, $batcache->group );
95
  }
96
  }
classes/Integration/Hosting/RocketNet.php CHANGED
@@ -10,18 +10,27 @@ class RocketNet extends Hosting {
10
  }
11
 
12
  public function init($stage) {
13
- if ($this->getHosting() == "rocketnet" && class_exists("\Rocket_Wordpress")) {
14
- add_action('nitropack_execute_purge_url', [$this, 'purgeUrl']);
15
- add_action('nitropack_execute_purge_all', [$this, 'purgeAll']);
 
 
 
 
 
16
  }
17
  }
18
 
19
  public function purgeUrl($url) {
20
- \NitroPack\Integration\Plugin\RocketNet_Helper::purgeUrl($url);
 
 
 
 
 
21
  }
22
 
23
  public function purgeAll() {
24
- \Rocket_Wordpress::purge_cache();
25
  }
26
  }
27
-
10
  }
11
 
12
  public function init($stage) {
13
+ if ($this->getHosting() == "rocketnet") {
14
+ if (class_exists("CDN_Clear_Cache_Api")) {
15
+ add_action('nitropack_execute_purge_url', [$this, 'purgeUrl']);
16
+ }
17
+
18
+ if (class_exists("CDN_Clear_Cache_Hooks")) {
19
+ add_action('nitropack_execute_purge_all', [$this, 'purgeAll']);
20
+ }
21
  }
22
  }
23
 
24
  public function purgeUrl($url) {
25
+ $urlObj = new \NitroPack\Url($url);
26
+ $entry = $urlObj->getPath();
27
+ if ($urlObj->getQuery()) {
28
+ $entry .= "?" . $urlObj->getQuery();
29
+ }
30
+ \CDN_Clear_Cache_Api::cache_api_call([$entry], 'purge');
31
  }
32
 
33
  public function purgeAll() {
34
+ \CDN_Clear_Cache_Hooks::purge_cache();
35
  }
36
  }
 
classes/Integration/Server/Cloudflare.php CHANGED
@@ -7,15 +7,21 @@ class Cloudflare {
7
  const STAGE = "very_early";
8
 
9
  public static function detect() {
10
- return !empty($_SERVER["HTTP_CF_CONNECTING_IP"]);
 
 
11
  }
12
 
13
  public static function isCacheEnabled() {
 
 
 
 
14
  return self::detect() && !empty($_SERVER["HTTP_SEC_CH_UA_MOBILE"]);
15
  }
16
 
17
  public function init($stage) {
18
- if (self::detect() && !\NitroPack\Integration\Plugin\Cloudflare::isApoRequest()) {
19
  header("Accept-CH: Sec-CH-UA-Mobile");
20
 
21
  if (self::isCacheEnabled()) {
@@ -42,4 +48,3 @@ class Cloudflare {
42
  header("Cloudflare-CDN-Cache-Control: no-cache");
43
  }
44
  }
45
-
7
  const STAGE = "very_early";
8
 
9
  public static function detect() {
10
+ return (!empty($_SERVER["HTTP_CF_CONNECTING_IP"]) && $_SERVER["HTTP_CF_CONNECTING_IP"] != "0.0.0.0")
11
+ || !empty($_SERVER["HTTP_CF_RAY"])
12
+ || !empty($_SERVER["HTTP_CF_IPCOUNTRY"]);
13
  }
14
 
15
  public static function isCacheEnabled() {
16
+ $siteConfig = get_nitropack()->getSiteConfig();
17
+ if ($siteConfig && !empty($siteConfig["hosting"]) && $siteConfig["hosting"] == "rocketnet") {
18
+ return self::detect();
19
+ }
20
  return self::detect() && !empty($_SERVER["HTTP_SEC_CH_UA_MOBILE"]);
21
  }
22
 
23
  public function init($stage) {
24
+ if (self::detect()) {
25
  header("Accept-CH: Sec-CH-UA-Mobile");
26
 
27
  if (self::isCacheEnabled()) {
48
  header("Cloudflare-CDN-Cache-Control: no-cache");
49
  }
50
  }
 
classes/WordPress/Config.php CHANGED
@@ -13,10 +13,13 @@ class Config {
13
  return $this->config;
14
  }
15
 
16
- $config = array();
17
 
18
  if ($this->exists()) {
19
  $config = json_decode(file_get_contents(NITROPACK_CONFIG_FILE), true); // TODO: Convert this to use the Filesystem abstraction for better Redis support
 
 
 
20
  }
21
 
22
  $this->config = $config;
@@ -26,6 +29,7 @@ class Config {
26
  public function set($config) {
27
  $np = NitroPack::getInstance();
28
  if (!$np->dataDirExists() && !$np->initDataDir()) return false;
 
29
  $this->config = $config;
30
  return WP_DEBUG ? file_put_contents(NITROPACK_CONFIG_FILE, json_encode($config, JSON_PRETTY_PRINT)) : @file_put_contents(NITROPACK_CONFIG_FILE, json_encode($config, JSON_PRETTY_PRINT)); // TODO: Convert this to use the Filesystem abstraction for better Redis support
31
  }
13
  return $this->config;
14
  }
15
 
16
+ $config = [];
17
 
18
  if ($this->exists()) {
19
  $config = json_decode(file_get_contents(NITROPACK_CONFIG_FILE), true); // TODO: Convert this to use the Filesystem abstraction for better Redis support
20
+ if (!empty($config['config_path']) && $config['config_path'] != md5(NITROPACK_DATA_DIR)) {
21
+ $config = [];
22
+ }
23
  }
24
 
25
  $this->config = $config;
29
  public function set($config) {
30
  $np = NitroPack::getInstance();
31
  if (!$np->dataDirExists() && !$np->initDataDir()) return false;
32
+ $config['config_path'] = md5(NITROPACK_DATA_DIR);
33
  $this->config = $config;
34
  return WP_DEBUG ? file_put_contents(NITROPACK_CONFIG_FILE, json_encode($config, JSON_PRETTY_PRINT)) : @file_put_contents(NITROPACK_CONFIG_FILE, json_encode($config, JSON_PRETTY_PRINT)); // TODO: Convert this to use the Filesystem abstraction for better Redis support
35
  }
classes/WordPress/NitroPack.php CHANGED
@@ -62,14 +62,7 @@ class NitroPack {
62
  }
63
 
64
  public function isConnected() {
65
- if (function_exists("esc_attr") && function_exists("get_option")) {
66
- $siteId = $this->getSiteId() || esc_attr( get_option('nitropack-siteId') );
67
- $siteSecret = $this->getSiteSecret() || esc_attr( get_option('nitropack-siteSecret') );
68
- } else {
69
- $siteId = $this->getSiteId();
70
- $siteSecret = $this->getSiteSecret();
71
- }
72
- return !empty($siteId) && !empty($siteSecret);
73
  }
74
 
75
  public function updateCurrentBlogConfig($siteId, $siteSecret, $blogId, $enableCompression = null) {
62
  }
63
 
64
  public function isConnected() {
65
+ return !empty($this->getSiteId()) && !empty($this->getSiteSecret());
 
 
 
 
 
 
 
66
  }
67
 
68
  public function updateCurrentBlogConfig($siteId, $siteSecret, $blogId, $enableCompression = null) {
classes/WordPress/Notifications.php CHANGED
@@ -39,6 +39,7 @@ class Notifications {
39
  if (!empty($this->notifications) && isset($this->notifications[$this->nitro->getSiteId()])) {
40
  $result = $this->notifications[$this->nitro->getSiteId()];
41
  if ($result['last_modified'] + $this->cacheTtl > time()) { // The cache is still fresh
 
42
  return;
43
  }
44
  }
@@ -71,4 +72,16 @@ class Notifications {
71
  $resp = $client->getStatusCode() == 200 ? json_decode($client->getBody(), true) : false;
72
  return $resp ? $resp['notifications'] : [];
73
  }
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
39
  if (!empty($this->notifications) && isset($this->notifications[$this->nitro->getSiteId()])) {
40
  $result = $this->notifications[$this->nitro->getSiteId()];
41
  if ($result['last_modified'] + $this->cacheTtl > time()) { // The cache is still fresh
42
+ $this->removeExpiredSystemNotifications();
43
  return;
44
  }
45
  }
72
  $resp = $client->getStatusCode() == 200 ? json_decode($client->getBody(), true) : false;
73
  return $resp ? $resp['notifications'] : [];
74
  }
75
+
76
+ private function removeExpiredSystemNotifications()
77
+ {
78
+ if (isset($this->notifications[$this->nitro->getSiteId()]['notifications']['system'])) {
79
+ date_default_timezone_set('UTC');
80
+ foreach ($this->notifications[$this->nitro->getSiteId()]['notifications']['system'] as $key => $notification) {
81
+ if (strtotime($notification['end_date']) < time()) {
82
+ unset($this->notifications[$this->nitro->getSiteId()]['notifications']['system'][$key]);
83
+ }
84
+ }
85
+ }
86
+ }
87
  }
constants.php CHANGED
@@ -6,7 +6,7 @@ function nitropack_trailingslashit($string) {
6
  return rtrim( $string, '/\\' ) . '/';
7
  }
8
 
9
- define( 'NITROPACK_VERSION', '1.5.8' );
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.9' );
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' );
diagnostics.php CHANGED
@@ -2,6 +2,8 @@
2
 
3
  defined( 'ABSPATH' ) or die( 'Someone made a boo boo!' );
4
 
 
 
5
  if (!function_exists('get_plugins')) {
6
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
7
  }
@@ -20,7 +22,7 @@ function npdiag_helper_trailingslashit($string) {
20
  return rtrim( $string, '/\\' ) . '/';
21
  }
22
 
23
- function npdiag_helper_compare_webhooks($nitro_sdk) {
24
  try {
25
  $siteConfig = nitropack_get_site_config();
26
  if (!empty($siteConfig['siteId'])) {
@@ -40,6 +42,33 @@ function npdiag_helper_compare_webhooks($nitro_sdk) {
40
  }
41
  }
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  function npdiag_get_general_info() {
44
  global $wp_version;
45
  if (null !== $nitro = get_nitropack_sdk()) {
@@ -50,7 +79,7 @@ function npdiag_get_general_info() {
50
  $probe_result = 'Error: ' . $e->getMessage();
51
  }
52
  } else {
53
- $probe_result = 'Error: Cannot get SDK instance';
54
  }
55
 
56
  $third_party_residual_cache = npdiag_detect_third_party_cache();
@@ -58,7 +87,8 @@ function npdiag_get_general_info() {
58
  $info = array(
59
  'Nitro_WP_version' => !empty($wp_version) ? $wp_version : get_bloginfo('version'),
60
  'Nitro_Version' => defined('NITROPACK_VERSION') ? NITROPACK_VERSION : 'Undefined',
61
- 'Nitro_API_Connection' => $probe_result,
 
62
  'Nitro_SDK_Version' => defined('NitroPack\SDK\Nitropack::VERSION') ? NitroPack\SDK\Nitropack::VERSION : 'Undefined',
63
  'Nitro_WP_Cache' => defined('WP_CACHE') ? (WP_CACHE ? 'OK for drop-in' : 'Turned off') : 'Undefined',
64
  'Advanced_Cache_Version' => defined('NITROPACK_ADVANCED_CACHE_VERSION') ? NITROPACK_ADVANCED_CACHE_VERSION : 'Undefined',
@@ -66,8 +96,9 @@ function npdiag_get_general_info() {
66
  'Nitro_Plugin_Direcotry' => defined('NITROPACK_PLUGIN_DIR') ? NITROPACK_PLUGIN_DIR : dirname(__FILE__),
67
  'Nitro_Data_Directory' => defined('NITROPACK_DATA_DIR') ? NITROPACK_DATA_DIR : 'Undefined',
68
  'Nitro_Config_File' => defined('NITROPACK_CONFIG_FILE') ? NITROPACK_CONFIG_FILE : 'Undefined',
69
- 'Nitro_Webhooks' => $nitro ? npdiag_helper_compare_webhooks($nitro) : 'Error: Cannot get SDK instance',
70
- 'Nitro_Connectivity_Requirements' => nitropack_check_func_availability('stream_socket_client') ? 'Yes' : 'Warning: "stream_socket_client" function is disabled.',
 
71
  'Residual_Cache_Found_For' => $third_party_residual_cache,
72
  );
73
 
@@ -121,7 +152,7 @@ function npdiag_get_dir_info() {
121
  $DoI = array(
122
  'WP_Content_Dir_Writable' => defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : (defined('ABSPATH') ? ABSPATH . '/wp-content' : 'Undefined'),
123
  'Nitro_Data_Dir_Writable' => defined('NITROPACK_DATA_DIR') ? NITROPACK_DATA_DIR : npdiag_helper_trailingslashit(WP_CONTENT_DIR) . 'nitropack',
124
- 'Nitro_siteID_Dir_Writable' => npdiag_helper_trailingslashit(WP_CONTENT_DIR) . 'nitropack/' . $siteID,
125
  'Nitro_Plugin_Dir_Writable' => defined('NITROPACK_PLUGIN_DIR') ? NITROPACK_PLUGIN_DIR : dirname(__FILE__)
126
  );
127
 
2
 
3
  defined( 'ABSPATH' ) or die( 'Someone made a boo boo!' );
4
 
5
+ use \NitroPack\SDK\Api\ResponseStatus;
6
+
7
  if (!function_exists('get_plugins')) {
8
  require_once ABSPATH . 'wp-admin/includes/plugin.php';
9
  }
22
  return rtrim( $string, '/\\' ) . '/';
23
  }
24
 
25
+ function npdiag_compare_webhooks($nitro_sdk) {
26
  try {
27
  $siteConfig = nitropack_get_site_config();
28
  if (!empty($siteConfig['siteId'])) {
42
  }
43
  }
44
 
45
+ function npdiag_poll_api($nitro_sdk) {
46
+ $pollResult = array(
47
+ ResponseStatus::OK => 'OK',
48
+ ResponseStatus::ACCEPTED => 'OK',
49
+ ResponseStatus::BAD_REQUEST => 'Bad request.',
50
+ ResponseStatus::PAYMENT_REQUIRED => 'Payment required. Please, contact NP support for details.',
51
+ ResponseStatus::FORBIDDEN => 'Site disabled. Please, contact NP support for details.',
52
+ ResponseStatus::NOT_FOUND => 'URL used for the API poll request returned 404. Please ignore this.',
53
+ ResponseStatus::CONFLICT => 'Conflict. There is another operation, which prevents accepting optimization requests at the moment. Please, contact NP support for details.',
54
+ ResponseStatus::RUNTIME_ERROR => 'Runtime error.',
55
+ ResponseStatus::SERVICE_UNAVAILABLE => 'Service unavailable.',
56
+ ResponseStatus::UNKNOWN => 'Unknown.',
57
+ );
58
+
59
+ try {
60
+ $apiResponseCode = $nitro_sdk->getApi()->getCache(get_home_url(), 'NitroPack Diagnostic Agent', array(), false, 'default')->getStatus();
61
+ return $pollResult[$apiResponseCode];
62
+ } catch (\Exception $e) {
63
+ return 'Error: ' . $e->getMessage();
64
+ }
65
+
66
+ }
67
+
68
+ function npdiag_backlog_status($nitro_sdk) {
69
+ return $nitro_sdk->backlog->exists() ? 'Warning' : 'OK';
70
+ }
71
+
72
  function npdiag_get_general_info() {
73
  global $wp_version;
74
  if (null !== $nitro = get_nitropack_sdk()) {
79
  $probe_result = 'Error: ' . $e->getMessage();
80
  }
81
  } else {
82
+ $probe_result = 'Error: Cannot get an SDK instance';
83
  }
84
 
85
  $third_party_residual_cache = npdiag_detect_third_party_cache();
87
  $info = array(
88
  'Nitro_WP_version' => !empty($wp_version) ? $wp_version : get_bloginfo('version'),
89
  'Nitro_Version' => defined('NITROPACK_VERSION') ? NITROPACK_VERSION : 'Undefined',
90
+ 'Nitro_SDK_Connection' => $probe_result,
91
+ 'Nitro_API_Polling' => $nitro ? npdiag_poll_api($nitro) : 'Error: Cannot get an SDK instance',
92
  'Nitro_SDK_Version' => defined('NitroPack\SDK\Nitropack::VERSION') ? NitroPack\SDK\Nitropack::VERSION : 'Undefined',
93
  'Nitro_WP_Cache' => defined('WP_CACHE') ? (WP_CACHE ? 'OK for drop-in' : 'Turned off') : 'Undefined',
94
  'Advanced_Cache_Version' => defined('NITROPACK_ADVANCED_CACHE_VERSION') ? NITROPACK_ADVANCED_CACHE_VERSION : 'Undefined',
96
  'Nitro_Plugin_Direcotry' => defined('NITROPACK_PLUGIN_DIR') ? NITROPACK_PLUGIN_DIR : dirname(__FILE__),
97
  'Nitro_Data_Directory' => defined('NITROPACK_DATA_DIR') ? NITROPACK_DATA_DIR : 'Undefined',
98
  'Nitro_Config_File' => defined('NITROPACK_CONFIG_FILE') ? NITROPACK_CONFIG_FILE : 'Undefined',
99
+ 'Nitro_Backlog_File_Status' => $nitro ? npdiag_backlog_status($nitro) : 'Error: Cannot get an SDK instance',
100
+ 'Nitro_Webhooks' => $nitro ? npdiag_compare_webhooks($nitro) : 'Error: Cannot get an SDK instance',
101
+ 'Nitro_Connectivity_Requirements' => nitropack_check_func_availability('stream_socket_client') ? 'OK' : 'Warning: "stream_socket_client" function is disabled.',
102
  'Residual_Cache_Found_For' => $third_party_residual_cache,
103
  );
104
 
152
  $DoI = array(
153
  'WP_Content_Dir_Writable' => defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : (defined('ABSPATH') ? ABSPATH . '/wp-content' : 'Undefined'),
154
  'Nitro_Data_Dir_Writable' => defined('NITROPACK_DATA_DIR') ? NITROPACK_DATA_DIR : npdiag_helper_trailingslashit(WP_CONTENT_DIR) . 'nitropack',
155
+ 'Nitro_siteID_Dir_Writable' => defined('NITROPACK_DATA_DIR') ? NITROPACK_DATA_DIR . "/$siteID" : npdiag_helper_trailingslashit(WP_CONTENT_DIR) . "nitropack/$siteID",
156
  'Nitro_Plugin_Dir_Writable' => defined('NITROPACK_PLUGIN_DIR') ? NITROPACK_PLUGIN_DIR : dirname(__FILE__)
157
  );
158
 
functions.php CHANGED
@@ -794,15 +794,15 @@ function nitropack_options() {
794
  $checkedCompression = get_option('nitropack-checkedCompression');
795
  $cacheableObjectTypes = nitropack_get_cacheable_object_types();
796
 
797
- if (empty($siteId) || empty($siteSecret)) {
798
- include plugin_dir_path(__FILE__) . nitropack_trailingslashit('view') . 'connect.php';
799
- } else {
800
  $planDetailsUrl = get_nitropack_integration_url("plan_details_json");
801
  $optimizationDetailsUrl = get_nitropack_integration_url("optimization_details_json");
802
  $quickSetupUrl = get_nitropack_integration_url("quicksetup_json");
803
  $quickSetupSaveUrl = get_nitropack_integration_url("quicksetup");
804
 
805
  include plugin_dir_path(__FILE__) . nitropack_trailingslashit('view') . 'admin.php';
 
 
806
  }
807
  }
808
 
@@ -2410,6 +2410,8 @@ function nitropack_detect_hosting() {
2410
  return "rocketnet";
2411
  } else if (\NitroPack\Integration\Hosting\Savvii::detect()) {
2412
  return "savvii";
 
 
2413
  } else {
2414
  return "unknown";
2415
  }
794
  $checkedCompression = get_option('nitropack-checkedCompression');
795
  $cacheableObjectTypes = nitropack_get_cacheable_object_types();
796
 
797
+ if (get_nitropack()->isConnected()) {
 
 
798
  $planDetailsUrl = get_nitropack_integration_url("plan_details_json");
799
  $optimizationDetailsUrl = get_nitropack_integration_url("optimization_details_json");
800
  $quickSetupUrl = get_nitropack_integration_url("quicksetup_json");
801
  $quickSetupSaveUrl = get_nitropack_integration_url("quicksetup");
802
 
803
  include plugin_dir_path(__FILE__) . nitropack_trailingslashit('view') . 'admin.php';
804
+ } else {
805
+ include plugin_dir_path(__FILE__) . nitropack_trailingslashit('view') . 'connect.php';
806
  }
807
  }
808
 
2410
  return "rocketnet";
2411
  } else if (\NitroPack\Integration\Hosting\Savvii::detect()) {
2412
  return "savvii";
2413
+ } else if (\NitroPack\Integration\Hosting\DreamHost::detect()) {
2414
+ return "dreamhost";
2415
  } else {
2416
  return "unknown";
2417
  }
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.8
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.9
7
  Author: NitroPack LLC
8
  Author URI: https://nitropack.io/
9
  License: GPL2
nitropack-sdk/NitroPack/SDK/Integrations/ReverseProxy.php CHANGED
@@ -7,10 +7,12 @@ class ReverseProxy {
7
 
8
  protected $serverList;
9
  protected $purgeMethod;
 
10
 
11
- public function __construct($serverList=null, $purgeMethod="PURGE") {
12
  $this->serverList = $serverList;
13
  $this->purgeMethod = $purgeMethod;
 
14
  }
15
 
16
  public function setServerList($serverList=null) {
@@ -21,6 +23,10 @@ class ReverseProxy {
21
  $this->purgeMethod = $method;
22
  }
23
 
 
 
 
 
24
  public function purge($url) {
25
  if (empty($this->serverList)) return false;
26
 
@@ -29,6 +35,11 @@ class ReverseProxy {
29
  $client = new HttpClient($url);
30
  $client->hostOverride($client->host, $server);
31
  $client->doNotDownload = true;
 
 
 
 
 
32
  $httpMulti->push($client);
33
  }
34
 
7
 
8
  protected $serverList;
9
  protected $purgeMethod;
10
+ protected $headers;
11
 
12
+ public function __construct($serverList=null, $purgeMethod="PURGE", $headers = []) {
13
  $this->serverList = $serverList;
14
  $this->purgeMethod = $purgeMethod;
15
+ $this->headers = $headers;
16
  }
17
 
18
  public function setServerList($serverList=null) {
23
  $this->purgeMethod = $method;
24
  }
25
 
26
+ public function setHeader($name, $value) {
27
+ $this->headers[$name] = $value;
28
+ }
29
+
30
  public function purge($url) {
31
  if (empty($this->serverList)) return false;
32
 
35
  $client = new HttpClient($url);
36
  $client->hostOverride($client->host, $server);
37
  $client->doNotDownload = true;
38
+
39
+ foreach ($this->headers as $name => $value) {
40
+ $client->setHeader($name, $value);
41
+ }
42
+
43
  $httpMulti->push($client);
44
  }
45
 
nitropack-sdk/NitroPack/SDK/NitroPack.php CHANGED
@@ -2,7 +2,7 @@
2
  namespace NitroPack\SDK;
3
 
4
  class NitroPack {
5
- const VERSION = '0.30.1';
6
  const PAGECACHE_LOCK_EXPIRATION_TIME = 300; // in seconds
7
  private $dataDir;
8
  private $cachePath = array('data', 'pagecache');
@@ -149,6 +149,10 @@ class NitroPack {
149
  $refererInfo = new \NitroPack\Url($_SERVER["HTTP_REFERER"]);
150
  $this->pageCache->setReferer($refererInfo->getNormalized());
151
  }
 
 
 
 
152
 
153
  $this->api = new Api($this->siteId, $siteSecret);
154
  $this->api->setBacklog($this->backlog);
@@ -427,6 +431,13 @@ class NitroPack {
427
 
428
  public function purgeLocalCache($quick = false) {
429
  $staleCacheDir = $this->getCacheDir() . '.stale.' . md5(microtime(true));
 
 
 
 
 
 
 
430
  $this->purgeProxyCache();
431
  $this->config->LastFetch = 0;
432
  $this->setConfig($this->config);
@@ -654,8 +665,8 @@ class NitroPack {
654
  $cacheDir = $this->getCacheDir();
655
  $knownDeviceTypes = Device::getKnownTypes();
656
  foreach ($knownDeviceTypes as $deviceType) {
657
- $urlDir = PageCache::getUrlDir($cacheDir . "/" . $deviceType, $url);
658
- $invalidatedUrlDir = PageCache::getUrlDir($cacheDir . "/" . $deviceType, $url, true);
659
  $localResult &= Filesystem::deleteDir($urlDir);
660
  $localResult &= Filesystem::deleteDir($invalidatedUrlDir);
661
  }
@@ -669,8 +680,8 @@ class NitroPack {
669
  $cacheDir = $this->getCacheDir();
670
  $knownDeviceTypes = Device::getKnownTypes();
671
  foreach ($knownDeviceTypes as $deviceType) {
672
- $urlDir = PageCache::getUrlDir($cacheDir . "/" . $deviceType, $url);
673
- $urlDirInvalid = PageCache::getUrlDir($cacheDir . "/" . $deviceType, $url, true);
674
 
675
  $this->invalidateDir($urlDir, $urlDirInvalid);
676
  }
2
  namespace NitroPack\SDK;
3
 
4
  class NitroPack {
5
+ const VERSION = '0.30.2';
6
  const PAGECACHE_LOCK_EXPIRATION_TIME = 300; // in seconds
7
  private $dataDir;
8
  private $cachePath = array('data', 'pagecache');
149
  $refererInfo = new \NitroPack\Url($_SERVER["HTTP_REFERER"]);
150
  $this->pageCache->setReferer($refererInfo->getNormalized());
151
  }
152
+ if (!empty($this->config->URLPathVersion)) {
153
+ $this->pageCache->setUrlPathVersion($this->config->URLPathVersion);
154
+ }
155
+
156
 
157
  $this->api = new Api($this->siteId, $siteSecret);
158
  $this->api->setBacklog($this->backlog);
431
 
432
  public function purgeLocalCache($quick = false) {
433
  $staleCacheDir = $this->getCacheDir() . '.stale.' . md5(microtime(true));
434
+ $staleCacheDirSuffix = "";
435
+ $counter = 0;
436
+ while (Filesystem::fileExists($staleCacheDir . $staleCacheDirSuffix)) {
437
+ $counter++;
438
+ $staleCacheDirSuffix = "_" . $counter;
439
+ }
440
+ $staleCacheDir .= $staleCacheDirSuffix;
441
  $this->purgeProxyCache();
442
  $this->config->LastFetch = 0;
443
  $this->setConfig($this->config);
665
  $cacheDir = $this->getCacheDir();
666
  $knownDeviceTypes = Device::getKnownTypes();
667
  foreach ($knownDeviceTypes as $deviceType) {
668
+ $urlDir = PageCache::getUrlDir($cacheDir . "/" . $deviceType, $url, false, $this->config->URLPathVersion);
669
+ $invalidatedUrlDir = PageCache::getUrlDir($cacheDir . "/" . $deviceType, $url, true, $this->config->URLPathVersion);
670
  $localResult &= Filesystem::deleteDir($urlDir);
671
  $localResult &= Filesystem::deleteDir($invalidatedUrlDir);
672
  }
680
  $cacheDir = $this->getCacheDir();
681
  $knownDeviceTypes = Device::getKnownTypes();
682
  foreach ($knownDeviceTypes as $deviceType) {
683
+ $urlDir = PageCache::getUrlDir($cacheDir . "/" . $deviceType, $url, false, $this->config->URLPathVersion);
684
+ $urlDirInvalid = PageCache::getUrlDir($cacheDir . "/" . $deviceType, $url, true, $this->config->URLPathVersion);
685
 
686
  $this->invalidateDir($urlDir, $urlDirInvalid);
687
  }
nitropack-sdk/NitroPack/SDK/Pagecache.php CHANGED
@@ -12,13 +12,21 @@ class Pagecache {
12
  protected $Device;
13
  protected $useCompression;
14
  protected $useInvalidated;
 
15
 
16
- public static function getUrlDir($dataDir, $url, $useInvalidated = false) {
17
  $safeUrl = str_replace(array('/','?',':',';','=','&','.','--','%','~'),'-', $url);
18
  if (defined('NITRO_DEBUG_MODE') && NITRO_DEBUG_MODE) {
19
  $urlDir = $dataDir . "/" . $safeUrl;
20
  } else {
21
- $urlDir = $dataDir . "/" . md5($safeUrl);
 
 
 
 
 
 
 
22
  }
23
 
24
  if ($useInvalidated) {
@@ -37,6 +45,7 @@ class Pagecache {
37
  $this->Device = new Device($userAgent);
38
  $this->useCompression = false;
39
  $this->useInvalidated = false;
 
40
  $this->setReferer($referer);
41
  }
42
 
@@ -69,11 +78,19 @@ class Pagecache {
69
  $this->referer = $referer ? new \NitroPack\Url($referer) : NULL;
70
  if ($this->referer) {
71
  $this->parent = new Pagecache($this->referer->getUrl(), $this->Device->getUserAgent(), $this->cookies, $this->supportedCookies);
 
72
  } else {
73
  $this->parent = NULL;
74
  }
75
  }
76
 
 
 
 
 
 
 
 
77
  public function getReferer() {
78
  return $this->referer;
79
  }
@@ -312,8 +329,8 @@ class Pagecache {
312
  public function getCachefilePath($suffix = "") {
313
  if ($suffix) $suffix = "." . $suffix;
314
  if ($this->isAjax && $this->referer) {
315
- return self::getUrlDir($this->dataDir, $this->referer->getUrl(), $this->useInvalidated) . "/" . $this->nameOfCachefile() . $suffix;
316
  }
317
- return self::getUrlDir($this->dataDir, $this->url->getUrl(), $this->useInvalidated) . "/" . $this->nameOfCachefile() . $suffix;
318
  }
319
  }
12
  protected $Device;
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);
19
  if (defined('NITRO_DEBUG_MODE') && NITRO_DEBUG_MODE) {
20
  $urlDir = $dataDir . "/" . $safeUrl;
21
  } else {
22
+ switch ($pathVersion) {
23
+ case 2:
24
+ $urlDir = $dataDir . "/" . md5($url);
25
+ break;
26
+ default:
27
+ $urlDir = $dataDir . "/" . md5($safeUrl);
28
+ break;
29
+ }
30
  }
31
 
32
  if ($useInvalidated) {
45
  $this->Device = new Device($userAgent);
46
  $this->useCompression = false;
47
  $this->useInvalidated = false;
48
+ $this->setUrlPathVersion(1);
49
  $this->setReferer($referer);
50
  }
51
 
78
  $this->referer = $referer ? new \NitroPack\Url($referer) : NULL;
79
  if ($this->referer) {
80
  $this->parent = new Pagecache($this->referer->getUrl(), $this->Device->getUserAgent(), $this->cookies, $this->supportedCookies);
81
+ $this->parent->setUrlPathVersion($this->urlPathVersion);
82
  } else {
83
  $this->parent = NULL;
84
  }
85
  }
86
 
87
+ public function setUrlPathVersion($version = 1) {
88
+ $this->urlPathVersion = $version;
89
+ if ($this->parent) {
90
+ $this->parent->setUrlPathVersion($version);
91
+ }
92
+ }
93
+
94
  public function getReferer() {
95
  return $this->referer;
96
  }
329
  public function getCachefilePath($suffix = "") {
330
  if ($suffix) $suffix = "." . $suffix;
331
  if ($this->isAjax && $this->referer) {
332
+ return self::getUrlDir($this->dataDir, $this->referer->getUrl(), $this->useInvalidated, $this->urlPathVersion) . "/" . $this->nameOfCachefile() . $suffix;
333
  }
334
+ return self::getUrlDir($this->dataDir, $this->url->getUrl(), $this->useInvalidated, $this->urlPathVersion) . "/" . $this->nameOfCachefile() . $suffix;
335
  }
336
  }
nitropack-sdk/vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit2e3dba6aa37dfe49fb3ede88169cdef9::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit3dcb0cd3b9802939155e959c3c6cfd5d::getLoader();
nitropack-sdk/vendor/composer/ClassLoader.php CHANGED
@@ -149,7 +149,7 @@ class ClassLoader
149
 
150
  /**
151
  * @return string[] Array of classname => path
152
- * @psalm-var array<string, string>
153
  */
154
  public function getClassMap()
155
  {
149
 
150
  /**
151
  * @return string[] Array of classname => path
152
+ * @psalm-return array<string, string>
153
  */
154
  public function getClassMap()
155
  {
nitropack-sdk/vendor/composer/autoload_psr4.php CHANGED
@@ -7,5 +7,5 @@ $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
  'NitroPack\\SDK\\' => array($baseDir . '/NitroPack/SDK'),
10
- 'NitroPack\\' => array($vendorDir . '/nitropack/url/src', $vendorDir . '/nitropack/httpclient/src'),
11
  );
7
 
8
  return array(
9
  'NitroPack\\SDK\\' => array($baseDir . '/NitroPack/SDK'),
10
+ 'NitroPack\\' => array($vendorDir . '/nitropack/httpclient/src', $vendorDir . '/nitropack/url/src'),
11
  );
nitropack-sdk/vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit2e3dba6aa37dfe49fb3ede88169cdef9
6
  {
7
  private static $loader;
8
 
@@ -22,15 +22,15 @@ class ComposerAutoloaderInit2e3dba6aa37dfe49fb3ede88169cdef9
22
  return self::$loader;
23
  }
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInit2e3dba6aa37dfe49fb3ede88169cdef9', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
27
- spl_autoload_unregister(array('ComposerAutoloaderInit2e3dba6aa37dfe49fb3ede88169cdef9', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
31
  require __DIR__ . '/autoload_static.php';
32
 
33
- call_user_func(\Composer\Autoload\ComposerStaticInit2e3dba6aa37dfe49fb3ede88169cdef9::getInitializer($loader));
34
  } else {
35
  $map = require __DIR__ . '/autoload_namespaces.php';
36
  foreach ($map as $namespace => $path) {
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit3dcb0cd3b9802939155e959c3c6cfd5d
6
  {
7
  private static $loader;
8
 
22
  return self::$loader;
23
  }
24
 
25
+ spl_autoload_register(array('ComposerAutoloaderInit3dcb0cd3b9802939155e959c3c6cfd5d', 'loadClassLoader'), true, true);
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInit3dcb0cd3b9802939155e959c3c6cfd5d', 'loadClassLoader'));
28
 
29
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30
  if ($useStaticLoader) {
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) {
nitropack-sdk/vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInit2e3dba6aa37dfe49fb3ede88169cdef9
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'N' =>
@@ -21,8 +21,8 @@ class ComposerStaticInit2e3dba6aa37dfe49fb3ede88169cdef9
21
  ),
22
  'NitroPack\\' =>
23
  array (
24
- 0 => __DIR__ . '/..' . '/nitropack/url/src',
25
- 1 => __DIR__ . '/..' . '/nitropack/httpclient/src',
26
  ),
27
  );
28
 
@@ -33,9 +33,9 @@ class ComposerStaticInit2e3dba6aa37dfe49fb3ede88169cdef9
33
  public static function getInitializer(ClassLoader $loader)
34
  {
35
  return \Closure::bind(function () use ($loader) {
36
- $loader->prefixLengthsPsr4 = ComposerStaticInit2e3dba6aa37dfe49fb3ede88169cdef9::$prefixLengthsPsr4;
37
- $loader->prefixDirsPsr4 = ComposerStaticInit2e3dba6aa37dfe49fb3ede88169cdef9::$prefixDirsPsr4;
38
- $loader->classMap = ComposerStaticInit2e3dba6aa37dfe49fb3ede88169cdef9::$classMap;
39
 
40
  }, null, ClassLoader::class);
41
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit3dcb0cd3b9802939155e959c3c6cfd5d
8
  {
9
  public static $prefixLengthsPsr4 = array (
10
  'N' =>
21
  ),
22
  'NitroPack\\' =>
23
  array (
24
+ 0 => __DIR__ . '/..' . '/nitropack/httpclient/src',
25
+ 1 => __DIR__ . '/..' . '/nitropack/url/src',
26
  ),
27
  );
28
 
33
  public static function getInitializer(ClassLoader $loader)
34
  {
35
  return \Closure::bind(function () use ($loader) {
36
+ $loader->prefixLengthsPsr4 = ComposerStaticInit3dcb0cd3b9802939155e959c3c6cfd5d::$prefixLengthsPsr4;
37
+ $loader->prefixDirsPsr4 = ComposerStaticInit3dcb0cd3b9802939155e959c3c6cfd5d::$prefixDirsPsr4;
38
+ $loader->classMap = ComposerStaticInit3dcb0cd3b9802939155e959c3c6cfd5d::$classMap;
39
 
40
  }, null, ClassLoader::class);
41
  }
nitropack-sdk/vendor/composer/installed.json CHANGED
@@ -42,9 +42,12 @@
42
  "source": {
43
  "type": "git",
44
  "url": "git@bitbucket.org:nitropack/url.git",
45
- "reference": "55b4d631e69a697a9de0fd8e1cbbfa063226a5b8"
46
  },
47
- "time": "2021-06-10T15:14:52+00:00",
 
 
 
48
  "default-branch": true,
49
  "type": "library",
50
  "installation-source": "source",
@@ -68,6 +71,6 @@
68
  "install-path": "../nitropack/url"
69
  }
70
  ],
71
- "dev": true,
72
  "dev-package-names": []
73
  }
42
  "source": {
43
  "type": "git",
44
  "url": "git@bitbucket.org:nitropack/url.git",
45
+ "reference": "faf6a956debd6e4f9ae9d45c8d3e0e763ca79d06"
46
  },
47
+ "require-dev": {
48
+ "phpunit/phpunit": "^9"
49
+ },
50
+ "time": "2022-02-07T07:22:13+00:00",
51
  "default-branch": true,
52
  "type": "library",
53
  "installation-source": "source",
71
  "install-path": "../nitropack/url"
72
  }
73
  ],
74
+ "dev": false,
75
  "dev-package-names": []
76
  }
nitropack-sdk/vendor/composer/installed.php CHANGED
@@ -5,9 +5,9 @@
5
  'type' => 'package',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => '13fbb0581464ff6224e9905cc422ba0f91e5a232',
9
  'name' => 'nitropack/nitropackcloud-sdk',
10
- 'dev' => true,
11
  ),
12
  'versions' => array(
13
  'nitropack/httpclient' => array(
@@ -27,7 +27,7 @@
27
  'type' => 'package',
28
  'install_path' => __DIR__ . '/../../',
29
  'aliases' => array(),
30
- 'reference' => '13fbb0581464ff6224e9905cc422ba0f91e5a232',
31
  'dev_requirement' => false,
32
  ),
33
  'nitropack/url' => array(
@@ -38,7 +38,7 @@
38
  'aliases' => array(
39
  0 => '9999999-dev',
40
  ),
41
- 'reference' => '55b4d631e69a697a9de0fd8e1cbbfa063226a5b8',
42
  'dev_requirement' => false,
43
  ),
44
  ),
5
  'type' => 'package',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
+ 'reference' => 'd078ce9ee21e856b364bd578db356773df01584b',
9
  'name' => 'nitropack/nitropackcloud-sdk',
10
+ 'dev' => false,
11
  ),
12
  'versions' => array(
13
  'nitropack/httpclient' => array(
27
  'type' => 'package',
28
  'install_path' => __DIR__ . '/../../',
29
  'aliases' => array(),
30
+ 'reference' => 'd078ce9ee21e856b364bd578db356773df01584b',
31
  'dev_requirement' => false,
32
  ),
33
  'nitropack/url' => array(
38
  'aliases' => array(
39
  0 => '9999999-dev',
40
  ),
41
+ 'reference' => 'faf6a956debd6e4f9ae9d45c8d3e0e763ca79d06',
42
  'dev_requirement' => false,
43
  ),
44
  ),
nitropack-sdk/vendor/nitropack/url/src/Url.php CHANGED
@@ -18,9 +18,9 @@ class Url {
18
  public function __construct($url) {
19
  $this->url = $url;
20
  $parts = parse_url($url);
21
- $this->scheme = isset($parts["scheme"]) ? $parts["scheme"] : NULL;
22
  $this->port = isset($parts["port"]) ? $parts["port"] : NULL;
23
- $this->host = isset($parts["host"]) ? $parts["host"] : NULL;
24
  $this->path = isset($parts["path"]) ? $parts["path"] : "/";
25
  $this->query = isset($parts["query"]) ? $parts["query"] : NULL;
26
  $this->hash = isset($parts["fragment"]) ? $parts["fragment"] : NULL;
18
  public function __construct($url) {
19
  $this->url = $url;
20
  $parts = parse_url($url);
21
+ $this->scheme = isset($parts["scheme"]) ? strtolower($parts["scheme"]) : NULL;
22
  $this->port = isset($parts["port"]) ? $parts["port"] : NULL;
23
+ $this->host = isset($parts["host"]) ? strtolower($parts["host"]) : NULL;
24
  $this->path = isset($parts["path"]) ? $parts["path"] : "/";
25
  $this->query = isset($parts["query"]) ? $parts["query"] : NULL;
26
  $this->hash = isset($parts["fragment"]) ? $parts["fragment"] : NULL;
nitropack-sdk/vendor/nitropack/url/tests/UrlTest.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use NitroPack\Url;
4
+ use PHPUnit\Framework\TestCase;
5
+
6
+ class UrlTest extends TestCase
7
+ {
8
+ public function testValidUrl()
9
+ {
10
+ $urlString = 'https://nitropack.io:80/test-page/?query=true&query2=false#top';
11
+
12
+ $url = new Url($urlString);
13
+ $this->assertEquals($urlString, $url->getUrl());
14
+ $this->assertEquals('https', $url->getScheme());
15
+ $this->assertEquals('nitropack.io', $url->getHost());
16
+ $this->assertEquals('/test-page/', $url->getPath());
17
+ $this->assertEquals('top', $url->getHash());
18
+ $this->assertEquals('query=true&query2=false', $url->getQuery());
19
+ $this->assertEquals('80', $url->getPort());
20
+ }
21
+
22
+ public function testSchemeToLower()
23
+ {
24
+ $url = new Url('HTTPS://nitropack.io/');
25
+ $this->assertEquals('https', $url->getScheme());
26
+ }
27
+
28
+ public function testHostToLower()
29
+ {
30
+ $url = new Url('https://NITROPACK.IO/');
31
+ $this->assertEquals('nitropack.io', $url->getHost());
32
+ }
33
+
34
+ public function testDetectAsHost()
35
+ {
36
+ $url = new Url('nitropack.io');
37
+ $this->assertEquals('nitropack.io', $url->getHost());
38
+ }
39
+
40
+ public function testDetectAsPath()
41
+ {
42
+ $url = new Url('/test-page');
43
+ $this->assertEquals('/test-page', $url->getPath());
44
+ }
45
+
46
+ public function testNormalization()
47
+ {
48
+ $url = new Url('test-page');
49
+ $url->setBaseUrl('nitropack.io');
50
+
51
+ $this->assertEquals('http://nitropack.io/', $url->getBaseUrl());
52
+ $this->assertEquals('http://nitropack.io/test-page', $url->getNormalized());
53
+ $this->assertEquals('test-page', $url->getPath());
54
+ }
55
+ }
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: 5.8
6
  Requires PHP: 5.3
7
- Stable tag: 1.5.8
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.8 =
173
  * New Feature: Compatibility with Savii hosting
174
  * New Feature: Basic compatibility with Pressable's caching layer
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: 5.9
6
  Requires PHP: 5.3
7
+ Stable tag: 1.5.9
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.9 =
173
+ * New Feature: Compatibility with DreamPress hosting
174
+ * Improvement: Full compatibility with Pressable's caching layer
175
+ * Improvement: Full compatibility with Rocket.net's caching layer
176
+ * Improvement: Overall stability improvements
177
+ * Bug fix: Resolve an issue where separate URLs were incorrectly using the same cache files
178
+ * Bug fix: Switching between prod and staging environments no-longer causes issues with cache sync
179
+
180
  = 1.5.8 =
181
  * New Feature: Compatibility with Savii hosting
182
  * New Feature: Basic compatibility with Pressable's caching layer