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