upgrader_pre_download filter-hookWP 3.7.0

Filters whether to download a package for a WordPress core, plugin, theme, or translation upgrade.

Return a non-false value to short-circuit the download and return that value instead.

Usage

add_filter( 'upgrader_pre_download', 'wp_kama_upgrader_pre_download_filter', 10, 4 );

/**
 * Function for `upgrader_pre_download` filter-hook.
 * 
 * @param false|string|WP_Error $reply      Whether to short-circuit the download, the path to the downloaded package, or a WP_Error object.
 * @param string                $package    The package URI. May be a remote URL or local file path.
 * @param WP_Upgrader           $upgrader   The WP_Upgrader instance.
 * @param array                 $hook_extra Extra arguments passed to hooked filters.
 *
 * @return false|string|WP_Error
 */
function wp_kama_upgrader_pre_download_filter( $reply, $package, $upgrader, $hook_extra ){

	// filter...
	return $reply;
}
$reply(false|string|WP_Error)
Whether to short-circuit the download, the path to the downloaded package, or a WP_Error object.
Default: false
$package(string)
The package URI. May be a remote URL or local file path.
$upgrader(WP_Upgrader)
The WP_Upgrader instance.
$hook_extra(array)
Extra arguments passed to hooked filters.

Changelog

Since 3.7.0 Introduced.
Since 5.5.0 Added the $hook_extra parameter.

Where the hook is called

WP_Upgrader::download_package()
upgrader_pre_download
wp-admin/includes/class-wp-upgrader.php 322
$reply = apply_filters( 'upgrader_pre_download', false, $package, $this, $hook_extra );

Where the hook is used in WordPress

Usage not found.