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