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

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?

share|improve this question
Is the function in the plugin pluggable? Does it have a function_exists conditional around it? – Brian Fegter Aug 25 '12 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 '12 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. – Brian Fegter Aug 25 '12 at 2:36
up vote 0 down vote accepted

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.

share|improve this answer

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.