PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.19.3
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.19.3
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 / AutoPurge.php
nitropack / classes / WordPress / Settings Last commit date
AutoPurge.php 4 months ago BeaverBuilder.php 4 months ago CPTOptimization.php 4 months ago CacheWarmup.php 3 months ago CartCache.php 4 months ago Components.php 4 months ago EditorClearCache.php 4 months ago GeneratePreview.php 7 months ago HTMLCompression.php 3 months ago Logger.php 4 months ago OptimizationLevel.php 3 months ago Optimizations.php 4 months ago PurgeCache.php 4 months ago Shortcodes.php 4 months ago StockRefresh.php 4 months ago Subscription.php 4 months ago SystemReport.php 4 months ago TestMode.php 4 months ago
AutoPurge.php
56 lines
1 <?php
2
3 namespace NitroPack\WordPress\Settings;
4 use Nitropack\WordPress\NitroPack;
5
6 /**
7 * Auto Purge NitroPack cache on post/page save
8 */
9 class AutoPurge {
10 /** @var string */
11 public $option_name;
12 public function __construct() {
13 add_action( 'wp_ajax_nitropack_set_auto_cache_purge_ajax', [ $this, 'nitropack_set_auto_cache_purge_ajax' ] );
14 $this->option_name = 'nitropack-autoCachePurge';
15 }
16
17 /**
18 * AJAX handler when toggling the setting in the Dashboard
19 * @return void
20 */
21 public function nitropack_set_auto_cache_purge_ajax() {
22 nitropack_verify_ajax_nonce( $_REQUEST );
23 $option = (int) ! empty( $_POST["autoCachePurgeStatus"] );
24 $updated = update_option( $this->option_name, $option );
25 if ( $updated ) {
26 NitroPack::getInstance()->getLogger()->notice( 'Auto cache purge is ' . ( $option === 1 ? 'enabled' : 'disabled' ) );
27 nitropack_json_and_exit( [ "type" => "success", "message" => nitropack_admin_toast_msgs( 'success' ), 'autoCachePurgeStatus' => $option ] );
28 } else {
29 NitroPack::getInstance()->getLogger()->error( 'Auto cache purge cannot be ' . ( $option === 1 ? 'enabled' : 'disabled' ) );
30 nitropack_json_and_exit( [
31 "type" => "error",
32 "message" => nitropack_admin_toast_msgs( 'error' )
33 ] );
34 }
35 }
36 /**
37 * Renders the Auto Purge option in the Dashboard
38 * @return void
39 */
40 public function render() {
41 $autoCachePurge = get_option( $this->option_name, 1 );
42 ?>
43 <div class="nitro-option" id="purge-cache-widget">
44 <div class="nitro-option-main">
45 <div class="text-box">
46 <h6><?php esc_html_e( 'Purge cache', 'nitropack' ); ?></h6>
47 <p><?php esc_html_e( 'Purge affected cache when content is updated or published', 'nitropack' ); ?>
48 </p>
49 </div>
50 <?php $components = new Components();
51 $components->render_toggle( 'auto-purge-status', $autoCachePurge ); ?>
52 </div>
53 </div>
54 <?php
55 }
56 }