]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/upgrade.php
WordPress 4.7.2
[autoinstalls/wordpress.git] / 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&#8217;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
55                 $site_ids = get_sites( array(
56                         'spam'       => 0,
57                         'deleted'    => 0,
58                         'archived'   => 0,
59                         'network_id' => get_current_network_id(),
60                         'number'     => 5,
61                         'offset'     => $n,
62                         'fields'     => 'ids',
63                         'order'      => 'DESC',
64                         'orderby'    => 'id',
65                 ) );
66                 if ( empty( $site_ids ) ) {
67                         echo '<p>' . __( 'All done!' ) . '</p>';
68                         break;
69                 }
70                 echo "<ul>";
71                 foreach ( (array) $site_ids as $site_id ) {
72                         switch_to_blog( $site_id );
73                         $siteurl = site_url();
74                         $upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
75                         restore_current_blog();
76
77                         echo "<li>$siteurl</li>";
78
79                         $response = wp_remote_get( $upgrade_url, array(
80                                 'timeout'     => 120,
81                                 'httpversion' => '1.1',
82                                 'sslverify'   => false,
83                         ) );
84                         if ( is_wp_error( $response ) ) {
85                                 wp_die( sprintf(
86                                         /* translators: 1: site url, 2: server error message */
87                                         __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: %2$s' ),
88                                         $siteurl,
89                                         '<em>' . $response->get_error_message() . '</em>'
90                                 ) );
91                         }
92
93                         /**
94                          * Fires after the Multisite DB upgrade for each site is complete.
95                          *
96                          * @since MU
97                          *
98                          * @param array|WP_Error $response The upgrade response array or WP_Error on failure.
99                          */
100                         do_action( 'after_mu_upgrade', $response );
101                         /**
102                          * Fires after each site has been upgraded.
103                          *
104                          * @since MU
105                          *
106                          * @param int $site_id The Site ID.
107                          */
108                         do_action( 'wpmu_upgrade_site', $site_id );
109                 }
110                 echo "</ul>";
111                 ?><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>
112                 <script type="text/javascript">
113                 <!--
114                 function nextpage() {
115                         location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>";
116                 }
117                 setTimeout( "nextpage()", 250 );
118                 //-->
119                 </script><?php
120         break;
121         case 'show':
122         default:
123                 if ( get_site_option( 'wpmu_upgrade_site' ) != $GLOBALS['wp_db_version'] ) :
124                 ?>
125                 <h2><?php _e( 'Database Update Required' ); ?></h2>
126                 <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>
127                 <?php endif; ?>
128
129                 <p><?php _e( 'The database update process may take a little while, so please be patient.' ); ?></p>
130                 <p><a class="button button-primary" href="upgrade.php?action=upgrade"><?php _e( 'Upgrade Network' ); ?></a></p>
131                 <?php
132                 /**
133                  * Fires before the footer on the network upgrade screen.
134                  *
135                  * @since MU
136                  */
137                 do_action( 'wpmu_upgrade_page' );
138         break;
139 }
140 ?>
141 </div>
142
143 <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>