images
1 year ago
javascript
1 year ago
modals
1 year ago
stylesheet
1 year ago
templates
2 years ago
admin.php
1 year ago
connect-oneclick.php
1 year ago
connect.php
2 years ago
dashboard-oneclick.php
1 year ago
dashboard.php
1 year ago
oneclick.php
1 year ago
system-report.php
1 year ago
dashboard-oneclick.php
501 lines
| 1 | <?php |
| 2 | $settings = new \NitroPack\WordPress\Settings(); |
| 3 | $notifications = new \NitroPack\WordPress\Notifications\Notifications(); |
| 4 | $usage = '0 MB'; |
| 5 | $max_usage = '1 GB'; |
| 6 | $page_views = '0'; |
| 7 | $max_page_views = '10000'; ?> |
| 8 | |
| 9 | <?php $notifications->nitropack_display_admin_notices(); ?> |
| 10 | |
| 11 | <div class="grid grid-cols-2 gap-6 grid-col-1-tablet items-start nitropack-dashboard"> |
| 12 | <div class="col-span-1"> |
| 13 | <!-- Optimized Pages Card --> |
| 14 | <div class="card card-optimized-pages"> |
| 15 | <div class="card-header"> |
| 16 | <h3><?php esc_html_e( 'Optimized pages', 'nitropack' ); ?></h3> |
| 17 | <div class="flex flex-row items-center" style="display: none;" id="pending-optimizations-section"> |
| 18 | <img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/loading.svg'; ?>" alt="loading" class="w-4 h-4"> |
| 19 | <span class="ml-2 mr-1 text-primary"> <?php esc_html_e( 'Processing', 'nitropack' ); ?> |
| 20 | <span id="pending-optimizations-count">X</span> |
| 21 | <?php esc_html_e( 'page(s) in the background', 'nitropack' ); ?></span> |
| 22 | </div> |
| 23 | </div> |
| 24 | <div class="card-body"> |
| 25 | <div class="card-body-inner"> |
| 26 | <div class="optimized-pages"><span data-optimized-pages-total>0</span></div> |
| 27 | <div class="text-box"> |
| 28 | <div class="time-ago"><?php esc_html_e( 'Last cache purge', 'nitropack' ); ?>: <span |
| 29 | data-last-cache-purge><?php esc_html_e( 'Never', 'nitropack' ); ?></span></div> |
| 30 | <div class="reason"><?php esc_html_e( 'Reason', 'nitropack' ); ?>: <span |
| 31 | data-purge-reason><?php esc_html_e( 'Unknown', 'nitropack' ); ?></span></div> |
| 32 | </div> |
| 33 | <button id="optimizations-purge-cache" type="button" class="btn btn-secondary" |
| 34 | data-modal-target="modal-purge-cache" |
| 35 | data-modal-toggle="modal-purge-cache"><?php esc_html_e( 'Purge cache', 'nitropack' ); ?></button> |
| 36 | </div> |
| 37 | </div> |
| 38 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-purge-cache.php'; ?> |
| 39 | </div> |
| 40 | <!-- Optimized Pages Card End --> |
| 41 | <!-- Optimization Mode Card --> |
| 42 | <div class="card card-optimization-mode"> |
| 43 | <div class="card-header no-border mb-0"> |
| 44 | <div class="flex items-center"> |
| 45 | <h3 class="mb-0"><?php esc_html_e( 'Optimization mode', 'nitropack' ); ?></h3> |
| 46 | <span class="tooltip-icon" data-tooltip-target="tooltip-optimization"> |
| 47 | <img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/info.svg'; ?>"> |
| 48 | </span> |
| 49 | <div id="tooltip-optimization" role="tooltip" class="tooltip-container hidden"> |
| 50 | <?php esc_html_e( 'Select from our range of predefined optimization modes to boost your site\'s performance.', 'nitropack' ); |
| 51 | ?> |
| 52 | <div class="tooltip-arrow" data-popper-arrow></div> |
| 53 | </div> |
| 54 | </div> |
| 55 | </div> |
| 56 | <?php $modes = array( 'standard' => esc_html__( 'Standard', 'nitropack' ), 'medium' => esc_html__( 'Medium', 'nitropack' ), 'strong' => esc_html__( 'Strong', 'nitropack' ), 'ludicrous' => esc_html__( 'Ludicrous', 'nitropack' ), 'custom' => esc_html__( 'Custom', 'nitropack' ) ); ?> |
| 57 | <div class="tabs-wrapper"> |
| 58 | <div class="tabs" id="optimization-modes"> |
| 59 | <?php foreach ( $modes as $mode_id => $mode ) : |
| 60 | $disabled = ( $mode_id === 'custom' ) ? 'disabled' : ''; |
| 61 | ?> |
| 62 | <a class="btn tab-link btn-link <?php echo $disabled; ?>" data-mode="<?php echo $mode_id; ?>" |
| 63 | data-modal-target="modal-optimization-mode" data-modal-toggle="modal-optimization-mode" <?php echo $disabled; ?>><?php echo $mode; ?></a> |
| 64 | <?php endforeach; ?> |
| 65 | </div> |
| 66 | <p><?php esc_html_e( 'Active Mode', 'nitropack' ); ?>: <span class="active-mode"></span></p> |
| 67 | <div class="tab-content-wrapper"> |
| 68 | <div class="hidden tab-content" role="tabpanel" data-tab="standard-tab"> |
| 69 | <p class="text-secondary mt-2"> |
| 70 | <?php esc_html_e( 'Standard optimization features enabled for your site. Ideal choice for maximum stability.', 'nitropack' ); ?> |
| 71 | </p> |
| 72 | </div> |
| 73 | <div class="hidden tab-content" role="tabpanel" data-tab="medium-tab"> |
| 74 | <p class="text-secondary mt-2"> |
| 75 | <?php esc_html_e( 'Adds image lazy loading to standard optimizations. Uses built-in browser techniques for loading resources.', 'nitropack' ); ?> |
| 76 | </p> |
| 77 | </div> |
| 78 | <div class="hidden tab-content" role="tabpanel" data-tab="strong-tab"> |
| 79 | <p class="text-secondary mt-2"> |
| 80 | <?php esc_html_e( 'Includes smart resource loading on top of Medium optimizations. Balances speed boost with stability.', 'nitropack' ); ?> |
| 81 | </p> |
| 82 | </div> |
| 83 | <div class="hidden tab-content" role="tabpanel" data-tab="ludicrous-tab"> |
| 84 | <p class="text-secondary mt-2"> |
| 85 | <?php esc_html_e( 'Applies deferred JS and advanced resource loading for optimal performance and Core Web Vitals.', 'nitropack' ); ?> |
| 86 | </p> |
| 87 | </div> |
| 88 | <div class="hidden tab-content" role="tabpanel" data-tab="custom-tab"> |
| 89 | <p class="text-secondary mt-2"> |
| 90 | <?php esc_html_e( 'Activated when manual setups are made. Ideal for advanced NitroPack optimizations.', 'nitropack' ); ?> |
| 91 | </p> |
| 92 | </div> |
| 93 | </div> |
| 94 | </div> |
| 95 | <div class="card-footer"> |
| 96 | <div class="flex flex-row"> |
| 97 | <p class=""><?php esc_html_e( 'Which optimization mode to choose?', 'nitropack' ); ?></p> |
| 98 | <a class="text-primary btn-link ml-auto see-modes" data-modal-target="modes-modal" |
| 99 | data-modal-toggle="modes-modal"><?php esc_html_e( 'See modes comparison', 'nitropack' ); ?></a> |
| 100 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-modes.php'; ?> |
| 101 | </div> |
| 102 | </div> |
| 103 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-optimization-mode.php'; ?> |
| 104 | </div> |
| 105 | <!-- Optimization Mode Card End --> |
| 106 | <!-- Automated Behavior Card --> |
| 107 | <div class="card card-automated-behavior"> |
| 108 | <div class="card-header"> |
| 109 | <h3><?php esc_html_e( 'Automated Behavior', 'nitropack' ); ?></h3> |
| 110 | </div> |
| 111 | <div class="card-body"> |
| 112 | <div class="options-container"> |
| 113 | <div class="nitro-option" id="purge-cache-widget"> |
| 114 | <div class="nitro-option-main"> |
| 115 | <div class="text-box"> |
| 116 | <h6><?php esc_html_e( 'Purge cache', 'nitropack' ); ?></h6> |
| 117 | <p><?php esc_html_e( 'Purge affected cache when content is updated or published', 'nitropack' ); ?></p> |
| 118 | </div> |
| 119 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 120 | <input type="checkbox" value="" class="sr-only peer" name="purge_cache" id="auto-purge-status" <?php if ( $autoCachePurge ) |
| 121 | echo "checked"; ?>> |
| 122 | <div class="toggle"></div> |
| 123 | </label> |
| 124 | </div> |
| 125 | </div> |
| 126 | <div class="nitro-option" id="page-optimization-widget"> |
| 127 | <div class="nitro-option-main"> |
| 128 | <div class="text-box"> |
| 129 | <h6><?php esc_html_e( 'Page optimization', 'nitropack' ); ?></h6> |
| 130 | <p><?php esc_html_e( 'Select what post/page types get optimized', 'nitropack' ); ?></p> |
| 131 | </div> |
| 132 | <a data-modal-target="modal-posttypes" data-modal-toggle="modal-posttypes" |
| 133 | class="btn btn-secondary btn-icon"> |
| 134 | <img src="<?php echo plugin_dir_url( __FILE__ ); ?>images/setting-icon.svg"> |
| 135 | </a> |
| 136 | </div> |
| 137 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-posttypes.php'; ?> |
| 138 | </div> |
| 139 | </div> |
| 140 | </div> |
| 141 | </div> |
| 142 | <!-- Automated Behavior Card End --> |
| 143 | <!-- Go to app Card --> |
| 144 | <div class="card exclusion-card"> |
| 145 | <div class="card-header"> |
| 146 | <h3><?php esc_html_e( 'Exclusions', 'nitropack' ); ?></h3> |
| 147 | </div> |
| 148 | <div class="card-body"> |
| 149 | <div class="options-container"> |
| 150 | <div class="nitro-option" id="ajax-shortcodes-widget"> |
| 151 | <?php $settings->render_ajax_shortcodes_setting(); ?> |
| 152 | </div> |
| 153 | </div> |
| 154 | </div> |
| 155 | </div> |
| 156 | <!-- Go to app card End --> |
| 157 | |
| 158 | |
| 159 | </div> |
| 160 | <div class="col-span-1"> |
| 161 | <!-- Subscription Card End --> |
| 162 | <!-- Basic Settings Card --> |
| 163 | <div class="card card-basic-settings"> |
| 164 | <div class="card-header"> |
| 165 | <h3><?php esc_html_e( 'Basic Settings', 'nitropack' ); ?></h3> |
| 166 | </div> |
| 167 | <div class="card-body"> |
| 168 | <div class="options-container"> |
| 169 | <div class="nitro-option" id="cache-warmup-widget"> |
| 170 | <div class="nitro-option-main"> |
| 171 | <div class="text-box" id="warmup-status-slider"> |
| 172 | |
| 173 | <?php $sitemap = get_option( 'np_warmup_sitemap', false ); |
| 174 | $toolTipDisplayState = $sitemap ? '' : 'hidden'; ?> |
| 175 | |
| 176 | <h6><?php esc_html_e( 'Cache warmup', 'nitropack' ); ?> <span |
| 177 | class="badge badge-primary ml-2"><?php esc_html_e( 'Recommended', 'nitropack' ); ?></span> <span |
| 178 | class="tooltip-icon <?php echo $toolTipDisplayState; ?>" data-tooltip-target="tooltip-sitemap"> |
| 179 | <img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/info.svg'; ?>"> |
| 180 | </span></h6> |
| 181 | <div id="tooltip-sitemap" role="tooltip" class="tooltip-container hidden"> |
| 182 | <?php echo $sitemap; ?> |
| 183 | <div class="tooltip-arrow" data-popper-arrow></div> |
| 184 | </div> |
| 185 | <p><?php esc_html_e( 'Automatically pre-caches your website\'s page content', 'nitropack' ); ?>. <a |
| 186 | href="https://support.nitropack.io/en/articles/8390320-cache-warmup" class="text-blue" |
| 187 | target="_blank"><?php esc_html_e( 'Learn more', 'nitropack' ); ?></a></p> |
| 188 | </div> |
| 189 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 190 | <input id="warmup-status" type="checkbox" class="sr-only peer"> |
| 191 | <div class="toggle"></div> |
| 192 | </label> |
| 193 | </div> |
| 194 | <div class="msg-container" id="loading-warmup-status"> |
| 195 | <img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/loading.svg'; ?>" alt="loading" class="icon"> |
| 196 | <span class="msg"><?php esc_html_e( 'Loading cache warmup status', 'nitropack' ); ?></span> |
| 197 | </div> |
| 198 | </div> |
| 199 | <div class="nitro-option" id="test-mode-widget"> |
| 200 | <div class="nitro-option-main"> |
| 201 | <div class="text-box" id="safemode-status-slider"> |
| 202 | <h6><?php esc_html_e( 'Test Mode', 'nitropack' ); ?></h6> |
| 203 | <p> |
| 204 | <?php esc_html_e( 'Test NitroPack\'s features without affecting your visitors\' experience', 'nitropack' ); ?>. |
| 205 | <a href="https://support.nitropack.io/en/articles/8390292-test-mode" class="text-blue" |
| 206 | target="_blank"><?php esc_html_e( 'Learn more', 'nitropack' ); ?></a></p> |
| 207 | </div> |
| 208 | |
| 209 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 210 | <input type="checkbox" class="sr-only peer" id="safemode-status"> |
| 211 | |
| 212 | <div class="toggle"></div> |
| 213 | </label> |
| 214 | </div> |
| 215 | <div class="msg-container" id="loading-safemode-status"> |
| 216 | <img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/loading.svg'; ?>" alt="loading" class="icon"> |
| 217 | <?php esc_html_e( 'Loading test mode status', 'nitropack' ); ?> |
| 218 | </div> |
| 219 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-test-mode.php'; ?> |
| 220 | </div> |
| 221 | <div class="nitro-option" id="compression-widget"> |
| 222 | <div class="nitro-option-main"> |
| 223 | <div class="text-box"> |
| 224 | <h6><span id="detected-compression"><?php esc_html_e( 'HTML Compression', 'nitropack' ); ?> </span></h6> |
| 225 | <p> |
| 226 | <?php esc_html_e( 'Compressing the structure of your HTML, ensures faster page rendering and an optimized browsing experience for your users.', 'nitropack' ); ?> |
| 227 | <a href="https://support.nitropack.io/en/articles/8390333-nitropack-plugin-settings-in-wordpress#h_29b7ab4836" |
| 228 | class="text-blue" target="_blank"><?php esc_html_e( 'Learn more', 'nitropack' ); ?></a></p> |
| 229 | </div> |
| 230 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 231 | <input type="checkbox" id="compression-status" class="sr-only peer" <?php echo (int) $enableCompression === 1 ? "checked" : ""; ?>> |
| 232 | <div class="toggle"></div> |
| 233 | </label> |
| 234 | </div> |
| 235 | <div class="mt-4 text-primary"> |
| 236 | <a href="javascript:void(0);" id="compression-test-btn" |
| 237 | class="text-primary"><?php esc_html_e( 'Run compression test', 'nitropack' ); ?></a> |
| 238 | <div class="flex items-start msg-container hidden"> |
| 239 | <span class="msg"></span> |
| 240 | </div> |
| 241 | </div> |
| 242 | </div> |
| 243 | <?php if ( \NitroPack\Integration\Plugin\BeaverBuilder::isActive() ) { ?> |
| 244 | <div class="nitro-option" id="beaver-builder-widget"> |
| 245 | <div class="nitro-option-main"> |
| 246 | <div class="text-box"> |
| 247 | <h6><span |
| 248 | id="detected-compression"><?php esc_html_e( 'Sync NitroPack Purge with Beaver Builder', 'nitropack' ); ?> |
| 249 | </span></h6> |
| 250 | <p> |
| 251 | <?php esc_html_e( 'When Beaver Builder cache is purged, NitroPack will perform a full cache purge keeping your site\'s content up-to-date.', 'nitropack' ); ?> |
| 252 | </p> |
| 253 | </div> |
| 254 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 255 | <input type="checkbox" class="sr-only peer" id="bb-purge-status" <?php if ( $bbCacheSyncPurge ) |
| 256 | echo "checked"; ?>> |
| 257 | <div class="toggle"></div> |
| 258 | </label> |
| 259 | </div> |
| 260 | </div> |
| 261 | <?php } ?> |
| 262 | <div class="nitro-option" id="can-editor-clear-cache-widget"> |
| 263 | <div class="nitro-option-main"> |
| 264 | <div class="text-box"> |
| 265 | <h6><?php esc_html_e( 'Allow Editors to purge cache', 'nitropack' ); ?> <span |
| 266 | class="badge badge-success ml-2">New</span></h6> |
| 267 | <p><?php esc_html_e( 'Give Editors the right to purge cache when content is updated.', 'nitropack' ); ?> |
| 268 | </p> |
| 269 | </div> |
| 270 | <label class="inline-flex items-center cursor-pointer ml-auto"> |
| 271 | <input type="checkbox" id="can-editor-clear-cache" class="sr-only peer" <?php echo (int) $canEditorClearCache === 1 ? "checked" : ""; ?>> |
| 272 | <div class="toggle"></div> |
| 273 | </label> |
| 274 | </div> |
| 275 | </div> |
| 276 | </div> |
| 277 | </div> |
| 278 | </div> |
| 279 | </div> |
| 280 | <?php $notOptimizedCPTs = nitropack_filter_non_optimized(); |
| 281 | if ( ! get_option( 'nitropack-noticeOptimizeCPT' ) && ! empty( $notOptimizedCPTs ) ) |
| 282 | require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-not-optimized-CPT.php'; ?> |
| 283 | </div> |
| 284 | <?php require_once NITROPACK_PLUGIN_DIR . 'view/modals/modal-unsaved-changes.php'; ?> |
| 285 | <script> |
| 286 | ($ => { |
| 287 | var getOptimizationsTimeout = null; |
| 288 | let isClearing = false; |
| 289 | var paid_plan = false; |
| 290 | $(window).on("load", function () { |
| 291 | getOptimizations(); |
| 292 | getPlan(); |
| 293 | <?php if ( $checkedCompression != 1 ) { ?> |
| 294 | autoDetectCompression(); |
| 295 | <?php } ?> |
| 296 | }); |
| 297 | |
| 298 | /* Cache Purge begin */ |
| 299 | window.performCachePurge = () => { |
| 300 | purgeCache(); |
| 301 | } |
| 302 | |
| 303 | let purgeCache = () => { |
| 304 | let purgeEvent = new Event("cache.purge.request"); |
| 305 | window.dispatchEvent(purgeEvent); |
| 306 | } |
| 307 | |
| 308 | var getOptimizations = _ => { |
| 309 | var url = '<?php echo $optimizationDetailsUrl; ?>'; |
| 310 | ((s, e, f) => { |
| 311 | if (window.fetch) { |
| 312 | fetch(url) |
| 313 | .then(resp => resp.json()) |
| 314 | .then(s) |
| 315 | .catch(e) |
| 316 | .finally(f); |
| 317 | } else { |
| 318 | $.ajax({ |
| 319 | url: url, |
| 320 | type: 'GET', |
| 321 | dataType: 'json', |
| 322 | success: s, |
| 323 | error: e, |
| 324 | complete: f |
| 325 | }) |
| 326 | } |
| 327 | })(data => { |
| 328 | $('[data-last-cache-purge]').text(data.last_cache_purge.timeAgo); |
| 329 | if (data.last_cache_purge.reason) { |
| 330 | $('[data-purge-reason]').text(data.last_cache_purge.reason); |
| 331 | $('[data-purge-reason]').attr('title', data.last_cache_purge.reason); |
| 332 | $('#last-cache-purge-reason').show(); |
| 333 | } else { |
| 334 | $('#last-cache-purge-reason').hide(); |
| 335 | } |
| 336 | if (data.pending_count) { |
| 337 | $("#pending-optimizations-count").text(data.pending_count); |
| 338 | $("#pending-optimizations-section").show(); |
| 339 | } else { |
| 340 | $("#pending-optimizations-section").hide(); |
| 341 | } |
| 342 | |
| 343 | $('[data-optimized-pages-total]').text(data.optimized_pages.total); |
| 344 | |
| 345 | }, __ => { |
| 346 | console.error("An error occurred while fetching data for optimized pages"); |
| 347 | }, __ => { |
| 348 | if (!getOptimizationsTimeout) { |
| 349 | getOptimizationsTimeout = setTimeout(function () { |
| 350 | getOptimizationsTimeout = null; |
| 351 | getOptimizations(); |
| 352 | }, 60000); |
| 353 | } |
| 354 | }); |
| 355 | } |
| 356 | |
| 357 | var getPlan = _ => { |
| 358 | |
| 359 | var url = '<?php echo $planDetailsUrl; ?>'; |
| 360 | ((s, e, f) => { |
| 361 | if (window.fetch) { |
| 362 | fetch(url) |
| 363 | .then(resp => resp.json()) |
| 364 | .then(s) |
| 365 | .catch(e) |
| 366 | .finally(f); |
| 367 | } else { |
| 368 | $.ajax({ |
| 369 | url: url, |
| 370 | type: 'GET', |
| 371 | dataType: 'json', |
| 372 | success: s, |
| 373 | error: e, |
| 374 | complete: f |
| 375 | }) |
| 376 | } |
| 377 | })(data => { |
| 378 | |
| 379 | $('.plan-name').text(data.plan_title); |
| 380 | $('[data-next-billing]').text(data.next_billing ? data.next_billing : 'N/A'); |
| 381 | $('[data-next-reset]').text(data.next_reset ? data.next_reset : 'N/A'); |
| 382 | $('[data-page-views]').text(data.page_views ? data.page_views : 'N/A'); |
| 383 | $('[data-cdn-bandwidth]').text(data.cdn_bandwidth ? data.cdn_bandwidth + ' out of ' + data.max_cdn_bandwidth : 'N/A'); |
| 384 | |
| 385 | for (prop in data) { |
| 386 | if (prop.indexOf("show_") === 0) continue; |
| 387 | if (prop.indexOf("label_") === 0) continue; |
| 388 | if (prop.indexOf("max_") === 0) continue; |
| 389 | if ( |
| 390 | typeof data["show_" + prop] != "undefined" && |
| 391 | data["show_" + prop] && |
| 392 | typeof data["label_" + prop] != "undefined" && |
| 393 | typeof data["max_" + prop] != "undefined" |
| 394 | ) { |
| 395 | let propertyLabel = data["label_" + prop]; |
| 396 | let propertyValue = data[prop]; |
| 397 | let propertyLimit = data["max_" + prop]; |
| 398 | $("#plan-quotas").append('<li class="list-group-item px-0 d-flex justify-content-between align-items-center">' + propertyLabel + ' <span><span data-optimizations>' + propertyValue + '</span> out of <span data-max-optimizations>' + propertyLimit + '</span></span></li>'); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | }, __ => { |
| 403 | NitropackUI.triggerToast('error', '<?php esc_html_e( 'Error while fetching plan data', 'nitropack' ); ?>'); |
| 404 | }, __ => { }); |
| 405 | } |
| 406 | |
| 407 | |
| 408 | $(document).on('click', "#compression-test-btn", e => { |
| 409 | e.preventDefault(); |
| 410 | autoDetectCompression(); |
| 411 | }); |
| 412 | /* Compression end */ |
| 413 | |
| 414 | /* HTML Compression begin */ |
| 415 | var autoDetectCompression = function () { |
| 416 | let msg_container = $('#compression-widget .msg-container'), |
| 417 | msg_icon = msg_container.find('.icon'), |
| 418 | msg_box = msg_container.find('.msg'), |
| 419 | compression_setting = $('#compression-status'), |
| 420 | compression_btn = $('#compression-test-btn'); |
| 421 | //add spinner here |
| 422 | msg_box.html('<img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/loading.svg'; ?>" alt="loading" class="icon"> <?php esc_html_e( 'Testing current compression status', 'nitropack' ); ?>'); |
| 423 | compression_btn.addClass('hidden'); |
| 424 | msg_container.removeClass('hidden'); |
| 425 | $.post(ajaxurl, { |
| 426 | action: 'nitropack_test_compression_ajax', |
| 427 | nonce: nitroNonce |
| 428 | }, function (response) { |
| 429 | var resp = JSON.parse(response); |
| 430 | |
| 431 | if (resp.status == "success") { |
| 432 | if (resp.hasCompression) { // compression already enabled |
| 433 | compression_setting.attr("checked", false); |
| 434 | |
| 435 | msg_box.text('<?php esc_html_e( 'Compression is already enabled on your server! There is no need to enable it in NitroPack.', 'nitropack' ); ?>') |
| 436 | } else { |
| 437 | compression_setting.attr("checked", true); |
| 438 | msg_box.text('<?php esc_html_e( 'No compression was detected! We will now enable it in NitroPack.', 'nitropack' ); ?>'); |
| 439 | } |
| 440 | NitropackUI.triggerToast(resp.type, resp.message); |
| 441 | } else { |
| 442 | msg_box.text('<?php esc_html_e( 'Could not determine compression status automatically. Please configure it manually.', 'nitropack' ); ?>'); |
| 443 | } |
| 444 | setTimeout(function () { |
| 445 | msg_container.addClass('hidden'); |
| 446 | compression_btn.removeClass('hidden'); |
| 447 | }, 5000); |
| 448 | }); |
| 449 | } |
| 450 | |
| 451 | |
| 452 | $("#compression-status").on("click", function (e) { |
| 453 | $.post(ajaxurl, { |
| 454 | action: 'nitropack_set_compression_ajax', |
| 455 | nonce: nitroNonce, |
| 456 | data: { |
| 457 | compressionStatus: $(this).is(":checked") ? 1 : 0 |
| 458 | } |
| 459 | }, function (response) { |
| 460 | var resp = JSON.parse(response); |
| 461 | NitropackUI.triggerToast(resp.type, resp.message); |
| 462 | }); |
| 463 | }); |
| 464 | $("#can-editor-clear-cache").on("click", function (e) { |
| 465 | $.post(ajaxurl, { |
| 466 | action: 'nitropack_set_can_editor_clear_cache', |
| 467 | nonce: nitroNonce, |
| 468 | data: { |
| 469 | canEditorClearCache: $(this).is(":checked") ? 1 : 0 |
| 470 | } |
| 471 | }, function (response) { |
| 472 | var resp = JSON.parse(response); |
| 473 | NitropackUI.triggerToast(resp.type, resp.message); |
| 474 | }); |
| 475 | }); |
| 476 | |
| 477 | $("#auto-purge-status").on("click", function (e) { |
| 478 | $.post(ajaxurl, { |
| 479 | action: 'nitropack_set_auto_cache_purge_ajax', |
| 480 | nonce: nitroNonce, |
| 481 | autoCachePurgeStatus: $(this).is(":checked") ? 1 : 0 |
| 482 | }, function (response) { |
| 483 | var resp = JSON.parse(response); |
| 484 | NitropackUI.triggerToast(resp.type, resp.message); |
| 485 | }); |
| 486 | }); |
| 487 | |
| 488 | $("#bb-purge-status").on("click", function (e) { |
| 489 | $.post(ajaxurl, { |
| 490 | action: 'nitropack_set_bb_cache_purge_sync_ajax', |
| 491 | nonce: nitroNonce, |
| 492 | bbCachePurgeSyncStatus: $(this).is(":checked") ? 1 : 0 |
| 493 | }, function (response) { |
| 494 | var resp = JSON.parse(response); |
| 495 | NitropackUI.triggerToast(resp.type, resp.message); |
| 496 | }); |
| 497 | }); |
| 498 | |
| 499 | |
| 500 | })(jQuery); |
| 501 | </script> |