3 * Update Core administration panel.
6 * @subpackage Administration
9 /** WordPress Administration Bootstrap */
10 require_once('./admin.php');
12 if ( is_multisite() && ! is_network_admin() ) {
13 wp_redirect( network_admin_url( 'update-core.php' ) );
17 if ( ! current_user_can( 'update_core' ) )
18 wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
20 function list_core_update( $update ) {
21 global $wp_local_package, $wpdb;
22 $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ?
23 $update->current : sprintf("%s–<strong>%s</strong>", $update->current, $update->locale);
25 if ( !isset($update->response) || 'latest' == $update->response )
27 $submit = __('Update Automatically');
28 $form_action = 'update-core.php?action=do-core-upgrade';
29 $php_version = phpversion();
30 $mysql_version = $wpdb->db_version();
32 if ( 'development' == $update->response ) {
33 $message = __('You are using a development version of WordPress. You can update to the latest nightly build automatically or download the nightly build and install it manually:');
34 $download = __('Download nightly build');
37 $message = sprintf(__('You have the latest version of WordPress. You do not need to update. However, if you want to re-install version %s, you can do so automatically or download the package and re-install manually:'), $version_string);
38 $submit = __('Re-install Automatically');
39 $form_action = 'update-core.php?action=do-core-reinstall';
41 $php_compat = version_compare( $php_version, $update->php_version, '>=' );
42 $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
43 if ( !$mysql_compat && !$php_compat )
44 $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 );
45 elseif ( !$php_compat )
46 $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 );
47 elseif ( !$mysql_compat )
48 $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 );
50 $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);
51 if ( !$mysql_compat || !$php_compat )
52 $show_buttons = false;
54 $download = sprintf(__('Download %s'), $version_string);
60 echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
61 wp_nonce_field('upgrade-core');
63 echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
64 echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
65 if ( $show_buttons ) {
66 submit_button( $submit, 'button', 'upgrade', false );
67 echo ' <a href="' . esc_url($update->package) . '" class="button">' . $download . '</a> ';
69 if ( 'en_US' != $update->locale )
70 if ( !isset( $update->dismissed ) || !$update->dismissed )
71 submit_button( __('Hide this update'), 'button', 'dismiss', false );
73 submit_button( __('Bring back this update'), 'button', 'undismiss', false );
75 if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) )
76 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>';
77 else if ( 'en_US' == $update->locale && get_locale() != 'en_US' ) {
78 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>';
84 function dismissed_updates() {
85 $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
88 $show_text = esc_js(__('Show hidden updates'));
89 $hide_text = esc_js(__('Hide hidden updates'));
91 <script type="text/javascript">
94 $('dismissed-updates').show();
95 $('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
96 $('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
100 echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
101 echo '<ul id="dismissed-updates" class="core-updates dismissed">';
102 foreach( (array) $dismissed as $update) {
104 list_core_update( $update );
112 * Display upgrade WordPress for downloading latest or upgrading automatically form.
118 function core_upgrade_preamble() {
119 global $upgrade_error;
121 $updates = get_core_updates();
124 <?php screen_icon('tools'); ?>
125 <h2><?php _e('WordPress Updates'); ?></h2>
127 if ( $upgrade_error ) {
128 echo '<div class="error"><p>';
129 if ( $upgrade_error == 'themes' )
130 _e('Please select one or more themes to update.');
132 _e('Please select one or more plugins to update.');
137 /* translators: %1 date, %2 time. */
138 printf( __('Last checked on %1$s at %2$s.'), date_i18n( get_option( 'date_format' ) ), date_i18n( get_option( 'time_format' ) ) );
139 echo ' <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
142 if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
144 _e('You have the latest version of WordPress.');
147 echo '<div class="updated inline"><p>';
148 _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.');
151 echo '<h3 class="response">';
152 _e( 'An updated version of WordPress is available.' );
156 echo '<ul class="core-updates">';
158 foreach( (array) $updates as $update ) {
160 list_core_update( $update );
164 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>';
167 if ( current_user_can( 'update_plugins' ) )
168 list_plugin_updates();
169 if ( current_user_can( 'update_themes' ) )
170 list_theme_updates();
171 do_action('core_upgrade_preamble');
175 function list_plugin_updates() {
178 $cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
180 require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
181 $plugins = get_plugin_updates();
182 if ( empty( $plugins ) ) {
183 echo '<h3>' . __( 'Plugins' ) . '</h3>';
184 echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
187 $form_action = 'update-core.php?action=do-plugin-upgrade';
189 $core_updates = get_core_updates();
190 if ( !isset($core_updates[0]->response) || 'latest' == $core_updates[0]->response || 'development' == $core_updates[0]->response || version_compare( $core_updates[0]->current, $cur_wp_version, '=') )
191 $core_update_version = false;
193 $core_update_version = $core_updates[0]->current;
195 <h3><?php _e( 'Plugins' ); ?></h3>
196 <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p>
197 <form method="post" action="<?php echo $form_action; ?>" name="upgrade-plugins" class="upgrade">
198 <?php wp_nonce_field('upgrade-core'); ?>
199 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
200 <table class="widefat" cellspacing="0" id="update-plugins-table">
203 <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
204 <th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
210 <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
211 <th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e('Select All'); ?></label></th>
214 <tbody class="plugins">
216 foreach ( (array) $plugins as $plugin_file => $plugin_data) {
217 $info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
218 // Get plugin compat for running version of WordPress.
219 if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
220 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
221 } elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
222 $compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
223 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $cur_wp_version, $compat[0], $compat[2], $compat[1]);
225 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
227 // Get plugin compat for updated version of WordPress.
228 if ( $core_update_version ) {
229 if ( isset($info->compatibility[$core_update_version][$plugin_data->update->new_version]) ) {
230 $update_compat = $info->compatibility[$core_update_version][$plugin_data->update->new_version];
231 $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: %2$d%% (%3$d "works" votes out of %4$d total)'), $core_update_version, $update_compat[0], $update_compat[2], $update_compat[1]);
233 $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
236 // Get the upgrade notice for the new plugin version.
237 if ( isset($plugin_data->update->upgrade_notice) ) {
238 $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice);
240 $upgrade_notice = '';
244 <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
245 <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>
251 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
256 function list_theme_updates() {
257 $themes = get_theme_updates();
258 if ( empty( $themes ) ) {
259 echo '<h3>' . __( 'Themes' ) . '</h3>';
260 echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
264 $form_action = 'update-core.php?action=do-theme-upgrade';
267 <h3><?php _e( 'Themes' ); ?></h3>
268 <p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click “Update Themes”.' ); ?></p>
269 <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>
270 <form method="post" action="<?php echo $form_action; ?>" name="upgrade-themes" class="upgrade">
271 <?php wp_nonce_field('upgrade-core'); ?>
272 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
273 <table class="widefat" cellspacing="0" id="update-themes-table">
276 <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
277 <th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
283 <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
284 <th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e('Select All'); ?></label></th>
287 <tbody class="plugins">
289 foreach ( (array) $themes as $stylesheet => $theme_data) {
290 $screenshot = $theme_data->{'Theme Root URI'} . '/' . $stylesheet . '/' . $theme_data->Screenshot;
294 <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' /></th>
295 <td class='plugin-title'><img src='$screenshot' width='64' height='64' style='float:left; padding: 5px' /><strong>{$theme_data->Name}</strong>" . sprintf(__('You have version %1$s installed. Update to %2$s.'), $theme_data->Version, $theme_data->update['new_version']) . "</td>
301 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
307 * Upgrade WordPress core display.
313 function do_core_upgrade( $reinstall = false ) {
314 global $wp_filesystem;
317 $url = 'update-core.php?action=do-core-reinstall';
319 $url = 'update-core.php?action=do-core-upgrade';
320 $url = wp_nonce_url($url, 'upgrade-core');
321 if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) )
324 $version = isset( $_POST['version'] )? $_POST['version'] : false;
325 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
326 $update = find_core_update( $version, $locale );
331 if ( ! WP_Filesystem($credentials, ABSPATH) ) {
332 request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again
337 <?php screen_icon('tools'); ?>
338 <h2><?php _e('Update WordPress'); ?></h2>
340 if ( $wp_filesystem->errors->get_error_code() ) {
341 foreach ( $wp_filesystem->errors->get_error_messages() as $message )
342 show_message($message);
348 $update->response = 'reinstall';
350 $result = wp_update_core($update, 'show_message');
352 if ( is_wp_error($result) ) {
353 show_message($result);
354 if ('up_to_date' != $result->get_error_code() )
355 show_message( __('Installation Failed') );
357 show_message( __('WordPress updated successfully') );
358 show_message( '<a href="' . esc_url( self_admin_url() ) . '">' . __('Go to Dashboard') . '</a>' );
363 function do_dismiss_core_update() {
364 $version = isset( $_POST['version'] )? $_POST['version'] : false;
365 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
366 $update = find_core_update( $version, $locale );
369 dismiss_core_update( $update );
370 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
374 function do_undismiss_core_update() {
375 $version = isset( $_POST['version'] )? $_POST['version'] : false;
376 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
377 $update = find_core_update( $version, $locale );
380 undismiss_core_update( $version, $locale );
381 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
385 function no_update_actions($actions) {
389 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
391 $upgrade_error = false;
392 if ( ( 'do-theme-upgrade' == $action || ( 'do-plugin-upgrade' == $action && ! isset( $_GET['plugins'] ) ) )
393 && ! isset( $_POST['checked'] ) ) {
394 $upgrade_error = $action == 'do-theme-upgrade' ? 'themes' : 'plugins';
395 $action = 'upgrade-core';
398 $title = __('WordPress Updates');
399 $parent_file = 'tools.php';
401 add_contextual_help($current_screen,
402 '<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>' .
403 '<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>' .
404 '<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>' .
405 '<p><strong>' . __('For more information:') . '</strong></p>' .
406 '<p>' . __('<a href="http://codex.wordpress.org/Dashboard_Updates_SubPanel" target="_blank">Documentation on Updating WordPress</a>') . '</p>' .
407 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
410 if ( 'upgrade-core' == $action ) {
413 require_once(ABSPATH . 'wp-admin/admin-header.php');
414 core_upgrade_preamble();
416 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
417 check_admin_referer('upgrade-core');
419 // do the (un)dismiss actions before headers,
420 // so that they can redirect
421 if ( isset( $_POST['dismiss'] ) )
422 do_dismiss_core_update();
423 elseif ( isset( $_POST['undismiss'] ) )
424 do_undismiss_core_update();
426 require_once(ABSPATH . 'wp-admin/admin-header.php');
427 if ( 'do-core-reinstall' == $action )
432 if ( isset( $_POST['upgrade'] ) )
433 do_core_upgrade($reinstall);
435 } elseif ( 'do-plugin-upgrade' == $action ) {
437 if ( ! current_user_can( 'update_plugins' ) )
438 wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
440 check_admin_referer('upgrade-core');
442 if ( isset( $_GET['plugins'] ) ) {
443 $plugins = explode( ',', $_GET['plugins'] );
444 } elseif ( isset( $_POST['checked'] ) ) {
445 $plugins = (array) $_POST['checked'];
447 wp_redirect( admin_url('update-core.php') );
451 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
452 $url = wp_nonce_url($url, 'bulk-update-plugins');
454 $title = __('Update Plugins');
456 require_once(ABSPATH . 'wp-admin/admin-header.php');
457 echo '<div class="wrap">';
458 screen_icon('plugins');
459 echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
460 echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
463 } elseif ( 'do-theme-upgrade' == $action ) {
465 if ( ! current_user_can( 'update_themes' ) )
466 wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
468 check_admin_referer('upgrade-core');
470 if ( isset( $_GET['themes'] ) ) {
471 $themes = explode( ',', $_GET['themes'] );
472 } elseif ( isset( $_POST['checked'] ) ) {
473 $themes = (array) $_POST['checked'];
475 wp_redirect( admin_url('update-core.php') );
479 $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
480 $url = wp_nonce_url($url, 'bulk-update-themes');
482 $title = __('Update Themes');
484 require_once(ABSPATH . 'wp-admin/admin-header.php');
485 echo '<div class="wrap">';
486 screen_icon('themes');
487 echo '<h2>' . esc_html__('Update Themes') . '</h2>';
488 echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
492 include(ABSPATH . 'wp-admin/admin-footer.php');