PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-admin/network/upgrade.php

https://bitbucket.org/julianelve/vendor-wordpress
PHP | 95 lines | 72 code | 14 blank | 9 comment | 6 complexity | e68567ee716b378ac641fabb12e4dbcb MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * Multisite upgrade administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Multisite
  7. * @since 3.0.0
  8. */
  9. /** Load WordPress Administration Bootstrap */
  10. require_once( './admin.php' );
  11. if ( ! is_multisite() )
  12. wp_die( __( 'Multisite support is not enabled.' ) );
  13. require_once( ABSPATH . WPINC . '/http.php' );
  14. $title = __( 'Update Network' );
  15. $parent_file = 'upgrade.php';
  16. get_current_screen()->add_help_tab( array(
  17. 'id' => 'overview',
  18. 'title' => __('Overview'),
  19. 'content' =>
  20. '<p>' . __('Only use this screen once you have updated to a new version of WordPress through Updates/Available Updates (via the Network Administration navigation menu or the Toolbar). Clicking the Update Network button will step through each site in the network, five at a time, and make sure any database updates are applied.') . '</p>' .
  21. '<p>' . __('If a version update to core has not happened, clicking this button won&#8217;t affect anything.') . '</p>' .
  22. '<p>' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '</p>'
  23. ) );
  24. get_current_screen()->set_help_sidebar(
  25. '<p><strong>' . __('For more information:') . '</strong></p>' .
  26. '<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Updates_Screen" target="_blank">Documentation on Update Network</a>') . '</p>' .
  27. '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
  28. );
  29. require_once('../admin-header.php');
  30. if ( ! current_user_can( 'manage_network' ) )
  31. wp_die( __( 'You do not have permission to access this page.' ) );
  32. echo '<div class="wrap">';
  33. screen_icon('tools');
  34. echo '<h2>' . __( 'Update Network' ) . '</h2>';
  35. $action = isset($_GET['action']) ? $_GET['action'] : 'show';
  36. switch ( $action ) {
  37. case "upgrade":
  38. $n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0;
  39. if ( $n < 5 ) {
  40. global $wp_db_version;
  41. update_site_option( 'wpmu_upgrade_site', $wp_db_version );
  42. }
  43. $blogs = $wpdb->get_results( "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' ORDER BY registered DESC LIMIT {$n}, 5", ARRAY_A );
  44. if ( empty( $blogs ) ) {
  45. echo '<p>' . __( 'All done!' ) . '</p>';
  46. break;
  47. }
  48. echo "<ul>";
  49. foreach ( (array) $blogs as $details ) {
  50. switch_to_blog( $details['blog_id'] );
  51. $siteurl = site_url();
  52. $upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
  53. restore_current_blog();
  54. echo "<li>$siteurl</li>";
  55. $response = wp_remote_get( $upgrade_url, array( 'timeout' => 120, 'httpversion' => '1.1' ) );
  56. if ( is_wp_error( $response ) )
  57. wp_die( sprintf( __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: <em>%2$s</em>' ), $siteurl, $response->get_error_message() ) );
  58. do_action( 'after_mu_upgrade', $response );
  59. do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] );
  60. }
  61. echo "</ul>";
  62. ?><p><?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this link:' ); ?> <a class="button" href="upgrade.php?action=upgrade&amp;n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p>
  63. <script type='text/javascript'>
  64. <!--
  65. function nextpage() {
  66. location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>";
  67. }
  68. setTimeout( "nextpage()", 250 );
  69. //-->
  70. </script><?php
  71. break;
  72. case 'show':
  73. default:
  74. ?><p><?php _e( 'You can update all the sites on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update.' ); ?></p>
  75. <p><a class="button" href="upgrade.php?action=upgrade"><?php _e("Update Network"); ?></a></p><?php
  76. do_action( 'wpmu_upgrade_page' );
  77. break;
  78. }
  79. ?>
  80. </div>
  81. <?php include('../admin-footer.php'); ?>