| @@ -31,8 +31,10 @@ | ||
| 31 | 31 | |
| 32 | 32 | if ( is_admin() ) { |
| 33 | 33 | add_action( 'elementor/admin/after_create_settings/' . Settings::PAGE_ID, [ $this, 'register_admin_fields' ], 100 ); |
| 34 | 34 | } |
| 35 | + | |
| 36 | + $this->clear_cache_on_site_changed(); | |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | 39 | public function get_unique_id() { |
| 38 | 40 | $unique_id = get_option( static::OPTION_UNIQUE_ID ); |
| @@ -139,6 +141,19 @@ | ||
| 139 | 141 | 'desc' => esc_html__( 'Specify the duration for which data is stored in the cache. Elements caching speeds up loading by serving pre-rendered copies of elements, rather than rendering them fresh each time. This control ensures efficient performance and up-to-date content.', 'elementor' ), |
| 140 | 142 | ], |
| 141 | 143 | ] |
| 142 | 144 | ); |
| 145 | + } | |
| 146 | + | |
| 147 | + private function clear_cache_on_site_changed() { | |
| 148 | + add_action( 'activated_plugin', [ $this, 'clear_cache' ] ); | |
| 149 | + add_action( 'deactivated_plugin', [ $this, 'clear_cache' ] ); | |
| 150 | + add_action( 'switch_theme', [ $this, 'clear_cache' ] ); | |
| 151 | + add_action( 'upgrader_process_complete', [ $this, 'clear_cache' ] ); | |
| 152 | + | |
| 153 | + add_action( 'update_option_elementor_element_cache_ttl', [ $this, 'clear_cache' ] ); | |
| 154 | + } | |
| 155 | + | |
| 156 | + public function clear_cache() { | |
| 157 | + Plugin::$instance->files_manager->clear_cache(); | |
| 143 | 158 | } |
| 144 | 159 | } |