Schedule Random Post Time

I’ll admit, I’m about as lazy a blogger as they come and when it comes to scheduling posts to be published in the future I really despise having to decide on what day and at what time the post should appear. After hacking a few other scripts to do something very similar I ran across a plugin called Date/Time Now Button created by someone named radiok. After checking it out I found it was pretty close to what I wanted but didn’t perform a random set. Since radiok already had the javascript worked out I just “adapted” that code to work the way I wanted it to.

Schedule Random Post Time adds a button to the post, page and comments that allows you to generate a random publish date. This plugin is useful for us lazy people that would rather not take the time trying to decide what date and time in the future to schedule a post for. Simply click the button and let it decide for you. It’s pretty simple really. Simply set the maximum number of hours into the future you want posts scheduled for in the settings, then just click the button and a random date between current time and your future time will be generated for you. Easy Peasy.

Installation is simple:

  1. Download the plugin from
  2. Copy it to the wp-content/plugins directory of your blog.
  3. Enable the plugin in your admin panel.
  4. Set the maximum number of hours into the future you want posts scheduled for.
  5. An option for Schedule Random Post Time will appear under Settings.
  6. Enter the verification code for each service you wish to use

If you like this plugin and want to support me, leave a comment or check out my donations and support page!

How To Add An Uninstaller To Your Plugin

On of the most annoying things I find about WordPress Plugins is that once you decide you no longer want to use one, simply deactivating the plugin, in most cases, still leaves behind a bunch of garbage in your database. Maybe you like to test a plugin to see what it does or maybe it sounded great but in reality it wasn’t quite what you were after. So you deactivate it and/or delete it thinking it’s gone right? Usually not. You might be left with altered database tables, indexes which now make your database inefficient, various settings and options that are now orphaned.

I recently decided I didn’t want to be part of this crowd. I wanted to give a reasonable option to my plugin users to 100% completely uninstall a plugin if they so chose. After a little research and some tweaking here’s what I came up with. It’s really rather simple.

There are 3 parts.
1. The uninstall form
2. The check for the uninstall submission
3. The uninstall itself

So here we go. First you need to create an uninstall form in your plugin. As you can see in the picture, I include a check box the user must check to confirm they want to uninstall the plugin. The form should look something like:

<form method="post">
<input id="plugin" name="plugin" type="hidden" value="plugin/plugin.php" />

	if ( isset( $_POST['uninstall'] ) && ! isset( $_POST['uninstall_confirm'] ) ) {

You must check the confirm box before continuing.


The options for this plugin are not removed on deactivation to ensure that no data is lost unintentionally.

If you wish to remove all plugin information for your database be sure to run this uninstall utility first.

<input name="uninstall_confirm" type="checkbox" value="1" />Please confirm before proceeding

<input class="button-secondary" name="uninstall" type="submit" value="Uninstall" />

I like to wrap this in a function called pluginname_form_uninstall() to prevent conflicts then add that to the plugin options screen. Next we need to check to see if the form was submitted.

if ( isset( $_POST['uninstall'], $_POST['uninstall_confirm'] ) ) {

Somewhere near the top of the plugin or before execution starts add a check of the $_POST vars to see if our uninstall option was submitted. If it was we call the third piece of this puzzle, the uninstall function itself.

function pluginname_uninstall() {

	delete_option( 'plugin_version' );
	delete_option( 'plugin_options' );

        // This is where you would remove and tables, indexes or fields you added when your plugin was first activated. Also anything else that caused modification to the database should be undone here.

        // Do not change (this deactivates the plugin)
	$current = get_settings('active_plugins');
	array_splice($current, array_search( $_POST['plugin'], $current), 1 ); // Array-function!
	update_option('active_plugins', $current);
	header('Location: plugins.php?deactivate=true');

This is pretty simple but it depends on what you’ve added to the database.

  • First use the delete_option function to remove any settings added to the wp_options table.
  • Next undo any SQL modification you made when your plugin was created. Any tables, fields or indexes added need to be removed or changed like your plugin was never there.
  • The final part deactivates the plugin and switches the user to the plugins management screen.

At this point the plugin can be activated again or deleted.

As you can this this really is fairly simple, I’m not why more developers don’t use something similar to this. I for one can’t stand to have a cluttered up database of things I don’t need.

WordPress 3.1 Finally Adds Long Awaited Admin Bar

I just got finished updating my blogs to WordPress 3.1, the latest release that’s been out for around two weeks now. The installation was painless and I have no real issues from themeforest wp themes to report yet. The first thing I noticed was the style admin bar which is a feature I think many will really like. Some won’t, but there’s a number of ways to turn it off. The easiest of which is to go into your personal profile options and just turn it off or you can change it display only in the admin section.

This release features a lightning fast redesigned linking workflow which makes it easy to link to your existing posts and pages, an admin bar so you’re never more than a click away from your most-used dashboard pages, a streamlined writing interface that hides many of the seldom-used panels by default to create a simpler and less intimidating writing experience for new bloggers (visit Screen Options in the top right to get old panels back), and a refreshed blue admin scheme available for selection under your personal options.

There’s a bucket of candy for developers as well, including our new Post Formats support which makes it easy for themes to create portable tumblelogs with different styling for different types of posts, new CMS capabilities like archive pages for custom content types, a new Network Admin, an overhaul of the import and export system, and the ability to perform advanced taxonomy and custom fields queries.

As I’m writing this post and getting it ready to publish I can tell there is a definite speed increase in editor interface which is good, it was starting to get bogged down. option panels I rarely use are all minimized and can be turned off via the screen option tab to clean up the editor interface even more.

Most of the other stuff I haven’t looked at yet, but I’m excited to play around with some of the new developer features and I can’t wait to see what the various frameworks can come up with now.

If you haven’t upgraded to WordPress 3.1 yet I certainly recommend you do. As always though, be sure to backup your database first, just in case.