[featured-image]Having covered the basics of a WordPress plugin from the php tags to the file header, I thought a quick discussion of the code types in which WordPress plugins can be written and which I have used.
There are two code types that can be used:
- Procedural Programming
- Object Oriented Programming
There has been many a flame war fought over which is better and which is worse, but in all honesty I believe that both can have their place and there is no one true way of coding.
I was going to cover the differences between the two types, but when I was researching for good definitions I came across an article by Tom McFarlin linking to articles he and Stephen Harris wrote on the coding paradigms which can be used with WordPress plugins.
I am not old, but my programming career (short as it was and now a few years in the past after I moved into being a consultant) tended to be with older languages such as Databasic and Visual Basic; I also self-taught myself Lua and later PHP.
In all of the programming/scripting languages I have worked with the code has been procedural; I’m not saying all of these languages are only procedural, just that all of the code I worked with was. As such I am far happier in a procedural world and so I have used this for writing my plugins.
I do intend to delve into object oriented at some point, and probably rewrite the plguins as I do, but the plugins I have created I needed to get done fairly quickly as I was using cobbled together code stored in a theme functions file; the number of WordPress sites I run has risen quite quicky and I needed an easy way to distribute the code between them (this also explains why I make all of my plugins multisite compatible). Most of the examples available online for WordPress plugins is procedural which made my choice easier.
The exception to this is widgets; WordPress widgets can only be written using object oriented programming so I will be covering some of this coding paradigm as the series progresses.