Пример #1
0
 /**
  * Backup an Envato theme.
  *
  * This function requires the template/theme slug
  * to locate and backup that theme.
  *
  * @access    private
  * @since     1.4
  *
  * @param     string    Template slug
  * @return    void
  */
 protected function _backup_theme($theme)
 {
     $backup_errors = array();
     $theme_backup = Envato_Backup::get_instance();
     $theme_backup->path = EWPT_BACKUP_DIR;
     $theme_backup->root = get_theme_root() . '/' . $theme . '/';
     $theme_backup->archive_filename = strtolower(sanitize_file_name($theme . '.backup.' . date('Y-m-d-H-i-s', time() + (current_time('timestamp') - time())) . '.zip'));
     if (!is_dir($theme_backup->path()) && (!is_writable(dirname($theme_backup->path())) || !mkdir($theme_backup->path())) || !is_writable($theme_backup->path())) {
         array_push($backup_errors, 'Invalid backup path');
         return false;
     }
     if (!is_dir($theme_backup->root()) || !is_readable($theme_backup->root())) {
         array_push($backup_errors, 'Invalid root path');
         return false;
     }
     $theme_backup->backup();
     if (file_exists(Envato_Backup::get_instance()->archive_filepath())) {
         return true;
     } else {
         return $backup_errors;
     }
 }
Пример #2
0
 function backup_theme($theme_dirname)
 {
     // initialize errors
     $this->errors = array();
     // configure backup
     $theme_backup = Envato_Backup::get_instance();
     $theme_backup->path = WP_CONTENT_DIR . '/envato-backups/';
     $theme_backup->root = get_theme_root() . '/' . $theme_dirname . '/';
     $theme_backup->archive_filename = strtolower(sanitize_file_name($theme_dirname . '.backup.' . date('Y-m-d-H-i-s', time() + (current_time('timestamp') - time())) . '.zip'));
     if (!$this->is_valid_dir_path($theme_backup->path())) {
         array_push($this->errors, 'Invalid backup path: ' . $this->secure_display_path($theme_backup->path()) . ' (bad permissions or does not exist)');
         return false;
     }
     if (!$this->is_valid_backup_root($theme_backup->root())) {
         array_push($this->errors, 'Invalid backup root path: ' . $this->secure_display_path($theme_backup->root()) . ' (bad permissions or not a directory)');
         return false;
     }
     // @todo clearer handling of errors from backup() method; currently black box
     $theme_backup->backup();
     if (file_exists($theme_backup->archive_filepath())) {
         return true;
     } else {
         // failed to create backup
         array_push($this->errors, 'Backup creation process succeeded but backup file can not be confirmed: ' . $this->secure_display_path($theme_backup->archive_filepath()));
         return false;
     }
 }
 /**
  * Return the current instance
  *
  * @access    public
  * @since     1.4
  *
  * @static
  * @return    object
  */
 public static function get_instance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Envato_Backup();
     }
     return self::$instance;
 }