[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/network/ -> upgrade.php (source)

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


Generated: Fri Oct 25 08:20:01 2019 Cross-referenced by PHPXref 0.7