how to create child WordPress plugin

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

add_action('Name-Of-Your-Action-hook','hook_function_callback');

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

add_filter('Name-Of-Your_hook','hook_function_callback');

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.

Leave a Comment