Make WordPress Core

Ticket #11562: 11562.diff

File 11562.diff, 4.7 KB (added by ryan, 15 years ago)

Use the new fields

  • wp-includes/update.php

     
    4444        else
    4545                $mysql_version = 'N/A';
    4646        $local_package = isset( $wp_local_package )? $wp_local_package : '';
    47         $url = "http://api.wordpress.org/core/version-check/1.3/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package";
     47        $url = "http://api.wordpress.org/core/version-check/1.4/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package";
    4848
    4949        $options = array(
    5050                'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
     
    7474                        $new_option->current = esc_attr( $returns[3] );
    7575                if ( isset( $returns[4] ) )
    7676                        $new_option->locale = esc_attr( $returns[4] );
     77                if ( isset( $returns[5] ) )
     78                        $new_option->php_version = esc_attr( $returns[5] );
     79                if ( isset( $returns[6] ) )
     80                        $new_option->mysql_version = esc_attr( $returns[6] );
    7781                $new_options[] = $new_option;
    7882        }
    7983
  • wp-admin/update-core.php

     
    1313        wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
    1414
    1515function list_core_update( $update ) {
    16         global $wp_local_package;
     16        global $wp_local_package, $wpdb;
    1717        $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ?
    1818                        $update->current : sprintf("%s&ndash;<strong>%s</strong>", $update->current, $update->locale);
    1919        $current = false;
     
    2121                $current = true;
    2222        $submit = __('Upgrade Automatically');
    2323        $form_action = 'update-core.php?action=do-core-upgrade';
     24        $php_version    = phpversion();
     25        $mysql_version  = $wpdb->db_version();
     26        $show_buttons = true;
    2427        if ( 'development' == $update->response ) {
    2528                $message = __('You are using a development version of WordPress.  You can upgrade to the latest nightly build automatically or download the nightly build and install it manually:');
    2629                $download = __('Download nightly build');
     
    3033                        $submit = __('Re-install Automatically');
    3134                        $form_action = 'update-core.php?action=do-core-reinstall';
    3235                } else {
    33                         $message =      sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
     36                        $php_compat     = version_compare( $php_version, $update->php_version, '>=' );
     37                        $mysql_compat   = version_compare( $mysql_version, $update->mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
     38                        if ( !$mysql_compat && !$php_compat )
     39                                $message = sprintf( __('You cannot upgrade because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.'), $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version );
     40                        elseif ( !$php_compat )
     41                                $message = sprintf( __('You cannot upgrade because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version );
     42                        elseif ( !$mysql_compat )
     43                                $message = sprintf( __('You cannot upgrade because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version );
     44                        else
     45                                $message =      sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
     46                        if ( !$mysql_compat || !$php_compat )
     47                                $show_buttons = false;
    3448                }
    3549                $download = sprintf(__('Download %s'), $version_string);
    3650        }
     
    4155        echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
    4256        wp_nonce_field('upgrade-core');
    4357        echo '<p>';
    44         echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" />&nbsp;';
    4558        echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
    4659        echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
    47         echo '<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
     60        if ( $show_buttons ) {
     61                echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" />&nbsp;';
     62                echo '<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
     63        }
    4864        if ( 'en_US' != $update->locale )
    4965                if ( !isset( $update->dismissed ) || !$update->dismissed )
    5066                        echo '<input id="dismiss" class="button" type="submit" value="' . esc_attr__('Hide this update') . '" name="dismiss" />';