WordPress Plugins - Virginity Lost

WordPress plugins. Incredibly useful to use when you can find the right one. Incredibly annoying to build. Especially when popping your plugin cherry.

So today I want to share my first attempts at making a usable and useful WordPress plugin.

(I’ll include links to my Github - but please note that these plugins are not supported in any way and are not available on the WordPress Plugin repository)

But first…. What are WordPress plugins?

WordPress.org defines a plugin like this:

A WordPress Plugin is a program, or a set of one or more functions, written in the PHP scripting language, that adds a specific set of features or services to the WordPress weblog, which can be seamlessly integrated with the weblog using access points and methods provided by the WordPress Plugin Application Program Interface (API).

But it’s a little more complicated than that and there are some great guides already out there for plugin development:

  1. The Official WordPress Guide
  2. WPMUDev: Ultimate Guide
  3. TutsPlus: Create a Custom WordPress Plugin

Time to move on to….

Why write a plugin?

I started working on a blog called Electric Thoughts in a Digital Era and immediately ran into an issue with some specific requirements. For example, a social sharing plugin that included Amazon’s Send to Kindle functionality and a plugin to display selected posts in the sidebar. Question is, which developer rule did I break by deciding to write the second one by myself? Answer right at the end…

Plugin #1: Social Sharing

This one isn’t too bad, only because I adapted it from the Add Twitter, Facebook Like, Google Plus One Social Share plugin by BeingMaverick - just so that I could add the Send to Kindle button. This Send to Kindle functionality is similar to the basic javascript widget that Facebook, Twitter, and Google Plus use so it wasn’t to difficult to implement within the plugin. I think that if I had to rewrite the whole thing, I would have gone in a different direction and probably over-complicated it to avoid adding all that javascript. Sometimes I create a lot of chaos in my search for simplicity and I really don’t like plugins that include too many libraries.

See the code on Github

The brief was to create a plugin that allows a user to select featured posts. Something I’m sure that was done before. Of course being a developer, I decided I could do it better.

I couldn’t.

At least, not at the time. The plugin saves a comma-separated string of post ID’s via a display list of posts in the admin panel. Pagination isn’t implemented and only the latest 10 posts are shown. But the actual display of those selected posts works just fine.

See the code on Github

Lessons learned

Both of these plugins are very simplistic and in the second case barely functional. But they do highlight the two ways that can be taken when starting plugin development. Adapting existing plugins or diving straight in without a net. Route one (adapting existing plugins, like Akismet) is the easiest and, in my opinion, the best route to take.

Oh, and the developer rule I broke for the second plugin?

“Don’t Reinvent the Wheel”.