From 7c2dbb9cb128995592444438617e7b89aef23b49 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 17 Aug 2007 10:33:52 +0000 Subject: [PATCH] First pass at upgrade notification for core, see #1476. Also includes some minor footer styling changes. git-svn-id: http://svn.automattic.com/wordpress/trunk@5892 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-footer.php | 9 ++++--- wp-admin/admin-header.php | 2 +- wp-admin/includes/admin.php | 1 + wp-admin/includes/update.php | 46 ++++++++++++++++++++++++++++++++ wp-admin/wp-admin.css | 43 +++++++++++++++++++----------- wp-includes/update.php | 51 ++++++++++++++++++++++++++++++++++++ wp-settings.php | 1 + 7 files changed, 133 insertions(+), 20 deletions(-) create mode 100644 wp-admin/includes/update.php create mode 100644 wp-includes/update.php diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php index 6ed934ec33..dbf76a2856 100644 --- a/wp-admin/admin-footer.php +++ b/wp-admin/admin-footer.php @@ -1,8 +1,11 @@ diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 601cf2c8f8..e010547581 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -42,7 +42,7 @@ else if ( isset($plugin_page) ) do_action('admin_head'); ?> - + diff --git a/wp-admin/includes/admin.php b/wp-admin/includes/admin.php index 0c4c52cccb..fc50709af4 100644 --- a/wp-admin/includes/admin.php +++ b/wp-admin/includes/admin.php @@ -12,6 +12,7 @@ require_once(ABSPATH . 'wp-admin/includes/taxonomy.php'); require_once(ABSPATH . 'wp-admin/includes/template.php'); require_once(ABSPATH . 'wp-admin/includes/theme.php'); require_once(ABSPATH . 'wp-admin/includes/user.php'); +require_once(ABSPATH . 'wp-admin/includes/update.php'); require_once(ABSPATH . WPINC . '/registration.php'); diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php new file mode 100644 index 0000000000..1a625da771 --- /dev/null +++ b/wp-admin/includes/update.php @@ -0,0 +1,46 @@ +response ) ) + return $msg; + + switch ( $cur->response ) { + case 'development' : + return sprintf( __( '| You are using a development version (%s). Cool! Please stay updated.' ), $GLOBALS['wp_version'], 'http://wordpress.org/download/svn/' ); + break; + + case 'upgrade' : + add_action( 'admin_footer', 'update_nag' ); + return sprintf( __( '| Your WordPress %s is out of date. Please update.' ), $GLOBALS['wp_version'], $cur->url ); + break; + + + case 'latest' : + return sprintf( __( '| Version %s' ), $GLOBALS['wp_version'] ); + break; + } +} +add_filter( 'update_footer', 'core_update_footer' ); + +function update_nag() { +$cur = get_option( 'update_core' ); +?> +
Please upgrade now.'), $cur->url ); ?>
+response ) || $cur->response != 'upgrade' ) + return $class; + + return "nagtime $class"; +} +add_filter( 'admin_body_class', 'update_nag_body' ); + +?> \ No newline at end of file diff --git a/wp-admin/wp-admin.css b/wp-admin/wp-admin.css index 37349da206..03b23519c5 100644 --- a/wp-admin/wp-admin.css +++ b/wp-admin/wp-admin.css @@ -175,7 +175,7 @@ h2 { background: url( images/heading-bg.gif ) repeat-x bottom; } -img, #footer a { +img { border: 0; } @@ -653,24 +653,15 @@ input.delete:hover { #footer { clear: both; - text-align: center; - width: 500px; - margin: auto; - height: 100px; + height: 35px; + padding-left: 40px; + margin: 15px 5%; + background: url('images/logo-ghost.png') no-repeat top left; } -#footer .docs { - padding-top: 19px; - line-height: 160%; -} - -#footer .docs a { - text-decoration: underline; -} -#footer .logo { - float: left; +#footer p { margin: 0; - padding: 0; + padding: 5px 0; } #login { @@ -1338,3 +1329,23 @@ a.view-link { margin-right: 220px; text-decoration:underline; } + +#update-nag { + width: 100%; + position: absolute; + top: 0; + left: 0; + background: #fff; + border-bottom: 2px solid #911; + text-align: center; + font-size: 11px; + height: 18px; +} + +.nagtime { + padding-top: 15px; +} + +.nagtime #user_info { + top: 17px ; +} \ No newline at end of file diff --git a/wp-includes/update.php b/wp-includes/update.php new file mode 100644 index 0000000000..703def4e88 --- /dev/null +++ b/wp-includes/update.php @@ -0,0 +1,51 @@ +last_checked ) && + 43200 > ( time() - $current->last_checked ) && + $current->version_checked == $wp_version + ) + return false; + + $new_option = ''; + $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 .= "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"; + $http_request .= "\r\n"; + + $response = ''; + if ( false !== ( $fs = @fsockopen( 'api.wordpress.org', 80, $errno, $errstr, 3 ) ) ) { + fwrite( $fs, $http_request ); + while ( !feof( $fs ) ) + $response .= fgets( $fs, 1160 ); // One TCP-IP packet + fclose( $fs ); + + $response = explode("\r\n\r\n", $response, 2); + $body = trim( $response[1] ); + $body = str_replace(array("\r\n", "\r"), "\n", $body); + + $returns = explode("\n", $body); + + $new_option->response = $returns[0]; + if ( isset( $returns[1] ) ) + $new_option->url = $returns[1]; + } + update_option( 'update_core', $new_option ); +} + +wp_version_check(); + +?> \ No newline at end of file diff --git a/wp-settings.php b/wp-settings.php index 6496d0c285..7879ff1538 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -193,6 +193,7 @@ require (ABSPATH . WPINC . '/version.php'); require (ABSPATH . WPINC . '/deprecated.php'); require (ABSPATH . WPINC . '/script-loader.php'); require (ABSPATH . WPINC . '/taxonomy.php'); +require (ABSPATH . WPINC . '/update.php'); require (ABSPATH . WPINC . '/canonical.php'); if (strpos($_SERVER['PHP_SELF'], 'install.php') === false) {