/**
  * Function to delete tables of plugins
  * @author Praveen Rajan
  */
 function _cvg_deactivate()
 {
     global $wpdb;
     $sub_name_gallery = 'cvg_gallery';
     $sub_name_videos = 'cvg_videos';
     $this->table_gallery = $wpdb->prefix . $sub_name_gallery;
     $this->table_videos = $wpdb->prefix . $sub_name_videos;
     $wpdb->query("DROP TABLE {$this->table_gallery}");
     $wpdb->query("DROP TABLE {$this->table_videos}");
     if (function_exists('is_multisite') && is_multisite()) {
         $gallery_path = get_option('upload_path') . '/video-gallery/';
     } else {
         $gallery_path = 'wp-content/uploads/video-gallery/';
     }
     CvgCore::deleteDir(ABSPATH . $gallery_path);
 }
Example #2
0
 /**
  * Function to remove directory and its files recursively
  * @param $directory - directory path
  * @param $empty - recursive true/false
  * @return true or false
  * @author Praveen Rajan
  */
 function deleteDir($directory, $empty = false)
 {
     if (substr($directory, -1) == "/") {
         $directory = substr($directory, 0, -1);
     }
     if (!file_exists($directory) || !is_dir($directory)) {
         return false;
     } elseif (!is_readable($directory)) {
         return false;
     } else {
         $directoryHandle = opendir($directory);
         while ($contents = readdir($directoryHandle)) {
             if ($contents != '.' && $contents != '..') {
                 $path = $directory . "/" . $contents;
                 if (is_dir($path)) {
                     CvgCore::deleteDir($path);
                 } else {
                     @unlink($path);
                 }
             }
         }
         closedir($directoryHandle);
         if ($empty == false) {
             if (!@rmdir($directory)) {
                 return false;
             }
         }
         return true;
     }
 }