0 && trim($config_file[$i]) == '' && $last_line == '' ) { unset($config_file[$i]); continue; } $last_line = trim($config_file[$i]); if ( ! preg_match( '/^define\(\s*\'([A-Z_]+)\',(.*)\)/', $config_file[$i], $match ) ) { continue; } if ( 'WP_CACHE' === $match[1] && strpos($config_file[$i], 'Added by WP Cloudflare Super Page Cache') !== false ) { unset($config_file[$i]); $last_line = ''; continue; } } if( trim($config_file[ $config_file_count-1 ]) == '' ) unset( $config_file[ $config_file_count-1 ] ); // Insert the constant in wp-config.php file. $handle = @fopen($config_file_path, 'w'); foreach ($config_file as $line) { @fwrite($handle, $line . "\n"); } @fclose($handle); } $timestamp = wp_next_scheduled( 'swcfpc_cache_purge_cron' ); wp_unschedule_event( $timestamp, 'swcfpc_cache_purge_cron' ); if( file_exists($plugin_storage_path) ) { delete_directory_recursive( $plugin_storage_path ); } if( file_exists($plugin_storage_main_path) && is_directory_empty($plugin_storage_main_path) ) rmdir( $plugin_storage_main_path ); function delete_directory_recursive($dir) { if( !class_exists('RecursiveDirectoryIterator') || !class_exists('RecursiveIteratorIterator') ) return false; $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS); $files = new RecursiveIteratorIterator($it,RecursiveIteratorIterator::CHILD_FIRST); foreach($files as $file) { if ($file->isDir()) rmdir($file->getRealPath()); else unlink($file->getRealPath()); } rmdir($dir); return true; } function is_directory_empty($dir) { $handle = opendir($dir); while (false !== ($entry = readdir($handle))) { if ($entry != '.' && $entry != '..') { closedir($handle); return false; } } closedir($handle); return true; }