WC_WCCOM_Site_Installation_Step_Activate_Product::activate_plugin
Activate plugin.
Метод класса: WC_WCCOM_Site_Installation_Step_Activate_Product{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->activate_plugin( $product_id );
- $product_id(int) (обязательный)
- Product ID.
Код WC_WCCOM_Site_Installation_Step_Activate_Product::activate_plugin() WC WCCOM Site Installation Step Activate Product::activate plugin WC 10.8.1
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 ) : '';
}
// Fallback: use installed_path from the move_product step.
if ( empty( $filename ) && ! empty( $this->state->get_installed_path() ) ) {
$filename = \WC_WCCOM_Site_Installer::get_wporg_plugin_main_file(
basename( $this->state->get_installed_path() )
);
}
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() );
}
}