PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.18.6
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.18.6
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-oneclick.php
nitropack / view Last commit date
animations 7 months ago images 7 months ago javascript 7 months ago modals 7 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 7 months ago dashboard.php 7 months ago oneclick.php 7 months ago preview-site.php 7 months ago system-report.php 1 year ago
dashboard-oneclick.php
408 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 $conflictingPlugins = \NitroPack\WordPress\ConflictingPlugins::getInstance();
10 $conflictingPlugins_list = $conflictingPlugins->nitropack_get_conflicting_plugins();
11 if ( $conflictingPlugins_list ) {
12 require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-plugin-deactivate.php';
13 }
14
15 $notifications->nitropack_display_admin_notices();
16 $dismissed_notices = get_option( 'nitropack-dismissed-notices' );
17
18 $nitro = get_nitropack_sdk();
19 $cache_warmup_stats = $nitro->getApi()->getWarmupStats();
20 $cache_warmup_enabled = ! empty( $cache_warmup_stats['status'] ) && $cache_warmup_stats['status'] === 1 ? true : false;
21 ?>
22 <div class="grid grid-cols-2 gap-6 grid-col-1-tablet items-start nitropack-dashboard">
23 <div class="col-span-1">
24 <!-- Optimized Pages Card -->
25 <div class="card card-optimized-pages">
26 <div class="card-header">
27 <h3><?php esc_html_e( 'Optimized pages', 'nitropack' ); ?></h3>
28 <div class="flex flex-row items-center" style="display: none;" id="pending-optimizations-section">
29 <img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/loading.svg'; ?>" alt="loading"
30 class="w-4 h-4">
31 <span class="ml-2 mr-1 text-primary"> <?php esc_html_e( 'Processing', 'nitropack' ); ?>
32 <span id="pending-optimizations-count">X</span>
33 <?php esc_html_e( 'page(s) in the background', 'nitropack' ); ?></span>
34 </div>
35 </div>
36 <div class="card-body">
37 <div class="card-body-inner">
38 <div class="optimized-pages"><span data-optimized-pages-total>0</span></div>
39 <div class="text-box">
40 <div class="time-ago"><?php esc_html_e( 'Last cache purge', 'nitropack' ); ?>: <span
41 data-last-cache-purge><?php esc_html_e( 'Never', 'nitropack' ); ?></span></div>
42 <div class="reason"><?php esc_html_e( 'Reason', 'nitropack' ); ?>: <span
43 data-purge-reason><?php esc_html_e( 'Unknown', 'nitropack' ); ?></span></div>
44 </div>
45 <button id="optimizations-purge-cache" type="button" class="btn btn-secondary"
46 data-modal-target="modal-purge-cache"
47 data-modal-toggle="modal-purge-cache"><?php esc_html_e( 'Purge cache', 'nitropack' ); ?></button>
48 </div>
49 </div>
50 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-purge-cache.php'; ?>
51 </div>
52 <!-- Optimized Pages Card End -->
53 <!-- Optimization Mode Card -->
54 <?php $settings->optimization_level->render(); ?>
55 <!-- Optimization Mode Card End -->
56 <!-- Automated Behavior Card -->
57 <div class="card card-automated-behavior">
58 <div class="card-header">
59 <h3><?php esc_html_e( 'Automated Behavior', 'nitropack' ); ?></h3>
60 </div>
61 <div class="card-body">
62 <div class="options-container">
63 <div class="nitro-option" id="purge-cache-widget">
64 <div class="nitro-option-main">
65 <div class="text-box">
66 <h6><?php esc_html_e( 'Purge cache', 'nitropack' ); ?></h6>
67 <p><?php esc_html_e( 'Purge affected cache when content is updated or published', 'nitropack' ); ?>
68 </p>
69 </div>
70 <label class="inline-flex items-center cursor-pointer ml-auto">
71 <input type="checkbox" value="" class="sr-only peer" name="purge_cache"
72 id="auto-purge-status" <?php if ( $autoCachePurge )
73 echo "checked"; ?>>
74 <div class="toggle"></div>
75 </label>
76 </div>
77 </div>
78 <div class="nitro-option" id="page-optimization-widget">
79 <div class="nitro-option-main">
80 <div class="text-box">
81 <h6><?php esc_html_e( 'Page optimization', 'nitropack' ); ?></h6>
82 <p><?php esc_html_e( 'Select what post/page types get optimized', 'nitropack' ); ?></p>
83 </div>
84 <a data-modal-target="modal-posttypes" data-modal-toggle="modal-posttypes"
85 class="btn btn-secondary btn-icon">
86 <img src="<?php echo plugin_dir_url( __FILE__ ); ?>images/setting-icon.svg">
87 </a>
88 </div>
89 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-posttypes.php'; ?>
90 </div>
91 </div>
92 </div>
93 </div>
94 <!-- Automated Behavior Card End -->
95 <!-- Go to app Card -->
96 <div class="card exclusion-card">
97 <div class="card-header">
98 <h3><?php esc_html_e( 'Exclusions', 'nitropack' ); ?></h3>
99 </div>
100 <div class="card-body">
101 <div class="options-container">
102 <div class="nitro-option" id="ajax-shortcodes-widget">
103 <?php $settings->render_ajax_shortcodes_setting(); ?>
104 </div>
105 </div>
106 </div>
107 </div>
108 <!-- Go to app card End -->
109 </div>
110 <div class="col-span-1">
111 <!-- Subscription Card End -->
112 <!-- Basic Settings Card -->
113 <div class="card card-basic-settings">
114 <div class="card-header">
115 <h3><?php esc_html_e( 'Basic Settings', 'nitropack' ); ?></h3>
116 </div>
117 <div class="card-body">
118 <div class="options-container">
119
120 <?php $settings->cache_warmup->render();
121 $settings->test_mode->render(); ?>
122
123 <div class="nitro-option" id="compression-widget">
124 <div class="nitro-option-main">
125 <div class="text-box">
126 <h6><span
127 id="detected-compression"><?php esc_html_e( 'HTML Compression', 'nitropack' ); ?>
128 </span></h6>
129 <p>
130 <?php esc_html_e( 'Compressing the structure of your HTML, ensures faster page rendering and an optimized browsing experience for your users.', 'nitropack' ); ?>
131 <a href="https://support.nitropack.io/en/articles/8390333-nitropack-plugin-settings-in-wordpress#h_29b7ab4836"
132 class="text-blue"
133 target="_blank"><?php esc_html_e( 'Learn more', 'nitropack' ); ?></a>
134 </p>
135 </div>
136 <label class="inline-flex items-center cursor-pointer ml-auto">
137 <input type="checkbox" id="compression-status" class="sr-only peer" <?php echo (int) $enableCompression === 1 ? "checked" : ""; ?>>
138 <div class="toggle"></div>
139 </label>
140 </div>
141 <div class="mt-4 text-primary">
142 <a href="javascript:void(0);" id="compression-test-btn"
143 class="text-primary"><?php esc_html_e( 'Run compression test', 'nitropack' ); ?></a>
144 <div class="flex items-start msg-container hidden">
145 <span class="msg"></span>
146 </div>
147 </div>
148 </div>
149 <?php if ( \NitroPack\Integration\Plugin\BeaverBuilder::isActive() ) { ?>
150 <div class="nitro-option" id="beaver-builder-widget">
151 <div class="nitro-option-main">
152 <div class="text-box">
153 <h6><span
154 id="detected-compression"><?php esc_html_e( 'Sync NitroPack Purge with Beaver Builder', 'nitropack' ); ?>
155 </span></h6>
156 <p>
157 <?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' ); ?>
158 </p>
159 </div>
160 <label class="inline-flex items-center cursor-pointer ml-auto">
161 <input type="checkbox" class="sr-only peer" id="bb-purge-status" <?php if ( $bbCacheSyncPurge )
162 echo "checked"; ?>>
163 <div class="toggle"></div>
164 </label>
165 </div>
166 </div>
167 <?php } ?>
168 <div class="nitro-option" id="can-editor-clear-cache-widget">
169 <div class="nitro-option-main">
170 <div class="text-box">
171 <h6><?php esc_html_e( 'Allow Editors to purge cache', 'nitropack' ); ?></h6>
172 <p><?php esc_html_e( 'Give Editors the right to purge cache when content is updated.', 'nitropack' ); ?>
173 </p>
174 </div>
175 <label class="inline-flex items-center cursor-pointer ml-auto">
176 <input type="checkbox" id="can-editor-clear-cache" class="sr-only peer" <?php echo (int) $canEditorClearCache === 1 ? "checked" : ""; ?>>
177 <div class="toggle"></div>
178 </label>
179 </div>
180 </div>
181 </div>
182 </div>
183 </div>
184 </div>
185 <?php $notOptimizedCPTs = nitropack_filter_non_optimized();
186 $notices = get_option( 'nitropack-dismissed-notices', [] );
187 $optimizedCPT_notice = in_array( 'OptimizeCPT', $notices, true ) ? true : false;
188 if ( ! $optimizedCPT_notice && ! empty( $notOptimizedCPTs ) )
189 require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-not-optimized-CPT.php'; ?>
190 </div>
191 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-unsaved-changes.php'; ?>
192 <script>
193 ($ => {
194 var getOptimizationsTimeout = null;
195 let isClearing = false;
196 var paid_plan = false;
197 $(window).on("load", function () {
198 getOptimizations();
199 getPlan();
200 <?php if ( $checkedCompression != 1 ) { ?>
201 autoDetectCompression();
202 <?php } ?>
203 });
204
205 /* Cache Purge begin */
206 window.performCachePurge = () => {
207 purgeCache();
208 }
209
210 let purgeCache = () => {
211 let purgeEvent = new Event("cache.purge.request");
212 window.dispatchEvent(purgeEvent);
213 }
214
215 var getOptimizations = _ => {
216 var url = '<?php echo $optimizationDetailsUrl; ?>';
217 ((s, e, f) => {
218 if (window.fetch) {
219 fetch(url)
220 .then(resp => resp.json())
221 .then(s)
222 .catch(e)
223 .finally(f);
224 } else {
225 $.ajax({
226 url: url,
227 type: 'GET',
228 dataType: 'json',
229 success: s,
230 error: e,
231 complete: f
232 })
233 }
234 })(data => {
235 $('[data-last-cache-purge]').text(data.last_cache_purge.timeAgo);
236 if (data.last_cache_purge.reason) {
237 $('[data-purge-reason]').text(data.last_cache_purge.reason);
238 $('[data-purge-reason]').attr('title', data.last_cache_purge.reason);
239 $('#last-cache-purge-reason').show();
240 } else {
241 $('#last-cache-purge-reason').hide();
242 }
243 if (data.pending_count) {
244 $("#pending-optimizations-count").text(data.pending_count);
245 $("#pending-optimizations-section").show();
246 } else {
247 $("#pending-optimizations-section").hide();
248 }
249
250 $('[data-optimized-pages-total]').text(data.optimized_pages.total);
251
252 }, __ => {
253 console.error("An error occurred while fetching data for optimized pages");
254 }, __ => {
255 if (!getOptimizationsTimeout) {
256 getOptimizationsTimeout = setTimeout(function () {
257 getOptimizationsTimeout = null;
258 getOptimizations();
259 }, 60000);
260 }
261 });
262 }
263
264 var getPlan = _ => {
265
266 var url = '<?php echo $planDetailsUrl; ?>';
267 ((s, e, f) => {
268 if (window.fetch) {
269 fetch(url)
270 .then(resp => resp.json())
271 .then(s)
272 .catch(e)
273 .finally(f);
274 } else {
275 $.ajax({
276 url: url,
277 type: 'GET',
278 dataType: 'json',
279 success: s,
280 error: e,
281 complete: f
282 })
283 }
284 })(data => {
285
286 $('.plan-name').text(data.plan_title);
287 $('[data-next-billing]').text(data.next_billing ? data.next_billing : 'N/A');
288 $('[data-next-reset]').text(data.next_reset ? data.next_reset : 'N/A');
289 $('[data-page-views]').text(data.page_views ? data.page_views : 'N/A');
290 $('[data-cdn-bandwidth]').text(data.cdn_bandwidth ? data.cdn_bandwidth + ' out of ' + data.max_cdn_bandwidth : 'N/A');
291
292 for (prop in data) {
293 if (prop.indexOf("show_") === 0) continue;
294 if (prop.indexOf("label_") === 0) continue;
295 if (prop.indexOf("max_") === 0) continue;
296 if (
297 typeof data["show_" + prop] != "undefined" &&
298 data["show_" + prop] &&
299 typeof data["label_" + prop] != "undefined" &&
300 typeof data["max_" + prop] != "undefined"
301 ) {
302 let propertyLabel = data["label_" + prop];
303 let propertyValue = data[prop];
304 let propertyLimit = data["max_" + prop];
305 $("#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>');
306 }
307 }
308
309 }, __ => {
310 NitropackUI.triggerToast('error', '<?php esc_html_e( 'Error while fetching plan data', 'nitropack' ); ?>');
311 }, __ => { });
312 }
313
314
315 $(document).on('click', "#compression-test-btn", e => {
316 e.preventDefault();
317 autoDetectCompression();
318 });
319 /* Compression end */
320
321 /* HTML Compression begin */
322 var autoDetectCompression = function () {
323 let msg_container = $('#compression-widget .msg-container'),
324 msg_icon = msg_container.find('.icon'),
325 msg_box = msg_container.find('.msg'),
326 compression_setting = $('#compression-status'),
327 compression_btn = $('#compression-test-btn');
328 //add spinner here
329 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' ); ?>');
330 compression_btn.addClass('hidden');
331 msg_container.removeClass('hidden');
332 $.post(ajaxurl, {
333 action: 'nitropack_test_compression_ajax',
334 nonce: nitroNonce
335 }, function (response) {
336 var resp = JSON.parse(response);
337
338 if (resp.status == "success") {
339 if (resp.hasCompression) { // compression already enabled
340 compression_setting.attr("checked", false);
341
342 msg_box.text('<?php esc_html_e( 'Compression is already enabled on your server! There is no need to enable it in NitroPack.', 'nitropack' ); ?>')
343 } else {
344 compression_setting.attr("checked", true);
345 msg_box.text('<?php esc_html_e( 'No compression was detected! We will now enable it in NitroPack.', 'nitropack' ); ?>');
346 }
347 NitropackUI.triggerToast(resp.type, resp.message);
348 } else {
349 msg_box.text('<?php esc_html_e( 'Could not determine compression status automatically. Please configure it manually.', 'nitropack' ); ?>');
350 }
351 setTimeout(function () {
352 msg_container.addClass('hidden');
353 compression_btn.removeClass('hidden');
354 }, 5000);
355 });
356 }
357
358
359 $("#compression-status").on("click", function (e) {
360 $.post(ajaxurl, {
361 action: 'nitropack_set_compression_ajax',
362 nonce: nitroNonce,
363 data: {
364 compressionStatus: $(this).is(":checked") ? 1 : 0
365 }
366 }, function (response) {
367 var resp = JSON.parse(response);
368 NitropackUI.triggerToast(resp.type, resp.message);
369 });
370 });
371 $("#can-editor-clear-cache").on("click", function (e) {
372 $.post(ajaxurl, {
373 action: 'nitropack_set_can_editor_clear_cache',
374 nonce: nitroNonce,
375 data: {
376 canEditorClearCache: $(this).is(":checked") ? 1 : 0
377 }
378 }, function (response) {
379 var resp = JSON.parse(response);
380 NitropackUI.triggerToast(resp.type, resp.message);
381 });
382 });
383
384 $("#auto-purge-status").on("click", function (e) {
385 $.post(ajaxurl, {
386 action: 'nitropack_set_auto_cache_purge_ajax',
387 nonce: nitroNonce,
388 autoCachePurgeStatus: $(this).is(":checked") ? 1 : 0
389 }, function (response) {
390 var resp = JSON.parse(response);
391 NitropackUI.triggerToast(resp.type, resp.message);
392 });
393 });
394
395 $("#bb-purge-status").on("click", function (e) {
396 $.post(ajaxurl, {
397 action: 'nitropack_set_bb_cache_purge_sync_ajax',
398 nonce: nitroNonce,
399 bbCachePurgeSyncStatus: $(this).is(":checked") ? 1 : 0
400 }, function (response) {
401 var resp = JSON.parse(response);
402 NitropackUI.triggerToast(resp.type, resp.message);
403 });
404 });
405
406
407 })(jQuery);
408 </script>