Sharing what I’ve learnt so far:
But I’m not sure if we have a use for it, as what we want to have is many WP plugins inside one repo, but these plugins don’t need to be
composer packages to be used by our general plugin.
1. One plugin to contain them all
In this solution, proposed by Luis, the main plugin is in the root of the repo and the other plugins will be inside that plugin, in a plugins folder, and will be directly imported by the main plugin.
- We still can publish the minor plugins on its own just keeping the WP install/activate logic out of the main class, so the class can be directly imported by the main plugin.
- The way the main plugin uses the minor ones is very simple, just require if not yet required.
- If a blog already has a minor plugin installed, the code of that plugin would be duplicated.
- We would need to use symlinks in development in order to work with the minor plugins as installed independently
- We might need to handle some conflicts that can appear between minor plugins if they are installed independently and the main plugin is also installed.
2. One plugin to rule them all
All the plugins live inside the packages folder of the repo (including the main plugin), and the main plugin will have the minor plugins as dependencies, so in order to use the main plugin in production all the minor plugins should be installed. The main plugin will act only as a manager and it might install any minor plugin required.
- There shouldn’t be conflicts between the main plugin and the minor plugins when installed.
- No code is duplicated in production.
- All minor plugins must be installed in order for the main one to work. To ask the user to install them is highly inconvenient. If we install them with the main plugin it might be a bit shady.
- We would need to use symlinks in development in order to work with all the plugins
Things to consider
Minor plugins might need to save settings/transients
We should be careful about removing the settings/transients when uninstalling/deactivating a minor plugin if the main one is still installed or viceversa.
Minor plugins might need an UI in order to be used
Maybe here we should declare a general admin page in the menu called
Frontity, no matter if we are dealing with the main plugin or with minor plugins, and for each of the minor plugins declare a subpage. So the UI for the main plugin would be a list of subpages created by the minor plugins.
We could also prevent the minor plugins from creating their UI in case the main plugin is installed, and with the main plugin render all the UIs needed in one page, if this is more suitable for our needs.