]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/update-core.php
WordPress 4.1.2-scripts
[autoinstalls/wordpress.git] / wp-admin / update-core.php
index 61535996891a465523edf3facaa80ea97dc0d475..600db23eee9a197c63585b968545c6bae7833c0b 100644 (file)
@@ -11,6 +11,7 @@ require_once( dirname( __FILE__ ) . '/admin.php' );
 
 wp_enqueue_style( 'plugin-install' );
 wp_enqueue_script( 'plugin-install' );
+wp_enqueue_script( 'updates' );
 add_thickbox();
 
 if ( is_multisite() && ! is_network_admin() ) {
@@ -133,7 +134,7 @@ function dismissed_updates() {
 /**
  * Display upgrade WordPress for downloading latest or upgrading automatically form.
  *
- * @since 2.7
+ * @since 2.7.0
  *
  * @return null
  */
@@ -173,12 +174,14 @@ function core_upgrade_preamble() {
        if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
                require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
                $upgrader = new WP_Automatic_Updater;
-               if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) )
-                       echo '<div class="updated inline"><p><strong>BETA TESTERS:</strong> This site is set up to install updates of future beta versions automatically.</p></div>';
+               if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) ) {
+                       echo '<div class="updated inline"><p>';
+                       echo '<strong>' . __( 'BETA TESTERS:' ) . '</strong> ' . __( 'This site is set up to install updates of future beta versions automatically.' );
+                       echo '</p></div>';
+               }
        }
 
        echo '<ul class="core-updates">';
