options = get_option('speedycache_options', []); $speedycache->options['lbc'] = true; $speedycache->options['minify_css'] = true; $speedycache->options['gzip'] = true; update_option('speedycache_options', $speedycache->options); update_option('speedycache_version', SPEEDYCACHE_VERSION); \SpeedyCache\Htaccess::init(); self::set_advanced_cache(); \SpeedyCache\Util::set_config_file(); } // Called during Deactivation static function deactivate(){ if(is_file(ABSPATH.'.htaccess') && is_writable(ABSPATH.'.htaccess')){ $htaccess = file_get_contents(ABSPATH.'.htaccess'); $htaccess = preg_replace("/#\s?BEGIN\s?speedycache.*?#\s?END\s?speedycache/s", '', $htaccess); $htaccess = preg_replace("/#\s?BEGIN\s?Gzipspeedycache.*?#\s?END\s?Gzipspeedycache/s", '', $htaccess); $htaccess = preg_replace("/#\s?BEGIN\s?LBCspeedycache.*?#\s?END\s?LBCspeedycache/s", '', $htaccess); $htaccess = preg_replace("/#\s?BEGIN\s?WEBPspeedycache.*?#\s?END\s?WEBPspeedycache/s", '', $htaccess); $htaccess = preg_replace("/#\s?BEGIN\s?SpeedyCacheheaders.*?#\s?END\s?SpeedyCacheheaders/s", '', $htaccess); $htaccess = preg_replace('/\n\n+/', "\n\n", $htaccess); // Cleans extra white space which gets added @file_put_contents(ABSPATH.'.htaccess', $htaccess); } self::remove_constant(); wp_clear_scheduled_hook('speedycache_preload'); wp_clear_scheduled_hook('speedycache_purge_cache'); wp_clear_scheduled_hook('speedycache_preload_split'); } static function set_advanced_cache(){ if(file_exists(WP_CONTENT_DIR . '/advanced-cache.php')){ unlink(WP_CONTENT_DIR . '/advanced-cache.php'); } if(!copy(SPEEDYCACHE_DIR . '/main/advanced-cache.php', WP_CONTENT_DIR . '/advanced-cache.php')){ return; } // Adding WP_CACHE Constant self::add_constant(); } // Adds WP_CACHE constant in wp-config.php static function add_constant(){ if(defined('SITEPAD')){ $cache_config_file = WP_CONTENT_DIR . '/enable-advanced-cache.php'; if ( ! file_exists($cache_config_file) ) { $content = "