/** * * Enter description here ... */ protected static function updatePlugin($viewBack = false) { $linkBack = self::getViewUrl($viewBack); $htmlLinkBack = UniteFunctionsRev::getHtmlLink($linkBack, "Go Back"); //check if css table exist, if not, we need to verify that the current captions.css can be parsed if (UniteFunctionsWPRev::isDBTableExists(GlobalsRevSlider::TABLE_CSS_NAME)) { $captions = RevOperations::getCaptionsCssContentArray(); if ($captions === false) { $message = "CSS parse error! Please make sure your captions.css is valid CSS before updating the plugin!"; echo "<div style='color:#B80A0A;font-size:18px;'><b>Update Error: </b> {$message}</div><br>"; echo $htmlLinkBack; exit; } } $zip = new UniteZipRev(); try { if (function_exists("unzip_file") == false) { if (UniteZipRev::isZipExists() == false) { UniteFunctionsRev::throwError("The ZipArchive php extension not exists, can't extract the update file. Please turn it on in php ini."); } } dmp("Update in progress..."); $arrFiles = UniteFunctionsRev::getVal($_FILES, "update_file"); if (empty($arrFiles)) { UniteFunctionsRev::throwError("Update file don't found."); } $filename = UniteFunctionsRev::getVal($arrFiles, "name"); if (empty($filename)) { UniteFunctionsRev::throwError("Update filename not found."); } $fileType = UniteFunctionsRev::getVal($arrFiles, "type"); /* $fileType = strtolower($fileType); if($fileType != "application/zip") UniteFunctionsRev::throwError("The file uploaded is not zip."); */ $filepathTemp = UniteFunctionsRev::getVal($arrFiles, "tmp_name"); if (file_exists($filepathTemp) == false) { UniteFunctionsRev::throwError("Can't find the uploaded file."); } //crate temp folder UniteFunctionsRev::checkCreateDir(self::$path_temp); //create the update folder $pathUpdate = self::$path_temp . "update_extract/"; UniteFunctionsRev::checkCreateDir($pathUpdate); //remove all files in the update folder if (is_dir($pathUpdate)) { $arrNotDeleted = UniteFunctionsRev::deleteDir($pathUpdate, false); if (!empty($arrNotDeleted)) { $strNotDeleted = print_r($arrNotDeleted, true); UniteFunctionsRev::throwError("Could not delete those files from the update folder: {$strNotDeleted}"); } } //copy the zip file. $filepathZip = $pathUpdate . $filename; $success = move_uploaded_file($filepathTemp, $filepathZip); if ($success == false) { UniteFunctionsRev::throwError("Can't move the uploaded file here: " . $filepathZip . "."); } if (function_exists("unzip_file") == true) { WP_Filesystem(); $response = unzip_file($filepathZip, $pathUpdate); } else { $zip->extract($filepathZip, $pathUpdate); } //get extracted folder $arrFolders = UniteFunctionsRev::getFoldersList($pathUpdate); if (empty($arrFolders)) { UniteFunctionsRev::throwError("The update folder is not extracted"); } if (count($arrFolders) > 1) { UniteFunctionsRev::throwError("Extracted folders are more then 1. Please check the update file."); } //get product folder $productFolder = $arrFolders[0]; if (empty($productFolder)) { UniteFunctionsRev::throwError("Wrong product folder."); } if ($productFolder != self::$dir_plugin) { UniteFunctionsRev::throwError("The update folder don't match the product folder, please check the update file."); } $pathUpdateProduct = $pathUpdate . $productFolder . "/"; //check some file in folder to validate it's the real one: $checkFilepath = $pathUpdateProduct . $productFolder . ".php"; if (file_exists($checkFilepath) == false) { UniteFunctionsRev::throwError("Wrong update extracted folder. The file: " . $checkFilepath . " not found."); } //copy the plugin without the captions file. //$pathOriginalPlugin = $pathUpdate."copy/"; $pathOriginalPlugin = self::$path_plugin; $arrBlackList = array(); $arrBlackList[] = "rs-plugin/css/captions.css"; $arrBlackList[] = "rs-plugin/css/dynamic-captions.css"; $arrBlackList[] = "rs-plugin/css/static-captions.css"; UniteFunctionsRev::copyDir($pathUpdateProduct, $pathOriginalPlugin, "", $arrBlackList); //delete the update UniteFunctionsRev::deleteDir($pathUpdate); dmp("Updated Successfully, redirecting..."); echo "<script>location.href='{$linkBack}'</script>"; } catch (Exception $e) { $message = $e->getMessage(); $message .= " <br> Please update the plugin manually via the ftp"; echo "<div style='color:#B80A0A;font-size:18px;'><b>Update Error: </b> {$message}</div><br>"; echo $htmlLinkBack; exit; } }
/** * * craete tables */ public static function createTable($tableName) { global $wpdb; $parseCssToDb = false; $checkForTablesOneTime = get_option('revslider_checktables', '0'); if ($checkForTablesOneTime == '0') { update_option('revslider_checktables', '1'); if (UniteFunctionsWPRev::isDBTableExists(self::$table_prefix . GlobalsRevSlider::TABLE_CSS_NAME)) { //check if database is empty $result = $wpdb->get_row("SELECT COUNT( DISTINCT id ) AS NumberOfEntrys FROM " . self::$table_prefix . GlobalsRevSlider::TABLE_CSS_NAME); if ($result->NumberOfEntrys == 0) { $parseCssToDb = true; } } } if ($parseCssToDb) { $revOperations = new RevOperations(); $revOperations->importCaptionsCssContentArray(); $revOperations->moveOldCaptionsCss(); //$revOperations->updateDynamicCaptions(true); } //if table exists - don't create it. $tableRealName = self::$table_prefix . $tableName; if (UniteFunctionsWPRev::isDBTableExists($tableRealName)) { return false; } $charset_collate = ''; if (method_exists($wpdb, "get_charset_collate")) { $charset_collate = $wpdb->get_charset_collate(); } else { if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } } switch ($tableName) { case GlobalsRevSlider::TABLE_SLIDERS_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t title tinytext NOT NULL,\n\t\t\t\t\t\t\t alias tinytext,\n\t\t\t\t\t\t\t params text NOT NULL,\n\t\t\t\t\t\t\t PRIMARY KEY (id)\n\t\t\t\t\t\t\t){$charset_collate};"; break; case GlobalsRevSlider::TABLE_SLIDES_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t slider_id int(9) NOT NULL,\n\t\t\t\t\t\t\t\t slide_order int not NULL,\t\n\t\t\t\t\t\t\t\t params text NOT NULL,\n\t\t\t\t\t\t\t\t layers text NOT NULL,\n\t\t\t\t\t\t\t\t PRIMARY KEY (id)\n\t\t\t\t\t\t\t\t){$charset_collate};"; break; case GlobalsRevSlider::TABLE_STATIC_SLIDES_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t slider_id int(9) NOT NULL,\n\t\t\t\t\t\t\t\t params text NOT NULL,\n\t\t\t\t\t\t\t\t layers text NOT NULL,\n\t\t\t\t\t\t\t\t PRIMARY KEY (id)\n\t\t\t\t\t\t\t\t){$charset_collate};"; break; case GlobalsRevSlider::TABLE_SETTINGS_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t general TEXT NOT NULL,\n\t\t\t\t\t\t\t\t params TEXT NOT NULL,\n\t\t\t\t\t\t\t\t PRIMARY KEY (id)\n\t\t\t\t\t\t\t\t){$charset_collate};"; break; case GlobalsRevSlider::TABLE_CSS_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t handle TEXT NOT NULL,\n\t\t\t\t\t\t\t\t settings TEXT,\n\t\t\t\t\t\t\t\t hover TEXT,\n\t\t\t\t\t\t\t\t params TEXT NOT NULL,\n\t\t\t\t\t\t\t\t PRIMARY KEY (id)\n\t\t\t\t\t\t\t\t){$charset_collate};"; $parseCssToDb = true; break; case GlobalsRevSlider::TABLE_LAYER_ANIMS_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t handle TEXT NOT NULL,\n\t\t\t\t\t\t\t\t params TEXT NOT NULL,\n\t\t\t\t\t\t\t\t PRIMARY KEY (id)\n\t\t\t\t\t\t\t\t){$charset_collate};"; break; default: UniteFunctionsRev::throwError("table: {$tableName} not found"); break; } require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); if ($parseCssToDb) { $revOperations = new RevOperations(); $revOperations->importCaptionsCssContentArray(); $revOperations->moveOldCaptionsCss(); //$revOperations->updateDynamicCaptions(true); } }
/** * * craete tables */ public static function createTable($tableName) { //if table exists - don't create it. $tableRealName = self::$table_prefix . $tableName; if (UniteFunctionsWPRev::isDBTableExists($tableRealName)) { return false; } switch ($tableName) { case GlobalsRevSlider::TABLE_SLIDERS_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\r\n\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t\t\t\t title tinytext NOT NULL,\r\n\t\t\t\t\t\t\t alias tinytext,\r\n\t\t\t\t\t\t\t params text NOT NULL,\r\n\t\t\t\t\t\t\t PRIMARY KEY (id)\r\n\t\t\t\t\t\t\t);"; break; case GlobalsRevSlider::TABLE_SLIDES_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\r\n\t\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t\t\t\t\t slider_id int(9) NOT NULL,\r\n\t\t\t\t\t\t\t\t slide_order int not NULL,\t\t \r\n\t\t\t\t\t\t\t\t params text NOT NULL,\r\n\t\t\t\t\t\t\t\t layers text NOT NULL,\r\n\t\t\t\t\t\t\t\t PRIMARY KEY (id)\r\n\t\t\t\t\t\t\t\t);"; break; default: UniteFunctionsRev::throwError("table: {$tableName} not found"); break; } require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); }
/** * * craete tables */ public static function createTable($tableName) { global $wpdb; //if table exists - don't create it. $tableRealName = self::$table_prefix . $tableName; if (UniteFunctionsWPRev::isDBTableExists($tableRealName)) { return false; } $charset_collate = ''; if (method_exists($wpdb, "get_charset_collate")) { $charset_collate = $wpdb->get_charset_collate(); } else { if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } } switch ($tableName) { case GlobalsRevSlider::TABLE_SLIDERS_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t title tinytext NOT NULL,\n\t\t\t\t\t\t\t alias tinytext,\n\t\t\t\t\t\t\t params text NOT NULL,\n\t\t\t\t\t\t\t PRIMARY KEY (id)\n\t\t\t\t\t\t\t){$charset_collate};"; break; case GlobalsRevSlider::TABLE_SLIDES_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t slider_id int(9) NOT NULL,\n\t\t\t\t\t\t\t\t slide_order int not NULL,\t\n\t\t\t\t\t\t\t\t params text NOT NULL,\n\t\t\t\t\t\t\t\t layers text NOT NULL,\n\t\t\t\t\t\t\t\t PRIMARY KEY (id)\n\t\t\t\t\t\t\t\t){$charset_collate};"; break; case GlobalsRevSlider::TABLE_SETTINGS_NAME: $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\n\t\t\t\t\t\t\t\t id int(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t general TEXT NOT NULL,\n\t\t\t\t\t\t\t\t params TEXT NOT NULL,\n\t\t\t\t\t\t\t\t PRIMARY KEY (id)\n\t\t\t\t\t\t\t\t){$charset_collate};"; break; default: UniteFunctionsRev::throwError("table: {$tableName} not found"); break; } require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); }