[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/ -> upgrade.php (source)

   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   */
  15  define( 'WP_INSTALLING', true );
  16  
  17  /** Load WordPress Bootstrap */
  18  require( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
  19  
  20  nocache_headers();
  21  
  22  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
  23  
  24  delete_site_transient( 'update_core' );
  25  
  26  if ( isset( $_GET['step'] ) ) {
  27      $step = $_GET['step'];
  28  } else {
  29      $step = 0;
  30  }
  31  
  32  // Do it. No output.
  33  if ( 'upgrade_db' === $step ) {
  34      wp_upgrade();
  35      die( '0' );
  36  }
  37  
  38  /**
  39   * @global string $wp_version
  40   * @global string $required_php_version
  41   * @global string $required_mysql_version
  42   */
  43  global $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, '>=' );
  50  if ( 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  
  56  header( '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
  66      wp_admin_css( 'install', true );
  67      wp_admin_css( 'ie', true );
  68      ?>
  69  </head>
  70  <body class="wp-core-ui">
  71  <p id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></p>
  72  
  73  <?php if ( get_option( 'db_version' ) == $wp_db_version || ! is_blog_installed() ) : ?>
  74  
  75  <h1><?php _e( 'No Update Required' ); ?></h1>
  76  <p><?php _e( 'Your WordPress database is already up to date!' ); ?></p>
  77  <p class="step"><a class="button button-large" href="<?php echo get_option( 'home' ); ?>/"><?php _e( 'Continue' ); ?></a></p>
  78  
  79      <?php
  80  elseif ( ! $php_compat || ! $mysql_compat ) :
  81      $version_url = sprintf(
  82          /* translators: %s: WordPress version. */
  83          esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
  84          sanitize_title( $wp_version )
  85      );
  86  
  87      /* translators: %s: URL to Update PHP page. */
  88      $php_update_message = '</p><p>' . sprintf( __( '<a href="%s">Learn more about updating PHP</a>.' ), esc_url( wp_get_update_php_url() ) );
  89  
  90      $annotation = wp_get_update_php_annotation();
  91      if ( $annotation ) {
  92          $php_update_message .= '</p><p><em>' . $annotation . '</em>';
  93      }
  94  
  95      if ( ! $mysql_compat && ! $php_compat ) {
  96          $message = sprintf(
  97              /* 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. */
  98              __( '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.' ),
  99              $version_url,
 100              $wp_version,
 101              $required_php_version,
 102              $required_mysql_version,
 103              $php_version,
 104              $mysql_version
 105          ) . $php_update_message;
 106      } elseif ( ! $php_compat ) {
 107          $message = sprintf(
 108              /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
 109              __( '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.' ),
 110              $version_url,
 111              $wp_version,
 112              $required_php_version,
 113              $php_version
 114          ) . $php_update_message;
 115      } elseif ( ! $mysql_compat ) {
 116          $message = sprintf(
 117              /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
 118              __( '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.' ),
 119              $version_url,
 120              $wp_version,
 121              $required_mysql_version,
 122              $mysql_version
 123          );
 124      }
 125  
 126      echo '<p>' . $message . '</p>';
 127      ?>
 128      <?php
 129  else :
 130      switch ( $step ) :
 131          case 0:
 132              $goback = wp_get_referer();
 133              if ( $goback ) {
 134                  $goback = esc_url_raw( $goback );
 135                  $goback = urlencode( $goback );
 136              }
 137              ?>
 138      <h1><?php _e( 'Database Update Required' ); ?></h1>
 139  <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>
 140  <p><?php _e( 'The database update process may take a little while, so please be patient.' ); ?></p>
 141  <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>
 142              <?php
 143              break;
 144          case 1:
 145              wp_upgrade();
 146  
 147              $backto = ! empty( $_GET['backto'] ) ? wp_unslash( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
 148              $backto = esc_url( $backto );
 149              $backto = wp_validate_redirect( $backto, __get_option( 'home' ) . '/' );
 150              ?>
 151      <h1><?php _e( 'Update Complete' ); ?></h1>
 152      <p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
 153      <p class="step"><a class="button button-large" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
 154              <?php
 155              break;
 156  endswitch;
 157  endif;
 158  ?>
 159  </body>
 160  </html>


Generated: Thu Sep 19 01:00:03 2019 Cross-referenced by PHPXref 0.7.1