I didn’t feel much like tackling the code refinement today, so instead I did a little bit of work on the administration menus as well as added some options to customize the plugin’s behavior.
Here’s a quick shot of it in action:
It’s pretty simple right now, as I just wanted to get a working version first, then I’ll play around with it.
Some interesting things I found out today:
For some reason, I couldn’t get the
activate_ action hook, nor the
register_activation_hook() function that wraps it to work. My goal was to add the required options to the DB when the plugin was activated (if they didn’t already exist), and delete them when the plugin was deactivated (so as to avoid cruft in the DB from uninstalled plugins). I couldn’t get it to work using either of these methods, and a quick googling didn’t turn up anything useful, so I’ll just have to look into it more at a later time. For the present, I’m adding the options to the DB (if they don’t already exist) by declaring them at the top of the plugin file. Aesthetically, I don’t really care for this because it means that the conditional statements to check for the existence of the options in the DB will run every time the plugin loads (which is every time any page reloads in WP). Seems a little inefficient if you ask me, but it appears to be the way several other plugins are written (based on a quick peek at the source of a few other plugins I’ve got installed).
Tomorrow I’ll be refining the options menus and moving on to the testing.