我可以通过使用“new”after\\u switch\\u theme挂钩激活我的主题来显示消息,方法如下:
function themeActivationFunction($oldname, $oldtheme=false) {
$msg = \'
<div class="error">
<p>The \' . get_option( \'current_theme\' ) . \' theme has been ACTIVATED.</p>
</div>\';
add_action( \'admin_notices\', $c = create_function( \'\', \'echo "\' . addcslashes( $msg, \'"\' ) . \'";\' ) );
}
add_action("after_switch_theme", "themeActivationFunction", 10 , 2);
但它不能与swith\\u主题挂钩一起禁用我的主题。我认为,因为将主题切换到另一个默认的WordPress消息会覆盖我的消息,在主题中被禁用,重新加载屏幕会删除所有内容。function themeDeactivationFunction($theme) {
// Lets let the admin know whats going on.
$msg = \'
<div class="error">
<p>Your theme has been DEACTIVATED</p>
</div>\';
add_action( \'admin_notices\', $c = create_function( \'\', \'echo "\' . addcslashes( $msg, \'"\' ) . \'";\' ) );
}
add_action("switch_theme", "themeDeactivationFunction", 10 , 2);
我正在寻找一个“变通方法”,通知用户停用我的主题和设置例程。