WC_Admin_Setup_Wizard::install_plugin()protectedWC 1.0

Deprecated from version 4.6.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.

Helper method to queue the background install of a plugin.

Method of the class: WC_Admin_Setup_Wizard{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->install_plugin( $plugin_id, $plugin_info );
$plugin_id(string) (required)
Plugin id used for background install.
$plugin_info(array) (required)
Plugin info array containing name and repo-slug, and optionally file if different from [repo-slug].php.

Changelog

Deprecated since 4.6.0

WC_Admin_Setup_Wizard::install_plugin() code WC 8.7.0

protected function install_plugin( $plugin_id, $plugin_info ) {
	_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
	// Make sure we don't trigger multiple simultaneous installs.
	if ( get_option( 'woocommerce_setup_background_installing_' . $plugin_id ) ) {
		return;
	}

	$plugin_file = isset( $plugin_info['file'] ) ? $plugin_info['file'] : $plugin_info['repo-slug'] . '.php';
	if ( is_plugin_active( $plugin_info['repo-slug'] . '/' . $plugin_file ) ) {
		return;
	}

	if ( empty( $this->deferred_actions ) ) {
		add_action( 'shutdown', array( $this, 'run_deferred_actions' ) );
	}

	array_push(
		$this->deferred_actions,
		array(
			'func' => array( 'WC_Install', 'background_installer' ),
			'args' => array( $plugin_id, $plugin_info ),
		)
	);

	// Set the background installation flag for this plugin.
	update_option( 'woocommerce_setup_background_installing_' . $plugin_id, true );
}