A collection of musings about technology, animation, and design.

Easy Digital Downloads, a terrific product by Pippin Williamson,  is among the best options available for selling digital products using the WordPress platform. With its Software Licensing extension, you can easily develop and sell premium WordPress products, which is what I do. As of v3.5.22, though, plugin updates are cached in both the plugin_updates transient and a custom cache—a fact that left my scratching my head for a while when I was trying to implement a “Check for updates” link on my plugin.

So here’s the deal, I’ve been working on switching over completely to EDD, and that has meant updating my entire licensing system: server, plugin components, the whole kit and caboodle. I’m moving  a lot of customers over from my old licensing system, though, so I’ve been doing lots of testing to make sure that the transition will hopefully (fingers crossed) be as uneventful as possible.

Once I had all of the moving parts in place and old licenses transferred, I geared up for a test. I installed an old version (1.3.7) of WP Social Media Slider on my test site, and bumped the version on the license server up to 1.3.8.

We all know what is supposed to happen here, right? My test site is supposed to notice that there’s a new version of my plugin on the license/update server and give me a notification saying something like “There is a new version of WP Social Media Slider available.”

So I loaded up my test site. Nothing. No update notification.

Of course, that was no surprise. WordPress doesn’t check for plugin updates on every page load; it does it every 12 hours by default. If you load up your plugins page before that 12 hour mark hits, the site just loads up the results of the last query from a site option called _site_transient_update_plugins. If you want to force a plugin update check you have to either delete the update_plugins transient value on your site, or install a plugin that’ll force plugin updates for you (which, incidentally, is also by Pippin WIlliamson).

The built-in WordPress plugin update check is cached in the update_plugins transient.

I started out with the plugin method; I forced plugin updates. Just like before, my test site still couldn’t see the new version of the plugin on my server. At this point I wasn’t sure if my license server was broken, my code was incorrect, or I was going crazy.

So I commenced an all-out search. I spoke with EDD support. I scoured the source code for EDD Software Licensing. I double-checked the code in my plugin. I did a thorough study of WordPress’s built-in update system. My search revealed that everything was actually working properly; I had just been incorrect in my assumption that deleting the update_plugins transient would force a new update check. It does with most plugins, but not with plugins using the EDD Software Licensing update class.

This is because the EDD Software License update class actually maintains another cache for your plugin’s update checks, following using the key edd_sl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx where the x’s represent a unique cache key specific to your plugin. So when you delete the update_plugins transient (or use the Force Plugin Updates Check, which just deletes that same transient), EDD Software Licensing just repopulates the update_plugins with the value stored in the backup cache. Sneaky, eh?

A plugin-specific cache is stored in a separate WordPress option.

The EDD cache (that edd_dl_xxx… option) has no technical expiration time. It’s not a transient, just a regular WordPress option. The EDD Updater class refreshes it if it’s been at least 3 hours since it was last refreshed…but only at times when update_plugins runs—which, as we already talked about, only happens every 12 hours. So if you delete the update_plugins transient more than 3 hours after the EDD cache was last refreshed, you’ll actually get your fresh update check. Anytime sooner than 3 hours, you won’t.

And of course, when I initially deleted the update_plugins transient, I was still under 3 hours from when the edd_sl_xx… cache was created, so the plugin didn’t look for an update.

At this point I realized that the only way to force an update is to delete both caches. That’s what I did next, and the update notification showed up exactly as expected. Viola!

I’m sure there are benefits to the second cache, but it sure threw me for a loop for a little while! That’s one fact that I plan to commit to immediate memory, though, and hopefully I can save a few other people some consternation by documenting my adventure here.

All that said, I couldn’t be more pleased with the Software Licensing extension. Sure, the update cache took me a little while to figure out, but other than that it’s been smooth sailing. And smooth[er] sailing is exactly what I bought it for.