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