Upgrade message in dash. Props mdawaffe. fixes #6060

git-svn-id: http://svn.automattic.com/wordpress/trunk@7237 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-11 16:13:07 +00:00
parent f14702fb65
commit 7fa4744082
3 changed files with 29 additions and 11 deletions

View File

@ -1,6 +1,6 @@
<?php
// The admin side of our 1.0 update system
// The admin side of our 1.1 update system
function core_update_footer( $msg = '' ) {
if ( !current_user_can('manage_options') )
@ -10,16 +10,18 @@ function core_update_footer( $msg = '' ) {
switch ( $cur->response ) {
case 'development' :
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/' );
return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please <a href="%s">stay updated</a>.' ), $GLOBALS['wp_version'], $cur->url, $cur->current );
break;
case 'upgrade' :
return sprintf( '| <strong>'.__( 'Your WordPress %s is out of date. <a href="%s">Please update</a>.' ).'</strong>', $GLOBALS['wp_version'], $cur->url );
break;
if ( current_user_can('manage_options') ) {
return sprintf( '| <strong>'.__( '<a href="%2$s">Get Version %3$s</a>' ).'</strong>', $GLOBALS['wp_version'], $cur->url, $cur->current );
break;
}
case 'latest' :
default :
return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'] );
return sprintf( '| '.__( 'Version %s' ), $GLOBALS['wp_version'], $cur->url, $cur->current );
break;
}
}
@ -32,14 +34,25 @@ function update_nag() {
return false;
if ( current_user_can('manage_options') )
$msg = sprintf( __('A new version of WordPress is available! <a href="%s">Please update now</a>.'), $cur->url );
$msg = sprintf( __('WordPress %2$s is available! <a href="%1$s">Please update now</a>.'), $cur->url, $cur->current );
else
$msg = __('A new version of WordPress is available! Please notify the site administrator.');
$msg = sprintf( __('WordPress %2$s is available! Please notify the site administrator.'), $cur->url, $cur->current );
echo "<div id='update-nag'>$msg</div>";
}
add_action( 'admin_notices', 'update_nag', 3 );
// Called directly from dashboard
function update_right_now_message() {
$cur = get_option( 'update_core' );
$msg = sprintf( __('This is WordPress version %s.'), $GLOBALS['wp_version'] );
if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('manage_options') )
$msg .= " <a href='$cur->url' class='rbutton'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
echo "<span id='wp-version-message'>$msg</span>";
}
function wp_update_plugins() {
global $wp_version;

View File

@ -101,7 +101,7 @@ if ( $can_switch_themes = current_user_can( 'switch_themes' ) )
<?php if ( $can_switch_themes ) : ?>
<a href="themes.php" class="rbutton"><?php _e('Change Theme'); ?></a>
<?php endif; ?>
<?php printf( __( "This is WordPress version %s." ), $GLOBALS['wp_version'] ); ?>
<?php update_right_now_message(); ?>
</p>
<?php do_action( 'rightnow_end' ); ?>

View File

@ -39,7 +39,7 @@ function wp_version_check() {
$new_option->last_checked = time(); // this gets set whether we get a response or not, so if something is down or misconfigured it won't delay the page load for more than 3 seconds, twice a day
$new_option->version_checked = $wp_version;
$http_request = "GET /core/version-check/1.0/?version=$wp_version&php=$php_version&locale=$locale HTTP/1.0\r\n";
$http_request = "GET /core/version-check/1.1/?version=$wp_version&php=$php_version&locale=$locale HTTP/1.0\r\n";
$http_request .= "Host: api.wordpress.org\r\n";
$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
$http_request .= 'User-Agent: WordPress/' . $wp_version . '; ' . get_bloginfo('url') . "\r\n";
@ -53,14 +53,19 @@ function wp_version_check() {
fclose( $fs );
$response = explode("\r\n\r\n", $response, 2);
if ( !preg_match( '|HTTP/.*? 200|', $response[0] ) )
return false;
$body = trim( $response[1] );
$body = str_replace(array("\r\n", "\r"), "\n", $body);
$returns = explode("\n", $body);
$new_option->response = $returns[0];
$new_option->response = attribute_escape( $returns[0] );
if ( isset( $returns[1] ) )
$new_option->url = $returns[1];
$new_option->url = clean_url( $returns[1] );
if ( isset( $returns[2] ) )
$new_option->current = attribute_escape( $returns[2] );
}
update_option( 'update_core', $new_option );
}