This vastly depends on the things you want to achieve with that. Most popular plugins also have a documentation for extending them so that might be a good starting point.
Hi Luka,
While you are right and most popular plugins have a good documentation on extending them, we face similar issues with plugins that are not as well documented. PErhaps you also ran into this problem and could let us know how you proceed in those cases?
Thanks!
If the plugin has no documentation and does not support extending it, I’m afraid that there’s no easy option to keep things easily maintainable.
You can always copy ‘parent’ plugin code and create ‘child’ plugin and modify things in there, however that’ll require some manual work once you want to update ‘parent’ code.
There’s also another option, and that’s to create a wrapper for the plugin in ‘theme’ directory. As an example, if plugin contains function called XX() and you want to modifying it’s behaviour, you’d create a wrapper function wrapperXX(), and store it somewhere in your activated theme folder. Inside of wrapperXX() you’d call XX() and do any modifications on it you need. Also, once you update plugin, you won’t have to modify anything (most likely) in theme’s folder. This approach however is not usable in all cases.
Nonetheless, as you’re probably aware, there’s no right approach for this, if you’re stuck with a plugin that is not extendable.
Haven’t really thought about the wrapper idea, but I believe that should work in our situation as changes are fairly minimal; a twitch in here and there, nothing major.
How does this work exactly? Is it by hooking the wrapper to the XX function or is it another mechanism?