/** * A mimic of the `WP_Upgrader::download_package` method that adds a step to store the temp file with a shorter * file name. * * @see WP_Upgrader::download_package() * * @param string $package The URI of the package. If this is the full path to an * existing local file, it will be returned untouched. * * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object. */ protected function download($package) { if (empty($this->filesystem)) { // try to connect $this->upgrader->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR)); global $wp_filesystem; // still empty? if (empty($wp_filesystem)) { // bail return false; } $this->filesystem = $wp_filesystem; } $this->upgrader->skin->feedback('downloading_package', $package); $download_file = download_url($package); if (is_wp_error($download_file)) { return new WP_Error('download_failed', $this->upgrader->strings['download_failed'], $download_file->get_error_message()); } $file = $this->get_short_filename($download_file); $moved = $this->filesystem->move($download_file, $file); if (empty($moved)) { // we tried, we failed, we bail and let WP do its job return false; } return $file; }