images
3 years ago
javascript
3 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
3 years ago
help.php
3 years ago
oneclick.php
2 years ago
safemode.php
2 years ago
safemode.tpl
4 years ago
admin.php
159 lines
| 1 | <div id="nitropack-container" class="wrap"> |
| 2 | <div id="heading"> |
| 3 | <h2><?php esc_html_e( 'NitroPack.io', 'nitropack' ); ?></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"><?php esc_html_e( 'Dashboard', 'nitropack' ); ?></a></li> |
| 12 | <li><a class="nav-tab" href="#help" data-toggle="tab"><?php esc_html_e( 'Help', 'nitropack' ); ?></a></li> |
| 13 | <li><a class="nav-tab" href="#diag" data-toggle="tab"><?php esc_html_e( 'Diagnostics', 'nitropack' ); ?></a></li> |
| 14 | </ul> |
| 15 | <div class="tab-content" style="display:block"> |
| 16 | <div id="dashboard" class="tab-pane hidden"> |
| 17 | <?php require_once NITROPACK_PLUGIN_DIR . "view/dashboard.php"; ?> |
| 18 | </div> |
| 19 | <div id="help" class="tab-pane hidden"> |
| 20 | <?php require_once NITROPACK_PLUGIN_DIR . "view/help.php"; ?> |
| 21 | </div> |
| 22 | <div id="diag" class="tab-pane hidden"> |
| 23 | <?php require_once NITROPACK_PLUGIN_DIR . "view/diag.php"; ?> |
| 24 | </div> |
| 25 | </div> |
| 26 | </form> |
| 27 | </div> |
| 28 | <?php if (NITROPACK_SUPPORT_BUBBLE_VISIBLE) { ?> |
| 29 | <div class="support-widget"> |
| 30 | <!-- support widget --> |
| 31 | <script> |
| 32 | window.intercomSettings = { |
| 33 | api_base: "https://api-iam.intercom.io", |
| 34 | app_id: "d5v9p9vg" |
| 35 | }; |
| 36 | |
| 37 | (function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/d5v9p9vg';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(document.readyState==='complete'){l();}else if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})(); |
| 38 | </script> |
| 39 | <!-- end support widget --> |
| 40 | </div> |
| 41 | <?php } ?> |
| 42 | <script> |
| 43 | (function($) { |
| 44 | window.Notification = (_ => { |
| 45 | var timeout; |
| 46 | |
| 47 | var display = (msg, type) => { |
| 48 | clearTimeout(timeout); |
| 49 | $('#nitropack-notification').remove(); |
| 50 | |
| 51 | $('[name="form"]').prepend('<div id="nitropack-notification" class="notice notice-' + type + '" is-dismissible"><p>' + msg + '</p></div>'); |
| 52 | |
| 53 | timeout = setTimeout(_ => { |
| 54 | $('#nitropack-notification').remove(); |
| 55 | }, 10000); |
| 56 | loadDismissibleNotices(); |
| 57 | } |
| 58 | |
| 59 | return { |
| 60 | success: msg => { |
| 61 | display(msg, 'success'); |
| 62 | }, |
| 63 | error: msg => { |
| 64 | display(msg, 'error'); |
| 65 | }, |
| 66 | info: msg => { |
| 67 | display(msg, 'info'); |
| 68 | }, |
| 69 | warning: msg => { |
| 70 | display(msg, 'warning'); |
| 71 | } |
| 72 | } |
| 73 | })(); |
| 74 | |
| 75 | const clearCacheHandler = clearCacheAction => { |
| 76 | return function(success, error) { |
| 77 | $.ajax({ |
| 78 | url: ajaxurl, |
| 79 | type: 'GET', |
| 80 | data: { |
| 81 | action: "nitropack_" + clearCacheAction + "_cache" |
| 82 | }, |
| 83 | dataType: 'json', |
| 84 | beforeSend: function() { |
| 85 | Notification.info("Loading. Please wait..."); |
| 86 | $('#optimizations-purge-cache').hide(); |
| 87 | $('#np-purge-cache-loading').show(); |
| 88 | }, |
| 89 | success: function(data) { |
| 90 | $('#np-purge-cache-loading').hide(); |
| 91 | if (data.type === 'success') { |
| 92 | $('#np-purge-cache-success').show(); |
| 93 | Notification[data.type](data.message); |
| 94 | cacheEvent = new Event("cache." + clearCacheAction + ".success"); |
| 95 | } else { |
| 96 | $('#np-purge-cache-error').show(); |
| 97 | Notification[data.type](data.message); |
| 98 | cacheEvent = new Event("cache." + clearCacheAction + ".error"); |
| 99 | } |
| 100 | window.dispatchEvent(cacheEvent); |
| 101 | }, |
| 102 | error: function(data) { |
| 103 | $('#np-purge-cache-loading').hide(); |
| 104 | $('#np-purge-cache-error').show(); |
| 105 | Notification[data.type](data.message); |
| 106 | cacheEvent = new Event("cache." + clearCacheAction + ".error"); |
| 107 | window.dispatchEvent(cacheEvent); |
| 108 | }, |
| 109 | complete: function() { |
| 110 | setTimeout(function(){$('#np-purge-cache-success').hide();$('#np-purge-cache-error').hide();$('#optimizations-purge-cache').show();}, 3000); |
| 111 | } |
| 112 | }); |
| 113 | }; |
| 114 | } |
| 115 | |
| 116 | $(window).on("load", _ => { |
| 117 | //Remove styles from jobcareer and jobhunt plugins since they break our layout. They should not be loaded on our options page anyway. |
| 118 | $('link[href*="jobcareer"').remove(); |
| 119 | $('link[href*="jobhunt"').remove(); |
| 120 | |
| 121 | $("#dashboard").addClass("show active"); |
| 122 | window.addEventListener('cache.invalidate.request', clearCacheHandler("invalidate")); |
| 123 | window.addEventListener('cache.purge.request', clearCacheHandler("purge")); |
| 124 | |
| 125 | NitroPack.QuickSetup.setChangeHandler(async function(value, success, error) { |
| 126 | success(value); |
| 127 | }); |
| 128 | }); |
| 129 | |
| 130 | $("#nitro-restore-connection-btn").on("click", function() { |
| 131 | $.ajax({ |
| 132 | url: ajaxurl, |
| 133 | type: 'GET', |
| 134 | data: { |
| 135 | action: "nitropack_reconfigure_webhooks" |
| 136 | }, |
| 137 | dataType: 'json', |
| 138 | beforeSend: function() { |
| 139 | $("#nitro-restore-connection-btn").attr("disabled", true).html("<i class='fa fa-refresh fa-spin'></i>"); |
| 140 | }, |
| 141 | success: function(data) { |
| 142 | if (!data.status || data.status != "success") { |
| 143 | if (data.message) { |
| 144 | alert("<?php esc_html_e( 'Error:', 'nitropack' ); ?> " + data.message); |
| 145 | } else { |
| 146 | alert("<?php esc_html_e( 'Error: We were unable to restore the connection. Please contact our support team to get this resolved.', 'nitropack' ); ?>"); |
| 147 | } |
| 148 | } else { |
| 149 | $("#nitro-restore-connection-btn").attr("disabled", true).html("<i class='fa fa-check'></i>"); |
| 150 | } |
| 151 | }, |
| 152 | complete: function() { |
| 153 | location.reload(); |
| 154 | } |
| 155 | }); |
| 156 | }); |
| 157 | })(jQuery); |
| 158 | </script> |
| 159 |