Automattic\WooCommerce\Blueprint\Importers
ImportInstallPlugin::activate
Activates an installed plugin by its slug.
Method of the class: ImportInstallPlugin{}
No Hooks.
Returns
\WP_Error|null
. WP_Error on failure, null on success.
Usage
// protected - for code of main (parent) or child class $result = $this->activate( $slug );
- $slug(string) (required)
- Plugin slug.
ImportInstallPlugin::activate() ImportInstallPlugin::activate code WC 9.9.5
protected function activate( $slug ) { if ( empty( $this->installed_plugin_paths ) ) { $this->installed_plugin_paths = $this->get_installed_plugins_paths(); } $path = $this->installed_plugin_paths[ $slug ] ?? false; if ( ! $path ) { return new \WP_Error( 'plugin_not_installed', "Plugin {$slug} is not installed." ); } return $this->wp_activate_plugin( $path ); }