Make WordPress Core

Ticket #1476: version-check-1st-pass.diff

File version-check-1st-pass.diff, 3.4 KB (added by westi, 19 years ago)

1st pass at a patch for svn head

  • wp-admin/wp-admin.css

     
    757757        -khtml-opacity: 0.8;
    758758        filter: alpha(opacity=80);
    759759}
     760
     761#updatemessage {
     762        width:45%;
     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 = human_time_diff(strtotime($latest_version_info["last_date"])) . ' ' . __('ago');
     1434                $message .= ' - <a href="'.$latest_version_info["last_url"].'">';
     1435                $message .= __('New WordPress Version is available');
     1436                $message .= '</a> - v';
     1437                $message .= $latest_version_info["last_version"];
     1438                $message .= ' (<a href="'.$latest_version_info["last_svn"].'">svn</a>)';
     1439        } else {
     1440                $message = "";
     1441        }
     1442
     1443        return $message;
     1444                                       
     1445} //end check_version_and_get_message()
     1446
     1447function _check_snoopy_get_results(&$snoopy, &$value)
     1448{
     1449        if (isset($snoopy) and $snoopy )
     1450        {
     1451                if (200 == $snoopy->status)
     1452                {
     1453                        $value = $snoopy->results;
     1454                        return true;
     1455                }
     1456        }
     1457        return false;
     1458}
     1459
     1460?>
  • 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?>