Automattic\WooCommerce\Blueprint\Importers
ImportInstallTheme::activate_theme
Attempt to activate the theme if the schema specifies to do so.
Method of the class: ImportInstallTheme{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->activate_theme( $schema );
- $schema(object) (required)
- installTheme schema.
ImportInstallTheme::activate_theme() ImportInstallTheme::activate theme code WC 10.9.4
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'." );
}
}
}