WP_Upgrader::download_package( string $package, bool $check_signatures = false, array $hook_extra = array() )

Download a package.


Parameters

$package

(Required) The URI of the package. If this is the full path to an existing local file, it will be returned untouched.

$check_signatures

(Optional) Whether to validate file signatures.

Default value: false

$hook_extra

(Optional) Extra arguments to pass to the filter hooks.

Default value: array()


Return

(string|WP_Error) The full path to the downloaded package file, or a WP_Error object.


Source

File: wp-admin/includes/class-wp-upgrader.php

	public function download_package( $package ) {

		/**
		 * Filters whether to return the package.
		 *
		 * @since WP-3.7.0
		 *
		 * @param bool        $reply   Whether to bail without returning the package.
		 *                             Default false.
		 * @param string      $package The package file name.
		 * @param WP_Upgrader $this    The WP_Upgrader instance.
		 */
		$reply = apply_filters( 'upgrader_pre_download', false, $package, $this );
		if ( false !== $reply )
			return $reply;

		if ( ! preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package) ) //Local file or remote?
			return $package; //must be a local file..

		if ( empty($package) )
			return new WP_Error('no_package', $this->strings['no_package']);

		$this->skin->feedback('downloading_package', $package);

		$download_file = download_url($package);

		if ( is_wp_error($download_file) )
			return new WP_Error('download_failed', $this->strings['download_failed'], $download_file->get_error_message());

		return $download_file;
	}

Changelog

Changelog
Version Description
5.5.0 Added the $hook_extra parameter.
5.2.0 Added the $check_signatures parameter.
2.8.0 Introduced.