diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php index 0a025761af..68d3ee53d4 100644 --- a/wp-admin/setup-config.php +++ b/wp-admin/setup-config.php @@ -41,31 +41,31 @@ define('WP_CONTENT_DIR', ABSPATH . 'wp-content'); define('WP_DEBUG', false); /**#@-*/ -require_once(ABSPATH . WPINC . '/load.php'); -require_once(ABSPATH . WPINC . '/version.php'); +require(ABSPATH . WPINC . '/load.php'); +require(ABSPATH . WPINC . '/version.php'); + +// Also loads functions.php, plugin.php, l10n.php, pomo/mo.php (all required by setup-config.php) +wp_load_translations_early(); + wp_check_php_mysql_versions(); require_once(ABSPATH . WPINC . '/compat.php'); -require_once(ABSPATH . WPINC . '/functions.php'); require_once(ABSPATH . WPINC . '/class-wp-error.php'); -if (!file_exists(ABSPATH . 'wp-config-sample.php')) - wp_die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.'); +if ( ! file_exists( ABSPATH . 'wp-config-sample.php' ) ) + wp_die( __( 'Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.' ) ); $config_file = file(ABSPATH . 'wp-config-sample.php'); // Check if wp-config.php has been created -if (file_exists(ABSPATH . 'wp-config.php')) - wp_die("
The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now.
"); +if ( file_exists( ABSPATH . 'wp-config.php' ) ) + wp_die( '' . sprintf( __( "The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now." ), 'install.php' ) . '
' ); // Check if wp-config.php exists above the root directory but is not part of another install -if (file_exists(ABSPATH . '../wp-config.php') && ! file_exists(ABSPATH . '../wp-settings.php')) - wp_die("The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now.
"); +if ( file_exists(ABSPATH . '../wp-config.php' ) && ! file_exists( ABSPATH . '../wp-settings.php' ) ) + wp_die( '' . sprintf( __( "The file 'wp-config.php' already exists one level above your WordPress installation. If you need to reset any of the configuration items in this file, please delete it first. You may try installing now."), 'install.php' ) . '
' ); -if (isset($_GET['step'])) - $step = $_GET['step']; -else - $step = 0; +$step = isset( $_GET['step'] ) ? (int) $_GET['step'] : 0; /** * Display setup wp-config.php file header. @@ -82,7 +82,7 @@ function display_header() { -Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.
+If for any reason this automatic file creation doesn't work, don't worry. All this does is fill in the database information to a configuration file. You may also simply open wp-config-sample.php
in a text editor, fill in your information, and save it as wp-config.php
.
In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…
+wp-config-sample.php in a text editor, fill in your information, and save it as wp-config.php
.
In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…" ); ?>
- + ERROR: "Table Prefix" can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/ ); + wp_die( __( 'ERROR: "Table Prefix" can only contain numbers, letters, and underscores.' ) ); // Test the db connection. /**#@+ @@ -175,15 +175,12 @@ switch($step) { // We'll fail here if the values are no good. require_wp_db(); if ( ! empty( $wpdb->error ) ) { - $back = ''; + $back = ''; wp_die( $wpdb->error->get_error_message() . $back ); } // Fetch or generate keys and salts. $no_api = isset( $_POST['noapi'] ); - require_once( ABSPATH . WPINC . '/plugin.php' ); - require_once( ABSPATH . WPINC . '/l10n.php' ); - require_once( ABSPATH . WPINC . '/pomo/translations.php' ); if ( ! $no_api ) { require_once( ABSPATH . WPINC . '/class-http.php' ); require_once( ABSPATH . WPINC . '/http.php' ); @@ -248,15 +245,15 @@ switch($step) { if ( ! is_writable(ABSPATH) ) : display_header(); ?> -Sorry, but I can't write the wp-config.php
file.
You can create the wp-config.php
manually and paste the following text into it.
wp-config.php file." ); ?>
+wp-config.php manually and paste the following text into it.' ); ?>
-After you've done that, click "Run the install."
- + + -All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to…
+ - + error = sprintf( /*WP_I18N_NO_TABLES*/'One or more database tables are unavailable. The database may need to be repaired.'/*/WP_I18N_NO_TABLES*/, 'maint/repair.php?referrer=is_blog_installed' ); + $wpdb->error = sprintf( __( 'One or more database tables are unavailable. The database may need to be repaired.' ), 'maint/repair.php?referrer=is_blog_installed' ); dead_db(); } @@ -2647,16 +2649,18 @@ function dead_db() { status_header( 500 ); nocache_headers(); header( 'Content-Type: text/html; charset=utf-8' ); + + wp_load_translations_early(); ?> > -$table_prefix
in wp-config.php
can only contain numbers, letters, and underscores.'/*/WP_I18N_BAD_PREFIX*/ );
+ if ( is_wp_error( $prefix ) ) {
+ wp_load_translations_early();
+ wp_die( __( 'ERROR: $table_prefix
in wp-config.php
can only contain numbers, letters, and underscores.' ) );
+ }
}
/**
@@ -649,3 +652,87 @@ function is_multisite() {
return false;
}
+
+/**
+ * Attempts an early load of translations.
+ *
+ * Used for errors encountered during the initial loading process, before the locale has been
+ * properly detected and loaded.
+ *
+ * Designed for unusual load sequences (like setup-config.php) or for when the script will then
+ * terminate with an error, otherwise there is a risk that a file can be double-included.
+ *
+ * @since 3.4.0
+ * @access private
+ */
+function wp_load_translations_early() {
+ global $text_direction, $wp_locale;
+
+ static $loaded = false;
+ if ( $loaded )
+ return;
+ $loaded = true;
+
+ if ( function_exists( 'did_action' ) && did_action( 'init' ) )
+ return;
+
+ // We need $wp_local_package
+ require ABSPATH . WPINC . '/version.php';
+
+ // Translation and localization
+ require_once ABSPATH . WPINC . '/pomo/mo.php';
+ require_once ABSPATH . WPINC . '/l10n.php';
+ require_once ABSPATH . WPINC . '/locale.php';
+
+ // General libraries
+ require_once ABSPATH . WPINC . '/functions.php';
+ require_once ABSPATH . WPINC . '/plugin.php';
+
+ $locales = $locations = array();
+
+ while ( true ) {
+ if ( defined( 'WPLANG' ) ) {
+ if ( '' == WPLANG )
+ break;
+ $locales[] = WPLANG;
+ }
+
+ if ( isset( $wp_local_package ) )
+ $locales[] = $wp_local_package;
+
+ if ( ! $locales )
+ break;
+
+ if ( defined( 'WP_LANG_DIR' ) && @is_dir( WP_LANG_DIR ) )
+ $locations[] = WP_LANG_DIR;
+
+ if ( defined( 'WP_CONTENT_DIR' ) && @is_dir( WP_CONTENT_DIR . '/languages' ) )
+ $locations[] = WP_CONTENT_DIR . '/languages';
+
+ if ( @is_dir( ABSPATH . 'wp-content/languages' ) )
+ $locations[] = ABSPATH . 'wp-content/languages';
+
+ if ( @is_dir( ABSPATH . WPINC . '/languages' ) )
+ $locations[] = ABSPATH . WPINC . '/languages';
+
+ if ( ! $locations )
+ break;
+
+ $locations = array_unique( $locations );
+
+ foreach ( $locales as $locale ) {
+ foreach ( $locations as $location ) {
+ if ( file_exists( $location . '/' . $locale . '.mo' ) ) {
+ load_textdomain( 'default', $location . '/' . $locale . '.mo' );
+ if ( WP_Locale::is_locale_rtl( $locale ) )
+ $text_direction = 'rtl';
+ break 2;
+ }
+ }
+ }
+
+ break;
+ }
+
+ $wp_locale = new WP_Locale();
+}
diff --git a/wp-includes/locale.php b/wp-includes/locale.php
index b34129238b..647888d7dd 100644
--- a/wp-includes/locale.php
+++ b/wp-includes/locale.php
@@ -87,7 +87,7 @@ class WP_Locale {
/**
* Locales which are known to be right-to-left.
*/
- private $rtl_locales = array( 'ar', 'ckb', 'fa_IR', 'he_IL', 'ug_CN', 'dv', 'fa_AF', 'ha', 'ps', 'uz_UZ', 'yi' );
+ private static $rtl_locales = array( 'ar', 'ckb', 'fa_IR', 'he_IL', 'ug_CN', 'dv', 'fa_AF', 'ha', 'ps', 'uz_UZ', 'yi' );
/**
* Sets up the translated strings and object properties.
@@ -183,7 +183,7 @@ class WP_Locale {
$this->number_format['decimal_point'] = ('number_format_decimal_point' == $trans) ? '.' : $trans;
// Locale-specific tweaks
- if ( in_array( get_locale(), $this->rtl_locales ) )
+ if ( self::is_locale_rtl( get_locale() ) )
$this->text_direction = 'rtl';
// Import the $text_direction global.
@@ -333,6 +333,9 @@ class WP_Locale {
return 'rtl' == $this->text_direction;
}
+ public static function is_locale_rtl( $locale ) {
+ return in_array( $locale, self::$rtl_locales );
+ }
}
/**
diff --git a/wp-includes/ms-load.php b/wp-includes/ms-load.php
index c55832ff43..58826e7804 100644
--- a/wp-includes/ms-load.php
+++ b/wp-includes/ms-load.php
@@ -211,10 +211,12 @@ function wpmu_current_site() {
}
// Still no dice.
+ wp_load_translations_early();
+
if ( 1 == count( $sites ) )
- wp_die( sprintf( /*WP_I18N_BLOG_DOESNT_EXIST*/'That site does not exist. Please try %s.'/*/WP_I18N_BLOG_DOESNT_EXIST*/, $sites[0]->domain . $sites[0]->path ) );
+ wp_die( sprintf( __( 'That site does not exist. Please try %s.' ), 'http://' . $sites[0]->domain . $sites[0]->path ) );
else
- wp_die( /*WP_I18N_NO_SITE_DEFINED*/'No site defined on this host. If you are the owner of this site, please check Debugging a WordPress Network for help.'/*/WP_I18N_NO_SITE_DEFINED*/ );
+ wp_die( __( 'No site defined on this host. If you are the owner of this site, please check Debugging a WordPress Network for help.' ) );
}
/**
@@ -228,19 +230,21 @@ function wpmu_current_site() {
function ms_not_installed() {
global $wpdb, $domain, $path;
- $title = /*WP_I18N_FATAL_ERROR*/'Error establishing database connection'/*/WP_I18N_FATAL_ERROR*/;
+ wp_load_translations_early();
+
+ $title = __( 'Error establishing database connection' );
$msg = '' . /*WP_I18N_CONTACT_OWNER*/'If your site does not display, please contact the owner of this network.'/*/WP_I18N_CONTACT_OWNER*/ . ''; - $msg .= ' ' . /*WP_I18N_CHECK_MYSQL*/'If you are the owner of this network please check that MySQL is running properly and all tables are error free.'/*/WP_I18N_CHECK_MYSQL*/ . '
'; + $msg .= '' . __( 'If your site does not display, please contact the owner of this network.' ) . ''; + $msg .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '
'; if ( false && !$wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) ) - $msg .= '' . sprintf( /*WP_I18N_TABLES_MISSING_LONG*/'Database tables are missing. This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s
. You really should look at your database now.'/*/WP_I18N_TABLES_MISSING_LONG*/, $wpdb->site ) . '
' . sprintf( __( 'Database tables are missing. This means that MySQL is not running, WordPress was not installed properly, or someone deleted %s
. You really should look at your database now.' ), $wpdb->site ) . '
' . sprintf( /*WP_I18N_NO_SITE_FOUND*/'Could not find site %1$s
. Searched for table %2$s
in database %3$s
. Is that right?'/*/WP_I18N_NO_SITE_FOUND*/, rtrim( $domain . $path, '/' ), $wpdb->blogs, DB_NAME ) . '
' . /*WP_I18N_WHAT_DO_I_DO*/'What do I do now?'/*/WP_I18N_WHAT_DO_I_DO*/ . ' '; - $msg .= /*WP_I18N_RTFM*/'Read the bug report page. Some of the guidelines there may help you figure out what went wrong.'/*/WP_I18N_RTFM*/; - $msg .= ' ' . /*WP_I18N_STUCK*/'If you’re still stuck with this message, then check that your database contains the following tables:'/*/WP_I18N_STUCK*/ . '
' . sprintf( __( 'Could not find site %1$s
. Searched for table %2$s
in database %3$s
. Is that right?' ), rtrim( $domain . $path, '/' ), $wpdb->blogs, DB_NAME ) . '
' . __( 'What do I do now?' ) . ' '; + $msg .= __( 'Read the bug report page. Some of the guidelines there may help you figure out what went wrong.' ); + $msg .= ' ' . __( 'If you’re still stuck with this message, then check that your database contains the following tables:' ) . '
We were able to connect to the database server (which means your username and password is okay) but not able to select the %1$s
database.
%2$s
have permission to use the %1$s
database?username_%1$s
. Could that be the problem?If you don\'t know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.
'/*/WP_I18N_DB_SELECT_DB*/, $db, $this->dbuser ), 'db_select_fail' ); +If you don\'t know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.
' ), $db, $this->dbuser ), 'db_select_fail' ); return; } } @@ -923,10 +924,12 @@ class wpdb { if ( $this->suppress_errors ) return false; + wp_load_translations_early(); + if ( $caller = $this->get_caller() ) - $error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR_FULL*/'WordPress database error %1$s for query %2$s made by %3$s'/*/WP_I18N_DB_QUERY_ERROR_FULL*/, $str, $this->last_query, $caller ); + $error_str = sprintf( __( 'WordPress database error %1$s for query %2$s made by %3$s' ), $str, $this->last_query, $caller ); else - $error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR*/'WordPress database error %1$s for query %2$s'/*/WP_I18N_DB_QUERY_ERROR*/, $str, $this->last_query ); + $error_str = sprintf( __( 'WordPress database error %1$s for query %2$s' ), $str, $this->last_query ); if ( function_exists( 'error_log' ) && ( $log_file = @ini_get( 'error_log' ) ) @@ -1037,7 +1040,8 @@ class wpdb { } if ( !$this->dbh ) { - $this->bail( sprintf( /*WP_I18N_DB_CONN_ERROR*/" + wp_load_translations_early(); + $this->bail( sprintf( __( "This either means that the username and password information in your wp-config.php
file is incorrect or we can't contact the database server at %s
. This could mean your host's database server is down.
If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.
-"/*/WP_I18N_DB_CONN_ERROR*/, $this->dbhost ), 'db_connect_fail' ); +" ), $this->dbhost ), 'db_connect_fail' ); return; } @@ -1073,8 +1077,7 @@ class wpdb { return false; // some queries are made before the plugins have been loaded, and thus cannot be filtered with this method - if ( function_exists( 'apply_filters' ) ) - $query = apply_filters( 'query', $query ); + $query = apply_filters( 'query', $query ); $return_val = 0; $this->flush(); @@ -1326,7 +1329,7 @@ class wpdb { } elseif ( $output == ARRAY_N ) { return $this->last_result[$y] ? array_values( get_object_vars( $this->last_result[$y] ) ) : null; } else { - $this->print_error(/*WP_I18N_DB_GETROW_ERROR*/" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"/*/WP_I18N_DB_GETROW_ERROR*/); + $this->print_error( " \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N" ); } } diff --git a/wp-load.php b/wp-load.php index 5878310afd..f8113e8ce1 100644 --- a/wp-load.php +++ b/wp-load.php @@ -39,21 +39,23 @@ if ( file_exists( ABSPATH . 'wp-config.php') ) { // Set a path for the link to the installer if ( strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false ) - $path = ''; + $path = 'setup-config.php'; else - $path = 'wp-admin/'; + $path = 'wp-admin/setup-config.php'; - require_once( ABSPATH . '/wp-includes/load.php' ); - require_once( ABSPATH . '/wp-includes/version.php' ); - define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); define( 'WPINC', 'wp-includes' ); + define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); + require_once( ABSPATH . WPINC . '/load.php' ); + require_once( ABSPATH . WPINC . '/version.php' ); + + wp_load_translations_early(); wp_check_php_mysql_versions(); // Die with an error message - require_once( ABSPATH . '/wp-includes/class-wp-error.php' ); - require_once( ABSPATH . '/wp-includes/functions.php' ); - require_once( ABSPATH . '/wp-includes/plugin.php' ); - $text_direction = /*WP_I18N_TEXT_DIRECTION*/'ltr'/*/WP_I18N_TEXT_DIRECTION*/; - wp_die(sprintf(/*WP_I18N_NO_CONFIG*/"There doesn't seem to be a wp-config.php
file. I need this before we can get started.
Need more help? We got it.
You can create a wp-config.php
file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file.
' . __( "There doesn't seem to be a wp-config.php
file. I need this before we can get started." ) . '
' . __( "Need more help? We got it." ) . '
'; + $die .= '' . __( "You can create a wp-config.php
file through a web interface, but this doesn't work for all server setups. The safest way is to manually create the file." ) . '