How to develop OOP plugins for WordPress without using the Singleton Pattern?

[ad_1]

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]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer