wp/wp-admin/update-core.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
     9 /** WordPress Administration Bootstrap */
     9 /** WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    11 
    11 
    12 wp_enqueue_style( 'plugin-install' );
    12 wp_enqueue_style( 'plugin-install' );
    13 wp_enqueue_script( 'plugin-install' );
    13 wp_enqueue_script( 'plugin-install' );
       
    14 wp_enqueue_script( 'updates' );
    14 add_thickbox();
    15 add_thickbox();
    15 
    16 
    16 if ( is_multisite() && ! is_network_admin() ) {
    17 if ( is_multisite() && ! is_network_admin() ) {
    17 	wp_redirect( network_admin_url( 'update-core.php' ) );
    18 	wp_redirect( network_admin_url( 'update-core.php' ) );
    18 	exit();
    19 	exit();
    55 				$mysql_compat = true;
    56 				$mysql_compat = true;
    56 			else
    57 			else
    57 				$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
    58 				$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );
    58 
    59 
    59 			if ( !$mysql_compat && !$php_compat )
    60 			if ( !$mysql_compat && !$php_compat )
    60 				$message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> 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 );
    61 				$message = sprintf( __('You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> 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 );
    61 			elseif ( !$php_compat )
    62 			elseif ( !$php_compat )
    62 				$message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version );
    63 				$message = sprintf( __('You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires PHP version %2$s or higher. You are running version %3$s.'), $update->current, $update->php_version, $php_version );
    63 			elseif ( !$mysql_compat )
    64 			elseif ( !$mysql_compat )
    64 				$message = sprintf( __('You cannot update because <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version );
    65 				$message = sprintf( __('You cannot update because <a href="https://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> requires MySQL version %2$s or higher. You are running version %3$s.'), $update->current, $update->mysql_version, $mysql_version );
    65 			else
    66 			else
    66 				$message = 	sprintf(__('You can update to <a href="http://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically or download the package and install it manually:'), $update->current, $version_string);
    67 				$message = 	sprintf(__('You can update to <a href="https://codex.wordpress.org/Version_%1$s">WordPress %2$s</a> automatically or download the package and install it manually:'), $update->current, $version_string);
    67 			if ( !$mysql_compat || !$php_compat )
    68 			if ( !$mysql_compat || !$php_compat )
    68 				$show_buttons = false;
    69 				$show_buttons = false;
    69 		}
    70 		}
    70 		$download = sprintf(__('Download %s'), $version_string);
    71 		$download = sprintf(__('Download %s'), $version_string);
    71 	}
    72 	}
   131 }
   132 }
   132 
   133 
   133 /**
   134 /**
   134  * Display upgrade WordPress for downloading latest or upgrading automatically form.
   135  * Display upgrade WordPress for downloading latest or upgrading automatically form.
   135  *
   136  *
   136  * @since 2.7
   137  * @since 2.7.0
   137  *
   138  *
   138  * @return null
   139  * @return null
   139  */
   140  */
   140 function core_upgrade_preamble() {
   141 function core_upgrade_preamble() {
   141 	global $wp_version, $required_php_version, $required_mysql_version;
   142 	global $wp_version, $required_php_version, $required_mysql_version;
   160 				echo ' ' . __( 'Future security updates will be applied automatically.' );
   161 				echo ' ' . __( 'Future security updates will be applied automatically.' );
   161 		}
   162 		}
   162 		echo '</h3>';
   163 		echo '</h3>';
   163 	} else {
   164 	} else {
   164 		echo '<div class="updated inline"><p>';
   165 		echo '<div class="updated inline"><p>';
   165 		_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.');
   166 		_e('<strong>Important:</strong> before updating, please <a href="https://codex.wordpress.org/WordPress_Backups">back up your database and files</a>. For help with updates, visit the <a href="https://codex.wordpress.org/Updating_WordPress">Updating WordPress</a> Codex page.');
   166 		echo '</p></div>';
   167 		echo '</p></div>';
   167 
   168 
   168 		echo '<h3 class="response">';
   169 		echo '<h3 class="response">';
   169 		_e( 'An updated version of WordPress is available.' );
   170 		_e( 'An updated version of WordPress is available.' );
   170 		echo '</h3>';
   171 		echo '</h3>';
   171 	}
   172 	}
   172 
   173 
   173 	if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
   174 	if ( isset( $updates[0] ) && $updates[0]->response == 'development' ) {
   174 		require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
   175 		require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
   175 		$upgrader = new WP_Automatic_Updater;
   176 		$upgrader = new WP_Automatic_Updater;
   176 		if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) )
   177 		if ( wp_http_supports( 'ssl' ) && $upgrader->should_update( 'core', $updates[0], ABSPATH ) ) {
   177 			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>';
   178 			echo '<div class="updated inline"><p>';
       
   179 			echo '<strong>' . __( 'BETA TESTERS:' ) . '</strong> ' . __( 'This site is set up to install updates of future beta versions automatically.' );
       
   180 			echo '</p></div>';
       
   181 		}
   178 	}
   182 	}
   179 
   183 
   180 	echo '<ul class="core-updates">';
   184 	echo '<ul class="core-updates">';
   181 	$alternate = true;
       
   182 	foreach( (array) $updates as $update ) {
   185 	foreach( (array) $updates as $update ) {
   183 		echo '<li>';
   186 		echo '<li>';
   184 		list_core_update( $update );
   187 		list_core_update( $update );
   185 		echo '</li>';
   188 		echo '</li>';
   186 	}
   189 	}
   218 <h3><?php _e( 'Plugins' ); ?></h3>
   221 <h3><?php _e( 'Plugins' ); ?></h3>
   219 <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click &#8220;Update Plugins&#8221;.' ); ?></p>
   222 <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click &#8220;Update Plugins&#8221;.' ); ?></p>
   220 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
   223 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-plugins" class="upgrade">
   221 <?php wp_nonce_field('upgrade-core'); ?>
   224 <?php wp_nonce_field('upgrade-core'); ?>
   222 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
   225 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
   223 <table class="widefat" cellspacing="0" id="update-plugins-table">
   226 <table class="widefat" id="update-plugins-table">
   224 	<thead>
   227 	<thead>
   225 	<tr>
   228 	<tr>
   226 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
   229 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
   227 		<th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
   230 		<th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
   228 	</tr>
   231 	</tr>
   229 	</thead>
   232 	</thead>
   230 
   233 
   231 	<tfoot>
       
   232 	<tr>
       
   233 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
       
   234 		<th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e('Select All'); ?></label></th>
       
   235 	</tr>
       
   236 	</tfoot>
       
   237 	<tbody class="plugins">
   234 	<tbody class="plugins">
   238 <?php
   235 <?php
   239 	foreach ( (array) $plugins as $plugin_file => $plugin_data) {
   236 	foreach ( (array) $plugins as $plugin_file => $plugin_data) {
   240 		$info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
   237 		$info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
       
   238 		if ( is_wp_error( $info ) ) {
       
   239 			$info = false;
       
   240 		}
       
   241 
   241 		// Get plugin compat for running version of WordPress.
   242 		// Get plugin compat for running version of WordPress.
   242 		if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
   243 		if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
   243 			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
   244 			$compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
   244 		} elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
   245 		} elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
   245 			$compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
   246 			$compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
   266 		$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '&section=changelog&TB_iframe=true&width=640&height=662');
   267 		$details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $plugin_data->update->slug . '&section=changelog&TB_iframe=true&width=640&height=662');
   267 		$details_text = sprintf(__('View version %1$s details'), $plugin_data->update->new_version);
   268 		$details_text = sprintf(__('View version %1$s details'), $plugin_data->update->new_version);
   268 		$details = sprintf('<a href="%1$s" class="thickbox" title="%2$s">%3$s</a>.', esc_url($details_url), esc_attr($plugin_data->Name), $details_text);
   269 		$details = sprintf('<a href="%1$s" class="thickbox" title="%2$s">%3$s</a>.', esc_url($details_url), esc_attr($plugin_data->Name), $details_text);
   269 
   270 
   270 		echo "
   271 		echo "
   271 	<tr class='active'>
   272 	<tr>
   272 		<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
   273 		<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
   273 		<td><p><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) . ' ' . $details . $compat . $upgrade_notice . "</p></td>
   274 		<td><p><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) . ' ' . $details . $compat . $upgrade_notice . "</p></td>
   274 	</tr>";
   275 	</tr>";
   275 	}
   276 	}
   276 ?>
   277 ?>
   277 	</tbody>
   278 	</tbody>
       
   279 
       
   280 	<tfoot>
       
   281 	<tr>
       
   282 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
       
   283 		<th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e( 'Select All' ); ?></label></th>
       
   284 	</tr>
       
   285 	</tfoot>
   278 </table>
   286 </table>
   279 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
   287 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
   280 </form>
   288 </form>
   281 <?php
   289 <?php
   282 }
   290 }
   292 	$form_action = 'update-core.php?action=do-theme-upgrade';
   300 	$form_action = 'update-core.php?action=do-theme-upgrade';
   293 
   301 
   294 ?>
   302 ?>
   295 <h3><?php _e( 'Themes' ); ?></h3>
   303 <h3><?php _e( 'Themes' ); ?></h3>
   296 <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>
   304 <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>
   297 <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.' ), __( 'http://codex.wordpress.org/Child_Themes' ) ); ?></p>
   305 <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.' ), __( 'https://codex.wordpress.org/Child_Themes' ) ); ?></p>
   298 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
   306 <form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
   299 <?php wp_nonce_field('upgrade-core'); ?>
   307 <?php wp_nonce_field('upgrade-core'); ?>
   300 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
   308 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
   301 <table class="widefat" cellspacing="0" id="update-themes-table">
   309 <table class="widefat" id="update-themes-table">
   302 	<thead>
   310 	<thead>
   303 	<tr>
   311 	<tr>
   304 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
   312 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
   305 		<th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
   313 		<th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
   306 	</tr>
   314 	</tr>
   307 	</thead>
   315 	</thead>
   308 
   316 
   309 	<tfoot>
       
   310 	<tr>
       
   311 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
       
   312 		<th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e('Select All'); ?></label></th>
       
   313 	</tr>
       
   314 	</tfoot>
       
   315 	<tbody class="plugins">
   317 	<tbody class="plugins">
   316 <?php
   318 <?php
   317 	foreach ( $themes as $stylesheet => $theme ) {
   319 	foreach ( $themes as $stylesheet => $theme ) {
   318 		echo "
   320 		echo "
   319 	<tr class='active'>
   321 	<tr>
   320 		<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' /></th>
   322 		<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' /></th>
   321 		<td class='plugin-title'><img src='" . esc_url( $theme->get_screenshot() ) . "' width='85' height='64' style='float:left; padding: 0 5px 5px' /><strong>" . $theme->display('Name') . '</strong> ' . sprintf( __( 'You have version %1$s installed. Update to %2$s.' ), $theme->display('Version'), $theme->update['new_version'] ) . "</td>
   323 		<td class='plugin-title'><img src='" . esc_url( $theme->get_screenshot() ) . "' width='85' height='64' style='float:left; padding: 0 5px 5px' /><strong>" . $theme->display('Name') . '</strong> ' . sprintf( __( 'You have version %1$s installed. Update to %2$s.' ), $theme->display('Version'), $theme->update['new_version'] ) . "</td>
   322 	</tr>";
   324 	</tr>";
   323 	}
   325 	}
   324 ?>
   326 ?>
   325 	</tbody>
   327 	</tbody>
       
   328 
       
   329 	<tfoot>
       
   330 	<tr>
       
   331 		<th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
       
   332 		<th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></th>
       
   333 	</tr>
       
   334 	</tfoot>
   326 </table>
   335 </table>
   327 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
   336 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
   328 </form>
   337 </form>
   329 <?php
   338 <?php
   330 }
   339 }
   340 	}
   349 	}
   341 
   350 
   342 	$form_action = 'update-core.php?action=do-translation-upgrade';
   351 	$form_action = 'update-core.php?action=do-translation-upgrade';
   343 	?>
   352 	?>
   344 	<h3><?php _e( 'Translations' ); ?></h3>
   353 	<h3><?php _e( 'Translations' ); ?></h3>
   345 	<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
   354 	<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-translations" class="upgrade">
   346 		<p><?php _e( 'Some of your translations are out of date.' ); ?></p>
   355 		<p><?php _e( 'New translations are available.' ); ?></p>
   347 		<?php wp_nonce_field('upgrade-translations'); ?>
   356 		<?php wp_nonce_field( 'upgrade-translations' ); ?>
   348 		<p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
   357 		<p><input class="button" type="submit" value="<?php esc_attr_e( 'Update Translations' ); ?>" name="upgrade" /></p>
   349 	</form>
   358 	</form>
   350 	<?php
   359 	<?php
   351 }
   360 }
   352 
   361 
   353 /**
   362 /**
   354  * Upgrade WordPress core display.
   363  * Upgrade WordPress core display.
   355  *
   364  *
   356  * @since 2.7
   365  * @since 2.7.0
   357  *
   366  *
   358  * @return null
   367  * @return null
   359  */
   368  */
   360 function do_core_upgrade( $reinstall = false ) {
   369 function do_core_upgrade( $reinstall = false ) {
   361 	global $wp_filesystem;
   370 	global $wp_filesystem;
   362 
   371 
   363 	include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
   372 	include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
   364 
   373 
   365 	if ( $reinstall )
   374 	if ( $reinstall )
   366 		$url = 'update-core.php?action=do-core-reinstall';
   375 		$url = 'update-core.php?action=do-core-reinstall';
   367 	else
   376 	else
   368 		$url = 'update-core.php?action=do-core-upgrade';
   377 		$url = 'update-core.php?action=do-core-upgrade';
   372 	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
   381 	$locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
   373 	$update = find_core_update( $version, $locale );
   382 	$update = find_core_update( $version, $locale );
   374 	if ( !$update )
   383 	if ( !$update )
   375 		return;
   384 		return;
   376 
   385 
       
   386 	// Allow relaxed file ownership writes for User-initiated upgrades when the API specifies
       
   387 	// that it's safe to do so. This only happens when there are no new files to create.
       
   388 	$allow_relaxed_file_ownership = ! $reinstall && isset( $update->new_files ) && ! $update->new_files;
       
   389 
   377 ?>
   390 ?>
   378 	<div class="wrap">
   391 	<div class="wrap">
   379 	<?php screen_icon('tools'); ?>
       
   380 	<h2><?php _e('Update WordPress'); ?></h2>
   392 	<h2><?php _e('Update WordPress'); ?></h2>
   381 <?php
   393 <?php
   382 
   394 
   383 	if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH ) ) ) {
   395 	if ( false === ( $credentials = request_filesystem_credentials( $url, '', false, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ) ) ) {
   384 		echo '</div>';
   396 		echo '</div>';
   385 		return;
   397 		return;
   386 	}
   398 	}
   387 
   399 
   388 	if ( ! WP_Filesystem( $credentials, ABSPATH ) ) {
   400 	if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
   389 		// Failed to connect, Error and request again
   401 		// Failed to connect, Error and request again
   390 		request_filesystem_credentials( $url, '', true, ABSPATH );
   402 		request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership );
   391 		echo '</div>';
   403 		echo '</div>';
   392 		return;
   404 		return;
   393 	}
   405 	}
   394 
   406 
   395 	if ( $wp_filesystem->errors->get_error_code() ) {
   407 	if ( $wp_filesystem->errors->get_error_code() ) {
   403 		$update->response = 'reinstall';
   415 		$update->response = 'reinstall';
   404 
   416 
   405 	add_filter( 'update_feedback', 'show_message' );
   417 	add_filter( 'update_feedback', 'show_message' );
   406 
   418 
   407 	$upgrader = new Core_Upgrader();
   419 	$upgrader = new Core_Upgrader();
   408 	$result = $upgrader->upgrade( $update );
   420 	$result = $upgrader->upgrade( $update, array(
       
   421 		'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership
       
   422 	) );
   409 
   423 
   410 	if ( is_wp_error($result) ) {
   424 	if ( is_wp_error($result) ) {
   411 		show_message($result);
   425 		show_message($result);
   412 		if ('up_to_date' != $result->get_error_code() )
   426 		if ('up_to_date' != $result->get_error_code() )
   413 			show_message( __('Installation Failed') );
   427 			show_message( __('Installation Failed') );
   446 	undismiss_core_update( $version, $locale );
   460 	undismiss_core_update( $version, $locale );
   447 	wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
   461 	wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
   448 	exit;
   462 	exit;
   449 }
   463 }
   450 
   464 
   451 function no_update_actions($actions) {
       
   452 	return '';
       
   453 }
       
   454 
       
   455 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
   465 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
   456 
   466 
   457 $upgrade_error = false;
   467 $upgrade_error = false;
   458 if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) )
   468 if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) )
   459 	&& ! isset( $_POST['checked'] ) ) {
   469 	&& ! isset( $_POST['checked'] ) ) {
   460 	$upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins';
   470 	$upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins';
   461 	$action = 'upgrade-core';
   471 	$action = 'upgrade-core';
   462 }
   472 }
   463 
   473 
   464 $title = __('WordPress Updates');
   474 $title = __('WordPress Updates');
   465 $parent_file = 'tools.php';
   475 $parent_file = 'index.php';
       
   476 
       
   477 $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>';
       
   478 $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>';
   466 
   479 
   467 get_current_screen()->add_help_tab( array(
   480 get_current_screen()->add_help_tab( array(
   468 'id'		=> 'overview',
   481 	'id'      => 'overview',
   469 'title'		=> __('Overview'),
   482 	'title'   => __( 'Overview' ),
   470 'content'	=>
   483 	'content' => $updates_overview
   471 	'<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.') . '</p>' .
       
   472 	'<p>' . __('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>'
       
   473 ) );
   484 ) );
   474 
   485 
       
   486 $updates_howto  = '<p>' . __( '<strong>WordPress</strong> &mdash; Updating your WordPress installation is a simple one-click procedure: just <strong>click on the &#8220;Update Now&#8221; button</strong> when you are notified that a new version is available.' ) . ' ' . __( 'In most cases, WordPress will automatically apply maintenance and security updates in the background for you.' ) . '</p>';
       
   487 $updates_howto .= '<p>' . __( '<strong>Themes and Plugins</strong> &mdash; To update individual themes or plugins from this screen, use the checkboxes to make your selection, then <strong>click on the appropriate &#8220;Update&#8221; button</strong>. To update all of your themes or plugins at once, you can check the box at the top of the section to select all before clicking the update button.' ) . '</p>';
       
   488 
       
   489 if ( 'en_US' != get_locale() ) {
       
   490 	$updates_howto .= '<p>' . __( '<strong>Translations</strong> &mdash; The files translating WordPress into your language are updated for you whenever any other updates occur. But if these files are out of date, you can <strong>click the &#8220;Update Translations&#8221;</strong> button.' ) . '</p>';
       
   491 }
       
   492 
   475 get_current_screen()->add_help_tab( array(
   493 get_current_screen()->add_help_tab( array(
   476 'id'		=> 'how-to-update',
   494 	'id'      => 'how-to-update',
   477 'title'		=> __('How to Update'),
   495 	'title'   => __( 'How to Update' ),
   478 'content'	=>
   496 	'content' => $updates_howto
   479 	'<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>' .
       
   480 	'<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>'
       
   481 ) );
   497 ) );
   482 
   498 
   483 get_current_screen()->set_help_sidebar(
   499 get_current_screen()->set_help_sidebar(
   484 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   500 	'<p><strong>' . __('For more information:') . '</strong></p>' .
   485 	'<p>' . __('<a href="http://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>') . '</p>' .
   501 	'<p>' . __( '<a href="https://codex.wordpress.org/Dashboard_Updates_Screen" target="_blank">Documentation on Updating WordPress</a>' ) . '</p>' .
   486 	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
   502 	'<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
   487 );
   503 );
   488 
   504 
   489 if ( 'upgrade-core' == $action ) {
   505 if ( 'upgrade-core' == $action ) {
   490 
   506 	// Force a update check when requested
   491 	wp_version_check();
   507 	$force_check = ! empty( $_GET['force-check'] );
       
   508 	wp_version_check( array(), $force_check );
       
   509 
   492 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   510 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   493 	?>
   511 	?>
   494 	<div class="wrap">
   512 	<div class="wrap">
   495 	<?php screen_icon('tools'); ?>
       
   496 	<h2><?php _e('WordPress Updates'); ?></h2>
   513 	<h2><?php _e('WordPress Updates'); ?></h2>
   497 	<?php
   514 	<?php
   498 	if ( $upgrade_error ) {
   515 	if ( $upgrade_error ) {
   499 		echo '<div class="error"><p>';
   516 		echo '<div class="error"><p>';
   500 		if ( $upgrade_error == 'themes' )
   517 		if ( $upgrade_error == 'themes' )
   505 	}
   522 	}
   506 
   523 
   507 	echo '<p>';
   524 	echo '<p>';
   508 	/* translators: %1 date, %2 time. */
   525 	/* translators: %1 date, %2 time. */
   509 	printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
   526 	printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
   510 	echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
   527 	echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php?force-check=1') ) . '">' . __( 'Check Again' ) . '</a>';
   511 	echo '</p>';
   528 	echo '</p>';
   512 
   529 
   513 	if ( $core = current_user_can( 'update_core' ) )
   530 	if ( $core = current_user_can( 'update_core' ) )
   514 		core_upgrade_preamble();
   531 		core_upgrade_preamble();
   515 	if ( $plugins = current_user_can( 'update_plugins' ) )
   532 	if ( $plugins = current_user_can( 'update_plugins' ) )
   517 	if ( $themes = current_user_can( 'update_themes' ) )
   534 	if ( $themes = current_user_can( 'update_themes' ) )
   518 		list_theme_updates();
   535 		list_theme_updates();
   519 	if ( $core || $plugins || $themes )
   536 	if ( $core || $plugins || $themes )
   520 		list_translation_updates();
   537 		list_translation_updates();
   521 	unset( $core, $plugins, $themes );
   538 	unset( $core, $plugins, $themes );
   522 	do_action('core_upgrade_preamble');
   539 	/**
       
   540 	 * Fires after the core, plugin, and theme update tables.
       
   541 	 *
       
   542 	 * @since 2.9.0
       
   543 	 */
       
   544 	do_action( 'core_upgrade_preamble' );
   523 	echo '</div>';
   545 	echo '</div>';
   524 	include(ABSPATH . 'wp-admin/admin-footer.php');
   546 	include(ABSPATH . 'wp-admin/admin-footer.php');
   525 
   547 
   526 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
   548 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
   527 
   549 
   528 	if ( ! current_user_can( 'update_core' ) )
   550 	if ( ! current_user_can( 'update_core' ) )
   529 		wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
   551 		wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
   530 
   552 
   531 	check_admin_referer('upgrade-core');
   553 	check_admin_referer('upgrade-core');
   532 
   554 
   533 	// do the (un)dismiss actions before headers,
   555 	// Do the (un)dismiss actions before headers, so that they can redirect.
   534 	// so that they can redirect
       
   535 	if ( isset( $_POST['dismiss'] ) )
   556 	if ( isset( $_POST['dismiss'] ) )
   536 		do_dismiss_core_update();
   557 		do_dismiss_core_update();
   537 	elseif ( isset( $_POST['undismiss'] ) )
   558 	elseif ( isset( $_POST['undismiss'] ) )
   538 		do_undismiss_core_update();
   559 		do_undismiss_core_update();
   539 
   560 
   569 
   590 
   570 	$title = __('Update Plugins');
   591 	$title = __('Update Plugins');
   571 
   592 
   572 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   593 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   573 	echo '<div class="wrap">';
   594 	echo '<div class="wrap">';
   574 	screen_icon('plugins');
       
   575 	echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
   595 	echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
   576 	echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
   596 	echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>';
   577 	echo '</div>';
   597 	echo '</div>';
   578 	include(ABSPATH . 'wp-admin/admin-footer.php');
   598 	include(ABSPATH . 'wp-admin/admin-footer.php');
   579 
   599 
   580 } elseif ( 'do-theme-upgrade' == $action ) {
   600 } elseif ( 'do-theme-upgrade' == $action ) {
   581 
   601 
   597 	$url = wp_nonce_url($url, 'bulk-update-themes');
   617 	$url = wp_nonce_url($url, 'bulk-update-themes');
   598 
   618 
   599 	$title = __('Update Themes');
   619 	$title = __('Update Themes');
   600 
   620 
   601 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   621 	require_once(ABSPATH . 'wp-admin/admin-header.php');
   602 	echo '<div class="wrap">';
   622 	?>
   603 	screen_icon('themes');
   623 	<div class="wrap">
   604 	echo '<h2>' . esc_html__('Update Themes') . '</h2>';
   624 		<h2><?php echo esc_html__('Update Themes') ?></h2>
   605 	echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
   625 		<iframe src="<?php echo $url ?>" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>
   606 	echo '</div>';
   626 	</div>
       
   627 	<?php
   607 	include(ABSPATH . 'wp-admin/admin-footer.php');
   628 	include(ABSPATH . 'wp-admin/admin-footer.php');
   608 
   629 
   609 } elseif ( 'do-translation-upgrade' == $action ) {
   630 } elseif ( 'do-translation-upgrade' == $action ) {
   610 
   631 
   611 	if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) )
   632 	if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) )
   625 	$result = $upgrader->bulk_upgrade();
   646 	$result = $upgrader->bulk_upgrade();
   626 
   647 
   627 	require_once( ABSPATH . 'wp-admin/admin-footer.php' );
   648 	require_once( ABSPATH . 'wp-admin/admin-footer.php' );
   628 
   649 
   629 } else {
   650 } else {
   630 	do_action('update-core-custom_' . $action);
   651 	/**
   631 }
   652 	 * Fires for each custom update action on the WordPress Updates screen.
       
   653 	 *
       
   654 	 * The dynamic portion of the hook name, `$action`, refers to the
       
   655 	 * passed update action. The hook fires in lieu of all available
       
   656 	 * default update actions.
       
   657 	 *
       
   658 	 * @since 3.2.0
       
   659 	 */
       
   660 	do_action( "update-core-custom_{$action}" );
       
   661 }