/** * 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; } }
/** * get_screenshots function. * * @access public * @since 1.0.0 * @uses WooDojo_Utils::glob_php() * @uses global $woodojo->settings->screenshot_url * @return array $screenshots */ public function get_screenshots() { global $woodojo; $screenshots = array(); if (isset($this->component->screenshot_url) && $this->component->screenshot_url != '') { $screenshots = explode(',', $this->component->screenshot_url); } if (is_array($screenshots) && count($screenshots) > 0) { foreach ($screenshots as $k => $v) { $screenshots[$k] = esc_url($woodojo->settings->screenshot_url . $v); } } $screenshots_path = trailingslashit($this->config->assets_path . 'screenshots/' . $this->component_token); $screenshots_url = trailingslashit($this->config->assets_url . 'screenshots/' . $this->component_token); if (count($screenshots) == 0 && is_dir($screenshots_path)) { $files = WooDojo_Utils::glob_php('*.jpg', GLOB_MARK, $screenshots_path); if (count($files) > 0) { foreach ($files as $k => $v) { $screenshots[] = $screenshots_url . basename($v); } } } return $screenshots; }