Make WordPress Core

Ticket #16156: 16156.diff

File 16156.diff, 4.6 KB (added by dd32, 15 years ago)
  • wp-admin/update-core.php

     
    133133                echo '</p></div>';
    134134        }
    135135
    136         echo '<p>';
    137         /* translators: %1 date, %2 time. */
    138         printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
     136        $current = get_site_transient( 'update_core' );
     137        $current->last_success = $current->last_success  - 30*60*60;
     138        $last_success = $current->last_success + (get_option( 'gmt_offset' ) * 3600); // display teh time in the users localtimezone.
     139
     140        if ( $current->last_success > time()-24*60*60 ) { // If it was within the last 24hrs
     141                echo '<div><p>';
     142                /* translators: %1 date, %2 time. */
     143                printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ), $last_success ), date_i18n( get_option( 'time_format' ), $last_success ) );
     144        } else { // Update is not happening..
     145                echo '<div class="error"><p>';
     146                /* translators: %1 date, %2 time, %3 error string */
     147                printf( __('The last successful update check was over 24 hours ago (%1$s %2$s), This means that WordPress is encountering an error whilst performing the update check. The error that is being reported is <code>%3$s</code> See the <a href="">Codex</a> for potential solutions.'),
     148                                date_i18n( get_option( 'date_format' ), $last_success ), date_i18n( get_option( 'time_format' ), $last_success ), $current->error->get_error_message() );
     149        }
    139150        echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
    140         echo '</p>';
     151        echo '</p></div>';
    141152
    142153        if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
    143154                echo '<h3>';
  • wp-includes/update.php

     
    2323        if ( defined('WP_INSTALLING') )
    2424                return;
    2525
    26         global $wp_version, $wpdb, $wp_local_package;
     26        global $wpdb, $wp_local_package;
     27        include ABSPATH . WPINC . '/version.php'; // for an unmodified $wp_version
    2728        $php_version = phpversion();
    2829
    2930        $current = get_site_transient( 'update_core' );
     
    3132                $current = new stdClass;
    3233                $current->updates = array();
    3334                $current->version_checked = $wp_version;
     35                $current->last_success = false;
    3436        }
    3537
    3638        $locale = apply_filters( 'core_version_check_locale', get_locale() );
     
    5759        }
    5860
    5961        $local_package = isset( $wp_local_package )? $wp_local_package : '';
    60         $url = "http://api.wordpress.org/core/version-check/1.5/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package&blogs=$num_blogs&users={$user_count['total_users']}&multisite_enabled=$multisite_enabled";
     62        $url = "http://localhost/core/version-check/1.5/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package&blogs=$num_blogs&users={$user_count['total_users']}&multisite_enabled=$multisite_enabled";
    6163
    6264        $options = array(
    6365                'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
     
    7072
    7173        $response = wp_remote_get($url, $options);
    7274
    73         if ( is_wp_error( $response ) )
     75        if ( is_wp_error( $response ) || 200 != $response['response']['code'] /* || 'php/serialized' != Some header */ ) {
     76                $current->error = is_wp_error($response) ? $response : new WP_Error('update_404', __('The server returned an unexpected response'));
     77                set_site_transient( 'update_core', $current );
    7478                return false;
     79        }
    7580
    76         if ( 200 != $response['response']['code'] )
    77                 return false;
    78 
    7981        $body = trim( $response['body'] );
    8082        $body = str_replace(array("\r\n", "\r"), "\n", $body);
    8183        $new_options = array();
     
    101103        $updates = new stdClass();
    102104        $updates->updates = $new_options;
    103105        $updates->last_checked = time();
     106        $updates->last_success = time();
    104107        $updates->version_checked = $wp_version;
    105108        set_site_transient( 'update_core',  $updates);
    106109}
     
    119122 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
    120123 */
    121124function wp_update_plugins() {
    122         global $wp_version;
     125        include ABSPATH . WPINC . '/version.php'; // for an unmodified $wp_version
    123126
    124127        if ( defined('WP_INSTALLING') )
    125128                return false;
     
    204207 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
    205208 */
    206209function wp_update_themes( ) {
    207         global $wp_version;
     210        include ABSPATH . WPINC . '/version.php'; // for an unmodified $wp_version
    208211
    209212        if ( defined( 'WP_INSTALLING' ) )
    210213                return false;