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