Can we code in Object-Oriented Programming (OOP) for WordPress

Tutorial/ WordPress, February 26th, 2021
597 Views
Image created in Canva

Can we code in Object-Oriented Programming (OOP) for WordPress ?? Answer is – NO, not recommended, It may break existing hooks and filters.

I just woke up in the morning and got a call form some company, they were looking for Object-Oriented Programming (OOP) for WordPress, might be they have mistaken but answer is NO. We can’t code or use oop concept here.
The acronym OOP stands for object-oriented programming. OOP is a programming paradigm, meaning it’s another approach for how you architect and build code. OOP is programming that is oriented to (focused on) objects. It seeks to emulate the real world.

Do I need to write code in OOP?

No. You can write code in procedural, functional, or OOP. The choice is yours. WordPress is built on procedural. There are some OOP implementations. Some plugins are built in static function wrappers while others are in OOP. But I am talking about third party plugins. When you are writing your own plugin you can write it in core php and create your own modules.

You don’t need to write OOP. However, it can be very helpful in your career to learn it.

Why learn OOP

If you want to grow in this profession, learning OOP will help. Outside of WordPress, OOP is popular. If you want to build in Laravel, Symfony, Zend, RoR, Drupal, and others, then you’ll need a solid mastery of OOP.

Learning OOP will help you to read and adapt more code. You’ll be able to go to other repositories and see how others are solving problems. You can bring those techniques and solutions back to your projects, adapt them, and make your sites better.

Reference, You can learn oop concept here https://knowthecode.io/labs/introduction-oop-wordpress

Comments
Manish Pushkar Jha
*Do you have any concerns? Write me at hello@manishpushkar.com