Disable WordPress Plugins update indicator for inactive plugins

I have to really tip my hat to the guys that work hard on the core WordPress code at Automatic. In the last 12 months they taken the system to new heights with a complete redo of the admin interface. Adding many features to extend the core so that developers like myself can extend things even further.

Take for example the nice little number displayed on the Plugins menu item when some of your installed plugins are out of date. What a nice little feature. There is also an update display on the actual Plugins page the little yellow-ish box below a plugin row to indicate there is an update and the user needs to take action. From a usability stand point I think this sort of forward thinking is the reason I keep hacking in WordPress instead of other CMS-type systems like Drupal, Joomla, eZ Publish, etc.

wp-plugin-list-update-indicator

WordPress Nav Update Indicator

But I do have a major annoyance with this ‘feature’. Like many other WordPress users I have man plugins installed. At any given time I will have a third of the plugins disabled maybe because I was testing things or maybe I deactivated the plugin but didn’t want to uninstall it. My annoyance is that the plugin update indicators work on all plugins even those you don’t have active. Not good. Worse on the client sites I support I really don’t want the client to need to worry about updating inactive plugins.

Sure I know there are at least half a dozen plugins that will completely turn off the plugin and WordPress core update nag indicators. But I really don’t want that. I just don’t want to see update nag on those plugins I’m not currently using.

So I did some research on this lazy Sunday afternoon and figured out how to hide the update indicator on those inactive plugins. The code below will hide these inactive plugin from the update counter. When the plugin is re-activated the plugin update indicator will once again show in the sidebar menu and on the plugins listing.

The Code


function update_active_plugins($value = '') {
/*
The $value array passed in contains the list of plugins with time
marks when the last time the groups was checked for version match
The $value->reponse node contains an array of the items that are
out of date. This response node is use by the 'Plugins' menu
for example to indicate there are updates. Also on the actual
plugins listing to provide the yellow box below a given plugin
to indicate action is needed by the user.
*/
if ((isset($value->response)) && (count($value->response))) {
// Get the list cut current active plugins
$active_plugins = get_option('active_plugins');
if ($active_plugins) {
// Here we start to compare the $value->response
// items checking each against the active plugins list.
foreach($value->response as $plugin_idx => $plugin_item) {
// If the response item is not an active plugin then remove it.
// This will prevent WordPress from indicating the plugin needs update actions.
if (!in_array($plugin_idx, $active_plugins))
unset($value->response[$plugin_idx]);
}
}
else {
// If no active plugins then ignore the inactive out of date ones.
foreach($value->response as $plugin_idx => $plugin_item) {
unset($value->response);
}
}
}
return $value;
}
add_filter('transient_update_plugins', 'update_active_plugins'); // Hook for 2.8.x
//add_filter( 'option_update_plugins', 'update_active_plugins'); // Hook for 2.7.x

A note on the ‘add_filter’ lines just above. Seems there are two different hooks depending your the WordPress version. If you are running version 2.8.x or newer you should be safe to use the first add_filter line. If however you are still using 2.7.x then comment out the first add_filter an use the second one.

Installation

I really don’t plan to turn this into an official plugin for WordPress. So the simplest method of installation is to add it to your theme’s functions.php file.

PHP Function Index new release

One of my favorite OS X utilities has just been update. I was lucky enough to find this tool just a few days after converting from being a long time Windows user to the Mac platform.

Being a web developer and using primarily PHP as my language of choice I had at my disposal a few desktop tools to assist in my development. I mostly used UltraEdit as my editor for PHP code on Windows. Along with the PHP compiled Help files for looking up PHP functions I couldn’t recall off the top of my head. On the Mac the support for compiled help (.chm) barely there. Sure there are a few chm viewers like Chamonix and Chmox. What is lacking however in these utilities for Mac is the display of comments. Sometime it’s the user comments that make all the difference when using a new PHP function or library.

Somehow I came across a link to the ARTisSoftware site. I don’t really remember. I just know I’ve used the little PHP function index ever since.

It comes with a script to use as part of BBEdit. Once installed I just move my cursor to a word to lookup. Then invoke the tool via alt-apple-period. The PHPfi window will open to the listing for the given PHP function I’m interested in. PHPfi also comes with a similar script to be invoked from TextMate. The index is built from the PHP HTML help files you download from php.net. Just unzip them into a folder on your mac. Then tell PHPfi to build the index.

What I would like to see is this engine used for other languages like Ruby or even some common tool like WordPress. Still given it works very well for PHP I consider it a steal for $8.50.

So give it a try. PHPfi version 2.1 is the latest. http://www.artissoftware.com/phpfi/