I tend to defend procedural code for WordPress plugins… not because I dislike OOP, but because almost all WP plugins I see follow the singleton pattern.
One single instance allowed, which contains a bunch of methods that are subscribed to some actions and filters.
Then, all the plugin does is call that instance and do $plugin->run().
I feel that this is just nonsense. The same can be achieved creating simple functions that are subscribed to hooks.
Want to avoid collisions? Use namespaces.
So, I am asking what design pattern do you follow to make your OOP plugin for WordPress that you are proud of to share with the loving WP community?
Why is your pattern better than procedural code?
Please provide examples if possible.
Thank you!
[ad_2]