PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-admin/upgrade.php

http://github.com/markjaquith/WordPress
PHP | 157 lines | 114 code | 19 blank | 24 comment | 16 complexity | c10db686db74734e2f88f635e5b34b79 MD5 | raw file
  1<?php
  2/**
  3 * Upgrade WordPress Page.
  4 *
  5 * @package WordPress
  6 * @subpackage Administration
  7 */
  8
  9/**
 10 * We are upgrading WordPress.
 11 *
 12 * @since 1.5.1
 13 * @var bool
 14 */
 15define( 'WP_INSTALLING', true );
 16
 17/** Load WordPress Bootstrap */
 18require dirname( __DIR__ ) . '/wp-load.php';
 19
 20nocache_headers();
 21
 22require_once ABSPATH . 'wp-admin/includes/upgrade.php';
 23
 24delete_site_transient( 'update_core' );
 25
 26if ( isset( $_GET['step'] ) ) {
 27	$step = $_GET['step'];
 28} else {
 29	$step = 0;
 30}
 31
 32// Do it. No output.
 33if ( 'upgrade_db' === $step ) {
 34	wp_upgrade();
 35	die( '0' );
 36}
 37
 38/**
 39 * @global string $wp_version             The WordPress version string.
 40 * @global string $required_php_version   The required PHP version string.
 41 * @global string $required_mysql_version The required MySQL version string.
 42 */
 43global $wp_version, $required_php_version, $required_mysql_version;
 44
 45$step = (int) $step;
 46
 47$php_version   = phpversion();
 48$mysql_version = $wpdb->db_version();
 49$php_compat    = version_compare( $php_version, $required_php_version, '>=' );
 50if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
 51	$mysql_compat = true;
 52} else {
 53	$mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
 54}
 55
 56header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
 57?>
 58<!DOCTYPE html>
 59<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
 60<head>
 61	<meta name="viewport" content="width=device-width" />
 62	<meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
 63	<meta name="robots" content="noindex,nofollow" />
 64	<title><?php _e( 'WordPress &rsaquo; Update' ); ?></title>
 65	<?php wp_admin_css( 'install', true ); ?>
 66</head>
 67<body class="wp-core-ui">
 68<p id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></p>
 69
 70<?php if ( get_option( 'db_version' ) == $wp_db_version || ! is_blog_installed() ) : ?>
 71
 72<h1><?php _e( 'No Update Required' ); ?></h1>
 73<p><?php _e( 'Your WordPress database is already up to date!' ); ?></p>
 74<p class="step"><a class="button button-large" href="<?php echo get_option( 'home' ); ?>/"><?php _e( 'Continue' ); ?></a></p>
 75
 76	<?php
 77elseif ( ! $php_compat || ! $mysql_compat ) :
 78	$version_url = sprintf(
 79		/* translators: %s: WordPress version. */
 80		esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
 81		sanitize_title( $wp_version )
 82	);
 83
 84	/* translators: %s: URL to Update PHP page. */
 85	$php_update_message = '</p><p>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
 86
 87	$annotation = wp_get_update_php_annotation();
 88	if ( $annotation ) {
 89		$php_update_message .= '</p><p><em>' . $annotation . '</em>';
 90	}
 91
 92	if ( ! $mysql_compat && ! $php_compat ) {
 93		$message = sprintf(
 94			/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */
 95			__( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ),
 96			$version_url,
 97			$wp_version,
 98			$required_php_version,
 99			$required_mysql_version,
100			$php_version,
101			$mysql_version
102		) . $php_update_message;
103	} elseif ( ! $php_compat ) {
104		$message = sprintf(
105			/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
106			__( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ),
107			$version_url,
108			$wp_version,
109			$required_php_version,
110			$php_version
111		) . $php_update_message;
112	} elseif ( ! $mysql_compat ) {
113		$message = sprintf(
114			/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
115			__( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ),
116			$version_url,
117			$wp_version,
118			$required_mysql_version,
119			$mysql_version
120		);
121	}
122
123	echo '<p>' . $message . '</p>';
124	?>
125	<?php
126else :
127	switch ( $step ) :
128		case 0:
129			$goback = wp_get_referer();
130			if ( $goback ) {
131				$goback = esc_url_raw( $goback );
132				$goback = urlencode( $goback );
133			}
134			?>
135	<h1><?php _e( 'Database Update Required' ); ?></h1>
136<p><?php _e( 'WordPress has been updated! Before we send you on your way, we have to update your database to the newest version.' ); ?></p>
137<p><?php _e( 'The database update process may take a little while, so please be patient.' ); ?></p>
138<p class="step"><a class="button button-large button-primary" href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e( 'Update WordPress Database' ); ?></a></p>
139			<?php
140			break;
141		case 1:
142			wp_upgrade();
143
144			$backto = ! empty( $_GET['backto'] ) ? wp_unslash( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
145			$backto = esc_url( $backto );
146			$backto = wp_validate_redirect( $backto, __get_option( 'home' ) . '/' );
147			?>
148	<h1><?php _e( 'Update Complete' ); ?></h1>
149	<p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
150	<p class="step"><a class="button button-large" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
151			<?php
152			break;
153endswitch;
154endif;
155?>
156</body>
157</html>