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.
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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.
Media Tags 2.2 plugin for WordPress Released
Filed Under: Tags: media-tags, plugin, WordPress
Over this past week I added quite a few features to the famous Media Tags plugin for WordPress. The list below details many of these new features
- Added a new tab to the Media Upload popup box. Anyone familiar with WordPress Post or Page entry is familiar with the popup provided to upload images and other media files. In this popup if you wanted to search for items using the handy Media Tags it was not possible. Now the user is provided with a new Tab labelled ‘Media Tags’. When the tab is clicked the user is presented with a listing of all Media Tags used on the site. Along with the Media Tag name there is a use could in the far right of the listing. This count if greater than zero is a link and will filter the Media Library (another Tab) listing for items from that Media Tags group.
Below is a screenshot of the new popup tab.
- More control over the permalink prefix. The Media Tags plugin works with the WordPress Permalink rewrite system to provide ‘pretty’ URLs for the archive. For example if you have some media loaded and tagged on your site for say ‘Texas’. The you can display these items in an archive type listing by using the URL http://www.mysite.com/media-tags/texas/ This format should be familiar to most users of WordPress since Categories and Tags or handled in much the same way. This feature was added in Media Tags version 2.0 and has received much acclaim from the users. The problem is the prefix ‘/media-tags/’ was hard-coded into the plugin. I have a few users request a way to alter this prefix. Other than suggesting they edit the config file for the plugin there was not a good solution.
So I starting thinking I would just build my own admin page where the user can set this permalink prefix. But I hated having to build a new admin page just for the one setting. Well over the weekend I found the solution of solutions. Why not just add my own field to the WordPress Settings -> Permalink page. This turned out to be quite easy using the new Settings API introduced into WordPress 2.7.
Below is a screenshot of the new Media Tags Permalink option. The new field just below the standard Category and Tags fields.
-
Playing nice with other plugins. I’ve used the Google Sitemap XML plugin for quite some time and generally install it by default onto any client site I’ve worked on. This is one of those plus plus plugins that can only help your site. Recently I had to figure out a way to include non-WordPress pages into the XML sitemap output. This is actually very easy to do as the plugin authors have provide a nice hook to allow this.
So my next enhancement to the Media-Tags plugin was to include the Media Tag archives into the Google Sitemaps XML output. This feature is quite powerful since it just adds juice to Google content harvesting. Not wanting to hard-coded this feature into the plugin I ended up building that admin interface I mentioned in the previous point. There is only one option on the page (more to come soon). A simple Yes/No box to include/exclude the Media Tags archive from the Sitemap XML output. I assume most people will wan this but also know there is always the possibility some may now.
Below is a screenshot of the new Media-Tag admin interface. Look for this under the standard WordPress Settings section.
- Along with the above mentioned new features I also cleaned up some code related issues. Most of these are under the covers cosmetic items and not related to any screen changes.
Media Tags Future Enhancements
Still on my list of features to add in some upcoming release is Media-Tags Cloud. This is still one of the most requested options for the sidebar. Still working on that code. Trying to follow some of the code written for the built-in WordPress Tags. pretty ugly stuff. Has to be a better way.
Other than the Media Tags Cloud I don’t have any big changes planned for the plugin. Then again the three features mentioned in this post were not planned at all. Just something that hit me on Friday that I started working toward.
So if there is a feature you just think would make the Media-Tags plugin rock for your blog please consider leaving a comment below.
Donations
If you enjoy using the Media Tags plugin or any of my other WordPress plugins, please consider making a donation to show your support. Anything is appreciated. Thanks.
Media tags plugin
Filed Under: Tags: media-tags, plugin, WordPress
Note: This post remains available to discuss the original 1.0 version of the Media Tags plugin. As of July 15 2009 version 2.0 of the Media Tags plugins has been released. Please refer to the update post http://www.codehooligans.com/2009/07/15/media-tags-20-released/ for information on changes to the use of the plugin.
Working on a client project recently I needed to extract 2 attachments uploaded from a post and display these along with the post title into the sidebar on another page. I’ve done this a few times before and always sad to say a little different. Probably the best solution is to name the ’special’ attachments using some defined naming convention like image_sidebar_1.jpg, image_sidebar_2.jpg, image_sidebar_x.jpg. This works but can get ugly if you even want the client to follow your instructions on the naming conventions.
I’ve figured out a better way. With my latest plugin you can now add tags to your media attachments. I write ‘media’ because this does not just apply to images. You can tag Word document, PDF documents basically anything you upload via the standard WordPress Media upload tool.
Here are some screenshots:
Usage
So now you can tag you media files. But how do you actually use the tags? How to you actually access attachments that have ‘x’ tag? Excellent question. And your answer is below.
1 2 3 4 5 6 7 | $media_items = $mediatags->get_media_by_tag('media_tags=sidebar&post_parent=6'); This call will filter the tags for the tag 'sidebar' and the post ID of 6. The function take three arguments. media_tags (Required) This is the tag or tags you are filtering on. media_types (Optional) Lets you also filter by pdf, txt, etc. post_parent (Optional) The ID of the attachment post. If not provided then the global post ID is assumed. |
As part of the plugin I also wrote a function to be used in your template. To follow the example I started this article with I need to display 2 of the 5 uploaded images in the sidebar. My first step was to upload the images and tag the two special images with ’sidebar’.
Now I use the function get_media_by_tag(). I pass the tag I want to access, in this case ’sidebar’ and the ID of the post parent. What is returned is an array of attachment items. This array is similar in fact to the return object when calling the WordPress get_posts which is partly what the function does.
Download the Media-Tags plugin via the WordPress.org plugin repository
Future plans
I’ve already starting thinking of some enhancements for the plugin. Which include a tag management screen and other utility functions. If you have any other needs post them here in the comments.
Revisions WordPress plugin update 1.8
Filed Under: Tags: plugin, revisions, versioning, WordPress
I’ve just released an update to my Revisions plugin released just a few short weeks ago, Revisions. The update to the plugins are in areas both architectural and UI based.
Architectural Improvements
On the architectural side one big improvement was made in the way the plugin created new Revisions of content. In the old version of the plugin a revision was made too late on the post update process after the user clicked the Save/Publish buttons. Effectively the updated post content and the latest revision were the same. In the newer version of the plugin the revision is generated earlier in the WP core processing. This mean we can take a copy of the post content before it is updated by WP core. This means the latest revision is the real previous version of the content.
UI Improvements
For the UI changes there are quite a few.
- Above the revision listing I added two new checkboxes, Minor Edit and a Revisions Status. The Minor Edit checkbox is a single-use option to tell the plugin NOT to generate a new revision when you save the post item. This functions like most wikis. The Revisions Status allow you to totally disable revision generation for the post. This is handy if you just don’t want to use revisions on certain post items. Or if you are like me trying to make some complex edits and just want to disable new revisions because you will be making a dozen or so minor edits. So you can turn it off make you changes then turn it back on.
- I’ve added logic to limit the display of revisions to the last 5 items. Below the list of revisions is a link. When you click this link the page will slide to reveal the older revisions.
- Added checkboxes at each revision to allow deletions. This is pretty handy is you just want to clean house. Not that if you delete revision 5 of 8 the numbering will NOT re sequence itself. But if you delete the latest revision then the revision number will be reused.
- On WP 2.5 and higher I added the Minor Edit and Revision Status checkboxes to the sidebar. This will make it easier to set the checkboxes to keep from scrolling to the bottom of the editor form. And with some jQuery magic when the sidebar checkboxes are set the lower checkboxes are also set.
Future Changes
I still have a long list of changes I’m reviewing for possible inclusionin future releases.
- One change was submitted that included actual changes to plugin to support versioning categories and tags. This was great. But I’m still holding on the change. In my view categories and tags are not as volatile as text content. Beside if a revision used a category that had since been deleted what should the action be?
- How to handle delete of the main post/page. Currently the plugin will delete all revisions when the parent post/page is deleted. I don’t like this. I want to build an interface to allow recreation of a post from a revision.
I also have some other small items on the list but they are not work mentioning. If you have any other suggestions please feel free to send them my way.
Download
You can download version 1.8 of the Revisions plugin from the WordPress.org plugin repository.
SimplyExclude Plugin for WordPress
Filed Under: Tags: category, exclude, include, page, plugin, WordPress
Have you ever been working on a client WordPress project, or maybe your own blog and needed to exclude a Post category from the Front page? Or needed to exclude a Page from being included in a Search? Keep reading.
Over the past year I’ve worked on twenty different client projects. Each one a little similar yet each one a little different. On most the client wanted only a certain category listed on the front page. After many checks on the different versions of WordPress, I’ve not found a ’standard’ way of doing this via the default WordPress admin interface. Sure on the Options -> Reading page you can select a Page or Latest Posts to display. But if you need to limit the display on the Front page to say just the News category you are out of luck.
One solution that works very well is to hook into the WP query object to intercept the ‘action’ in WordPress. All it takes is a simple function and filter added to your theme’s function.php file. Something like the following.
1 2 3 4 5 6 7 8 9 10 | // Used to limit the categories displayed on the home page. Simple function myHomePostsFilter($query) { if ($query->is_home) { $query->set('cat','1'); } return $query; } add_filter('pre_get_posts','myHomePostsFilter'); |
If you are not familiar with WordPress filters let me provide some overview. The function takes a single parameter, This is the reference to the WP Query object (see /includes/query.php from the WordPress engine code). Don’t worry about the details as you will not be calling this function directly. This function will be called when WordPress is preparing a query for some display of information via another function call. Inside the function you will see the ‘if ($query->is_home)’. The ‘is_home’ is a built-in WordPress action. for Categories there are 5 total. They are ‘is_home’, ‘is_list’, ‘is_search’, ‘is_feed’ and ‘is_archive’. In our example above I’m only concerned with the ‘is_home’. So if the query is being built for the Home/Front page the if is true so the next line is executed. The next line ‘$query->set(‘cat’,'1′);’ sets the query category to the one cat_id I’m interested in. For the example this is cat_id=1. If needed I could have added more than one category as in ‘$query->set(‘cat’,'1,5,15,36,285′);’. I could also exclude categories from the category list simply by preceding the cat_id with a minus as in ‘$query->set(‘cat’,'-1, -16, -32′);’. The next line returns the query back to the calling function. Then end of function. So far this is just a standalone function. Now we have to tell WordPress we want it to hit our function. This is the last line. A filter in WordPress can be thought of as a ’subscribe’ action. The first parameter of the filter. Tells WordPress you want to subscribe to a certain action. In our case this is ‘pre_get_posts’. See this Codex page on Custom Queries. Scroll down to the section header ‘Category Exclusion’. Our filter basically tells WordPress ‘before you run the query hit our function first’. This give our function to massage the parameters to adjust the query. Done. This works for most versions of WordPress 2.x up to the latest and greatest (2.3.1 as of this entry). Pretty simple.
But sadly this cat_id is hard-coded into the functions.php file. So if this is your blog and you have control of the admin keys to the kingdom you can stop reading. I mean it takes all of two seconds to adjust the value of the cat_ids you wish to include/exclude. But what if you are knocking out a project for a client. A client you don’t really want to hit you up every time they need to exclude/include a category from some WordPress action like ‘keep the category X from showing on the Home page’. You have a choice. You can document for the user how to make edits to the functions.php file and hope they don’t somehow screw the code up.
Or you can look for some plugin that will do this or you. I can tell you I’ve looked through various plugins. Only really found one that came close to making this somewhat automated. And that plugin stopped working at WordPress 2.1. Something about the very complicate queries it was building. After reading through 300 line of it’s code just for the query logic I dropped it. I mean the 8 lines of code I provided above are really all you need for the logic portion to include/exclude cat_ids. Why go through the twisted query logic that didn’t run until after the page was loaded. This in effect caused two queries to be executed.
So I started writing my own. Something simple. I just wanted a list of the categories and the available options or WordPress ‘actions’. Let the user select the action for the category and go. I’ve produced something functional. It’s in the very early stages of work. I’ve also included a section for Pages. for Pages I’ve only worked through the logic for the ‘is_search’ action. For both Categories and Pages the user has the option of including or excluding for the actions.
Here is a screenshot of the SimplyExclude Category admin page. It’s the same for the Pages but just for search action.
So download the SimplyExclude Plugin for WordPress v0.1. It’s version 0.1 0.2 but I plan adding more bling soon. I’ve tested this on the latest 2.3.1 engine only. If you are running this and have trouble please feel free to contact me for help.
Update
After entering this post and sending a similar response to someone on the wp-hackers list it occurred to me that for Pages there should be an option on the Page editor that allows the exclusion of the page from the Search actions. So took some time this evening to update the plugin to version 0.2 (W00t!). So not only will the Pages be listed under the plugin’s options. But along the right sidebar on the Page editor look for the ‘Exclude from Search’ dropdown option. Both options update the same information.
See the screenshot below for what it appears like.

Download SimplyExclude Plugin for WordPress v0.2
Update 2008-04-27
After some comment I took another look at the plugin code. Seems I provided the version for WordPress before 2.3. The new version now works all the way up to WordPress 2.5.1. Also, I’ve relabeled ‘List’ to ‘Archive’. I’ve also added logic for tags inclusion/exclusion. This works the same way as Categories. The tags admin menu only works under WordPress 2.3 and higher.
Download SimplyExclude Plugin for WordPress
Also upcoming is a better Category and Tags display listing. I’ve received some comments that users want to see the display nested similar to other parts of the WordPress admin interface.
Update 2008-07-16
Seems some of the WordPress 2.6 changes do in fact effect the way the plugin stores it’s options. I have a fixed version but due to technical (or accounting) I’m having trouble updating the plugin into the main repository. You can download version 1.7.1 here. I’ll update the plugin into the repository when WordPress gets things worked out.









