Make WordPress Core

Changeset 7237


Ignore:
Timestamp:
03/11/2008 04:13:07 PM (19 years ago)
Author:
ryan
Message:

Upgrade message in dash. Props mdawaffe. fixes #6060

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/update.php

    r7209 r7237  
    11<?php
    22
    3 // The admin side of our 1.0 update system
     3// The admin side of our 1.1 update system
    44
    55function core_update_footer( $msg = '' ) {
    … …  
    1111        switch ( $cur->response ) {
    1212        case 'development' :
    13                 return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please <a href="%s">stay updated</a>.' ), $GLOBALS['wp_version'], 'http://wordpress.org/download/svn/' );
     13                return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please <a href="%s">stay updated</a>.' ), $GLOBALS['wp_version'], $cur->url, $cur->current );
    1414        break;
    1515
    1616        case 'upgrade' :
    17                 return sprintf( '| <strong>'.__( 'Your WordPress %s is out of date. <a href="%s">Please update</a>.' ).'</strong>', $GLOBALS['wp_version'], $cur->url );
    18         break;
     17                if ( current_user_can('manage_options') ) {
     18                        return sprintf( '| <strong>'.__( '<a href="%2$s">Get Version %3$s</a>' ).'</strong>', $GLOBALS['wp_version'], $cur->url, $cur->current );
     19                        break;
     20                }
    1921
    2022        case 'latest' :
    2123        default :
    22                 return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] );
     24                return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'], $cur->url, $cur->current );
    2325        break;
    2426        }
    … …  
    3335
    3436        if ( current_user_can('manage_options') )
    35                 $msg = sprintf( __('A new version of WordPress is available! <a href="%s">Please update now</a>.'), $cur->url );
     37                $msg = sprintf( __('WordPress %2$s is available! <a href="%1$s">Please update now</a>.'), $cur->url, $cur->current );
    3638        else
    37                 $msg = __('A new version of WordPress is available! Please notify the site administrator.');
     39                $msg = sprintf( __('WordPress %2$s is available! Please notify the site administrator.'), $cur->url, $cur->current );
    3840
    3941        echo "<div id='update-nag'>$msg</div>";
    4042}
    4143add_action( 'admin_notices', 'update_nag', 3 );
     44
     45// Called directly from dashboard
     46function update_right_now_message() {
     47        $cur = get_option( 'update_core' );
     48
     49        $msg = sprintf( __('This is WordPress version %s.'), $GLOBALS['wp_version'] );
     50        if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('manage_options') )
     51                $msg .= " <a href='$cur->url' class='rbutton'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
     52
     53        echo "<span id='wp-version-message'>$msg</span>";
     54}
    4255
    4356function wp_update_plugins() {
  • trunk/wp-admin/index.php

    r7217 r7237  
    102102                <a href="themes.php" class="rbutton"><?php _e('Change Theme'); ?></a>
    103103        <?php endif; ?>
    104         <?php printf( __( "This is WordPress version %s." ), $GLOBALS['wp_version'] ); ?>
     104        <?php update_right_now_message(); ?>
    105105</p>
    106106
  • trunk/wp-includes/update.php

    r6925 r7237  
    4040        $new_option->version_checked = $wp_version;
    4141
    42         $http_request  = "GET /core/version-check/1.0/?version=$wp_version&php=$php_version&locale=$locale HTTP/1.0\r\n";
     42        $http_request  = "GET /core/version-check/1.1/?version=$wp_version&php=$php_version&locale=$locale HTTP/1.0\r\n";
    4343        $http_request .= "Host: api.wordpress.org\r\n";
    4444        $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
    … …  
    5454
    5555                $response = explode("\r\n\r\n", $response, 2);
     56                if ( !preg_match( '|HTTP/.*? 200|', $response[0] ) )
     57                        return false;
     58
    5659                $body = trim( $response[1] );
    5760                $body = str_replace(array("\r\n", "\r"), "\n", $body);
    … …  
    5962                $returns = explode("\n", $body);
    6063
    61                 $new_option->response = $returns[0];
     64                $new_option->response = attribute_escape( $returns[0] );
    6265                if ( isset( $returns[1] ) )
    63                         $new_option->url = $returns[1];
     66                        $new_option->url = clean_url( $returns[1] );
     67                if ( isset( $returns[2] ) )
     68                        $new_option->current = attribute_escape( $returns[2] );
    6469        }
    6570        update_option( 'update_core', $new_option );
Note: See TracChangeset for help on using the changeset viewer.