I know that you can install plugin code as part of a theme, but I would like to do it the other way round. I’m developing a plugin that does a lot of non-public things, but I would also like to bundle a theme with it.
It seems from this question that it’s possible to use the plugin’s activation function to copy the theme files to the necessary place and then activate it using switch_theme, but there are enough aspects of this method where something can go wrong (e.g. permission issues when copying the theme files) that I feel this is something better handled by WordPress core.
Ideally, I hope there is a way that I can provide the theme files as part of my plugin, so that I only have to manage one project, and the user only has to update one plugin.
Read more here:: Install theme as part of a plugin