PageRenderTime 19ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Web/wp-admin/network/upgrade.php

https://bitbucket.org/jimjenkins5/blog
PHP | 92 lines | 69 code | 14 blank | 9 comment | 6 complexity | e2c97714aacc8bbdcb1e90ef7270a277 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, AGPL-1.0, LGPL-2.1
 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 */
11require_once( './admin.php' );
12
13if ( ! is_multisite() )
14	wp_die( __( 'Multisite support is not enabled.' ) );
15
16require_once( ABSPATH . WPINC . '/http.php' );
17
18$title = __( 'Update Network' );
19$parent_file = 'upgrade.php';
20
21get_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 Update 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&#8217;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
30get_current_screen()->set_help_sidebar(
31	'<p><strong>' . __('For more information:') . '</strong></p>' .
32	'<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Updates_Screen" target="_blank">Documentation on Update Network</a>') . '</p>' .
33	'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
34);
35
36require_once('../admin-header.php');
37
38if ( ! current_user_can( 'manage_network' ) )
39	wp_die( __( 'You do not have permission to access this page.' ) );
40
41echo '<div class="wrap">';
42screen_icon('tools');
43echo '<h2>' . __( 'Update Network' ) . '</h2>';
44
45$action = isset($_GET['action']) ? $_GET['action'] : 'show';
46
47switch ( $action ) {
48	case "upgrade":
49		$n = ( isset($_GET['n']) ) ? intval($_GET['n']) : 0;
50
51		if ( $n < 5 ) {
52			global $wp_db_version;
53			update_site_option( 'wpmu_upgrade_site', $wp_db_version );
54		}
55
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 );
57		if ( empty( $blogs ) ) {
58			echo '<p>' . __( 'All done!' ) . '</p>';
59			break;
60		}
61		echo "<ul>";
62		foreach ( (array) $blogs as $details ) {
63			$siteurl = get_blog_option( $details['blog_id'], 'siteurl' );
64			echo "<li>$siteurl</li>";
65			$response = wp_remote_get( trailingslashit( $siteurl ) . "wp-admin/upgrade.php?step=upgrade_db", array( 'timeout' => 120, 'httpversion' => '1.1' ) );
66			if ( is_wp_error( $response ) )
67				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() ) );
68			do_action( 'after_mu_upgrade', $response );
69			do_action( 'wpmu_upgrade_site', $details[ 'blog_id' ] );
70		}
71		echo "</ul>";
72		?><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>
73		<script type='text/javascript'>
74		<!--
75		function nextpage() {
76			location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>";
77		}
78		setTimeout( "nextpage()", 250 );
79		//-->
80		</script><?php
81	break;
82	case 'show':
83	default:
84		?><p><?php _e( 'You can update all the sites on your network through this page. It works by calling the update script of each site automatically. Hit the link below to update.' ); ?></p>
85		<p><a class="button" href="upgrade.php?action=upgrade"><?php _e("Update Network"); ?></a></p><?php
86		do_action( 'wpmu_upgrade_page' );
87	break;
88}
89?>
90</div>
91
92<?php include('../admin-footer.php'); ?>