PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / trunk
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization vtrunk
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-cache-warmup.php 1 month ago modal-disconnect.php 1 month ago modal-go-live.php 1 month ago modal-modes.php 3 days ago modal-not-optimized-CPT.php 1 year ago modal-optimization-mode.php 1 month ago modal-plugin-deactivate.php 1 month ago modal-posttypes.php 3 months ago modal-processing-html-error.php 3 months ago modal-processing-html-success.php 1 month ago modal-processing-html.php 1 month ago modal-purge-cache.php 1 month ago modal-safemode.php 1 month ago modal-test-mode.php 1 month ago modal-unsaved-changes.php 1 month ago
modal-test-mode.php
170 lines
1 <div id="modal-test-mode" data-modal-backdrop="" tabindex="-1" aria-hidden="true"
2 class="hidden modal-wrapper popup-modal">
3 <!-- Modal container -->
4 <div class="modal-container">
5 <!-- Modal inner -->
6 <div class="modal-inner">
7 <div class="popup-header">
8 <button type="button" class="close-modal">
9 <svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
10 <path fill-rule="evenodd" clip-rule="evenodd"
11 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"
12 fill="#1B004E" />
13 </svg>
14 <span class="sr-only"><?php esc_html_e( 'Close modal', 'nitropack' ); ?></span>
15 </button>
16 <img src="<?php echo NITROPACK_PLUGIN_DIR_URL . 'assets/img/info.svg'; ?>" width="46" height="46"
17 alt="" class="icon rotate-180">
18 <h3><?php esc_html_e( 'Enable Test Mode?', 'nitropack' ); ?></h3>
19 </div>
20 <!-- Modal body -->
21 <div class="popup-body"></div>
22 <div class="popup-footer" style="margin-bottom: 0;">
23 <button type="button"
24 class="btn btn-secondary modal-close"><?php esc_html_e( 'Cancel', 'nitropack' ); ?></button>
25 <button type="button"
26 class="btn btn-primary modal-action"><?php esc_html_e( 'Enable', 'nitropack' ); ?></button>
27 </div>
28 </div>
29 </div>
30 </div>
31 <script>
32 jQuery(document).ready(function ($) {
33 const $targetEl = document.getElementById('modal-test-mode'),
34 modal_options = {
35 backdrop: 'static',
36 backdropClasses: 'nitro-backdrop',
37 closable: false,
38 },
39 instanceOptions = {
40 id: 'modal-test-mode',
41 override: true
42 },
43 modal = new Modal($targetEl, modal_options, instanceOptions),
44 modal_wrapper = $('#modal-test-mode'),
45 modal_icon = modal_wrapper.find('.icon'),
46 modal_text = modal_wrapper.find('.popup-body'),
47 modal_title = modal_wrapper.find('.popup-header h3'),
48 x_button = modal_wrapper.find('.close-modal'),
49 modal_footer = modal_wrapper.find('.popup-footer'),
50 close_btn = modal_footer.find('.modal-close'),
51 action_btn = modal_footer.find('.modal-action'),
52 setting_id = '#safemode-status',
53 test_mode_notification = $(".nitro-notification.test-mode");
54
55
56 $(setting_id).change(function () {
57 close_btn.off("click");
58 action_btn.off("click");
59 modal_icon.attr('src', '<?php echo NITROPACK_PLUGIN_DIR_URL . 'assets/img/info.svg'; ?>');
60 modal_footer.removeClass('hidden');
61 if (this.checked) {
62 modal_title.text('<?php esc_html_e( 'Enable Test Mode?', 'nitropack' ); ?>');
63 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>');
64 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>");
65 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>");
66 close_btn.text('<?php esc_html_e( 'Cancel', 'nitropack' ); ?>');
67 action_btn.text('<?php esc_html_e( 'Enable', 'nitropack' ); ?>');
68 close_btn.click(function () {
69 $(setting_id).prop('checked', false);
70 modal.hide();
71 });
72 x_button.click(function () {
73 $(setting_id).prop('checked', false);
74 });
75
76 action_btn.click(function () {
77 enableSafemode().then(function (respType) {
78 if (respType && !test_mode_notification.length) {
79 return renderNotification();
80 } else if (!respType && test_mode_notification.length) {
81 test_mode_notification.remove();
82 }
83 });
84 });
85
86 } else {
87
88 modal_title.text('<?php esc_html_e( 'Purge cache after disabling Test Mode?', 'nitropack' ); ?>');
89 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>');
90 close_btn.text('<?php esc_html_e( 'I will do it later', 'nitropack' ); ?>');
91 action_btn.text('<?php esc_html_e( 'Purge cache now', 'nitropack' ); ?>');
92
93 action_btn.click(function () {
94 let purgeEvent = new Event("cache.purge.request");
95 window.dispatchEvent(purgeEvent);
96 modal.hide();
97 });
98 disableSafemode();
99
100 $(setting_id).prop('checked', false);
101 }
102 close_btn.click(function () {
103 modal.hide();
104 });
105 modal.show();
106 });
107 close_btn.click(function () {
108 modal.hide();
109 });
110 x_button.click(function () {
111 modal.hide();
112 });
113 var enableSafemode = () => {
114 modal_icon.attr('src', '<?php echo NITROPACK_PLUGIN_DIR_URL . 'assets/img/loading.svg'; ?>');
115 return $.ajax({
116 url: ajaxurl,
117 type: "POST",
118 data: {
119 action: "nitropack_enable_safemode",
120 nonce: nitroNonce
121 },
122 dataType: "json"
123 }).done(function (resp) {
124 modal_footer.addClass('hidden');
125 if (resp.type == "success") {
126 $(setting_id).prop("checked", true);
127 modal_title.text(resp.message);
128 modal_text.text('');
129 } else {
130 modal_title.text('<?php esc_html_e( 'Error!', 'nitropack' ); ?>');
131 modal_text.text('');
132 $(setting_id).prop('checked', false);
133 }
134 NitropackUI.triggerToast(resp.type, resp.message);
135 modal.hide();
136 return resp.type;
137 }).fail(function () {
138 NitropackUI.triggerToast('error', 'Error enabling safemode status');
139 });
140 };
141
142 var disableSafemode = () => {
143 $.post(ajaxurl, {
144 action: 'nitropack_disable_safemode',
145 nonce: nitroNonce
146 }, function (response) {
147 var resp = JSON.parse(response);
148 if (resp.type == "success") $(document).find('.nitro-notification.test-mode').remove();
149
150 NitropackUI.triggerToast(resp.type, resp.message);
151 });
152 };
153
154 var renderNotification = () => {
155 return $.ajax({
156 url: ajaxurl,
157 type: "POST",
158 data: {
159 action: "nitropack_safemode_notification",
160 nonce: nitroNonce
161 },
162 dataType: "html"
163 }).done(function (resp) {
164 $(resp).insertBefore('#main > .container .nitropack-dashboard');
165 }).fail(function () {
166 console.error("Error rendering notification");
167 });
168 };
169 });
170 </script>