Ticket #15677: 15677.15.patch
File 15677.15.patch, 29.9 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/translation-install.php
1 <?php 2 /** 3 * WordPress Translation Install Administration API 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 10 /** 11 * Retrieve translations from WordPress Translation API. 12 * 13 * @since 4.0.0 14 * 15 * @param string $type Type of translations. Accepts 'plugins', 'themes', 'core'. 16 * @param array|object $args Translation API arguments. Optional. 17 * @return object|WP_Error On success an object of translations, WP_Error on failure. 18 */ 19 function translations_api( $type, $args = null ) { 20 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 21 22 if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ) ) ) { 23 return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) ); 24 } 25 26 /** 27 * Allows a plugin to override the WordPress.org Translation Install API entirely. 28 * 29 * @since 4.0.0 30 * 31 * @param bool|array $result The result object. Default false. 32 * @param string $type The type of translations being requested. 33 * @param object $args Translation API arguments. 34 */ 35 $res = apply_filters( 'translations_api', false, $type, $args ); 36 37 if ( false === $res ) { 38 $url = $http_url = 'http://api.wordpress.org/translations/' . $type . '/1.0/'; 39 if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { 40 $url = set_url_scheme( $url, 'https' ); 41 } 42 43 $options = array( 44 'timeout' => 3, 45 'body' => array( 46 'wp_version' => $wp_version, 47 'locale' => get_locale(), 48 'version' => $args['version'], // Version of plugin, theme or core 49 ), 50 ); 51 52 if ( 'core' !== $type ) { 53 $options['body']['slug'] = $args['slug']; // Plugin or theme slug 54 } 55 56 $request = wp_remote_post( $url, $options ); 57 58 if ( $ssl && is_wp_error( $request ) ) { 59 trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); 60 61 $request = wp_remote_post( $http_url, $options ); 62 } 63 64 if ( is_wp_error( $request ) ) { 65 $res = new WP_Error( 'translations_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() ); 66 } else { 67 $res = json_decode( wp_remote_retrieve_body( $request ), true ); 68 if ( ! is_object( $res ) && ! is_array( $res ) ) { 69 $res = new WP_Error( 'translations_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); 70 } 71 } 72 } 73 74 /** 75 * Filter the Translation Install API response results. 76 * 77 * @since 4.0.0 78 * 79 * @param object|WP_Error $res Response object or WP_Error. 80 * @param string $type The type of translations being requested. 81 * @param object $args Translation API arguments. 82 */ 83 return apply_filters( 'translations_api_result', $res, $type, $args ); 84 } 85 86 /** 87 * Get available translations from the WordPress.org API. 88 * 89 * @since 4.0.0 90 * 91 * @see translations_api() 92 * 93 * @return array Array of translations, each an array of data. If the API response results 94 * in an error, an empty array will be returned. 95 */ 96 function wp_get_available_translations() { 97 if ( ! defined( 'WP_INSTALLING' ) && false !== ( $translations = get_site_transient( 'available_translations' ) ) ) { 98 return $translations; 99 } 100 101 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 102 103 $api = translations_api( 'core', array( 'version' => $wp_version ) ); 104 105 if ( is_wp_error( $api ) || empty( $api['translations'] ) ) { 106 return array(); 107 } 108 109 $translations = array(); 110 // Key the array with the language code for now. 111 foreach ( $api['translations'] as $translation ) { 112 $translations[ $translation['language'] ] = $translation; 113 } 114 115 if ( ! defined( 'WP_INSTALLING' ) ) { 116 set_site_transient( 'available_translations', $translations, 3 * HOUR_IN_SECONDS ); 117 } 118 119 return $translations; 120 } 121 122 /** 123 * Output the select form for the language selection on the installation screen. 124 * 125 * @since 4.0.0 126 * 127 * @param array $languages Array of available languages (populated via the Translation API). 128 */ 129 function wp_install_language_form( $languages ) { 130 $installed_languages = get_available_languages(); 131 132 echo "<label class='screen-reader-text' for='language'>Select a default language</label>\n"; 133 echo "<select size='14' name='language' id='language'>\n"; 134 echo '<option value="" lang="en" selected="selected" data-continue="Continue" data-installed="1">English (United States)</option>'; 135 echo "\n"; 136 137 if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && ( 'en_US' !== WPLANG ) ) { 138 if ( isset( $languages[ WPLANG ] ) ) { 139 $language = $languages[ WPLANG ]; 140 echo '<option value="' . esc_attr( $language['language'] ) . '" lang="' . esc_attr( $language['iso'][1] ) . '">' . esc_html( $language['native_name'] ) . "</option>\n"; 141 unset( $languages[ WPLANG ] ); 142 } 143 } 144 145 foreach ( $languages as $language ) { 146 printf( '<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n", 147 esc_attr( $language['language'] ), 148 esc_attr( $language['iso'][1] ), 149 esc_attr( $language['strings']['continue'] ), 150 in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '', 151 esc_html( $language['native_name'] ) ); 152 } 153 echo "</select>\n"; 154 echo '<p class="step"><span class="spinner"></span><input id="language-continue" type="submit" class="button button-primary button-large" value="Continue" /></p>'; 155 } 156 157 /** 158 * Download a language pack. 159 * 160 * @since 4.0.0 161 * 162 * @see wp_get_available_translations() 163 * 164 * @param string $download Language code to download. 165 * @return string|bool Returns the language code if successfully downloaded 166 * (or already installed), or false on failure. 167 */ 168 function wp_download_language_pack( $download ) { 169 // Check if the translation is already installed. 170 if ( in_array( $download, get_available_languages() ) ) { 171 return $download; 172 } 173 174 if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) { 175 return false; 176 } 177 178 // Confirm the translation is one we can download. 179 $translations = wp_get_available_translations(); 180 if ( ! $translations ) { 181 return false; 182 } 183 foreach ( $translations as $translation ) { 184 if ( $translation['language'] === $download ) { 185 $translation_to_load = true; 186 break; 187 } 188 } 189 190 if ( empty( $translation_to_load ) ) { 191 return false; 192 } 193 $translation = (object) $translation; 194 195 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 196 $skin = new Automatic_Upgrader_Skin; 197 $upgrader = new Language_Pack_Upgrader( $skin ); 198 $translation->type = 'core'; 199 /** 200 * @todo failures (such as non-direct FS) 201 */ 202 $result = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) ); 203 return $translation->language; 204 } -
src/wp-admin/includes/upgrade.php
437 437 if ( $wp_current_db_version < 26691 ) 438 438 upgrade_380(); 439 439 440 if ( $wp_current_db_version < 29600 ) 441 upgrade_400(); 442 440 443 maybe_disable_link_manager(); 441 444 442 445 maybe_disable_automattic_widgets(); … … 1304 1307 deactivate_plugins( array( 'mp6/mp6.php' ), true ); 1305 1308 } 1306 1309 } 1310 1307 1311 /** 1312 * Execute changes made in WordPress 4.0.0. 1313 * 1314 * @since 4.0.0 1315 */ 1316 function upgrade_400() { 1317 global $wp_current_db_version; 1318 if ( $wp_current_db_version < 29600 ) { 1319 if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) { 1320 if ( 1321 defined( 'WPLANG' ) && ( '' !== WPLANG ) && ( 'en_US' !== WPLANG ) && 1322 in_array( WPLANG, get_available_languages() ) ) 1323 { 1324 update_option( 'WPLANG', WPLANG ); 1325 } else { 1326 update_option( 'WPLANG', '' ); 1327 } 1328 } 1329 } 1330 } 1331 1332 /** 1308 1333 * Execute network level changes 1309 1334 * 1310 1335 * @since 3.0.0 … … 1419 1444 */ 1420 1445 function maybe_create_table($table_name, $create_ddl) { 1421 1446 global $wpdb; 1422 1447 1423 1448 $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $table_name ) ); 1424 1449 1425 1450 if ( $wpdb->get_var( $query ) == $table_name ) { … … 2192 2217 dbDelta( $ms_queries ); 2193 2218 } 2194 2219 endif; 2195 2196 /**2197 * Output the input fields for the language selection form on the installation screen.2198 *2199 * @since 4.0.02200 *2201 * @see wp_get_available_translations_from_api()2202 *2203 * @param array $languages Array of available languages (populated via the Translations API).2204 */2205 function wp_install_language_form( $languages ) {2206 $installed_languages = get_available_languages();2207 2208 echo "<label class='screen-reader-text' for='language'>Select a default language</label>\n";2209 echo "<select size='14' name='language' id='language'>\n";2210 echo '<option value="" lang="en" selected="selected" data-continue="Continue" data-installed="1">English (United States)</option>';2211 echo "\n";2212 2213 if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && ( 'en_US' !== WPLANG ) ) {2214 if ( isset( $languages[ WPLANG ] ) ) {2215 $language = $languages[ WPLANG ];2216 echo '<option value="' . esc_attr( $language['language'] ) . '" lang="' . esc_attr( $language['iso'][1] ) . '">' . esc_html( $language['native_name'] ) . "</option>\n";2217 }2218 }2219 2220 foreach ( $languages as $language ) {2221 printf( '<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",2222 esc_attr( $language['language'] ),2223 esc_attr( $language['iso'][1] ),2224 esc_attr( $language['strings']['continue'] ),2225 in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '',2226 esc_html( $language['native_name'] ) );2227 }2228 echo "</select>\n";2229 echo '<p class="step"><span class="spinner"></span><input id="language-continue" type="submit" class="button button-primary button-large" value="Continue" /></p>';2230 }2231 2232 /**2233 * Get available translations from the WordPress.org API.2234 *2235 * @since 4.0.02236 *2237 * @see wp_remote_post()2238 *2239 * @return array Array of translations, each an array of data.2240 */2241 function wp_get_available_translations_from_api() {2242 $url = 'http://api.wordpress.org/translations/core/1.0/';2243 if ( wp_http_supports( array( 'ssl' ) ) ) {2244 $url = set_url_scheme( $url, 'https' );2245 }2246 2247 $options = array(2248 'timeout' => 3,2249 'body' => array( 'version' => $GLOBALS['wp_version'] ),2250 );2251 2252 $response = wp_remote_post( $url, $options );2253 $body = wp_remote_retrieve_body( $response );2254 if ( $body && $body = json_decode( $body, true ) ) {2255 $translations = array();2256 // Key the array with the language code for now2257 foreach ( $body['translations'] as $translation ) {2258 $translations[ $translation['language'] ] = $translation;2259 }2260 return $translations;2261 }2262 return false;2263 }2264 2265 /**2266 * Download a language pack.2267 *2268 * @since 4.0.02269 *2270 * @see wp_get_available_translations_from_api()2271 *2272 * @param string $download Language code to download.2273 * @return string|bool Returns the language code if successfully downloaded2274 * (or already installed), or false on failure.2275 */2276 function wp_install_download_language_pack( $download ) {2277 // Check if the translation is already installed.2278 if ( in_array( $download, get_available_languages() ) ) {2279 return $download;2280 }2281 2282 // Confirm the translation is one we can download.2283 $translations = wp_get_available_translations_from_api();2284 if ( ! $translations ) {2285 return false;2286 }2287 foreach ( $translations as $translation ) {2288 if ( $translation['language'] === $download ) {2289 $translation_to_load = true;2290 break;2291 }2292 }2293 2294 if ( empty( $translation_to_load ) ) {2295 return false;2296 }2297 $translation = (object) $translation;2298 2299 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';2300 $skin = new Automatic_Upgrader_Skin;2301 $upgrader = new Language_Pack_Upgrader( $skin );2302 $translation->type = 'core';2303 /**2304 * @todo failures (such as non-direct FS)2305 */2306 $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );2307 return $translation->language;2308 }2309 2310 /**2311 * Load a translation during the install process.2312 *2313 * @since 4.0.02314 *2315 * @see load_textdomain()2316 *2317 * @param string $translation Translation to load.2318 * @return string|bool Returns the language code if successfully loaded,2319 * or false on failure.2320 */2321 function wp_install_load_language( $translation ) {2322 if ( ! empty( $translation ) ) {2323 if ( in_array( $translation, get_available_languages() ) ) {2324 $translation_to_load = $translation;2325 }2326 }2327 2328 if ( empty( $translation_to_load ) ) {2329 return false;2330 }2331 2332 unload_textdomain( 'default' ); // Start over.2333 load_textdomain( 'default', WP_LANG_DIR . "/{$translation_to_load}.mo" );2334 load_textdomain( 'default', WP_LANG_DIR . "/admin-{$translation_to_load}.mo" );2335 return $translation_to_load;2336 } -
src/wp-admin/install.php
23 23 </html> 24 24 <?php 25 25 } 26 26 error_reporting(-1); 27 27 /** 28 28 * We are installing WordPress. 29 29 * … … 38 38 /** Load WordPress Administration Upgrade API */ 39 39 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 40 40 41 /** Load WordPress Translation Install API */ 42 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); 43 41 44 /** Load wpdb */ 42 45 require_once( ABSPATH . WPINC . '/wp-db.php' ); 43 46 … … 178 181 die( '<h1>' . __( 'Configuration Error' ) . '</h1><p>' . __( 'Your <code>wp-config.php</code> file has an empty database table prefix, which is not supported.' ) . '</p></body></html>' ); 179 182 } 180 183 184 $langugage = ''; 185 if ( ! empty( $_REQUEST['language'] ) ) { 186 $langugage = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] ); 187 } 188 181 189 switch($step) { 182 190 case 0: // Step 0 183 191 184 if ( empty( $ _GET['language'] ) && ( $languages = wp_get_available_translations_from_api() ) ) {192 if ( empty( $langugage ) && ( $languages = wp_get_available_translations() ) ) { 185 193 display_header( 'language-chooser' ); 186 194 echo '<form id="setup" method="post" action="?step=1">'; 187 195 wp_install_language_form( $languages ); … … 192 200 // Deliberately fall through if we can't reach the translations API. 193 201 194 202 case 1: // Step 1, direct link or from language chooser. 195 if ( ! empty( $ _REQUEST['language']) ) {196 $loaded_language = wp_ install_download_language_pack( $_REQUEST['language']);203 if ( ! empty( $langugage ) ) { 204 $loaded_language = wp_download_language_pack( $langugage ); 197 205 if ( $loaded_language ) { 198 wp_install_load_language( $loaded_language );206 load_default_textdomain( $loaded_language ); 199 207 } 200 208 } 201 209 … … 211 219 display_setup_form(); 212 220 break; 213 221 case 2: 214 if ( ! empty( $_REQUEST['language']) ) {215 $loaded_language = wp_install_load_language( $_REQUEST['language'] );222 if ( ! empty( $langugage ) && load_default_textdomain( $langugage ) ) { 223 $loaded_language = $langugage; 216 224 } else { 217 225 $loaded_language = 'en_US'; 218 226 } … … 226 234 $user_name = isset($_POST['user_name']) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; 227 235 $admin_password = isset($_POST['admin_password']) ? wp_unslash( $_POST['admin_password'] ) : ''; 228 236 $admin_password_check = isset($_POST['admin_password2']) ? wp_unslash( $_POST['admin_password2'] ) : ''; 229 $admin_email = isset( $_POST['admin_email'] 230 $public = isset( $_POST['blog_public'] 237 $admin_email = isset( $_POST['admin_email'] ) ?trim( wp_unslash( $_POST['admin_email'] ) ) : ''; 238 $public = isset( $_POST['blog_public'] ) ? (int) $_POST['blog_public'] : 0; 231 239 232 240 // Check e-mail address. 233 241 $error = false; -
src/wp-admin/network/settings.php
102 102 <input name="admin_email" type="email" id="admin_email" class="regular-text" value="<?php echo esc_attr( get_site_option( 'admin_email' ) ) ?>" /> 103 103 <p class="description"> 104 104 <?php _e( 'This email address will receive notifications. Registration and support emails will also come from this address.' ); ?> 105 </p> 105 </p> 106 106 </td> 107 107 </tr> 108 108 </table> … … 165 165 <?php echo esc_textarea( $limited_email_domains == '' ? '' : implode( "\n", (array) $limited_email_domains ) ); ?></textarea> 166 166 <p class="description"> 167 167 <?php _e( 'If you want to limit site registrations to certain domains. One domain per line.' ) ?> 168 </p> 168 </p> 169 169 </td> 170 170 </tr> 171 171 … … 231 231 <?php echo esc_textarea( get_site_option( 'first_comment' ) ) ?></textarea> 232 232 <p class="description"> 233 233 <?php _e( 'The first comment on a new site.' ) ?> 234 </p> 234 </p> 235 235 </td> 236 236 </tr> 237 237 <tr> … … 273 273 </tr> 274 274 </table> 275 275 276 <?php276 <?php 277 277 $languages = get_available_languages(); 278 278 if ( ! empty( $languages ) ) { 279 $lang = get_site_option( 'WPLANG' ); 280 ?> 281 <h3><?php _e( 'Language Settings' ); ?></h3> 282 <table class="form-table"> 279 ?> 280 <h3><?php _e( 'Language Settings' ); ?></h3> 281 <table class="form-table"> 283 282 <tr> 284 283 <th><label for="WPLANG"><?php _e( 'Default Language' ); ?></label></th> 285 284 <td> 286 <select name="WPLANG" id="WPLANG"> 287 <?php mu_dropdown_languages( $languages, get_site_option( 'WPLANG' ) ); ?> 288 </select> 285 <?php 286 $lang = get_site_option( 'WPLANG' ); 287 if ( ! in_array( $lang, $languages ) ) { 288 $lang = ''; 289 } 290 291 wp_dropdown_languages( array( 292 'name' => 'WPLANG', 293 'id' => 'WPLANG', 294 'selected' => $lang, 295 'languages' => $languages, 296 ) ); 297 ?> 289 298 </td> 290 299 </tr> 291 </table>292 <?php293 } // languages294 ?>300 </table> 301 <?php 302 } 303 ?> 295 304 296 305 <h3><?php _e( 'Menu Settings' ); ?></h3> 297 306 <table id="menu" class="form-table"> … … 324 333 </tr> 325 334 </table> 326 335 327 <?php 336 <?php 328 337 /** 329 338 * Fires at the end of the Network Settings form, before the submit button. 330 339 * -
src/wp-admin/options-general.php
302 302 </select></td> 303 303 </tr> 304 304 <?php do_settings_fields('general', 'default'); ?> 305 305 306 <?php 306 307 if ( $languages ) : 308 ?>307 $languages = get_available_languages(); 308 if ( ! empty( $languages ) ) { 309 ?> 309 310 <tr> 310 <th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language')?></label></th>311 <th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?></label></th> 311 312 <td> 312 <?php wp_dropdown_languages( array( 313 <?php 314 $locale = get_locale(); 315 // Check if current locale is still installed. en_US will fail this test, but that's okay. 316 if ( ! in_array( $locale, $languages ) ) { 317 $locale = ''; 318 } 319 320 wp_dropdown_languages( array( 313 321 'name' => 'WPLANG', 314 322 'id' => 'WPLANG', 315 'selected' => get_option( 'WPLANG' ),323 'selected' => $locale, 316 324 'languages' => $languages, 317 ) ); ?> 325 ) ); 326 327 // Add note about deprecated WPLANG constant. 328 if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && $locale !== WPLANG && is_super_admin() ) { 329 ?> 330 <p class="description"> 331 <?php _e( '<strong>Note:</strong> The <code>WPLANG</code> constant in your <code>wp-config.php</code> file is deprecated.' ); ?> 332 </p> 333 <?php 334 } 335 ?> 318 336 </td> 319 337 </tr> 320 <?php321 endif; 338 <?php 339 } 322 340 ?> 323 341 </table> 324 342 -
src/wp-admin/options.php
151 151 $options = $whitelist_options[ $option_page ]; 152 152 } 153 153 154 // Handle custom date/time formats 154 // Handle custom date/time formats. 155 155 if ( 'general' == $option_page ) { 156 156 if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) 157 157 $_POST['date_format'] = $_POST['date_format_custom']; … … 180 180 } 181 181 update_option( $option, $value ); 182 182 } 183 184 // Switch translation in case WPLANG was changed. 185 $language = get_option( 'WPLANG' ); 186 if ( $language ) { 187 load_default_textdomain( $language ); 188 } else { 189 unload_textdomain( 'default' ); 190 } 183 191 } 184 192 185 193 /** -
src/wp-admin/setup-config.php
26 26 * 27 27 * Set this to error_reporting( -1 ) for debugging 28 28 */ 29 error_reporting( 0);29 error_reporting(-1); 30 30 31 31 define( 'ABSPATH', dirname( dirname( __FILE__ ) ) . '/' ); 32 32 33 33 require( ABSPATH . 'wp-settings.php' ); 34 34 35 require( ABSPATH . 'wp-admin/includes/upgrade.php' ); 35 /** Load WordPress Administration Upgrade API */ 36 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 36 37 38 /** Load WordPress Translation Install API */ 39 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); 40 37 41 nocache_headers(); 38 42 39 43 // Support wp-config-sample.php one level up, for the develop repo. … … 85 89 <?php 86 90 } // end function setup_config_display_header(); 87 91 92 $language = ''; 93 if ( ! empty( $_REQUEST['language'] ) ) { 94 $language = preg_replace( '/[^a-zA-Z_]/', '', $_REQUEST['language'] ); 95 } 88 96 switch($step) { 89 97 case -1: 90 91 if ( empty( $_GET['language'] ) && ( $languages = wp_get_available_translations_from_api() ) ) { 98 if ( empty( $language ) && ( $languages = wp_get_available_translations() ) ) { 92 99 setup_config_display_header( 'language-chooser' ); 93 100 echo '<form id="setup" method="post" action="?step=0">'; 94 101 wp_install_language_form( $languages ); … … 99 106 // Deliberately fall through if we can't reach the translations API. 100 107 101 108 case 0: 102 if ( ! empty( $ _REQUEST['language']) ) {103 $loaded_language = wp_ install_download_language_pack( $_REQUEST['language']);109 if ( ! empty( $language ) ) { 110 $loaded_language = wp_download_language_pack( $language ); 104 111 if ( $loaded_language ) { 105 wp_install_load_language( $loaded_language );112 load_default_textdomain( $loaded_language ); 106 113 } 107 114 } 108 115 … … 136 143 break; 137 144 138 145 case 1: 139 $loaded_language = wp_install_load_language( $_REQUEST['language']);146 load_default_textdomain( $language ); 140 147 setup_config_display_header(); 141 148 ?> 142 149 <form method="post" action="setup-config.php?step=2"> … … 169 176 </tr> 170 177 </table> 171 178 <?php if ( isset( $_GET['noapi'] ) ) { ?><input name="noapi" type="hidden" value="1" /><?php } ?> 172 <input type="hidden" name="language" value="<?php echo esc_attr( $l oaded_language ); ?>" />179 <input type="hidden" name="language" value="<?php echo esc_attr( $language ); ?>" /> 173 180 <p class="step"><input name="submit" type="submit" value="<?php echo htmlspecialchars( __( 'Submit' ), ENT_QUOTES ); ?>" class="button button-large" /></p> 174 181 </form> 175 182 <?php 176 183 break; 177 184 178 185 case 2: 179 $loaded_language = wp_install_load_language( $_REQUEST['language']);186 load_default_textdomain( $language ); 180 187 $dbname = trim( wp_unslash( $_POST[ 'dbname' ] ) ); 181 188 $uname = trim( wp_unslash( $_POST[ 'uname' ] ) ); 182 189 $pwd = trim( wp_unslash( $_POST[ 'pwd' ] ) ); … … 189 196 $step_1 .= '&noapi'; 190 197 } 191 198 192 if ( $l oaded_language ) {193 $step_1 .= '&language=' . $l oaded_language;194 $install .= '?language=' . $l oaded_language;199 if ( $language ) { 200 $step_1 .= '&language=' . $language; 201 $install .= '?language=' . $language; 195 202 } else { 196 203 $install .= '?language=en_US'; 197 204 } -
src/wp-includes/l10n.php
24 24 * @return string The locale of the blog or from the 'locale' hook. 25 25 */ 26 26 function get_locale() { 27 global $locale ;27 global $locale, $wp_local_package; 28 28 29 29 if ( isset( $locale ) ) { 30 30 /** … … 38 38 } 39 39 40 40 // WPLANG is defined in wp-config. 41 if ( defined( 'WPLANG' ) ) 41 if ( defined( 'WPLANG' ) ) { 42 42 $locale = WPLANG; 43 } 43 44 45 if ( isset( $wp_local_package ) ) { 46 $locale = $wp_local_package; 47 } 48 44 49 // If multisite, check options. 45 50 if ( is_multisite() ) { 46 51 // Don't check blog option when installing. 47 if ( defined( 'WP_INSTALLING' ) || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) 48 $ms_locale = get_site_option('WPLANG'); 52 if ( defined( 'WP_INSTALLING' ) || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) { 53 $ms_locale = get_site_option( 'WPLANG' ); 54 } 49 55 50 if ( $ms_locale !== false ) 56 if ( $ms_locale !== false ) { 51 57 $locale = $ms_locale; 52 } elseif ( ! defined( 'WP_INSTALLING' ) ) { 58 } 59 } else { 53 60 $db_locale = get_option( 'WPLANG' ); 54 if ( $db_locale ) {61 if ( $db_locale !== false ) { 55 62 $locale = $db_locale; 56 63 } 57 64 } 58 65 59 if ( empty( $locale ) ) 66 if ( empty( $locale ) ) { 60 67 $locale = 'en_US'; 68 } 61 69 62 70 /** This filter is documented in wp-includes/l10n.php */ 63 71 return apply_filters( 'locale', $locale ); … … 523 531 * @see load_textdomain() 524 532 * 525 533 * @since 1.5.0 534 * 535 * @param string $locale Optional. Locale to load. Defaults to get_locale(). 526 536 */ 527 function load_default_textdomain() { 528 $locale = get_locale(); 537 function load_default_textdomain( $locale = null ) { 538 if ( null === $locale ) { 539 $locale = get_locale(); 540 } 529 541 530 load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" ); 542 // Unload previously loaded strings so we can switch translations. 543 unload_textdomain( 'default' ); 531 544 545 $return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" ); 546 532 547 if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists( WP_LANG_DIR . "/admin-$locale.mo" ) ) { 533 548 load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" ); 534 return ;549 return $return; 535 550 } 536 551 537 if ( is_admin() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) )552 if ( is_admin() || defined( 'WP_INSTALLING' ) || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) { 538 553 load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" ); 554 } 539 555 540 556 if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) 541 557 load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" ); 542 558 559 return $return; 543 560 } 544 561 545 562 /** … … 818 835 } 819 836 820 837 /** 821 * Language selector. More to come.838 * Language selector. 822 839 * 823 840 * @since 4.0.0 824 841 * 825 842 * @see get_available_languages() 843 * @see wp_get_available_translations() 826 844 * 827 845 * @param array $args Optional arguments. Default empty array. 828 846 */ 829 847 function wp_dropdown_languages( $args = array() ) { 830 if ( isset( $args['languages'] ) ) { 831 $languages = $args['languages']; 832 } else { 833 $languages = get_available_languages(); 848 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); 849 850 $args = wp_parse_args( $args, array( 851 'id' => '', 852 'name' => '', 853 'languages' => array(), 854 'selected' => '' 855 ) ); 856 857 if ( empty( $args['languages'] ) ) { 858 return false; 834 859 } 835 860 861 $translations = wp_get_available_translations(); 862 863 /* 864 * $args['languages'] should only contain the locales. Find the locale in 865 * $translations to get the native name. Fall back to locale. 866 */ 867 $languages = array(); 868 foreach ( $args['languages'] as $locale ) { 869 if ( isset( $translations[ $locale ] ) ) { 870 $translation = $translations[ $locale ]; 871 $languages[] = $translation; 872 } else { 873 $languages[] = array( 874 'language' => $locale, 875 'native_name' => $locale, 876 'lang' => '', 877 ); 878 } 879 } 880 836 881 printf( '<select name="%s" id="%s">', esc_attr( $args['name'] ), esc_attr( $args['id'] ) ); 837 echo '<option value="">en_US</option>'; 882 883 // List installed languages. 884 echo '<option value="">English (United States)</option>'; 838 885 foreach ( $languages as $language ) { 839 $selected = selected( $language, $args['selected'], false ); 840 echo '<option value="' . esc_attr( $language ) .'"' . $selected . '>' . $language . '</option>'; 886 $selected = selected( $language['language'], $args['selected'], false ); 887 printf( 888 '<option value="%s" lang="%s"%s>%s</option>', 889 esc_attr( $language['language'] ), 890 esc_attr( $language['iso'][1] ), 891 $selected, 892 esc_html( $language['native_name'] ) 893 ); 841 894 } 895 842 896 echo '</select>'; 843 897 } -
src/wp-includes/version.php
11 11 * 12 12 * @global int $wp_db_version 13 13 */ 14 $wp_db_version = 29 188;14 $wp_db_version = 29600; 15 15 16 16 /** 17 17 * Holds the TinyMCE version -
wp-config-sample.php
62 62 $table_prefix = 'wp_'; 63 63 64 64 /** 65 * WordPress Localized Language, defaults to English.66 *67 * Change this to localize WordPress. A corresponding MO file for the chosen68 * language must be installed to wp-content/languages. For example, install69 * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German70 * language support.71 */72 define('WPLANG', '');73 74 /**75 65 * For developers: WordPress debugging mode. 76 66 * 77 67 * Change this to true to enable the display of notices during development.