主题don\'t currently have activation/deactivation/installation/uninstallation hooks.
你最好的选择是以某种方式“伪造”它,也许是使用一个只执行一次的函数,基于该函数执行时切换的开关。e、 g.:
<?php
function wpse45817_theme_activation() {
// globalize our switch
global $wpse45817_theme_activation_switch;
// Check to see if the switch is set
if ( isset( $wpse45817_theme_activation_switch ) ) {
return;
} else {
// EXECUTE YOUR THEME-ACTIVATION CODE HERE
//
//
// Toggle Theme activation switch
$wpse45817_theme_activation_switch = true;
}
}
add_action( \'after_setup_theme\', \'wpse45817_theme_activation\' );
?>