helper = Cache_Helper::get_instance(); $this->register_action( 'wp_smush_avif_status_changed', array( $this, 'avif_status_changed' ) ); $this->register_action( 'wp_smush_webp_status_changed', array( $this, 'webp_status_changed' ) ); $this->register_action( 'wp_smush_webp_method_changed', array( $this, 'webp_method_changed' ) ); $this->register_action( 'wp_smush_cdn_status_changed', array( $this, 'cdn_status_changed' ) ); // TODO: identify other cases where cache should be cleared and call the clear_third_party_cache method $this->register_action( 'wp_ajax_smush_dismiss_cache_notice', array( $this, 'dismiss_cache_notice' ) ); $this->register_action( 'wp_smush_header_notices', array( $this, 'maybe_show_cache_notice' ) ); } public function cdn_status_changed() { $this->helper->clear_full_cache( 'cdn' ); } public function webp_method_changed() { $this->helper->clear_full_cache( 'next_gen_method' ); } public function webp_status_changed() { $this->helper->clear_full_cache( 'next_gen' ); } public function avif_status_changed() { $this->helper->clear_full_cache( 'next_gen' ); } public function dismiss_cache_notice() { check_ajax_referer( 'wp-smush-ajax' ); // Check for permission. if ( ! Helper::is_user_allowed( 'manage_options' ) ) { wp_die( esc_html__( 'Unauthorized', 'wp-smushit' ), 403 ); } $this->helper->delete_notice_key(); wp_send_json_success(); } public function maybe_show_cache_notice() { $notice = $this->get_cache_notice(); if ( empty( $notice ) ) { return; } ?>