Make WordPress Core

Changeset 9543


Ignore:
Timestamp:
11/06/2008 03:31:41 AM (18 years ago)
Author:
ryan
Message:

More core update to update-core.php. Allow re-installing current version (requires api.wp.org changes)

Location:
trunk/wp-admin
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/update.php

    r9524 r9543  
    9595        switch ( $cur->response ) {
    9696        case 'development' :
    97                 return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), $GLOBALS['wp_version'], 'update.php?action=upgrade-core');
     97                return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), $GLOBALS['wp_version'], 'update-core.php');
    9898        break;
    9999
    100100        case 'upgrade' :
    101101                if ( current_user_can('manage_options') ) {
    102                         return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', wp_nonce_url('update.php?action=upgrade-core', 'upgrade-core'), $cur->current);
     102                        return sprintf( '<strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', 'update-core.php', $cur->current);
    103103                        break;
    104104                }
     
    119119
    120120        if ( current_user_can('manage_options') )
    121                 $msg = sprintf( __('WordPress %1$s is available! <a href="%2$s">Please update now</a>.'), $cur->current, 'update.php?action=upgrade-core' );
     121                $msg = sprintf( __('WordPress %1$s is available! <a href="%2$s">Please update now</a>.'), $cur->current, 'update-core.php' );
    122122        else
    123123                $msg = sprintf( __('WordPress %1$s is available! Please notify the site administrator.'), $cur->current );
     
    133133        $msg = sprintf( __('You are using <span class="b">WordPress %s</span>.'), $GLOBALS['wp_version'] );
    134134        if ( isset( $cur->response ) && $cur->response == 'upgrade' && current_user_can('manage_options') )
    135                 $msg .= " <a href='update.php?action=upgrade-core' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
     135                $msg .= " <a href='update-core.php' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
    136136
    137137        echo "<span id='wp-version-message'>$msg</span>";
     
    480480
    481481        if ( current_user_can('manage_options') )
    482                 $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update.php?action=upgrade-core' );
     482                $msg = sprintf( __('An automated WordPress update has failed to complete - <a href="%s">please attempt the update again now</a>.'), 'update-core.php' );
    483483        else
    484484                $msg = __('An automated WordPress update has failed to complete! Please notify the site administrator.');
  • trunk/wp-admin/menu.php

    r9537 r9543  
    9292        if ( ! $is_opera )
    9393                $submenu['import.php'][20] = array( __('Turbo'), 'read', 'turbo.php' );
    94         $submenu['import.php'][30] = array( __('Update'), 'read',  wp_nonce_url('update.php?action=upgrade-core', 'upgrade-core'));
     94        $submenu['import.php'][30] = array( __('Update'), 'read',  'update-core.php');
    9595
    9696$menu[50] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top-last', 'menu-settings', 'images/menu/settings.png' );
  • trunk/wp-admin/update.php

    r9441 r9543  
    11<?php
    22/**
    3  * Update Plugin / Core administration panel.
     3 * Update Plugin/Theme administration panel.
    44 *
    55 * @package WordPress
     
    123123}
    124124
    125 function list_core_update( $update ) {
    126         $version_string = 'en_US' == $update->locale?
    127                         $update->current : sprintf("%s&ndash;<strong>%s</strong>", $update->current, $update->locale);
    128         if ( 'development' == $update->response ) {
    129                 $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:');
    130                 $submit = __('Download nightly build');
    131         } else {
    132                 $message =      sprintf(__('You can upgrade to version %s automatically or download the package and install it manually:'), $version_string);
    133                 $submit = sprintf(__('Download %s'), $version_string);
    134         }
    135 
    136         echo '<p>';
    137         echo $message;
    138         echo '</p>';
    139         echo '<form method="post" action="update.php?action=do-core-upgrade" name="upgrade" class="upgrade">';
    140         wp_nonce_field('upgrade-core');
    141         echo '<p>';
    142         echo '<input id="upgrade" class="button" type="submit" value="' . __('Upgrade Automatically') . '" name="upgrade" />&nbsp;';
    143         echo '<input name="version" value="'.$update->current.'" type="hidden"/>';
    144         echo '<input name="locale" value="'.$update->locale.'" type="hidden"/>';
    145         echo '<a href="' . $update->package . '" class="button">' . $submit . '</a>&nbsp;';
    146         if ( 'en_US' != $update->locale )
    147                 if ( !isset( $update->dismissed ) || !$update->dismissed )
    148                         echo '<input id="dismiss" class="button" type="submit" value="' . attribute_escape(__('Hide this update')) . '" name="dismiss" />';
    149                 else
    150                         echo '<input id="undismiss" class="button" type="submit" value="' . attribute_escape(__('Bring back this update')) . '" name="undismiss" />';
    151         echo '</p>';
    152         echo '</form>';
    153        
    154 }
    155 
    156 function dismissed_updates() {
    157         $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
    158         if ( $dismissed ) {
    159                
    160                 $show_text = js_escape(__('Show hidden updates'));
    161                 $hide_text = js_escape(__('Hide hidden updates'));
    162         ?>
    163         <script type="text/javascript">
    164                
    165                 jQuery(function($) {
    166                         $('dismissed-updates').show();
    167                         $('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
    168                         $('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
    169                 });
    170         </script>
    171         <?php
    172                 echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
    173                 echo '<ul id="dismissed-updates" class="core-updates dismissed">';
    174                 foreach($dismissed as $update) {
    175                         echo '<li>';
    176                         list_core_update( $update );
    177                         echo '</li>';
    178                 }
    179                 echo '</ul>';
    180         }       
    181 }
    182 
    183 /**
    184  * Display upgrade WordPress for downloading latest or upgrading automatically form.
    185  *
    186  * @since 2.7
    187  *
    188  * @return null
    189  */
    190 function core_upgrade_preamble() {
    191         $updates = get_core_updates();
    192        
    193         echo '<div class="wrap">';
    194         echo '<h2>' . __('Upgrade WordPress') . '</h2>';
    195 
    196         if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
    197                 echo '<h3>';
    198                 _e('You have the latest version of WordPress. You do not need to upgrade');
    199                 echo '</h3>';
    200                 dismissed_updates();
    201                 echo '</div>';
    202                 return;
    203         }
    204 
    205         echo '<div class="updated fade"><p>';
    206         _e('<strong>Important:</strong> before upgrading, please <a href="http://codex.wordpress.org/WordPress_Backups">backup your database and files</a>.'); 
    207         echo '</p></div>';
    208        
    209         echo '<h3 class="response">';
    210         _e( 'There is a new version of WordPress available for upgrade' );
    211         echo '</h3>';
    212         echo '<ul class="core-updates">';
    213         $alternate = true;
    214         foreach( $updates as $update ) {
    215                 $class = $alternate? ' class="alternate"' : '';
    216                 $alternate = !$alternate;
    217                 echo "<li $class>";
    218                 list_core_update( $update );
    219                 echo '</li>';
    220         }
    221         echo '</ul>';
    222         dismissed_updates();
    223         echo '</div>';
    224 }
    225 
    226 
    227 /**
    228  * Upgrade WordPress core display.
    229  *
    230  * @since 2.7
    231  *
    232  * @return null
    233  */
    234 function do_core_upgrade() {
    235         global $wp_filesystem;
    236        
    237         $url = wp_nonce_url('update.php?action=do-core-upgrade', 'upgrade-core');
    238         if ( false === ($credentials = request_filesystem_credentials($url)) )
    239                 return;
    240                
    241         $version = isset( $_POST['version'] )? $_POST['version'] : false;
    242         $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
    243         $update = find_core_update( $version, $locale );
    244         if ( !$update )
    245                 return;
    246                
    247 
    248         if ( ! WP_Filesystem($credentials) ) {
    249                 request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
    250                 return;
    251         }
    252 
    253         echo '<div class="wrap">';
    254         echo '<h2>' . __('Upgrade WordPress') . '</h2>';
    255         if ( $wp_filesystem->errors->get_error_code() ) {
    256                 foreach ( $wp_filesystem->errors->get_error_messages() as $message )
    257                         show_message($message);
    258                 echo '</div>';
    259                 return;
    260         }
    261 
    262         $result = wp_update_core($update, 'show_message');
    263 
    264         if ( is_wp_error($result) ) {
    265                 show_message($result);
    266                 if ('up_to_date' != $result->get_error_code() )
    267                         show_message( __('Installation Failed') );
    268         } else {
    269                 show_message( __('WordPress upgraded successfully') );
    270         }
    271         echo '</div>';
    272 }
    273 
    274 function do_dismiss_core_update() {
    275         $version = isset( $_POST['version'] )? $_POST['version'] : false;
    276         $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
    277         $update = find_core_update( $version, $locale );
    278         if ( !$update )
    279                 return;
    280         dismiss_core_update( $update );
    281         wp_redirect( wp_nonce_url('update.php?action=upgrade-core', 'upgrade-core') );
    282 }
    283 
    284 function do_undismiss_core_update() {
    285         $version = isset( $_POST['version'] )? $_POST['version'] : false;
    286         $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
    287         $update = find_core_update( $version, $locale );
    288         if ( !$update )
    289                 return;
    290         undismiss_core_update( $version, $locale );
    291         wp_redirect( wp_nonce_url('update.php?action=upgrade-core', 'upgrade-core') );
    292 }
    293 
    294125if ( isset($_GET['action']) ) {
    295126        $plugin = isset($_GET['plugin']) ? trim($_GET['plugin']) : '';
     
    323154                }
    324155                iframe_footer();
    325         } elseif ( 'upgrade-core' == $action ) {
    326                 $title = __('Upgrade WordPress');
    327                 $parent_file = 'index.php';
    328                 require_once('admin-header.php');
    329                 core_upgrade_preamble();
    330                 include('admin-footer.php');
    331         } elseif ( 'do-core-upgrade' == $action ) {
    332                 check_admin_referer('upgrade-core');
    333                 $title = __('Upgrade WordPress');
    334                 $parent_file = 'index.php';
    335                 // do the (un)dismiss actions before headers,
    336                 // so that they can redirect
    337                 if ( isset( $_POST['dismiss'] ) )
    338                         do_dismiss_core_update();
    339                 elseif ( isset( $_POST['undismiss'] ) )
    340                         do_undismiss_core_update();
    341                 require_once('admin-header.php');
    342                 if ( isset( $_POST['upgrade'] ) )
    343                         do_core_upgrade();
    344                 include('admin-footer.php');
    345156        } elseif ( 'upgrade-theme' == $action ) {       
    346157                check_admin_referer('upgrade-theme_' . $theme);
Note: See TracChangeset for help on using the changeset viewer.