Update Monitor
August 8th, 2007
It’s about time to start featuring the most useful & valuable, elegant & slik WordPress Plugins that I frequently use. To learn how to write WordPress Plugins, the best thing you could possibly do is to look at the source of such plugins.
One thing I really like is the Update Monitor. It’s about 40 lines of code and it keeps reminding me to update my wordpress installation:
The red colored reminder itself is pure CSS:
function monitor_css() {
echo "<style type='text/css'>
#monitor {
position: absolute;
top: 35px;
margin-right: 33px;
padding: 0;
right: 1.5em;
border: 1px solid #000000;
font-size: 11px;
}
.info {
background: #a3a3a3;
color: #ffffff;
padding: 0;
}
.alarm, .alarm a {
background: #ce0000;
color: #ffffff;
padding: 0;
text-decoration: none;
}
</style>
";
}
Which is later on called via the admin_head filter:
add_action('admin_head', 'monitor_css');
The rest is retrieving the current WordPress version number from a reliable source via rss and writing it between div tags:
require_once (ABSPATH . WPINC . '/rss-functions.php');
function monitor_text() {
global $wp_version;
$rss = @fetch_rss('http://static.wordpress-deutschland.org/version.xml');
$rss->items = array_slice($rss->items, 0, 1);
foreach ($rss->items as $item ) {
$blogversion = ereg_replace("[.]", "", $wp_version);
if ($item['description'] <> $blogversion) {
echo "<p>
<div id='monitor'>
<span class='info'> ".$wp_version." </span>
<span class='alarm'> <a href='".$item['link']."'>".$item['title']."</a>
</span>
</div>
</p>";
} else {
echo "<p>
<div id='monitor' class='info'> ".$wp_version." </div>
</p>";
}
}
}
Last thing to do is to call the function displaying the version number:
add_action('admin_footer', 'monitor_text');
Share This
Posted by Roland Rust
File under: Wordpress Plugins
See also:
- Find Us in dutch language (January 13th, 2008)
- Plugins in action: Mini-Slides (November 19th, 2007)
- Demo Mode 1.2 released (November 18th, 2007)
- Plugins in action: Mini-Slides on timbuktoons.tv (November 17th, 2007)
- Demo Mode 1.1 released (November 9th, 2007)


Leave a Reply