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
3 years ago
safemode.tpl
4 years ago
dashboard-oneclick.php
274 lines
| 1 | <style> |
| 2 | .rml_btn { |
| 3 | float: right; |
| 4 | color: #989898 !important; |
| 5 | font-size: 13px; |
| 6 | cursor: pointer; |
| 7 | text-decoration: underline !important; |
| 8 | } |
| 9 | |
| 10 | .rml_btn:hover{ |
| 11 | color: #212529 !important; |
| 12 | /*text-decoration: underline !important;*/ |
| 13 | } |
| 14 | |
| 15 | .card { |
| 16 | box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); |
| 17 | border: none; |
| 18 | } |
| 19 | </style> |
| 20 | |
| 21 | <div> |
| 22 | <div class="row mt-0"> |
| 23 | <div class="col-md-12"> |
| 24 | <?php nitropack_display_admin_notices(); ?> |
| 25 | </div> |
| 26 | </div> |
| 27 | <?php if (count(get_nitropack()->Notifications->get('system')) > 0) { ?> |
| 28 | <div class="row mt-0"> |
| 29 | <div class="col-12 mb-3"> |
| 30 | <div class="card-overlay-blurrable np-widget" id="notifications"> |
| 31 | <div class="card card-d-item"> |
| 32 | <div class="card-body"> |
| 33 | <h5 class="card-title" style="display: inline-block;"><?php esc_html_e( 'Notifications', 'nitropack' ); ?></h5> |
| 34 | <ul class="list-group list-group-flush" id="notifications-list"> |
| 35 | <?php foreach(get_nitropack()->Notifications->get('system') as $notification) : ?> |
| 36 | <li class="list-group-item px-0 d-flex justify-content-between align-items-center"> |
| 37 | <div class="col-10"> |
| 38 | <?php echo $notification['message']; ?> |
| 39 | </div> |
| 40 | <div class="col-2"> <a class="rml_btn" data-notification_end="<?php echo $notification['end_date']; ?>" data-notification_id="<?php echo $notification['id']; ?>">Remind me later</a> </div> |
| 41 | </li> |
| 42 | <?php endforeach; ?> |
| 43 | </ul> |
| 44 | </div> |
| 45 | </div> |
| 46 | </div> |
| 47 | </div> |
| 48 | </div> |
| 49 | <?php } ?> |
| 50 | <div class="row"> |
| 51 | |
| 52 | <div class="col-md-6 mb-3"> |
| 53 | <div class="card-overlay-blurrable np-widget rounded" id="optimizations-widget"> |
| 54 | <div class="card card-d-item"> |
| 55 | <div class="card-body"> |
| 56 | <h5 class="card-title font-weight-bold" style="color: #484848; font-size: 17px"><?php esc_html_e( 'Optimized pages', 'nitropack' ); ?> |
| 57 | <span id="pending-optimizations-section" class="pull-right mt-1" style="display:none;font-size: 12px;color: #28a745"><?php esc_html_e( 'Processing', 'nitropack' ); ?> |
| 58 | <span id="pending-optimizations-count">X</span> page(s) in the background <i class="fa fa-spinner fa-spin"></i> |
| 59 | <a href="https://support.nitropack.io/hc/en-us/articles/4766337974801" target="_blank" rel="noopener noreferrer" class="pull-right"><i data-info-tooltip class="mx-2 info-tooltip fa fa-info-circle text-primary" data-toggle="tooltip" data-placement="top" title="<?php esc_html_e( 'Click to learn more', 'nitropack' ); ?>"></i></a> |
| 60 | </span> |
| 61 | |
| 62 | </h5> |
| 63 | <div class="row mt-4" data-hideable> |
| 64 | <div id="optimized-pages"><span data-optimized-pages-total>0</span></div> |
| 65 | <div id="last-cache-purge" class="text-secondary"><?php esc_html_e( 'Last cache purge:', 'nitropack' ); ?> <span data-last-cache-purge><?php esc_html_e( 'Never', 'nitropack' ); ?></span></div> |
| 66 | <div id="last-cache-purge-reason" class="text-secondary"><?php esc_html_e( 'Reason:', 'nitropack' ); ?> <span data-purge-reason><?php esc_html_e( 'Unknown', 'nitropack' ); ?></span></div> |
| 67 | </div> |
| 68 | <div class="row mt-4 optimizations-hidden" data-hideable> |
| 69 | <div class="optimizations-subcount"><span data-optimized-pages-mobile>0</span> <?php esc_html_e( 'mobile pages', 'nitropack' ); ?></div> |
| 70 | <div class="optimizations-subcount"><span data-optimized-pages-tablet>0</span> <?php esc_html_e( 'tablet pages', 'nitropack' ); ?></div> |
| 71 | <div class="optimizations-subcount"><span data-optimized-pages-desktop>0</span> <?php esc_html_e( 'desktop pages', 'nitropack' ); ?></div> |
| 72 | </div> |
| 73 | <div class="row mt-5 justify-content-center"> |
| 74 | <i id="np-purge-cache-loading"class="fa fa-refresh fa-spin" style="margin:5px;font-size:48px;display:none;"></i> |
| 75 | <i id="np-purge-cache-success" class="fa fa-check-circle" style="margin:5px;font-size:48px;display:none;"></i> |
| 76 | <i id="np-purge-cache-error" class="fa fa-times-circle" style="margin:5px;font-size:48px;display:none;"></i> |
| 77 | <button id="optimizations-purge-cache" class="btn btn-light btn-outline-secondary btn-widget-optimizations"><?php esc_html_e( 'Purge Cache', 'nitropack' ); ?></button> |
| 78 | </div> |
| 79 | </div> |
| 80 | </div> |
| 81 | </div> |
| 82 | </div> |
| 83 | |
| 84 | |
| 85 | <div class="col-md-6 mb-3" style="line-height: 0.5; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;"> |
| 86 | <div class="card-overlay-blurrable np-widget rounded"> |
| 87 | <div class="card card-d-item"> |
| 88 | <div class="card-body"> |
| 89 | <?php if (empty($oneClickVendorWidget)) { ?> |
| 90 | <div class="row mt-0"> |
| 91 | <div class="col-10"> |
| 92 | <h5 class="card-title font-weight-bold" style="color: #484848; font-size: 17px"><?php esc_html_e( 'What is NitroPack OneClick?', 'nitropack' ); ?></h5> |
| 93 | </div> |
| 94 | |
| 95 | <div class="col-2 text-right"> |
| 96 | <span style="font-size: 44px; color:#d9d9d9;"> ⓘ </span> |
| 97 | </div> |
| 98 | |
| 99 | </div> |
| 100 | <div class="row mt-4"> |
| 101 | <div class="col-9"> |
| 102 | <p clas="default-fonts" style="font-size: 16.4px; color:#484848">NitroPack OneClick is technically a one-click version of NitroPack preconfigured with essential features for immediate use. Activate is effortlessly and enjoy an instant boost in page speed. </p> |
| 103 | </div> |
| 104 | </div> |
| 105 | <div class="row"> |
| 106 | <button class="btn btn-outline-secondary btn-widget-optimizations"><?php esc_html_e( 'Learn More', 'nitropack' ); ?></button> |
| 107 | </div> |
| 108 | <?php } else { ?> |
| 109 | <?php echo $oneClickVendorWidget; ?> |
| 110 | <?php } ?> |
| 111 | </div> |
| 112 | </div> |
| 113 | </div> |
| 114 | </div> |
| 115 | </div> |
| 116 | </div> |
| 117 | <script> |
| 118 | |
| 119 | |
| 120 | ($ => { |
| 121 | var getOptimizationsTimeout = null; |
| 122 | let isClearing = false; |
| 123 | |
| 124 | $(window).on("load",function() { |
| 125 | $("#optimizations-widget").cardOverlay("loading", {message: "Loading optimizations data"}); |
| 126 | $(function () { $('[data-toggle="tooltip"]').tooltip()}); |
| 127 | getOptimizations(); |
| 128 | }); |
| 129 | |
| 130 | $(document).on('click', '[data-hideable]', function(e) { |
| 131 | e.preventDefault(); |
| 132 | |
| 133 | $('[data-hideable]').removeClass('optimizations-hidden'); |
| 134 | |
| 135 | $(this).addClass('optimizations-hidden'); |
| 136 | }); |
| 137 | |
| 138 | $(document).on('click', '#optimizations-invalidate-cache', function(e) { |
| 139 | e.preventDefault(); |
| 140 | //Overlay.loading("Invalidating cache..."); |
| 141 | |
| 142 | invalidateEvent = new Event("cache.invalidate.request"); |
| 143 | window.dispatchEvent(invalidateEvent); |
| 144 | }); |
| 145 | |
| 146 | $(document).on('click', '#optimizations-purge-cache', function(e) { |
| 147 | e.preventDefault(); |
| 148 | //Overlay.loading("Purging cache..."); |
| 149 | purgeCache(); |
| 150 | }); |
| 151 | |
| 152 | let purgeCache = () => { |
| 153 | let purgeEvent = new Event("cache.purge.request"); |
| 154 | window.dispatchEvent(purgeEvent); |
| 155 | } |
| 156 | |
| 157 | $(document).on('click', '[nitropack-rc-data]', function(e) { |
| 158 | e.preventDefault(); |
| 159 | if (isClearing) return; |
| 160 | let currentButton = $(this); |
| 161 | $.ajax({ |
| 162 | url: ajaxurl, |
| 163 | type: "POST", |
| 164 | dataType: "text", |
| 165 | data: { |
| 166 | action: 'nitropack_clear_residual_cache', |
| 167 | gde: currentButton.attr('nitropack-rc-data') |
| 168 | }, |
| 169 | beforeSend: function () { |
| 170 | currentButton.parent(".alert-warning").hide(); |
| 171 | isClearing = true; |
| 172 | }, |
| 173 | success: function(resp) { |
| 174 | result = JSON.parse(resp); |
| 175 | Notification[result.type](result.message); |
| 176 | }, |
| 177 | error: function(resp) { |
| 178 | result = JSON.parse(resp); |
| 179 | Notification[result.type](result.message); |
| 180 | }, |
| 181 | complete: function() { |
| 182 | isClearing = false; |
| 183 | setTimeout(function(){location.reload();}, 3000); |
| 184 | } |
| 185 | }); |
| 186 | }); |
| 187 | |
| 188 | var getOptimizations = _ => { |
| 189 | var url = '<?php echo $optimizationDetailsUrl; ?>'; |
| 190 | ((s, e, f) => { |
| 191 | if (window.fetch) { |
| 192 | fetch(url) |
| 193 | .then(resp => resp.json()) |
| 194 | .then(s) |
| 195 | .catch(e) |
| 196 | .finally(f); |
| 197 | } else { |
| 198 | $.ajax({ |
| 199 | url: url, |
| 200 | type: 'GET', |
| 201 | dataType: 'json', |
| 202 | success: s, |
| 203 | error: e, |
| 204 | complete: f |
| 205 | }) |
| 206 | } |
| 207 | })(data => { |
| 208 | $('[data-last-cache-purge]').text(data.last_cache_purge.timeAgo); |
| 209 | if (data.last_cache_purge.reason) { |
| 210 | $('[data-purge-reason]').text(data.last_cache_purge.reason); |
| 211 | $('#last-cache-purge-reason').show(); |
| 212 | } else { |
| 213 | $('#last-cache-purge-reason').hide(); |
| 214 | } |
| 215 | |
| 216 | if (data.pending_count) { |
| 217 | $("#pending-optimizations-count").text(data.pending_count); |
| 218 | $("#pending-optimizations-section").show(); |
| 219 | } else { |
| 220 | $("#pending-optimizations-section").hide(); |
| 221 | } |
| 222 | |
| 223 | $('[data-optimized-pages-desktop]').text(data.optimized_pages.desktop); |
| 224 | $('[data-optimized-pages-mobile]').text(data.optimized_pages.mobile); |
| 225 | $('[data-optimized-pages-tablet]').text(data.optimized_pages.tablet); |
| 226 | $('[data-optimized-pages-total]').text(data.optimized_pages.total); |
| 227 | |
| 228 | $("#optimizations-widget").cardOverlay("clear"); |
| 229 | }, __ => { |
| 230 | $("#optimizations-widget").cardOverlay("error", {message: "<?php esc_html_e( 'Error while fetching optimizations data', 'nitropack' ); ?>"}); |
| 231 | }, __ => { |
| 232 | if (!getOptimizationsTimeout) { |
| 233 | getOptimizationsTimeout = setTimeout(function() {getOptimizationsTimeout = null; getOptimizations();}, 60000); |
| 234 | } |
| 235 | }); |
| 236 | } |
| 237 | |
| 238 | var loadSafemodeStatus = function() { |
| 239 | $.ajax({ |
| 240 | url: ajaxurl, |
| 241 | type: "POST", |
| 242 | data: { |
| 243 | action: "nitropack_safemode_status" |
| 244 | }, |
| 245 | dataType: "json", |
| 246 | success: function(resp) { |
| 247 | if (resp.type == "success") { |
| 248 | $("#nitropack-smenabled-notice").length && !!resp.isEnabled ? $("#nitropack-smenabled-notice").parent().show() : $("#nitropack-smenabled-notice").parent().hide(); |
| 249 | } else { |
| 250 | setTimeout(loadSafemodeStatus, 500); |
| 251 | } |
| 252 | } |
| 253 | }); |
| 254 | } |
| 255 | loadSafemodeStatus(); |
| 256 | |
| 257 | window.addEventListener("cache.invalidate.success", getOptimizations); |
| 258 | if ($('#np-onstate-cache-purge').length) { |
| 259 | window.addEventListener("cache.purge.success", function(){setTimeout(function(){document.cookie = "nitropack_apwarning=1; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=<?php echo nitropack_cookiepath(); ?>"; window.location.reload()}, 1500)}); |
| 260 | } else { |
| 261 | window.addEventListener("cache.purge.success", getOptimizations); |
| 262 | } |
| 263 | |
| 264 | window.closeModalOverlay = function() { |
| 265 | $("#settings-widget").cardOverlay("clear"); |
| 266 | } |
| 267 | |
| 268 | window.performCachePurge = () => { |
| 269 | purgeCache(); |
| 270 | closeModalOverlay(); |
| 271 | } |
| 272 | })(jQuery); |
| 273 | </script> |
| 274 |