I'm currently building a WordPress plugin in which I need some functionality that already exists inside of another plugin. I was hoping to find a way to leverage that third-party code in such a way that if it received updates, I could easily update my own plugin to include them. Note that I don't want to have the plugin be a dependency that users are required to install before they can install and use my plugin. I'd prefer to shield users from this.

My question is what is the best way to accomplish this? Originally I had just ported the code I needed into my own plugin, with credit to the other plugin's author. This is not ideal as including updates would have to be a manual process.

Is it possible to utilize Composer for something like this? Is there some other solution I haven't thought of? I guess the fact that the code exists inside of a plugin, rather than a library, is what is throwing me off.


1 Answer 1


This really depends on the scoping of the code you want to use and whether there are actions or filters that encompass the functionality.

You should be able to check whether the code you want is available with a combination of class_exists() and function_exists() calls. But this will depend on whether the classes and functions you want to use are scoped as public, protected or private.

If you can determine that the plugin is loaded and are lucky enough that the code you want to utilise is wrapped up in an action or filter then you should be able to simply do_action or apply_filters based on the assumption that the other plugin will handle it for you. But this is an unlikely scenario I expect.

If the plugin and its classes you want don't exist, what are you going to do instead though, just not enable that feature?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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