I’ve a plugin. And the next code:
operate activate_my_plugin(){
// my_option worth right here: 1
update_option('my_option',0,true); // I've tried with and with out final parameter
// my_option worth right here: 0
}
operate deactivate_my_plugin{
// my_option worth right here: 1
delete_option('my_option');
// my_option worth right here: 1
// or
// my_option worth right here: 1
update_option('my_option',2);
// my_option worth right here: 1
}
operate xyz(){
// my_option worth right here: 1 or 0
if(!get_option('my_option')){
// my_option worth right here: 1
update_option('my_option',1);
// my_option worth right here: 1
}
}
register_activation_hook(__FILE__, __NAMESPACE__ . 'activate_my_plugin');
register_deactivation_hook(__FILE__, __NAMESPACE__ . 'deactivate_my_plugin');
add_action('init','xyz');
The deactivation hook is certainly firing, however for some cause, it will not replace the choice to a brand new worth or delete it. What am I lacking right here?