images
6 years ago
javascript
5 years ago
stylesheet
5 years ago
admin.php
5 years ago
connect.php
5 years ago
dashboard.php
5 years ago
diag.php
5 years ago
help.php
6 years ago
admin.php
131 lines
| 1 | <div id="nitropack-container" class="wrap"> |
| 2 | <div id="heading"> |
| 3 | <h2>NitroPack.io</h2> |
| 4 | </div> |
| 5 | |
| 6 | <form method="post" action="options.php" name="form"> |
| 7 | <?php settings_fields( NITROPACK_OPTION_GROUP ); ?> |
| 8 | <?php do_settings_sections( NITROPACK_OPTION_GROUP ); ?> |
| 9 | |
| 10 | <ul class="nav nav-tabs nav-tab-wrapper"> |
| 11 | <li><a class="nav-tab active" href="#dashboard" data-toggle="tab">Dashboard</a></li> |
| 12 | <li><a class="nav-tab" href="#help" data-toggle="tab">Help</a></li> |
| 13 | <li><a class="nav-tab" href="#diag" data-toggle="tab">Diagnostics</a></li> |
| 14 | </ul> |
| 15 | <div class="tab-content" style="display:block"> |
| 16 | <div id="dashboard" class="tab-pane hidden"> |
| 17 | <?php require_once "dashboard.php"; ?> |
| 18 | </div> |
| 19 | <div id="help" class="tab-pane hidden"> |
| 20 | <?php require_once "help.php"; ?> |
| 21 | </div> |
| 22 | <div id="diag" class="tab-pane hidden"> |
| 23 | <?php require_once "diag.php"; ?> |
| 24 | </div> |
| 25 | </div> |
| 26 | </form> |
| 27 | </div> |
| 28 | <?php if (NITROPACK_SUPPORT_BUBBLE_VISIBLE) { ?> |
| 29 | <div class="nitropack-support-icon" data-toggle="tooltip" title="Get help"> |
| 30 | <a href="<?php echo NITROPACK_SUPPORT_BUBBLE_URL; ?>" target="_blank" rel="noopener noreferrer"><i class="fa fa-life-ring"></i></a> |
| 31 | </div> |
| 32 | <?php } ?> |
| 33 | <script> |
| 34 | (function($) { |
| 35 | window.Notification = (_ => { |
| 36 | var timeout; |
| 37 | |
| 38 | var display = (msg, type) => { |
| 39 | clearTimeout(timeout); |
| 40 | $('#nitropack-notification').remove(); |
| 41 | |
| 42 | $('[name="form"]').prepend('<div id="nitropack-notification" class="notice notice-' + type + '" is-dismissible"><p>' + msg + '</p></div>'); |
| 43 | |
| 44 | timeout = setTimeout(_ => { |
| 45 | $('#nitropack-notification').remove(); |
| 46 | }, 10000); |
| 47 | loadDismissibleNotices(); |
| 48 | } |
| 49 | |
| 50 | return { |
| 51 | success: msg => { |
| 52 | display(msg, 'success'); |
| 53 | }, |
| 54 | error: msg => { |
| 55 | display(msg, 'error'); |
| 56 | }, |
| 57 | info: msg => { |
| 58 | display(msg, 'info'); |
| 59 | }, |
| 60 | warning: msg => { |
| 61 | display(msg, 'warning'); |
| 62 | } |
| 63 | } |
| 64 | })(); |
| 65 | |
| 66 | const clearCacheHandler = clearCacheAction => { |
| 67 | return function(success, error) { |
| 68 | $.ajax({ |
| 69 | url: ajaxurl, |
| 70 | type: 'GET', |
| 71 | data: { |
| 72 | action: "nitropack_" + clearCacheAction + "_cache" |
| 73 | }, |
| 74 | dataType: 'json', |
| 75 | beforeSend: function() { |
| 76 | Notification.info("Loading. Please wait..."); |
| 77 | }, |
| 78 | success: function(data) { |
| 79 | Notification[data.type](data.message); |
| 80 | |
| 81 | cacheEvent = new Event("cache." + clearCacheAction + ".success"); |
| 82 | window.dispatchEvent(cacheEvent); |
| 83 | } |
| 84 | }); |
| 85 | }; |
| 86 | } |
| 87 | |
| 88 | $(window).on("load", _ => { |
| 89 | //Remove styles from jobcareer and jobhunt plugins since they break our layout. They should not be loaded on our options page anyway. |
| 90 | $('link[href*="jobcareer"').remove(); |
| 91 | $('link[href*="jobhunt"').remove(); |
| 92 | |
| 93 | $("#dashboard").addClass("show active"); |
| 94 | window.addEventListener('cache.invalidate.request', clearCacheHandler("invalidate")); |
| 95 | window.addEventListener('cache.purge.request', clearCacheHandler("purge")); |
| 96 | |
| 97 | NitroPack.QuickSetup.setChangeHandler(async function(value, success, error) { |
| 98 | success(value); |
| 99 | }); |
| 100 | }); |
| 101 | |
| 102 | $("#nitro-restore-connection-btn").on("click", function() { |
| 103 | $.ajax({ |
| 104 | url: ajaxurl, |
| 105 | type: 'GET', |
| 106 | data: { |
| 107 | action: "nitropack_reconfigure_webhooks" |
| 108 | }, |
| 109 | dataType: 'json', |
| 110 | beforeSend: function() { |
| 111 | $("#nitro-restore-connection-btn").attr("disabled", true).html("<i class='fa fa-refresh fa-spin'></i>"); |
| 112 | }, |
| 113 | success: function(data) { |
| 114 | if (!data.status || data.status != "success") { |
| 115 | if (data.message) { |
| 116 | alert("Error: " + data.message); |
| 117 | } else { |
| 118 | alert("Error: We were unable to restore the connection. Please contact our support team to get this resolved."); |
| 119 | } |
| 120 | } else { |
| 121 | $("#nitro-restore-connection-btn").attr("disabled", true).html("<i class='fa fa-check'></i>"); |
| 122 | } |
| 123 | }, |
| 124 | complete: function() { |
| 125 | location.reload(); |
| 126 | } |
| 127 | }); |
| 128 | }); |
| 129 | })(jQuery); |
| 130 | </script> |
| 131 |