I created a plugin that insert a field on the customise theme options. Since I use
add_action( 'customize_register', 'myregister' );
to create the customise, should I use
remove_action( 'customize_register', 'myregister' );
when the plugin is deactivated or uninstalled?
The Plugin API has hooks for that:
You can use
register_deactivation_hook
to run a function when the plugin is deactivated.For uninstall, you have two options. Either
register_uninstall_hook
or add a file calleduninstall.php
in your plugin folder.I would not recommend delete plugin options on plugin deactivation though, the user might not know that he is losing his saved data.