Make WordPress Core

Changeset 48399


Ignore:
Timestamp:
07/07/2020 07:13:30 PM (4 years ago)
Author:
desrosj
Message:

Upgrade/Install: Add hook_extra parameter to the upgrader_pre_download filter.

This provides additional context to code running on this hook, including which plugin or theme update will be downloaded. It also brings consistency to this filter with others throughout the upgrade process.

Props obliviousharmony, desrosj.
Fixes #49686.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r48390 r48399  
    249249     *                                 existing local file, it will be returned untouched.
    250250     * @param bool   $check_signatures Whether to validate file signatures. Default false.
     251     * @param array  $hook_extra       Extra arguments to pass to the filter hooks. Default empty array.
    251252     * @return string|WP_Error The full path to the downloaded package file, or a WP_Error object.
    252253     */
    253     public function download_package( $package, $check_signatures = false ) {
    254 
     254    public function download_package( $package, $check_signatures = false, $hook_extra = array() ) {
    255255        /**
    256256         * Filters whether to return the package.
     
    258258         * @since 3.7.0
    259259         *
    260          * @param bool        $reply   Whether to bail without returning the package.
    261          *                             Default false.
    262          * @param string      $package The package file name.
    263          * @param WP_Upgrader $this    The WP_Upgrader instance.
     260         * @param bool        $reply      Whether to bail without returning the package.
     261         *                                Default false.
     262         * @param string      $package    The package file name.
     263         * @param WP_Upgrader $this       The WP_Upgrader instance.
     264         * @param array       $hook_extra Extra arguments passed to hooked filters.
    264265         */
    265         $reply = apply_filters( 'upgrader_pre_download', false, $package, $this );
     266        $reply = apply_filters( 'upgrader_pre_download', false, $package, $this, $hook_extra );
    266267        if ( false !== $reply ) {
    267268            return $reply;
     
    738739         * of the file if the package is a local file)
    739740         */
    740         $download = $this->download_package( $options['package'], true );
     741        $download = $this->download_package( $options['package'], true, $options['hook_extra'] );
    741742
    742743        // Allow for signature soft-fail.
Note: See TracChangeset for help on using the changeset viewer.