When to delete a theme created database table?
-
I need a custom database table for my theme and are thinking about what the best practice is in this case when it comes to when it should be created and when it should be deleted.
There are not very many guides about this. Most guides and tutorials about this topic are about how it’s done with plugins and plugin development. Not themes.
But this is about a theme. My first thought was of course “It should be created when the theme is activated (
'after_switch_theme'
) and deleted when it’s deactivated ('switch_theme'
). But then I realised that that’s not very good. As for with plugins, deleting all data on deactivation is not very good since a lot of people are only temporary deactivating themes and plugins and loosing all data then would be bad.So, it should be deleted on theme delete. But I can’t find a hook for that.
What is the common practice on how to do this?
- The topic ‘When to delete a theme created database table?’ is closed to new replies.