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