-       $alternate = true;
        foreach( (array) $updates as $update ) {
                echo '<li>';
                list_core_update( $update );
@@ -220,7 +223,7 @@ function list_plugin_updates() {
 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
 <?php wp_nonce_field('upgrade-core'); ?>
 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
-<table class="widefat" cellspacing="0" id="update-plugins-table">
+<table class="widefat" id="update-plugins-table">
        <thead>
        <tr>
                <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
@@ -238,6 +241,10 @@ function list_plugin_updates() {
 <?php
        foreach ( (array) $plugins as $plugin_file => $plugin_data) {
                $info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
+               if ( is_wp_error( $info ) ) {
+                       $info = false;
+               }
+
                // Get plugin compat for running version of WordPress.
                if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
                        $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
@@ -298,7 +305,7 @@ function list_theme_updates() {
 <form method="post" action="<?php echo esc_url( $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>
-<table class="widefat" cellspacing="0" id="update-themes-table">
+<table class="widefat" id="update-themes-table">
        <thead>
        <tr>
                <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
@@ -342,9 +349,9 @@ function list_translation_updates() {
        $form_action = 'update-core.php?action=do-translation-upgrade';
        ?>
        <h3><?php _e( 'Translations' ); ?></h3>
-       <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
+       <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade">
                <p><?php _e( 'Some of your translations are out of date.' ); ?></p>
-               <?php wp_nonce_field('upgrade-translations'); ?>
+               <?php wp_nonce_field( 'upgrade-translations' ); ?>
                <p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
        </form>
        <?php
@@ -353,14 +360,14 @@ function list_translation_updates() {
 /**
  * Upgrade WordPress core display.
  *
- * @since 2.7
+ * @since 2.7.0
  *
  * @return null
  */
 function do_core_upgrade( $reinstall = false ) {
        global $wp_filesystem;
 
-       include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
+       include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
 
        if ( $reinstall )
                $url = 'update-core.php?action=do-core-reinstall';
@@ -374,19 +381,23 @@ function do_core_upgrade( $reinstall = false ) {
        if ( !$update )
                return;
 
+       // Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
+       // that it's safe to do so. This only happens when there are no new files to create.
+       $allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
+
 ?>
        <div class="wrap">
        <h2><?php _e('Update WordPress'); ?></h2>
 <?php
 
-       if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH ) ) ) {
+       if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) {
                echo '</div>';
                return;
        }
 
-       if ( ! WP_Filesystem( $credentials, ABSPATH ) ) {
+       if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
                // Failed to connect, Error and request again
-               request_filesystem_credentials( $url, '', true, ABSPATH );
+               request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
                echo '</div>';
                return;
        }
@@ -404,7 +415,9 @@ function do_core_upgrade( $reinstall = false ) {
        add_filter( 'update_feedback', 'show_message' );
 
        $upgrader = new Core_Upgrader();
-       $result = $upgrader->upgrade( $update );
+       $result = $upgrader->upgrade( $update, array(
+               'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership
+       ) );
 
        if ( is_wp_error($result) ) {
                show_message($result);
@@ -457,10 +470,10 @@ if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! is
 }
 
 $title = __('WordPress Updates');
-$parent_file = 'tools.php';
+$parent_file = 'index.php';
 
 $updates_overview  = '<p>' . __( 'On this screen, you can update to the latest version of WordPress, as well as update your themes and plugins from the WordPress.org repositories.' ) . '</p>';
-$updates_overview .= '<p>' . __( 'If an update is available, you&#8127;ll see a notification appear in the Toolbar and navigation menu.' ) . ' ' . __( 'Keeping your site up to date is important for your site&#8217;s security, and makes the internet a safer place for you and your readers.' ) . '</p>';
+$updates_overview .= '<p>' . __( 'If an update is available, you&#8127;ll see a notification appear in the Toolbar and navigation menu.' ) . ' ' . __( 'Keeping your site updated is important for security. It also makes the internet a safer place for you and your readers.' ) . '</p>';
 
 get_current_screen()->add_help_tab( array(
        'id'      => 'overview',
@@ -484,7 +497,7 @@ get_current_screen()->add_help_tab( array(
 get_current_screen()->set_help_sidebar(
        '<p><strong>' . __('For more information:') . '</strong></p>' .
        '<p>' . __( '<a href="http://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>' ) . '</p>' .
-       '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
+       '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
 );
 
 if ( 'upgrade-core' == $action ) {
@@ -521,7 +534,12 @@ if ( 'upgrade-core' == $action ) {
        if ( $core || $plugins || $themes )
                list_translation_updates();
        unset( $core, $plugins, $themes );
-       do_action('core_upgrade_preamble');
+       /**
+        * Fires after the core, plugin, and theme update tables.
+        *
+        * @since 2.9.0
+        */
+       do_action( 'core_upgrade_preamble' );
        echo '</div>';
        include(ABSPATH . 'wp-admin/admin-footer.php');
 
@@ -532,8 +550,7 @@ if ( 'upgrade-core' == $action ) {
 
        check_admin_referer('upgrade-core');
 
-       // do the (un)dismiss actions before headers,
-       // so that they can redirect
+       // Do the (un)dismiss actions before headers, so that they can redirect.
        if ( isset( $_POST['dismiss'] ) )
                do_dismiss_core_update();
        elseif ( isset( $_POST['undismiss'] ) )
@@ -574,7 +591,7 @@ if ( 'upgrade-core' == $action ) {
        require_once(ABSPATH . 'wp-admin/admin-header.php');
        echo '<div class="wrap">';
        echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
-       echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
+       echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>';
        echo '</div>';
        include(ABSPATH . 'wp-admin/admin-footer.php');
 
@@ -600,10 +617,12 @@ if ( 'upgrade-core' == $action ) {
        $title = __('Update Themes');
 
        require_once(ABSPATH . 'wp-admin/admin-header.php');
-       echo '<div class="wrap">';
-       echo '<h2>' . esc_html__('Update Themes') . '</h2>';
-       echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
-       echo '</div>';
+       ?>
+       <div class="wrap">
+               <h2><?php echo esc_html__('Update Themes') ?></h2>
+               <iframe src="<?php echo $url ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>
+       </div>
+       <?php
        include(ABSPATH . 'wp-admin/admin-footer.php');
 
 } elseif ( 'do-translation-upgrade' == $action ) {
@@ -627,5 +646,14 @@ if ( 'upgrade-core' == $action ) {
        require_once( ABSPATH . 'wp-admin/admin-footer.php' );
 
 } else {
-       do_action('update-core-custom_' . $action);
+       /**
+        * Fires for each custom update action on the WordPress Updates screen.
+        *
+        * The dynamic portion of the hook name, `$action`, refers to the
+        * passed update action. The hook fires in lieu of all available
+        * default update actions.
+        *
+        * @since 3.2.0
+        */
+       do_action( "update-core-custom_{$action}" );
 }