Index: trunk/src/wp-admin/includes/upgrade.php =================================================================== --- trunk/src/wp-admin/includes/upgrade.php (revision 29372) +++ trunk/src/wp-admin/includes/upgrade.php (revision 29630) @@ -437,4 +437,7 @@ if ( $wp_current_db_version < 26691 ) upgrade_380(); + + if ( $wp_current_db_version < 29630 ) + upgrade_400(); maybe_disable_link_manager(); @@ -1305,4 +1308,23 @@ } } + +/** + * Execute changes made in WordPress 4.0.0. + * + * @since 4.0.0 + */ +function upgrade_400() { + global $wp_current_db_version; + if ( $wp_current_db_version < 29630 ) { + if ( ! is_multisite() && false === get_option( 'WPLANG' ) ) { + if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && in_array( WPLANG, get_available_languages() ) ) { + update_option( 'WPLANG', WPLANG ); + } else { + update_option( 'WPLANG', '' ); + } + } + } +} + /** * Execute network level changes @@ -1420,5 +1442,5 @@ function maybe_create_table($table_name, $create_ddl) { global $wpdb; - + $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $table_name ) ); @@ -2193,144 +2215,2 @@ } endif; - -/** - * Output the input fields for the language selection form on the installation screen. - * - * @since 4.0.0 - * - * @see wp_get_available_translations_from_api() - * - * @param array $languages Array of available languages (populated via the Translations API). - */ -function wp_install_language_form( $languages ) { - $installed_languages = get_available_languages(); - - echo "\n"; - echo "\n"; - echo '
'; -} - -/** - * Get available translations from the WordPress.org API. - * - * @since 4.0.0 - * - * @see wp_remote_post() - * - * @return array Array of translations, each an array of data. - */ -function wp_get_available_translations_from_api() { - $url = 'http://api.wordpress.org/translations/core/1.0/'; - if ( wp_http_supports( array( 'ssl' ) ) ) { - $url = set_url_scheme( $url, 'https' ); - } - - $options = array( - 'timeout' => 3, - 'body' => array( 'version' => $GLOBALS['wp_version'] ), - ); - - $response = wp_remote_post( $url, $options ); - $body = wp_remote_retrieve_body( $response ); - if ( $body && $body = json_decode( $body, true ) ) { - $translations = array(); - // Key the array with the language code for now - foreach ( $body['translations'] as $translation ) { - $translations[ $translation['language'] ] = $translation; - } - return $translations; - } - return false; -} - -/** - * Download a language pack. - * - * @since 4.0.0 - * - * @see wp_get_available_translations_from_api() - * - * @param string $download Language code to download. - * @return string|bool Returns the language code if successfully downloaded - * (or already installed), or false on failure. - */ -function wp_install_download_language_pack( $download ) { - // Check if the translation is already installed. - if ( in_array( $download, get_available_languages() ) ) { - return $download; - } - - // Confirm the translation is one we can download. - $translations = wp_get_available_translations_from_api(); - if ( ! $translations ) { - return false; - } - foreach ( $translations as $translation ) { - if ( $translation['language'] === $download ) { - $translation_to_load = true; - break; - } - } - - if ( empty( $translation_to_load ) ) { - return false; - } - $translation = (object) $translation; - - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; - $skin = new Automatic_Upgrader_Skin; - $upgrader = new Language_Pack_Upgrader( $skin ); - $translation->type = 'core'; - /** - * @todo failures (such as non-direct FS) - */ - $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) ); - return $translation->language; -} - -/** - * Load a translation during the install process. - * - * @since 4.0.0 - * - * @see load_textdomain() - * - * @param string $translation Translation to load. - * @return string|bool Returns the language code if successfully loaded, - * or false on failure. - */ -function wp_install_load_language( $translation ) { - if ( ! empty( $translation ) ) { - if ( in_array( $translation, get_available_languages() ) ) { - $translation_to_load = $translation; - } - } - - if ( empty( $translation_to_load ) ) { - return false; - } - - unload_textdomain( 'default' ); // Start over. - load_textdomain( 'default', WP_LANG_DIR . "/{$translation_to_load}.mo" ); - load_textdomain( 'default', WP_LANG_DIR . "/admin-{$translation_to_load}.mo" ); - return $translation_to_load; -}