/** * upgrade_component function. * * @access public * @since 1.0.0 * @param string $component * @param string $type * @param boolean $redirect * @return void */ public function upgrade_component($component, $type = 'downloadable', $redirect = true) { global $woodojo; $redirect_to = admin_url('admin.php?page=' . $this->config->token . '&component=' . $component . '&component-type=' . $type . '&process-action=' . 'upgrade' . '&upgrade-component=' . $component . '&activate=false'); // Backup the current version. $dir = $this->config->downloads_path; if ($type == 'bundled') { $dir = $this->config->components_path; } $component_dir = $dir . dirname($this->components[$type][$component]->filepath); $files = WooDojo_Utils::glob_php('*', 0, $component_dir); if (count($files) > 0) { foreach ($files as $k => $v) { if ($v == $dir || is_dir($v)) { unset($files[$k]); } else { $files[$k] = str_replace($this->config->downloads_path, '', $v); } } } $has_zip = WooDojo_Utils::create_zip($files, $dir, $this->config->backups_path . sanitize_title_with_dashes($component) . '.zip', true); if ($has_zip == true) { // Download the latest version. $upgraded = $this->download_component($component, $type, false, false); } if ($upgraded == true) { wp_redirect(admin_url('admin.php?page=' . $this->config->token . '&upgraded-component=' . $component . '&type=' . $type)); exit; } else { wp_redirect(admin_url('admin.php?page=' . $this->config->token . '&upgrade-error=' . $component . '&type=' . $type)); exit; } }