Automattic\WooCommerce\Blueprint\Importers

ImportInstallPlugin::activateprotectedWC 1.0

Activates an installed plugin by its slug.

Метод класса: ImportInstallPlugin{}

Хуков нет.

Возвращает

\WP_Error|null. WP_Error on failure, null on success.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->activate( $slug );
$slug(строка) (обязательный)
Plugin slug.

Код ImportInstallPlugin::activate() WC 10.0.2

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 );
}