How to import theme mods when switching from a ThemeIsle Hestia child theme to Hestia
When switching from a Themeisle Hestia child theme (such as Christmas Hestia or Tiny Hestia) to Hestia or Hestia Pro, your Customizer settings are not carried over automatically. This code snippet migrates those theme modifications so your configuration is preserved after the switch.
Add this piece of code in Hestia/Hestia PRO's functions.php file just at the end:
add_action( 'after_switch_theme', 'hestia_import_theme_mods_from_themeisle_child_themes' );
/**
* Import theme mods when switching from a Themeisle Hestia child theme to Hestia
*/
function hestia_import_theme_mods_from_themeisle_child_themes() {
// Get the name of the previously active theme.
$previous_theme = strtolower( get_option( 'theme_switched' ) );
if ( ! in_array( $previous_theme, array( 'christmas-hestia', 'tiny-hestia' ) ) ) {
return;
}
// Get the theme mods from the previous theme.
$previous_theme_content = get_option( 'theme_mods_' . $previous_theme );
if ( ! empty( $previous_theme_content ) ) {
foreach ( $previous_theme_content as $previous_theme_mod_k => $previous_theme_mod_v ) {
set_theme_mod( $previous_theme_mod_k, $previous_theme_mod_v );
}
}
}