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-oneclick.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-oneclick.php
354 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 <!-- Basic Settings Card -->
112 <div class="card card-basic-settings">
113 <div class="card-header">
114 <h3><?php esc_html_e( 'Basic Settings', 'nitropack' ); ?></h3>
115 </div>
116 <div class="card-body">
117 <div class="options-container">
118
119 <?php $settings->cache_warmup->render();
120 $settings->test_mode->render(); ?>
121
122 <div class="nitro-option" id="compression-widget">
123 <div class="nitro-option-main">
124 <div class="text-box">
125 <h6><span
126 id="detected-compression"><?php esc_html_e( 'HTML Compression', 'nitropack' ); ?>
127 </span></h6>
128 <p>
129 <?php esc_html_e( 'Compressing the structure of your HTML, ensures faster page rendering and an optimized browsing experience for your users.', 'nitropack' ); ?>
130 <a href="https://support.nitropack.io/en/articles/8390333-nitropack-plugin-settings-in-wordpress#h_29b7ab4836"
131 class="text-blue"
132 target="_blank"><?php esc_html_e( 'Learn more', 'nitropack' ); ?></a>
133 </p>
134 </div>
135 <label class="inline-flex items-center cursor-pointer ml-auto">
136 <input type="checkbox" id="compression-status" class="sr-only peer" <?php echo (int) $enableCompression === 1 ? "checked" : ""; ?>>
137 <div class="toggle"></div>
138 </label>
139 </div>
140 <div class="mt-4 text-primary">
141 <a href="javascript:void(0);" id="compression-test-btn"
142 class="text-primary"><?php esc_html_e( 'Run compression test', 'nitropack' ); ?></a>
143 <div class="flex items-start msg-container hidden">
144 <span class="msg"></span>
145 </div>
146 </div>
147 </div>
148 <?php if ( \NitroPack\Integration\Plugin\BeaverBuilder::isActive() ) { ?>
149 <div class="nitro-option" id="beaver-builder-widget">
150 <div class="nitro-option-main">
151 <div class="text-box">
152 <h6><span
153 id="detected-compression"><?php esc_html_e( 'Sync NitroPack Purge with Beaver Builder', 'nitropack' ); ?>
154 </span></h6>
155 <p>
156 <?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' ); ?>
157 </p>
158 </div>
159 <label class="inline-flex items-center cursor-pointer ml-auto">
160 <input type="checkbox" class="sr-only peer" id="bb-purge-status" <?php if ( $bbCacheSyncPurge )
161 echo "checked"; ?>>
162 <div class="toggle"></div>
163 </label>
164 </div>
165 </div>
166 <?php } ?>
167 <div class="nitro-option" id="can-editor-clear-cache-widget">
168 <div class="nitro-option-main">
169 <div class="text-box">
170 <h6><?php esc_html_e( 'Allow Editors to purge cache', 'nitropack' ); ?></h6>
171 <p><?php esc_html_e( 'Give Editors the right to purge cache when content is updated.', 'nitropack' ); ?>
172 </p>
173 </div>
174 <label class="inline-flex items-center cursor-pointer ml-auto">
175 <input type="checkbox" id="can-editor-clear-cache" class="sr-only peer" <?php echo (int) $canEditorClearCache === 1 ? "checked" : ""; ?>>
176 <div class="toggle"></div>
177 </label>
178 </div>
179 </div>
180 </div>
181 </div>
182 </div>
183 </div>
184 <?php $notOptimizedCPTs = nitropack_filter_non_optimized();
185 $notices = get_option( 'nitropack-dismissed-notices', [] );
186 $optimizedCPT_notice = in_array( 'OptimizeCPT', $notices, true ) ? true : false;
187 if ( ! $optimizedCPT_notice && ! empty( $notOptimizedCPTs ) )
188 require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-not-optimized-CPT.php'; ?>
189 </div>
190 <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-unsaved-changes.php'; ?>
191 <script>
192 ($ => {
193 var getOptimizationsTimeout = null;
194 let isClearing = false;
195 $(window).on("load", function () {
196 getOptimizations();
197 <?php if ( $checkedCompression != 1 ) { ?>
198 autoDetectCompression();
199 <?php } ?>
200 });
201
202 /* Cache Purge begin */
203 window.performCachePurge = () => {
204 purgeCache();
205 }
206
207 let purgeCache = () => {
208 let purgeEvent = new Event("cache.purge.request");
209 window.dispatchEvent(purgeEvent);
210 }
211
212 var getOptimizations = _ => {
213 var url = '<?php echo $optimizationDetailsUrl; ?>';
214 ((s, e, f) => {
215 if (window.fetch) {
216 fetch(url)
217 .then(resp => resp.json())
218 .then(s)
219 .catch(e)
220 .finally(f);
221 } else {
222 $.ajax({
223 url: url,
224 type: 'GET',
225 dataType: 'json',
226 success: s,
227 error: e,
228 complete: f
229 })
230 }
231 })(data => {
232 $('[data-last-cache-purge]').text(data.last_cache_purge.timeAgo);
233 if (data.last_cache_purge.reason) {
234 $('[data-purge-reason]').text(data.last_cache_purge.reason);
235 $('[data-purge-reason]').attr('title', data.last_cache_purge.reason);
236 $('#last-cache-purge-reason').show();
237 } else {
238 $('#last-cache-purge-reason').hide();
239 }
240 if (data.pending_count) {
241 $("#pending-optimizations-count").text(data.pending_count);
242 $("#pending-optimizations-section").show();
243 } else {
244 $("#pending-optimizations-section").hide();
245 }
246
247 $('[data-optimized-pages-total]').text(data.optimized_pages.total);
248
249 }, __ => {
250 console.error("An error occurred while fetching data for optimized pages");
251 }, __ => {
252 if (!getOptimizationsTimeout) {
253 getOptimizationsTimeout = setTimeout(function () {
254 getOptimizationsTimeout = null;
255 getOptimizations();
256 }, 60000);
257 }
258 });
259 }
260
261 $(document).on('click', "#compression-test-btn", e => {
262 e.preventDefault();
263 autoDetectCompression();
264 });
265 /* Compression end */
266
267 /* HTML Compression begin */
268 var autoDetectCompression = function () {
269 let msg_container = $('#compression-widget .msg-container'),
270 msg_icon = msg_container.find('.icon'),
271 msg_box = msg_container.find('.msg'),
272 compression_setting = $('#compression-status'),
273 compression_btn = $('#compression-test-btn');
274 //add spinner here
275 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' ); ?>');
276 compression_btn.addClass('hidden');
277 msg_container.removeClass('hidden');
278 $.post(ajaxurl, {
279 action: 'nitropack_test_compression_ajax',
280 nonce: nitroNonce
281 }, function (response) {
282 var resp = JSON.parse(response);
283
284 if (resp.status == "success") {
285 if (resp.hasCompression) { // compression already enabled
286 compression_setting.attr("checked", false);
287
288 msg_box.text('<?php esc_html_e( 'Compression is already enabled on your server! There is no need to enable it in NitroPack.', 'nitropack' ); ?>')
289 } else {
290 compression_setting.attr("checked", true);
291 msg_box.text('<?php esc_html_e( 'No compression was detected! We will now enable it in NitroPack.', 'nitropack' ); ?>');
292 }
293 NitropackUI.triggerToast(resp.type, resp.message);
294 } else {
295 msg_box.text('<?php esc_html_e( 'Could not determine compression status automatically. Please configure it manually.', 'nitropack' ); ?>');
296 }
297 setTimeout(function () {
298 msg_container.addClass('hidden');
299 compression_btn.removeClass('hidden');
300 }, 5000);
301 });
302 }
303
304
305 $("#compression-status").on("click", function (e) {
306 $.post(ajaxurl, {
307 action: 'nitropack_set_compression_ajax',
308 nonce: nitroNonce,
309 data: {
310 compressionStatus: $(this).is(":checked") ? 1 : 0
311 }
312 }, function (response) {
313 var resp = JSON.parse(response);
314 NitropackUI.triggerToast(resp.type, resp.message);
315 });
316 });
317 $("#can-editor-clear-cache").on("click", function (e) {
318 $.post(ajaxurl, {
319 action: 'nitropack_set_can_editor_clear_cache',
320 nonce: nitroNonce,
321 data: {
322 canEditorClearCache: $(this).is(":checked") ? 1 : 0
323 }
324 }, function (response) {
325 var resp = JSON.parse(response);
326 NitropackUI.triggerToast(resp.type, resp.message);
327 });
328 });
329
330 $("#auto-purge-status").on("click", function (e) {
331 $.post(ajaxurl, {
332 action: 'nitropack_set_auto_cache_purge_ajax',
333 nonce: nitroNonce,
334 autoCachePurgeStatus: $(this).is(":checked") ? 1 : 0
335 }, function (response) {
336 var resp = JSON.parse(response);
337 NitropackUI.triggerToast(resp.type, resp.message);
338 });
339 });
340
341 $("#bb-purge-status").on("click", function (e) {
342 $.post(ajaxurl, {
343 action: 'nitropack_set_bb_cache_purge_sync_ajax',
344 nonce: nitroNonce,
345 bbCachePurgeSyncStatus: $(this).is(":checked") ? 1 : 0
346 }, function (response) {
347 var resp = JSON.parse(response);
348 NitropackUI.triggerToast(resp.type, resp.message);
349 });
350 });
351
352
353 })(jQuery);
354 </script>