WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 14 down vote accepted

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:

Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points, using the Action API.

example of a new action hook:

Function whatever(){
   //regular stuff you do normally 
  do_action('Name-Of-Your-Action-hook', $args1,$args2)
  //regular stuff you do normally

Now we can interact with that function and use its arguments ($args1,$args2) using 'Name-Of-Your_hook' hook


Filter Hook

from the codex:

Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.

example of a new filter hook:

Function whatever(){
   //regular stuff you do normally 
   $output = apply_filters('Name-Of-Your-Filter-hook', $output,$args1,$args2)
  //regular stuff you do normally

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

  • Contact Form 7 - Campaign Monitor Addon
  • Contact Form 7 Dynamic Text Extension
  • Contact Form 7 Calendar
  • Contact Form 7 Textarea Wordcount
  • Contact Form 7 Customfield in mail
  • Contact Form 7 to Database Extension

and many more which all (most) are plugins that extend the functionality of Contact Form 7 based on its hooks.

share|improve this answer
Thank you. This is a very detailed and well written solution. My only thoughts are that you could use a clearer name for Function whatever() ... still a great answer, THANK YOU – Metagrapher Oct 2 '15 at 15:21

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')) or class_exists if its a class.

share|improve this answer
I don't think this is a good solution, since the whole reason one would like to have a child plugin rather than modify the original plugin is so that you don't have to modify the original (or "parent") plugin. Hooks in the parent plugin for extensibility are nice, but the asker's solution could not rely on them. (...as I and many others are surely in the same boat.) – Metagrapher Oct 2 '15 at 15:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.