| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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 $step = $_GET['step'] ?? 0; 27 28 // Do it. No output. 29 if ( 'upgrade_db' === $step ) { 30 wp_upgrade(); 31 die( '0' ); 32 } 33 34 /** 35 * @global string $wp_version The WordPress version string. 36 * @global string $required_php_version The minimum required PHP version string. 37 * @global string[] $required_php_extensions The names of required PHP extensions. 38 * @global string $required_mysql_version The minimum required MySQL version string. 39 * @global wpdb $wpdb WordPress database abstraction object. 40 */ 41 global $wp_version, $required_php_version, $required_php_extensions, $required_mysql_version, $wpdb; 42 43 $step = (int) $step; 44 45 $php_version = PHP_VERSION; 46 $mysql_version = $wpdb->db_version(); 47 $php_compat = version_compare( $php_version, $required_php_version, '>=' ); 48 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { 49 $mysql_compat = true; 50 } else { 51 $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ); 52 } 53 54 $missing_extensions = array(); 55 56 if ( isset( $required_php_extensions ) && is_array( $required_php_extensions ) ) { 57 foreach ( $required_php_extensions as $extension ) { 58 if ( extension_loaded( $extension ) ) { 59 continue; 60 } 61 62 $missing_extensions[] = sprintf( 63 /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: The PHP extension name needed. */ 64 __( 'You cannot upgrade because <a href="%1$s">WordPress %2$s</a> requires the %3$s PHP extension.' ), 65 $version_url, 66 $wp_version, 67 $extension 68 ); 69 } 70 } 71 72 header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); 73 ?> 74 <!DOCTYPE html> 75 <html <?php language_attributes(); ?>> 76 <head> 77 <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 78 <meta http-equiv="Content-Type" content="<?php bloginfo( 'html_type' ); ?>; charset=<?php echo get_option( 'blog_charset' ); ?>" /> 79 <meta name="robots" content="noindex,nofollow" /> 80 <title><?php _e( 'WordPress › Update' ); ?></title> 81 <?php wp_admin_css( 'install', true ); ?> 82 </head> 83 <body class="wp-core-ui admin-color-modern"> 84 <p id="logo"><?php _e( 'WordPress' ); ?></p> 85 86 <?php if ( (int) get_option( 'db_version' ) === $wp_db_version || ! is_blog_installed() ) : ?> 87 88 <h1><?php _e( 'No Update Required' ); ?></h1> 89 <p><?php _e( 'Your WordPress database is already up to date!' ); ?></p> 90 <p class="step"><a class="button button-large" href="<?php echo esc_url( get_option( 'home' ) ); ?>/"><?php _e( 'Continue' ); ?></a></p> 91 92 <?php 93 elseif ( ! $php_compat || ! $mysql_compat ) : 94 $version_url = sprintf( 95 /* translators: %s: WordPress version. */ 96 esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ), 97 sanitize_title( $wp_version ) 98 ); 99 100 $php_update_message = '</p><p>' . sprintf( 101 /* translators: %s: URL to Update PHP page. */ 102 __( '<a href="%s">Learn more about updating PHP</a>.' ), 103 esc_url( wp_get_update_php_url() ) 104 ); 105 106 $annotation = wp_get_update_php_annotation(); 107 108 if ( $annotation ) { 109 $php_update_message .= '</p><p><em>' . $annotation . '</em>'; 110 } 111 112 if ( ! $mysql_compat && ! $php_compat ) { 113 $message = sprintf( 114 /* 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. */ 115 __( '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.' ), 116 $version_url, 117 $wp_version, 118 $required_php_version, 119 $required_mysql_version, 120 $php_version, 121 $mysql_version 122 ) . $php_update_message; 123 } elseif ( ! $php_compat ) { 124 $message = sprintf( 125 /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */ 126 __( '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.' ), 127 $version_url, 128 $wp_version, 129 $required_php_version, 130 $php_version 131 ) . $php_update_message; 132 } elseif ( ! $mysql_compat ) { 133 $message = sprintf( 134 /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */ 135 __( '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.' ), 136 $version_url, 137 $wp_version, 138 $required_mysql_version, 139 $mysql_version 140 ); 141 } 142 143 echo '<p>' . $message . '</p>'; 144 elseif ( count( $missing_extensions ) > 0 ) : 145 echo '<p>' . implode( '</p><p>', $missing_extensions ) . '</p>'; 146 else : 147 switch ( $step ) : 148 case 0: 149 $goback = wp_get_referer(); 150 if ( $goback ) { 151 $goback = sanitize_url( $goback ); 152 $goback = urlencode( $goback ); 153 } 154 ?> 155 <h1><?php _e( 'Database Update Required' ); ?></h1> 156 <p><?php _e( 'WordPress has been updated! Next and final step is to update your database to the newest version.' ); ?></p> 157 <p><?php _e( 'The database update process may take a little while, so please be patient.' ); ?></p> 158 <p class="step"><a class="button button-large button-primary" href="upgrade.php?step=1&backto=<?php echo $goback; ?>"><?php _e( 'Update WordPress Database' ); ?></a></p> 159 <?php 160 break; 161 case 1: 162 wp_upgrade(); 163 164 $backto = ! empty( $_GET['backto'] ) ? wp_unslash( urldecode( $_GET['backto'] ) ) : __get_option( 'home' ) . '/'; 165 $backto = esc_url( $backto ); 166 $backto = wp_validate_redirect( $backto, __get_option( 'home' ) . '/' ); 167 ?> 168 <h1><?php _e( 'Update Complete' ); ?></h1> 169 <p><?php _e( 'Your WordPress database has been successfully updated!' ); ?></p> 170 <p class="step"><a class="button button-large" href="<?php echo $backto; ?>"><?php _e( 'Continue' ); ?></a></p> 171 <?php 172 break; 173 endswitch; 174 endif; 175 ?> 176 </body> 177 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Mon Apr 20 08:20:11 2026 | Cross-referenced by PHPXref |