Make WordPress Core

Ticket #1476: version-check-2nd-pass.diff

File version-check-2nd-pass.diff, 3.2 KB (added by westi, 19 years ago)

Improved patch with new message text

  • wp-admin/wp-admin.css

     
    757757        -khtml-opacity: 0.8;
    758758        filter: alpha(opacity=80);
    759759}
     760
     761#updatemessage {
     762        display:inline;
     763        padding:1em;
     764        border: 1px solid #69c;
     765        background: #ebb;
     766        text-align:center;
     767        position:absolute;
     768        top: 120px;
     769        right:65px;
     770}
  • wp-admin/admin-functions.php

     
    13941394        return $wp_importers;
    13951395}
    13961396
    1397 ?>
    1398  No newline at end of file
     1397function check_version_and_get_message()
     1398{
     1399        if (get_option('lastest_version_info'))
     1400        {
     1401                $latest_version_info = get_option('latest_version_info');
     1402        } else {
     1403                //Defaults
     1404                $latest_version_info = array("last_update" => 0,
     1405                                                                         "last_version" => "0.0.0",
     1406                                                                         "last_url" => "http://wordpress.org",
     1407                                                                         "last_date" => "19800101",
     1408                                                                         "last_svn" => "http://svn.automattic.com/wordpress/tags/1.5.2/" );
     1409        }
     1410       
     1411        //Check every 15 minutes for now - maybe up this to 1 hour or so ??
     1412        if (($latest_version_info["last_update"] + ( 15 * 60)) < time())
     1413        {
     1414                $version_snoopy = _fetch_remote_file("http://rpc.wordpress.org/latest-stable/version/");
     1415                $date_snoopy = _fetch_remote_file("http://rpc.wordpress.org/latest-stable/date/");
     1416                $link_snoopy = _fetch_remote_file("http://rpc.wordpress.org/latest-stable/link/");
     1417                $svn_snoopy = _fetch_remote_file("http://rpc.wordpress.org/latest-stable/svn/");
     1418               
     1419                if (_check_snoopy_get_results($version_snoopy, $latest_version_info["last_version"]) and
     1420                        _check_snoopy_get_results($date_snoopy, $latest_version_info["last_date"]) and
     1421                        _check_snoopy_get_results($link_snoopy, $latest_version_info["last_url"]) and
     1422                        _check_snoopy_get_results($svn_snoopy, $latest_version_info["last_svn"]))
     1423                {
     1424                        //All suceeded so update timestamp
     1425                        $latest_version_info["last_update"] = time();
     1426                        update_option('latest_version_info',$latest_version_info);
     1427                }
     1428               
     1429        }
     1430
     1431        if ( $wp_version != $latest_version_info["last_version"])
     1432        {
     1433                $message = sprintf(__('A <a href="%s">new WordPress version</a>, version %s, was released %s ago.'), $latest_version_info["last_url"], $latest_version_info["last_version"], human_time_diff(strtotime($latest_version_info["last_date"])));
     1434        } else {
     1435                $message = "";
     1436        }
     1437
     1438        return $message;
     1439                                       
     1440} //end check_version_and_get_message()
     1441
     1442function _check_snoopy_get_results(&$snoopy, &$value)
     1443{
     1444        if (isset($snoopy) and $snoopy )
     1445        {
     1446                if (200 == $snoopy->status)
     1447                {
     1448                        $value = $snoopy->results;
     1449                        return true;
     1450                }
     1451        }
     1452        return false;
     1453}
     1454
     1455?>
  • wp-admin/index.php

     
    1111
    1212<h2><?php _e('Dashboard'); ?></h2>
    1313
     14<?php if ("" != check_version_and_get_message()) { ?>
     15<div id="updatemessage">
     16<?php echo check_version_and_get_message(); ?>
     17</div>
     18<?php } ?>
     19
    1420<div id="zeitgeist">
    1521<h2><?php _e('Latest Activity'); ?></h2>
    1622
     
    157163
    158164<?php
    159165require('./admin-footer.php');
    160 ?>
    161  No newline at end of file
     166?>