Created
May 27, 2011 15:59
-
-
Save franz-josef-kaiser/995560 to your computer and use it in GitHub Desktop.
WordPress Plugin: List all plugins that need updates in wp_footer()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Plugin update lister | |
Plugin URI: https://gist.github.com/995560 | |
Description: Adds a table to your ´wp_footer()´ that lists all plugins that need updates. The plugin works out of the box. | |
Author: Franz Josef Kaiser | |
Author URI: https://github.com/franz-josef-kaiser | |
Version: 0.1. | |
License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | |
(c) Copyright 2011 - 201X by AUTHOR | |
This program is free software; you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation; either version 2 of the License, or | |
(at your option) any later version. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
*/ | |
// Secure: doesn't allow to load this file directly | |
if( ! class_exists('WP') ) | |
{ | |
header( 'Status: 403 Forbidden' ); | |
header( 'HTTP/1.1 403 Forbidden' ); | |
exit; | |
} | |
function wpse18476_check_plugin_updates() | |
{ | |
// Assuming that plugins have properly named folders: | |
$update_plugins = get_site_transient('update_plugins'); | |
$update_plugins = $update_plugins->response; | |
echo '<style> | |
#plugin-lister { width: 100%; margin-bottom: 1.5em; } | |
#plugin-lister caption { font-size: 1.5em; font-weight: bold; margin: 1em 0; } | |
#plugin-lister { text-align: left; } | |
#plugin-lister tr th.name, tr td.name { width: 40%; border: 1px solid #ddd; border-top: none; border-left: none; } | |
#plugin-lister tr th, tr td { width: 15%; border: 1px solid #ddd; border-top: none; border-left: none; } | |
#plugin-lister tfoot tr th, #plugin-lister tfoot tr th.name { border: none; border-right: 1px solid #ddd; } | |
</style>'; | |
echo '<table id="plugin-lister">'; | |
echo '<caption>'.__( 'All Plugins that need updates' ).'</caption>'; | |
echo '<thead>'; | |
echo '<tr>'; | |
echo '<th class="name">'.__( 'Name' ).'</th>'; | |
echo '<th>'.__( 'Curr. Version' ).'</th>'; | |
echo '<th>'.__( 'New version' ).'</th>'; | |
echo '<th>'.__( 'Repo Link' ).'</th>'; | |
echo '<th>'.__( 'Download' ).'</th>'; | |
echo '</tr>'; | |
echo '</thead>'; | |
echo '<tbody>'; | |
#echo '<pre>'; print_r($update_plugins); echo '</pre>'; | |
foreach ( $update_plugins as $plugin_name => $plugin_data ) | |
{ | |
$plugin = explode( "/", $plugin_name ); | |
$folder = $plugin[0]; | |
$init_file = $plugin[1]; | |
$data = get_plugin_data( WP_PLUGIN_DIR.'/'.$folder.'/'.$init_file, false, true); | |
#echo '<pre>'; print_r($plugin_data); echo '</pre>'; | |
$name = $data['Name']; | |
$old_version = $data['Version']; | |
echo '<tr>'; | |
echo '<td class="name">'.$name.'</td>'; | |
echo '<td>'.$old_version.'</td>'; | |
echo '<td>'.$plugin_data->new_version.'</td>'; | |
echo '<td><a href="'.$plugin_data->url.'">'.__( 'Go' ).'</a></td>'; | |
echo '<td><a href="'.$plugin_data->package.'">'.__( 'Go' ).'</a></td>'; | |
echo '</tr>'; | |
} | |
echo '</tbody>'; | |
echo '<tfoot>'; | |
echo '<tr>'; | |
echo '<th class="name">'.__( 'Name' ).'</th>'; | |
echo '<th style="width: 15%;">'.__( 'Curr. Version' ).'</th>'; | |
echo '<th style="width: 15%;">'.__( 'New version' ).'</th>'; | |
echo '<th style="width: 15%;">'.__( 'Repo Link' ).'</th>'; | |
echo '<th style="width: 15%;">'.__( 'Download' ).'</th>'; | |
echo '</tr>'; | |
echo '</tfoot>'; | |
echo '</table>'; | |
} | |
add_action( 'admin_footer', 'wpse18476_check_plugin_updates', 99 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment