]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/update-core.php
Wordpress 3.1
[autoinstalls/wordpress.git] / wp-admin / update-core.php
index 81472f23c5d2968db8612ec4c678ed277f364514..3671915d577dd73d9a5f196c57b315edb6cc5874 100644 (file)
@@ -9,8 +9,13 @@
 /** WordPress Administration Bootstrap */
 require_once('./admin.php');
 
-if ( ! current_user_can('update_plugins') )
-       wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
+if ( is_multisite() && ! is_network_admin() ) {
+       wp_redirect( network_admin_url( 'update-core.php' ) );
+       exit();
+}
+
+if ( ! current_user_can( 'update_core' ) )
+       wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
 
 function list_core_update( $update ) {
        global $wp_local_package, $wpdb;
@@ -58,19 +63,19 @@ function list_core_update( $update ) {
        echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
        echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
        if ( $show_buttons ) {
-               echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" />&nbsp;';
-               echo '<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
+               submit_button( $submit, 'button', 'upgrade', false );
+               echo '&nbsp;<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
        }
        if ( 'en_US' != $update->locale )
                if ( !isset( $update->dismissed ) || !$update->dismissed )
-                       echo '<input id="dismiss" class="button" type="submit" value="' . esc_attr__('Hide this update') . '" name="dismiss" />';
+                       submit_button( __('Hide this update'), 'button', 'dismiss', false );
                else
-                       echo '<input id="undismiss" class="button" type="submit" value="' . esc_attr__('Bring back this update') . '" name="undismiss" />';
+                       submit_button( __('Bring back this update'), 'button', 'undismiss', false );
        echo '</p>';
        if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) )
            echo '<p class="hint">'.__('This localized version contains both the translation and various other localization fixes. You can skip upgrading if you want to keep your current translation.').'</p>';
        else if ( 'en_US' == $update->locale && get_locale() != 'en_US' ) {
-           echo '<p class="hint">'.sprintf( __('You are about to install WordPress %s <strong>in English.</strong> There is a chance this upgrade will break your translation. You may prefer to wait for the localized version to be released.'), $update->current ).'</p>';
+           echo '<p class="hint">'.sprintf( __('You are about to install WordPress %s <strong>in English (US).</strong> There is a chance this update will break your translation. You may prefer to wait for the localized version to be released.'), $update->current ).'</p>';
        }
        echo '</form>';
 
