One of the things that many of us see (and are guilty of abusing) are WordPress plugin constructors.
If you’re using object-oriented programming, you’re likely familiar with constructors. However, the purpose they serve isn’t always clear at least in the world of WordPress.
The definition of a constructor well-defined in Wikipedia:
In class-based object-oriented programming, a constructor (abbreviation: ctor) in a class is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.
But here’s the key thing to notice for anyone working with constructors and object-oriented programming in WordPress plugin development:
It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.
And this is where many of us, and WordPress plugin developers, fail. We abuse constructors for a purpose they are not intended.




