这里没有专门的钩子。然而,钩子switch_theme
应该对你有用。
/**
* Switches current theme to new template and stylesheet names.
*
* @since unknown
* @uses do_action() Calls \'switch_theme\' action on updated theme display name.
*
* @param string $template Template name
* @param string $stylesheet Stylesheet name.
*/
function switch_theme($template, $stylesheet) {
update_option(\'template\', $template);
update_option(\'stylesheet\', $stylesheet);
delete_option(\'current_theme\');
$theme = get_current_theme();
do_action(\'switch_theme\', $theme);
}
因此,如果您完成了任务,您应该编写自定义函数,通过钩子停用主题并激活回主题。
add_action(\'switch_theme\', function($theme){
if ( \'Your_Theme_Name\' == $theme )
{
// do something.
}
// do others.
return;
});