'latest'); return $updates[0]; } /** * Get available core updates * * @param array $options Set $options['dismissed'] to true to show dismissed upgrades too, * set $options['available'] to false to skip not-dimissed updates. * @return array Array of the update objects */ function get_core_updates( $options = array() ) { $options = array_merge( array('available' => true, 'dismissed' => false ), $options ); $dismissed = get_option( 'dismissed_update_core' ); if ( !is_array( $dismissed ) ) $dismissed = array(); $from_api = get_transient( 'update_core' ); if ( empty($from_api) ) return false; if ( !isset( $from_api->updates ) || !is_array( $from_api->updates ) ) return false; $updates = $from_api->updates; if ( !is_array( $updates ) ) return false; $result = array(); foreach($updates as $update) { if ( array_key_exists( $update->current.'|'.$update->locale, $dismissed ) ) { if ( $options['dismissed'] ) { $update->dismissed = true; $result[]= $update; } } else { if ( $options['available'] ) { $update->dismissed = false; $result[]= $update; } } } return $result; } function dismiss_core_update( $update ) { $dismissed = get_option( 'dismissed_update_core' ); $dismissed[ $update->current.'|'.$update->locale ] = true; return update_option( 'dismissed_update_core', $dismissed ); } function undismiss_core_update( $version, $locale ) { $dismissed = get_option( 'dismissed_update_core' ); $key = $version.'|'.$locale; if ( !isset( $dismissed[$key] ) ) return false; unset( $dismissed[$key] ); return update_option( 'dismissed_update_core', $dismissed ); } function find_core_update( $version, $locale ) { $from_api = get_transient( 'update_core' ); 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; } return false; } function core_update_footer( $msg = '' ) { if ( !current_user_can('manage_options') ) return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] ); $cur = get_preferred_from_update_core(); if ( ! isset( $cur->current ) ) $cur->current = ''; if ( ! isset( $cur->url ) ) $cur->url = ''; if ( ! isset( $cur->response ) ) $cur->response = ''; switch ( $cur->response ) { case 'development' : return sprintf( __( 'You are using a development version (%1$s). Cool! Please stay updated.' ), $GLOBALS['wp_version'], 'update-core.php'); break; case 'upgrade' : if ( current_user_can('manage_options') ) { return sprintf( ''.__( 'Get Version %2$s' ).'', 'update-core.php', $cur->current); break; } case 'latest' : default : return sprintf( __( 'Version %s' ), $GLOBALS['wp_version'] ); break; } } add_filter( 'update_footer', 'core_update_footer' ); function update_nag() { global $pagenow; if ( 'update-core.php' == $pagenow ) return; $cur = get_preferred_from_update_core(); if ( ! isset( $cur->response ) || $cur->response != 'upgrade' ) return false; if ( current_user_can('manage_options') ) $msg = sprintf( __('WordPress %1$s is available! Please update now.'), $cur->current, 'update-core.php' ); else $msg = sprintf( __('WordPress %1$s is available! Please notify the site administrator.'), $cur->current ); echo "