This is what I am trying to do:

Lets say I have a parent plugin, Plugin X, and a child plugin (an extension, whose purpose is to enhance X) Y.

There is a function in plugin X that I wish to add code to, from plugin Y. In other words, I am writing plugin Y.

Using WordPress, I know there is a way to override Plugin X's like such:

  • remove action plugin X's function
  • add action Y's function
  • function thatIgotfromXmodified { }

But is there any other way? I don't want to have to modify my plugin everytime Plugin X's author changes the functions code, so that users of my plugin get all the benefits of X's new version.

It looks like if Plugin X's author adds something like an action filter, I can hook into that somehow and add code there? Not sure if it matters or not but the function I am editing is backend code (ie no output to user).

Suggestions? Ideas?

  • Is the function in the plugin pluggable? Does it have a function_exists conditional around it? Aug 25, 2012 at 1:55
  • @BrianFegter No. I don't want to plug the whole function either, since its large, and I just need to add a couple lines of code. Is there something that Plugin X could add to their function that would allow code to be added at a particular point in the function by a extension?
    – Chris
    Aug 25, 2012 at 2:00
  • If you're looking to DO something, they would need to add an action. If you're looking to CHANGE data, they would need to add a filter. Aug 25, 2012 at 2:36

1 Answer 1


This would depend on the way the plugin was structured. If it is just procedural then your pretty much out of luck. If it is written within a class you can extend or create a new instance of it and override methods. As an example in my media tools plugin I use a portion of Regenerate Thumbnails by calling

 if ( class_exists( 'Regenerate_Thumbnails' ) {
        $regen = new Regenerate_Thumbnails();



To override a method:

 if ( class_exists( 'Regenerate_Thumbnails' ) {

   My_Class extends Regenerate_Thumbnails {

         function __construct() {

     parent_function_to_override() {
        //do stuff

$barorfoo = new My_Class();

Again this totally depends on the way the parent plugin is constructed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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