From e032847e3edc2e44126843b6c49cc9218c847a03 Mon Sep 17 00:00:00 2001 From: azaozz Date: Tue, 14 Jul 2009 08:34:39 +0000 Subject: [PATCH] Hide update notification for themes that are updated manually, props Denis-de-Bernardy, fixes #10220 git-svn-id: http://svn.automattic.com/wordpress/trunk@11714 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/update.php | 45 +++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/wp-includes/update.php b/wp-includes/update.php index 141cecfe2b..933075364b 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -201,7 +201,36 @@ function wp_update_themes( ) { $timeout = 'load-themes.php' == current_filter() ? 3600 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours $time_not_changed = isset( $current_theme->last_checked ) && $timeout > ( time( ) - $current_theme->last_checked ); - if( $time_not_changed ) + $themes = array(); + $checked = array(); + $themes['current_theme'] = (array) $current_theme; + foreach( (array) $installed_themes as $theme_title => $theme ) { + $themes[$theme['Stylesheet']] = array(); + $checked[$theme['Stylesheet']] = $theme['Version']; + + foreach( (array) $theme as $key => $value ) { + $themes[$theme['Stylesheet']][$key] = $value; + } + } + + $theme_changed = false; + foreach ( $checked as $slug => $v ) { + $new_option->checked[ $slug ] = $v; + + if ( !isset( $current_theme->checked[ $slug ] ) || strval($current_theme->checked[ $slug ]) !== strval($v) ) + $theme_changed = true; + } + + if ( isset ( $current_theme->response ) && is_array( $current_theme->response ) ) { + foreach ( $current_theme->response as $slug => $update_details ) { + if ( ! isset($checked[ $slug ]) ) { + $theme_changed = true; + break; + } + } + } + + if( $time_not_changed && !$theme_changed ) return false; // Update last_checked for current to prevent multiple blocking requests if request hangs @@ -210,16 +239,6 @@ function wp_update_themes( ) { $current_theme->template = get_option( 'template' ); - $themes = array( ); - $themes['current_theme'] = (array) $current_theme; - foreach( (array) $installed_themes as $theme_title => $theme ) { - $themes[$theme['Stylesheet']] = array( ); - - foreach( (array) $theme as $key => $value ) { - $themes[$theme['Stylesheet']][$key] = $value; - } - } - $options = array( 'timeout' => 3, 'body' => array( 'themes' => serialize( $themes ) ), @@ -235,8 +254,10 @@ function wp_update_themes( ) { return false; $response = unserialize( $raw_response['body'] ); - if( $response ) + if( $response ) { + $new_option->checked = $checked; $new_option->response = $response; + } set_transient( 'update_themes', $new_option ); }