WordPress

Simplifying always helps

As you may recall, I used a boilerplate plugin template for my WP Blipper Widget. It turned out to be the most complicated thing in thw world, with me not knowing where to put any of the code.

I had a class to do the settings on a settings page in the WP settings menu, but it seemed that the object saving the settings on the settings page wasn’t the same object I was using to create the Polaroid|Blipfoto API client; this object was uninitialised and so the client couldn’t be created. What to do? Simplify.

A bit of poking around the internet later, I discovered that I was over-complicating things even more than I could possibly have known: all I needed for a widget was one PHP file, not a whole load of them. I was calling the wrong functions for registering widgets and all sorts. I started again.

Now, I have one PHP file, a read-me file and a licence file, and that’s it. The settings are set in the widget itself in the widget backend, I use the Widget API to register the widget, and the latest blip from my Polaroid|Blipfoto account is displayed in a widget in the sidebar of my test blog. Amazing.

Now, I just have to resolve the issues listed in GitHub, and I’m sorted.

It’s such a relief not having to use that unwieldy boilerplate any more. Next plugin, whether it’s a widget or not, will be built entirely from scratch (by which I most likely mean cobbled together from the internet), so I will have an understanding of what is going on.

Leave a Reply