WC_WCCOM_Site_Installation_Step_Activate_Product::activate_theme()
Activate theme.
Method of the class: WC_WCCOM_Site_Installation_Step_Activate_Product{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->activate_theme( $product_id );
- $product_id(int) (required)
- Product ID.
WC_WCCOM_Site_Installation_Step_Activate_Product::activate_theme() WC WCCOM Site Installation Step Activate Product::activate theme code WC 9.4.2
private function activate_theme( $product_id ) { // Clear plugins cache used in `WC_Helper::get_local_woo_themes`. wp_clean_themes_cache(); $theme_slug = false; // If product is WP.org theme, find out its slug. $dir_name = $this->get_wporg_product_dir_name(); if ( false !== $dir_name ) { $theme_slug = basename( $dir_name ); } if ( false === $theme_slug ) { $themes = wp_list_filter( WC_Helper::get_local_woo_themes(), array( '_product_id' => $product_id, ) ); $theme_slug = is_array( $themes ) && ! empty( $themes ) ? dirname( key( $themes ) ) : ''; } if ( empty( $theme_slug ) ) { throw new Installer_Error( Installer_Error_Codes::UNKNOWN_FILENAME ); } switch_theme( $theme_slug ); }