| [ XREF Home ] [ Index ] |
PHP Cross Reference of WordPress TrunkProvided by Yoast |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Update Core administration panel. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once ('./admin.php'); 11 12 if ( is_multisite() && ! is_network_admin() ) { 13 wp_redirect( network_admin_url( 'update-core.php' ) ); 14 exit(); 15 } 16 17 if ( ! current_user_can( 'update_core' ) ) 18 wp_die( __( 'You do not have sufficient permissions to update this site.' ) ); 19 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); 24 $current = false; 25 if ( !isset($update->response) || 'latest' == $update->response ) 26 $current = true; 27 $submit = __('Update Automatically'); 28 $form_action = 'update-core.php?action=do-core-upgrade'; 29 $php_version = phpversion(); 30 $mysql_version = $wpdb->db_version(); 31 $show_buttons = true; 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'); 35 } else { 36 if ( $current ) { 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'; 40 } else { 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 ); 49 else 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; 53 } 54 $download = sprintf(__('Download %s'), $version_string); 55 } 56 57 echo '<p>'; 58 echo $message; 59 echo '</p>'; 60 echo '<form method="post" action="' . $form_action . '" name="upgrade" class="upgrade">'; 61 wp_nonce_field('upgrade-core'); 62 echo '<p>'; 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> '; 68 } 69 if ( 'en_US' != $update->locale ) 70 if ( !isset( $update->dismissed ) || !$update->dismissed ) 71 submit_button( __('Hide this update'), 'button', 'dismiss', false ); 72 else 73 submit_button( __('Bring back this update'), 'button', 'undismiss', false ); 74 echo '</p>'; 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>'; 79 } 80 echo '</form>'; 81 82 } 83 84 function dismissed_updates() { 85 $dismissed = get_core_updates( array( 'dismissed' => true, 'available' => false ) ); 86 if ( $dismissed ) { 87 88 $show_text = esc_js(__('Show hidden updates')); 89 $hide_text = esc_js(__('Hide hidden updates')); 90 ?> 91 <script type="text/javascript"> 92 93 jQuery(function($) { 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');}); 97 }); 98 </script> 99 <?php 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) { 103 echo '<li>'; 104 list_core_update( $update ); 105 echo '</li>'; 106 } 107 echo '</ul>'; 108 } 109 } 110 111 /** 112 * Display upgrade WordPress for downloading latest or upgrading automatically form. 113 * 114 * @since 2.7 115 * 116 * @return null 117 */ 118 function core_upgrade_preamble() { 119 global $upgrade_error; 120 121 $updates = get_core_updates(); 122 ?> 123 <div class="wrap"> 124 <?php screen_icon('tools'); ?> 125 <h2><?php _e('WordPress Updates'); ?></h2> 126 <?php 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.'); 131 else 132 _e('Please select one or more plugins to update.'); 133 echo '</p></div>'; 134 } 135 136 echo '<p>'; 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>'; 140 echo '</p>'; 141 142 if ( !isset($updates[0]->response) || 'latest' == $updates[0]->response ) { 143 echo '<h3>'; 144 _e('You have the latest version of WordPress.'); 145 echo '</h3>'; 146 } else { 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.'); 149 echo '</p></div>'; 150 151 echo '<h3 class="response">'; 152 _e( 'An updated version of WordPress is available.' ); 153 echo '</h3>'; 154 } 155 156 echo '<ul class="core-updates">'; 157 $alternate = true; 158 foreach( (array) $updates as $update ) { 159 echo '<li>'; 160 list_core_update( $update ); 161 echo '</li>'; 162 } 163 echo '</ul>'; 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>'; 165 dismissed_updates(); 166 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'); 172 echo '</div>'; 173 } 174 175 function list_plugin_updates() { 176 global $wp_version; 177 178 $cur_wp_version = preg_replace('/-.*$/', '', $wp_version); 179 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>'; 185 return; 186 } 187 $form_action = 'update-core.php?action=do-plugin-upgrade'; 188 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; 192 else 193 $core_update_version = $core_updates[0]->current; 194 ?> 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"> 201 <thead> 202 <tr> 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> 205 </tr> 206 </thead> 207 208 <tfoot> 209 <tr> 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> 212 </tr> 213 </tfoot> 214 <tbody class="plugins"> 215 <?php 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]); 224 } else { 225 $compat = '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $cur_wp_version); 226 } 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]); 232 } else { 233 $compat .= '<br />' . sprintf(__('Compatibility with WordPress %1$s: Unknown'), $core_update_version); 234 } 235 } 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); 239 } else { 240 $upgrade_notice = ''; 241 } 242 echo " 243 <tr class='active'> 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> 246 </tr>"; 247 } 248 ?> 249 </tbody> 250 </table> 251 <p><input id="upgrade-plugins-2" class="button" type="submit" value="<?php esc_attr_e('Update Plugins'); ?>" name="upgrade" /></p> 252 </form> 253 <?php 254 } 255 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>'; 261 return; 262 } 263 264 $form_action = 'update-core.php?action=do-theme-upgrade'; 265 266 ?> 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"> 274 <thead> 275 <tr> 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> 278 </tr> 279 </thead> 280 281 <tfoot> 282 <tr> 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> 285 </tr> 286 </tfoot> 287 <tbody class="plugins"> 288 <?php 289 foreach ( (array) $themes as $stylesheet => $theme_data) { 290 $screenshot = $theme_data->{'Theme Root URI'} . '/' . $stylesheet . '/' . $theme_data->Screenshot; 291 292 echo " 293 <tr class='active'> 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> 296 </tr>"; 297 } 298 ?> 299 </tbody> 300 </table> 301 <p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e('Update Themes'); ?>" name="upgrade" /></p> 302 </form> 303 <?php 304 } 305 306 /** 307 * Upgrade WordPress core display. 308 * 309 * @since 2.7 310 * 311 * @return null 312 */ 313 function do_core_upgrade( $reinstall = false ) { 314 global $wp_filesystem; 315 316 if ( $reinstall ) 317 $url = 'update-core.php?action=do-core-reinstall'; 318 else 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)) ) 322 return; 323 324 $version = isset( $_POST['version'] )? $_POST['version'] : false; 325 $locale = isset( $_POST['locale'] )? $_POST['locale'] : 'en_US'; 326 $update = find_core_update( $version, $locale ); 327 if ( !$update ) 328 return; 329 330 331 if ( ! WP_Filesystem($credentials, ABSPATH) ) { 332 request_filesystem_credentials($url, '', true, ABSPATH); //Failed to connect, Error and request again 333 return; 334 } 335 ?> 336 <div class="wrap"> 337 <?php screen_icon('tools'); ?> 338 <h2><?php _e('Update WordPress'); ?></h2> 339 <?php 340 if ( $wp_filesystem->errors->get_error_code() ) { 341 foreach ( $wp_filesystem->errors->get_error_messages() as $message ) 342 show_message($message); 343 echo '</div>'; 344 return; 345 } 346 347 if ( $reinstall ) 348 $update->response = 'reinstall'; 349 350 $result = wp_update_core($update, 'show_message'); 351 352 if ( is_wp_error($result) ) { 353 show_message($result); 354 if ('up_to_date' != $result->get_error_code() ) 355 show_message( __('Installation Failed') ); 356 } else { 357 show_message( __('WordPress updated successfully') ); 358 show_message( '<a href="' . esc_url( self_admin_url() ) . '">' . __('Go to Dashboard') . '</a>' ); 359 } 360 echo '</div>'; 361 } 362 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 ); 367 if ( !$update ) 368 return; 369 dismiss_core_update( $update ); 370 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') ); 371 exit; 372 } 373 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 ); 378 if ( !$update ) 379 return; 380 undismiss_core_update( $version, $locale ); 381 wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') ); 382 exit; 383 } 384 385 function no_update_actions($actions) { 386 return ''; 387 } 388 389 $action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core'; 390 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'; 396 } 397 398 $title = __('WordPress Updates'); 399 $parent_file = 'tools.php'; 400 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_Screen" target="_blank">Documentation on Updating WordPress</a>') . '</p>' . 407 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 408 ); 409 410 if ( 'upgrade-core' == $action ) { 411 412 wp_version_check(); 413 require_once (ABSPATH . 'wp-admin/admin-header.php'); 414 core_upgrade_preamble(); 415 include (ABSPATH . 'wp-admin/admin-footer.php'); 416 417 } elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) { 418 check_admin_referer('upgrade-core'); 419 420 // do the (un)dismiss actions before headers, 421 // so that they can redirect 422 if ( isset( $_POST['dismiss'] ) ) 423 do_dismiss_core_update(); 424 elseif ( isset( $_POST['undismiss'] ) ) 425 do_undismiss_core_update(); 426 427 require_once (ABSPATH . 'wp-admin/admin-header.php'); 428 if ( 'do-core-reinstall' == $action ) 429 $reinstall = true; 430 else 431 $reinstall = false; 432 433 if ( isset( $_POST['upgrade'] ) ) 434 do_core_upgrade($reinstall); 435 436 include (ABSPATH . 'wp-admin/admin-footer.php'); 437 438 } elseif ( 'do-plugin-upgrade' == $action ) { 439 440 if ( ! current_user_can( 'update_plugins' ) ) 441 wp_die( __( 'You do not have sufficient permissions to update this site.' ) ); 442 443 check_admin_referer('upgrade-core'); 444 445 if ( isset( $_GET['plugins'] ) ) { 446 $plugins = explode( ',', $_GET['plugins'] ); 447 } elseif ( isset( $_POST['checked'] ) ) { 448 $plugins = (array) $_POST['checked']; 449 } else { 450 wp_redirect( admin_url('update-core.php') ); 451 exit; 452 } 453 454 $url = 'update.php?action=update-selected&plugins=' . urlencode(implode(',', $plugins)); 455 $url = wp_nonce_url($url, 'bulk-update-plugins'); 456 457 $title = __('Update Plugins'); 458 459 require_once (ABSPATH . 'wp-admin/admin-header.php'); 460 echo '<div class="wrap">'; 461 screen_icon('plugins'); 462 echo '<h2>' . esc_html__('Update Plugins') . '</h2>'; 463 echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>"; 464 echo '</div>'; 465 include (ABSPATH . 'wp-admin/admin-footer.php'); 466 467 } elseif ( 'do-theme-upgrade' == $action ) { 468 469 if ( ! current_user_can( 'update_themes' ) ) 470 wp_die( __( 'You do not have sufficient permissions to update this site.' ) ); 471 472 check_admin_referer('upgrade-core'); 473 474 if ( isset( $_GET['themes'] ) ) { 475 $themes = explode( ',', $_GET['themes'] ); 476 } elseif ( isset( $_POST['checked'] ) ) { 477 $themes = (array) $_POST['checked']; 478 } else { 479 wp_redirect( admin_url('update-core.php') ); 480 exit; 481 } 482 483 $url = 'update.php?action=update-selected-themes&themes=' . urlencode(implode(',', $themes)); 484 $url = wp_nonce_url($url, 'bulk-update-themes'); 485 486 $title = __('Update Themes'); 487 488 require_once (ABSPATH . 'wp-admin/admin-header.php'); 489 echo '<div class="wrap">'; 490 screen_icon('themes'); 491 echo '<h2>' . esc_html__('Update Themes') . '</h2>'; 492 echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>"; 493 echo '</div>'; 494 include (ABSPATH . 'wp-admin/admin-footer.php'); 495 496 } else { 497 do_action('update-core-custom_' . $action); 498 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jun 1 08:30:02 2011 |
Cross-referenced by PHPXref 0.7 Provided by Yoast and awesome WordPress Hosting |