@@ -121,17 +126,26 @@ function core_upgrade_preamble() {
 <?php
        if ( $upgrade_error ) {
                echo '<div class="error"><p>';
-               _e('Please select one or more plugins to upgrade.');
+               if ( $upgrade_error == 'themes' )
+                       _e('Please select one or more themes to update.');
+               else
+                       _e('Please select one or more plugins to update.');
                echo '</p></div>';
        }
 
+       echo '<p>';
+       /* translators: %1 date, %2 time. */
+       printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
+       echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
+       echo '</p>';
+
        if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
                echo '<h3>';
                _e('You have the latest version of WordPress.');
                echo '</h3>';
        } else {
-               echo '<div class="updated"><p>';
-               _e('<strong>Important:</strong> before updating, please <a href="http://codex.wordpress.org/WordPress_Backups">backup your database and files</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.');
+               echo '<div class="updated inline"><p>';
+               _e('<strong>Important:</strong> before updating, please <a href="http://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="http://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.');
                echo '</p></div>';
 
                echo '<h3 class="response">';
@@ -142,9 +156,7 @@ function core_upgrade_preamble() {
        echo '<ul class="core-updates">';
        $alternate = true;
        foreach( (array) $updates as $update ) {
-               $class = $alternate? ' class="alternate"' : '';
-               $alternate = !$alternate;
-               echo "<li $class>";
+               echo '<li>';
                list_core_update( $update );
                echo '</li>';
        }
@@ -152,8 +164,10 @@ function core_upgrade_preamble() {
        echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.' ) . '</p>';
        dismissed_updates();
 
-       list_plugin_updates();
-       list_theme_updates();
+       if ( current_user_can( 'update_plugins' ) )
+               list_plugin_updates();
+       if ( current_user_can( 'update_themes' ) )
+               list_theme_updates();
        do_action('core_upgrade_preamble');
        echo '</div>';
 }
@@ -228,7 +242,7 @@ function list_plugin_updates() {
                echo "
        <tr class='active'>
                <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
-               <td class='plugin-title'><strong>{$plugin_data->Name}</strong>" . sprintf(__('You have version %1$s installed. Update to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . $compat . $upgrade_notice . "</td>
+               <td><strong>{$plugin_data->Name}</strong><br />" . sprintf(__('You have version %1$s installed. Update to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . $compat . $upgrade_notice . "</td>
        </tr>";
        }
 ?>
@@ -252,7 +266,7 @@ function list_theme_updates() {
 ?>
 <h3><?php _e( 'Themes' ); ?></h3>
 <p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.' ); ?></p>
-<p><?php printf( __('<strong>Please Note:</strong> Any customizations you have made to the Themes files will be lost. Please consider using <a href="%s">child themes</a> for modifications.'), _x('http://codex.wordpress.org/Child_Themes', 'Link used in suggestion to use child themes in GUU') ); ?></p>
+<p><?php printf( __('<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.'), _x('http://codex.wordpress.org/Child_Themes', 'Link used in suggestion to use child themes in GUU') ); ?></p>
 <form method="post" action="<?php echo $form_action; ?>" name="upgrade-themes" class="upgrade">
 <?php wp_nonce_field('upgrade-core'); ?>
 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
@@ -320,7 +334,7 @@ function do_core_upgrade( $reinstall = false ) {
        }
 ?>
        <div class="wrap">
-       <?php screen_icon(); ?>
+       <?php screen_icon('tools'); ?>
        <h2><?php _e('Update WordPress'); ?></h2>
 <?php
        if ( $wp_filesystem->errors->get_error_code() ) {
@@ -341,7 +355,7 @@ function do_core_upgrade( $reinstall = false ) {
                        show_message( __('Installation Failed') );
        } else {
                show_message( __('WordPress updated successfully') );
-               show_message( '<strong>' . __('Actions:') . '</strong> <a href="' . esc_url( admin_url() ) . '">' . __('Go to Dashboard') . '</a>' );
+               show_message( '<a href="' . esc_url( self_admin_url() ) . '">' . __('Go to Dashboard') . '</a>' );
        }
        echo '</div>';
 }
@@ -354,6 +368,7 @@ function do_dismiss_core_update() {
                return;
        dismiss_core_update( $update );
        wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
+       exit;
 }
 
 function do_undismiss_core_update() {
@@ -364,6 +379,7 @@ function do_undismiss_core_update() {
                return;
        undismiss_core_update( $version, $locale );
        wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
+       exit;
 }
 
 function no_update_actions($actions) {
@@ -373,8 +389,9 @@ function no_update_actions($actions) {
 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
 
 $upgrade_error = false;
-if ( 'do-plugin-upgrade' == $action && !isset($_GET['plugins']) && !isset($_POST['checked']) ) {
-       $upgrade_error = true;
+if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) )
+       && ! isset( $_POST['checked'] ) ) {
+       $upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins';
        $action = 'upgrade-core';
 }
 
@@ -384,16 +401,18 @@ $parent_file = 'tools.php';
 add_contextual_help($current_screen,
        '<p>' . __('This screen lets you update to the latest version of WordPress as well as update your themes and plugins from the WordPress.org repository. When updates are available, the number of available updates will appear in a bubble on the left hand menu as a notification. It is very important to keep your WordPress installation up to date for security reasons, so when you see a number appear, make sure you take the time to update, which is an easy process.') . '</p>' .
        '<p>' . __('Updating your WordPress installation is a simple one-click procedure; just click on the Update button when it says a new version is available.') . '</p>' .
-       '<p>' . __('To upgrade themes or plugins from this screen, use the checkboxes to make your selection and click on the appropriate Update button. Check the box at the top of the Themes or Plugins section to select all and update them all at once.') . '</p>' .
+       '<p>' . __('To update themes or plugins from this screen, use the checkboxes to make your selection and click on the appropriate Update button. Check the box at the top of the Themes or Plugins section to select all and update them all at once.') . '</p>' .
        '<p><strong>' . __('For more information:') . '</strong></p>' .
        '<p>' . __('<a href="http://codex.wordpress.org/Dashboard_Updates_SubPanel" target="_blank">Documentation on Updating WordPress</a>') . '</p>' .
        '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
 );
 
 if ( 'upgrade-core' == $action ) {
+
        wp_version_check();
-       require_once('./admin-header.php');
+       require_once(ABSPATH . 'wp-admin/admin-header.php');
        core_upgrade_preamble();
+
 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
        check_admin_referer('upgrade-core');
 
@@ -404,7 +423,7 @@ if ( 'upgrade-core' == $action ) {
        elseif ( isset( $_POST['undismiss'] ) )
                do_undismiss_core_update();
 
-       require_once('./admin-header.php');
+       require_once(ABSPATH . 'wp-admin/admin-header.php');
        if ( 'do-core-reinstall' == $action )
                $reinstall = true;
        else
@@ -414,6 +433,10 @@ if ( 'upgrade-core' == $action ) {
                do_core_upgrade($reinstall);
 
 } elseif ( 'do-plugin-upgrade' == $action ) {
+
+       if ( ! current_user_can( 'update_plugins' ) )
+               wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
+
        check_admin_referer('upgrade-core');
 
        if ( isset( $_GET['plugins'] ) ) {
@@ -421,7 +444,7 @@ if ( 'upgrade-core' == $action ) {
        } elseif ( isset( $_POST['checked'] ) ) {
                $plugins = (array) $_POST['checked'];
        } else {
-               wp_redirect('update-core.php');
+               wp_redirect( admin_url('update-core.php') );
                exit;
        }
 
@@ -430,13 +453,18 @@ if ( 'upgrade-core' == $action ) {
 
        $title = __('Update Plugins');
 
-       require_once('./admin-header.php');
+       require_once(ABSPATH . 'wp-admin/admin-header.php');
        echo '<div class="wrap">';
        screen_icon('plugins');
        echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
        echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
        echo '</div>';
+
 } elseif ( 'do-theme-upgrade' == $action ) {
+
+       if ( ! current_user_can( 'update_themes' ) )
+               wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
+
        check_admin_referer('upgrade-core');
 
        if ( isset( $_GET['themes'] ) ) {
@@ -444,7 +472,7 @@ if ( 'upgrade-core' == $action ) {
        } elseif ( isset( $_POST['checked'] ) ) {
                $themes = (array) $_POST['checked'];
        } else {
-               wp_redirect('update-core.php');
+               wp_redirect( admin_url('update-core.php') );
                exit;
        }
 
@@ -453,7 +481,7 @@ if ( 'upgrade-core' == $action ) {
 
        $title = __('Update Themes');
 
-       require_once('./admin-header.php');
+       require_once(ABSPATH . 'wp-admin/admin-header.php');
        echo '<div class="wrap">';
        screen_icon('themes');
        echo '<h2>' . esc_html__('Update Themes') . '</h2>';
@@ -461,4 +489,4 @@ if ( 'upgrade-core' == $action ) {
        echo '</div>';
 }
 
-include('./admin-footer.php');
+include(ABSPATH . 'wp-admin/admin-footer.php');