unify upgrader_pre_download hook actions

Signed-off-by: Andy Fragen <andy@thefragens.com>
This commit is contained in:
Andy Fragen 2025-07-27 09:23:53 -07:00
parent c9337fd72c
commit 6f8ca915aa
2 changed files with 3 additions and 14 deletions

View file

@ -572,13 +572,15 @@ function get_update_data( $did ) {
}
/**
* Send upgrader_pre_download filter to hook `upgrader_source_selection` during AJAX.
* Send upgrader_pre_download filter to hook `upgrader_source_selection` during AJAX
* and send to `maybe_add_accept_header()`.
*
* @param bool $false Whether to bail without returning the package.
* Default false.
* @return bool
*/
function upgrader_pre_download( $false ) : bool {
add_filter( 'http_request_args', 'FAIR\\Packages\\maybe_add_accept_header', 20, 2 );
add_filter( 'upgrader_source_selection', __NAMESPACE__ . '\\rename_source_selection', 10, 3 );
return $false;
}

View file

@ -14,19 +14,6 @@ use FAIR\Packages;
*/
function bootstrap() {
add_action( 'init', __NAMESPACE__ . '\\run' );
add_filter( 'upgrader_pre_download', __NAMESPACE__ . '\\upgrader_pre_download', 10, 1 );
}
/**
* Send upgrader_pre_download filter to maybe_add_accept_header().
*
* @param bool $false Whether to bail without returning the package.
* Default false.
* @return bool
*/
function upgrader_pre_download( $false ) : bool {
add_filter( 'http_request_args', 'FAIR\\Packages\\maybe_add_accept_header', 20, 2 );
return $false;
}
/**