PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.18.8
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.18.8
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
animations 7 months ago images 7 months ago javascript 7 months ago modals 6 months ago stylesheet 7 months ago templates 1 year ago admin.php 7 months ago connect-oneclick.php 1 year ago connect.php 7 months ago dashboard-oneclick.php 6 months ago dashboard.php 6 months ago oneclick.php 7 months ago preview-site.php 7 months ago system-report.php 1 year ago
dashboard.php
507 lines
1 <?php
2 $settings = new \NitroPack\WordPress\Settings();
3 $notifications = new \NitroPack\WordPress\Notifications\Notifications();
4
5 $conflictingPlugins = \NitroPack\WordPress\ConflictingPlugins::getInstance();
6 $conflictingPlugins_list = $conflictingPlugins->nitropack_get_conflicting_plugins();
7 if ( $conflictingPlugins_list ) {
8 require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-plugin-deactivate.php';
9 }
10
11 $notifications->nitropack_display_admin_notices();
12 $dismissed_notices = get_option( 'nitropack-dismissed-notices' );
13
14 $nitro = get_nitropack_sdk();
15 $cache_warmup_stats = $nitro->getApi()->getWarmupStats();
16 $cache_warmup_enabled = ! empty( $cache_warmup_stats['status'] ) && $cache_warmup_stats['status'] === 1 ? true : false;
17
18 if ( empty( $dismissed_notices['skip_cache_warmup'] ) && ! $cache_warmup_enabled ) : ?>
19 <div class="card cache-warmup">
20 <div class="progress-wrapper mb-4">
21 <div class="progress-bar">
22 <div class="progress" style="width: 100%;"></div>
23 </div>
24 <div class="step"><?php esc_html_e( 'Step', 'nitropack' ); ?> 3/3</div>
25 </div>
26 <div class="card-body">
27 <h3><?php esc_html_e( 'Enable proactive optimizations', 'nitropack' ); ?>
28 </h3>
29 <p><?php esc_html_e( 'Turn on Cache Warmup so NitroPack can start optimizing your pages immediately, without waiting for traffic. This guarantees a fast site for every visitor right from the start.', 'nitropack' ); ?>
30 </p>
31 </div>
32 <div class="card-footer">
33 <button id="enable-cache-warmup"
34 class="btn btn-primary"><?php esc_html_e( 'Enable Cache Warmup', 'nitropack' ); ?></button>
35 <a id="skip-cache-warmup" class="btn btn-secondary ml-2"><?php esc_html_e( 'Skip', 'nitropack' ); ?></a>
36 </div>
37 </div>
38 <?php endif; ?>
39 <div class="grid grid-cols-2 gap-6 grid-col-1-tablet items-start nitropack-dashboard">
40 <div class="col-span-1">
41 <!-- Go to app Card -->
42 <div class="card app-card">
43 <div class="card-header">
44 <h3><?php esc_html_e( 'Customize NitroPack\'s Optimization Settings in Your Account', 'nitropack' ); ?>
45 </h3>
46 </div>
47 <div class="card-body">
48 <div class="flex items-center justify-between">
49 <div class="text-box">
50 <p>
51 <?php esc_html_e( 'You can further configure how NitroPack\'s optimization behaves through your account.', 'nitropack' ); ?>
52 </p>
53 </div>
54 <?php
55 function getNitropackDashboardUrl() {
56 $siteId = nitropack_get_current_site_id();
57 $dashboardUrl = 'https://app.nitropack.io/dashboard';
58
59 if ( $siteId !== null ) {
60 $dashboardUrl .= '?update_session_website_id=' . urlencode( $siteId );
61 }
62
63 return $dashboardUrl;
64 }
65 ?>
66 <a href="<?php echo esc_url( getNitropackDashboardUrl() ); ?>" target="_blank"
67 class="btn btn-primary ml-2 flex-shrink-0"><?php esc_html_e( 'Go to app', 'nitropack' ); ?></a>
68 </div>
69 </div>
70 </div>
71 <!-- Go to app card End -->
72 <!-- Optimized Pages Card -->
73 <div class="card card-optimized-pages">
74 <div class="card-header">
75 <h3><?php esc_html_e( 'Optimized pages', 'nitropack' ); ?></h3>
76 <div class="flex flex-row items-center" style="display: none;" id="pending-optimizations-section">
77 <img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/loading.svg'; ?>" alt="loading"
78 class="w-4 h-4">
79 <span class="ml-2 mr-1 text-primary"> <?php esc_html_e( 'Processing', 'nitropack' ); ?>
80 <span id="pending-optimizations-count">X</span>
81 <?php esc_html_e( 'page(s) in the background', 'nitropack' ); ?></span>
82 </div>
83 </div>
84 <div class="card-body">
85 <div class="card-body-inner">
86 <div class="optimized-pages"><span data-optimized-pages-total>0</span></div>
87 <div class="text-box">
88 <div class="time-ago"><?php esc_html_e( 'Last cache purge', 'nitropack' ); ?>: <span
89 data-last-cache-purge><?php esc_html_e( 'Never', 'nitropack' ); ?></span></div>
90 <div class="reason"><?php esc_html_e( 'Reason', 'nitropack' ); ?>: <span
91 data-purge-reason><?php esc_html_e( 'Unknown', 'nitropack' ); ?></span></div>
92 </div>
93 <button id="optimizations-purge-cache" type="button" class="btn btn-secondary"
94 data-modal-target="modal-purge-cache"
95 data-modal-toggle="modal-purge-cache"><?php esc_html_e( 'Purge cache', 'nitropack' ); ?></button>
96 </div>
97 </div>
98 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-purge-cache.php'; ?>
99 </div>
100 <!-- Optimized Pages Card End -->
101 <!-- Optimization Mode Card -->
102 <?php $settings->optimization_level->render(); ?>
103 <!-- Optimization Mode Card End -->
104 <!-- Automated Behavior Card -->
105 <div class="card card-automated-behavior">
106 <div class="card-header">
107 <h3><?php esc_html_e( 'Automated Behavior', 'nitropack' ); ?></h3>
108 </div>
109 <div class="card-body">
110 <div class="options-container">
111 <div class="nitro-option" id="purge-cache-widget">
112 <div class="nitro-option-main">
113 <div class="text-box">
114 <h6><?php esc_html_e( 'Purge cache', 'nitropack' ); ?></h6>
115 <p><?php esc_html_e( 'Purge affected cache when content is updated or published', 'nitropack' ); ?>
116 </p>
117 </div>
118 <label class="inline-flex items-center cursor-pointer ml-auto">
119 <input type="checkbox" value="" class="sr-only peer" name="purge_cache"
120 id="auto-purge-status" <?php if ( $autoCachePurge )
121 echo "checked"; ?>>
122 <div class="toggle"></div>
123 </label>
124 </div>
125 </div>
126 <div class="nitro-option" id="page-optimization-widget">
127 <div class="nitro-option-main">
128 <div class="text-box">
129 <h6><?php esc_html_e( 'Page optimization', 'nitropack' ); ?></h6>
130 <p><?php esc_html_e( 'Select what post/page types get optimized', 'nitropack' ); ?></p>
131 </div>
132 <a data-modal-target="modal-posttypes" data-modal-toggle="modal-posttypes"
133 class="btn btn-secondary btn-icon">
134 <img src="<?php echo plugin_dir_url( __FILE__ ); ?>images/setting-icon.svg">
135 </a>
136 </div>
137 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-posttypes.php'; ?>
138 </div>
139 </div>
140 </div>
141 </div>
142 <!-- Automated Behavior Card End -->
143 <!-- Go to app Card -->
144 <div class="card exclusion-card">
145 <div class="card-header">
146 <h3><?php esc_html_e( 'Exclusions', 'nitropack' ); ?></h3>
147 </div>
148 <div class="card-body">
149 <div class="options-container">
150 <div class="nitro-option" id="ajax-shortcodes-widget">
151 <?php $settings->shortcodes->render(); ?>
152 </div>
153 </div>
154 </div>
155 </div>
156 <!-- Go to app card End -->
157 </div>
158 <div class="col-span-1">
159 <!-- Subscription Card -->
160 <?php $settings->subscription->render(); ?>
161
162 <!-- Subscription Card End -->
163 <!-- Basic Settings Card -->
164 <div class="card card-basic-settings">
165 <div class="card-header">
166 <h3><?php esc_html_e( 'Basic Settings', 'nitropack' ); ?></h3>
167 </div>
168 <div class="card-body">
169 <div class="options-container">
170
171 <?php $settings->cache_warmup->render();
172 $settings->test_mode->render(); ?>
173
174 <div class="nitro-option" id="compression-widget">
175 <div class="nitro-option-main">
176 <div class="text-box">
177 <h6><span
178 id="detected-compression"><?php esc_html_e( 'HTML Compression', 'nitropack' ); ?>
179 </span></h6>
180 <p>
181 <?php esc_html_e( 'Compressing the structure of your HTML, ensures faster page rendering and an optimized browsing experience for your users.', 'nitropack' ); ?>
182 <a href="https://support.nitropack.io/en/articles/8390333-nitropack-plugin-settings-in-wordpress#h_29b7ab4836"
183 class="text-blue"
184 target="_blank"><?php esc_html_e( 'Learn more', 'nitropack' ); ?></a>
185 </p>
186 </div>
187 <label class="inline-flex items-center cursor-pointer ml-auto">
188 <input type="checkbox" id="compression-status" class="sr-only peer" <?php echo (int) $enableCompression === 1 ? "checked" : ""; ?>>
189 <div class="toggle"></div>
190 </label>
191 </div>
192 <div class="mt-4 text-primary">
193 <a href="javascript:void(0);" id="compression-test-btn"
194 class="text-primary"><?php esc_html_e( 'Run compression test', 'nitropack' ); ?></a>
195 <div class="flex items-start msg-container hidden">
196 <span class="msg"></span>
197 </div>
198 </div>
199 </div>
200 <?php if ( \NitroPack\Integration\Plugin\BeaverBuilder::isActive() ) { ?>
201 <div class="nitro-option" id="beaver-builder-widget">
202 <div class="nitro-option-main">
203 <div class="text-box">
204 <h6><span
205 id="detected-compression"><?php esc_html_e( 'Sync NitroPack Purge with Beaver Builder', 'nitropack' ); ?>
206 </span></h6>
207 <p>
208 <?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' ); ?>
209 </p>
210 </div>
211 <label class="inline-flex items-center cursor-pointer ml-auto">
212 <input type="checkbox" class="sr-only peer" id="bb-purge-status" <?php if ( $bbCacheSyncPurge )
213 echo "checked"; ?>>
214 <div class="toggle"></div>
215 </label>
216 </div>
217 </div>
218 <?php } ?>
219 <div class="nitro-option" id="can-editor-clear-cache-widget">
220 <div class="nitro-option-main">
221 <div class="text-box">
222 <h6><?php esc_html_e( 'Allow Editors to purge cache', 'nitropack' ); ?></h6>
223 <p><?php esc_html_e( 'Give Editors the right to purge cache when content is updated.', 'nitropack' ); ?>
224 </p>
225 </div>
226 <label class="inline-flex items-center cursor-pointer ml-auto">
227 <input type="checkbox" id="can-editor-clear-cache" class="sr-only peer" <?php echo (int) $canEditorClearCache === 1 ? "checked" : ""; ?>>
228 <div class="toggle"></div>
229 </label>
230 </div>
231 </div>
232 <?php if ( nitropack_render_woocommerce_cart_cache_option() ) { ?>
233 <div class="nitro-option" id="cart-cache-widget">
234 <div class="nitro-option-main">
235 <div class="text-box">
236 <h6><?php esc_html_e( 'Cart cache', 'nitropack' ); ?></h6>
237 <p>
238 <?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' ); ?>
239 </p>
240
241 </div>
242 <label class="inline-flex items-center cursor-pointer ml-auto">
243 <input type="checkbox" id="cart-cache-status" class="sr-only peer" <?php if ( nitropack_is_cart_cache_active() )
244 echo "checked"; ?> <?php if ( ! nitropack_is_cart_cache_available() )
245 echo "disabled"; ?>>
246 <div class="toggle"></div>
247 </label>
248 </div>
249 <?php if ( ! nitropack_is_cart_cache_available() ) : ?>
250 <div class="msg-container bg-success paid-msg">
251 <p><svg width="20" height="20" viewBox="0 0 20 20" fill="none"
252 xmlns="http://www.w3.org/2000/svg" class="text-success">
253 <g clip-path="url(#clip0_1244_36215)">
254 <path
255 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"
256 stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
257 stroke-linejoin="round"></path>
258 <path d="M13.3334 9.99996L10.0001 6.66663L6.66675 9.99996" stroke="currentColor"
259 stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
260 <path d="M10 13.3333V6.66663" stroke="currentColor" stroke-width="1.5"
261 stroke-linecap="round" stroke-linejoin="round"></path>
262 </g>
263 <defs>
264 <clipPath id="clip0_1244_36215">
265 <rect width="20" height="20" fill="white"></rect>
266 </clipPath>
267 </defs>
268 </svg>
269 <?php esc_html_e( 'This feature is available on Plus plan and above.', 'nitropack' ); ?>
270 <a href="https://app.nitropack.io/subscription/buy" class="text-primary"
271 target="_blank"><b><?php esc_html_e( 'Upgrade here', 'nitropack' ); ?></b></a>
272 </p>
273 </div>
274 <?php endif; ?>
275 </div>
276 <div class="nitro-option" id="real-time-stock-refresh-widget">
277 <div class="nitro-option-main">
278 <div class="text-box">
279 <h6><?php esc_html_e( 'Real-time Stock Refresh', 'nitropack' ); ?></h6>
280 <p>
281 <?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' ); ?>
282 </p>
283
284 </div>
285 <label class="inline-flex items-center cursor-pointer ml-auto">
286 <input type="checkbox" id="woo-stock-reduce-status" class="sr-only peer" <?php echo (int) $stockReduceStatus === 1 ? "checked" : ""; ?>>
287 <div class="toggle"></div>
288 </label>
289 </div>
290 </div>
291 <?php } ?>
292
293 </div>
294 </div>
295 <div class="card-footer disconnect-container">
296 <a class="text-primary btn-link"
297 id="disconnect-btn"><?php esc_html_e( 'Disconnect NitroPack plugin', 'nitropack' ); ?></a>
298 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-disconnect.php'; ?>
299 </div>
300 </div>
301 <!-- Basic Settings Card End -->
302
303 </div>
304 <?php $notOptimizedCPTs = nitropack_filter_non_optimized();
305 $notices = get_option( 'nitropack-dismissed-notices', [] );
306 $optimizedCPT_notice = in_array( 'OptimizeCPT', $notices, true ) ? true : false;
307 if ( ! $optimizedCPT_notice && ! empty( $notOptimizedCPTs ) )
308 require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-not-optimized-CPT.php'; ?>
309
310 </div>
311 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-unsaved-changes.php'; ?>
312 <script>
313 ($ => {
314 var getOptimizationsTimeout = null;
315 let isClearing = false;
316 var paid_plan = false;
317 $(window).on("load", function () {
318 getOptimizations();
319 <?php if ( $checkedCompression != 1 ) { ?>
320 autoDetectCompression();
321 <?php } ?>
322 });
323
324 /* Cache Purge begin */
325 window.performCachePurge = () => {
326 purgeCache();
327 }
328
329 let purgeCache = () => {
330 let purgeEvent = new Event("cache.purge.request");
331 window.dispatchEvent(purgeEvent);
332 }
333
334 var getOptimizations = _ => {
335 var url = '<?php echo $optimizationDetailsUrl; ?>';
336 ((s, e, f) => {
337 if (window.fetch) {
338 fetch(url)
339 .then(resp => resp.json())
340 .then(s)
341 .catch(e)
342 .finally(f);
343 } else {
344 $.ajax({
345 url: url,
346 type: 'GET',
347 dataType: 'json',
348 success: s,
349 error: e,
350 complete: f
351 })
352 }
353 })(data => {
354 $('[data-last-cache-purge]').text(data.last_cache_purge.timeAgo);
355 if (data.last_cache_purge.reason) {
356 $('[data-purge-reason]').text(data.last_cache_purge.reason);
357 $('[data-purge-reason]').attr('title', data.last_cache_purge.reason);
358 $('#last-cache-purge-reason').show();
359 } else {
360 $('#last-cache-purge-reason').hide();
361 }
362 if (data.pending_count) {
363 $("#pending-optimizations-count").text(data.pending_count);
364 $("#pending-optimizations-section").show();
365 } else {
366 $("#pending-optimizations-section").hide();
367 }
368
369 $('[data-optimized-pages-total]').text(data.optimized_pages.total);
370
371 }, __ => {
372 console.error("An error occurred while fetching data for optimized pages");
373 }, __ => {
374 if (!getOptimizationsTimeout) {
375 getOptimizationsTimeout = setTimeout(function () {
376 getOptimizationsTimeout = null;
377 getOptimizations();
378 }, 60000);
379 }
380 });
381 }
382 window.addEventListener("cache.invalidate.success", getOptimizations);
383 if ($('#np-onstate-cache-purge').length) {
384 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) });
385 } else {
386 window.addEventListener("cache.purge.success", getOptimizations);
387 }
388
389 $(document).on('click', "#compression-test-btn", e => {
390 e.preventDefault();
391 autoDetectCompression();
392 });
393 /* Compression end */
394
395 /* HTML Compression begin */
396 var autoDetectCompression = function () {
397 let msg_container = $('#compression-widget .msg-container'),
398 msg_icon = msg_container.find('.icon'),
399 msg_box = msg_container.find('.msg'),
400 compression_setting = $('#compression-status'),
401 compression_btn = $('#compression-test-btn');
402 //add spinner here
403 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' ); ?>');
404 compression_btn.addClass('hidden');
405 msg_container.removeClass('hidden');
406 $.post(ajaxurl, {
407 action: 'nitropack_test_compression_ajax',
408 nonce: nitroNonce
409 }, function (response) {
410 var resp = JSON.parse(response);
411
412 if (resp.status == "success") {
413 if (resp.hasCompression) { // compression already enabled
414 compression_setting.attr("checked", false);
415
416 msg_box.text('<?php esc_html_e( 'Compression is already enabled on your server! There is no need to enable it in NitroPack.', 'nitropack' ); ?>')
417 } else {
418 compression_setting.attr("checked", true);
419 msg_box.text('<?php esc_html_e( 'No compression was detected! We will now enable it in NitroPack.', 'nitropack' ); ?>');
420 }
421 NitropackUI.triggerToast(resp.type, resp.message);
422 } else {
423 msg_box.text('<?php esc_html_e( 'Could not determine compression status automatically. Please configure it manually.', 'nitropack' ); ?>');
424 }
425 setTimeout(function () {
426 msg_container.addClass('hidden');
427 compression_btn.removeClass('hidden');
428 }, 5000);
429 });
430 }
431
432
433 $("#compression-status").on("click", function (e) {
434 $.post(ajaxurl, {
435 action: 'nitropack_set_compression_ajax',
436 nonce: nitroNonce,
437 data: {
438 compressionStatus: $(this).is(":checked") ? 1 : 0
439 }
440 }, function (response) {
441 var resp = JSON.parse(response);
442 NitropackUI.triggerToast(resp.type, resp.message);
443 });
444 });
445 $("#can-editor-clear-cache").on("click", function (e) {
446 $.post(ajaxurl, {
447 action: 'nitropack_set_can_editor_clear_cache',
448 nonce: nitroNonce,
449 data: {
450 canEditorClearCache: $(this).is(":checked") ? 1 : 0
451 }
452 }, function (response) {
453 var resp = JSON.parse(response);
454 NitropackUI.triggerToast(resp.type, resp.message);
455 });
456 });
457
458 $("#auto-purge-status").on("click", function (e) {
459 $.post(ajaxurl, {
460 action: 'nitropack_set_auto_cache_purge_ajax',
461 nonce: nitroNonce,
462 autoCachePurgeStatus: $(this).is(":checked") ? 1 : 0
463 }, function (response) {
464 var resp = JSON.parse(response);
465 NitropackUI.triggerToast(resp.type, resp.message);
466 });
467 });
468
469 $("#cart-cache-status").on("click", function (e) {
470 $.post(ajaxurl, {
471 action: 'nitropack_set_cart_cache_ajax',
472 nonce: nitroNonce,
473 cartCacheStatus: $(this).is(":checked") ? 1 : 0
474 }, function (response) {
475 var resp = JSON.parse(response);
476 NitropackUI.triggerToast(resp.type, resp.message);
477 });
478 });
479
480
481 $("#woo-stock-reduce-status").on("click", function (e) {
482 $.post(ajaxurl, {
483 action: 'nitropack_set_stock_reduce_status',
484 nonce: nitroNonce,
485 data: {
486 stockReduceStatus: $(this).is(":checked") ? 1 : 0
487 }
488 }, function (response) {
489 var resp = JSON.parse(response);
490 NitropackUI.triggerToast(resp.type, resp.message);
491 });
492 });
493
494 $("#bb-purge-status").on("click", function (e) {
495 $.post(ajaxurl, {
496 action: 'nitropack_set_bb_cache_purge_sync_ajax',
497 nonce: nitroNonce,
498 bbCachePurgeSyncStatus: $(this).is(":checked") ? 1 : 0
499 }, function (response) {
500 var resp = JSON.parse(response);
501 NitropackUI.triggerToast(resp.type, resp.message);
502 });
503 });
504
505
506 })(jQuery);
507 </script>