WP settings as arrays

The first thing I thought I’d do with my WP Blipper plugin was the settings. Without the settings, I can’t get OAuth authorisation to use the Blipfoto API, so it seemed like a pretty basic thing to get up-and-running.

I looked on the internet to see how to do it. The WP settings API seemed the way to go. I got it working using individual database entries, but then I read that it’s best to use an array to store all the settings in one database entry. So how do you do that?

Well, it’s all very complicated, of course, and it refused to work for quite some time. It didn’t help that I forgot to remove the multiple invocations of register_setting. This meant that I saw some crazy behaviour: you only need to call it once per database entry. As soon as I twigged what I’d done wrong, I corrected it, and now my settings page is pretty robust.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.