29 Jan
Since updating to WordPress 2.1 I’ve been keeping my eye on both of my current active plugins: Bible Verse of the Day & Feed Locations. They both seem to be working fine (and I’ve heard no complaints yet from users) so I’ve added them to the compatibility list.
The rest of this post is a technical description of updates done to the Bible Verse of the Day plugin. If you’re not a plugin developer or not interested, the short of it is that the 3.0 version plugin has been released with a bunch of updates and improvements. This release requires WordPress 2.1 to work, so if you haven’t updated WordPress, don’t update this plugin. If you have, grab the update here. The zip file now contains 2 PHP files, extract both into your wp-plugins folder.
On to the tech stuff…
However, in the process of checking, I was having a look at the Verse of the Day code, and I thought it was time for an update. The first thing I did was wrap all the code into it’s own class rather than prefixing the functions with wp_ as per the suggestion in this Codex article. The only code exposed directly is the wp_votd() function and the instantiation of the verse of the day object.
The function now extends a class called plugin_base which is a class now contained in a separate file in the zip download file. This contains a basic framework for building plugins. My plan is to use this as the basis for any future plugin development, and put any common functions in there. As is stands, all it does is by default register the activation & deactivation hooks for the plugin and setup the options page if it needs one. I’m also interested in a standard base plugin class that all developers can use, if anyone knows of such a thing, please drop me a comment.
One other change was the removal of the support for Hemingway Blocks. This was done because in the next release (3.1) I’m going to introduce support for WordPress Widgets, which does basically the same thing. This is not set in stone though, if someone desperately wants to have the Hemingway support I’ll put it back in.
The last change, and the one that makes this plugin now require the 2.1 version of WordPress is the implementation of the pseudo-cron function. It was mentioned in the release notes, but there wasn’t much in the way of details. A search of the Codex didn’t reveal any doco, so I can only assume it’s undocumented as yet (please correct me on this!). It was actually surprisingly easy to setup the daily schedule once I’d dug into the cron functions and got my head around what was going on. I’m planning to post something shortly on how use the cron functions, but briefly, all I needed to do was have the method the updates the verse content defined as an action:
add_action('wp_votd_update_contents', array(&$this, 'update_contents'));
That is set in the constructor of the plugin’s container object. Then in the activation hook method (so it’s only called once, when the plugin is installed) the schedule is set:
wp_schedule_event(0, 'daily', 'wp_votd_update_contents' );
Not too complicated, but there are a number of other options and other things you can do with the new cron functionality, but as I said, that is for another day.
I’ve been running the new version of the plugin now for a few days and making updates & adjustments as needed and I now think it’s stable enough to release. As always, please read through the instructions and let me know about any bugs or problems.
God bless.
Add New Comment
Viewing 2 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)