/wp-admin/network/upgrade.php

  1. <?php 
  2. /** 
  3. * Multisite upgrade administration panel. 
  4. * 
  5. * @package WordPress 
  6. * @subpackage Multisite 
  7. * @since 3.0.0 
  8. */ 
  9.  
  10. /** Load WordPress Administration Bootstrap */ 
  11. require_once( dirname( __FILE__ ) . '/admin.php' ); 
  12.  
  13. require_once( ABSPATH . WPINC . '/http.php' ); 
  14.  
  15. $title = __( 'Upgrade Network' ); 
  16. $parent_file = 'upgrade.php'; 
  17.  
  18. get_current_screen()->add_help_tab( array( 
  19. 'id' => 'overview',  
  20. 'title' => __('Overview'),  
  21. 'content' => 
  22. '<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 Upgrade Network button will step through each site in the network, five at a time, and make sure any database updates are applied.') . '</p>' . 
  23. '<p>' . __('If a version update to core has not happened, clicking this button won’t affect anything.') . '</p>' . 
  24. '<p>' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '</p>' 
  25. ) ); 
  26.  
  27. get_current_screen()->set_help_sidebar( 
  28. '<p><strong>' . __('For more information:') . '</strong></p>' . 
  29. '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Updates_Screen">Documentation on Upgrade Network</a>') . '</p>' . 
  30. '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' 
  31. ); 
  32.  
  33. require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
  34.  
  35. if ( ! current_user_can( 'manage_network' ) ) 
  36. wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); 
  37.  
  38. echo '<div class="wrap">'; 
  39. echo '<h1>' . __( 'Upgrade Network' ) . '</h1>'; 
  40.  
  41. $action = isset($_GET['action']) ? $_GET['action'] : 'show'; 
  42.  
  43. switch ( $action ) { 
  44. case "upgrade": 
  45. $n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0; 
  46.  
  47. if ( $n < 5 ) { 
  48. /** 
  49. * @global string $wp_db_version 
  50. */ 
  51. global $wp_db_version; 
  52. update_site_option( 'wpmu_upgrade_site', $wp_db_version ); 
  53.  
  54. $site_ids = get_sites( array( 
  55. 'spam' => 0,  
  56. 'deleted' => 0,  
  57. 'archived' => 0,  
  58. 'network_id' => get_current_network_id(),  
  59. 'number' => 5,  
  60. 'offset' => $n,  
  61. 'fields' => 'ids',  
  62. 'order' => 'DESC',  
  63. 'orderby' => 'id',  
  64. ) ); 
  65. if ( empty( $site_ids ) ) { 
  66. echo '<p>' . __( 'All done!' ) . '</p>'; 
  67. break; 
  68. echo "<ul>"; 
  69. foreach ( (array) $site_ids as $site_id ) { 
  70. switch_to_blog( $site_id ); 
  71. $siteurl = site_url(); 
  72. $upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' ); 
  73. restore_current_blog(); 
  74.  
  75. echo "<li>$siteurl</li>"; 
  76.  
  77. $response = wp_remote_get( $upgrade_url, array( 
  78. 'timeout' => 120,  
  79. 'httpversion' => '1.1',  
  80. 'sslverify' => false,  
  81. ) ); 
  82. if ( is_wp_error( $response ) ) { 
  83. wp_die( sprintf( 
  84. /** translators: 1: site url, 2: server error message */ 
  85. __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s' ),  
  86. $siteurl,  
  87. '<em>' . $response->get_error_message() . '</em>' 
  88. ) ); 
  89.  
  90. /** 
  91. * Fires after the Multisite DB upgrade for each site is complete. 
  92. * 
  93. * @since MU 
  94. * 
  95. * @param array|WP_Error $response The upgrade response array or WP_Error on failure. 
  96. */ 
  97. do_action( 'after_mu_upgrade', $response ); 
  98. /** 
  99. * Fires after each site has been upgraded. 
  100. * 
  101. * @since MU 
  102. * 
  103. * @param int $site_id The Site ID. 
  104. */ 
  105. do_action( 'wpmu_upgrade_site', $site_id ); 
  106. echo "</ul>"; 
  107. ?><p><?php _e( 'If your browser doesn’t start loading the next page automatically, click this link:' ); ?> <a class="button" href="upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p> 
  108. <script type="text/javascript"> 
  109. <!-- 
  110. function nextpage() { 
  111. location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>"; 
  112. setTimeout( "nextpage()", 250 ); 
  113. //--> 
  114. </script><?php 
  115. break; 
  116. case 'show': 
  117. default: 
  118. if ( get_site_option( 'wpmu_upgrade_site' ) != $GLOBALS['wp_db_version'] ) : 
  119. ?> 
  120. <h2><?php _e( 'Database Update Required' ); ?></h2> 
  121. <p><?php _e( 'WordPress has been updated! Before we send you on your way, we need to individually upgrade the sites in your network.' ); ?></p> 
  122. <?php endif; ?> 
  123.  
  124. <p><?php _e( 'The database update process may take a little while, so please be patient.' ); ?></p> 
  125. <p><a class="button button-primary" href="upgrade.php?action=upgrade"><?php _e( 'Upgrade Network' ); ?></a></p> 
  126. <?php 
  127. /** 
  128. * Fires before the footer on the network upgrade screen. 
  129. * 
  130. * @since MU 
  131. */ 
  132. do_action( 'wpmu_upgrade_page' ); 
  133. break; 
  134. ?> 
  135. </div> 
  136.  
  137. <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> 
.