From 7fa47440825464f1bfebe034f7ab87a4753b3fb6 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 11 Mar 2008 16:13:07 +0000 Subject: [PATCH] Upgrade message in dash. Props mdawaffe. fixes #6060 git-svn-id: http://svn.automattic.com/wordpress/trunk@7237 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/update.php | 27 ++++++++++++++++++++------- wp-admin/index.php | 2 +- wp-includes/update.php | 11 ++++++++--- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php index 5523252032..edfd0f7c59 100644 --- a/wp-admin/includes/update.php +++ b/wp-admin/includes/update.php @@ -1,6 +1,6 @@ response ) { case 'development' : - return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please stay updated.' ), $GLOBALS['wp_version'], 'http://wordpress.org/download/svn/' ); + return sprintf( '| '.__( 'You are using a development version (%s). Cool! Please stay updated.' ), $GLOBALS['wp_version'], $cur->url, $cur->current ); break; case 'upgrade' : - return sprintf( '| '.__( 'Your WordPress %s is out of date. Please update.' ).'', $GLOBALS['wp_version'], $cur->url ); - break; + if ( current_user_can('manage_options') ) { + return sprintf( '| '.__( 'Get Version %3$s' ).'', $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! Please update now.'), $cur->url ); + $msg = sprintf( __('WordPress %2$s is available! Please update now.'), $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 "
$msg
"; } 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 .= " " . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . ''; + + echo "$msg"; +} + function wp_update_plugins() { global $wp_version; diff --git a/wp-admin/index.php b/wp-admin/index.php index fb05ba2335..9a811b4411 100644 --- a/wp-admin/index.php +++ b/wp-admin/index.php @@ -101,7 +101,7 @@ if ( $can_switch_themes = current_user_can( 'switch_themes' ) ) - +

diff --git a/wp-includes/update.php b/wp-includes/update.php index 05a28dc0ae..297bcbdeb3 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -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 ); }