| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * WordPress Installer 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 // Confidence check. 10 if ( false ) { 11 ?> 12 <!DOCTYPE html> 13 <html lang="en-US"> 14 <head> 15 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 16 <title>Error: PHP is not running</title> 17 </head> 18 <body class="wp-core-ui admin-color-modern"> 19 <h1>Error: PHP is not running</h1> 20 <p>WordPress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.</p> 21 </body> 22 </html> 23 <?php 24 } 25 26 /** 27 * We are installing WordPress. 28 * 29 * @since 1.5.1 30 */ 31 define( 'WP_INSTALLING', true ); 32 33 /** Load WordPress Bootstrap */ 34 require_once dirname( __DIR__ ) . '/wp-load.php'; 35 36 /** Load WordPress Administration Upgrade API */ 37 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 38 39 /** Load WordPress Translation Install API */ 40 require_once ABSPATH . 'wp-admin/includes/translation-install.php'; 41 42 /** Load wpdb */ 43 require_once ABSPATH . WPINC . '/class-wpdb.php'; 44 45 nocache_headers(); 46 47 $step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0; 48 49 /** 50 * Display installation header. 51 * 52 * @since 2.5.0 53 * 54 * @param string $body_classes Class attribute values for the body tag. 55 */ 56 function display_header( $body_classes = '' ) { 57 header( 'Content-Type: text/html; charset=utf-8' ); 58 if ( is_rtl() ) { 59 $body_classes .= 'rtl'; 60 } 61 if ( $body_classes ) { 62 $body_classes = ' ' . $body_classes; 63 } 64 ?> 65 <!DOCTYPE html> 66 <html <?php language_attributes(); ?>> 67 <head> 68 <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 69 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 70 <meta name="robots" content="noindex,nofollow" /> 71 <title><?php _e( 'WordPress › Installation' ); ?></title> 72 <?php wp_admin_css( 'install', true ); ?> 73 </head> 74 <body class="wp-core-ui admin-color-modern<?php echo $body_classes; ?>"> 75 <p id="logo"><?php _e( 'WordPress' ); ?></p> 76 77 <?php 78 } // End display_header(). 79 80 /** 81 * Displays installer setup form. 82 * 83 * @since 2.8.0 84 * 85 * @global wpdb $wpdb WordPress database abstraction object. 86 * 87 * @param string|null $error Error message to display, if any. 88 */ 89 function display_setup_form( $error = null ) { 90 global $wpdb; 91 92 $user_table = ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) ) ) !== null ); 93 94 // Ensure that sites appear in search engines by default. 95 $blog_public = 1; 96 if ( isset( $_POST['weblog_title'] ) ) { 97 $blog_public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : $blog_public; 98 } 99 100 $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; 101 $user_name = isset( $_POST['user_name'] ) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; 102 $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : ''; 103 104 if ( ! is_null( $error ) ) { 105 ?> 106 <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1> 107 <p class="message"><?php echo $error; ?></p> 108 <?php } ?> 109 <form id="setup" method="post" action="install.php?step=2" novalidate="novalidate"> 110 <table class="form-table" role="presentation"> 111 <tr> 112 <th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th> 113 <td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td> 114 </tr> 115 <tr> 116 <?php if ( $user_table ) : ?> 117 <th scope="row"><?php _e( 'Username' ); ?></th> 118 <td> 119 <?php _e( 'User(s) already exists.' ); ?> 120 <input name="user_name" type="hidden" value="admin" /> 121 </td> 122 <?php else : ?> 123 <th scope="row"><label for="user_login"><?php _e( 'Username' ); ?></label></th> 124 <td> 125 <input name="user_name" type="text" id="user_login" size="25" aria-describedby="user-name-desc" value="<?php echo esc_attr( sanitize_user( $user_name, true ) ); ?>" /> 126 <p id="user-name-desc"><?php _e( 'Usernames can have only alphanumeric characters, spaces, underscores, hyphens, periods, and the @ symbol.' ); ?></p> 127 </td> 128 <?php endif; ?> 129 </tr> 130 <?php if ( ! $user_table ) : ?> 131 <tr class="form-field form-required user-pass1-wrap"> 132 <th scope="row"> 133 <label for="pass1"> 134 <?php _e( 'Password' ); ?> 135 </label> 136 </th> 137 <td> 138 <div class="wp-pwd"> 139 <?php $initial_password = isset( $_POST['admin_password'] ) ? stripslashes( $_POST['admin_password'] ) : wp_generate_password( 18 ); ?> 140 <div class="password-input-wrapper"> 141 <input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="new-password" spellcheck="false" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result admin-password-desc" /> 142 <div id="pass-strength-result" aria-live="polite"></div> 143 </div> 144 <button type="button" class="button wp-hide-pw user-new-password-toggle hide-if-no-js" data-start-masked="<?php echo (int) isset( $_POST['admin_password'] ); ?>" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>"> 145 <span class="dashicons dashicons-hidden"></span> 146 <span class="text"><?php _e( 'Hide' ); ?></span> 147 </button> 148 </div> 149 <p id="admin-password-desc"><span class="description important"> 150 <strong><?php _e( 'Important:' ); ?></strong> 151 <?php /* translators: The non-breaking space prevents 1Password from thinking the text "log in" should trigger a password save prompt. */ ?> 152 <?php _e( 'You will need this password to log in. Please store it in a secure location.' ); ?></span></p> 153 </td> 154 </tr> 155 <tr class="form-field form-required user-pass2-wrap hide-if-js"> 156 <th scope="row"> 157 <label for="pass2"><?php _e( 'Repeat Password' ); ?></label> 158 </th> 159 <td> 160 <input type="password" name="admin_password2" id="pass2" autocomplete="new-password" spellcheck="false" aria-describedby="admin-repeat-password-desc" /> 161 <p id="admin-repeat-password-desc"> 162 <span class="description important hide-if-js"> 163 <?php _e( 'You can leave both password fields empty and one will be auto-generated for you.' ); ?> 164 </span> 165 </p> 166 </td> 167 </tr> 168 <tr class="pw-weak"> 169 <th scope="row"><?php _e( 'Confirm Password' ); ?></th> 170 <td> 171 <label> 172 <input type="checkbox" name="pw_weak" class="pw-checkbox" /> 173 <?php _e( 'Confirm use of weak password' ); ?> 174 </label> 175 </td> 176 </tr> 177 <?php endif; ?> 178 <tr> 179 <th scope="row"><label for="admin_email"><?php _e( 'Your Email' ); ?></label></th> 180 <td><input name="admin_email" type="email" id="admin_email" size="25" aria-describedby="admin-email-desc" value="<?php echo esc_attr( $admin_email ); ?>" /> 181 <p id="admin-email-desc"><?php _e( 'Double-check your email address before continuing.' ); ?></p></td> 182 </tr> 183 <?php 184 $has_action_blog_privacy_selector = has_action( 'blog_privacy_selector' ); 185 $blog_privacy_selector_title = $has_action_blog_privacy_selector ? __( 'Site visibility' ) : __( 'Search engine visibility' ); 186 $fieldset_aria_describedby = $has_action_blog_privacy_selector ? ' aria-describedby="options-site-visibility-description"' : ''; 187 ?> 188 <tr> 189 <th scope="row"><?php echo esc_html( $blog_privacy_selector_title ); ?></th> 190 <td> 191 <fieldset<?php echo $fieldset_aria_describedby; ?>> 192 <legend class="screen-reader-text"><?php echo esc_html( $blog_privacy_selector_title ); ?></legend> 193 <?php 194 if ( $has_action_blog_privacy_selector ) { 195 ?> 196 <input id="blog-public" type="radio" name="blog_public" value="1" <?php checked( 1, $blog_public ); ?> /> 197 <label for="blog-public"><?php _e( 'Allow search engines to index this site' ); ?></label><br /> 198 <input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked( 0, $blog_public ); ?> /> 199 <label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label> 200 <p id="options-site-visibility-description" class="description"><?php _e( 'Note: Discouraging search engines does not block access to your site — it is up to search engines to honor your request.' ); ?></p> 201 <?php 202 /** This action is documented in wp-admin/options-reading.php */ 203 do_action( 'blog_privacy_selector' ); 204 } else { 205 ?> 206 <input name="blog_public" type="checkbox" id="blog_public" aria-describedby="options-site-visibility-description" value="0" <?php checked( 0, $blog_public ); ?> /> 207 <label for="blog_public"><?php _e( 'Discourage search engines from indexing this site' ); ?></label> 208 <p id="options-site-visibility-description" class="description"><?php _e( 'It is up to search engines to honor this request.' ); ?></p> 209 <?php } ?> 210 </fieldset> 211 </td> 212 </tr> 213 </table> 214 <p class="step"><?php submit_button( __( 'Install WordPress' ), 'large', 'Submit', false, array( 'id' => 'submit' ) ); ?></p> 215 <input type="hidden" name="language" value="<?php echo isset( $_REQUEST['language'] ) ? esc_attr( $_REQUEST['language'] ) : ''; ?>" /> 216 </form> 217 <?php 218 } // End display_setup_form(). 219 220 // Let's check to make sure WP isn't already installed. 221 if ( is_blog_installed() ) { 222 display_header(); 223 die( 224 '<h1>' . __( 'Already Installed' ) . '</h1>' . 225 '<p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p>' . 226 '<p class="step"><a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log In' ) . '</a></p>' . 227 '</body></html>' 228 ); 229 } 230 231 /** 232 * @global string $wp_version The WordPress version string. 233 * @global string $required_php_version The minimum required PHP version string. 234 * @global string[] $required_php_extensions The names of required PHP extensions. 235 * @global string $required_mysql_version The minimum required MySQL version string. 236 * @global wpdb $wpdb WordPress database abstraction object. 237 */ 238 global $wp_version, $required_php_version, $required_php_extensions, $required_mysql_version, $wpdb; 239 240 $php_version = PHP_VERSION; 241 $mysql_version = $wpdb->db_version(); 242 $php_compat = version_compare( $php_version, $required_php_version, '>=' ); 243 $mysql_compat = version_compare( $mysql_version, $required_mysql_version, '>=' ) || file_exists( WP_CONTENT_DIR . '/db.php' ); 244 245 $version_url = sprintf( 246 /* translators: %s: WordPress version. */ 247 esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ), 248 sanitize_title( $wp_version ) 249 ); 250 251 $php_update_message = '</p><p>' . sprintf( 252 /* translators: %s: URL to Update PHP page. */ 253 __( '<a href="%s">Learn more about updating PHP</a>.' ), 254 esc_url( wp_get_update_php_url() ) 255 ); 256 257 $annotation = wp_get_update_php_annotation(); 258 259 if ( $annotation ) { 260 $php_update_message .= '</p><p><em>' . $annotation . '</em>'; 261 } 262 263 if ( ! $mysql_compat && ! $php_compat ) { 264 $compat = sprintf( 265 /* 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. */ 266 __( 'You cannot install 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.' ), 267 $version_url, 268 $wp_version, 269 $required_php_version, 270 $required_mysql_version, 271 $php_version, 272 $mysql_version 273 ) . $php_update_message; 274 } elseif ( ! $php_compat ) { 275 $compat = sprintf( 276 /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number. */ 277 __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), 278 $version_url, 279 $wp_version, 280 $required_php_version, 281 $php_version 282 ) . $php_update_message; 283 } elseif ( ! $mysql_compat ) { 284 $compat = sprintf( 285 /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number. */ 286 __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires MySQL version %3$s or higher. You are running version %4$s.' ), 287 $version_url, 288 $wp_version, 289 $required_mysql_version, 290 $mysql_version 291 ); 292 } 293 294 if ( ! $mysql_compat || ! $php_compat ) { 295 display_header(); 296 die( '<h1>' . __( 'Requirements Not Met' ) . '</h1><p>' . $compat . '</p></body></html>' ); 297 } 298 299 if ( isset( $required_php_extensions ) && is_array( $required_php_extensions ) ) { 300 $missing_extensions = array(); 301 302 foreach ( $required_php_extensions as $extension ) { 303 if ( extension_loaded( $extension ) ) { 304 continue; 305 } 306 307 $missing_extensions[] = sprintf( 308 /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: The PHP extension name needed. */ 309 __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires the %3$s PHP extension.' ), 310 $version_url, 311 $wp_version, 312 $extension 313 ); 314 } 315 316 if ( count( $missing_extensions ) > 0 ) { 317 display_header(); 318 die( '<h1>' . __( 'Requirements Not Met' ) . '</h1><p>' . implode( '</p><p>', $missing_extensions ) . '</p></body></html>' ); 319 } 320 } 321 322 if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) { 323 display_header(); 324 die( 325 '<h1>' . __( 'Configuration Error' ) . '</h1>' . 326 '<p>' . sprintf( 327 /* translators: %s: wp-config.php */ 328 __( 'Your %s file has an empty database table prefix, which is not supported.' ), 329 '<code>wp-config.php</code>' 330 ) . '</p></body></html>' 331 ); 332 } 333 334 // Set error message if DO_NOT_UPGRADE_GLOBAL_TABLES isn't set as it will break install. 335 if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { 336 display_header(); 337 die( 338 '<h1>' . __( 'Configuration Error' ) . '</h1>' . 339 '<p>' . sprintf( 340 /* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */ 341 __( 'The constant %s cannot be defined when installing WordPress.' ), 342 '<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>' 343 ) . '</p></body></html>' 344 ); 345 } 346 347 /** 348 * @global string $wp_local_package Locale code of the package. 349 * @global WP_Locale $wp_locale WordPress date and time locale object. 350 * @global wpdb $wpdb WordPress database abstraction object. 351 */ 352 $language = ''; 353 if ( ! empty( $_REQUEST['language'] ) ) { 354 $language = sanitize_locale_name( $_REQUEST['language'] ); 355 } elseif ( isset( $GLOBALS['wp_local_package'] ) ) { 356 $language = $GLOBALS['wp_local_package']; 357 } 358 359 $scripts_to_print = array( 'jquery' ); 360 361 switch ( $step ) { 362 case 0: // Step 0. 363 if ( wp_can_install_language_pack() && empty( $language ) ) { 364 $languages = wp_get_available_translations(); 365 if ( $languages ) { 366 $scripts_to_print[] = 'language-chooser'; 367 display_header( 'language-chooser' ); 368 echo '<form id="setup" method="post" action="?step=1">'; 369 wp_install_language_form( $languages ); 370 echo '</form>'; 371 break; 372 } 373 } 374 375 // Deliberately fall through if we can't reach the translations API. 376 377 case 1: // Step 1, direct link or from language chooser. 378 if ( ! empty( $language ) ) { 379 $loaded_language = wp_download_language_pack( $language ); 380 if ( $loaded_language ) { 381 load_default_textdomain( $loaded_language ); 382 $GLOBALS['wp_locale'] = new WP_Locale(); 383 } 384 } 385 386 $scripts_to_print[] = 'user-profile'; 387 388 display_header(); 389 ?> 390 <h1><?php _ex( 'Welcome', 'Howdy' ); ?></h1> 391 <p><?php _e( 'Welcome to the famous five-minute WordPress installation process! Just fill in the information below and you’ll be on your way to using the most extendable and powerful personal publishing platform in the world.' ); ?></p> 392 393 <h2><?php _e( 'Information needed' ); ?></h2> 394 <p><?php _e( 'Please provide the following information. Do not worry, you can always change these settings later.' ); ?></p> 395 396 <?php 397 display_setup_form(); 398 break; 399 case 2: 400 if ( ! empty( $language ) && load_default_textdomain( $language ) ) { 401 $loaded_language = $language; 402 $GLOBALS['wp_locale'] = new WP_Locale(); 403 } else { 404 $loaded_language = 'en_US'; 405 } 406 407 if ( ! empty( $wpdb->error ) ) { 408 wp_die( $wpdb->error->get_error_message() ); 409 } 410 411 $scripts_to_print[] = 'user-profile'; 412 413 display_header(); 414 // Fill in the data we gathered. 415 $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; 416 $user_name = isset( $_POST['user_name'] ) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; 417 $admin_password = isset( $_POST['admin_password'] ) ? wp_unslash( $_POST['admin_password'] ) : ''; 418 $admin_password_check = isset( $_POST['admin_password2'] ) ? wp_unslash( $_POST['admin_password2'] ) : ''; 419 $admin_email = isset( $_POST['admin_email'] ) ? trim( wp_unslash( $_POST['admin_email'] ) ) : ''; 420 $public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 1; 421 422 // Check email address. 423 $error = false; 424 if ( empty( $user_name ) ) { 425 // TODO: Poka-yoke. 426 display_setup_form( __( 'Please provide a valid username.' ) ); 427 $error = true; 428 } elseif ( sanitize_user( $user_name, true ) !== $user_name ) { 429 display_setup_form( __( 'The username you provided has invalid characters.' ) ); 430 $error = true; 431 } elseif ( $admin_password !== $admin_password_check ) { 432 // TODO: Poka-yoke. 433 display_setup_form( __( 'Your passwords do not match. Please try again.' ) ); 434 $error = true; 435 } elseif ( empty( $admin_email ) ) { 436 // TODO: Poka-yoke. 437 display_setup_form( __( 'You must provide an email address.' ) ); 438 $error = true; 439 } elseif ( ! is_email( $admin_email ) ) { 440 // TODO: Poka-yoke. 441 display_setup_form( __( 'Sorry, that is not a valid email address. Email addresses look like <code>username@example.com</code>.' ) ); 442 $error = true; 443 } 444 445 if ( false === $error ) { 446 $wpdb->show_errors(); 447 $result = wp_install( $weblog_title, $user_name, $admin_email, $public, '', wp_slash( $admin_password ), $loaded_language ); 448 ?> 449 450 <h1><?php _e( 'Success!' ); ?></h1> 451 452 <p><?php _e( 'WordPress has been installed. Thank you, and enjoy!' ); ?></p> 453 454 <table class="form-table install-success"> 455 <tr> 456 <th><?php _e( 'Username' ); ?></th> 457 <td><?php echo esc_html( sanitize_user( $user_name, true ) ); ?></td> 458 </tr> 459 <tr> 460 <th><?php _e( 'Password' ); ?></th> 461 <td> 462 <?php if ( ! empty( $result['password'] ) && empty( $admin_password_check ) ) : ?> 463 <code><?php echo esc_html( $result['password'] ); ?></code><br /> 464 <?php endif; ?> 465 <p><?php echo $result['password_message']; ?></p> 466 </td> 467 </tr> 468 </table> 469 470 <p class="step"><a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log In' ); ?></a></p> 471 472 <?php 473 } 474 break; 475 } 476 477 if ( ! wp_is_mobile() ) { 478 wp_print_inline_script_tag( 479 <<<'JS' 480 const t = document.getElementById( 'weblog_title' ); 481 if ( t ) { 482 t.focus(); 483 } 484 JS 485 ); 486 } 487 488 wp_print_scripts( $scripts_to_print ); 489 490 wp_print_inline_script_tag( 491 <<<'JS' 492 /** 493 * Shows the content intended only for browsers with JS enabled. 494 * 495 * @param {JQueryStatic} $ The jQuery object. 496 */ 497 jQuery( function ( $ ) { 498 $( '.hide-if-no-js' ).removeClass( 'hide-if-no-js' ); 499 } ); 500 JS 501 ); 502 ?> 503 </body> 504 </html>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Fri Dec 4 08:20:01 2026 | Cross-referenced by PHPXref |