After a long delay, a new version of my PluginUpdateChecker library is finally ready for release. Read on to find out what’s new, or go straight to the download page.
For those of you not familiar with this library, here’s a short summary:
- You can use it to add automatic update support to any WordPress plugin.
- Especially useful for commercial plugins that can’t be hosted on the official WordPress.org repository.
- Free and open source.
- See the original post for more details.
Here’s what’s new in this version:
Added a “Check For Updates” Link
This version adds a new “Check for updates” link to the associated plugin’s row in the Plugins page. Clicking the link will trigger an immediate update check. You can change the link text by using the
puc_manual_check_link-$slug filter. To disable the link, return an empty string from the filter.
Debug Bar Integration
(Click to view full size screenshot.)
Judging by the comments that the previous version received, one of the things that it was really missing was better error reporting and debugging features. When it worked, it worked well. When it didn’t, it was ridiculously hard to figure out why.
To make debugging easier, this version adds a new Debug Bar panel that displays all kinds of useful information about the update checker, including all of its configuration fields, last check timestamp, cached update information and more. You can also click “Request Info” to download and parse the metadata file, which is a good way to make sure the URL and file format are correct. If you have multiple plugins using this library, each plugin gets its own Debug Bar panel.
You can set
true to make the library report errors that it would usually ignore. For example, if it gets an HTTP error while trying to download plugin information, it will usually fail silently and treat it as “no updates available”. With debug mode enabled, it will trigger a PHP warning instead. Debug mode will be enabled automatically if
WP_DEBUG is enabled.
Previously there was no good way to get information about available updates from the update checker instance. Sure, the updates would show up just fine in the WordPress UI, but if you wanted to get the update details from inside your plugin, you had to jump through quite a few hoops.
In this version, you can just call
getUpdate(). It returns an instance of
PluginUpdate if there is an update available, or
null otherwise. Note that this method uses the internal cache, so use
checkForUpdates() instead if you want the most recent information.
- Added a
resetUpdateState()method. It clears the update cache, last check timestamp and last checked version number.
checkForUpdates()now returns the update details, if any. It didn’t return anything in the previous version.
- You can use the new
puc_pre_inject_info-$slugfilter to modify the update just before it’s passed to WordPress.
- Store cached updates as generic
StdClassobjects to prevent the “Tried to use an incomplete object” error on sites that use an object cache.
- Fixed an incompatibility between this library and WooThemes plugin updater that would cause no updates to show up even if everything was configured correctly. The problem: both libraries use the
plugins_apifilter, but the WooThemes updater throws away the response returned by other plugins and breaks my update checker.
- Minor code clean-up.