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