When I was working on the designs for the new WordPress Block Directory, I thought a bit about how it could be integrated with themes, which currently don’t allow inclusion of blocks and plugins (for good reason — it would suck to lose content on theme switch!). With some careful planning, I think we could safely introduce block dependencies into themes. Here’s what I’m thinking.
Themes can specify blocks.
When creating a theme, you can specify specific blocks from the Block Directory to include with your theme. These could be blocks you’ve written, or other blocks you’ve accounted for in your theme styles.
Activate blocks on theme activation.
When someone activates (not installs) your theme, WordPress can silently download the blocks from the Block Directory.
Delete unused blocks on theme switch
If someone is trying out a bunch of themes, and each of those theme includes block dependencies, we don’t want to install a dozen or more blocks someone might not use. If someone switches to a new theme without using included blocks, WordPress could silently delete them from the site, just as it silently installed them.
Keep used blocks on theme switch
If you’ve used any of the blocks a theme provides, they remain installed and activated when you switch themes.
Third party blocks = third party dependency management
If the blocks you’re including aren’t in one of the Block Directory, you’ll need to rely on a third party dependency management system, similar to TGM.
How does this sound? As a theme author, would you like to see a dependencies system like this?