Theme activation hooks

//Activate Hooks
ddt_theme_activation_hook('desert_default','ddt_theme_activate');
ddt_theme_deactivation_hook('desert_default','ddt_theme_deactivate');

//Activation Routine
function ddt_theme_activate(){
$first_activation = get_option('desert_default_activated');
if(!$first_activation) update_option('desert_default_activated',1); //Set first activation option
}

//Deactivation Routine
function ddt_theme_deactivate(){
//Code here to run on de-activation
}

//Activation Hook
function ddt_theme_activation_hook($theme,$callback){
$option_name = $theme . "_active";
if(!get_option($option_name)) {
call_user_func($callback);
update_option($option_name,1);
}
}

//Deactivation Hook
function ddt_theme_deactivation_hook($theme,$callback){
$GLOBALS[$theme . '_deactivation_hook_fn'] = $callback;
$action_fn = create_function('$theme',' call_user_func($GLOBALS["' . $theme . '_deactivation_hook_fn"]); delete_option("' . $theme . '_active");');
add_action('switch_theme',$action_fn);
}

0 Comments

You must be logged in to post a comment.