0, "last_version"=>"", "ixr_response"=>array("class" => "warning", "message" => "Failed to get update information.")); var $version = 0.91; function init() { add_option('pjw_wp_version_check',$this->options,'Settings for the version check plugin.','yes'); $this->options = get_option('pjw_wp_version_check'); /* wp-dash integration */ if(function_exists('make_widget_available')) make_widget_available('Wordpress Version Check', 'Displays the WP Version Check message.', 'pjw_wp_version_check_'); } function update_and_output_css() { $this->update_if_required(); $this->output_css(); } function update_if_required() { global $wp_version; if (($this->options["last_run"] + ( 15 * 60)) < time() || $this->options["last_version"] != $wp_version) { $ixrcli = new IXR_Client('http://sandbox.ftwr.co.uk/xmlrpc/wp.php'); $ixrcli->useragent = 'IXR '; $ixrcli->useragent .= ' -- WordPress/'.$wp_version; $ixrcli->useragent .= ' -- VC/'.$this->version; $ixrcli->useragent .= ' ('.get_bloginfo('url').')'; if ($ixrcli->query('wp.get_version_report',$wp_version)) { $ixr_res = $ixrcli->getResponse(); // Ok if the we have an email address do the has_changed check if ("" != $this->admin_email) { if ($ixr_res["message"] != $this->options["ixr_response"]["message"]) { $title = "[". get_settings('blogname') ."] Message from Version-Check/".$this->version."\n"; $email = "Message from Version-Check/".$this->version."\n"; $email .= "Running at ".get_bloginfo('url')."\n"; $email .= $ixr_res["message"]."\n"; $email .= "Previous message was:\n"; $email .= $this->options["ixr_response"]["message"]; wp_mail($this->admin_email,$title,$email); } } $this->options["ixr_response"] = $ixr_res; $this->options["last_run"] = time(); $this->options["last_version"] = $wp_version; update_option('pjw_wp_version_check',$this->options); } else { $this->options["ixr_response"] = array("class"=>"warning", "message" => "XML-RPC Error:".$ixrcli->getErrorCode().":".$ixrcli->getErrorMessage()); update_option('pjw_wp_version_check',$this->options); } } } //The message function output_text() { echo "

"; echo $this->options["ixr_response"]["message"]; echo "

"; } function wp_dash_content($id) { //If we are running from wp-dash then we will get called here before the normal update. $this->update_if_required(); $content = "

"; $content .= $this->options["ixr_response"]["message"]; $content .= "

"; return $content; } function wp_dash_css($id) { return default_widget_css($id) . "#widget$id {font-size:15px;} "; } //Do we have the Tiger Admin plugin running? function is_tiger_admin() { global $current_plugins; if (!empty($current_plugins) && (in_array("wp-admin-tiger/wp-admin-tiger.php", $current_plugins) || (in_array("wp-admin-tiger.php", $current_plugins)))) return TRUE; else return FALSE; } // We need some CSS to position the paragraph function output_css() { if (!$this->is_tiger_admin()) { //Default Style echo " "; }else{ //Alternate Tiger compatible style //Props to Mark J (http://txfx.net) for the CSS //As seen here: http://blog.ftwr.co.uk/archives/2005/07/09/wordpress-version-check-080/#comment-4271 echo " "; } } } /* Initialise outselves */ $pjw_wp_ver_chk = new pjw_wp_version_check; /* add some actions */ /* move all code to actions - only run update if it's an admin page - should reduce calls to XML-RPC service */ add_action('plugins_loaded', array(&$pjw_wp_ver_chk,'init')); add_action('admin_footer', array(&$pjw_wp_ver_chk,'output_text')); add_action('admin_head', array(&$pjw_wp_ver_chk,'update_and_output_css')); /* Support functions for wp-dash widget */ function pjw_wp_version_check_content($id){ global $pjw_wp_ver_chk; return $pjw_wp_ver_chk->wp_dash_content($id); } function pjw_wp_version_check_css($id){ global $pjw_wp_ver_chk; return $pjw_wp_ver_chk->wp_dash_css($id); } ?>