Fix core update checking. Don't check on every page load.

git-svn-id: http://svn.automattic.com/wordpress/trunk@9512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-11-04 17:12:03 +00:00
parent feab9ff5f1
commit 1d347362af
2 changed files with 14 additions and 5 deletions

View File

@ -34,9 +34,13 @@ function get_core_updates( $options = array() ) {
$dismissed = get_option( 'dismissed_update_core' );
if ( !is_array( $dismissed ) ) $dismissed = array();
$from_api = get_option( 'update_core' );
if ( !is_array( $from_api ) ) return false;
if ( empty($from_api) )
return false;
if ( !is_array( $from_api->updates ) ) return false;
$updates = $from_api->updates;
if ( !is_array( $updates ) ) return false;
$result = array();
foreach($from_api as $update) {
foreach($updates as $update) {
if ( array_key_exists( $update->current.'|'.$update->locale, $dismissed ) ) {
if ( $options['dismissed'] ) {
$update->dismissed = true;
@ -68,8 +72,9 @@ function undismiss_core_update( $version, $locale ) {
function find_core_update( $version, $locale ) {
$from_api = get_option( 'update_core' );
if ( !is_array( $from_api ) ) return false;
foreach($from_api as $update) {
if ( !is_array( $from_api->updates ) ) return false;
$updates = $from_api->updates;
foreach($updates as $update) {
if ( $update->current == $version && $update->locale == $locale )
return $update;
}

View File

@ -77,7 +77,11 @@ function wp_version_check() {
$new_options[] = $new_option;
}
update_option( 'update_core', $new_options );
$updates = new stdClass();
$updates->updates = $new_options;
$updates->last_checked = time();
$updates->version_checked = $wp_version;
update_option( 'update_core', $updates);
}
add_action( 'init', 'wp_version_check' );