PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.16.0
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.16.0
1.19.8 1.19.7 1.19.6 1.19.5 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.11.0 1.12.0 1.13.0 1.14.0 1.15.0 1.15.1 1.15.2 1.15.3 1.16.0 1.16.1 1.16.2 1.16.3 1.16.4 1.16.5 1.16.6 1.16.7 1.16.8 1.17.0 1.17.6 1.17.7 1.17.8 1.17.9 1.18.0 1.18.1 1.18.2 1.18.3 1.18.4 1.18.5 1.18.6 1.18.7 1.18.8 1.18.9 1.19.0 1.19.1 1.19.2 1.19.3 1.19.4 1.3.19 1.3.20 1.4.0 1.4.1 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.16 1.5.17 1.5.18 1.5.19 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.8.1 1.8.3 1.9.0 1.9.1 1.9.2
nitropack / view / dashboard.php
nitropack / view Last commit date
images 1 year ago javascript 1 year ago modals 1 year ago stylesheet 1 year ago templates 2 years ago admin.php 1 year ago connect-oneclick.php 1 year ago connect.php 2 years ago dashboard-oneclick.php 2 years ago dashboard.php 1 year ago oneclick.php 2 years ago safemode.php 2 years ago system-report.php 1 year ago
dashboard.php
560 lines
1 <?php
2 $processing = 0;
3 $usage = '0 MB';
4 $max_usage = '1 GB';
5 $page_views = '0';
6 $max_page_views = '10000';
7 ?>
8 <?php nitropack_display_admin_notices(); ?>
9 <div class="grid grid-cols-2 gap-6 grid-col-1-tablet items-start">
10 <div class="col-span-1">
11 <!-- Optimized Pages Card -->
12 <div class="card card-optimized-pages">
13 <div class="card-header">
14 <h3><?php esc_html_e('Optimized pages', 'nitropack'); ?></h3>
15 <div class="flex flex-row items-center" style="display: none;" id="pending-optimizations-section">
16 <img src="<?php echo plugin_dir_url(__FILE__) . 'images/loading.svg'; ?>" alt="loading" class="w-4 h-4">
17 <span class="ml-2 mr-1 text-primary"> <?php esc_html_e('Processing', 'nitropack'); ?>
18 <span id="pending-optimizations-count">X</span> <?php esc_html_e('page(s) in the background', 'nitropack'); ?></span>
19 </div>
20 </div>
21 <div class="card-body">
22 <div class="flex flex-row items-center">
23 <div class="optimized-pages"><span data-optimized-pages-total>0</span></div>
24 <div class="text-box mr-2">
25 <p class="text-md"><?php esc_html_e('Last cache purge', 'nitropack'); ?>: <span data-last-cache-purge><?php esc_html_e('Never', 'nitropack'); ?></span> </br>
26 <?php esc_html_e('Reason', 'nitropack'); ?>: <span data-purge-reason><?php esc_html_e('Unknown', 'nitropack'); ?></span></p>
27 </div>
28 <button id="optimizations-purge-cache" type="button" class="ml-auto btn btn-secondary flex-shrink-0" data-modal-target="modal-purge-cache" data-modal-toggle="modal-purge-cache"><?php esc_html_e('Purge cache', 'nitropack'); ?></button>
29 </div>
30 </div>
31 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-purge-cache.php'; ?>
32 </div>
33 <!-- Optimized Pages Card End -->
34 <!-- Optimization Mode Card -->
35 <div class="card card-optimization-mode">
36 <div class="card-header no-border mb-0">
37 <div class="flex items-center">
38 <h3 class="mb-0"><?php esc_html_e('Optimization mode', 'nitropack'); ?></h3>
39 <span class="tooltip-icon" data-tooltip-target="tooltip-optimization">
40 <img src="<?php echo plugin_dir_url(__FILE__) . 'images/info.svg'; ?>">
41 </span>
42 <div id="tooltip-optimization" role="tooltip" class="tooltip-container hidden">
43 <?php esc_html_e('Select from our range of predefined optimization modes to boost your site\'s performance.', 'nitropack');
44 ?>
45 <div class="tooltip-arrow" data-popper-arrow></div>
46 </div>
47 </div>
48 </div>
49 <?php $modes = array('standard' => esc_html__('Standard', 'nitropack'), 'medium' => esc_html__('Medium', 'nitropack'), 'strong' => esc_html__('Strong', 'nitropack'), 'ludicrous' => esc_html__('Ludicrous', 'nitropack'), 'custom' => esc_html__('Custom', 'nitropack')); ?>
50 <div class="tabs-wrapper">
51 <div class="tabs" id="optimization-modes">
52 <?php foreach ($modes as $mode_id => $mode) : ?>
53 <a class="btn tab-link btn-link" data-mode="<?php echo $mode_id; ?>" data-modal-target="modal-optimization-mode" data-modal-toggle="modal-optimization-mode"><?php echo $mode; ?></a>
54 <?php endforeach; ?>
55 </div>
56 <p><?php esc_html_e('Active Mode', 'nitropack'); ?>: <span class="active-mode"></span></p>
57 <div class="tab-content-wrapper">
58 <div class="hidden tab-content" role="tabpanel" data-tab="standard-tab">
59 <p class="text-secondary mt-2"> <?php esc_html_e('Standard optimization features enabled for your site. Ideal choice for maximum stability.', 'nitropack'); ?></p>
60 </div>
61 <div class="hidden tab-content" role="tabpanel" data-tab="medium-tab">
62 <p class="text-secondary mt-2"> <?php esc_html_e('Adds image lazy loading to standard optimizations. Uses built-in browser techniques for loading resources.', 'nitropack'); ?></p>
63 </div>
64 <div class="hidden tab-content" role="tabpanel" data-tab="strong-tab">
65 <p class="text-secondary mt-2"> <?php esc_html_e('Includes smart resource loading on top of Medium optimizations. Balances speed boost with stability.', 'nitropack'); ?></p>
66 </div>
67 <div class="hidden tab-content" role="tabpanel" data-tab="ludicrous-tab">
68 <p class="text-secondary mt-2"> <?php esc_html_e('Applies deferred JS and advanced resource loading for optimal performance and Core Web Vitals.', 'nitropack'); ?></p>
69 </div>
70 <div class="hidden tab-content" role="tabpanel" data-tab="custom-tab">
71 <p class="text-secondary mt-2"> <?php esc_html_e('Activated when manual setups are made. Ideal for advanced NitroPack optimizations.', 'nitropack'); ?></p>
72 </div>
73 </div>
74 </div>
75 <div class="card-footer">
76 <div class="flex flex-row">
77 <p class=""><?php esc_html_e('Which optimization mode to choose?', 'nitropack'); ?></p>
78 <a href="#" class="text-primary ml-auto" data-modal-target="modes-modal" data-modal-toggle="modes-modal"><?php esc_html_e('See modes comparison', 'nitropack'); ?></a>
79 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-modes.php'; ?>
80 </div>
81 </div>
82 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-optimization-mode.php'; ?>
83 </div>
84 <!-- Optimization Mode Card End -->
85 <!-- Automated Behavior Card -->
86 <div class="card card-automated-behavior">
87 <div class="card-header">
88 <h3><?php esc_html_e('Automated Behavior', 'nitropack'); ?></h3>
89 </div>
90 <div class="card-body">
91 <div class="options-container">
92 <div class="nitro-option" id="purge-cache-widget">
93 <div class="nitro-option-main">
94 <div class="text-box">
95 <h6><?php esc_html_e('Purge cache', 'nitropack'); ?></h6>
96 <p><?php esc_html_e('Purge affected cache when content is updated or published', 'nitropack'); ?></p>
97 </div>
98 <label class="inline-flex items-center cursor-pointer ml-auto">
99 <input type="checkbox" value="" class="sr-only peer" name="purge_cache" id="auto-purge-status" <?php if ($autoCachePurge) echo "checked"; ?>>
100 <div class="toggle"></div>
101 </label>
102 </div>
103 </div>
104 <div class="nitro-option" id="page-optimization-widget">
105 <div class="nitro-option-main">
106 <div class="text-box">
107 <h6><?php esc_html_e('Page optimization', 'nitropack'); ?></h6>
108 <p><?php esc_html_e('Select what post/page types get optimized', 'nitropack'); ?></p>
109 </div>
110 <a data-modal-target="modal-posttypes" data-modal-toggle="modal-posttypes" class="btn btn-secondary btn-icon" href="#">
111 <img src="<?php echo plugin_dir_url(__FILE__); ?>images/setting-icon.svg">
112 </a>
113 </div>
114 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-posttypes.php'; ?>
115 </div>
116 </div>
117 </div>
118 </div>
119 <!-- Automated Behavior Card End -->
120 <!-- Go to app Card -->
121 <div class="card app-card">
122 <div class="card-body">
123 <div class="flex items-center justify-between">
124 <p><?php esc_html_e('You can further configure how NitroPack\'s optimization behaves through your account', 'nitropack'); ?>.</p>
125 <?php
126 function getNitropackDashboardUrl() {
127 $siteId = nitropack_get_current_site_id();
128 $dashboardUrl = 'https://app.nitropack.io/dashboard';
129
130 if ($siteId !== null) {
131 $dashboardUrl .= '?update_session_website_id=' . urlencode($siteId);
132 }
133
134 return $dashboardUrl;
135 }
136 ?>
137 <a href="<?php echo esc_url(getNitropackDashboardUrl()); ?>" target="_blank" class="btn btn-primary ml-2 flex-shrink-0"><?php esc_html_e('Go to app', 'nitropack'); ?></a>
138 </div>
139 </div>
140 </div>
141 <!-- Go to app card End -->
142 </div>
143 <div class="col-span-1">
144 <!-- Subscription Card -->
145 <div class="card card-subscription">
146 <div class="card-header">
147 <h3><?php esc_html_e('Subscription', 'nitropack'); ?></h3>
148 </div>
149 <div class="card-body">
150 <div class="flex flex-row items-center">
151 <div class="plan-name"><?php esc_html_e('Free', 'nitropack'); ?></div>
152 <a type="button" target="_blank" href="https://app.nitropack.io/account/billing" class="btn btn-secondary ml-auto" id="btn-manage-subscription"><?php esc_html_e('Manage subscription', 'nitropack'); ?></a>
153 </div>
154 <div class="table-wrapper">
155 <table class="w-full">
156 <tbody>
157 <tr>
158 <td class="key"><?php esc_html_e('Next reset', 'nitropack'); ?></td>
159 <td class="value" data-next-reset><?php esc_html_e('No ETA', 'nitropack'); ?></td>
160 </tr>
161 <tr>
162 <td class="key"><?php esc_html_e('Next billing', 'nitropack'); ?></td>
163 <td class="value" data-next-billing><?php esc_html_e('No ETA', 'nitropack'); ?></td>
164 </tr>
165 <tr>
166 <td class="key"><?php esc_html_e('Page views', 'nitropack'); ?></td>
167 <td class="value" data-page-views><?php printf( esc_html__('%1$s out of %2$s', 'nitropack'), $page_views, $max_page_views); ?></td>
168 </tr>
169 <tr>
170 <td class="key"><?php esc_html_e('CDN bandwidth', 'nitropack'); ?></td>
171 <td class="value" data-cdn-bandwidth><?php printf( esc_html__('%1$s out of %2$s', 'nitropack'), $usage, $max_usage); ?></td>
172 </tr>
173 </tbody>
174 </table>
175 </div>
176 </div>
177 <div class="card-footer">
178 <p class="text-secondary text-smaller"><?php esc_html_e('You will be notified by email when your website reaches the subscription resource limits.', 'nitropack'); ?></p>
179 </div>
180 </div>
181 <!-- Subscription Card End -->
182 <!-- Basic Settings Card -->
183 <div class="card card-basic-settings">
184 <div class="card-header">
185 <h3><?php esc_html_e('Basic Settings', 'nitropack'); ?></h3>
186 </div>
187 <div class="card-body">
188 <div class="options-container">
189 <div class="nitro-option" id="cache-warmup-widget">
190 <div class="nitro-option-main">
191 <div class="text-box" id="warmup-status-slider">
192
193 <?php $sitemap = get_option('np_warmup_sitemap', false);
194 $toolTipDisplayState = $sitemap ? '' : 'hidden'; ?>
195
196 <h6><?php esc_html_e('Cache warmup', 'nitropack'); ?> <span class="badge badge-primary ml-2"><?php esc_html_e('Recommeneded', 'nitropack'); ?></span> <span class="tooltip-icon <?php echo $toolTipDisplayState; ?>" data-tooltip-target="tooltip-sitemap">
197 <img src="<?php echo plugin_dir_url(__FILE__) . 'images/info.svg'; ?>">
198 </span></h6>
199 <div id="tooltip-sitemap" role="tooltip" class="tooltip-container hidden">
200 <?php echo $sitemap; ?>
201 <div class="tooltip-arrow" data-popper-arrow></div>
202 </div>
203 <p><?php esc_html_e('Automatically pre-caches your website\'s page content', 'nitropack'); ?>. <a href="https://support.nitropack.io/en/articles/8390320-cache-warmup" class="text-blue" target="_blank"><?php esc_html_e('Learn more', 'nitropack'); ?></a></p>
204 </div>
205 <label class="inline-flex items-center cursor-pointer ml-auto">
206 <input id="warmup-status" type="checkbox" class="sr-only peer">
207 <div class="toggle"></div>
208 </label>
209 </div>
210 <div class="msg-container" id="loading-warmup-status">
211 <img src="<?php echo plugin_dir_url(__FILE__) . 'images/loading.svg'; ?>" alt="loading" class="icon"> <span class="msg"><?php esc_html_e('Loading cache warmup status', 'nitropack'); ?></span>
212 </div>
213 </div>
214 <div class="nitro-option" id="test-mode-widget">
215 <div class="nitro-option-main">
216 <div class="text-box" id="safemode-status-slider">
217 <h6><?php esc_html_e('Test Mode', 'nitropack'); ?></h6>
218 <p><?php esc_html_e('Test NitroPack\'s features without affecting your visitors\' experience', 'nitropack'); ?>. <a href="https://support.nitropack.io/en/articles/8390292-test-mode" class="text-blue" target="_blank"><?php esc_html_e('Learn more', 'nitropack'); ?></a></p>
219 </div>
220
221 <label class="inline-flex items-center cursor-pointer ml-auto" >
222 <input type="checkbox" class="sr-only peer" id="safemode-status">
223
224 <div class="toggle"></div>
225 </label>
226 </div>
227 <div class="msg-container" id="loading-safemode-status">
228 <img src="<?php echo plugin_dir_url(__FILE__) . 'images/loading.svg'; ?>" alt="loading" class="icon"> <?php esc_html_e('Loading test mode status', 'nitropack'); ?>
229 </div>
230 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-test-mode.php'; ?>
231 </div>
232 <div class="nitro-option" id="compression-widget">
233 <div class="nitro-option-main">
234 <div class="text-box">
235 <h6><span id="detected-compression"><?php esc_html_e('HTML Compression', 'nitropack'); ?> </span></h6>
236 <p><?php esc_html_e('Compressing the structure of your HTML, ensures faster page rendering and an optimized browsing experience for your users.', 'nitropack'); ?> <a href="https://support.nitropack.io/en/articles/8390333-nitropack-plugin-settings-in-wordpress#h_29b7ab4836" class="text-blue" target="_blank"><?php esc_html_e('Learn more', 'nitropack'); ?></a></p>
237 </div>
238 <label class="inline-flex items-center cursor-pointer ml-auto">
239 <input type="checkbox" id="compression-status" class="sr-only peer" <?php echo (int)$enableCompression === 1 ? "checked" : ""; ?>>
240 <div class="toggle"></div>
241 </label>
242 </div>
243 <div class="mt-4 text-primary">
244 <a href="javascript:void(0);" id="compression-test-btn" class="text-primary"><?php esc_html_e('Run compression test', 'nitropack'); ?></a>
245 <div class="flex items-start msg-container hidden">
246 <span class="msg"></span>
247 </div>
248 </div>
249 </div>
250 <?php if (\NitroPack\Integration\Plugin\BeaverBuilder::isActive()) { ?>
251 <div class="nitro-option" id="beaver-builder-widget">
252 <div class="nitro-option-main">
253 <div class="text-box">
254 <h6><span id="detected-compression"><?php esc_html_e('Sync NitroPack Purge with Beaver Builder', 'nitropack'); ?> </span></h6>
255 <p><?php esc_html_e('When Beaver Builder cache is purged, NitroPack will perform a full cache purge keeping your site\'s content up-to-date.', 'nitropack'); ?></p>
256 </div>
257 <label class="inline-flex items-center cursor-pointer ml-auto">
258 <input type="checkbox" class="sr-only peer" id="bb-purge-status" <?php if ($bbCacheSyncPurge) echo "checked"; ?>>
259 <div class="toggle"></div>
260 </label>
261 </div>
262 </div>
263 <?php } ?>
264
265 <?php if (nitropack_render_woocommerce_cart_cache_option()) { ?>
266 <div class="nitro-option" id="cart-cache-widget">
267 <div class="nitro-option-main">
268 <div class="text-box">
269 <h6><?php esc_html_e('Cart cache', 'nitropack'); ?> <span class="badge badge-success ml-2">New</span></h6>
270 <p><?php esc_html_e('Your visitors will enjoy full site speed while browsing with items in cart. Fully optimized page cache will be served.', 'nitropack'); ?></p>
271
272 </div>
273 <label class="inline-flex items-center cursor-pointer ml-auto">
274 <input type="checkbox" id="cart-cache-status" class="sr-only peer" <?php if (nitropack_is_cart_cache_active()) echo "checked"; ?> <?php if (!nitropack_is_cart_cache_available()) echo "disabled"; ?>>
275 <div class="toggle"></div>
276 </label>
277 </div>
278 <?php if (!nitropack_is_cart_cache_available()) : ?>
279 <div class="msg-container bg-success paid-msg">
280 <p><svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="text-success">
281 <g clip-path="url(#clip0_1244_36215)">
282 <path d="M10.0001 18.3333C14.6025 18.3333 18.3334 14.6023 18.3334 9.99996C18.3334 5.39759 14.6025 1.66663 10.0001 1.66663C5.39771 1.66663 1.66675 5.39759 1.66675 9.99996C1.66675 14.6023 5.39771 18.3333 10.0001 18.3333Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
283 <path d="M13.3334 9.99996L10.0001 6.66663L6.66675 9.99996" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
284 <path d="M10 13.3333V6.66663" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
285 </g>
286 <defs>
287 <clipPath id="clip0_1244_36215">
288 <rect width="20" height="20" fill="white"></rect>
289 </clipPath>
290 </defs>
291 </svg> <?php esc_html_e('This feature is available on paid subscription.', 'nitropack'); ?> <a href="https://app.nitropack.io/subscription/buy" class="text-primary" target="_blank"><b><?php esc_html_e('Upgrade here', 'nitropack'); ?></b></a>
292 </p>
293 </div>
294 <?php endif; ?>
295 </div>
296 <div class="nitro-option" id="real-time-stock-refresh-widget">
297 <div class="nitro-option-main">
298 <div class="text-box">
299 <h6><?php esc_html_e('Real-time Stock Refresh', 'nitropack'); ?></h6>
300 <p><?php esc_html_e('Keep accurate product availability on your WooCommerce site. Turn on this feature if you display stock quantities, and enjoy automatic cache clearance when stock decreases.', 'nitropack'); ?></p>
301
302 </div>
303 <label class="inline-flex items-center cursor-pointer ml-auto">
304 <input type="checkbox" id="woo-stock-reduce-status" class="sr-only peer" <?php echo (int)$stockReduceStatus === 1 ? "checked" : ""; ?>>
305 <div class="toggle"></div>
306 </label>
307 </div>
308 </div>
309 <?php } ?>
310 </div>
311 </div>
312 <div class="card-footer disconnect-container">
313 <a href="#" class="text-primary" id="disconnect-btn"><?php esc_html_e('Disconnect NitroPack plugin', 'nitropack'); ?></a>
314 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-disconnect.php'; ?>
315 </div>
316 </div>
317 <!-- Basic Settings Card End -->
318 </div>
319 </div>
320
321 <script>
322 ($ => {
323 var getOptimizationsTimeout = null;
324 let isClearing = false;
325 var paid_plan = false;
326 $(window).on("load", function() {
327 getOptimizations();
328 getPlan();
329 <?php if ($checkedCompression != 1) { ?>
330 autoDetectCompression();
331 <?php } ?>
332 });
333
334 /* Cache Purge begin */
335 window.performCachePurge = () => {
336 purgeCache();
337 }
338
339 let purgeCache = () => {
340 let purgeEvent = new Event("cache.purge.request");
341 window.dispatchEvent(purgeEvent);
342 }
343
344 var getOptimizations = _ => {
345 var url = '<?php echo $optimizationDetailsUrl; ?>';
346 ((s, e, f) => {
347 if (window.fetch) {
348 fetch(url)
349 .then(resp => resp.json())
350 .then(s)
351 .catch(e)
352 .finally(f);
353 } else {
354 $.ajax({
355 url: url,
356 type: 'GET',
357 dataType: 'json',
358 success: s,
359 error: e,
360 complete: f
361 })
362 }
363 })(data => {
364 $('[data-last-cache-purge]').text(data.last_cache_purge.timeAgo);
365 if (data.last_cache_purge.reason) {
366 $('[data-purge-reason]').text(data.last_cache_purge.reason);
367 $('#last-cache-purge-reason').show();
368 } else {
369 $('#last-cache-purge-reason').hide();
370 }
371 if (data.pending_count) {
372 $("#pending-optimizations-count").text(data.pending_count);
373 $("#pending-optimizations-section").show();
374 } else {
375 $("#pending-optimizations-section").hide();
376 }
377
378 $('[data-optimized-pages-total]').text(data.optimized_pages.total);
379
380 }, __ => {
381 console.error("An error occurred while fetching data for optimized pages");
382 }, __ => {
383 if (!getOptimizationsTimeout) {
384 getOptimizationsTimeout = setTimeout(function() {
385 getOptimizationsTimeout = null;
386 getOptimizations();
387 }, 60000);
388 }
389 });
390 }
391
392 var getPlan = _ => {
393
394 var url = '<?php echo $planDetailsUrl; ?>';
395 ((s, e, f) => {
396 if (window.fetch) {
397 fetch(url)
398 .then(resp => resp.json())
399 .then(s)
400 .catch(e)
401 .finally(f);
402 } else {
403 $.ajax({
404 url: url,
405 type: 'GET',
406 dataType: 'json',
407 success: s,
408 error: e,
409 complete: f
410 })
411 }
412 })(data => {
413
414 $('.plan-name').text(data.plan_title);
415 $('[data-next-billing]').text(data.next_billing ? data.next_billing : 'N/A');
416 $('[data-next-reset]').text(data.next_reset ? data.next_reset : 'N/A');
417 $('[data-page-views]').text(data.page_views ? data.page_views : 'N/A');
418 $('[data-cdn-bandwidth]').text(data.cdn_bandwidth ? data.cdn_bandwidth + ' out of ' + data.max_cdn_bandwidth : 'N/A');
419
420 for (prop in data) {
421 if (prop.indexOf("show_") === 0) continue;
422 if (prop.indexOf("label_") === 0) continue;
423 if (prop.indexOf("max_") === 0) continue;
424 if (
425 typeof data["show_" + prop] != "undefined" &&
426 data["show_" + prop] &&
427 typeof data["label_" + prop] != "undefined" &&
428 typeof data["max_" + prop] != "undefined"
429 ) {
430 let propertyLabel = data["label_" + prop];
431 let propertyValue = data[prop];
432 let propertyLimit = data["max_" + prop];
433 $("#plan-quotas").append('<li class="list-group-item px-0 d-flex justify-content-between align-items-center">' + propertyLabel + ' <span><span data-optimizations>' + propertyValue + '</span> out of <span data-max-optimizations>' + propertyLimit + '</span></span></li>');
434 }
435 }
436
437 }, __ => {
438 NitropackUI.triggerToast('error', '<?php esc_html_e('Error while fetching plan data', 'nitropack'); ?>');
439 }, __ => {});
440 }
441
442 $(document).on('click', "#compression-test-btn", e => {
443 e.preventDefault();
444 autoDetectCompression();
445 });
446 /* Compression end */
447
448 /* HTML Compression begin */
449 var autoDetectCompression = function() {
450 let msg_container = $('#compression-widget .msg-container'),
451 msg_icon = msg_container.find('.icon'),
452 msg_box = msg_container.find('.msg'),
453 compression_setting = $('#compression-status'),
454 compression_btn = $('#compression-test-btn');
455 //add spinner here
456 msg_box.html('<img src="<?php echo plugin_dir_url(__FILE__) . 'images/loading.svg'; ?>" alt="loading" class="icon"> <?php esc_html_e('Testing current compression status', 'nitropack'); ?>');
457 compression_btn.addClass('hidden');
458 msg_container.removeClass('hidden');
459 $.post(ajaxurl, {
460 action: 'nitropack_test_compression_ajax',
461 nonce: nitroNonce
462 }, function(response) {
463 var resp = JSON.parse(response);
464
465 if (resp.status == "success") {
466 if (resp.hasCompression) { // compression already enabled
467 compression_setting.attr("checked", false);
468
469 msg_box.text('<?php esc_html_e('Compression is already enabled on your server! There is no need to enable it in NitroPack.', 'nitropack'); ?>')
470 } else {
471 compression_setting.attr("checked", true);
472 msg_box.text('<?php esc_html_e('No compression was detected! We will now enable it in NitroPack.', 'nitropack'); ?>');
473 }
474 NitropackUI.triggerToast(resp.type, resp.message);
475 } else {
476 msg_box.text('<?php esc_html_e('Could not determine compression status automatically. Please configure it manually.', 'nitropack'); ?>');
477 }
478 setTimeout(function() {
479 msg_container.addClass('hidden');
480 compression_btn.removeClass('hidden');
481 }, 5000);
482 });
483 }
484
485
486 $("#compression-status").on("click", function(e) {
487 $.post(ajaxurl, {
488 action: 'nitropack_set_compression_ajax',
489 nonce: nitroNonce,
490 data: {
491 compressionStatus: $(this).is(":checked") ? 1 : 0
492 }
493 }, function(response) {
494 var resp = JSON.parse(response);
495 NitropackUI.triggerToast(resp.type, resp.message);
496 });
497 });
498
499 $("#auto-purge-status").on("click", function(e) {
500 $.post(ajaxurl, {
501 action: 'nitropack_set_auto_cache_purge_ajax',
502 nonce: nitroNonce,
503 autoCachePurgeStatus: $(this).is(":checked") ? 1 : 0
504 }, function(response) {
505 var resp = JSON.parse(response);
506 NitropackUI.triggerToast(resp.type, resp.message);
507 });
508 });
509
510 $("#cart-cache-status").on("click", function(e) {
511 $.post(ajaxurl, {
512 action: 'nitropack_set_cart_cache_ajax',
513 nonce: nitroNonce,
514 cartCacheStatus: $(this).is(":checked") ? 1 : 0
515 }, function(response) {
516 var resp = JSON.parse(response);
517 NitropackUI.triggerToast(resp.type, resp.message);
518 });
519 });
520
521
522 $("#woo-stock-reduce-status").on("click", function(e) {
523 $.post(ajaxurl, {
524 action: 'nitropack_set_stock_reduce_status',
525 nonce: nitroNonce,
526 data: {
527 stockReduceStatus: $(this).is(":checked") ? 1 : 0
528 }
529 }, function(response) {
530 var resp = JSON.parse(response);
531 NitropackUI.triggerToast(resp.type, resp.message);
532 });
533 });
534
535 $("#legacy-purge-status").on("click", function(e) {
536 $.post(ajaxurl, {
537 action: 'nitropack_set_legacy_purge_ajax',
538 nonce: nitroNonce,
539 legacyPurgeStatus: $(this).is(":checked") ? 1 : 0
540 }, function(response) {
541 var resp = JSON.parse(response);
542 NitropackUI.triggerToast(resp.type, resp.message);
543
544 });
545 });
546
547 $("#bb-purge-status").on("click", function(e) {
548 $.post(ajaxurl, {
549 action: 'nitropack_set_bb_cache_purge_sync_ajax',
550 nonce: nitroNonce,
551 bbCachePurgeSyncStatus: $(this).is(":checked") ? 1 : 0
552 }, function(response) {
553 var resp = JSON.parse(response);
554 NitropackUI.triggerToast(resp.type, resp.message);
555 });
556 });
557
558
559 })(jQuery);
560 </script>