images
1 year ago
javascript
1 year ago
modals
1 year ago
stylesheet
1 year ago
templates
2 years ago
admin.php
1 year ago
connect-oneclick.php
1 year ago
connect.php
2 years ago
dashboard-oneclick.php
2 years ago
dashboard.php
1 year ago
oneclick.php
2 years ago
safemode.php
2 years ago
system-report.php
1 year ago
admin.php
219 lines
| 1 | <script> |
| 2 | let nitroNonce = '<?php echo wp_create_nonce(NITROPACK_NONCE); ?>'; |
| 3 | </script> |
| 4 | <div id="nitropack-container"> |
| 5 | <nav class="nitro-navigation"> |
| 6 | <div class="nitro-navigation-inner"> |
| 7 | <img src="<?php echo plugin_dir_url(__FILE__) . 'images/nitropack_logo.svg'; ?>" height="25" alt="NitroPack" /> |
| 8 | </div> |
| 9 | </nav> |
| 10 | |
| 11 | <main id="main"> |
| 12 | |
| 13 | <div class="container"> |
| 14 | <?php if (count(get_nitropack()->Notifications->get('system')) > 0) { ?> |
| 15 | <div class="notification notification-danger" id="notifications"> |
| 16 | <div class="text-box"> |
| 17 | <div class="title-wrapper"> |
| 18 | <img src="<?php echo plugin_dir_url(__FILE__) . 'images/alert-triangle.svg'; ?>" alt="alert" class="icon" /> |
| 19 | <h5 class="title"><?php esc_html_e('Notifications', 'nitropack'); ?></h5> |
| 20 | </div> |
| 21 | <ul> |
| 22 | |
| 23 | <?php foreach (get_nitropack()->Notifications->get('system') as $notification) : ?> |
| 24 | <li class="grid grid-cols-2 justify-between items-center"> |
| 25 | <div class="col-span-8"> |
| 26 | <?php echo $notification['message']; ?> |
| 27 | </div> |
| 28 | <div class="col-span-4 ml-auto"> |
| 29 | <a class="btn btn-danger rml_btn" data-notification_end="<?php echo $notification['end_date']; ?>" data-notification_id="<?php echo $notification['id']; ?>">Remind me later</a> |
| 30 | </div> |
| 31 | </li> |
| 32 | <?php endforeach; ?> |
| 33 | </ul> |
| 34 | </div> |
| 35 | </div> |
| 36 | <?php } ?> |
| 37 | <?php if (!isset($_GET['subpage'])) : ?> |
| 38 | <?php require_once NITROPACK_PLUGIN_DIR . "view/dashboard.php"; |
| 39 | ?> |
| 40 | <?php endif; ?> |
| 41 | |
| 42 | |
| 43 | <?php if (isset($_GET['subpage']) && $_GET['subpage'] == 'system-report') : ?> |
| 44 | <?php require_once NITROPACK_PLUGIN_DIR . "view/system-report.php"; |
| 45 | ?> |
| 46 | <?php endif; ?> |
| 47 | </div> |
| 48 | </main> |
| 49 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/templates/template-toast.php'; ?> |
| 50 | </div> |
| 51 | |
| 52 | <?php if (NITROPACK_SUPPORT_BUBBLE_VISIBLE) { ?> |
| 53 | <div class="support-widget"> |
| 54 | <!-- support widget --> |
| 55 | <script> |
| 56 | window.intercomSettings = { |
| 57 | api_base: "https://api-iam.intercom.io", |
| 58 | app_id: "d5v9p9vg" |
| 59 | }; |
| 60 | |
| 61 | (function() { |
| 62 | var w = window; |
| 63 | var ic = w.Intercom; |
| 64 | if (typeof ic === "function") { |
| 65 | ic('reattach_activator'); |
| 66 | ic('update', w.intercomSettings); |
| 67 | } else { |
| 68 | var d = document; |
| 69 | var i = function() { |
| 70 | i.c(arguments); |
| 71 | }; |
| 72 | i.q = []; |
| 73 | i.c = function(args) { |
| 74 | i.q.push(args); |
| 75 | }; |
| 76 | w.Intercom = i; |
| 77 | var l = function() { |
| 78 | var s = d.createElement('script'); |
| 79 | s.type = 'text/javascript'; |
| 80 | s.async = true; |
| 81 | s.src = 'https://widget.intercom.io/widget/d5v9p9vg'; |
| 82 | var x = d.getElementsByTagName('script')[0]; |
| 83 | x.parentNode.insertBefore(s, x); |
| 84 | }; |
| 85 | if (document.readyState === 'complete') { |
| 86 | l(); |
| 87 | } else if (w.attachEvent) { |
| 88 | w.attachEvent('onload', l); |
| 89 | } else { |
| 90 | w.addEventListener('load', l, false); |
| 91 | } |
| 92 | } |
| 93 | })(); |
| 94 | </script> |
| 95 | <!-- end support widget --> |
| 96 | </div> |
| 97 | <?php } ?> |
| 98 | <script> |
| 99 | (function($) { |
| 100 | window.Notification = (_ => { |
| 101 | var timeout; |
| 102 | |
| 103 | var display = (msg, type) => { |
| 104 | clearTimeout(timeout); |
| 105 | $('#nitropack-notification').remove(); |
| 106 | |
| 107 | $('[name="form"]').prepend('<div id="nitropack-notification" class="notice notice-' + type + '" is-dismissible"><p>' + msg + '</p></div>'); |
| 108 | |
| 109 | timeout = setTimeout(_ => { |
| 110 | $('#nitropack-notification').remove(); |
| 111 | }, 10000); |
| 112 | loadDismissibleNotices(); |
| 113 | } |
| 114 | |
| 115 | return { |
| 116 | success: msg => { |
| 117 | display(msg, 'success'); |
| 118 | }, |
| 119 | error: msg => { |
| 120 | display(msg, 'error'); |
| 121 | }, |
| 122 | info: msg => { |
| 123 | display(msg, 'info'); |
| 124 | }, |
| 125 | warning: msg => { |
| 126 | display(msg, 'warning'); |
| 127 | } |
| 128 | } |
| 129 | })(); |
| 130 | |
| 131 | const clearCacheHandler = clearCacheAction => { |
| 132 | return function(success, error) { |
| 133 | $.ajax({ |
| 134 | url: ajaxurl, |
| 135 | type: 'GET', |
| 136 | data: { |
| 137 | action: "nitropack_" + clearCacheAction + "_cache", |
| 138 | nonce: nitroNonce |
| 139 | }, |
| 140 | dataType: 'json', |
| 141 | beforeSend: function() { |
| 142 | $('#optimizations-purge-cache').attr('disabled', true); |
| 143 | }, |
| 144 | success: function(data) { |
| 145 | if (data.type === 'success') { |
| 146 | NitropackUI.triggerToast('success', data.message); |
| 147 | cacheEvent = new Event("cache." + clearCacheAction + ".success"); |
| 148 | } else { |
| 149 | NitropackUI.triggerToast('error', data.message); |
| 150 | cacheEvent = new Event("cache." + clearCacheAction + ".error"); |
| 151 | } |
| 152 | window.dispatchEvent(cacheEvent); |
| 153 | }, |
| 154 | error: function(data) { |
| 155 | |
| 156 | NitropackUI.triggerToast('error', data.message); |
| 157 | cacheEvent = new Event("cache." + clearCacheAction + ".error"); |
| 158 | window.dispatchEvent(cacheEvent); |
| 159 | }, |
| 160 | complete: function() { |
| 161 | setTimeout(function() { |
| 162 | $('#optimizations-purge-cache').attr('disabled', false); |
| 163 | }, 3000); |
| 164 | } |
| 165 | }); |
| 166 | }; |
| 167 | } |
| 168 | |
| 169 | window.addEventListener("cache.purge.success", function() { |
| 170 | setTimeout(function() { |
| 171 | document.cookie = "nitropack_apwarning=1; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=<?php echo nitropack_cookiepath(); ?>"; |
| 172 | window.location.reload() |
| 173 | }, 1500) |
| 174 | }); |
| 175 | |
| 176 | $(window).on("load", _ => { |
| 177 | //Remove styles from jobcareer and jobhunt plugins since they break our layout. They should not be loaded on our options page anyway. |
| 178 | $('link[href*="jobcareer"').remove(); |
| 179 | $('link[href*="jobhunt"').remove(); |
| 180 | |
| 181 | $("#dashboard").addClass("show active"); |
| 182 | window.addEventListener('cache.invalidate.request', clearCacheHandler("invalidate")); |
| 183 | window.addEventListener('cache.purge.request', clearCacheHandler("purge")); |
| 184 | |
| 185 | }); |
| 186 | const loading_icon = '<img src="<?php echo plugin_dir_url(__FILE__); ?>/images/loading.svg" width="14" class="icon loading"/>', |
| 187 | success_icon = '<img src="<?php echo plugin_dir_url(__FILE__); ?>/images/check.svg" width="16" class="icon success"/>'; |
| 188 | |
| 189 | $("#nitro-restore-connection-btn").on("click", function() { |
| 190 | $.ajax({ |
| 191 | url: ajaxurl, |
| 192 | type: 'GET', |
| 193 | data: { |
| 194 | action: "nitropack_reconfigure_webhooks", |
| 195 | nonce: nitroNonce |
| 196 | }, |
| 197 | dataType: 'json', |
| 198 | beforeSend: function() { |
| 199 | $("#nitro-restore-connection-btn").attr("disabled", true).html(loading_icon); |
| 200 | }, |
| 201 | success: function(data) { |
| 202 | if (!data.status || data.status != "success") { |
| 203 | if (data.message) { |
| 204 | alert("<?php esc_html_e('Error:', 'nitropack'); ?> " + data.message); |
| 205 | } else { |
| 206 | alert("<?php esc_html_e('Error: We were unable to restore the connection. Please contact our support team to get this resolved.', 'nitropack'); ?>"); |
| 207 | } |
| 208 | } else { |
| 209 | $("#nitro-restore-connection-btn").attr("disabled", true).html(success_icon); |
| 210 | NitropackUI.triggerToast('success', data.message); |
| 211 | } |
| 212 | }, |
| 213 | complete: function() { |
| 214 | location.reload(); |
| 215 | } |
| 216 | }); |
| 217 | }); |
| 218 | })(jQuery); |
| 219 | </script> |