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