Update Monitor

August 8th, 2007

Update Monitor
1 2
Update MonitorUpdate Monitor
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

Leave a Reply

For support questions, bug reports and troubleshooting regarding plugins from this site, please visit the forum.

See also:

Plugins in action: Mini-Slides

Turakraft uses Mini-Slides.

Plugins in action: Mini-Slides on timbuktoons.tv

Timbuktoons uses the Mini-Slides plugin.

This time it's Facebook

As being advised I did my Facebook page today ;)

Plugins in action: Find Us

KGALEWOOD, the Botswana Travel Community Podcast Channel uses Find Us.

Close
E-mail It