Lessons learned from writing a premium WordPress plugin

About 3 months ago, I had a killer idea for a WordPress plugin. I had never written a plugin before and my first venture was a daunting one to say the least. I have learned a lot over the past 3 months and so I’d figure I would share some of my experiences with you.

Lesson #1: v1 is Always Terrible

Yeah that’s right, I said it. When I finally released v1 to the public, there were a lot of problems. PHP 5.2 support? Meh, who needs it? I know a lot of premium plugin developers have dropped PHP 5.2 to take advantage of awesome features like closures, however, since my plugin is sort of an “add-on” for another WordPress product, I wanted to maintain compatibility as much as the other service. Needless to say, the first person who complained that their site got whitescreened after activating, definitely was not happy. Also, WordPress multisite support was also not included. Heck, I’ll honest, I had never even installed multisite before someone mentioned it on the support forums. Whoops. Point being, you will always miss stuff in version 1.0. That’s why we have version numbers! Software was designed to be improved. Don’t beat yourself up too much because things aren’t perfect from the starting line.

Lesson #2: You Know Nothing Jon Snow!

Specifically, in regards to how people will use your software. If you develop a product that allows for any user customization at all, someone will think of a way to use, abuse, and re-use your product in ways you could have never imagined. The feature that took me most by surprise, was the ability to include the plugin in a theme. First of all, MIND BLOWN! I never in a million years would have thought that my creation would be so cool, that someone would want to include it in a theme. Especially within the first month?! After recovering from a mild excitement induced heart attack, I then had to find a way to make everything play nice when not activated like a normal plugin.

One thing that I’m grateful I learned because of this, is the order in which hooks and filters are fired. For example, the action hook fired after the `functions.php` is loaded (`after_theme_setup`) is `init`. 99% of plugin and theme functions can be fired on or after `init` without any consequences and still have access to everything they need. All that was required to make my plugin “includable”, was moving any actions from `plugins_loaded` to `after_theme_setup`. Also, actions and filters are freaking cool! I never really understood how to utilize them effectively until I started using them on a more regular basis. Now I find myself skimming through other plugins looking for hooks and filters to extend their functionality too. It’s a great feeling when you find a problem and a quick glance at the codebase assures you that everything is extensible. Easy Digital Downloads is a great example of a plugin with tons of hooks and filters. Pippin has definitely been an inspiration to the way I look at plugin development.

Lesson #3: Open Source is your Friend

For the first couple of versions, I didn’t release the plugin on GitHub. Which ended up hurting me more than I thought it would. The day that I pushed the codebase to GitHub, something strange happened. I felt obligated to track every change I made. If I read a support email or just ran into a bug while testing, I would go to GitHub and open an issue. Even if the fix was just 1 line of code, I would open one. That small amount of perceived accountability, the knowledge that now anyone could look over my code and judge my decisions, made me better. While I haven’t received any contributions yet, I’m excited for what the future holds and more and more people start to use my creations.

A lot of people also have problems with putting “Premium” plugins in open repositories. First of all, everything used with WordPress is automatically subject to it’s license, the GPL. This means anyone can take the code and copy, modify, sell, distribute, etc, as much as they want. So if people really want it, they’ll get it. The benefit of having a project that anyone can contribute too, vastly outweighs any negatives in my opinion.

Lesson #4: You’ll Become an Addict

I finally understand why Pippin has written 100+ plugins in just a few short years. I’m hooked. Just the other day, someone over on a reddit thread in /r/WordPress was looking for a plugin to do something fairly simple from the admin area. I looked at his problem, thought about it for a minute, and then replied telling him to give me an hour to see what I could do. This led to the creation of Post Author Link, which I will eventually release on WordPress.org for everyone to enjoy. It’s a small plugin now at less than 30 lines of actual code, but it works! It solves a problem in an elegant way without being overly complex. The beauty of it is, that I wanted to write it. I wanted to help this random guy on the internet. For the first time, the kindness bug from the WordPress community infected me and I felt compelled to give back however I could. Now I catch myself browsing through sites like Reddit and WP Chat actively looking for people to help. WordPress has given me so much to become successful that I’m excited to give back to the community in any way I can.

Conclusions

Overall, I’ve learned a lot. I’ve learned to deal with abuse from my plugin website’s contact form, 700,000 API calls in less than a month that shut down my website, etc. The little things. My advice to anyone out there thinking about writing a plugin, premium or otherwise, do it. Stop thinking about it and do it. You’re never gonna learn or grow if you sit on your hands and think about all the things you could do. You are the only person standing in the way of your success. Don’t be afraid to screw up, because it happens to the best of us.