0
|
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 |
if ( ! is_multisite() ) |
|
14 |
wp_die( __( 'Multisite support is not enabled.' ) ); |
|
15 |
|
|
16 |
require_once( ABSPATH . WPINC . '/http.php' ); |
|
17 |
|
|
18 |
$title = __( 'Upgrade Network' ); |
|
19 |
$parent_file = 'upgrade.php'; |
|
20 |
|
|
21 |
get_current_screen()->add_help_tab( array( |
|
22 |
'id' => 'overview', |
|
23 |
'title' => __('Overview'), |
|
24 |
'content' => |
|
25 |
'<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>' . |
|
26 |
'<p>' . __('If a version update to core has not happened, clicking this button won’t affect anything.') . '</p>' . |
|
27 |
'<p>' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '</p>' |
|
28 |
) ); |
|
29 |
|
|
30 |
get_current_screen()->set_help_sidebar( |
|
31 |
'<p><strong>' . __('For more information:') . '</strong></p>' . |
5
|
32 |
'<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Updates_Screen" target="_blank">Documentation on Upgrade Network</a>') . '</p>' . |
|
33 |
'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
0
|
34 |
); |
|
35 |
|
|
36 |
require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
37 |
|
|
38 |
if ( ! current_user_can( 'manage_network' ) ) |
5
|
39 |
wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
0
|
40 |
|
|
41 |
echo '<div class="wrap">'; |
|
42 |
echo '<h2>' . __( 'Upgrade Network' ) . '</h2>'; |
|
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 |
global $wp_db_version; |
|
52 |
update_site_option( 'wpmu_upgrade_site', $wp_db_version ); |
|
53 |
} |
|
54 |
|
5
|
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 ); |
0
|
56 |
if ( empty( $blogs ) ) { |
|
57 |
echo '<p>' . __( 'All done!' ) . '</p>'; |
|
58 |
break; |
|
59 |
} |
|
60 |
echo "<ul>"; |
|
61 |
foreach ( (array) $blogs as $details ) { |
|
62 |
switch_to_blog( $details['blog_id'] ); |
|
63 |
$siteurl = site_url(); |
|
64 |
$upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' ); |
|
65 |
restore_current_blog(); |
5
|
66 |
|
0
|
67 |
echo "<li>$siteurl</li>"; |
5
|
68 |
|
0
|
69 |
$response = wp_remote_get( $upgrade_url, array( 'timeout' => 120, 'httpversion' => '1.1' ) ); |
5
|
70 |
if ( is_wp_error( $response ) ) { |
|
71 |
wp_die( sprintf( |
|
72 |
/* 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' ), |
|
74 |
$siteurl, |
|
75 |
'<em>' . $response->get_error_message() . '</em>' |
|
76 |
) ); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Fires after the Multisite DB upgrade for each site is complete. |
|
81 |
* |
|
82 |
* @since MU |
|
83 |
* |
|
84 |
* @param array|WP_Error $response The upgrade response array or WP_Error on failure. |
|
85 |
*/ |
0
|
86 |
do_action( 'after_mu_upgrade', $response ); |
5
|
87 |
/** |
|
88 |
* Fires after each site has been upgraded. |
|
89 |
* |
|
90 |
* @since MU |
|
91 |
* |
|
92 |
* @param int $blog_id The id of the blog. |
|
93 |
*/ |
0
|
94 |
do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] ); |
|
95 |
} |
|
96 |
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> |
5
|
98 |
<script type="text/javascript"> |
0
|
99 |
<!-- |
|
100 |
function nextpage() { |
|
101 |
location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>"; |
|
102 |
} |
|
103 |
setTimeout( "nextpage()", 250 ); |
|
104 |
//--> |
|
105 |
</script><?php |
|
106 |
break; |
|
107 |
case 'show': |
|
108 |
default: |
|
109 |
if ( get_site_option( 'wpmu_upgrade_site' ) != $GLOBALS['wp_db_version'] ) : |
|
110 |
?> |
|
111 |
<h3><?php _e( 'Database Upgrade Required' ); ?></h3> |
|
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> |
|
113 |
<?php endif; ?> |
|
114 |
|
|
115 |
<p><?php _e( 'The database upgrade 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> |
|
117 |
<?php |
5
|
118 |
/** |
|
119 |
* Fires before the footer on the network upgrade screen. |
|
120 |
* |
|
121 |
* @since MU |
|
122 |
*/ |
0
|
123 |
do_action( 'wpmu_upgrade_page' ); |
|
124 |
break; |
|
125 |
} |
|
126 |
?> |
|
127 |
</div> |
|
128 |
|
|
129 |
<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |