upgrader_pre_install filter-hookWP 2.8.0

Filters the installation response before the installation has started.

Returning a value that could be evaluated as a WP_Error will effectively short-circuit the installation, returning that value instead.

Usage

add_filter( 'upgrader_pre_install', 'wp_kama_upgrader_pre_install_filter', 10, 2 );

/**
 * Function for `upgrader_pre_install` filter-hook.
 * 
 * @param bool|WP_Error $response   Installation response.
 * @param array         $hook_extra Extra arguments passed to hooked filters.
 *
 * @return bool|WP_Error
 */
function wp_kama_upgrader_pre_install_filter( $response, $hook_extra ){

	// filter...
	return $response;
}
$response(true|false|WP_Error)
Installation response.
$hook_extra(array)
Extra arguments passed to hooked filters.

Changelog

Since 2.8.0 Introduced.

Where the hook is called

WP_Upgrader::install_package()
upgrader_pre_install
wp-admin/includes/class-wp-upgrader.php 546
$res = apply_filters( 'upgrader_pre_install', true, $args['hook_extra'] );

Where the hook is used in WordPress

wp-admin/includes/class-plugin-upgrader.php 211
add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
wp-admin/includes/class-plugin-upgrader.php 212
add_filter( 'upgrader_pre_install', array( $this, 'active_before' ), 10, 2 );
wp-admin/includes/class-plugin-upgrader.php 245
remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) );
wp-admin/includes/class-plugin-upgrader.php 246
remove_filter( 'upgrader_pre_install', array( $this, 'active_before' ) );
wp-admin/includes/class-theme-upgrader.php 316
add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
wp-admin/includes/class-theme-upgrader.php 344
remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );
wp-admin/includes/class-theme-upgrader.php 399
add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
wp-admin/includes/class-theme-upgrader.php 529
remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );