I like to create child plugin..
Explanation :-
I have one parent plugin named X. This will work independently (like other existing plugins).
Now I decided to add some extra features to that plugin X (think of it as an upgrade). So I want to create extra features by way of another plugin Y, which will depend on (and inherit from) X.
This plugin Y will not work with out plugin X.
How can I do this?
the Best way to do this is have your X plugin made with its own hooks for actions and filters so new plugins (in your case Y) could interact with plugin X’s functions and data.
Defining your own hooks is fairly easy and simple.
Action Hook
from the codex:
example of a new action hook:
Now we can interact with that function and use its arguments ($args1,$args2) using ‘Name-Of-Your_hook’ hook
Filter Hook
from the codex:
example of a new filter hook:
Now we can interact with that function , filter $output use and its arguments ($args1,$args2) using ‘Name-Of-Your-Filter-hook’ hook
A good example to that would be contact form 7
Addon
and many more which all (most) are plugins that extend the functionality of Contact Form 7 based on its hooks.
Make some hooks in your parent plugin to which the child plugin can attach their own function. Also wrap the child plugin in
if(function_exists('parent-plugin-function'))
orclass_exists
if its a class.I just went through myself and I had so many changes that I couldn’t just override the actions.
I created this tool that allows you to create a child plugin like a child theme. You can make updates to the plugin and still update it without losing your changes.
I’m posting this here because it relates and hopefully becomes useful to the next person who runs into this issue.
https://github.com/ThomasDepole/wordpress-child-plugin-tool