NitroPack - Version 1.5.2

Version Description

  • Improvement: Faster cache purge via the webhook
  • Improvement: Purging/Invalidating cache via WP-CLI is now direct and provides better feedback of the result
  • Bug fix: Any cache purge was triggering full cache purge on the local server. This is now resolved.
Download this release

Release Info

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

Code changes from version 1.5.1 to 1.5.2

Files changed (5) hide show
  1. constants.php +1 -1
  2. functions.php +7 -4
  3. main.php +1 -1
  4. readme.txt +6 -1
  5. wp-cli.php +27 -2
constants.php CHANGED
@@ -6,7 +6,7 @@ function nitropack_trailingslashit($string) {
6
  return rtrim( $string, '/\\' ) . '/';
7
  }
8
 
9
- define( 'NITROPACK_VERSION', '1.5.1' );
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.2' );
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
@@ -1152,7 +1152,10 @@ function nitropack_sdk_purge($url = NULL, $tag = NULL, $reason = NULL, $type = \
1152
  }
1153
  }
1154
 
1155
- $nitro->purgeLocalCache(true);
 
 
 
1156
  $nitro->purgeCache($url, $tag, $type, $reason);
1157
 
1158
  try {
@@ -1185,7 +1188,7 @@ function nitropack_sdk_purge_local($url = NULL) {
1185
  $nitro->purgeLocalUrlCache($url);
1186
  do_action('nitropack_integration_purge_url', $url);
1187
  } else {
1188
- $nitro->purgeLocalCache();
1189
 
1190
  try {
1191
  do_action('nitropack_integration_purge_all');
@@ -1237,7 +1240,7 @@ function nitropack_log_purge($url = NULL, $tag = NULL, $reason = NULL) {
1237
  }
1238
 
1239
  $purgeRequestKey = md5($keyBase);
1240
- if (array_key_exists($purgeRequestKey, $np_loggedPurges)) {
1241
  $np_loggedPurges[$purgeRequestKey]["reason"] = $reason;
1242
  $np_loggedPurges[$purgeRequestKey]["priority"]++;
1243
  } else {
@@ -1284,7 +1287,7 @@ function nitropack_log_invalidate($url = NULL, $tag = NULL, $reason = NULL) {
1284
  }
1285
 
1286
  $invalidateRequestKey = md5($keyBase);
1287
- if (array_key_exists($invalidateRequestKey, $np_loggedInvalidations)) {
1288
  $np_loggedInvalidations[$invalidateRequestKey]["reason"] = $reason;
1289
  $np_loggedInvalidations[$invalidateRequestKey]["priority"]++;
1290
  } else {
1152
  }
1153
  }
1154
 
1155
+ if (!$url && !$tag) {
1156
+ $nitro->purgeLocalCache(true);
1157
+ }
1158
+
1159
  $nitro->purgeCache($url, $tag, $type, $reason);
1160
 
1161
  try {
1188
  $nitro->purgeLocalUrlCache($url);
1189
  do_action('nitropack_integration_purge_url', $url);
1190
  } else {
1191
+ $nitro->purgeLocalCache(true);
1192
 
1193
  try {
1194
  do_action('nitropack_integration_purge_all');
1240
  }
1241
 
1242
  $purgeRequestKey = md5($keyBase);
1243
+ if (is_array($np_loggedPurges) && array_key_exists($purgeRequestKey, $np_loggedPurges)) {
1244
  $np_loggedPurges[$purgeRequestKey]["reason"] = $reason;
1245
  $np_loggedPurges[$purgeRequestKey]["priority"]++;
1246
  } else {
1287
  }
1288
 
1289
  $invalidateRequestKey = md5($keyBase);
1290
+ if (is_array($np_loggedInvalidations) && array_key_exists($invalidateRequestKey, $np_loggedInvalidations)) {
1291
  $np_loggedInvalidations[$invalidateRequestKey]["reason"] = $reason;
1292
  $np_loggedInvalidations[$invalidateRequestKey]["priority"]++;
1293
  } else {
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.1
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.2
7
  Author: NitroPack LLC
8
  Author URI: https://nitropack.io/
9
  License: GPL2
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: cache,perfomance,optimize,pagespeed,lazy load,cdn,critical css,compression
4
  Requires at least: 4.7
5
  Tested up to: 5.6
6
  Requires PHP: 5.3
7
- Stable tag: 1.5.1
8
  License: GNU General Public License, version 2
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -169,6 +169,11 @@ No. We’ve designed NitroPack to be a very lightweight solution that adds no CP
169
 
170
  == Changelog ==
171
 
 
 
 
 
 
172
  = 1.5.1 =
173
  * Bug fix: Resolve an issue causing a fatal error related to undefined class name
174
 
4
  Requires at least: 4.7
5
  Tested up to: 5.6
6
  Requires PHP: 5.3
7
+ Stable tag: 1.5.2
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.2 =
173
+ * Improvement: Faster cache purge via the webhook
174
+ * Improvement: Purging/Invalidating cache via WP-CLI is now direct and provides better feedback of the result
175
+ * Bug fix: Any cache purge was triggering full cache purge on the local server. This is now resolved.
176
+
177
  = 1.5.1 =
178
  * Bug fix: Resolve an issue causing a fatal error related to undefined class name
179
 
wp-cli.php CHANGED
@@ -49,7 +49,19 @@ function nitropack_cli_purge($args, $assocArgs) {
49
  $tag = !empty($assocArgs["purge-tag"]) ? $assocArgs["purge-tag"] : NULL;
50
  $reason = !empty($assocArgs["purge-reason"]) ? $assocArgs["purge-reason"] : NULL;
51
  if ($url || $tag || $reason) {
52
- nitropack_purge($url, $tag, $reason);
 
 
 
 
 
 
 
 
 
 
 
 
53
  } else {
54
  nitropack_purge_cache();
55
  }
@@ -68,7 +80,20 @@ function nitropack_cli_invalidate($args, $assocArgs) {
68
  $tag = !empty($assocArgs["purge-tag"]) ? $assocArgs["purge-tag"] : NULL;
69
  $reason = !empty($assocArgs["purge-reason"]) ? $assocArgs["purge-reason"] : NULL;
70
  if ($url || $tag || $reason) {
71
- nitropack_invalidate($url, $tag, $reason);
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  } else {
73
  nitropack_invalidate_cache();
74
  }
49
  $tag = !empty($assocArgs["purge-tag"]) ? $assocArgs["purge-tag"] : NULL;
50
  $reason = !empty($assocArgs["purge-reason"]) ? $assocArgs["purge-reason"] : NULL;
51
  if ($url || $tag || $reason) {
52
+ try {
53
+ if (nitropack_sdk_purge($url, $tag, $reason)) {
54
+ nitropack_json_and_exit(array(
55
+ "type" => "success",
56
+ "message" => "Success! Cache has been purged successfully!"
57
+ ));
58
+ }
59
+ } catch (\Exception $e) {}
60
+
61
+ nitropack_json_and_exit(array(
62
+ "type" => "error",
63
+ "message" => "Error! There was an error and the cache was not purged!"
64
+ ));
65
  } else {
66
  nitropack_purge_cache();
67
  }
80
  $tag = !empty($assocArgs["purge-tag"]) ? $assocArgs["purge-tag"] : NULL;
81
  $reason = !empty($assocArgs["purge-reason"]) ? $assocArgs["purge-reason"] : NULL;
82
  if ($url || $tag || $reason) {
83
+ try {
84
+ if (nitropack_sdk_invalidate($url, $tag, $reason)) {
85
+ nitropack_json_and_exit(array(
86
+ "type" => "success",
87
+ "message" => "Success! Cache has been invalidated successfully!"
88
+ ));
89
+ }
90
+ } catch (\Exception $e) {}
91
+
92
+ nitropack_json_and_exit(array(
93
+ "type" => "error",
94
+ "message" => "Error! There was an error and the cache was not invalidated!"
95
+ ));
96
+ nitropack_sdk_invalidate($url, $tag, $reason);
97
  } else {
98
  nitropack_invalidate_cache();
99
  }