/**
  * Import themes
  *
  * @return void
  */
 public function import()
 {
     $storage = StorageArea::getInstance();
     // Themes directory
     $themes_dir = get_theme_root();
     if (!is_dir($themes_dir)) {
         mkdir($themes_dir);
     }
     // Backup themes files
     $backup_themes_to = $storage->makeDirectory();
     StorageUtility::copy($themes_dir, $backup_themes_to->getName());
     // Flush themes files
     StorageUtility::flush($themes_dir);
     // Import themes files
     StorageUtility::copy($storage->getRootPath() . AI1WM_THEMES_NAME, $themes_dir);
 }
 /**
  * Import plugins
  *
  * @return void
  */
 public function import()
 {
     $storage = StorageArea::getInstance();
     // Plugins directory
     $plugins_dir = WP_PLUGIN_DIR;
     if (!is_dir($plugins_dir)) {
         mkdir($plugins_dir);
     }
     // Backup plugin files
     $backup_plugins_to = $storage->makeDirectory();
     StorageUtility::copy($plugins_dir, $backup_plugins_to->getName(), array(AI1WM_PLUGIN_NAME));
     // Flush plugin files
     StorageUtility::flush($plugins_dir, array(AI1WM_PLUGIN_NAME));
     // Import plugin files
     StorageUtility::copy($storage->getRootPath() . AI1WM_PLUGINS_NAME, $plugins_dir);
 }
 /**
  * Import media
  *
  * @return void
  */
 public function import()
 {
     $storage = StorageArea::getInstance();
     // Media directory
     $upload_dir = wp_upload_dir();
     $upload_basedir = $upload_dir['basedir'];
     if (!is_dir($upload_basedir)) {
         mkdir($upload_basedir);
     }
     // Backup media files
     $backup_media_to = $storage->makeDirectory();
     StorageUtility::copy($upload_basedir, $backup_media_to->getName());
     // Flush media files
     StorageUtility::flush($upload_basedir);
     // Import media files
     StorageUtility::copy($storage->getRootPath() . AI1WM_MEDIA_NAME, $upload_basedir);
 }
 /**
  * Import sites (Network mode)
  *
  * @return void
  */
 public function import()
 {
     global $wp_version;
     $storage = StorageArea::getInstance();
     if (version_compare($wp_version, '3.5', '<')) {
         // Blogs.dir directory
         $blogs_dir = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . AI1WM_BLOGS_NAME;
         if (!is_dir($blogs_dir)) {
             mkdir($blogs_dir);
         }
         // Backup blogs.dir files
         $backup_blogs_to = $storage->makeDirectory();
         StorageUtility::copy($blogs_dir, $backup_blogs_to->getName());
         // Flush blogs.dir files
         StorageUtility::flush($blogs_dir);
         // Import blogs.dir files
         StorageUtility::copy($storage->getRootPath() . AI1WM_SITES_NAME, $blogs_dir);
     } else {
         // Media directory
         $upload_dir = wp_upload_dir();
         $upload_basedir = $upload_dir['basedir'];
         if (!is_dir($upload_basedir)) {
             mkdir($upload_basedir);
         }
         // Sites directory
         $sites_dir = $upload_basedir . DIRECTORY_SEPARATOR . AI1WM_SITES_NAME;
         if (!is_dir($sites_dir)) {
             mkdir($sites_dir);
         }
         // Backup sites files
         $backup_sites_to = $storage->makeDirectory();
         StorageUtility::copy($sites_dir, $backup_sites_to->getName());
         // Flush sites files
         StorageUtility::flush($sites_dir);
         // Import sites files
         StorageUtility::copy($storage->getRootPath() . AI1WM_SITES_NAME, $sites_dir);
     }
 }
 /**
  * Delete directory
  *
  * @return boolean
  */
 public function delete()
 {
     // Remove child files and directories
     if (StorageUtility::flush($this->directory)) {
         return rmdir($this->directory);
     }
 }
示例#6
0
 /**
  * Delete all files and directories in the storage
  *
  * @return boolean
  */
 public function flush()
 {
     if (defined('AI1WM_STORAGE_INDEX')) {
         return StorageUtility::flush($this->getRootPath(), array(AI1WM_STORAGE_INDEX));
     }
     return StorageUtility::flush($this->getRootPath());
 }