A few weeks ago we were at WordCamp Barcelona, where we talked to some of our colleagues and friends. As you may recall, we had the chance to share our experience in WordPress through 3 different talks. For those of you who couldn’t come to Barcelona during those days, I thought it’d be interesting to reproduce the contents of our talks. Today I’ll reproduce mine (which, spoiler alert, happens to be the best ?) here, but stay tuned for Ruth’s and Toni’s, which they’ll publish during the next few days!
How to Become an Evil WordPress Developer – Sinopsis
Most of the talks you can attend teach you how to be better—better developer, better blogger, better entrepreneur, better professional. But, who cares? Do we really want to be “better”? If your dream is to become evil, this is your talk. Here you’ll learn some of the most useful tips and tricks that’ll make your plugin the best while, at the same time, break your competitors’ and make them look ugly. Focus only on delivering the best user experience to your customers (who, by the way, are the ones who pay your salary), and don’t even think about being nice to other developers!
The World Has Gone Mad!
Have you looked around you lately? World’s completely crazy! And no, I’m not talking about president Donald J. Trump (someone who deserves a whole post about him)—I’m talking about our peers and, especially, what’s going on in the technological world.
Since the first PDAs came out, followed by iPhone’s first release in 2007, it looks like we’re super interested in making things smart. We want our phones to be smart, our TVs, our watches, our refrigerators… everything has to be smart. Except people, of course—they can be as dumb as ever.
In my opinion, there’s plenty of examples of stupid smart things targeted at stupid customers. Smart underwear, smart socks that never loose their partner, smart vessels, smart diapers that tweet when your baby peed itself! WTF?!
I used to think all this technological madness didn’t affect WorPress developers. We’re above this worldliness—we’re interested in important stuff solely! The REST API, good support, customer care, making WooCommerce great again… we’re perfect beings focused on relevant tasks.
Well, as it turns out, I was completely wrong. WordPress developers are no better than anybody else—they get things wrong and they can even do evil stuff. On purpose. Remember these lines: WordPress developers are dangerous! Trust none!
WordPress Developers Are Dangerous
A few months ago I described a problem we had with our new plugin, Nelio Content. Basically, this is what happened: one of our users opened a support ticket complaining because he couldn’t see the plugin as it appeared in our screenshots:
That’s what he saw instead (what a mess!):
That was completely unusable! After investigating the problem and studying what the hell was going on, we discovered that the offender was another plugin. In Nelio we are super nice people, that’s why we decided to get in touch with the developer of the other plugin and explain not only the problem that we found, but also how to fix it. As you can see in the previous link, we tried to contact him/her almost 5 months ago and … well, we’re still unanswered. The feeling that remained after that silence was similar to this:
It always makes us proud to talk about the WordPress community, to say that we are all friends and we help each other… but when a problem like this happens –a problem that can cause your customers to leave away from you– the only thing that I got from that community (or, better said, from that soulless developer) was silence.
Not anymore! ?
Best Worst Practices to Do Evil Things
After that bad experience, I decided to explore the dark side and be the one who makes the wrong things to end up breaking the plugins and themes of others. After all, if they can do it, why shouldn’t I?
If you want to be good at something you must learn from the best, and that’s what I did. For a few days, I reviewed all the support tickets I had received over the last few years and collected the reasons causing the errors for which our customers had contacted us. I got a good list of tricks and “good bad” practices with which to do evil on my own. These are the three easiest tips to implement and that will work best for you, little monster.
#1. Use CSS Viciously
If you’ve read the previous post where I explained the problem we had with Nelio Content and the other plugin, you know that it was all due to misuse of CSS stylesheets. As you know, the appearance of the components we add to an HTML page is defined through CSS styles. If someone modifies those styles, overriding the rules that come by default in WordPress or those that others have defined, you can break the appearance of the components that used those styles. For example, the problem that made Nelio Content look ugly was (in part) generated by the following CSS rules:
Using a global style reset, we make an HTML node to have the default properties we want. In this example, the damage is maximum because it applies a totally global reset. Note that you are not only resetting all span or div tags. No! Those rules are completely resetting all tags (and even some pseudo-elements) using the selectors
The next thing you can do if you want to guarantee the destruction of other plugins is to use CSS classes with generic names and specify the rules that suit you. If you’re a good person, your CSS rules most likely include some type of prefix so that they only affect the elements you’ve added. So, for example, if you want to define a “column” somewhere in your plugin, instead of using the
column class you would use something like
nc- is the prefix of your plugin (Nelio Content, in our case). But, of course, here we are not talking about doing things right, we want to blow up everything, so let’s use generic rules:
If you use generic names, you risk having another developer add their own rules after you and that these ones override yours. Avoid this with the
And to be even a worse developer, follow the advice that Dario Balbontin gave me. Be sure to set Comic Sans everywhere:
Doing this you go straight to hell… but there you’ll become the bro of Lucifer!
The best thing you can do (especially if you’re a theme developer) is to include the scripts directly into the page, typing the script tag inside the HTML and forgetting about the crap that WordPress requires. Also, I don’t know if you know that WordPress includes a lot of scripts that you can use. In addition to the well-known jQuery, there are several libraries like jQuery UI, Backbone, underscore,… ready to be used by any developer. Well, don’t waste your time looking at what WordPress offers; when you need anything, pack it in your own plugin and ignore the old and outdated versions that are in WordPress:
Even better, suppose you’re going to use the latest version of jQuery, which is the most cool. Why are you allowing other plugins to enqueue the default version of jQuery? Best thing is to make sure that version is not available using the
wp_deregister_script function that includes WordPress:
By doing so, we make sure that the WordPress version of jQuery does not collide with yours. Okay, okay, we agree that doing this will cause all other plugins that depend on jQuery to fail, since jQuery will no longer appear as available (you just deleted it). But… who cares? It’s all about doing evil, remember?
#3. Expand Your Evilness
Finally, my last tip today is that you apply the previous tricks on as many pages as possible. For example, it is quite common for plugins to define their own admin pages. Some examples admin pages of Nelio Content could be the settings page or the editorial calendar:
Usually, you only add the scripts and styles that these pages need when the user is visiting them, and avoid adding them when users are in other locations:
But, of course, let’s not forget that we are trying to harm other developers work, so better don’t add any control on this. If you don’t worry about adding these controls, your productivity at work will escalate, since you will no longer have to waste time writing code that “prevents” your things from appearing on other people’s pages.
Doing things wrong in WordPress is very simple. All you have to do is to ignore the guidelines and do everything as you want, without worrying at all about the consequences of your actions. So, remember:
- write CSS rules in the most general way you can,
- include scripts without WordPress complexities (forget about registering, enqueuing or specifying dependencies…),
- and try to do all of this on as many WordPress pages as possible.
For things to go well, all developers need to be good people and act by following the WordPress rules. But doing evil is so easy and tempting…
By the way, notice the irony throughout the whole article. Please, follow the style guidelines and WordPress rules! Seriously, don’t be evil developers!
Featured image by Charles Rodstrom.