wp/wp-admin/network/upgrade.php
author ymh <ymh.work@gmail.com>
Thu, 07 Nov 2013 00:08:07 +0000
changeset 1 f6eb5a861d2f
parent 0 d970ebf37754
child 5 5e2f62d02dcd
permissions -rw-r--r--
remove unnessary files. Make timthumb work
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Multisite upgrade administration panel.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Multisite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/** Load WordPress Administration Bootstrap */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
require_once( dirname( __FILE__ ) . '/admin.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
if ( ! is_multisite() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	wp_die( __( 'Multisite support is not enabled.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
require_once( ABSPATH . WPINC . '/http.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
$title = __( 'Upgrade Network' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
$parent_file = 'upgrade.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
get_current_screen()->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
	'id'      => 'overview',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
	'title'   => __('Overview'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	'content' =>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
		'<p>' . __('If a version update to core has not happened, clicking this button won&#8217;t affect anything.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
		'<p>' . __('If this process fails for any reason, users logging in to their sites will force the same update.') . '</p>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
get_current_screen()->set_help_sidebar(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
	'<p><strong>' . __('For more information:') . '</strong></p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Updates_Screen" target="_blank">Documentation on Upgrade Network</a>') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
require_once( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
if ( ! current_user_can( 'manage_network' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
	wp_die( __( 'You do not have permission to access this page.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
echo '<div class="wrap">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
screen_icon('tools');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
echo '<h2>' . __( 'Upgrade Network' ) . '</h2>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
$action = isset($_GET['action']) ? $_GET['action'] : 'show';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
switch ( $action ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
	case "upgrade":
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
		$n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
		if ( $n < 5 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
			global $wp_db_version;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
			update_site_option( 'wpmu_upgrade_site', $wp_db_version );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
		$blogs = $wpdb->get_results( "SELECT * 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 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
		if ( empty( $blogs ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
			echo '<p>' . __( 'All done!' ) . '</p>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
		echo "<ul>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
		foreach ( (array) $blogs as $details ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
			switch_to_blog( $details['blog_id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
			$siteurl = site_url();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
			$upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
			restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
			echo "<li>$siteurl</li>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
			$response = wp_remote_get( $upgrade_url, array( 'timeout' => 120, 'httpversion' => '1.1' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
			if ( is_wp_error( $response ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
				wp_die( sprintf( __( 'Warning! Problem updating %1$s. Your server may not be able to connect to sites running on it. Error message: <em>%2$s</em>' ), $siteurl, $response->get_error_message() ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
			do_action( 'after_mu_upgrade', $response );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
			do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
		echo "</ul>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
		?><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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
		<script type='text/javascript'>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		<!--
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
		function nextpage() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
			location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
		setTimeout( "nextpage()", 250 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
		//-->
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
		</script><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
	break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
	case 'show':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
	default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
		if ( get_site_option( 'wpmu_upgrade_site' ) != $GLOBALS['wp_db_version'] ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
		<h3><?php _e( 'Database Upgrade Required' ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
		<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>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
		<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
		<p><?php _e( 'The database upgrade process may take a little while, so please be patient.' ); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
		<p><a class="button" href="upgrade.php?action=upgrade"><?php _e( 'Upgrade Network' ); ?></a></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
		do_action( 'wpmu_upgrade_page' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
	break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>