Version Description
- Improvement: Add exclude for a healtcheck endpoint in Pagely
- Bug fix: Resolve compatibility issues related to Aelia Currency Switcher
- Bug fix: Resolve an issue causing settings to be reset to "Standard" mode
Download this release
Release Info
Developer | nitropack |
Plugin | NitroPack |
Version | 1.5.12 |
Comparing to | |
See all releases |
Code changes from version 1.5.11 to 1.5.12
- classes/Integration/Hosting/Pagely.php +15 -1
- classes/Integration/Plugin/AeliaCurrencySwitcher.php +32 -17
- classes/PluginStateHandler.php +1 -1
- classes/WordPress/NitroPack.php +20 -2
- constants.php +1 -1
- functions.php +13 -4
- main.php +1 -1
- readme.txt +6 -1
- view/dashboard.php +8 -9
classes/Integration/Hosting/Pagely.php
CHANGED
@@ -15,6 +15,7 @@ class Pagely extends Hosting {
|
|
15 |
case "very_early":
|
16 |
add_action('nitropack_cacheable_cache_headers', [$this, 'addCacheControl']);
|
17 |
add_action('nitropack_cachehit_cache_headers', [$this, 'addCacheControl']);
|
|
|
18 |
\NitroPack\Integration::initSemAcquire();
|
19 |
return true;
|
20 |
case "early":
|
@@ -52,6 +53,19 @@ class Pagely extends Hosting {
|
|
52 |
}
|
53 |
|
54 |
public function addCacheControl() {
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
}
|
15 |
case "very_early":
|
16 |
add_action('nitropack_cacheable_cache_headers', [$this, 'addCacheControl']);
|
17 |
add_action('nitropack_cachehit_cache_headers', [$this, 'addCacheControl']);
|
18 |
+
add_filter('nitropack_can_serve_cache', [$this, 'canServeCache']);
|
19 |
\NitroPack\Integration::initSemAcquire();
|
20 |
return true;
|
21 |
case "early":
|
53 |
}
|
54 |
|
55 |
public function addCacheControl() {
|
56 |
+
if ($this->isHealthcheckRequest()) {
|
57 |
+
nitropack_header("Cache-Control: no-cache");
|
58 |
+
nitropack_header("X-Nitro-Disabled: 1");
|
59 |
+
} else {
|
60 |
+
nitropack_header("Cache-Control: public, max-age=0, s-maxage=3600");
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
public function canServeCache() {
|
65 |
+
return !$this->isHealthcheckRequest();
|
66 |
+
}
|
67 |
+
|
68 |
+
public function isHealthcheckRequest() {
|
69 |
+
return !empty($_SERVER['REQUEST_URI']) && trim(strtolower($_SERVER['REQUEST_URI']), "/") == "pagely/status";
|
70 |
}
|
71 |
}
|
classes/Integration/Plugin/AeliaCurrencySwitcher.php
CHANGED
@@ -3,8 +3,8 @@
|
|
3 |
namespace NitroPack\Integration\Plugin;
|
4 |
|
5 |
class AeliaCurrencySwitcher {
|
6 |
-
|
7 |
-
|
8 |
|
9 |
public static function isActive() {
|
10 |
return class_exists("\Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher");
|
@@ -17,6 +17,10 @@ class AeliaCurrencySwitcher {
|
|
17 |
return true; // ACS is not active
|
18 |
}
|
19 |
|
|
|
|
|
|
|
|
|
20 |
// use CloudFlare geolocation if available
|
21 |
if (isset($_SERVER["HTTP_CF_IPCOUNTRY"])) {
|
22 |
add_action('set_nitropack_geo_cache_prefix', function() {
|
@@ -36,20 +40,8 @@ class AeliaCurrencySwitcher {
|
|
36 |
return true;
|
37 |
}
|
38 |
|
39 |
-
// Check if
|
40 |
-
if (!
|
41 |
-
&& !empty($siteConfig['options_cache']['woocommerce_default_customer_address'])
|
42 |
-
&& "geolocation_ajax" === $siteConfig['options_cache']['woocommerce_default_customer_address']
|
43 |
-
) {
|
44 |
-
self::resetVariationCookies();
|
45 |
-
return true;
|
46 |
-
}
|
47 |
-
|
48 |
-
// Check if Woocommerce Cache Handler is configured
|
49 |
-
if (!empty($siteConfig['isWoocommerceCacheHandlerActive'])
|
50 |
-
&& !empty($siteConfig['options_cache']['cache_handler_cache_handler'])
|
51 |
-
&& in_array($siteConfig['options_cache']['cache_handler_cache_handler'], ['enable_redirect', 'enable_ajax'])
|
52 |
-
) {
|
53 |
self::resetVariationCookies();
|
54 |
return true;
|
55 |
}
|
@@ -101,10 +93,33 @@ class AeliaCurrencySwitcher {
|
|
101 |
&& empty($_COOKIE["aelia_customer_state"])
|
102 |
&& empty($_COOKIE["aelia_tax_exempt"])
|
103 |
) {
|
104 |
-
|
105 |
return false;
|
106 |
}
|
107 |
|
108 |
return $currentState;
|
109 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
3 |
namespace NitroPack\Integration\Plugin;
|
4 |
|
5 |
class AeliaCurrencySwitcher {
|
6 |
+
const STAGE = "very_early";
|
7 |
+
const customVariationCookies = ['aelia_cs_selected_currency', 'aelia_customer_country'];
|
8 |
|
9 |
public static function isActive() {
|
10 |
return class_exists("\Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher");
|
17 |
return true; // ACS is not active
|
18 |
}
|
19 |
|
20 |
+
if (!self::isAeliaGeolocationEnabled() || self::doesWoocommerceHandleCache() || self::doesCacheHandlerHandleCache()) {
|
21 |
+
return true;
|
22 |
+
}
|
23 |
+
|
24 |
// use CloudFlare geolocation if available
|
25 |
if (isset($_SERVER["HTTP_CF_IPCOUNTRY"])) {
|
26 |
add_action('set_nitropack_geo_cache_prefix', function() {
|
40 |
return true;
|
41 |
}
|
42 |
|
43 |
+
// Check if ACS is configured to not geolocate or geolocation is already with caching
|
44 |
+
if (!self::isAeliaGeolocationEnabled() || self::doesWoocommerceHandleCache() || self::doesCacheHandlerHandleCache()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
self::resetVariationCookies();
|
46 |
return true;
|
47 |
}
|
93 |
&& empty($_COOKIE["aelia_customer_state"])
|
94 |
&& empty($_COOKIE["aelia_tax_exempt"])
|
95 |
) {
|
96 |
+
nitropack_header("X-Nitro-Disabled-Reason: Aelia cookie bypass");
|
97 |
return false;
|
98 |
}
|
99 |
|
100 |
return $currentState;
|
101 |
}
|
102 |
+
|
103 |
+
public static function isAeliaGeolocationEnabled() {
|
104 |
+
$siteConfig = get_nitropack()->getSiteConfig();
|
105 |
+
|
106 |
+
return !empty($siteConfig['options_cache']['wc_aelia_currency_switcher']['ipgeolocation_enabled'])
|
107 |
+
&& $siteConfig['options_cache']['wc_aelia_currency_switcher']['ipgeolocation_enabled'] == 1;
|
108 |
+
}
|
109 |
+
|
110 |
+
public static function doesWoocommerceHandleCache() {
|
111 |
+
$siteConfig = get_nitropack()->getSiteConfig();
|
112 |
+
|
113 |
+
return !empty($siteConfig['isWoocommerceActive'])
|
114 |
+
&& !empty($siteConfig['options_cache']['woocommerce_default_customer_address'])
|
115 |
+
&& "geolocation_ajax" === $siteConfig['options_cache']['woocommerce_default_customer_address'];
|
116 |
+
}
|
117 |
+
|
118 |
+
public static function doesCacheHandlerHandleCache() {
|
119 |
+
$siteConfig = get_nitropack()->getSiteConfig();
|
120 |
+
|
121 |
+
return !empty($siteConfig['isWoocommerceCacheHandlerActive'])
|
122 |
+
&& !empty($siteConfig['options_cache']['cache_handler_cache_handler'])
|
123 |
+
&& in_array($siteConfig['options_cache']['cache_handler_cache_handler'], ['enable_redirect', 'enable_ajax']);
|
124 |
+
}
|
125 |
}
|
classes/PluginStateHandler.php
CHANGED
@@ -5,7 +5,7 @@ namespace NitroPack;
|
|
5 |
use NitroPack\Integration\Plugin\AeliaCurrencySwitcher;
|
6 |
|
7 |
class PluginStateHandler {
|
8 |
-
|
9 |
'woocommerce-aelia-currencyswitcher/woocommerce-aelia-currencyswitcher.php' =>[
|
10 |
'activateCallback' => 'HandleAeliaCurrencyActivation',
|
11 |
'deactivateCallback' => 'HandleAeliaCurrencyDeactivation',
|
5 |
use NitroPack\Integration\Plugin\AeliaCurrencySwitcher;
|
6 |
|
7 |
class PluginStateHandler {
|
8 |
+
const eventHandlersMap = [
|
9 |
'woocommerce-aelia-currencyswitcher/woocommerce-aelia-currencyswitcher.php' =>[
|
10 |
'activateCallback' => 'HandleAeliaCurrencyActivation',
|
11 |
'deactivateCallback' => 'HandleAeliaCurrencyDeactivation',
|
classes/WordPress/NitroPack.php
CHANGED
@@ -6,7 +6,11 @@ class NitroPack {
|
|
6 |
public static $preUpdatePosts = array();
|
7 |
public static $preUpdateTaxonomies = array();
|
8 |
public static $ignoreUpdatePostIDs = array();
|
9 |
-
public static $optionsToCache = [
|
|
|
|
|
|
|
|
|
10 |
|
11 |
public static function getInstance() {
|
12 |
if (!self::$instance) {
|
@@ -110,7 +114,21 @@ class NitroPack {
|
|
110 |
"options_cache" => [],
|
111 |
);
|
112 |
foreach (self::$optionsToCache as $opt) {
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
}
|
115 |
$configSetResult = $this->Config->set($staticConfig);
|
116 |
|
6 |
public static $preUpdatePosts = array();
|
7 |
public static $preUpdateTaxonomies = array();
|
8 |
public static $ignoreUpdatePostIDs = array();
|
9 |
+
public static $optionsToCache = [
|
10 |
+
'cache_handler_cache_handler',
|
11 |
+
'woocommerce_default_customer_address',
|
12 |
+
[ "wc_aelia_currency_switcher" => "ipgeolocation_enabled"]
|
13 |
+
];
|
14 |
|
15 |
public static function getInstance() {
|
16 |
if (!self::$instance) {
|
114 |
"options_cache" => [],
|
115 |
);
|
116 |
foreach (self::$optionsToCache as $opt) {
|
117 |
+
if (is_array($opt)) {
|
118 |
+
foreach($opt as $option => $suboption) {
|
119 |
+
if (empty($staticConfig[$configKey]["options_cache"][$option])) {
|
120 |
+
$staticConfig[$configKey]["options_cache"][$option] = [];
|
121 |
+
}
|
122 |
+
$optionValue = get_option($option);
|
123 |
+
if (!empty($optionValue)) {
|
124 |
+
$staticConfig[$configKey]["options_cache"][$option][$suboption] = $optionValue[$suboption];
|
125 |
+
} else {
|
126 |
+
$staticConfig[$configKey]["options_cache"][$option][$suboption] = null;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
} else {
|
130 |
+
$staticConfig[$configKey]["options_cache"][$opt] = get_option($opt);
|
131 |
+
}
|
132 |
}
|
133 |
$configSetResult = $this->Config->set($staticConfig);
|
134 |
|
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.12' );
|
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
@@ -2538,7 +2538,7 @@ function nitropack_handle_request($servedFrom = "unknown") {
|
|
2538 |
}
|
2539 |
}
|
2540 |
|
2541 |
-
if (nitropack_passes_cookie_requirements()) {
|
2542 |
if ($nitro->isCacheAllowed()) {
|
2543 |
if (!nitropack_is_ajax()) {
|
2544 |
do_action("nitropack_cacheable_cache_headers");
|
@@ -2883,9 +2883,18 @@ function nitropack_plugin_notices() {
|
|
2883 |
$optionsMistmatch = false;
|
2884 |
if (array_key_exists('options_cache', $siteConfig)) {
|
2885 |
foreach (\NitroPack\WordPress\NitroPack::$optionsToCache as $opt) {
|
2886 |
-
if (
|
2887 |
-
$
|
2888 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2889 |
}
|
2890 |
}
|
2891 |
} else {
|
2538 |
}
|
2539 |
}
|
2540 |
|
2541 |
+
if (nitropack_passes_cookie_requirements() && apply_filters("nitropack_can_serve_cache", true)) {
|
2542 |
if ($nitro->isCacheAllowed()) {
|
2543 |
if (!nitropack_is_ajax()) {
|
2544 |
do_action("nitropack_cacheable_cache_headers");
|
2883 |
$optionsMistmatch = false;
|
2884 |
if (array_key_exists('options_cache', $siteConfig)) {
|
2885 |
foreach (\NitroPack\WordPress\NitroPack::$optionsToCache as $opt) {
|
2886 |
+
if (is_array($opt)) {
|
2887 |
+
foreach ($opt as $option => $suboption) {
|
2888 |
+
if (empty($siteConfig['options_cache'][$option][$suboption]) || $siteConfig['options_cache'][$option][$suboption] != get_option($option)[$suboption]) {
|
2889 |
+
$optionsMistmatch = true;
|
2890 |
+
break 2;
|
2891 |
+
}
|
2892 |
+
}
|
2893 |
+
} else {
|
2894 |
+
if (!array_key_exists($opt, $siteConfig['options_cache']) || $siteConfig['options_cache'][$opt] != get_option($opt)) {
|
2895 |
+
$optionsMistmatch = true;
|
2896 |
+
break;
|
2897 |
+
}
|
2898 |
}
|
2899 |
}
|
2900 |
} 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.
|
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.12
|
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.9
|
6 |
Requires PHP: 5.3
|
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.11 =
|
173 |
* Improvement: Make the connection to our API servers even more stable
|
174 |
* Improvement: Out of the box compatibility with Aelia Currency Switcher
|
4 |
Requires at least: 4.7
|
5 |
Tested up to: 5.9
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 1.5.12
|
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.12 =
|
173 |
+
* Improvement: Add exclude for a healtcheck endpoint in Pagely
|
174 |
+
* Bug fix: Resolve compatibility issues related to Aelia Currency Switcher
|
175 |
+
* Bug fix: Resolve an issue causing settings to be reset to "Standard" mode
|
176 |
+
|
177 |
= 1.5.11 =
|
178 |
* Improvement: Make the connection to our API servers even more stable
|
179 |
* Improvement: Out of the box compatibility with Aelia Currency Switcher
|
view/dashboard.php
CHANGED
@@ -792,8 +792,6 @@
|
|
792 |
};
|
793 |
|
794 |
let rangeInputElement = document.getElementById('range');
|
795 |
-
|
796 |
-
let defaultModeValue = rangeInputElement.value;
|
797 |
|
798 |
let className = document.getElementsByClassName("label");
|
799 |
|
@@ -852,16 +850,17 @@
|
|
852 |
document.getElementById('range').classList.add(classIndex[shown]);
|
853 |
}
|
854 |
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
|
|
861 |
};
|
862 |
|
863 |
rangeInputElement.oninput = changeMode;
|
864 |
-
rangeInputElement.oninput(false);
|
865 |
|
866 |
for (var i = min; i <= max; i++) {
|
867 |
let divisor = document.createElement('div');
|
792 |
};
|
793 |
|
794 |
let rangeInputElement = document.getElementById('range');
|
|
|
|
|
795 |
|
796 |
let className = document.getElementsByClassName("label");
|
797 |
|
850 |
document.getElementById('range').classList.add(classIndex[shown]);
|
851 |
}
|
852 |
|
853 |
+
if (do_save) {
|
854 |
+
atTimeout(async function() {
|
855 |
+
jQuery("#quicksetup-widget").cardOverlay("loading", {message: "Saving..."});
|
856 |
+
await saveSetting(shown);
|
857 |
+
jQuery("#quicksetup-widget").cardOverlay("clear");
|
858 |
+
}, 0);
|
859 |
+
}
|
860 |
};
|
861 |
|
862 |
rangeInputElement.oninput = changeMode;
|
863 |
+
//rangeInputElement.oninput(false);
|
864 |
|
865 |
for (var i = min; i <= max; i++) {
|
866 |
let divisor = document.createElement('div');
|