Automattic\WooCommerce\Blueprint\Importers

ImportInstallTheme::activate_themeprotectedWC 1.0

Attempt to activate the theme if the schema specifies to do so.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

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

Код ImportInstallTheme::activate_theme() WC 10.0.2

protected function activate_theme( $schema ) {
	// phpcs:ignore
	$theme = $schema->themeData;
	if ( isset( $schema->options->activate ) && true === $schema->options->activate ) {
		$this->wp_switch_theme( $theme->slug );
		$current_theme = $this->wp_get_theme()->get_stylesheet();
		if ( $current_theme === $theme->slug ) {
			$this->result->add_info( "Switched theme to '$theme->slug'." );
		} else {
			$this->result->add_error( "Failed to switch theme to '$theme->slug'." );
		}
	}
}