PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.15.2
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.15.2
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 / modals / modal-test-mode.php
nitropack / view / modals Last commit date
modal-disconnect.php 2 years ago modal-modes.php 2 years ago modal-optimization-mode.php 2 years ago modal-posttypes.php 2 years ago modal-purge-cache.php 2 years ago modal-test-mode.php 2 years ago
modal-test-mode.php
168 lines
1 <div id="modal-test-mode" data-modal-backdrop="static" tabindex="-1" aria-hidden="true" class="hidden modal-wrapper popup-modal">
2 <!-- Modal container -->
3 <div class="modal-container">
4 <!-- Modal inner -->
5 <div class="modal-inner">
6 <div class="popup-header">
7 <button type="button" class="close-modal">
8 <svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
9 <path fill-rule="evenodd" clip-rule="evenodd" d="M0.293031 1.29308C0.480558 1.10561 0.734866 1.00029 1.00003 1.00029C1.26519 1.00029 1.5195 1.10561 1.70703 1.29308L6.00003 5.58608L10.293 1.29308C10.3853 1.19757 10.4956 1.12139 10.6176 1.06898C10.7396 1.01657 10.8709 0.988985 11.0036 0.987831C11.1364 0.986677 11.2681 1.01198 11.391 1.06226C11.5139 1.11254 11.6255 1.18679 11.7194 1.28069C11.8133 1.37458 11.8876 1.48623 11.9379 1.60913C11.9881 1.73202 12.0134 1.8637 12.0123 1.99648C12.0111 2.12926 11.9835 2.26048 11.9311 2.38249C11.8787 2.50449 11.8025 2.61483 11.707 2.70708L7.41403 7.00008L11.707 11.2931C11.8892 11.4817 11.99 11.7343 11.9877 11.9965C11.9854 12.2587 11.8803 12.5095 11.6948 12.6949C11.5094 12.8803 11.2586 12.9855 10.9964 12.9878C10.7342 12.99 10.4816 12.8892 10.293 12.7071L6.00003 8.41408L1.70703 12.7071C1.51843 12.8892 1.26583 12.99 1.00363 12.9878C0.741432 12.9855 0.49062 12.8803 0.305212 12.6949C0.119804 12.5095 0.0146347 12.2587 0.0123563 11.9965C0.0100779 11.7343 0.110873 11.4817 0.293031 11.2931L4.58603 7.00008L0.293031 2.70708C0.10556 2.51955 0.000244141 2.26525 0.000244141 2.00008C0.000244141 1.73492 0.10556 1.48061 0.293031 1.29308Z" fill="#1B004E" />
10 </svg>
11 <span class="sr-only"><?php esc_html_e('Close modal', 'nitropack'); ?></span>
12 </button>
13 <img src="<?php echo plugin_dir_url(__FILE__) . '../images/info.svg'; ?>" width="46" height="46" class="icon rotate-180">
14 <h3><?php esc_html_e('Enable Test Mode?', 'nitropack'); ?></h3>
15 </div>
16 <!-- Modal body -->
17 <div class="popup-body"></div>
18 <div class="popup-footer" style="margin-bottom: 0;">
19 <button type="button" class="btn btn-secondary modal-close"><?php esc_html_e('Cancel', 'nitropack'); ?></button>
20 <button type="button" class="btn btn-primary modal-action"><?php esc_html_e('Enable', 'nitropack'); ?></button>
21 </div>
22 </div>
23 </div>
24 </div>
25 <script>
26 jQuery(document).ready(function($) {
27 const $targetEl = document.getElementById('modal-test-mode'),
28 modal_options = {
29 backdrop: 'static',
30 backdropClasses: 'nitro-backdrop',
31 closable: false,
32 },
33 instanceOptions = {
34 id: 'modal-test-mode',
35 override: true
36 },
37 modal = new Modal($targetEl, modal_options, instanceOptions),
38 modal_wrapper = $('#modal-test-mode'),
39 modal_icon = modal_wrapper.find('.icon'),
40 modal_text = modal_wrapper.find('.popup-body'),
41 modal_title = modal_wrapper.find('.popup-header h3'),
42 x_button = modal_wrapper.find('.close-modal'),
43 modal_footer = modal_wrapper.find('.popup-footer'),
44 close_btn = modal_footer.find('.modal-close'),
45 action_btn = modal_footer.find('.modal-action'),
46 setting_id = '#safemode-status';
47
48
49 $(setting_id).change(function() {
50 close_btn.off("click");
51 action_btn.off("click");
52 modal_icon.attr('src', '<?php echo plugin_dir_url(__FILE__) . '../images/info.svg'; ?>');
53 modal_footer.removeClass('hidden');
54 if (this.checked) {
55 modal_title.text('<?php esc_html_e('Enable Test Mode?', 'nitropack'); ?>');
56 modal_text.html('<p><?php esc_html_e('When you enable Test Mode, we disable all NitroPack’s optimizations and your site visitors are accessing your regular, unoptimized URLs.', 'nitropack'); ?></p>');
57 modal_text.append("<p class='msg-container'><?php _e('To view how a NitroPack optimised page will load and behave simply append <b>?testnitro=1</b> to any URL (e.g. https://yourwebsite.com/?testnitro=1)', 'nitropack'); ?></p>");
58 modal_text.append("<p><?php esc_html_e('This allows you to assess and fine-tune NitroPack’s performance before implementing optimizations site-wide.', 'nitropack'); ?></p>");
59 close_btn.text('<?php esc_html_e('Cancel', 'nitropack'); ?>');
60 action_btn.text('<?php esc_html_e('Enable', 'nitropack'); ?>');
61 close_btn.click(function() {
62 $(setting_id).prop('checked', false);
63 modal.hide();
64 });
65 x_button.click(function() {
66 $(setting_id).prop('checked', false);
67 });
68
69 action_btn.click(function() {
70 enableSafemode();
71 });
72
73 } else {
74
75 modal_title.text('<?php esc_html_e('Purge cache after disabling Test Mode?', 'nitropack'); ?>');
76 modal_text.html('<p><?php esc_html_e('If you have made changes to NitroPack configuration or your website while you were using test mode, we recommend you to purge your cache. In this way we will update NitroPack cache with your recent changes.', 'nitropack'); ?></p>');
77 close_btn.text('<?php esc_html_e('I will do it later', 'nitropack'); ?>');
78 action_btn.text('<?php esc_html_e('Purge cache now', 'nitropack'); ?>');
79
80 action_btn.click(function() {
81 let purgeEvent = new Event("cache.purge.request");
82 window.dispatchEvent(purgeEvent);
83 modal.hide();
84 });
85 disableSafemode();
86
87 $(setting_id).prop('checked', false);
88 }
89 close_btn.click(function() {
90 modal.hide();
91 });
92 modal.show();
93 });
94 close_btn.click(function() {
95 modal.hide();
96 });
97 x_button.click(function() {
98 modal.hide();
99 });
100 var enableSafemode = () => {
101 modal_icon.attr('src', '<?php echo plugin_dir_url(__FILE__) . '../images/loading.svg'; ?>');
102 $.post(ajaxurl, {
103 action: 'nitropack_enable_safemode',
104 nonce: nitroNonce
105 }, function(response) {
106 var resp = JSON.parse(response);
107 modal_footer.addClass('hidden');
108 if (resp.type == "success") {
109 $(setting_id).prop("checked", true);
110 $("#nitropack-smenabled-notice").closest('.nitro-notification').show();
111 modal_title.text(resp.message);
112 modal_text.text('');
113 } else {
114 modal_title.text('<?php esc_html_e('Error!', 'nitropack'); ?>');
115 modal_text.text('');
116 $(setting_id).prop('checked', false);
117
118 }
119 NitropackUI.triggerToast(resp.type, resp.message);
120 modal.hide();
121 });
122 }
123
124 var disableSafemode = () => {
125 $.post(ajaxurl, {
126 action: 'nitropack_disable_safemode',
127 nonce: nitroNonce
128 }, function(response) {
129 var resp = JSON.parse(response);
130 if (resp.type == "success") $("#nitropack-smenabled-notice").closest('.nitro-notification').hide();
131
132 NitropackUI.triggerToast(resp.type, resp.message);
133 });
134 }
135
136 var loadSafemodeStatus = function() {
137 $.ajax({
138 url: ajaxurl,
139 type: "POST",
140 data: {
141 action: "nitropack_safemode_status",
142 nonce: nitroNonce
143 },
144 dataType: "json",
145 success: function(resp) {
146 if (resp.type == "success") {
147 $("#safemode-status").attr("checked", !!resp.isEnabled);
148 $("#nitropack-smenabled-notice").length && !!resp.isEnabled ? $("#nitropack-smenabled-notice").parent().show() : $("#nitropack-smenabled-notice").parent().hide();
149 if (resp.isEnabled && !$("#nitropack-smenabled-notice").length) {
150 $('#main > .container').prepend('<div class="nitro-notification notification-warning"><div class="notification-inner">' +
151 +'<div class="title-msg"><div class="title-wrapper">' +
152 '<img src="/view/images/info.svg" alt="alert" class="icon">' +
153 '<h5 class="title">Warning</h5>' +
154 '</div><div class="msg"><div id="nitropack-smenabled-notice">Test Mode is enabled for your site and visitors are accessing your unoptimized pages. Make sure to disable it once you are done testing.</div></div>' +
155 '</div></div>' +
156 '</div>')
157 }
158 $("#loading-safemode-status").hide();
159 } else {
160 setTimeout(loadSafemodeStatus, 500);
161 }
162 }
163 });
164 }
165
166 loadSafemodeStatus();
167 });
168 </script>