WordPress at Your Fingertips
function is not described

WC_WCCOM_Site_Installer::activate_plugin() private WC 3.7.0

Activate plugin given its product ID.

{} It's a method of the class: WC_WCCOM_Site_Installer{}

No Hooks.

Return

\WP_Error|null.

Usage

$result = WC_WCCOM_Site_Installer::activate_plugin( $product_id );
$product_id(int) (required)
Product ID.

Changelog

Since 3.7.0 Introduced.

Code of WC_WCCOM_Site_Installer::activate_plugin() WC 5.8.0

private static function activate_plugin( $product_id ) {
	// Clear plugins cache used in `WC_Helper::get_local_woo_plugins`.
	wp_clean_plugins_cache();
	$filename = false;

	// If product is WP.org one, find out its filename.
	$dir_name = self::get_wporg_product_dir_name( $product_id );
	if ( false !== $dir_name ) {
		$filename = self::get_wporg_plugin_main_file( $dir_name );
	}

	if ( false === $filename ) {
		$plugins = wp_list_filter(
			WC_Helper::get_local_woo_plugins(),
			array(
				'_product_id' => $product_id,
			)
		);

		$filename = is_array( $plugins ) && ! empty( $plugins ) ? key( $plugins ) : '';
	}

	if ( empty( $filename ) ) {
		return new WP_Error( 'unknown_filename', __( 'Unknown product filename.', 'woocommerce' ) );
	}

	return activate_plugin( $filename );
}