[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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( __DIR__ ) . '/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             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   * @global wpdb   $wpdb                   WordPress database abstraction object.
  43   */
  44  global $wp_version, $required_php_version, $required_mysql_version, $wpdb;
  45  
  46  $step = (int) $step;
  47  
  48  $php_version   = PHP_VERSION;
  49  $mysql_version = $wpdb->db_version();
  50  $php_compat    = version_compare( $php_version, $required_php_version, '>=' );
  51  if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
  52      $mysql_compat = true;
  53  } else {
  54      $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' );
  55  }
  56  
  57  header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
  58  ?>
  59  <!DOCTYPE html>
  60  <html <?php language_attributes(); ?>>
  61  <head>
  62      <meta name="viewport" content="width=device-width" />
  63      <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" />
  64      <meta name="robots" content="noindex,nofollow" />
  65      <title><?php _e( 'WordPress &rsaquo; Update' ); ?></title>
  66      <?php wp_admin_css( 'install', true ); ?>
  67  </head>
  68  <body class="wp-core-ui">
  69  <p id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></p>
  70  
  71  <?php if ( (int) get_option( 'db_version' ) === $wp_db_version || ! is_blog_installed() ) : ?>
  72  
  73  <h1><?php _e( 'No Update Required' ); ?></h1>
  74  <p><?php _e( 'Your WordPress database is already up to date!' ); ?></p>
  75  <p class="step"><a class="button button-large" href="<?php echo esc_url( get_option( 'home' ) ); ?>/"><?php _e( 'Continue' ); ?></a></p>
  76  
  77      <?php
  78  elseif ( ! $php_compat || ! $mysql_compat ) :
  79      $version_url = sprintf(
  80          /* translators: %s: WordPress version. */
  81          esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ),
  82          sanitize_title( $wp_version )
  83      );
  84  
  85      $php_update_message = '</p><p>' . sprintf(
  86          /* translators: %s: URL to Update PHP page. */
  87          __( '<a href="%s">Learn more about updating PHP</a>.' ),
  88          esc_url( wp_get_update_php_url() )
  89      );
  90  
  91      $annotation = wp_get_update_php_annotation();
  92  
  93      if ( $annotation ) {
  94          $php_update_message .= '</p><p><em>' . $annotation . '</em>';
  95      }
  96  
  97      if ( ! $mysql_compat && ! $php_compat ) {
  98          $message = sprintf(
  99              /* 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. */
 100              __( '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.' ),
 101              $version_url,
 102              $wp_version,
 103              $required_php_version,
 104              $required_mysql_version,
 105              $php_version,
 106              $mysql_version
 107          ) . $php_update_message;
 108      } elseif ( ! $php_compat ) {
 109          $message = sprintf(
 110              /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */
 111              __( '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.' ),
 112              $version_url,
 113              $wp_version,
 114              $required_php_version,
 115              $php_version
 116          ) . $php_update_message;
 117      } elseif ( ! $mysql_compat ) {
 118          $message = sprintf(
 119              /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */
 120              __( '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.' ),
 121              $version_url,
 122              $wp_version,
 123              $required_mysql_version,
 124              $mysql_version
 125          );
 126      }
 127  
 128      echo '<p>' . $message . '</p>';
 129      ?>
 130      <?php
 131  else :
 132      switch ( $step ) :
 133          case 0:
 134              $goback = wp_get_referer();
 135              if ( $goback ) {
 136                  $goback = sanitize_url( $goback );
 137                  $goback = urlencode( $goback );
 138              }
 139              ?>
 140      <h1><?php _e( 'Database Update Required' ); ?></h1>
 141  <p><?php _e( 'WordPress has been updated! Next and final step is to update your database to the newest version.' ); ?></p>
 142  <p><?php _e( 'The database update process may take a little while, so please be patient.' ); ?></p>
 143  <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>
 144              <?php
 145              break;
 146          case 1:
 147              wp_upgrade();
 148  
 149              $backto = ! empty( $_GET['backto'] ) ? wp_unslash( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/';
 150              $backto = esc_url( $backto );
 151              $backto = wp_validate_redirect( $backto, __get_option( 'home' ) . '/' );
 152              ?>
 153      <h1><?php _e( 'Update Complete' ); ?></h1>
 154      <p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p>
 155      <p class="step"><a class="button button-large" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p>
 156              <?php
 157              break;
 158  endswitch;
 159  endif;
 160  ?>
 161  </body>
 162  </html>


Generated : Mon Mar 18 08:20:01 2024 Cross-referenced by PHPXref