images
2 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
oneclick.php
135 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" class="mt-4"> |
| 6 | <h5 class="font-weight-bold default-fonts npoc-title"><?php esc_html_e( 'NitroPack OneClick™', 'nitropack' ); ?></h5> |
| 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 | <div class="tab-content" style="display:block"> |
| 13 | <div id="dashboard" class="tab-pane hidden"> |
| 14 | <?php require_once NITROPACK_PLUGIN_DIR . "view/dashboard-oneclick.php"; ?> |
| 15 | </div> |
| 16 | </div> |
| 17 | </form> |
| 18 | </div> |
| 19 | <script> |
| 20 | (function($) { |
| 21 | window.Notification = (_ => { |
| 22 | var timeout; |
| 23 | |
| 24 | var display = (msg, type) => { |
| 25 | clearTimeout(timeout); |
| 26 | $('#nitropack-notification').remove(); |
| 27 | |
| 28 | $('[name="form"]').prepend('<div id="nitropack-notification" class="notice notice-' + type + '" is-dismissible"><p>' + msg + '</p></div>'); |
| 29 | |
| 30 | timeout = setTimeout(_ => { |
| 31 | $('#nitropack-notification').remove(); |
| 32 | }, 10000); |
| 33 | loadDismissibleNotices(); |
| 34 | } |
| 35 | |
| 36 | return { |
| 37 | success: msg => { |
| 38 | display(msg, 'success'); |
| 39 | }, |
| 40 | error: msg => { |
| 41 | display(msg, 'error'); |
| 42 | }, |
| 43 | info: msg => { |
| 44 | display(msg, 'info'); |
| 45 | }, |
| 46 | warning: msg => { |
| 47 | display(msg, 'warning'); |
| 48 | } |
| 49 | } |
| 50 | })(); |
| 51 | |
| 52 | const clearCacheHandler = clearCacheAction => { |
| 53 | return function(success, error) { |
| 54 | $.ajax({ |
| 55 | url: ajaxurl, |
| 56 | type: 'GET', |
| 57 | data: { |
| 58 | action: "nitropack_" + clearCacheAction + "_cache", |
| 59 | nonce: nitroNonce |
| 60 | }, |
| 61 | dataType: 'json', |
| 62 | beforeSend: function() { |
| 63 | Notification.info("Loading. Please wait..."); |
| 64 | $('#optimizations-purge-cache').hide(); |
| 65 | $('#np-purge-cache-loading').show(); |
| 66 | }, |
| 67 | success: function(data) { |
| 68 | $('#np-purge-cache-loading').hide(); |
| 69 | if (data.type === 'success') { |
| 70 | $('#np-purge-cache-success').show(); |
| 71 | Notification[data.type](data.message); |
| 72 | cacheEvent = new Event("cache." + clearCacheAction + ".success"); |
| 73 | } else { |
| 74 | $('#np-purge-cache-error').show(); |
| 75 | Notification[data.type](data.message); |
| 76 | cacheEvent = new Event("cache." + clearCacheAction + ".error"); |
| 77 | } |
| 78 | window.dispatchEvent(cacheEvent); |
| 79 | }, |
| 80 | error: function(data) { |
| 81 | $('#np-purge-cache-loading').hide(); |
| 82 | $('#np-purge-cache-error').show(); |
| 83 | Notification[data.type](data.message); |
| 84 | cacheEvent = new Event("cache." + clearCacheAction + ".error"); |
| 85 | window.dispatchEvent(cacheEvent); |
| 86 | }, |
| 87 | complete: function() { |
| 88 | setTimeout(function(){$('#np-purge-cache-success').hide();$('#np-purge-cache-error').hide();$('#optimizations-purge-cache').show();}, 3000); |
| 89 | } |
| 90 | }); |
| 91 | }; |
| 92 | } |
| 93 | |
| 94 | $(window).on("load", _ => { |
| 95 | //Remove styles from jobcareer and jobhunt plugins since they break our layout. They should not be loaded on our options page anyway. |
| 96 | $('link[href*="jobcareer"').remove(); |
| 97 | $('link[href*="jobhunt"').remove(); |
| 98 | |
| 99 | $("#dashboard").addClass("show active"); |
| 100 | window.addEventListener('cache.invalidate.request', clearCacheHandler("invalidate")); |
| 101 | window.addEventListener('cache.purge.request', clearCacheHandler("purge")); |
| 102 | |
| 103 | }); |
| 104 | |
| 105 | $("#nitro-restore-connection-btn").on("click", function() { |
| 106 | $.ajax({ |
| 107 | url: ajaxurl, |
| 108 | type: 'GET', |
| 109 | data: { |
| 110 | action: "nitropack_reconfigure_webhooks", |
| 111 | nonce: nitroNonce |
| 112 | }, |
| 113 | dataType: 'json', |
| 114 | beforeSend: function() { |
| 115 | $("#nitro-restore-connection-btn").attr("disabled", true).html("<i class='fa fa-refresh fa-spin'></i>"); |
| 116 | }, |
| 117 | success: function(data) { |
| 118 | if (!data.status || data.status != "success") { |
| 119 | if (data.message) { |
| 120 | alert("<?php esc_html_e( 'Error:', 'nitropack' ); ?> " + data.message); |
| 121 | } else { |
| 122 | alert("<?php esc_html_e( 'Error: We were unable to restore the connection. Please contact our support team to get this resolved.', 'nitropack' ); ?>"); |
| 123 | } |
| 124 | } else { |
| 125 | $("#nitro-restore-connection-btn").attr("disabled", true).html("<i class='fa fa-check'></i>"); |
| 126 | } |
| 127 | }, |
| 128 | complete: function() { |
| 129 | location.reload(); |
| 130 | } |
| 131 | }); |
| 132 | }); |
| 133 | })(jQuery); |
| 134 | </script> |
| 135 |