3 * Update Core administration panel.
6 * @subpackage Administration
9 /** WordPress Administration Bootstrap */
10 require_once('./admin.php');
12 if ( ! current_user_can('update_plugins') )
13 wp_die(__('You do not have sufficient permissions to update plugins for this site.'));
15 function list_core_update( $update ) {
16 global $wp_local_package, $wpdb;
17 $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ?
18 $update->current : sprintf("%s–<strong>%s</strong>", $update->current, $update->locale);
20 if ( !isset($update->response) || 'latest' == $update->response )
22 $submit = __('Update Automatically');
23 $form_action = 'update-core.php?action=do-core-upgrade';
24 $php_version = phpversion();
25 $mysql_version = $wpdb->db_version();
27 if ( 'development' == $update->response ) {
28 $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:');
29 $download = __('Download nightly build');
32 $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);
33 $submit = __('Re-install Automatically');
34 $form_action = 'update-core.php?action=do-core-reinstall';
36 $php_compat = version_compare( $php_version, $update->php_version, '>=' );
37 $mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' );
38 if ( !$mysql_compat && !$php_compat )
39 $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 );
40 elseif ( !$php_compat )
41 $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 );
42 elseif ( !$mysql_compat )
43 $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 );
45 $message = sprintf(__('You can update to <a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> automatically or download the package and install it manually:'), $version_string);
46 if ( !$mysql_compat || !$php_compat )
47 $show_buttons = false;
49 $download = sprintf(__('Download %s'), $version_string);
55 echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">';
56 wp_nonce_field('upgrade-core');
58 echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
59 echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
60 if ( $show_buttons ) {
61 echo '<input id="upgrade" class="button" type="submit" value="' . esc_attr($submit) . '" name="upgrade" /> ';
62 echo '<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a> ';
64 if ( 'en_US' != $update->locale )
65 if ( !isset( $update->dismissed ) || !$update->dismissed )
66 echo '<input id="dismiss" class="button" type="submit" value="' . esc_attr__('Hide this update') . '" name="dismiss" />';
68 echo '<input id="undismiss" class="button" type="submit" value="' . esc_attr__('Bring back this update') . '" name="undismiss" />';
70 if ( 'en_US' != $update->locale && ( !isset($wp_local_package) || $wp_local_package != $update->locale ) )
71 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>';
72 else if ( 'en_US' == $update->locale && get_locale() != 'en_US' ) {
73 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>';
79 function dismissed_updates() {
80 $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) );
83 $show_text = esc_js(__('Show hidden updates'));
84 $hide_text = esc_js(__('Hide hidden updates'));
86 <script type="text/javascript">
89 $('dismissed-updates').show();
90 $('#show-dismissed').toggle(function(){$(this).text('<?php echo $hide_text; ?>');}, function() {$(this).text('<?php echo $show_text; ?>')});
91 $('#show-dismissed').click(function() { $('#dismissed-updates').toggle('slow');});
95 echo '<p class="hide-if-no-js"><a id="show-dismissed" href="#">'.__('Show hidden updates').'</a></p>';
96 echo '<ul id="dismissed-updates" class="core-updates dismissed">';
97 foreach( (array) $dismissed as $update) {
99 list_core_update( $update );
107 * Display upgrade WordPress for downloading latest or upgrading automatically form.
113 function core_upgrade_preamble() {
114 global $upgrade_error;
116 $updates = get_core_updates();
119 <?php screen_icon('tools'); ?>
120 <h2><?php _e('WordPress Updates'); ?></h2>
122 if ( $upgrade_error ) {
123 echo '<div class="error"><p>';
124 _e('Please select one or more plugins to upgrade.');
128 if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) {
130 _e('You have the latest version of WordPress.');
133 echo '<div class="updated"><p>';
134 _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.');
137 echo '<h3 class="response">';
138 _e( 'An updated version of WordPress is available.' );
142 echo '<ul class="core-updates">';
144 foreach( (array) $updates as $update ) {
145 $class = $alternate? ' class="alternate"' : '';
146 $alternate = !$alternate;
148 list_core_update( $update );
152 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>';
155 list_plugin_updates();
156 list_theme_updates();
157 do_action('core_upgrade_preamble');
161 function list_plugin_updates() {
164 $cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
166 require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
167 $plugins = get_plugin_updates();
168 if ( empty( $plugins ) ) {
169 echo '<h3>' . __( 'Plugins' ) . '</h3>';
170 echo '<p>' . __( 'Your plugins are all up to date.' ) . '</p>';
173 $form_action = 'update-core.php?action=do-plugin-upgrade';
175 $core_updates = get_core_updates();
176 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, '=') )
177 $core_update_version = false;
179 $core_update_version = $core_updates[0]->current;
181 <h3><?php _e( 'Plugins' ); ?></h3>
182 <p><?php _e( 'The following plugins have new versions available. Check the ones you want to update and then click “Update Plugins”.' ); ?></p>
183 <form method="post" action="<?php echo $form_action; ?>" name="upgrade-plugins" class="upgrade">
184 <?php wp_nonce_field('upgrade-core'); ?>
185 <p><input id="upgrade-plugins" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
186 <table class="widefat" cellspacing="0" id="update-plugins-table">
189 <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all" /></th>
190 <th scope="col" class="manage-column"><label for="plugins-select-all"><?php _e('Select All'); ?></label></th>
196 <th scope="col" class="manage-column check-column"><input type="checkbox" id="plugins-select-all-2" /></th>
197 <th scope="col" class="manage-column"><label for="plugins-select-all-2"><?php _e('Select All'); ?></label></th>
200 <tbody class="plugins">
202 foreach ( (array) $plugins as $plugin_file => $plugin_data) {
203 $info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
204 // Get plugin compat for running version of WordPress.
205 if ( isset($info->tested) && version_compare($info->tested, $cur_wp_version, '>=') ) {
206 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: 100%% (according to its author)'), $cur_wp_version);
207 } elseif ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
208 $compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
209 $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]);
211 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version);
213 // Get plugin compat for updated version of WordPress.
214 if ( $core_update_version ) {
215 if ( isset($info->compatibility[$core_update_version][$plugin_data->update->new_version]) ) {
216 $update_compat = $info->compatibility[$core_update_version][$plugin_data->update->new_version];
217 $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]);
219 $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version);
222 // Get the upgrade notice for the new plugin version.
223 if ( isset($plugin_data->update->upgrade_notice) ) {
224 $upgrade_notice = '<br />' . strip_tags($plugin_data->update->upgrade_notice);
226 $upgrade_notice = '';
230 <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
231 <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>
237 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p>
242 function list_theme_updates() {
243 $themes = get_theme_updates();
244 if ( empty( $themes ) ) {
245 echo '<h3>' . __( 'Themes' ) . '</h3>';
246 echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
250 $form_action = 'update-core.php?action=do-theme-upgrade';
253 <h3><?php _e( 'Themes' ); ?></h3>
254 <p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click “Update Themes”.' ); ?></p>
255 <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>
256 <form method="post" action="<?php echo $form_action; ?>" name="upgrade-themes" class="upgrade">
257 <?php wp_nonce_field('upgrade-core'); ?>
258 <p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
259 <table class="widefat" cellspacing="0" id="update-themes-table">
262 <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></th>
263 <th scope="col" class="manage-column"><label for="themes-select-all"><?php _e('Select All'); ?></label></th>
269 <th scope="col" class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></th>
270 <th scope="col" class="manage-column"><label for="themes-select-all-2"><?php _e('Select All'); ?></label></th>
273 <tbody class="plugins">
275 foreach ( (array) $themes as $stylesheet => $theme_data) {
276 $screenshot = $theme_data->{'Theme Root URI'} . '/' . $stylesheet . '/' . $theme_data->Screenshot;
280 <th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($stylesheet) . "' /></th>
281 <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>
287 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p>
293 * Upgrade WordPress core display.
299 function do_core_upgrade( $reinstall = false ) {
300 global $wp_filesystem;
303 $url = 'update-core.php?action=do-core-reinstall';
305 $url = 'update-core.php?action=do-core-upgrade';
306 $url = wp_nonce_url($url, 'upgrade-core');
307 if ( false === ($credentials = request_filesystem_credentials($url, '', false, ABSPATH)) )
310 $version = isset( $_POST['version'] )? $_POST['version'] : false;
311 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
312 $update = find_core_update( $version, $locale );
317 if ( ! WP_Filesystem($credentials, ABSPATH) ) {
318 request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again
323 <?php screen_icon(); ?>
324 <h2><?php _e('Update WordPress'); ?></h2>
326 if ( $wp_filesystem->errors->get_error_code() ) {
327 foreach ( $wp_filesystem->errors->get_error_messages() as $message )
328 show_message($message);
334 $update->response = 'reinstall';
336 $result = wp_update_core($update, 'show_message');
338 if ( is_wp_error($result) ) {
339 show_message($result);
340 if ('up_to_date' != $result->get_error_code() )
341 show_message( __('Installation Failed') );
343 show_message( __('WordPress updated successfully') );
344 show_message( '<strong>' . __('Actions:') . '</strong> <a href="' . esc_url( admin_url() ) . '">' . __('Go to Dashboard') . '</a>' );
349 function do_dismiss_core_update() {
350 $version = isset( $_POST['version'] )? $_POST['version'] : false;
351 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
352 $update = find_core_update( $version, $locale );
355 dismiss_core_update( $update );
356 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
359 function do_undismiss_core_update() {
360 $version = isset( $_POST['version'] )? $_POST['version'] : false;
361 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US';
362 $update = find_core_update( $version, $locale );
365 undismiss_core_update( $version, $locale );
366 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
369 function no_update_actions($actions) {
373 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
375 $upgrade_error = false;
376 if ( 'do-plugin-upgrade' == $action && !isset($_GET['plugins']) && !isset($_POST['checked']) ) {
377 $upgrade_error = true;
378 $action = 'upgrade-core';
381 $title = __('WordPress Updates');
382 $parent_file = 'tools.php';
384 add_contextual_help($current_screen,
385 '<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>' .
386 '<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>' .
387 '<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>' .
388 '<p><strong>' . __('For more information:') . '</strong></p>' .
389 '<p>' . __('<a href="http://codex.wordpress.org/Dashboard_Updates_SubPanel" target="_blank">Documentation on Updating WordPress</a>') . '</p>' .
390 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
393 if ( 'upgrade-core' == $action ) {
395 require_once('./admin-header.php');
396 core_upgrade_preamble();
397 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
398 check_admin_referer('upgrade-core');
400 // do the (un)dismiss actions before headers,
401 // so that they can redirect
402 if ( isset( $_POST['dismiss'] ) )
403 do_dismiss_core_update();
404 elseif ( isset( $_POST['undismiss'] ) )
405 do_undismiss_core_update();
407 require_once('./admin-header.php');
408 if ( 'do-core-reinstall' == $action )
413 if ( isset( $_POST['upgrade'] ) )
414 do_core_upgrade($reinstall);
416 } elseif ( 'do-plugin-upgrade' == $action ) {
417 check_admin_referer('upgrade-core');
419 if ( isset( $_GET['plugins'] ) ) {
420 $plugins = explode( ',', $_GET['plugins'] );
421 } elseif ( isset( $_POST['checked'] ) ) {
422 $plugins = (array) $_POST['checked'];
424 wp_redirect('update-core.php');
428 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins));
429 $url = wp_nonce_url($url, 'bulk-update-plugins');
431 $title = __('Update Plugins');
433 require_once('./admin-header.php');
434 echo '<div class="wrap">';
435 screen_icon('plugins');
436 echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
437 echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
439 } elseif ( 'do-theme-upgrade' == $action ) {
440 check_admin_referer('upgrade-core');
442 if ( isset( $_GET['themes'] ) ) {
443 $themes = explode( ',', $_GET['themes'] );
444 } elseif ( isset( $_POST['checked'] ) ) {
445 $themes = (array) $_POST['checked'];
447 wp_redirect('update-core.php');
451 $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes));
452 $url = wp_nonce_url($url, 'bulk-update-themes');
454 $title = __('Update Themes');
456 require_once('./admin-header.php');
457 echo '<div class="wrap">';
458 screen_icon('themes');
459 echo '<h2>' . esc_html__('Update Themes') . '</h2>';
460 echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
464 include('./admin-footer.php');