0

I'm using a plugin (Paid Memberships Pro, but that shouldn't matter), and I need to overload a function in that plugin. I'm writing a custom "plugin" that changes certain parts of the Paid Memberships Pro plugin. Most of this works well. I can write templates that take priority over their counterparts, but when I write a function I can't call it from the other plugin. I imagine this is due to security or something, and intentional.

My question is: is there a good way to overwrite certain plugin functionality from a different function? I want to be able to update the original plugin and not lose functionality (otherwise I would literally just overwrite it). If you need to see any code I've got it handy.

1 Answer 1

1

The best way to add functionality is to decompose the plugin and seperate the behaviours. If the plugin is not designed with extensibility and customizability in mind you're going to have a hard time, especially if you want updates to have no breaking changes.

For instance: you might need access to a private function or property, you can't do that if you inherit/override. The function or property might even be gone when you update to a new version of the plugin.

Inheriting from a class that is not abstract or designed to be inherited from is a code smell.

1
  • Thanks Frits, this is what I ended up doing - essentially just pulling the plugin apart and rewriting the parts that I needed to. Losing upgradability is a pain, but not the end of the world.
    – Spencer
    Commented Jun 5, 2013 at 17:23

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.