Automattic\WooCommerce\Blueprint\Importers
ImportInstallTheme::activate_theme
Attempt to activate the theme if the schema specifies to do so.
Метод класса: ImportInstallTheme{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->activate_theme( $schema );
- $schema(объект) (обязательный)
- installTheme schema.
Код ImportInstallTheme::activate_theme() ImportInstallTheme::activate theme WC 11.1.0
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'." );
}
}
}