diff --git a/system/controllers/pluginmanager.php b/system/controllers/pluginmanager.php
index 42f560a1..c6eb5996 100644
--- a/system/controllers/pluginmanager.php
+++ b/system/controllers/pluginmanager.php
@@ -34,8 +34,7 @@ if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
 }
 
 switch ($action) {
-
-    case 'install':
+    case 'delete':
         if (!is_writeable($CACHE_PATH)) {
             r2(U . "pluginmanager", 'e', 'Folder cache/ is not writable');
         }
@@ -45,7 +44,53 @@ switch ($action) {
         set_time_limit(-1);
         $tipe = $routes['2'];
         $plugin = $routes['3'];
-        $file = $CACHE_PATH . File::pathFixer('/') . $plugin . '.zip';
+        $file = $CACHE_PATH . DIRECTORY_SEPARATOR . $plugin . '.zip';
+        if (file_exists($file)) unlink($file);
+        if ($tipe == 'plugin') {
+            foreach ($json['plugins'] as $plg) {
+                if ($plg['id'] == $plugin) {
+                    $fp = fopen($file, 'w+');
+                    $ch = curl_init($plg['github'] . '/archive/refs/heads/master.zip');
+                    curl_setopt($ch, CURLOPT_POST, 0);
+                    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15);
+                    curl_setopt($ch, CURLOPT_TIMEOUT, 15);
+                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+                    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+                    curl_setopt($ch, CURLOPT_FILE, $fp);
+                    curl_exec($ch);
+                    curl_close($ch);
+                    fclose($fp);
+
+                    $zip = new ZipArchive();
+                    $zip->open($file);
+                    $zip->extractTo($CACHE_PATH);
+                    $zip->close();
+                    $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-main/');
+                    if (!file_exists($folder)) {
+                        $folder = $CACHE_PATH . File::pathFixer('/' . $plugin . '-master/');
+                    }
+                    if (!file_exists($folder)) {
+                        r2(U . "pluginmanager", 'e', 'Extracted Folder is unknown');
+                    }
+                    scanAndRemovePath($folder, $PLUGIN_PATH . DIRECTORY_SEPARATOR);
+                    File::deleteFolder($folder);
+                    unlink($file);
+                    r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been deleted');
+                    break;
+                }
+            }
+            break;
+        }
+        break;
+    case 'install':
+        if (!is_writeable($CACHE_PATH)) {
+            r2(U . "pluginmanager", 'e', 'Folder cache/ is not writable');
+        }
+        if (!is_writeable($PLUGIN_PATH)) {
+            r2(U . "pluginmanager", 'e', 'Folder plugin/ is not writable');
+        }
+
+        $file = $CACHE_PATH . DIRECTORY_SEPARATOR . $plugin . '.zip';
         if (file_exists($file)) unlink($file);
         if ($tipe == 'plugin') {
             foreach ($json['plugins'] as $plg) {
@@ -76,7 +121,7 @@ switch ($action) {
                     File::copyFolder($folder, $PLUGIN_PATH . DIRECTORY_SEPARATOR, ['README.md', 'LICENSE']);
                     File::deleteFolder($folder);
                     unlink($file);
-                    r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been installed');
+                    r2(U . "pluginmanager", 's', 'Plugin ' . $plugin . ' has been deleted');
                     break;
                 }
             }
@@ -127,3 +172,24 @@ switch ($action) {
         $ui->assign('pgs', $json['payment_gateway']);
         $ui->display('plugin-manager.tpl');
 }
+
+
+function scanAndRemovePath($source, $target)
+{
+    $files = scandir($source);
+    foreach ($files as $file) {
+        if (is_file($source . $file)) {
+            if(file_exists($target.$file)){
+                unlink($target . $file);
+            }
+        } else if (is_dir($source . $file) && !in_array($file, ['.', '..'])) {
+            scanAndRemovePath($source. $file. DIRECTORY_SEPARATOR, $target. $file. DIRECTORY_SEPARATOR);
+            if(file_exists($target.$file)){
+                rmdir($target . $file);
+            }
+        }
+    }
+    if(file_exists($target)){
+        rmdir($target);
+    }
+}
\ No newline at end of file