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