What I Learned About Myself Writing Plugins for WordPress

Self Introspection with Wordpress

Oh, the things you will learn (about yourself)

 
Wordpress 4.8 Coding Standards site screepcap.

I’ve developed many custom WordPress plugins and themes over the years to suite clients’ needs, and only partway through that did I become acquainted with the official WordPress Coding Standards. This is a set of documents outlining the expectations of syntax and style set by the official WordPress team to (ideally) be followed by the world at large. What started as a desire to “go completely in line” with my code turned out to actually be something of a voyage of self discovery, and here’s what I found.

Easy on the Eyes is Magical

I may be turning into my mother since I’m quickly considering 16pt type a great size for all websites. Ha! Initially I found it slightly burdensome that WordPress asks for certain formatting regarding spaces and tabs to be adhered to, but quickly I became obsessed with it.

Look at the little “arrows” in the above screenshot from their docs and how they all line up vertically. This is so easily done with the Tab key, and I have been doing this always ever since. It’s so easy to read! Compare it with this example:

$uglier = array(
    'first_fruit_is' => 'apple',
    'an' => 'orange',
    'another_fruit_is' => 'banana'
);

Not impossible, but as your eyes get used to well formatted things they get a bit lazy. At this point my eyes are not into doing any more work than they have to. My only gripe is that no one except WordPress developers seem to do this. Actually if I could have a second gripe, it would be that I wish someone would invent a macro or some kind of code filter that would turn everyone else’s code into nicely formatted code for me to work on. Then when I’m done, I can magically turn it back into the formatting that they prefer to read. If this exists already, please let me know because I am so ready with the hallelujahs to give.

When My Way “Wins”, Everything is Golden

Specifically here I am talking about the very silly but very real devotion that developers have to things like Tabs Vs Spaces. To outsiders it probably looks like the old Coke vs Pepsi thing, where you have to wonder can you even tell the difference? And, this is so petty – why u fight about dis?

So I’m slightly ashamed to say that yes I do care about camelCase versus snake_case! The answers are snake case and tabs please, which I will never say out loud as a complaint in person, but these are big wins when I get to use them. My love for snake case where_you_name_things_like_this goes back to my #1 point of being easy to read. I just find it incredibly easy to read when compared to camelCase whichIsWhereYouNameThingsLikeThis.

Seriously, I will do it, but inside I will be thinking that “I just can’t”. And tabs are required to get things lining up like point #1, so tabs all the way.

Now this is not to say that I won’t play ball with others who want to do things differently. If I join a team you can be sure I am going to go with the flow and try to produce uniform code whose author is undetectable. But I did learn from WordPress all about secret gloating and the little pedestal that we put our favorite things on, and that I’m not immune from that!

I Don’t Much Care for The Man

Who is “the man?” Well by definition “the man” is authority, but we rarely use the term when talking about the good things. We don’t talk about “the man” as the one who gets the roads paved, or drives the school bus.

No, every time “the man” is mentioned it’s a clear indicator that we’re bedgrugingly falling in line with something that’s been asked of us. When the reasons are dutiful, we go along with it. But when the reasons are muddy or the benefits soft, some people take a little creative license.

The way I learned (or again confirmed) that I’m one of those people who are interested in the big picture and turn a cheek on the man was from WordPress’s request for Yoda statements.

A yoda statement is one where you put the adjective before the subject. “Big is the elephant?” you might ask. It’s a valid question and I guess some people think that’s the better way to do things. But I am not one of those people.

Maybe I diagrammed too many sentences in my youth or it’s my lazy eyes again, but I just cannot get on the bus with yoda statements. If I can borrow that phrase from people half my age again, I literally just… can’t.

It’s a conflicting dance between wanting the gold star on your forehead for meeting the official standards, and wanting to avoid questions like “True it is, that the database is ready?” Be still, my pulsing brain. We have so much more code to write and I won’t try to retrain you for this thing that almost nobody else uses.

High Five me by sharing: Pin on PinterestTweet about this on TwitterShare on LinkedInShare on FacebookShare on Reddit

Last updated on