upgrader_pre_install хук-фильтрWP 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.

Использование

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(массив)
Extra arguments passed to hooked filters.

Список изменений

С версии 2.8.0 Введена.

Где вызывается хук

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

Где используется хук в 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 238
remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) );
wp-admin/includes/class-plugin-upgrader.php 239
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 339
remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );
wp-admin/includes/class-theme-upgrader.php 388
add_filter( 'upgrader_pre_install', array( $this, 'current_before' ), 10, 2 );
wp-admin/includes/class-theme-upgrader.php 481
remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );