PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.18.6
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.18.6
1.19.8 1.19.7 1.19.6 1.19.5 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.11.0 1.12.0 1.13.0 1.14.0 1.15.0 1.15.1 1.15.2 1.15.3 1.16.0 1.16.1 1.16.2 1.16.3 1.16.4 1.16.5 1.16.6 1.16.7 1.16.8 1.17.0 1.17.6 1.17.7 1.17.8 1.17.9 1.18.0 1.18.1 1.18.2 1.18.3 1.18.4 1.18.5 1.18.6 1.18.7 1.18.8 1.18.9 1.19.0 1.19.1 1.19.2 1.19.3 1.19.4 1.3.19 1.3.20 1.4.0 1.4.1 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.16 1.5.17 1.5.18 1.5.19 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.8.1 1.8.3 1.9.0 1.9.1 1.9.2
nitropack / classes / WordPress / Settings / CacheWarmup.php
nitropack / classes / WordPress / Settings Last commit date
CacheWarmup.php 7 months ago Components.php 1 year ago GeneratePreview.php 7 months ago Logger.php 7 months ago OptimizationLevel.php 7 months ago Shortcodes.php 1 year ago TestMode.php 10 months ago
CacheWarmup.php
71 lines
1 <?php
2
3 namespace NitroPack\WordPress\Settings;
4
5 class CacheWarmup {
6 private static $instance = NULL;
7 public function __construct() {
8 add_action( 'wp_ajax_nitropack_skip_cache_warmup', array( $this, 'nitropack_skip_cache_warmup' ) );
9
10 }
11 public static function getInstance() {
12 if ( null === self::$instance ) {
13 self::$instance = new self();
14 }
15 return self::$instance;
16 }
17
18 /* Dismiss cache warmup notice in the final third step when Onboarding */
19 public function nitropack_skip_cache_warmup() {
20 nitropack_verify_ajax_nonce( $_REQUEST );
21
22 $nitropack_notices = get_option( 'nitropack-dismissed-notices', array() );
23 $nitropack_notices['skip_cache_warmup'] = 1;
24 update_option( 'nitropack-dismissed-notices', $nitropack_notices );
25
26 nitropack_json_and_exit( array(
27 "type" => "success",
28 "message" => nitropack_admin_toast_msgs( 'success', esc_html__( 'Cache warmup skipped.', 'nitropack' ) )
29 ) );
30 }
31
32 /* Render cache warmup setting widget */
33 public function render() {
34 $nitro = get_nitropack_sdk();
35 $cache_warmup_stats = $nitro->getApi()->getWarmupStats();
36 ?>
37 <div class="nitro-option" id="cache-warmup-widget">
38 <div class="nitro-option-main">
39 <div class="text-box" id="warmup-status-slider">
40
41 <?php $sitemap = get_option( 'nitropack-warmup-sitemap', false );
42 $toolTipDisplayState = $sitemap ? '' : 'hidden'; ?>
43
44 <h6><?php esc_html_e( 'Cache warmup', 'nitropack' ); ?> <span
45 class="badge badge-primary ml-2"><?php esc_html_e( 'Recommended', 'nitropack' ); ?></span>
46 <span class="tooltip-icon <?php echo $toolTipDisplayState; ?>" data-tooltip-target="tooltip-sitemap">
47 <img src="<?php echo plugin_dir_url( NITROPACK_FILE ) . 'view/images/info.svg'; ?>">
48 </span>
49 </h6>
50 <div id="tooltip-sitemap" role="tooltip" class="tooltip-container hidden">
51 <?php echo $sitemap; ?>
52 <div class="tooltip-arrow" data-popper-arrow></div>
53 </div>
54 <p><?php esc_html_e( 'Automatically pre-caches your website\'s page content', 'nitropack' ); ?>.
55 <a href="https://support.nitropack.io/en/articles/8390320-cache-warmup" class="text-blue"
56 target="_blank"><?php esc_html_e( 'Learn more', 'nitropack' ); ?></a>
57 </p>
58 </div>
59 <label class="inline-flex items-center cursor-pointer ml-auto">
60 <input id="warmup-status" type="checkbox" class="sr-only peer" <?php echo $cache_warmup_stats['status'] === 1 ? "checked" : ""; ?>>
61 <div class="toggle"></div>
62 </label>
63 </div>
64 <div class="msg-container hidden" id="loading-warmup-status">
65 <img src="<?php echo plugin_dir_url( NITROPACK_FILE ) . 'view/images/loading.svg'; ?>" alt="loading" class="icon">
66 <span class="msg"><?php esc_html_e( 'Loading cache warmup status', 'nitropack' ); ?></span>
67 </div>
68 </div>
69 <?php }
70 }
71