[wp-hackers] Version RPC

Peter Westwood peter.westwood at ftwr.co.uk
Sun Aug 21 15:57:07 GMT 2005


Matt Mullenweg wrote:

> Peter Westwood wrote:
>
>>> 1) Latest version string (as in version.php)
>>> 2) Date of revision
>>> 3) SVN location (branch, tags, trunk?) and Revision
>>>
>> I would add to this:
>> 4) Link to release notification
>> 5) A short text message
>> 6) A severity level for the message - ie is the upgrade critical due 
>> to security fixes or only recommended because of new features.
>
>
> Okay I added some of these:
>
> http://rpc.wordpress.org/latest-stable/version/
> http://rpc.wordpress.org/latest-stable/date/
> http://rpc.wordpress.org/latest-stable/link/
> http://rpc.wordpress.org/latest-stable/svn/

These look good.

I've made a first pass at creating a patch to use this (for 
http://trac.wordpress.org/ticket/1476 patch also attached there) which 
will display a message on the dashboard the returned version is 
different from the installed version.

I've also attached a screenshot of how it looks at present

Comments??

I would have had this done a bit quicker if I hadn't been offline for 
nearly a week!  :( - 
http://blog.ftwr.co.uk/archives/2005/08/20/hospital-food/
--
westi
-------------- next part --------------
Index: wp-admin/wp-admin.css
===================================================================
--- wp-admin/wp-admin.css	(revision 2800)
+++ wp-admin/wp-admin.css	(working copy)
@@ -757,3 +757,14 @@
 	-khtml-opacity: 0.8;
 	filter: alpha(opacity=80);
 }
+
+#updatemessage {
+	width:45%;
+	padding:1em;
+	border: 1px solid #69c;
+	background: #ebb;
+	text-align:center;
+	position:absolute;
+	top: 120px;
+	right:65px;
+}
Index: wp-admin/admin-functions.php
===================================================================
--- wp-admin/admin-functions.php	(revision 2800)
+++ wp-admin/admin-functions.php	(working copy)
@@ -1394,4 +1394,67 @@
 	return $wp_importers;
 }
 
-?>
\ No newline at end of file
+function check_version_and_get_message()
+{
+	if (get_option('lastest_version_info'))
+	{
+		$latest_version_info = get_option('latest_version_info');
+	} else {
+		//Defaults
+		$latest_version_info = array("last_update" => 0, 
+									 "last_version" => "0.0.0", 
+									 "last_url" => "http://wordpress.org", 
+									 "last_date" => "19800101", 
+									 "last_svn" => "http://svn.automattic.com/wordpress/tags/1.5.2/" );
+	}
+	
+	//Check every 15 minutes for now - maybe up this to 1 hour or so ??
+	if (($latest_version_info["last_update"] + ( 15 * 60)) < time())
+	{
+		$version_snoopy = _fetch_remote_file("http://rpc.wordpress.org/latest-stable/version/");
+		$date_snoopy = _fetch_remote_file("http://rpc.wordpress.org/latest-stable/date/");
+		$link_snoopy = _fetch_remote_file("http://rpc.wordpress.org/latest-stable/link/");
+		$svn_snoopy = _fetch_remote_file("http://rpc.wordpress.org/latest-stable/svn/");
+		
+		if (_check_snoopy_get_results($version_snoopy, $latest_version_info["last_version"]) and
+			_check_snoopy_get_results($date_snoopy, $latest_version_info["last_date"]) and
+			_check_snoopy_get_results($link_snoopy, $latest_version_info["last_url"]) and
+			_check_snoopy_get_results($svn_snoopy, $latest_version_info["last_svn"]))
+		{
+			//All suceeded so update timestamp
+			$latest_version_info["last_update"] = time();
+			update_option('latest_version_info',$latest_version_info);
+		}
+		
+	}
+
+	if ( $wp_version != $latest_version_info["last_version"])
+	{
+		$message = human_time_diff(strtotime($latest_version_info["last_date"])) . ' ' . __('ago');
+		$message .= ' - <a href="'.$latest_version_info["last_url"].'">'; 
+		$message .= __('New WordPress Version is available');
+		$message .= '</a> - v';
+		$message .= $latest_version_info["last_version"];
+		$message .= ' (<a href="'.$latest_version_info["last_svn"].'">svn</a>)';
+	} else {
+		$message = "";
+	}
+
+	return $message;
+					
+} //end check_version_and_get_message()
+
+function _check_snoopy_get_results(&$snoopy, &$value) 
+{
+	if (isset($snoopy) and $snoopy )
+	{
+		if (200 == $snoopy->status)
+		{
+			$value = $snoopy->results;
+			return true;
+		}
+	}
+	return false;
+}
+
+?>
Index: wp-admin/index.php
===================================================================
--- wp-admin/index.php	(revision 2800)
+++ wp-admin/index.php	(working copy)
@@ -11,6 +11,12 @@
 
 <h2><?php _e('Dashboard'); ?></h2>
 
+<?php if ("" != check_version_and_get_message()) { ?>
+<div id="updatemessage">
+<?php echo check_version_and_get_message(); ?>
+</div>
+<?php } ?>
+
 <div id="zeitgeist">
 <h2><?php _e('Latest Activity'); ?></h2>
 
@@ -157,4 +163,4 @@
 
 <?php
 require('./admin-footer.php');
-?>
\ No newline at end of file
+?>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: screenshot.JPG
Type: image/jpeg
Size: 148630 bytes
Desc: not available
Url : http://comox.textdrive.com/pipermail/wp-hackers/attachments/20050821/0c9bb06a/screenshot-0001.jpe


More information about the wp-hackers mailing list