I'm working on a website project using WordPress that requires a few custom plugins. I want to keep the plugins modular, but a few of them require similar functionality. So, I find myself with conflicting goals:
- Make each plugin self-contained and modular
- Don't repeat code
For example, I have a need in two different plugins to output <select>
elements based on a list of terms and some arguments. I wrote a function to accomplish this, but should I duplicate the function in both plugins? That seems like a maintenance nightmare, but if I don't, one plugin will depend on the other in a pretty arbitrary way. Is there some clever solution to this that I'm missing?