WC_WCCOM_Site_Installation_Step_Activate_Product::activate_plugin()
Activate plugin.
Method of the class: WC_WCCOM_Site_Installation_Step_Activate_Product{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->activate_plugin( $product_id );
- $product_id(int) (required)
- Product ID.
WC_WCCOM_Site_Installation_Step_Activate_Product::activate_plugin() WC WCCOM Site Installation Step Activate Product::activate plugin code WC 9.4.2
private 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 = $this->get_wporg_product_dir_name(); if ( false !== $dir_name ) { $filename = \WC_WCCOM_Site_Installer::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 ) ) { throw new Installer_Error( Installer_Error_Codes::UNKNOWN_FILENAME ); } // If the plugin is already active, make sure we call the registration hook. if ( is_plugin_active( $filename ) ) { WC_Helper::activated_plugin( $filename ); } $result = activate_plugin( $filename ); if ( is_wp_error( $result ) ) { throw new Installer_Error( Installer_Error_Codes::PLUGIN_ACTIVATION_ERROR, $result->get_error_message() ); } }