->delete( $cache_folder_path . $entry ); } } /** * Reset cache when changing the option. * * @param array $new new configurations. * @param array $old old configurations. * * @return array */ public function on_change_directory_for_default_language_clean_cache( array $new, array $old ): array { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.newFound if ( ! key_exists( 'urls', $old ) || ! key_exists( 'directory_for_default_language', $old['urls'] ) || ! key_exists( 'urls', $new ) || ! key_exists( 'directory_for_default_language', $new['urls'] ) || $new['urls']['directory_for_default_language'] === $old['urls']['directory_for_default_language'] ) { return $new; } /** * Reset WP Rocket Preload. */ do_action( 'rocket_reset_preload' ); rocket_clean_domain(); return $new; } /** * Clear the cache when the option language directory is enabled. * * @return void */ public function maybe_clear_on_disable(): void { $option = get_option( 'icl_sitepress_settings' ); if ( ! $option || ! is_array( $option ) || ! key_exists( 'urls', $option ) || ! key_exists( 'directory_for_default_language', $option['urls'] ) || false === $option['urls']['directory_for_default_language'] ) { return; } /** * Reset WP Rocket Preload. */ do_action( 'rocket_reset_preload' ); rocket_clean_cache_dir(); rocket_clean_domain(); } }