PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.18.3
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.18.3
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 11 months ago modals 11 months ago stylesheet 11 months ago templates 1 year ago admin.php 1 year ago connect-oneclick.php 1 year ago connect.php 1 year ago dashboard-oneclick.php 11 months ago dashboard.php 11 months ago oneclick.php 1 year ago system-report.php 1 year ago
dashboard.php
590 lines
1 <?php
2 $settings = new \NitroPack\WordPress\Settings();
3 $notifications = new \NitroPack\WordPress\Notifications\Notifications();
4 $usage = '0 MB';
5 $max_usage = '1 GB';
6 $page_views = '0';
7 $max_page_views = '10000'; ?>
8
9 <?php $notifications->nitropack_display_admin_notices(); ?>
10
11 <div class="grid grid-cols-2 gap-6 grid-col-1-tablet items-start nitropack-dashboard">
12 <div class="col-span-1">
13 <!-- Optimized Pages Card -->
14 <div class="card card-optimized-pages">
15 <div class="card-header">
16 <h3><?php esc_html_e('Optimized pages', 'nitropack'); ?></h3>
17 <div class="flex flex-row items-center" style="display: none;" id="pending-optimizations-section">
18 <img src="<?php echo plugin_dir_url(__FILE__) . 'images/loading.svg'; ?>" alt="loading" class="w-4 h-4">
19 <span class="ml-2 mr-1 text-primary"> <?php esc_html_e('Processing', 'nitropack'); ?>
20 <span id="pending-optimizations-count">X</span> <?php esc_html_e('page(s) in the background', 'nitropack'); ?></span>
21 </div>
22 </div>
23 <div class="card-body">
24 <div class="card-body-inner">
25 <div class="optimized-pages"><span data-optimized-pages-total>0</span></div>
26 <div class="text-box">
27 <div class="time-ago"><?php esc_html_e('Last cache purge', 'nitropack'); ?>: <span data-last-cache-purge><?php esc_html_e('Never', 'nitropack'); ?></span></div>
28 <div class="reason"><?php esc_html_e('Reason', 'nitropack'); ?>: <span data-purge-reason><?php esc_html_e('Unknown', 'nitropack'); ?></span></div>
29 </div>
30 <button id="optimizations-purge-cache" type="button" class="btn btn-secondary" data-modal-target="modal-purge-cache" data-modal-toggle="modal-purge-cache"><?php esc_html_e('Purge cache', 'nitropack'); ?></button>
31 </div>
32 </div>
33 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-purge-cache.php'; ?>
34 </div>
35 <!-- Optimized Pages Card End -->
36 <!-- Optimization Mode Card -->
37 <div class="card card-optimization-mode">
38 <div class="card-header no-border mb-0">
39 <div class="flex items-center">
40 <h3 class="mb-0"><?php esc_html_e('Optimization mode', 'nitropack'); ?></h3>
41 <span class="tooltip-icon" data-tooltip-target="tooltip-optimization">
42 <img src="<?php echo plugin_dir_url(__FILE__) . 'images/info.svg'; ?>">
43 </span>
44 <div id="tooltip-optimization" role="tooltip" class="tooltip-container hidden">
45 <?php esc_html_e('Select from our range of predefined optimization modes to boost your site\'s performance.', 'nitropack');
46 ?>
47 <div class="tooltip-arrow" data-popper-arrow></div>
48 </div>
49 </div>
50 </div>
51 <?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')); ?>
52 <div class="tabs-wrapper">
53 <div class="tabs" id="optimization-modes">
54 <?php foreach ( $modes as $mode_id => $mode ) :
55 $disabled = ( $mode_id === 'custom' ) ? 'disabled' : '';
56 ?>
57 <a class="btn tab-link btn-link <?php echo $disabled; ?>" data-mode="<?php echo $mode_id; ?>"
58 data-modal-target="modal-optimization-mode" data-modal-toggle="modal-optimization-mode" <?php echo $disabled; ?>><?php echo $mode; ?></a>
59 <?php endforeach; ?>
60 </div>
61 <p><?php esc_html_e('Active Mode', 'nitropack'); ?>: <span class="active-mode"></span></p>
62 <div class="tab-content-wrapper">
63 <div class="hidden tab-content" role="tabpanel" data-tab="standard-tab">
64 <p class="text-secondary mt-2"> <?php esc_html_e('Standard optimization features enabled for your site. Ideal choice for maximum stability.', 'nitropack'); ?></p>
65 </div>
66 <div class="hidden tab-content" role="tabpanel" data-tab="medium-tab">
67 <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>
68 </div>
69 <div class="hidden tab-content" role="tabpanel" data-tab="strong-tab">
70 <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>
71 </div>
72 <div class="hidden tab-content" role="tabpanel" data-tab="ludicrous-tab">
73 <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>
74 </div>
75 <div class="hidden tab-content" role="tabpanel" data-tab="custom-tab">
76 <p class="text-secondary mt-2"> <?php esc_html_e('Activated when manual setups are made. Ideal for advanced NitroPack optimizations.', 'nitropack'); ?></p>
77 </div>
78 </div>
79 </div>
80 <div class="card-footer">
81 <div class="flex flex-row">
82 <p class=""><?php esc_html_e('Which optimization mode to choose?', 'nitropack'); ?></p>
83 <a class="text-primary btn-link ml-auto see-modes" data-modal-target="modes-modal" data-modal-toggle="modes-modal"><?php esc_html_e('See modes comparison', 'nitropack'); ?></a>
84 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-modes.php'; ?>
85 </div>
86 </div>
87 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-optimization-mode.php'; ?>
88 </div>
89 <!-- Optimization Mode Card End -->
90 <!-- Automated Behavior Card -->
91 <div class="card card-automated-behavior">
92 <div class="card-header">
93 <h3><?php esc_html_e('Automated Behavior', 'nitropack'); ?></h3>
94 </div>
95 <div class="card-body">
96 <div class="options-container">
97 <div class="nitro-option" id="purge-cache-widget">
98 <div class="nitro-option-main">
99 <div class="text-box">
100 <h6><?php esc_html_e('Purge cache', 'nitropack'); ?></h6>
101 <p><?php esc_html_e('Purge affected cache when content is updated or published', 'nitropack'); ?></p>
102 </div>
103 <label class="inline-flex items-center cursor-pointer ml-auto">
104 <input type="checkbox" value="" class="sr-only peer" name="purge_cache" id="auto-purge-status" <?php if ($autoCachePurge) echo "checked"; ?>>
105 <div class="toggle"></div>
106 </label>
107 </div>
108 </div>
109 <div class="nitro-option" id="page-optimization-widget">
110 <div class="nitro-option-main">
111 <div class="text-box">
112 <h6><?php esc_html_e('Page optimization', 'nitropack'); ?></h6>
113 <p><?php esc_html_e('Select what post/page types get optimized', 'nitropack'); ?></p>
114 </div>
115 <a data-modal-target="modal-posttypes" data-modal-toggle="modal-posttypes" class="btn btn-secondary btn-icon">
116 <img src="<?php echo plugin_dir_url(__FILE__); ?>images/setting-icon.svg">
117 </a>
118 </div>
119 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-posttypes.php'; ?>
120 </div>
121 </div>
122 </div>
123 </div>
124 <!-- Automated Behavior Card End -->
125 <!-- Go to app Card -->
126 <div class="card exclusion-card">
127 <div class="card-header">
128 <h3><?php esc_html_e('Exclusions', 'nitropack'); ?></h3>
129 </div>
130 <div class="card-body">
131 <div class="options-container">
132 <div class="nitro-option" id="ajax-shortcodes-widget">
133 <?php $settings->shortcodes->render(); ?>
134 </div>
135 </div>
136 </div>
137 </div>
138 <!-- Go to app card End -->
139
140
141 </div>
142 <div class="col-span-1">
143 <!-- Subscription Card -->
144 <div class="card card-subscription">
145 <div class="card-header">
146 <h3><?php esc_html_e('Subscription', 'nitropack'); ?></h3>
147 </div>
148 <div class="card-body">
149 <div class="flex flex-row items-center">
150 <div class="plan-name"><?php esc_html_e('Free', 'nitropack'); ?></div>
151 <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>
152 </div>
153 <div class="table-wrapper">
154 <table class="w-full">
155 <tbody>
156 <tr>
157 <td class="key"><?php esc_html_e('Next reset', 'nitropack'); ?></td>
158 <td class="value" data-next-reset><?php esc_html_e('No ETA', 'nitropack'); ?></td>
159 </tr>
160 <tr>
161 <td class="key"><?php esc_html_e('Next billing', 'nitropack'); ?></td>
162 <td class="value" data-next-billing><?php esc_html_e('No ETA', 'nitropack'); ?></td>
163 </tr>
164 <tr>
165 <td class="key"><?php esc_html_e('Page views', 'nitropack'); ?></td>
166 <td class="value" data-page-views><?php printf(esc_html__('%1$s out of %2$s', 'nitropack'), $page_views, $max_page_views); ?></td>
167 </tr>
168 <tr>
169 <td class="key"><?php esc_html_e('CDN bandwidth', 'nitropack'); ?></td>
170 <td class="value" data-cdn-bandwidth><?php printf(esc_html__('%1$s out of %2$s', 'nitropack'), $usage, $max_usage); ?></td>
171 </tr>
172 </tbody>
173 </table>
174 </div>
175 </div>
176 <div class="card-footer">
177 <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>
178 </div>
179 </div>
180 <!-- Subscription Card End -->
181 <!-- Basic Settings Card -->
182 <div class="card card-basic-settings">
183 <div class="card-header">
184 <h3><?php esc_html_e('Basic Settings', 'nitropack'); ?></h3>
185 </div>
186 <div class="card-body">
187 <div class="options-container">
188 <div class="nitro-option" id="cache-warmup-widget">
189 <div class="nitro-option-main">
190 <div class="text-box" id="warmup-status-slider">
191
192 <?php $sitemap = get_option('np_warmup_sitemap', false);
193 $toolTipDisplayState = $sitemap ? '' : 'hidden'; ?>
194
195 <h6><?php esc_html_e('Cache warmup', 'nitropack'); ?> <span class="badge badge-primary ml-2"><?php esc_html_e('Recommended', 'nitropack'); ?></span> <span class="tooltip-icon <?php echo $toolTipDisplayState; ?>" data-tooltip-target="tooltip-sitemap">
196 <img src="<?php echo plugin_dir_url(__FILE__) . 'images/info.svg'; ?>">
197 </span></h6>
198 <div id="tooltip-sitemap" role="tooltip" class="tooltip-container hidden">
199 <?php echo $sitemap; ?>
200 <div class="tooltip-arrow" data-popper-arrow></div>
201 </div>
202 <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>
203 </div>
204 <label class="inline-flex items-center cursor-pointer ml-auto">
205 <input id="warmup-status" type="checkbox" class="sr-only peer">
206 <div class="toggle"></div>
207 </label>
208 </div>
209 <div class="msg-container" id="loading-warmup-status">
210 <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>
211 </div>
212 </div>
213
214 <?php $settings->test_mode->render(); ?>
215
216 <div class="nitro-option" id="compression-widget">
217 <div class="nitro-option-main">
218 <div class="text-box">
219 <h6><span id="detected-compression"><?php esc_html_e('HTML Compression', 'nitropack'); ?> </span></h6>
220 <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>
221 </div>
222 <label class="inline-flex items-center cursor-pointer ml-auto">
223 <input type="checkbox" id="compression-status" class="sr-only peer" <?php echo (int)$enableCompression === 1 ? "checked" : ""; ?>>
224 <div class="toggle"></div>
225 </label>
226 </div>
227 <div class="mt-4 text-primary">
228 <a href="javascript:void(0);" id="compression-test-btn" class="text-primary"><?php esc_html_e('Run compression test', 'nitropack'); ?></a>
229 <div class="flex items-start msg-container hidden">
230 <span class="msg"></span>
231 </div>
232 </div>
233 </div>
234 <?php if (\NitroPack\Integration\Plugin\BeaverBuilder::isActive()) { ?>
235 <div class="nitro-option" id="beaver-builder-widget">
236 <div class="nitro-option-main">
237 <div class="text-box">
238 <h6><span id="detected-compression"><?php esc_html_e('Sync NitroPack Purge with Beaver Builder', 'nitropack'); ?> </span></h6>
239 <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>
240 </div>
241 <label class="inline-flex items-center cursor-pointer ml-auto">
242 <input type="checkbox" class="sr-only peer" id="bb-purge-status" <?php if ($bbCacheSyncPurge) echo "checked"; ?>>
243 <div class="toggle"></div>
244 </label>
245 </div>
246 </div>
247 <?php } ?>
248 <div class="nitro-option" id="can-editor-clear-cache-widget">
249 <div class="nitro-option-main">
250 <div class="text-box">
251 <h6><?php esc_html_e('Allow Editors to purge cache', 'nitropack'); ?></h6>
252 <p><?php esc_html_e('Give Editors the right to purge cache when content is updated.', 'nitropack'); ?></p>
253 </div>
254 <label class="inline-flex items-center cursor-pointer ml-auto">
255 <input type="checkbox" id="can-editor-clear-cache" class="sr-only peer" <?php echo (int)$canEditorClearCache === 1 ? "checked" : ""; ?>>
256 <div class="toggle"></div>
257 </label>
258 </div>
259 </div>
260 <?php if (nitropack_render_woocommerce_cart_cache_option()) { ?>
261 <div class="nitro-option" id="cart-cache-widget">
262 <div class="nitro-option-main">
263 <div class="text-box">
264 <h6><?php esc_html_e('Cart cache', 'nitropack'); ?></h6>
265 <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>
266
267 </div>
268 <label class="inline-flex items-center cursor-pointer ml-auto">
269 <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"; ?>>
270 <div class="toggle"></div>
271 </label>
272 </div>
273 <?php if (!nitropack_is_cart_cache_available()) : ?>
274 <div class="msg-container bg-success paid-msg">
275 <p><svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" class="text-success">
276 <g clip-path="url(#clip0_1244_36215)">
277 <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>
278 <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>
279 <path d="M10 13.3333V6.66663" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
280 </g>
281 <defs>
282 <clipPath id="clip0_1244_36215">
283 <rect width="20" height="20" fill="white"></rect>
284 </clipPath>
285 </defs>
286 </svg> <?php esc_html_e('This feature is available on Plus plan and above.', 'nitropack'); ?> <a href="https://app.nitropack.io/subscription/buy" class="text-primary" target="_blank"><b><?php esc_html_e('Upgrade here', 'nitropack'); ?></b></a>
287 </p>
288 </div>
289 <?php endif; ?>
290 </div>
291 <div class="nitro-option" id="real-time-stock-refresh-widget">
292 <div class="nitro-option-main">
293 <div class="text-box">
294 <h6><?php esc_html_e('Real-time Stock Refresh', 'nitropack'); ?></h6>
295 <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>
296
297 </div>
298 <label class="inline-flex items-center cursor-pointer ml-auto">
299 <input type="checkbox" id="woo-stock-reduce-status" class="sr-only peer" <?php echo (int)$stockReduceStatus === 1 ? "checked" : ""; ?>>
300 <div class="toggle"></div>
301 </label>
302 </div>
303 </div>
304 <?php } ?>
305
306 </div>
307 </div>
308 <div class="card-footer disconnect-container">
309 <a class="text-primary btn-link" id="disconnect-btn"><?php esc_html_e('Disconnect NitroPack plugin', 'nitropack'); ?></a>
310 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-disconnect.php'; ?>
311 </div>
312 </div>
313 <!-- Basic Settings Card End -->
314 <!-- Go to app Card -->
315 <div class="card app-card">
316 <div class="card-body">
317 <div class="flex items-center justify-between">
318 <p><?php esc_html_e('You can further configure how NitroPack\'s optimization behaves through your account', 'nitropack'); ?>.</p>
319 <?php
320 function getNitropackDashboardUrl() {
321 $siteId = nitropack_get_current_site_id();
322 $dashboardUrl = 'https://app.nitropack.io/dashboard';
323
324 if ($siteId !== null) {
325 $dashboardUrl .= '?update_session_website_id=' . urlencode($siteId);
326 }
327
328 return $dashboardUrl;
329 }
330 ?>
331 <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>
332 </div>
333 </div>
334 </div>
335 <!-- Go to app card End -->
336 </div>
337 <?php $notOptimizedCPTs = nitropack_filter_non_optimized();
338 $notices = get_option('nitropack-dismissed-notices', []);
339 $optimizedCPT_notice = in_array( 'OptimizeCPT', $notices, true ) ? true : false;
340 if (!$optimizedCPT_notice && !empty($notOptimizedCPTs)) require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-not-optimized-CPT.php'; ?>
341
342 </div>
343 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-unsaved-changes.php'; ?>
344 <script>
345 ($ => {
346 var getOptimizationsTimeout = null;
347 let isClearing = false;
348 var paid_plan = false;
349 $(window).on("load", function() {
350 getOptimizations();
351 getPlan();
352 <?php if ($checkedCompression != 1) { ?>
353 autoDetectCompression();
354 <?php } ?>
355 });
356
357 /* Cache Purge begin */
358 window.performCachePurge = () => {
359 purgeCache();
360 }
361
362 let purgeCache = () => {
363 let purgeEvent = new Event("cache.purge.request");
364 window.dispatchEvent(purgeEvent);
365 }
366
367 var getOptimizations = _ => {
368 var url = '<?php echo $optimizationDetailsUrl; ?>';
369 ((s, e, f) => {
370 if (window.fetch) {
371 fetch(url)
372 .then(resp => resp.json())
373 .then(s)
374 .catch(e)
375 .finally(f);
376 } else {
377 $.ajax({
378 url: url,
379 type: 'GET',
380 dataType: 'json',
381 success: s,
382 error: e,
383 complete: f
384 })
385 }
386 })(data => {
387 $('[data-last-cache-purge]').text(data.last_cache_purge.timeAgo);
388 if (data.last_cache_purge.reason) {
389 $('[data-purge-reason]').text(data.last_cache_purge.reason);
390 $('[data-purge-reason]').attr('title', data.last_cache_purge.reason);
391 $('#last-cache-purge-reason').show();
392 } else {
393 $('#last-cache-purge-reason').hide();
394 }
395 if (data.pending_count) {
396 $("#pending-optimizations-count").text(data.pending_count);
397 $("#pending-optimizations-section").show();
398 } else {
399 $("#pending-optimizations-section").hide();
400 }
401
402 $('[data-optimized-pages-total]').text(data.optimized_pages.total);
403
404 }, __ => {
405 console.error("An error occurred while fetching data for optimized pages");
406 }, __ => {
407 if (!getOptimizationsTimeout) {
408 getOptimizationsTimeout = setTimeout(function() {
409 getOptimizationsTimeout = null;
410 getOptimizations();
411 }, 60000);
412 }
413 });
414 }
415
416 var getPlan = _ => {
417
418 var url = '<?php echo $planDetailsUrl; ?>';
419 ((s, e, f) => {
420 if (window.fetch) {
421 fetch(url)
422 .then(resp => resp.json())
423 .then(s)
424 .catch(e)
425 .finally(f);
426 } else {
427 $.ajax({
428 url: url,
429 type: 'GET',
430 dataType: 'json',
431 success: s,
432 error: e,
433 complete: f
434 })
435 }
436 })(data => {
437
438 $('.plan-name').text(data.plan_title);
439 $('[data-next-billing]').text(data.next_billing ? data.next_billing : 'N/A');
440 $('[data-next-reset]').text(data.next_reset ? data.next_reset : 'N/A');
441 $('[data-page-views]').text(data.page_views ? data.page_views : 'N/A');
442 $('[data-cdn-bandwidth]').text(data.cdn_bandwidth ? data.cdn_bandwidth + ' out of ' + data.max_cdn_bandwidth : 'N/A');
443
444 for (prop in data) {
445 if (prop.indexOf("show_") === 0) continue;
446 if (prop.indexOf("label_") === 0) continue;
447 if (prop.indexOf("max_") === 0) continue;
448 if (
449 typeof data["show_" + prop] != "undefined" &&
450 data["show_" + prop] &&
451 typeof data["label_" + prop] != "undefined" &&
452 typeof data["max_" + prop] != "undefined"
453 ) {
454 let propertyLabel = data["label_" + prop];
455 let propertyValue = data[prop];
456 let propertyLimit = data["max_" + prop];
457 $("#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>');
458 }
459 }
460
461 }, __ => {
462 NitropackUI.triggerToast('error', '<?php esc_html_e('Error while fetching plan data', 'nitropack'); ?>');
463 }, __ => {});
464 }
465 window.addEventListener("cache.invalidate.success", getOptimizations);
466 if ($('#np-onstate-cache-purge').length) {
467 window.addEventListener("cache.purge.success", function(){setTimeout(function(){document.cookie = "nitropack_apwarning=1; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=<?php echo nitropack_cookiepath(); ?>"; window.location.reload()}, 1500)});
468 } else {
469 window.addEventListener("cache.purge.success", getOptimizations);
470 }
471
472 $(document).on('click', "#compression-test-btn", e => {
473 e.preventDefault();
474 autoDetectCompression();
475 });
476 /* Compression end */
477
478 /* HTML Compression begin */
479 var autoDetectCompression = function() {
480 let msg_container = $('#compression-widget .msg-container'),
481 msg_icon = msg_container.find('.icon'),
482 msg_box = msg_container.find('.msg'),
483 compression_setting = $('#compression-status'),
484 compression_btn = $('#compression-test-btn');
485 //add spinner here
486 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'); ?>');
487 compression_btn.addClass('hidden');
488 msg_container.removeClass('hidden');
489 $.post(ajaxurl, {
490 action: 'nitropack_test_compression_ajax',
491 nonce: nitroNonce
492 }, function(response) {
493 var resp = JSON.parse(response);
494
495 if (resp.status == "success") {
496 if (resp.hasCompression) { // compression already enabled
497 compression_setting.attr("checked", false);
498
499 msg_box.text('<?php esc_html_e('Compression is already enabled on your server! There is no need to enable it in NitroPack.', 'nitropack'); ?>')
500 } else {
501 compression_setting.attr("checked", true);
502 msg_box.text('<?php esc_html_e('No compression was detected! We will now enable it in NitroPack.', 'nitropack'); ?>');
503 }
504 NitropackUI.triggerToast(resp.type, resp.message);
505 } else {
506 msg_box.text('<?php esc_html_e('Could not determine compression status automatically. Please configure it manually.', 'nitropack'); ?>');
507 }
508 setTimeout(function() {
509 msg_container.addClass('hidden');
510 compression_btn.removeClass('hidden');
511 }, 5000);
512 });
513 }
514
515
516 $("#compression-status").on("click", function(e) {
517 $.post(ajaxurl, {
518 action: 'nitropack_set_compression_ajax',
519 nonce: nitroNonce,
520 data: {
521 compressionStatus: $(this).is(":checked") ? 1 : 0
522 }
523 }, function(response) {
524 var resp = JSON.parse(response);
525 NitropackUI.triggerToast(resp.type, resp.message);
526 });
527 });
528 $("#can-editor-clear-cache").on("click", function(e) {
529 $.post(ajaxurl, {
530 action: 'nitropack_set_can_editor_clear_cache',
531 nonce: nitroNonce,
532 data: {
533 canEditorClearCache: $(this).is(":checked") ? 1 : 0
534 }
535 }, function(response) {
536 var resp = JSON.parse(response);
537 NitropackUI.triggerToast(resp.type, resp.message);
538 });
539 });
540
541 $("#auto-purge-status").on("click", function(e) {
542 $.post(ajaxurl, {
543 action: 'nitropack_set_auto_cache_purge_ajax',
544 nonce: nitroNonce,
545 autoCachePurgeStatus: $(this).is(":checked") ? 1 : 0
546 }, function(response) {
547 var resp = JSON.parse(response);
548 NitropackUI.triggerToast(resp.type, resp.message);
549 });
550 });
551
552 $("#cart-cache-status").on("click", function(e) {
553 $.post(ajaxurl, {
554 action: 'nitropack_set_cart_cache_ajax',
555 nonce: nitroNonce,
556 cartCacheStatus: $(this).is(":checked") ? 1 : 0
557 }, function(response) {
558 var resp = JSON.parse(response);
559 NitropackUI.triggerToast(resp.type, resp.message);
560 });
561 });
562
563
564 $("#woo-stock-reduce-status").on("click", function(e) {
565 $.post(ajaxurl, {
566 action: 'nitropack_set_stock_reduce_status',
567 nonce: nitroNonce,
568 data: {
569 stockReduceStatus: $(this).is(":checked") ? 1 : 0
570 }
571 }, function(response) {
572 var resp = JSON.parse(response);
573 NitropackUI.triggerToast(resp.type, resp.message);
574 });
575 });
576
577 $("#bb-purge-status").on("click", function(e) {
578 $.post(ajaxurl, {
579 action: 'nitropack_set_bb_cache_purge_sync_ajax',
580 nonce: nitroNonce,
581 bbCachePurgeSyncStatus: $(this).is(":checked") ? 1 : 0
582 }, function(response) {
583 var resp = JSON.parse(response);
584 NitropackUI.triggerToast(resp.type, resp.message);
585 });
586 });
587
588
589 })(jQuery);
590 </script>