Version Description
- Improvement: Better handling of healthchecks after LiteSpeed .htaccess configuration
- Bug fix: Resolve an issue with sitemap XSL schemas
- Bug fix: Resolve an issue AMP pages
Download this release
Release Info
Developer | nitropack |
Plugin | NitroPack |
Version | 1.5.15 |
Comparing to | |
See all releases |
Code changes from version 1.5.14 to 1.5.15
- advanced-cache.php +9 -1
- constants.php +1 -1
- functions.php +65 -34
- main.php +9 -1
- readme.txt +6 -1
advanced-cache.php
CHANGED
@@ -31,7 +31,15 @@ if (defined("NITROPACK_VERSION") && defined("NITROPACK_ADVANCED_CACHE_VERSION")
|
|
31 |
define( 'NITROPACK_IS_BUFFERING', true );
|
32 |
ob_start(function($buffer) use (&$nitro) {
|
33 |
if (!defined("NITROPACK_BEACON_PRINTED")) {
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
define("NITROPACK_BEACON_PRINTED", true);
|
36 |
$buffer = str_replace("</body", nitropack_get_beacon_script() . "</body", $buffer);
|
37 |
}
|
31 |
define( 'NITROPACK_IS_BUFFERING', true );
|
32 |
ob_start(function($buffer) use (&$nitro) {
|
33 |
if (!defined("NITROPACK_BEACON_PRINTED")) {
|
34 |
+
$respHeaders = headers_list();
|
35 |
+
$contentType = NULL;
|
36 |
+
foreach ($respHeaders as $respHeader) {
|
37 |
+
if (stripos(trim($respHeader), 'Content-Type:') === 0) {
|
38 |
+
$contentType = $respHeader;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( stripos($contentType, 'text/html') !== false && nitropack_passes_cookie_requirements() && nitropack_passes_page_requirements(false)) {
|
43 |
define("NITROPACK_BEACON_PRINTED", true);
|
44 |
$buffer = str_replace("</body", nitropack_get_beacon_script() . "</body", $buffer);
|
45 |
}
|
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.15' );
|
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
@@ -38,7 +38,6 @@ 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()) {
|
@@ -46,6 +45,9 @@ function nitropack_activate() {
|
|
46 |
}
|
47 |
nitropack_install_advanced_cache();
|
48 |
|
|
|
|
|
|
|
49 |
try {
|
50 |
do_action('nitropack_integration_purge_all');
|
51 |
} catch (\Exception $e) {
|
@@ -233,13 +235,22 @@ function nitropack_set_htaccess_rules($status) {
|
|
233 |
|
234 |
if ($homeUrl) {
|
235 |
$homeUrl .= (strpos($homeUrl, "?") === false ? "?" : "&") . "nitroHealthcheck=1";
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
242 |
return false;
|
|
|
|
|
|
|
|
|
243 |
}
|
244 |
} else {
|
245 |
return false;
|
@@ -447,29 +458,41 @@ function nitropack_sanitize_url_input($url) {
|
|
447 |
return $result;
|
448 |
}
|
449 |
|
450 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
$reduceCheckoutChecks = defined("NITROPACK_REDUCE_CHECKOUT_CHECKS") && NITROPACK_REDUCE_CHECKOUT_CHECKS;
|
452 |
$reduceCartChecks = defined("NITROPACK_REDUCE_CART_CHECKS") && NITROPACK_REDUCE_CART_CHECKS;
|
453 |
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
|
|
|
|
|
|
|
|
|
|
473 |
}
|
474 |
|
475 |
function nitropack_is_home() {
|
@@ -759,9 +782,9 @@ function nitropack_set_custom_expiration() {
|
|
759 |
}
|
760 |
|
761 |
function nitropack_print_beacon_script() {
|
762 |
-
if (defined("NITROPACK_BEACON_PRINTED")) return;
|
763 |
define("NITROPACK_BEACON_PRINTED", true);
|
764 |
-
echo nitropack_get_beacon_script();
|
765 |
}
|
766 |
|
767 |
function nitropack_get_beacon_script() {
|
@@ -799,7 +822,7 @@ function nitropack_get_beacon_script() {
|
|
799 |
function nitropack_print_cookie_handler_script() {
|
800 |
if (defined("NITROPACK_COOKIE_HANDLER_PRINTED")) return;
|
801 |
define("NITROPACK_COOKIE_HANDLER_PRINTED", true);
|
802 |
-
echo nitropack_get_cookie_handler_script();
|
803 |
}
|
804 |
|
805 |
function nitropack_get_cookie_handler_script() {
|
@@ -812,7 +835,7 @@ function nitropack_get_cookie_handler_script() {
|
|
812 |
function nitropack_print_telemetry_script() {
|
813 |
if (defined("NITROPACK_TELEMETRY_PRINTED")) return;
|
814 |
define("NITROPACK_TELEMETRY_PRINTED", true);
|
815 |
-
echo nitropack_get_telemetry_script();
|
816 |
}
|
817 |
|
818 |
function nitropack_get_telemetry_script() {
|
@@ -1243,6 +1266,7 @@ function nitropack_sdk_invalidate($url = NULL, $tag = NULL, $reason = NULL) {
|
|
1243 |
/* Start Heartbeat Related Functions */
|
1244 |
function nitropack_is_heartbeat_needed() {
|
1245 |
return !nitropack_is_optimizer_request() &&
|
|
|
1246 |
!nitropack_is_heartbeat_running() &&
|
1247 |
(!nitropack_is_heartbeat_completed() || time() - nitropack_last_heartbeat() > NITROPACK_HEARTBEAT_INTERVAL);
|
1248 |
}
|
@@ -1251,7 +1275,7 @@ function nitropack_print_heartbeat_script() {
|
|
1251 |
if (nitropack_is_heartbeat_needed()) {
|
1252 |
if (defined("NITROPACK_HEARTBEAT_PRINTED")) return;
|
1253 |
define("NITROPACK_HEARTBEAT_PRINTED", true);
|
1254 |
-
echo nitropack_get_heartbeat_script();
|
1255 |
}
|
1256 |
}
|
1257 |
|
@@ -2738,6 +2762,7 @@ function nitropack_is_dropin_cache_allowed() {
|
|
2738 |
}
|
2739 |
|
2740 |
function nitropack_admin_bar_menu($wp_admin_bar){
|
|
|
2741 |
|
2742 |
|
2743 |
$nitropackPluginNotices = nitropack_plugin_notices();
|
@@ -2843,16 +2868,22 @@ function nitropack_admin_bar_menu($wp_admin_bar){
|
|
2843 |
}
|
2844 |
|
2845 |
function nitropack_admin_bar_script($hook) {
|
|
|
2846 |
wp_enqueue_script('nitropack_admin_bar_menu_script', plugin_dir_url(__FILE__) . 'view/javascript/admin_bar_menu.js?np_v=' . NITROPACK_VERSION, ['jquery'], false, true);
|
2847 |
wp_localize_script( 'nitropack_admin_bar_menu_script', 'frontendajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
|
|
|
2848 |
}
|
2849 |
|
2850 |
function nitropack_enqueue_load_fa() {
|
2851 |
-
|
|
|
|
|
2852 |
}
|
2853 |
|
2854 |
function enqueue_nitropack_admin_bar_menu_stylesheet() {
|
2855 |
-
|
|
|
|
|
2856 |
}
|
2857 |
|
2858 |
function nitropack_cookiepath() {
|
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()) {
|
45 |
}
|
46 |
nitropack_install_advanced_cache();
|
47 |
|
48 |
+
// Htaccess mods need to happen after installing the advanced cache file so the healthcheck can execute fast
|
49 |
+
nitropack_set_htaccess_rules(true);
|
50 |
+
|
51 |
try {
|
52 |
do_action('nitropack_integration_purge_all');
|
53 |
} catch (\Exception $e) {
|
235 |
|
236 |
if ($homeUrl) {
|
237 |
$homeUrl .= (strpos($homeUrl, "?") === false ? "?" : "&") . "nitroHealthcheck=1";
|
238 |
+
try {
|
239 |
+
$client = new \NitroPack\HttpClient($homeUrl);
|
240 |
+
$client->timeout = 5;
|
241 |
+
$client->setHeader("Accept", "text/html");
|
242 |
+
$client->fetch();
|
243 |
+
if ($client->getStatusCode() != 200) {
|
244 |
+
// Restore the initial version of the file
|
245 |
+
WP_DEBUG ? file_put_contents($htaccessFilePath, implode("", $linesBackup)) : @file_put_contents($htaccessFilePath, implode("", $linesBackup));
|
246 |
+
return false;
|
247 |
+
}
|
248 |
+
} catch (\Exception $e) {
|
249 |
return false;
|
250 |
+
// Unfortunately we can't be certain whether an issue appeared due to the .htaccess mods
|
251 |
+
// There are no known cases of this happening, so it's fairly safe to assume that all is fine
|
252 |
+
// There are server setups which do not allow loopback requests, which is the more likely reason to end up here
|
253 |
+
// However we can't be certain which one it is, so we are taking the safer approach
|
254 |
}
|
255 |
} else {
|
256 |
return false;
|
458 |
return $result;
|
459 |
}
|
460 |
|
461 |
+
function nitropack_is_amp_page() {
|
462 |
+
return
|
463 |
+
(function_exists('amp_is_request') && amp_is_request() && !nitropack_header("X-Nitro-Disabled-Reason: amp page")) ||
|
464 |
+
(function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() && !nitropack_header("X-Nitro-Disabled-Reason: amp page"));
|
465 |
+
}
|
466 |
+
|
467 |
+
function nitropack_passes_page_requirements($detectIfNoCachedResult = true) {
|
468 |
+
static $cachedResult = NULL;
|
469 |
$reduceCheckoutChecks = defined("NITROPACK_REDUCE_CHECKOUT_CHECKS") && NITROPACK_REDUCE_CHECKOUT_CHECKS;
|
470 |
$reduceCartChecks = defined("NITROPACK_REDUCE_CART_CHECKS") && NITROPACK_REDUCE_CART_CHECKS;
|
471 |
|
472 |
+
if ($cachedResult === NULL && $detectIfNoCachedResult) {
|
473 |
+
$cachedResult = !(
|
474 |
+
( is_404() && !nitropack_header("X-Nitro-Disabled-Reason: 404") ) ||
|
475 |
+
( is_preview() && !nitropack_header("X-Nitro-Disabled-Reason: preview page") ) ||
|
476 |
+
( is_feed() && !nitropack_header("X-Nitro-Disabled-Reason: feed") ) ||
|
477 |
+
( is_comment_feed() && !nitropack_header("X-Nitro-Disabled-Reason: comment feed") ) ||
|
478 |
+
( is_trackback() && !nitropack_header("X-Nitro-Disabled-Reason: trackback") ) ||
|
479 |
+
( is_user_logged_in() && !nitropack_header("X-Nitro-Disabled-Reason: logged in") ) ||
|
480 |
+
( is_search() && !nitropack_header("X-Nitro-Disabled-Reason: search") ) ||
|
481 |
+
( nitropack_is_ajax() && !nitropack_header("X-Nitro-Disabled-Reason: ajax") ) ||
|
482 |
+
( nitropack_is_post() && !nitropack_header("X-Nitro-Disabled-Reason: post request") ) ||
|
483 |
+
( nitropack_is_xmlrpc() && !nitropack_header("X-Nitro-Disabled-Reason: xmlrpc") ) ||
|
484 |
+
( nitropack_is_robots() && !nitropack_header("X-Nitro-Disabled-Reason: robots") ) ||
|
485 |
+
nitropack_is_amp_page() ||
|
486 |
+
!nitropack_is_allowed_request() ||
|
487 |
+
( nitropack_is_wp_cron() && !nitropack_header("X-Nitro-Disabled-Reason: doing cron") ) || // CRON request
|
488 |
+
( nitropack_is_wp_cli() ) || // CLI request
|
489 |
+
( defined('WC_PLUGIN_FILE') && (is_page( 'cart' ) || ( !$reduceCartChecks && is_cart()) ) && !nitropack_header("X-Nitro-Disabled-Reason: cart page") ) || // WooCommerce
|
490 |
+
( defined('WC_PLUGIN_FILE') && (is_page( 'checkout' ) || ( !$reduceCheckoutChecks && is_checkout()) ) && !nitropack_header("X-Nitro-Disabled-Reason: checkout page") ) || // WooCommerce
|
491 |
+
( defined('WC_PLUGIN_FILE') && is_account_page() && !nitropack_header("X-Nitro-Disabled-Reason: account page") ) // WooCommerce
|
492 |
+
);
|
493 |
+
}
|
494 |
+
|
495 |
+
return $cachedResult;
|
496 |
}
|
497 |
|
498 |
function nitropack_is_home() {
|
782 |
}
|
783 |
|
784 |
function nitropack_print_beacon_script() {
|
785 |
+
if (defined("NITROPACK_BEACON_PRINTED") || !nitropack_passes_page_requirements()) return;
|
786 |
define("NITROPACK_BEACON_PRINTED", true);
|
787 |
+
echo apply_filters("nitro_script_output", nitropack_get_beacon_script());
|
788 |
}
|
789 |
|
790 |
function nitropack_get_beacon_script() {
|
822 |
function nitropack_print_cookie_handler_script() {
|
823 |
if (defined("NITROPACK_COOKIE_HANDLER_PRINTED")) return;
|
824 |
define("NITROPACK_COOKIE_HANDLER_PRINTED", true);
|
825 |
+
echo apply_filters("nitro_script_output", nitropack_get_cookie_handler_script());
|
826 |
}
|
827 |
|
828 |
function nitropack_get_cookie_handler_script() {
|
835 |
function nitropack_print_telemetry_script() {
|
836 |
if (defined("NITROPACK_TELEMETRY_PRINTED")) return;
|
837 |
define("NITROPACK_TELEMETRY_PRINTED", true);
|
838 |
+
echo apply_filters("nitro_script_output", nitropack_get_telemetry_script());
|
839 |
}
|
840 |
|
841 |
function nitropack_get_telemetry_script() {
|
1266 |
/* Start Heartbeat Related Functions */
|
1267 |
function nitropack_is_heartbeat_needed() {
|
1268 |
return !nitropack_is_optimizer_request() &&
|
1269 |
+
!nitropack_is_amp_page() &&
|
1270 |
!nitropack_is_heartbeat_running() &&
|
1271 |
(!nitropack_is_heartbeat_completed() || time() - nitropack_last_heartbeat() > NITROPACK_HEARTBEAT_INTERVAL);
|
1272 |
}
|
1275 |
if (nitropack_is_heartbeat_needed()) {
|
1276 |
if (defined("NITROPACK_HEARTBEAT_PRINTED")) return;
|
1277 |
define("NITROPACK_HEARTBEAT_PRINTED", true);
|
1278 |
+
echo apply_filters("nitro_script_output", nitropack_get_heartbeat_script());
|
1279 |
}
|
1280 |
}
|
1281 |
|
2762 |
}
|
2763 |
|
2764 |
function nitropack_admin_bar_menu($wp_admin_bar){
|
2765 |
+
if (nitropack_is_amp_page()) return;
|
2766 |
|
2767 |
|
2768 |
$nitropackPluginNotices = nitropack_plugin_notices();
|
2868 |
}
|
2869 |
|
2870 |
function nitropack_admin_bar_script($hook) {
|
2871 |
+
if (!nitropack_is_amp_page()) {
|
2872 |
wp_enqueue_script('nitropack_admin_bar_menu_script', plugin_dir_url(__FILE__) . 'view/javascript/admin_bar_menu.js?np_v=' . NITROPACK_VERSION, ['jquery'], false, true);
|
2873 |
wp_localize_script( 'nitropack_admin_bar_menu_script', 'frontendajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
|
2874 |
+
}
|
2875 |
}
|
2876 |
|
2877 |
function nitropack_enqueue_load_fa() {
|
2878 |
+
if (!nitropack_is_amp_page()) {
|
2879 |
+
wp_enqueue_style( 'load-fa', plugin_dir_url(__FILE__) . 'view/stylesheet/fontawesome/font-awesome.min.css?np_v=' . NITROPACK_VERSION);
|
2880 |
+
}
|
2881 |
}
|
2882 |
|
2883 |
function enqueue_nitropack_admin_bar_menu_stylesheet() {
|
2884 |
+
if (!nitropack_is_amp_page()) {
|
2885 |
+
wp_enqueue_style( 'nitropack_admin_bar_menu_stylesheet', plugin_dir_url(__FILE__) . 'view/stylesheet/admin_bar_menu.css?np_v=' . NITROPACK_VERSION);
|
2886 |
+
}
|
2887 |
}
|
2888 |
|
2889 |
function nitropack_cookiepath() {
|
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
|
@@ -34,6 +34,14 @@ if ( \NitroPack\Integration\Plugin\Ezoic::isActive() ) {
|
|
34 |
nitropack_handle_request("plugin");
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
add_action( 'pre_post_update', 'nitropack_log_post_pre_update', 10, 3);
|
38 |
add_action( 'transition_post_status', 'nitropack_handle_post_transition', 10, 3);
|
39 |
add_action( 'transition_comment_status', 'nitropack_handle_comment_transition', 10, 3);
|
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.15
|
7 |
Author: NitroPack LLC
|
8 |
Author URI: https://nitropack.io/
|
9 |
License: GPL2
|
34 |
nitropack_handle_request("plugin");
|
35 |
}
|
36 |
|
37 |
+
add_filter( 'nitro_script_output', function($script) {
|
38 |
+
// Make sure we don't accidentally print a non-amp compatible script to an amp page
|
39 |
+
if (nitropack_is_amp_page()) {
|
40 |
+
return "";
|
41 |
+
} else {
|
42 |
+
return $script;
|
43 |
+
}
|
44 |
+
});
|
45 |
add_action( 'pre_post_update', 'nitropack_log_post_pre_update', 10, 3);
|
46 |
add_action( 'transition_post_status', 'nitropack_handle_post_transition', 10, 3);
|
47 |
add_action( 'transition_comment_status', 'nitropack_handle_comment_transition', 10, 3);
|
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: 6.0.1
|
6 |
Requires PHP: 5.6
|
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,11 @@ No. We’ve designed NitroPack to be a very lightweight solution that adds no CP
|
|
169 |
|
170 |
== Changelog ==
|
171 |
|
|
|
|
|
|
|
|
|
|
|
172 |
= 1.5.14 =
|
173 |
* Bug fix: Resolve an issue with activate/deactivate if opcache_reset is not available
|
174 |
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 6.0.1
|
6 |
Requires PHP: 5.6
|
7 |
+
Stable tag: 1.5.15
|
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.15 =
|
173 |
+
* Improvement: Better handling of healthchecks after LiteSpeed .htaccess configuration
|
174 |
+
* Bug fix: Resolve an issue with sitemap XSL schemas
|
175 |
+
* Bug fix: Resolve an issue AMP pages
|
176 |
+
|
177 |
= 1.5.14 =
|
178 |
* Bug fix: Resolve an issue with activate/deactivate if opcache_reset is not available
|
179 |
|