public function update_code($type, $url, $addon = "")
 {
     global $Chronosly_Settings;
     switch ($type) {
         case "core":
             $path = CHRONOSLY_PATH;
             break;
         case "addons":
             $path = CHRONOSLY_ADDONS_PATH;
             break;
         case "templates":
             $path = CHRONOSLY_TEMPLATES_PATH;
             break;
     }
     $cont = $this->get_external_content($url);
     // return;
     //save the zip temporaly
     if ($cont["error"]) {
         return 0;
     }
     $zip = $cont["content"];
     $fp = fopen(CHRONOSLY_PATH . DIRECTORY_SEPARATOR . "temp.zip", "w");
     fwrite($fp, $zip);
     fclose($fp);
     require_once ABSPATH . '/wp-admin/includes/file.php';
     WP_Filesystem();
     if (stripos($addon, "organizers_and_places") !== FALSE or stripos($addon, "extended_marketplace") !== FALSE) {
         $path = CHRONOSLY_PATH;
     }
     $unzipfile = unzip_file(CHRONOSLY_PATH . DIRECTORY_SEPARATOR . "temp.zip", $path);
     @unlink(CHRONOSLY_PATH . DIRECTORY_SEPARATOR . "temp.zip");
     $utils = new Chronosly_Utils();
     if (stripos($addon, "organizers_and_places") !== FALSE and $unzipfile === true) {
         $files = scandir($path . DIRECTORY_SEPARATOR . "organizers_and_places");
         foreach ($files as $file) {
             if ($file != "." && $file != "..") {
                 $utils->rcopy($path . DIRECTORY_SEPARATOR . "organizers_and_places/{$file}", $destination_path . DIRECTORY_SEPARATOR . "{$file}");
             }
         }
     } else {
         if (stripos($addon, "extended_marketplace") !== FALSE and $unzipfile === true) {
             $files = scandir($path . DIRECTORY_SEPARATOR . "extended_marketplace");
             foreach ($files as $file) {
                 if ($file != "." && $file != "..") {
                     $utils->rcopy($path . DIRECTORY_SEPARATOR . "extended_marketplace/{$file}", $destination_path . DIRECTORY_SEPARATOR . "{$file}");
                 }
             }
         }
     }
     if ($unzipfile === true) {
         return 1;
     }
     return 0;
 }
             if ($file != "." && $file != "..") {
                 $utils->rcopy($destination_path . DIRECTORY_SEPARATOR . "organizers_and_places/{$file}", CHRONOSLY_PATH . "/{$file}");
             }
         }
         // $utils->rrmdir( $destination_path.DIRECTORY_SEPARATOR."organizers_and_places");
         $settings = unserialize(get_option("chronosly-settings"));
         $settings["chronosly_organizers_addon"] = 1;
         $settings["chronosly_places_addon"] = 1;
         update_option('chronosly-settings', serialize($settings));
     } else {
         if (stripos($upload['file'], "extended_marketplace") !== FALSE) {
             $utils = new Chronosly_Utils();
             $files = scandir($destination_path . DIRECTORY_SEPARATOR . "extended_marketplace");
             foreach ($files as $file) {
                 if ($file != "." && $file != "..") {
                     $utils->rcopy($destination_path . DIRECTORY_SEPARATOR . "extended_marketplace/{$file}", CHRONOSLY_PATH . "/{$file}");
                 }
             }
             // $utils->rrmdir( $destination_path.DIRECTORY_SEPARATOR."extended_marketplace");
         }
     }
     unlink($upload['file']);
     $names = explode(DIRECTORY_SEPARATOR, $upload['file']);
     $name = str_replace(".zip", "", $names[count($names) - 1]);
     if (stripos($upload['file'], "organizers_and_places") !== FALSE) {
         $name = "organizers_and_places";
     }
     // wp_redirect("admin.php?page=chronosly_addons_configs&installed=$name");
     echo "<script type=\"text/javascript\"> document.location.href= '" . $_SERVER["SCRIPT_URI"] . "?page=chronosly_addons_configs&installed={$name}'; </script>";
     die;
 } else {