PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.10.2
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.10.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 / oneclick.php
nitropack / view Last commit date
images 3 years ago javascript 2 years ago stylesheet 2 years ago admin.php 2 years ago connect-oneclick.php 2 years ago connect.php 2 years ago dashboard-oneclick.php 2 years ago dashboard.php 2 years ago diag.php 2 years ago help.php 3 years ago oneclick.php 2 years ago safemode.php 2 years ago safemode.tpl 4 years ago
oneclick.php
138 lines
1 <script>
2 let nitroNonce = '<?php echo wp_create_nonce(NITROPACK_NONCE); ?>';
3 </script>
4 <div id="nitropack-container" class="wrap">
5 <div id="heading" class="mt-4">
6 <h5 class="font-weight-bold default-fonts npoc-title"><?php esc_html_e( 'NitroPack OneClick™', 'nitropack' ); ?></h5>
7 </div>
8
9 <form method="post" action="options.php" name="form">
10 <?php settings_fields( NITROPACK_OPTION_GROUP ); ?>
11 <?php do_settings_sections( NITROPACK_OPTION_GROUP ); ?>
12 <div class="tab-content" style="display:block">
13 <div id="dashboard" class="tab-pane hidden">
14 <?php require_once NITROPACK_PLUGIN_DIR . "view/dashboard-oneclick.php"; ?>
15 </div>
16 </div>
17 </form>
18 </div>
19 <script>
20 (function($) {
21 window.Notification = (_ => {
22 var timeout;
23
24 var display = (msg, type) => {
25 clearTimeout(timeout);
26 $('#nitropack-notification').remove();
27
28 $('[name="form"]').prepend('<div id="nitropack-notification" class="notice notice-' + type + '" is-dismissible"><p>' + msg + '</p></div>');
29
30 timeout = setTimeout(_ => {
31 $('#nitropack-notification').remove();
32 }, 10000);
33 loadDismissibleNotices();
34 }
35
36 return {
37 success: msg => {
38 display(msg, 'success');
39 },
40 error: msg => {
41 display(msg, 'error');
42 },
43 info: msg => {
44 display(msg, 'info');
45 },
46 warning: msg => {
47 display(msg, 'warning');
48 }
49 }
50 })();
51
52 const clearCacheHandler = clearCacheAction => {
53 return function(success, error) {
54 $.ajax({
55 url: ajaxurl,
56 type: 'GET',
57 data: {
58 action: "nitropack_" + clearCacheAction + "_cache",
59 nonce: nitroNonce
60 },
61 dataType: 'json',
62 beforeSend: function() {
63 Notification.info("Loading. Please wait...");
64 $('#optimizations-purge-cache').hide();
65 $('#np-purge-cache-loading').show();
66 },
67 success: function(data) {
68 $('#np-purge-cache-loading').hide();
69 if (data.type === 'success') {
70 $('#np-purge-cache-success').show();
71 Notification[data.type](data.message);
72 cacheEvent = new Event("cache." + clearCacheAction + ".success");
73 } else {
74 $('#np-purge-cache-error').show();
75 Notification[data.type](data.message);
76 cacheEvent = new Event("cache." + clearCacheAction + ".error");
77 }
78 window.dispatchEvent(cacheEvent);
79 },
80 error: function(data) {
81 $('#np-purge-cache-loading').hide();
82 $('#np-purge-cache-error').show();
83 Notification[data.type](data.message);
84 cacheEvent = new Event("cache." + clearCacheAction + ".error");
85 window.dispatchEvent(cacheEvent);
86 },
87 complete: function() {
88 setTimeout(function(){$('#np-purge-cache-success').hide();$('#np-purge-cache-error').hide();$('#optimizations-purge-cache').show();}, 3000);
89 }
90 });
91 };
92 }
93
94 $(window).on("load", _ => {
95 //Remove styles from jobcareer and jobhunt plugins since they break our layout. They should not be loaded on our options page anyway.
96 $('link[href*="jobcareer"').remove();
97 $('link[href*="jobhunt"').remove();
98
99 $("#dashboard").addClass("show active");
100 window.addEventListener('cache.invalidate.request', clearCacheHandler("invalidate"));
101 window.addEventListener('cache.purge.request', clearCacheHandler("purge"));
102
103 NitroPack.QuickSetup.setChangeHandler(async function(value, success, error) {
104 success(value);
105 });
106 });
107
108 $("#nitro-restore-connection-btn").on("click", function() {
109 $.ajax({
110 url: ajaxurl,
111 type: 'GET',
112 data: {
113 action: "nitropack_reconfigure_webhooks",
114 nonce: nitroNonce
115 },
116 dataType: 'json',
117 beforeSend: function() {
118 $("#nitro-restore-connection-btn").attr("disabled", true).html("<i class='fa fa-refresh fa-spin'></i>");
119 },
120 success: function(data) {
121 if (!data.status || data.status != "success") {
122 if (data.message) {
123 alert("<?php esc_html_e( 'Error:', 'nitropack' ); ?> " + data.message);
124 } else {
125 alert("<?php esc_html_e( 'Error: We were unable to restore the connection. Please contact our support team to get this resolved.', 'nitropack' ); ?>");
126 }
127 } else {
128 $("#nitro-restore-connection-btn").attr("disabled", true).html("<i class='fa fa-check'></i>");
129 }
130 },
131 complete: function() {
132 location.reload();
133 }
134 });
135 });
136 })(jQuery);
137 </script>
138