Upgrader: Allow plugins to short-circuit the package download. Props rmccue and DrewAPicture. Fixes #22378

Built from https://develop.svn.wordpress.org/trunk@25427


git-svn-id: http://core.svn.wordpress.org/trunk@25351 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2013-09-13 12:53:08 +00:00
parent 680a7a596d
commit dd8e15f612
1 changed files with 13 additions and 0 deletions

View File

@ -108,6 +108,19 @@ class WP_Upgrader {
function download_package($package) {
/**
* Filter whether to return the package.
*
* @since 3.7.0
*
* @param bool $reply Whether to bail without returning the package. Default is false.
* @param string $package The package file name.
* @param object $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..