Automattic\WooCommerce\Internal\Utilities
PluginInstaller::handle_upgrader_process_complete
Handler for the upgrader_process_complete It's used to remove the autoinstalled plugin information for plugins that are upgraded or reinstalled manually (or more generally, by using any install method other than this class).
Method of the class: PluginInstaller{}
No Hooks.
Returns
null
. Nothing (null).
Usage
$PluginInstaller = new PluginInstaller(); $PluginInstaller->handle_upgrader_process_complete( $upgrader, $hook_extra );
- $upgrader(WP_Upgrader) (required)
- The upgrader class that has performed the plugin upgrade/reinstall.
- $hook_extra(array) (required)
- Extra information about the upgrade process.
PluginInstaller::handle_upgrader_process_complete() PluginInstaller::handle upgrader process complete code WC 9.9.3
public function handle_upgrader_process_complete( \WP_Upgrader $upgrader, array $hook_extra ) { if ( $this->installing_plugin || ! ( $upgrader instanceof \Plugin_Upgrader ) || ( 'plugin' !== ( $hook_extra['type'] ?? null ) ) ) { return; } $auto_installed_plugins = get_site_option( 'woocommerce_autoinstalled_plugins' ); if ( ! $auto_installed_plugins ) { return; } if ( $hook_extra['bulk'] ?? false ) { $updated_plugin_names = $hook_extra['plugins'] ?? array(); } else { $updated_plugin_names = array( $upgrader->plugin_info() ); } $auto_installed_plugin_names = array_keys( $auto_installed_plugins ); $updated_auto_installed_plugin_names = array_intersect( $auto_installed_plugin_names, $updated_plugin_names ); if ( empty( $updated_auto_installed_plugin_names ) ) { return; } $new_auto_installed_plugins = array_diff_key( $auto_installed_plugins, array_flip( $updated_auto_installed_plugin_names ) ); if ( empty( $new_auto_installed_plugins ) ) { delete_site_option( 'woocommerce_autoinstalled_plugins' ); } else { update_site_option( 'woocommerce_autoinstalled_plugins', $new_auto_installed_plugins ); } }