I have a question. I am trying to make a theme compatible with another one. For example if you have this theme named "old theme" and you change it to "new theme", options from customizer will remain in "new theme" also. Everything works great if I go in Appearance -> Themes and switch themes from there. The problem comes when I switch theme from customizer. I'm using something like this (let's say I want to import a text control) :
function import_settings{
$old_theme_content = get_option('theme_mods_my_old_theme');
if( !empty($old_theme_content['my_text_control']) ){
set_theme_mod('my_new_control', $old_theme_content['my_text_control']);
}
}
add_action( 'after_switch_theme','import_settings');
When I switch the theme from customizer, I have to close the customizer, eventually remove the changeset and after that I can see those changes from import. I want the changes to be visible in customize preview after I switch the theme from there. It seems that 'after_switch_theme' hook doesn't trigger then. Does anyone have any idea how to achieve this?